aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2011-08-27 09:43:54 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2011-08-27 10:06:11 -0400
commit7b1bb388bc879ffcc6c69b567816d5c354afe42b (patch)
tree5a217fdfb0b5e5a327bdcd624506337c1ae1fe32 /include
parent7d754596756240fa918b94cd0c3011c77a638987 (diff)
parent02f8c6aee8df3cdc935e9bdd4f2d020306035dbe (diff)
Merge 'Linux v3.0' into Litmus
Some notes: * Litmus^RT scheduling class is the topmost scheduling class (above stop_sched_class). * scheduler_ipi() function (e.g., in smp_reschedule_interrupt()) may increase IPI latencies. * Added path into schedule() to quickly re-evaluate scheduling decision without becoming preemptive again. This used to be a standard path before the removal of BKL. Conflicts: Makefile arch/arm/kernel/calls.S arch/arm/kernel/smp.c arch/x86/include/asm/unistd_32.h arch/x86/kernel/smp.c arch/x86/kernel/syscall_table_32.S include/linux/hrtimer.h kernel/printk.c kernel/sched.c kernel/sched_fair.c
Diffstat (limited to 'include')
-rw-r--r--include/acpi/acexcep.h2
-rw-r--r--include/acpi/acnames.h2
-rw-r--r--include/acpi/acoutput.h14
-rw-r--r--include/acpi/acpi.h2
-rw-r--r--include/acpi/acpi_bus.h29
-rw-r--r--include/acpi/acpi_drivers.h2
-rw-r--r--include/acpi/acpiosxf.h20
-rw-r--r--include/acpi/acpixf.h29
-rw-r--r--include/acpi/acrestyp.h2
-rw-r--r--include/acpi/actbl.h20
-rw-r--r--include/acpi/actbl1.h4
-rw-r--r--include/acpi/actbl2.h66
-rw-r--r--include/acpi/actypes.h109
-rw-r--r--include/acpi/apei.h11
-rw-r--r--include/acpi/platform/acenv.h8
-rw-r--r--include/acpi/platform/acgcc.h4
-rw-r--r--include/acpi/platform/aclinux.h27
-rw-r--r--include/acpi/processor.h13
-rw-r--r--include/acpi/video.h5
-rw-r--r--include/asm-generic/atomic.h39
-rw-r--r--include/asm-generic/audit_change_attr.h8
-rw-r--r--include/asm-generic/audit_dir_write.h14
-rw-r--r--include/asm-generic/audit_read.h5
-rw-r--r--include/asm-generic/audit_write.h2
-rw-r--r--include/asm-generic/bitops.h3
-rw-r--r--include/asm-generic/bitops/ext2-atomic.h4
-rw-r--r--include/asm-generic/bitops/ext2-non-atomic.h20
-rw-r--r--include/asm-generic/bitops/find.h41
-rw-r--r--include/asm-generic/bitops/le.h96
-rw-r--r--include/asm-generic/bitops/minix-le.h17
-rw-r--r--include/asm-generic/bitops/minix.h15
-rw-r--r--include/asm-generic/bug.h38
-rw-r--r--include/asm-generic/cacheflush.h5
-rw-r--r--include/asm-generic/cmpxchg-local.h1
-rw-r--r--include/asm-generic/cputime.h9
-rw-r--r--include/asm-generic/errno.h2
-rw-r--r--include/asm-generic/fcntl.h6
-rw-r--r--include/asm-generic/ftrace.h16
-rw-r--r--include/asm-generic/futex.h7
-rw-r--r--include/asm-generic/gpio.h24
-rw-r--r--include/asm-generic/hardirq.h2
-rw-r--r--include/asm-generic/io.h77
-rw-r--r--include/asm-generic/ioctls.h4
-rw-r--r--include/asm-generic/irq_regs.h8
-rw-r--r--include/asm-generic/irqflags.h52
-rw-r--r--include/asm-generic/kdebug.h2
-rw-r--r--include/asm-generic/mman-common.h3
-rw-r--r--include/asm-generic/percpu.h14
-rw-r--r--include/asm-generic/pgtable.h233
-rw-r--r--include/asm-generic/ptrace.h74
-rw-r--r--include/asm-generic/resource.h2
-rw-r--r--include/asm-generic/sections.h1
-rw-r--r--include/asm-generic/siginfo.h2
-rw-r--r--include/asm-generic/sizes.h47
-rw-r--r--include/asm-generic/stat.h14
-rw-r--r--include/asm-generic/system.h20
-rw-r--r--include/asm-generic/tlb.h156
-rw-r--r--include/asm-generic/types.h27
-rw-r--r--include/asm-generic/uaccess.h8
-rw-r--r--include/asm-generic/unistd.h227
-rw-r--r--include/asm-generic/user.h4
-rw-r--r--include/asm-generic/vmlinux.lds.h159
-rw-r--r--include/asm-generic/xor.h2
-rw-r--r--include/crypto/cryptd.h24
-rw-r--r--include/crypto/gf128mul.h4
-rw-r--r--include/crypto/if_alg.h92
-rw-r--r--include/crypto/padlock.h29
-rw-r--r--include/crypto/scatterwalk.h15
-rw-r--r--include/drm/Kbuild1
-rw-r--r--include/drm/drm.h17
-rw-r--r--include/drm/drmP.h324
-rw-r--r--include/drm/drm_crtc.h46
-rw-r--r--include/drm/drm_crtc_helper.h8
-rw-r--r--include/drm/drm_dp_helper.h8
-rw-r--r--include/drm/drm_edid.h25
-rw-r--r--include/drm/drm_fb_helper.h19
-rw-r--r--include/drm/drm_hashtab.h6
-rw-r--r--include/drm/drm_mm.h56
-rw-r--r--include/drm/drm_mode.h31
-rw-r--r--include/drm/drm_pciids.h75
-rw-r--r--include/drm/drm_usb.h15
-rw-r--r--include/drm/i830_drm.h342
-rw-r--r--include/drm/i915_drm.h21
-rw-r--r--include/drm/intel-gtt.h41
-rw-r--r--include/drm/mga_drm.h2
-rw-r--r--include/drm/nouveau_drm.h13
-rw-r--r--include/drm/radeon_drm.h7
-rw-r--r--include/drm/savage_drm.h2
-rw-r--r--include/drm/ttm/ttm_bo_api.h83
-rw-r--r--include/drm/ttm/ttm_bo_driver.h224
-rw-r--r--include/drm/ttm/ttm_execbuf_util.h11
-rw-r--r--include/drm/ttm/ttm_page_alloc.h8
-rw-r--r--include/drm/vmwgfx_drm.h3
-rw-r--r--include/keys/ceph-type.h8
-rw-r--r--include/keys/encrypted-type.h29
-rw-r--r--include/keys/rxrpc-type.h1
-rw-r--r--include/keys/trusted-type.h31
-rw-r--r--include/linux/Kbuild26
-rw-r--r--include/linux/acpi.h23
-rw-r--r--include/linux/acpi_io.h15
-rw-r--r--include/linux/acpi_pmtmr.h2
-rw-r--r--include/linux/aer.h24
-rw-r--r--include/linux/agp_backend.h2
-rw-r--r--include/linux/alarmtimer.h40
-rw-r--r--include/linux/altera_uart.h5
-rw-r--r--include/linux/amba/bus.h31
-rw-r--r--include/linux/amba/clcd.h92
-rw-r--r--include/linux/amba/mmci.h19
-rw-r--r--include/linux/amba/pl022.h13
-rw-r--r--include/linux/amba/pl08x.h223
-rw-r--r--include/linux/amba/serial.h36
-rw-r--r--include/linux/ata.h209
-rw-r--r--include/linux/ath9k_platform.h7
-rw-r--r--include/linux/atmdev.h9
-rw-r--r--include/linux/atomic.h50
-rw-r--r--include/linux/audit.h12
-rw-r--r--include/linux/auto_fs4.h2
-rw-r--r--include/linux/average.h30
-rw-r--r--include/linux/backing-dev.h19
-rw-r--r--include/linux/backlight.h9
-rw-r--r--include/linux/basic_mmio_gpio.h77
-rw-r--r--include/linux/bch.h79
-rw-r--r--include/linux/bcma/bcma.h224
-rw-r--r--include/linux/bcma/bcma_driver_chipcommon.h302
-rw-r--r--include/linux/bcma/bcma_driver_pci.h89
-rw-r--r--include/linux/bcma/bcma_regs.h34
-rw-r--r--include/linux/bfin_mac.h30
-rw-r--r--include/linux/binfmts.h6
-rw-r--r--include/linux/bio.h20
-rw-r--r--include/linux/bit_spinlock.h12
-rw-r--r--include/linux/bitmap.h5
-rw-r--r--include/linux/bitops.h60
-rw-r--r--include/linux/blk_types.h19
-rw-r--r--include/linux/blkdev.h323
-rw-r--r--include/linux/blktrace_api.h4
-rw-r--r--include/linux/bootmem.h29
-rw-r--r--include/linux/bsearch.h9
-rw-r--r--include/linux/buffer_head.h20
-rw-r--r--include/linux/c2port.h3
-rw-r--r--include/linux/caif/Kbuild2
-rw-r--r--include/linux/can/core.h13
-rw-r--r--include/linux/can/error.h2
-rw-r--r--include/linux/can/netlink.h2
-rw-r--r--include/linux/can/platform/mcp251x.h6
-rw-r--r--include/linux/capability.h66
-rw-r--r--include/linux/cdev.h2
-rw-r--r--include/linux/cdk.h2
-rw-r--r--include/linux/cdrom.h6
-rw-r--r--include/linux/ceph/auth.h92
-rw-r--r--include/linux/ceph/buffer.h39
-rw-r--r--include/linux/ceph/ceph_debug.h38
-rw-r--r--include/linux/ceph/ceph_frag.h109
-rw-r--r--include/linux/ceph/ceph_fs.h751
-rw-r--r--include/linux/ceph/ceph_hash.h13
-rw-r--r--include/linux/ceph/debugfs.h33
-rw-r--r--include/linux/ceph/decode.h201
-rw-r--r--include/linux/ceph/libceph.h249
-rw-r--r--include/linux/ceph/mdsmap.h62
-rw-r--r--include/linux/ceph/messenger.h257
-rw-r--r--include/linux/ceph/mon_client.h122
-rw-r--r--include/linux/ceph/msgpool.h25
-rw-r--r--include/linux/ceph/msgr.h175
-rw-r--r--include/linux/ceph/osd_client.h290
-rw-r--r--include/linux/ceph/osdmap.h130
-rw-r--r--include/linux/ceph/pagelist.h75
-rw-r--r--include/linux/ceph/rados.h426
-rw-r--r--include/linux/ceph/types.h29
-rw-r--r--include/linux/cfag12864b.h2
-rw-r--r--include/linux/cgroup.h29
-rw-r--r--include/linux/cgroup_subsys.h10
-rw-r--r--include/linux/cleancache.h122
-rw-r--r--include/linux/clkdev.h36
-rw-r--r--include/linux/clockchips.h56
-rw-r--r--include/linux/clocksource.h43
-rw-r--r--include/linux/cm4000_cs.h2
-rw-r--r--include/linux/cnt32_to_63.h20
-rw-r--r--include/linux/coda_cache.h22
-rw-r--r--include/linux/coda_fs_i.h53
-rw-r--r--include/linux/coda_linux.h95
-rw-r--r--include/linux/coda_psdev.h4
-rw-r--r--include/linux/compaction.h20
-rw-r--r--include/linux/compat.h238
-rw-r--r--include/linux/compiler-gcc.h12
-rw-r--r--include/linux/compiler-gcc3.h8
-rw-r--r--include/linux/compiler-gcc4.h10
-rw-r--r--include/linux/compiler.h4
-rw-r--r--include/linux/completion.h18
-rw-r--r--include/linux/configfs.h2
-rw-r--r--include/linux/connector.h36
-rw-r--r--include/linux/console.h14
-rw-r--r--include/linux/cper.h90
-rw-r--r--include/linux/cpu.h5
-rw-r--r--include/linux/cpu_rmap.h73
-rw-r--r--include/linux/cpufreq.h63
-rw-r--r--include/linux/cpuidle.h6
-rw-r--r--include/linux/cpumask.h15
-rw-r--r--include/linux/cpuset.h2
-rw-r--r--include/linux/cramfs_fs.h2
-rw-r--r--include/linux/crash_dump.h14
-rw-r--r--include/linux/crc32.h2
-rw-r--r--include/linux/cred.h14
-rw-r--r--include/linux/crush/crush.h180
-rw-r--r--include/linux/crush/hash.h17
-rw-r--r--include/linux/crush/mapper.h20
-rw-r--r--include/linux/cs5535.h6
-rw-r--r--include/linux/davinci_emac.h17
-rw-r--r--include/linux/dcache.h258
-rw-r--r--include/linux/dcbnl.h295
-rw-r--r--include/linux/dccp.h35
-rw-r--r--include/linux/dcookies.h2
-rw-r--r--include/linux/debug_locks.h5
-rw-r--r--include/linux/debugobjects.h5
-rw-r--r--include/linux/decompress/inflate.h3
-rw-r--r--include/linux/decompress/mm.h8
-rw-r--r--include/linux/decompress/unxz.h19
-rw-r--r--include/linux/device-mapper.h20
-rw-r--r--include/linux/device.h193
-rw-r--r--include/linux/device_cgroup.h10
-rw-r--r--include/linux/dlm.h4
-rw-r--r--include/linux/dlm_plock.h6
-rw-r--r--include/linux/dm-io.h3
-rw-r--r--include/linux/dm-ioctl.h18
-rw-r--r--include/linux/dm-kcopyd.h3
-rw-r--r--include/linux/dm-log-userspace.h13
-rw-r--r--include/linux/dma_remapping.h4
-rw-r--r--include/linux/dmaengine.h75
-rw-r--r--include/linux/dmar.h33
-rw-r--r--include/linux/dmi.h47
-rw-r--r--include/linux/drbd.h53
-rw-r--r--include/linux/drbd_limits.h51
-rw-r--r--include/linux/drbd_nl.h19
-rw-r--r--include/linux/drbd_tag_magic.h3
-rw-r--r--include/linux/dvb/frontend.h20
-rw-r--r--include/linux/dvb/version.h2
-rw-r--r--include/linux/dw_dmac.h45
-rw-r--r--include/linux/dynamic_debug.h33
-rw-r--r--include/linux/early_res.h23
-rw-r--r--include/linux/edac.h4
-rw-r--r--include/linux/efi.h38
-rw-r--r--include/linux/elevator.h23
-rw-r--r--include/linux/elf.h1
-rw-r--r--include/linux/err.h8
-rw-r--r--include/linux/etherdevice.h37
-rw-r--r--include/linux/ethtool.h616
-rw-r--r--include/linux/eventpoll.h2
-rw-r--r--include/linux/exportfs.h24
-rw-r--r--include/linux/ext3_fs.h25
-rw-r--r--include/linux/falloc.h1
-rw-r--r--include/linux/fanotify.h46
-rw-r--r--include/linux/fb.h21
-rw-r--r--include/linux/fcntl.h2
-rw-r--r--include/linux/fdreg.h2
-rw-r--r--include/linux/fdtable.h6
-rw-r--r--include/linux/fec.h3
-rw-r--r--include/linux/file.h4
-rw-r--r--include/linux/filter.h139
-rw-r--r--include/linux/firewire-cdev.h4
-rw-r--r--include/linux/firewire.h15
-rw-r--r--include/linux/firmware-map.h1
-rw-r--r--include/linux/firmware.h4
-rw-r--r--include/linux/flex_array.h6
-rw-r--r--include/linux/freezer.h2
-rw-r--r--include/linux/fs.h379
-rw-r--r--include/linux/fs_struct.h3
-rw-r--r--include/linux/fscache-cache.h14
-rw-r--r--include/linux/fscache.h27
-rw-r--r--include/linux/fsl-diu-fb.h7
-rw-r--r--include/linux/fsl_devices.h34
-rw-r--r--include/linux/fsnotify.h37
-rw-r--r--include/linux/fsnotify_backend.h39
-rw-r--r--include/linux/ftrace.h37
-rw-r--r--include/linux/ftrace_event.h37
-rw-r--r--include/linux/fuse.h26
-rw-r--r--include/linux/gameport.h4
-rw-r--r--include/linux/genalloc.h25
-rw-r--r--include/linux/generic_acl.h2
-rw-r--r--include/linux/genhd.h117
-rw-r--r--include/linux/gfp.h142
-rw-r--r--include/linux/gpio-fan.h36
-rw-r--r--include/linux/gpio-i2cmux.h38
-rw-r--r--include/linux/gpio.h35
-rw-r--r--include/linux/gpio_keys.h10
-rw-r--r--include/linux/hardirq.h19
-rw-r--r--include/linux/hid-roccat.h29
-rw-r--r--include/linux/hid.h91
-rw-r--r--include/linux/hiddev.h4
-rw-r--r--include/linux/hidraw.h3
-rw-r--r--include/linux/highmem.h78
-rw-r--r--include/linux/hp_sdc.h2
-rw-r--r--include/linux/hrtimer.h90
-rw-r--r--include/linux/htirq.h5
-rw-r--r--include/linux/huge_mm.h176
-rw-r--r--include/linux/hugetlb.h24
-rw-r--r--include/linux/hugetlb_inline.h2
-rw-r--r--include/linux/hw_breakpoint.h4
-rw-r--r--include/linux/hwspinlock.h292
-rw-r--r--include/linux/i2c-id.h59
-rw-r--r--include/linux/i2c-omap.h5
-rw-r--r--include/linux/i2c-tegra.h25
-rw-r--r--include/linux/i2c.h63
-rw-r--r--include/linux/i2c/adp5588.h36
-rw-r--r--include/linux/i2c/adp8870.h153
-rw-r--r--include/linux/i2c/ads1015.h36
-rw-r--r--include/linux/i2c/apds990x.h79
-rw-r--r--include/linux/i2c/atmel_mxt_ts.h (renamed from include/linux/i2c/qt602240_ts.h)34
-rw-r--r--include/linux/i2c/bh1770glc.h53
-rw-r--r--include/linux/i2c/ds620.h21
-rw-r--r--include/linux/i2c/i2c-sh_mobile.h10
-rw-r--r--include/linux/i2c/max6639.h14
-rw-r--r--include/linux/i2c/mcs.h1
-rw-r--r--include/linux/i2c/mpr121_touchkey.h20
-rw-r--r--include/linux/i2c/pmbus.h45
-rw-r--r--include/linux/i2c/pxa-i2c.h82
-rw-r--r--include/linux/i2c/tsc2007.h7
-rw-r--r--include/linux/i2c/twl.h146
-rw-r--r--include/linux/i2c/twl4030-madc.h141
-rw-r--r--include/linux/i2o.h2
-rw-r--r--include/linux/icmpv6.h4
-rw-r--r--include/linux/ide.h2
-rw-r--r--include/linux/idr.h12
-rw-r--r--include/linux/ieee80211.h124
-rw-r--r--include/linux/if.h9
-rw-r--r--include/linux/if_alg.h40
-rw-r--r--include/linux/if_bonding.h3
-rw-r--r--include/linux/if_bridge.h4
-rw-r--r--include/linux/if_ether.h8
-rw-r--r--include/linux/if_infiniband.h2
-rw-r--r--include/linux/if_link.h30
-rw-r--r--include/linux/if_macvlan.h43
-rw-r--r--include/linux/if_packet.h3
-rw-r--r--include/linux/if_ppp.h16
-rw-r--r--include/linux/if_pppox.h52
-rw-r--r--include/linux/if_vlan.h93
-rw-r--r--include/linux/igmp.h20
-rw-r--r--include/linux/ima.h6
-rw-r--r--include/linux/in.h19
-rw-r--r--include/linux/in6.h4
-rw-r--r--include/linux/inetdevice.h35
-rw-r--r--include/linux/init.h27
-rw-r--r--include/linux/init_task.h51
-rw-r--r--include/linux/input-polldev.h4
-rw-r--r--include/linux/input.h142
-rw-r--r--include/linux/input/ad714x.h3
-rw-r--r--include/linux/input/adp5589.h213
-rw-r--r--include/linux/input/as5011.h20
-rw-r--r--include/linux/input/bu21013.h40
-rw-r--r--include/linux/input/cma3000.h59
-rw-r--r--include/linux/input/matrix_keypad.h6
-rw-r--r--include/linux/input/mt.h63
-rw-r--r--include/linux/input/pmic8xxx-keypad.h52
-rw-r--r--include/linux/input/pmic8xxx-pwrkey.h31
-rw-r--r--include/linux/input/sh_keysc.h2
-rw-r--r--include/linux/intel-gtt.h20
-rw-r--r--include/linux/intel_mid_dma.h16
-rw-r--r--include/linux/interrupt.h101
-rw-r--r--include/linux/io-mapping.h14
-rw-r--r--include/linux/iocontext.h3
-rw-r--r--include/linux/ioport.h1
-rw-r--r--include/linux/ip_vs.h23
-rw-r--r--include/linux/ipc_namespace.h10
-rw-r--r--include/linux/ipmi.h42
-rw-r--r--include/linux/ipmi_smi.h10
-rw-r--r--include/linux/ipv6.h6
-rw-r--r--include/linux/irq.h884
-rw-r--r--include/linux/irq_work.h20
-rw-r--r--include/linux/irqdesc.h175
-rw-r--r--include/linux/irqflags.h107
-rw-r--r--include/linux/irqnr.h7
-rw-r--r--include/linux/irqreturn.h6
-rw-r--r--include/linux/isdn/hdlc.h2
-rw-r--r--include/linux/ixjuser.h2
-rw-r--r--include/linux/jbd2.h60
-rw-r--r--include/linux/jhash.h183
-rw-r--r--include/linux/jiffies.h3
-rw-r--r--include/linux/journal-head.h7
-rw-r--r--include/linux/jump_label.h102
-rw-r--r--include/linux/kallsyms.h7
-rw-r--r--include/linux/kbd_kern.h5
-rw-r--r--include/linux/kd.h1
-rw-r--r--include/linux/kdb.h51
-rw-r--r--include/linux/kernel.h454
-rw-r--r--include/linux/kernel_stat.h29
-rw-r--r--include/linux/kexec.h1
-rw-r--r--include/linux/key-type.h14
-rw-r--r--include/linux/key.h23
-rw-r--r--include/linux/keyctl.h2
-rw-r--r--include/linux/kfifo.h28
-rw-r--r--include/linux/kgdb.h14
-rw-r--r--include/linux/khugepaged.h67
-rw-r--r--include/linux/klist.h2
-rw-r--r--include/linux/kmemcheck.h2
-rw-r--r--include/linux/kmod.h12
-rw-r--r--include/linux/kmsg_dump.h5
-rw-r--r--include/linux/kobject.h12
-rw-r--r--include/linux/kobject_ns.h10
-rw-r--r--include/linux/kprobes.h8
-rw-r--r--include/linux/kref.h2
-rw-r--r--include/linux/kthread.h61
-rw-r--r--include/linux/ktime.h4
-rw-r--r--include/linux/kvm.h19
-rw-r--r--include/linux/kvm_host.h185
-rw-r--r--include/linux/kvm_para.h7
-rw-r--r--include/linux/kvm_types.h7
-rw-r--r--include/linux/led-lm3530.h107
-rw-r--r--include/linux/leds-lp5521.h48
-rw-r--r--include/linux/leds-lp5523.h (renamed from include/linux/spi/wl12xx.h)38
-rw-r--r--include/linux/leds-pca9532.h3
-rw-r--r--include/linux/leds-regulator.h2
-rw-r--r--include/linux/leds.h56
-rw-r--r--include/linux/libata.h87
-rw-r--r--include/linux/linkage.h4
-rw-r--r--include/linux/lis3lv02d.h55
-rw-r--r--include/linux/list.h54
-rw-r--r--include/linux/list_bl.h156
-rw-r--r--include/linux/lockd/debug.h10
-rw-r--r--include/linux/lockd/lockd.h7
-rw-r--r--include/linux/lockdep.h35
-rw-r--r--include/linux/lru_cache.h14
-rw-r--r--include/linux/lsm_audit.h11
-rw-r--r--include/linux/magic.h4
-rw-r--r--include/linux/marvell_phy.h3
-rw-r--r--include/linux/math64.h12
-rw-r--r--include/linux/mbcache.h11
-rw-r--r--include/linux/mdio.h5
-rw-r--r--include/linux/media.h132
-rw-r--r--include/linux/memblock.h175
-rw-r--r--include/linux/memcontrol.h102
-rw-r--r--include/linux/memory.h9
-rw-r--r--include/linux/memory_hotplug.h30
-rw-r--r--include/linux/mempolicy.h7
-rw-r--r--include/linux/mfd/88pm860x.h28
-rw-r--r--include/linux/mfd/ab8500.h137
-rw-r--r--include/linux/mfd/ab8500/gpadc.h32
-rw-r--r--include/linux/mfd/ab8500/gpio.h21
-rw-r--r--include/linux/mfd/ab8500/sysctrl.h254
-rw-r--r--include/linux/mfd/abx500.h11
-rw-r--r--include/linux/mfd/asic3.h23
-rw-r--r--include/linux/mfd/core.h62
-rw-r--r--include/linux/mfd/db5500-prcmu.h45
-rw-r--r--include/linux/mfd/db8500-prcmu.h978
-rw-r--r--include/linux/mfd/ds1wm.h7
-rw-r--r--include/linux/mfd/max8997-private.h364
-rw-r--r--include/linux/mfd/max8997.h117
-rw-r--r--include/linux/mfd/max8998-private.h131
-rw-r--r--include/linux/mfd/max8998.h42
-rw-r--r--include/linux/mfd/mc13783.h308
-rw-r--r--include/linux/mfd/mc13892.h39
-rw-r--r--include/linux/mfd/mc13xxx.h153
-rw-r--r--include/linux/mfd/pcf50633/core.h7
-rw-r--r--include/linux/mfd/pm8xxx/core.h81
-rw-r--r--include/linux/mfd/pm8xxx/irq.h59
-rw-r--r--include/linux/mfd/pm8xxx/pm8921.h31
-rw-r--r--include/linux/mfd/stmpe.h6
-rw-r--r--include/linux/mfd/tc35892.h132
-rw-r--r--include/linux/mfd/tc3589x.h195
-rw-r--r--include/linux/mfd/ti_ssp.h93
-rw-r--r--include/linux/mfd/tmio.h28
-rw-r--r--include/linux/mfd/tps6105x.h101
-rw-r--r--include/linux/mfd/tps6586x.h31
-rw-r--r--include/linux/mfd/tps65910.h800
-rw-r--r--include/linux/mfd/twl4030-codec.h2
-rw-r--r--include/linux/mfd/wl1273-core.h290
-rw-r--r--include/linux/mfd/wm831x/core.h39
-rw-r--r--include/linux/mfd/wm831x/pdata.h15
-rw-r--r--include/linux/mfd/wm8350/audio.h3
-rw-r--r--include/linux/mfd/wm8350/pmic.h2
-rw-r--r--include/linux/mfd/wm8994/core.h13
-rw-r--r--include/linux/mfd/wm8994/pdata.h80
-rw-r--r--include/linux/mfd/wm8994/registers.h304
-rw-r--r--include/linux/micrel_phy.h16
-rw-r--r--include/linux/migrate.h24
-rw-r--r--include/linux/mlx4/cmd.h3
-rw-r--r--include/linux/mlx4/device.h103
-rw-r--r--include/linux/mlx4/driver.h5
-rw-r--r--include/linux/mlx4/qp.h10
-rw-r--r--include/linux/mm.h384
-rw-r--r--include/linux/mm_inline.h19
-rw-r--r--include/linux/mm_types.h44
-rw-r--r--include/linux/mmc/Kbuild1
-rw-r--r--include/linux/mmc/boot.h7
-rw-r--r--include/linux/mmc/card.h212
-rw-r--r--include/linux/mmc/core.h8
-rw-r--r--include/linux/mmc/dw_mmc.h222
-rw-r--r--include/linux/mmc/host.h115
-rw-r--r--include/linux/mmc/ioctl.h54
-rw-r--r--include/linux/mmc/mmc.h33
-rw-r--r--include/linux/mmc/sd.h9
-rw-r--r--include/linux/mmc/sdhci-pltfm.h (renamed from include/linux/sdhci-pltfm.h)2
-rw-r--r--include/linux/mmc/sdhci.h165
-rw-r--r--include/linux/mmc/sdio_ids.h1
-rw-r--r--include/linux/mmc/sh_mmcif.h109
-rw-r--r--include/linux/mmc/sh_mobile_sdhi.h (renamed from include/linux/mfd/sh_mobile_sdhi.h)6
-rw-r--r--include/linux/mmc/tmio.h63
-rw-r--r--include/linux/mmu_notifier.h70
-rw-r--r--include/linux/mmzone.h49
-rw-r--r--include/linux/mod_devicetable.h17
-rw-r--r--include/linux/module.h70
-rw-r--r--include/linux/moduleparam.h17
-rw-r--r--include/linux/mount.h58
-rw-r--r--include/linux/mroute.h3
-rw-r--r--include/linux/mroute6.h3
-rw-r--r--include/linux/msi.h13
-rw-r--r--include/linux/msm_mdp.h1
-rw-r--r--include/linux/mtd/bbm.h4
-rw-r--r--include/linux/mtd/blktrans.h3
-rw-r--r--include/linux/mtd/cfi.h7
-rw-r--r--include/linux/mtd/fsmc.h163
-rw-r--r--include/linux/mtd/inftl.h14
-rw-r--r--include/linux/mtd/latch-addr-flash.h29
-rw-r--r--include/linux/mtd/mtd.h43
-rw-r--r--include/linux/mtd/nand.h433
-rw-r--r--include/linux/mtd/nand_bch.h72
-rw-r--r--include/linux/mtd/onenand.h15
-rw-r--r--include/linux/mtd/onenand_regs.h1
-rw-r--r--include/linux/mtd/partitions.h23
-rw-r--r--include/linux/mtd/physmap.h9
-rw-r--r--include/linux/mtd/super.h5
-rw-r--r--include/linux/mtd/ubi.h26
-rw-r--r--include/linux/mtd/xip.h2
-rw-r--r--include/linux/mtio.h1
-rw-r--r--include/linux/mutex.h15
-rw-r--r--include/linux/mxm-wmi.h33
-rw-r--r--include/linux/n_r3964.h1
-rw-r--r--include/linux/namei.h24
-rw-r--r--include/linux/ncp_fs.h128
-rw-r--r--include/linux/ncp_fs_i.h29
-rw-r--r--include/linux/ncp_fs_sb.h162
-rw-r--r--include/linux/ncp_mount.h22
-rw-r--r--include/linux/net.h12
-rw-r--r--include/linux/netdevice.h561
-rw-r--r--include/linux/netfilter.h33
-rw-r--r--include/linux/netfilter/Kbuild7
-rw-r--r--include/linux/netfilter/ipset/Kbuild4
-rw-r--r--include/linux/netfilter/ipset/ip_set.h452
-rw-r--r--include/linux/netfilter/ipset/ip_set_ahash.h1073
-rw-r--r--include/linux/netfilter/ipset/ip_set_bitmap.h31
-rw-r--r--include/linux/netfilter/ipset/ip_set_getport.h33
-rw-r--r--include/linux/netfilter/ipset/ip_set_hash.h26
-rw-r--r--include/linux/netfilter/ipset/ip_set_list.h27
-rw-r--r--include/linux/netfilter/ipset/ip_set_timeout.h129
-rw-r--r--include/linux/netfilter/ipset/pfxlen.h35
-rw-r--r--include/linux/netfilter/nf_conntrack_common.h9
-rw-r--r--include/linux/netfilter/nf_conntrack_proto_gre.h2
-rw-r--r--include/linux/netfilter/nf_conntrack_sip.h1
-rw-r--r--include/linux/netfilter/nf_conntrack_snmp.h9
-rw-r--r--include/linux/netfilter/nfnetlink.h3
-rw-r--r--include/linux/netfilter/nfnetlink_conntrack.h20
-rw-r--r--include/linux/netfilter/nfnetlink_log.h4
-rw-r--r--include/linux/netfilter/nfnetlink_queue.h4
-rw-r--r--include/linux/netfilter/x_tables.h104
-rw-r--r--include/linux/netfilter/xt_AUDIT.h30
-rw-r--r--include/linux/netfilter/xt_CT.h12
-rw-r--r--include/linux/netfilter/xt_NFQUEUE.h6
-rw-r--r--include/linux/netfilter/xt_SECMARK.h12
-rw-r--r--include/linux/netfilter/xt_TCPOPTSTRIP.h4
-rw-r--r--include/linux/netfilter/xt_TPROXY.h19
-rw-r--r--include/linux/netfilter/xt_addrtype.h44
-rw-r--r--include/linux/netfilter/xt_cluster.h10
-rw-r--r--include/linux/netfilter/xt_comment.h2
-rw-r--r--include/linux/netfilter/xt_connbytes.h4
-rw-r--r--include/linux/netfilter/xt_connlimit.h16
-rw-r--r--include/linux/netfilter/xt_conntrack.h15
-rw-r--r--include/linux/netfilter/xt_devgroup.h21
-rw-r--r--include/linux/netfilter/xt_quota.h8
-rw-r--r--include/linux/netfilter/xt_set.h56
-rw-r--r--include/linux/netfilter/xt_socket.h2
-rw-r--r--include/linux/netfilter/xt_time.h16
-rw-r--r--include/linux/netfilter/xt_u32.h18
-rw-r--r--include/linux/netfilter_arp/arp_tables.h68
-rw-r--r--include/linux/netfilter_bridge/Kbuild2
-rw-r--r--include/linux/netfilter_bridge/ebt_802_3.h26
-rw-r--r--include/linux/netfilter_bridge/ebt_among.h4
-rw-r--r--include/linux/netfilter_bridge/ebt_arp.h6
-rw-r--r--include/linux/netfilter_bridge/ebt_ip.h14
-rw-r--r--include/linux/netfilter_bridge/ebt_ip6.h25
-rw-r--r--include/linux/netfilter_bridge/ebt_limit.h10
-rw-r--r--include/linux/netfilter_bridge/ebt_log.h8
-rw-r--r--include/linux/netfilter_bridge/ebt_mark_m.h6
-rw-r--r--include/linux/netfilter_bridge/ebt_nflog.h12
-rw-r--r--include/linux/netfilter_bridge/ebt_pkttype.h6
-rw-r--r--include/linux/netfilter_bridge/ebt_stp.h26
-rw-r--r--include/linux/netfilter_bridge/ebt_ulog.h4
-rw-r--r--include/linux/netfilter_bridge/ebt_vlan.h10
-rw-r--r--include/linux/netfilter_bridge/ebtables.h2
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h107
-rw-r--r--include/linux/netfilter_ipv4/ipt_CLUSTERIP.h16
-rw-r--r--include/linux/netfilter_ipv4/ipt_ECN.h8
-rw-r--r--include/linux/netfilter_ipv4/ipt_SAME.h8
-rw-r--r--include/linux/netfilter_ipv4/ipt_TTL.h6
-rw-r--r--include/linux/netfilter_ipv4/ipt_addrtype.h16
-rw-r--r--include/linux/netfilter_ipv4/ipt_ah.h6
-rw-r--r--include/linux/netfilter_ipv4/ipt_ecn.h10
-rw-r--r--include/linux/netfilter_ipv4/ipt_ttl.h6
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h110
-rw-r--r--include/linux/netfilter_ipv6/ip6t_HL.h6
-rw-r--r--include/linux/netfilter_ipv6/ip6t_REJECT.h4
-rw-r--r--include/linux/netfilter_ipv6/ip6t_ah.h10
-rw-r--r--include/linux/netfilter_ipv6/ip6t_frag.h10
-rw-r--r--include/linux/netfilter_ipv6/ip6t_hl.h6
-rw-r--r--include/linux/netfilter_ipv6/ip6t_ipv6header.h8
-rw-r--r--include/linux/netfilter_ipv6/ip6t_mh.h6
-rw-r--r--include/linux/netfilter_ipv6/ip6t_opts.h12
-rw-r--r--include/linux/netfilter_ipv6/ip6t_rt.h13
-rw-r--r--include/linux/netlink.h7
-rw-r--r--include/linux/netpoll.h9
-rw-r--r--include/linux/nfc/pn544.h97
-rw-r--r--include/linux/nfs3.h3
-rw-r--r--include/linux/nfs4.h92
-rw-r--r--include/linux/nfs4_acl.h61
-rw-r--r--include/linux/nfs_fs.h43
-rw-r--r--include/linux/nfs_fs_sb.h32
-rw-r--r--include/linux/nfs_idmap.h36
-rw-r--r--include/linux/nfs_iostat.h2
-rw-r--r--include/linux/nfs_mount.h3
-rw-r--r--include/linux/nfs_page.h18
-rw-r--r--include/linux/nfs_xdr.h240
-rw-r--r--include/linux/nfsacl.h4
-rw-r--r--include/linux/nfsd/export.h4
-rw-r--r--include/linux/nfsd/nfsfh.h2
-rw-r--r--include/linux/nfsd_idmap.h64
-rw-r--r--include/linux/nilfs2_fs.h54
-rw-r--r--include/linux/nl80211.h788
-rw-r--r--include/linux/nmi.h17
-rw-r--r--include/linux/node.h11
-rw-r--r--include/linux/notifier.h15
-rw-r--r--include/linux/nsproxy.h9
-rw-r--r--include/linux/of.h18
-rw-r--r--include/linux/of_address.h6
-rw-r--r--include/linux/of_device.h20
-rw-r--r--include/linux/of_fdt.h22
-rw-r--r--include/linux/of_irq.h5
-rw-r--r--include/linux/of_net.h15
-rw-r--r--include/linux/of_pci.h9
-rw-r--r--include/linux/of_pdt.h45
-rw-r--r--include/linux/of_platform.h21
-rw-r--r--include/linux/omap3isp.h646
-rw-r--r--include/linux/oom.h2
-rw-r--r--include/linux/opp.h105
-rw-r--r--include/linux/oprofile.h23
-rw-r--r--include/linux/padata.h4
-rw-r--r--include/linux/page-flags.h75
-rw-r--r--include/linux/page_cgroup.h102
-rw-r--r--include/linux/pageblock-flags.h5
-rw-r--r--include/linux/pagemap.h37
-rw-r--r--include/linux/pata_arasan_cf_data.h49
-rw-r--r--include/linux/pci-acpi.h7
-rw-r--r--include/linux/pci-aspm.h10
-rw-r--r--include/linux/pci-ats.h52
-rw-r--r--include/linux/pci.h93
-rw-r--r--include/linux/pci_ids.h90
-rw-r--r--include/linux/pci_regs.h37
-rw-r--r--include/linux/percpu-defs.h9
-rw-r--r--include/linux/percpu.h374
-rw-r--r--include/linux/percpu_counter.h16
-rw-r--r--include/linux/perf_event.h352
-rw-r--r--include/linux/phonet.h3
-rw-r--r--include/linux/phy.h16
-rw-r--r--include/linux/pid.h17
-rw-r--r--include/linux/pipe_fs_i.h2
-rw-r--r--include/linux/pkt_cls.h1
-rw-r--r--include/linux/pkt_sched.h124
-rw-r--r--include/linux/platform_data/msm_serial_hs.h49
-rw-r--r--include/linux/platform_data/tegra_usb.h31
-rw-r--r--include/linux/platform_data/uio_pruss.h25
-rw-r--r--include/linux/platform_device.h76
-rw-r--r--include/linux/plist.h47
-rw-r--r--include/linux/pm.h126
-rw-r--r--include/linux/pm_qos_params.h4
-rw-r--r--include/linux/pm_runtime.h185
-rw-r--r--include/linux/pm_wakeup.h122
-rw-r--r--include/linux/pnfs_osd_xdr.h345
-rw-r--r--include/linux/poll.h6
-rw-r--r--include/linux/posix-clock.h151
-rw-r--r--include/linux/posix-timers.h47
-rw-r--r--include/linux/posix_acl.h20
-rw-r--r--include/linux/power/bq20z75.h39
-rw-r--r--include/linux/power/bq27x00_battery.h19
-rw-r--r--include/linux/power/gpio-charger.h41
-rw-r--r--include/linux/power/isp1704_charger.h29
-rw-r--r--include/linux/power/max17042_battery.h30
-rw-r--r--include/linux/power/max8903_charger.h57
-rw-r--r--include/linux/power_supply.h53
-rw-r--r--include/linux/pps.h7
-rw-r--r--include/linux/pps_kernel.h61
-rw-r--r--include/linux/prefetch.h2
-rw-r--r--include/linux/printk.h309
-rw-r--r--include/linux/proc_fs.h44
-rw-r--r--include/linux/pstore.h62
-rw-r--r--include/linux/pti.h42
-rw-r--r--include/linux/ptp_classify.h7
-rw-r--r--include/linux/ptp_clock.h84
-rw-r--r--include/linux/ptp_clock_kernel.h139
-rw-r--r--include/linux/ptrace.h28
-rw-r--r--include/linux/pwm_backlight.h4
-rw-r--r--include/linux/pxa2xx_ssp.h209
-rw-r--r--include/linux/quota.h5
-rw-r--r--include/linux/quotaops.h11
-rw-r--r--include/linux/radix-tree.h59
-rw-r--r--include/linux/raid/md_p.h2
-rw-r--r--include/linux/ramfs.h4
-rw-r--r--include/linux/ramoops.h15
-rw-r--r--include/linux/rar_register.h16
-rw-r--r--include/linux/ratelimit.h42
-rw-r--r--include/linux/rbtree.h8
-rw-r--r--include/linux/rculist.h77
-rw-r--r--include/linux/rculist_bl.h128
-rw-r--r--include/linux/rculist_nulls.h16
-rw-r--r--include/linux/rcupdate.h574
-rw-r--r--include/linux/rcutiny.h115
-rw-r--r--include/linux/rcutree.h70
-rw-r--r--include/linux/rds.h115
-rw-r--r--include/linux/regulator/ab8500.h73
-rw-r--r--include/linux/regulator/consumer.h3
-rw-r--r--include/linux/regulator/db8500-prcmu.h45
-rw-r--r--include/linux/regulator/driver.h30
-rw-r--r--include/linux/regulator/lp3972.h48
-rw-r--r--include/linux/regulator/machine.h13
-rw-r--r--include/linux/regulator/max8952.h135
-rw-r--r--include/linux/reiserfs_fs.h32
-rw-r--r--include/linux/reiserfs_xattr.h4
-rw-r--r--include/linux/res_counter.h52
-rw-r--r--include/linux/resource.h1
-rw-r--r--include/linux/resume-trace.h2
-rw-r--r--include/linux/rfkill-gpio.h43
-rw-r--r--include/linux/rfkill-regulator.h48
-rw-r--r--include/linux/rfkill.h31
-rw-r--r--include/linux/ring_buffer.h14
-rw-r--r--include/linux/rio.h130
-rw-r--r--include/linux/rio_drv.h79
-rw-r--r--include/linux/rio_ids.h5
-rw-r--r--include/linux/rio_regs.h22
-rw-r--r--include/linux/rmap.h74
-rw-r--r--include/linux/romfs_fs.h3
-rw-r--r--include/linux/rotary_encoder.h1
-rw-r--r--include/linux/rtc.h57
-rw-r--r--include/linux/rtnetlink.h30
-rw-r--r--include/linux/rwlock_types.h8
-rw-r--r--include/linux/rwsem-spinlock.h31
-rw-r--r--include/linux/rwsem.h53
-rw-r--r--include/linux/s3c_adc_battery.h1
-rw-r--r--include/linux/sched.h353
-rw-r--r--include/linux/sdla.h6
-rw-r--r--include/linux/security.h161
-rw-r--r--include/linux/selection.h1
-rw-r--r--include/linux/selinux.h63
-rw-r--r--include/linux/semaphore.h6
-rw-r--r--include/linux/seqlock.h88
-rw-r--r--include/linux/serial_8250.h8
-rw-r--r--include/linux/serial_core.h31
-rw-r--r--include/linux/serial_reg.h21
-rw-r--r--include/linux/serial_sci.h38
-rw-r--r--include/linux/serio.h10
-rw-r--r--include/linux/sfi.h32
-rw-r--r--include/linux/sh_clk.h55
-rw-r--r--include/linux/sh_intc.h19
-rw-r--r--include/linux/sh_pfc.h1
-rw-r--r--include/linux/sh_timer.h1
-rw-r--r--include/linux/shmem_fs.h29
-rw-r--r--include/linux/sht15.h18
-rw-r--r--include/linux/sigma.h60
-rw-r--r--include/linux/signal.h15
-rw-r--r--include/linux/signalfd.h3
-rw-r--r--include/linux/skbuff.h186
-rw-r--r--include/linux/slab.h3
-rw-r--r--include/linux/slab_def.h33
-rw-r--r--include/linux/slub_def.h82
-rw-r--r--include/linux/sm501.h8
-rw-r--r--include/linux/smb.h118
-rw-r--r--include/linux/smb_fs.h153
-rw-r--r--include/linux/smb_fs_i.h37
-rw-r--r--include/linux/smb_fs_sb.h100
-rw-r--r--include/linux/smb_mount.h65
-rw-r--r--include/linux/smbno.h363
-rw-r--r--include/linux/smc91x.h2
-rw-r--r--include/linux/smp.h37
-rw-r--r--include/linux/smp_lock.h65
-rw-r--r--include/linux/smsc911x.h1
-rw-r--r--include/linux/snmp.h1
-rw-r--r--include/linux/socket.h20
-rw-r--r--include/linux/sockios.h4
-rw-r--r--include/linux/sonypi.h2
-rw-r--r--include/linux/soundcard.h2
-rw-r--r--include/linux/spi/74x164.h11
-rw-r--r--include/linux/spi/ads7846.h3
-rw-r--r--include/linux/spi/dw_spi.h219
-rw-r--r--include/linux/spi/ifx_modem.h19
-rw-r--r--include/linux/spi/mcp23s08.h15
-rw-r--r--include/linux/spi/pxa2xx_spi.h152
-rw-r--r--include/linux/spi/spi.h11
-rw-r--r--include/linux/spi/spi_oc_tiny.h20
-rw-r--r--include/linux/spi/spidev.h2
-rw-r--r--include/linux/spi/tsc2005.h41
-rw-r--r--include/linux/spinlock.h3
-rw-r--r--include/linux/spinlock_types.h8
-rw-r--r--include/linux/spinlock_up.h2
-rw-r--r--include/linux/srcu.h34
-rw-r--r--include/linux/ssb/ssb.h11
-rw-r--r--include/linux/ssb/ssb_driver_chipcommon.h11
-rw-r--r--include/linux/ssb/ssb_driver_gige.h17
-rw-r--r--include/linux/ssb/ssb_regs.h48
-rw-r--r--include/linux/stacktrace.h4
-rw-r--r--include/linux/stmmac.h16
-rw-r--r--include/linux/stop_machine.h12
-rw-r--r--include/linux/string.h1
-rw-r--r--include/linux/sunrpc/auth.h12
-rw-r--r--include/linux/sunrpc/auth_gss.h4
-rw-r--r--include/linux/sunrpc/bc_xprt.h2
-rw-r--r--include/linux/sunrpc/cache.h45
-rw-r--r--include/linux/sunrpc/clnt.h7
-rw-r--r--include/linux/sunrpc/gss_api.h3
-rw-r--r--include/linux/sunrpc/gss_krb5_enctypes.h4
-rw-r--r--include/linux/sunrpc/gss_spkm3.h55
-rw-r--r--include/linux/sunrpc/msg_prot.h1
-rw-r--r--include/linux/sunrpc/sched.h9
-rw-r--r--include/linux/sunrpc/stats.h23
-rw-r--r--include/linux/sunrpc/svc.h3
-rw-r--r--include/linux/sunrpc/svc_xprt.h44
-rw-r--r--include/linux/sunrpc/svcauth.h17
-rw-r--r--include/linux/sunrpc/svcauth_gss.h2
-rw-r--r--include/linux/sunrpc/svcsock.h2
-rw-r--r--include/linux/sunrpc/xdr.h23
-rw-r--r--include/linux/sunrpc/xprt.h11
-rw-r--r--include/linux/suspend.h44
-rw-r--r--include/linux/svga.h34
-rw-r--r--include/linux/swap.h45
-rw-r--r--include/linux/swiotlb.h1
-rw-r--r--include/linux/synclink.h5
-rw-r--r--include/linux/syscalls.h57
-rw-r--r--include/linux/syscore_ops.h29
-rw-r--r--include/linux/sysctl.h14
-rw-r--r--include/linux/sysdev.h14
-rw-r--r--include/linux/sysfs.h27
-rw-r--r--include/linux/sysrq.h3
-rw-r--r--include/linux/taskstats.h3
-rw-r--r--include/linux/tc_act/Kbuild1
-rw-r--r--include/linux/tc_act/tc_csum.h32
-rw-r--r--include/linux/tc_ematch/tc_em_meta.h1
-rw-r--r--include/linux/tcp.h1
-rw-r--r--include/linux/thermal.h55
-rw-r--r--include/linux/thread_info.h9
-rw-r--r--include/linux/ti_wilink_st.h423
-rw-r--r--include/linux/time.h19
-rw-r--r--include/linux/timer.h32
-rw-r--r--include/linux/timerfd.h3
-rw-r--r--include/linux/timerqueue.h50
-rw-r--r--include/linux/timex.h4
-rw-r--r--include/linux/tipc.h38
-rw-r--r--include/linux/tipc_config.h114
-rw-r--r--include/linux/topology.h8
-rw-r--r--include/linux/toshiba.h2
-rw-r--r--include/linux/tpm.h4
-rw-r--r--include/linux/tpm_command.h28
-rw-r--r--include/linux/tracehook.h33
-rw-r--r--include/linux/tracepoint.h85
-rw-r--r--include/linux/tty.h26
-rw-r--r--include/linux/tty_driver.h31
-rw-r--r--include/linux/tty_ldisc.h7
-rw-r--r--include/linux/types.h26
-rw-r--r--include/linux/u64_stats_sync.h12
-rw-r--r--include/linux/uaccess.h8
-rw-r--r--include/linux/ucb1400.h2
-rw-r--r--include/linux/uinput.h1
-rw-r--r--include/linux/uio_driver.h4
-rw-r--r--include/linux/unaligned/packed_struct.h6
-rw-r--r--include/linux/usb.h24
-rw-r--r--include/linux/usb/Kbuild1
-rw-r--r--include/linux/usb/cdc.h102
-rw-r--r--include/linux/usb/ch11.h93
-rw-r--r--include/linux/usb/ch9.h84
-rw-r--r--include/linux/usb/composite.h58
-rw-r--r--include/linux/usb/ehci_def.h21
-rw-r--r--include/linux/usb/functionfs.h4
-rw-r--r--include/linux/usb/gadget.h28
-rw-r--r--include/linux/usb/hcd.h46
-rw-r--r--include/linux/usb/intel_mid_otg.h180
-rw-r--r--include/linux/usb/langwell_otg.h139
-rw-r--r--include/linux/usb/midi.h2
-rw-r--r--include/linux/usb/msm_hsusb.h185
-rw-r--r--include/linux/usb/msm_hsusb_hw.h57
-rw-r--r--include/linux/usb/musb.h10
-rw-r--r--include/linux/usb/ncm.h114
-rw-r--r--include/linux/usb/otg.h26
-rw-r--r--include/linux/usb/renesas_usbhs.h156
-rw-r--r--include/linux/usb/rndis_host.h2
-rw-r--r--include/linux/usb/serial.h14
-rw-r--r--include/linux/usb/storage.h48
-rw-r--r--include/linux/usb/ulpi.h5
-rw-r--r--include/linux/usb/usbnet.h12
-rw-r--r--include/linux/usb/wusb.h2
-rw-r--r--include/linux/usb_usual.h45
-rw-r--r--include/linux/user_namespace.h2
-rw-r--r--include/linux/uts.h2
-rw-r--r--include/linux/utsname.h10
-rw-r--r--include/linux/uvcvideo.h69
-rw-r--r--include/linux/uwb.h6
-rw-r--r--include/linux/uwb/umc.h2
-rw-r--r--include/linux/v4l2-mediabus.h114
-rw-r--r--include/linux/v4l2-subdev.h141
-rw-r--r--include/linux/vga_switcheroo.h2
-rw-r--r--include/linux/vgaarb.h4
-rw-r--r--include/linux/via-core.h19
-rw-r--r--include/linux/video_output.h15
-rw-r--r--include/linux/videodev.h340
-rw-r--r--include/linux/videodev2.h163
-rw-r--r--include/linux/videotext.h125
-rw-r--r--include/linux/virtio.h9
-rw-r--r--include/linux/virtio_9p.h26
-rw-r--r--include/linux/virtio_balloon.h25
-rw-r--r--include/linux/virtio_blk.h25
-rw-r--r--include/linux/virtio_config.h30
-rw-r--r--include/linux/virtio_console.h29
-rw-r--r--include/linux/virtio_ids.h24
-rw-r--r--include/linux/virtio_net.h25
-rw-r--r--include/linux/virtio_pci.h23
-rw-r--r--include/linux/virtio_ring.h52
-rw-r--r--include/linux/vm_event_item.h64
-rw-r--r--include/linux/vmalloc.h48
-rw-r--r--include/linux/vmstat.h73
-rw-r--r--include/linux/vt_kern.h8
-rw-r--r--include/linux/wimax.h2
-rw-r--r--include/linux/wireless.h2
-rw-r--r--include/linux/wl12xx.h78
-rw-r--r--include/linux/wlp.h736
-rw-r--r--include/linux/workqueue.h77
-rw-r--r--include/linux/writeback.h10
-rw-r--r--include/linux/xattr.h14
-rw-r--r--include/linux/xfrm.h14
-rw-r--r--include/linux/xilinxfb.h2
-rw-r--r--include/linux/xz.h264
-rw-r--r--include/linux/zlib.h11
-rw-r--r--include/media/bt819.h5
-rw-r--r--include/media/cx2341x.h2
-rw-r--r--include/media/davinci/dm355_ccdc.h2
-rw-r--r--include/media/davinci/isif.h2
-rw-r--r--include/media/davinci/vpss.h2
-rw-r--r--include/media/ir-common.h107
-rw-r--r--include/media/ir-core.h185
-rw-r--r--include/media/ir-kbd-i2c.h21
-rw-r--r--include/media/lirc.h2
-rw-r--r--include/media/lirc_dev.h14
-rw-r--r--include/media/m5mols.h35
-rw-r--r--include/media/media-device.h95
-rw-r--r--include/media/media-devnode.h97
-rw-r--r--include/media/media-entity.h151
-rw-r--r--include/media/mt9v011.h17
-rw-r--r--include/media/mt9v032.h12
-rw-r--r--include/media/noon010pc30.h28
-rw-r--r--include/media/omap1_camera.h35
-rw-r--r--include/media/ovcamchip.h90
-rw-r--r--include/media/rc-core.h226
-rw-r--r--include/media/rc-map.h68
-rw-r--r--include/media/s5p_fimc.h61
-rw-r--r--include/media/saa6588.h (renamed from include/media/rds.h)18
-rw-r--r--include/media/saa7146.h4
-rw-r--r--include/media/sh_vou.h1
-rw-r--r--include/media/si4713.h3
-rw-r--r--include/media/soc_camera.h53
-rw-r--r--include/media/soc_camera_platform.h50
-rw-r--r--include/media/soc_mediabus.h27
-rw-r--r--include/media/sr030pc30.h21
-rw-r--r--include/media/timb_radio.h1
-rw-r--r--include/media/timb_video.h33
-rw-r--r--include/media/tuner.h16
-rw-r--r--include/media/v4l2-chip-ident.h13
-rw-r--r--include/media/v4l2-common.h54
-rw-r--r--include/media/v4l2-ctrls.h11
-rw-r--r--include/media/v4l2-dev.h48
-rw-r--r--include/media/v4l2-device.h83
-rw-r--r--include/media/v4l2-fh.h29
-rw-r--r--include/media/v4l2-i2c-drv.h80
-rw-r--r--include/media/v4l2-ioctl.h40
-rw-r--r--include/media/v4l2-mediabus.h53
-rw-r--r--include/media/v4l2-mem2mem.h58
-rw-r--r--include/media/v4l2-subdev.h162
-rw-r--r--include/media/videobuf-core.h27
-rw-r--r--include/media/videobuf-dma-contig.h3
-rw-r--r--include/media/videobuf-dma-sg.h3
-rw-r--r--include/media/videobuf-dvb.h4
-rw-r--r--include/media/videobuf-vmalloc.h3
-rw-r--r--include/media/videobuf2-core.h380
-rw-r--r--include/media/videobuf2-dma-contig.h32
-rw-r--r--include/media/videobuf2-dma-sg.h32
-rw-r--r--include/media/videobuf2-memops.h45
-rw-r--r--include/media/videobuf2-vmalloc.h20
-rw-r--r--include/media/wm8775.h9
-rw-r--r--include/mtd/mtd-abi.h16
-rw-r--r--include/mtd/mtd-user.h2
-rw-r--r--include/mtd/ubi-user.h40
-rw-r--r--include/net/9p/9p.h83
-rw-r--r--include/net/9p/client.h15
-rw-r--r--include/net/9p/transport.h12
-rw-r--r--include/net/addrconf.h92
-rw-r--r--include/net/af_rxrpc.h3
-rw-r--r--include/net/af_unix.h4
-rw-r--r--include/net/ah.h2
-rw-r--r--include/net/arp.h3
-rw-r--r--include/net/atmclip.h2
-rw-r--r--include/net/bluetooth/bluetooth.h36
-rw-r--r--include/net/bluetooth/hci.h214
-rw-r--r--include/net/bluetooth/hci_core.h227
-rw-r--r--include/net/bluetooth/l2cap.h225
-rw-r--r--include/net/bluetooth/mgmt.h291
-rw-r--r--include/net/bluetooth/rfcomm.h23
-rw-r--r--include/net/bluetooth/sco.h20
-rw-r--r--include/net/bluetooth/smp.h76
-rw-r--r--include/net/caif/caif_dev.h54
-rw-r--r--include/net/caif/caif_layer.h36
-rw-r--r--include/net/caif/caif_shm.h26
-rw-r--r--include/net/caif/caif_spi.h2
-rw-r--r--include/net/caif/cfcnfg.h69
-rw-r--r--include/net/caif/cfctrl.h17
-rw-r--r--include/net/caif/cffrml.h7
-rw-r--r--include/net/caif/cfmuxl.h2
-rw-r--r--include/net/caif/cfpkt.h76
-rw-r--r--include/net/caif/cfsrvl.h32
-rw-r--r--include/net/cfg80211.h789
-rw-r--r--include/net/cls_cgroup.h3
-rw-r--r--include/net/compat.h2
-rw-r--r--include/net/dcbevent.h31
-rw-r--r--include/net/dcbnl.h37
-rw-r--r--include/net/dn.h8
-rw-r--r--include/net/dn_dev.h27
-rw-r--r--include/net/dn_fib.h8
-rw-r--r--include/net/dn_route.h14
-rw-r--r--include/net/dst.h213
-rw-r--r--include/net/dst_ops.h41
-rw-r--r--include/net/fib_rules.h5
-rw-r--r--include/net/flow.h223
-rw-r--r--include/net/garp.h4
-rw-r--r--include/net/gen_stats.h2
-rw-r--r--include/net/genetlink.h23
-rw-r--r--include/net/gre.h18
-rw-r--r--include/net/icmp.h3
-rw-r--r--include/net/ieee80211_radiotap.h25
-rw-r--r--include/net/if_inet6.h30
-rw-r--r--include/net/inet6_connection_sock.h5
-rw-r--r--include/net/inet_connection_sock.h10
-rw-r--r--include/net/inet_ecn.h18
-rw-r--r--include/net/inet_hashtables.h2
-rw-r--r--include/net/inet_sock.h56
-rw-r--r--include/net/inet_timewait_sock.h20
-rw-r--r--include/net/inetpeer.h66
-rw-r--r--include/net/ip.h69
-rw-r--r--include/net/ip6_fib.h20
-rw-r--r--include/net/ip6_route.h53
-rw-r--r--include/net/ip6_tunnel.h2
-rw-r--r--include/net/ip_fib.h83
-rw-r--r--include/net/ip_vs.h653
-rw-r--r--include/net/ipip.h18
-rw-r--r--include/net/ipv6.h101
-rw-r--r--include/net/ipx.h2
-rw-r--r--include/net/irda/ircomm_tty.h6
-rw-r--r--include/net/irda/irlan_common.h1
-rw-r--r--include/net/irda/irlan_event.h2
-rw-r--r--include/net/irda/irlap.h4
-rw-r--r--include/net/irda/irlmp.h2
-rw-r--r--include/net/irda/irttp.h2
-rw-r--r--include/net/irda/wrapper.h2
-rw-r--r--include/net/iucv/iucv.h2
-rw-r--r--include/net/iw_handler.h4
-rw-r--r--include/net/llc_pdu.h8
-rw-r--r--include/net/mac80211.h581
-rw-r--r--include/net/ndisc.h12
-rw-r--r--include/net/neighbour.h51
-rw-r--r--include/net/net_namespace.h33
-rw-r--r--include/net/net_ratelimit.h8
-rw-r--r--include/net/netevent.h3
-rw-r--r--include/net/netfilter/ipv6/nf_conntrack_ipv6.h10
-rw-r--r--include/net/netfilter/ipv6/nf_defrag_ipv6.h16
-rw-r--r--include/net/netfilter/nf_conntrack.h35
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h15
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h12
-rw-r--r--include/net/netfilter/nf_conntrack_extend.h10
-rw-r--r--include/net/netfilter/nf_conntrack_helper.h6
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h2
-rw-r--r--include/net/netfilter/nf_conntrack_timestamp.h65
-rw-r--r--include/net/netfilter/nf_conntrack_tuple.h4
-rw-r--r--include/net/netfilter/nf_nat.h10
-rw-r--r--include/net/netfilter/nf_nat_core.h4
-rw-r--r--include/net/netfilter/nf_nat_protocol.h3
-rw-r--r--include/net/netfilter/nf_tproxy_core.h198
-rw-r--r--include/net/netfilter/xt_log.h54
-rw-r--r--include/net/netlink.h34
-rw-r--r--include/net/netns/conntrack.h4
-rw-r--r--include/net/netns/generic.h2
-rw-r--r--include/net/netns/ipv4.h4
-rw-r--r--include/net/netns/xfrm.h9
-rw-r--r--include/net/phonet/pep.h7
-rw-r--r--include/net/phonet/phonet.h10
-rw-r--r--include/net/phonet/pn_dev.h3
-rw-r--r--include/net/ping.h55
-rw-r--r--include/net/pkt_cls.h4
-rw-r--r--include/net/pkt_sched.h2
-rw-r--r--include/net/protocol.h8
-rw-r--r--include/net/raw.h5
-rw-r--r--include/net/rawv6.h4
-rw-r--r--include/net/red.h1
-rw-r--r--include/net/regulatory.h7
-rw-r--r--include/net/rose.h8
-rw-r--r--include/net/route.h224
-rw-r--r--include/net/rtnetlink.h36
-rw-r--r--include/net/sch_generic.h100
-rw-r--r--include/net/scm.h5
-rw-r--r--include/net/sctp/command.h6
-rw-r--r--include/net/sctp/constants.h32
-rw-r--r--include/net/sctp/sctp.h63
-rw-r--r--include/net/sctp/sm.h15
-rw-r--r--include/net/sctp/structs.h29
-rw-r--r--include/net/sctp/tsnmap.h2
-rw-r--r--include/net/sctp/ulpevent.h5
-rw-r--r--include/net/sctp/user.h38
-rw-r--r--include/net/snmp.h22
-rw-r--r--include/net/sock.h192
-rw-r--r--include/net/tc_act/tc_csum.h15
-rw-r--r--include/net/tcp.h37
-rw-r--r--include/net/timewait_sock.h8
-rw-r--r--include/net/tipc/tipc.h257
-rw-r--r--include/net/tipc/tipc_bearer.h138
-rw-r--r--include/net/tipc/tipc_msg.h207
-rw-r--r--include/net/tipc/tipc_port.h103
-rw-r--r--include/net/transp_v6.h10
-rw-r--r--include/net/udp.h20
-rw-r--r--include/net/udplite.h12
-rw-r--r--include/net/wimax.h7
-rw-r--r--include/net/wpan-phy.h2
-rw-r--r--include/net/x25.h2
-rw-r--r--include/net/xfrm.h264
-rw-r--r--include/pcmcia/cs.h95
-rw-r--r--include/pcmcia/ds.h90
-rw-r--r--include/pcmcia/ss.h1
-rw-r--r--include/rdma/Kbuild5
-rw-r--r--include/rdma/ib_addr.h135
-rw-r--r--include/rdma/ib_pack.h39
-rw-r--r--include/rdma/ib_user_cm.h1
-rw-r--r--include/rdma/ib_user_verbs.h3
-rw-r--r--include/rdma/ib_verbs.h14
-rw-r--r--include/rdma/iw_cm.h11
-rw-r--r--include/rdma/rdma_cm.h29
-rw-r--r--include/rdma/rdma_netlink.h92
-rw-r--r--include/rdma/rdma_user_cm.h5
-rw-r--r--include/rxrpc/packet.h2
-rw-r--r--include/scsi/fc/fc_fcp.h6
-rw-r--r--include/scsi/fc/fc_ns.h11
-rw-r--r--include/scsi/fc_encode.h26
-rw-r--r--include/scsi/iscsi_if.h3
-rw-r--r--include/scsi/libfc.h97
-rw-r--r--include/scsi/libfcoe.h113
-rw-r--r--include/scsi/libiscsi.h13
-rw-r--r--include/scsi/libiscsi_tcp.h3
-rw-r--r--include/scsi/libsas.h7
-rw-r--r--include/scsi/osd_initiator.h18
-rw-r--r--include/scsi/osd_protocol.h42
-rw-r--r--include/scsi/osd_types.h5
-rw-r--r--include/scsi/sas_ata.h22
-rw-r--r--include/scsi/scsi.h43
-rw-r--r--include/scsi/scsi_device.h6
-rw-r--r--include/scsi/scsi_host.h32
-rw-r--r--include/scsi/scsi_tcq.h7
-rw-r--r--include/scsi/scsi_transport_fc.h9
-rw-r--r--include/scsi/scsi_transport_iscsi.h6
-rw-r--r--include/scsi/srp.h38
-rw-r--r--include/sound/ac97_codec.h9
-rw-r--r--include/sound/ak4641.h26
-rw-r--r--include/sound/alc5623.h15
-rw-r--r--include/sound/asound.h3
-rw-r--r--include/sound/control.h9
-rw-r--r--include/sound/core.h8
-rw-r--r--include/sound/cs4271.h24
-rw-r--r--include/sound/cs46xx_dsp_spos.h2
-rw-r--r--include/sound/emu10k1.h2
-rw-r--r--include/sound/hdsp.h1
-rw-r--r--include/sound/hdspm.h181
-rw-r--r--include/sound/jack.h5
-rw-r--r--include/sound/max98088.h50
-rw-r--r--include/sound/max98095.h54
-rw-r--r--include/sound/minors.h4
-rw-r--r--include/sound/mixer_oss.h3
-rw-r--r--include/sound/pcm.h97
-rw-r--r--include/sound/sb16_csp.h9
-rw-r--r--include/sound/sh_fsi.h83
-rw-r--r--include/sound/soc-dai.h102
-rw-r--r--include/sound/soc-dapm.h219
-rw-r--r--include/sound/soc-of-simple.h25
-rw-r--r--include/sound/soc.h503
-rw-r--r--include/sound/tea575x-tuner.h26
-rw-r--r--include/sound/tlv.h4
-rw-r--r--include/sound/tlv320aic32x4.h31
-rw-r--r--include/sound/tlv320aic3x.h43
-rw-r--r--include/sound/tlv320dac33-plat.h2
-rw-r--r--include/sound/tpa6130a2-plat.h2
-rw-r--r--include/sound/version.h2
-rw-r--r--include/sound/wm8903.h30
-rw-r--r--include/sound/wm8915.h55
-rw-r--r--include/sound/wm8962.h54
-rw-r--r--include/sound/wm9081.h9
-rw-r--r--include/target/configfs_macros.h147
-rw-r--r--include/target/target_core_base.h985
-rw-r--r--include/target/target_core_configfs.h56
-rw-r--r--include/target/target_core_device.h61
-rw-r--r--include/target/target_core_fabric_configfs.h106
-rw-r--r--include/target/target_core_fabric_lib.h28
-rw-r--r--include/target/target_core_fabric_ops.h99
-rw-r--r--include/target/target_core_tmr.h35
-rw-r--r--include/target/target_core_tpg.h35
-rw-r--r--include/target/target_core_transport.h360
-rw-r--r--include/trace/define_trace.h25
-rw-r--r--include/trace/events/asoc.h260
-rw-r--r--include/trace/events/bkl.h61
-rw-r--r--include/trace/events/block.h48
-rw-r--r--include/trace/events/btrfs.h667
-rw-r--r--include/trace/events/compaction.h74
-rw-r--r--include/trace/events/ext4.h828
-rw-r--r--include/trace/events/gfpflags.h6
-rw-r--r--include/trace/events/gpio.h56
-rw-r--r--include/trace/events/irq.h56
-rw-r--r--include/trace/events/kvm.h121
-rw-r--r--include/trace/events/mce.h8
-rw-r--r--include/trace/events/module.h15
-rw-r--r--include/trace/events/napi.h25
-rw-r--r--include/trace/events/net.h84
-rw-r--r--include/trace/events/power.h178
-rw-r--r--include/trace/events/regulator.h141
-rw-r--r--include/trace/events/sched.h29
-rw-r--r--include/trace/events/scsi.h28
-rw-r--r--include/trace/events/skb.h23
-rw-r--r--include/trace/events/syscalls.h4
-rw-r--r--include/trace/events/vmscan.h127
-rw-r--r--include/trace/events/workqueue.h77
-rw-r--r--include/trace/events/writeback.h38
-rw-r--r--include/trace/ftrace.h58
-rw-r--r--include/video/atmel_lcdc.h1
-rw-r--r--include/video/da8xx-fb.h1
-rw-r--r--include/video/kyro.h2
-rw-r--r--include/video/neomagic.h2
-rw-r--r--include/video/newport.h4
-rw-r--r--include/video/omap-panel-generic-dpi.h37
-rw-r--r--include/video/omap-panel-nokia-dsi.h33
-rw-r--r--include/video/omapdss.h641
-rw-r--r--include/video/s1d13xxxfb.h6
-rw-r--r--include/video/sh_mipi_dsi.h6
-rw-r--r--include/video/sh_mobile_hdmi.h19
-rw-r--r--include/video/sh_mobile_lcdc.h18
-rw-r--r--include/video/sh_mobile_meram.h68
-rw-r--r--include/video/sisfb.h2
-rw-r--r--include/video/sstfb.h6
-rw-r--r--include/video/udlfb.h95
-rw-r--r--include/video/vga.h2
-rw-r--r--include/xen/Kbuild1
-rw-r--r--include/xen/balloon.h25
-rw-r--r--include/xen/events.h44
-rw-r--r--include/xen/gntalloc.h82
-rw-r--r--include/xen/gntdev.h150
-rw-r--r--include/xen/grant_table.h44
-rw-r--r--include/xen/interface/elfnote.h2
-rw-r--r--include/xen/interface/features.h3
-rw-r--r--include/xen/interface/io/blkif.h50
-rw-r--r--include/xen/interface/io/netif.h80
-rw-r--r--include/xen/interface/io/pciif.h112
-rw-r--r--include/xen/interface/io/ring.h11
-rw-r--r--include/xen/interface/io/xenbus.h8
-rw-r--r--include/xen/interface/memory.h42
-rw-r--r--include/xen/interface/physdev.h77
-rw-r--r--include/xen/interface/sched.h34
-rw-r--r--include/xen/interface/xen.h26
-rw-r--r--include/xen/page.h7
-rw-r--r--include/xen/privcmd.h77
-rw-r--r--include/xen/xen-ops.h11
-rw-r--r--include/xen/xenbus.h4
1268 files changed, 54417 insertions, 15447 deletions
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 17714beb868e..5b6c391efc8e 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index 9cf736ea4691..fc1575fd4596 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index bc4a6deb73b0..d7bd661bfae7 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -183,13 +183,19 @@
183 183
184#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) 184#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
185/* 185/*
186 * Module name is included in both debug and non-debug versions primarily for 186 * The module name is used primarily for error and debug messages.
187 * error messages. The __FILE__ macro is not very useful for this, because it 187 * The __FILE__ macro is not very useful for this, because it
188 * often includes the entire pathname to the module 188 * usually includes the entire pathname to the module making the
189 * debug output difficult to read.
189 */ 190 */
190#define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name; 191#define ACPI_MODULE_NAME(name) static const char ACPI_UNUSED_VAR _acpi_module_name[] = name;
191#else 192#else
193/*
194 * For the no-debug and no-error-msg cases, we must at least define
195 * a null module name.
196 */
192#define ACPI_MODULE_NAME(name) 197#define ACPI_MODULE_NAME(name)
198#define _acpi_module_name ""
193#endif 199#endif
194 200
195/* 201/*
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index a091cabca4b1..de39915f6b7f 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 4de84ce3a927..6cd5b6403a7b 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -148,9 +148,7 @@ struct acpi_device_flags {
148 u32 suprise_removal_ok:1; 148 u32 suprise_removal_ok:1;
149 u32 power_manageable:1; 149 u32 power_manageable:1;
150 u32 performance_manageable:1; 150 u32 performance_manageable:1;
151 u32 wake_capable:1; /* Wakeup(_PRW) supported? */ 151 u32 reserved:24;
152 u32 force_power_state:1;
153 u32 reserved:22;
154}; 152};
155 153
156/* File System */ 154/* File System */
@@ -184,7 +182,7 @@ struct acpi_device_pnp {
184 182
185#define acpi_device_bid(d) ((d)->pnp.bus_id) 183#define acpi_device_bid(d) ((d)->pnp.bus_id)
186#define acpi_device_adr(d) ((d)->pnp.bus_address) 184#define acpi_device_adr(d) ((d)->pnp.bus_address)
187char *acpi_device_hid(struct acpi_device *device); 185const char *acpi_device_hid(struct acpi_device *device);
188#define acpi_device_name(d) ((d)->pnp.device_name) 186#define acpi_device_name(d) ((d)->pnp.device_name)
189#define acpi_device_class(d) ((d)->pnp.device_class) 187#define acpi_device_class(d) ((d)->pnp.device_class)
190 188
@@ -212,7 +210,7 @@ struct acpi_device_power_state {
212struct acpi_device_power { 210struct acpi_device_power {
213 int state; /* Current state */ 211 int state; /* Current state */
214 struct acpi_device_power_flags flags; 212 struct acpi_device_power_flags flags;
215 struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ 213 struct acpi_device_power_state states[ACPI_D_STATE_COUNT]; /* Power states (D0-D3Cold) */
216}; 214};
217 215
218/* Performance Management */ 216/* Performance Management */
@@ -242,23 +240,16 @@ struct acpi_device_perf {
242struct acpi_device_wakeup_flags { 240struct acpi_device_wakeup_flags {
243 u8 valid:1; /* Can successfully enable wakeup? */ 241 u8 valid:1; /* Can successfully enable wakeup? */
244 u8 run_wake:1; /* Run-Wake GPE devices */ 242 u8 run_wake:1; /* Run-Wake GPE devices */
245 u8 always_enabled:1; /* Run-wake devices that are always enabled */
246 u8 notifier_present:1; /* Wake-up notify handler has been installed */ 243 u8 notifier_present:1; /* Wake-up notify handler has been installed */
247}; 244};
248 245
249struct acpi_device_wakeup_state {
250 u8 enabled:1;
251};
252
253struct acpi_device_wakeup { 246struct acpi_device_wakeup {
254 acpi_handle gpe_device; 247 acpi_handle gpe_device;
255 u64 gpe_number; 248 u64 gpe_number;
256 u64 sleep_state; 249 u64 sleep_state;
257 struct acpi_handle_list resources; 250 struct acpi_handle_list resources;
258 struct acpi_device_wakeup_state state;
259 struct acpi_device_wakeup_flags flags; 251 struct acpi_device_wakeup_flags flags;
260 int prepare_count; 252 int prepare_count;
261 int run_wake_count;
262}; 253};
263 254
264/* Device */ 255/* Device */
@@ -328,8 +319,8 @@ void acpi_bus_data_handler(acpi_handle handle, void *context);
328acpi_status acpi_bus_get_status_handle(acpi_handle handle, 319acpi_status acpi_bus_get_status_handle(acpi_handle handle,
329 unsigned long long *sta); 320 unsigned long long *sta);
330int acpi_bus_get_status(struct acpi_device *device); 321int acpi_bus_get_status(struct acpi_device *device);
331int acpi_bus_get_power(acpi_handle handle, int *state);
332int acpi_bus_set_power(acpi_handle handle, int state); 322int acpi_bus_set_power(acpi_handle handle, int state);
323int acpi_bus_update_power(acpi_handle handle, int *state_p);
333bool acpi_bus_power_manageable(acpi_handle handle); 324bool acpi_bus_power_manageable(acpi_handle handle);
334bool acpi_bus_can_wakeup(acpi_handle handle); 325bool acpi_bus_can_wakeup(acpi_handle handle);
335#ifdef CONFIG_ACPI_PROC_EVENT 326#ifdef CONFIG_ACPI_PROC_EVENT
@@ -389,21 +380,25 @@ struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
389int acpi_enable_wakeup_device_power(struct acpi_device *dev, int state); 380int acpi_enable_wakeup_device_power(struct acpi_device *dev, int state);
390int acpi_disable_wakeup_device_power(struct acpi_device *dev); 381int acpi_disable_wakeup_device_power(struct acpi_device *dev);
391 382
392#ifdef CONFIG_PM_SLEEP 383#ifdef CONFIG_PM
393int acpi_pm_device_sleep_state(struct device *, int *); 384int acpi_pm_device_sleep_state(struct device *, int *);
394int acpi_pm_device_sleep_wake(struct device *, bool); 385#else
395#else /* !CONFIG_PM_SLEEP */
396static inline int acpi_pm_device_sleep_state(struct device *d, int *p) 386static inline int acpi_pm_device_sleep_state(struct device *d, int *p)
397{ 387{
398 if (p) 388 if (p)
399 *p = ACPI_STATE_D0; 389 *p = ACPI_STATE_D0;
400 return ACPI_STATE_D3; 390 return ACPI_STATE_D3;
401} 391}
392#endif
393
394#ifdef CONFIG_PM_SLEEP
395int acpi_pm_device_sleep_wake(struct device *, bool);
396#else
402static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) 397static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
403{ 398{
404 return -ENODEV; 399 return -ENODEV;
405} 400}
406#endif /* !CONFIG_PM_SLEEP */ 401#endif
407 402
408#endif /* CONFIG_ACPI */ 403#endif /* CONFIG_ACPI */
409 404
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 23d78b4d088b..3090471b2a5e 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -115,8 +115,6 @@ void pci_acpi_crs_quirks(void);
115#define ACPI_PROCESSOR_LIMIT_INCREMENT 0x01 115#define ACPI_PROCESSOR_LIMIT_INCREMENT 0x01
116#define ACPI_PROCESSOR_LIMIT_DECREMENT 0x02 116#define ACPI_PROCESSOR_LIMIT_DECREMENT 0x02
117 117
118int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
119
120/*-------------------------------------------------------------------------- 118/*--------------------------------------------------------------------------
121 Dock Station 119 Dock Station
122 -------------------------------------------------------------------------- */ 120 -------------------------------------------------------------------------- */
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 29bf945143e8..4543b6f75867 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -8,7 +8,7 @@
8 *****************************************************************************/ 8 *****************************************************************************/
9 9
10/* 10/*
11 * Copyright (C) 2000 - 2010, Intel Corp. 11 * Copyright (C) 2000 - 2011, Intel Corp.
12 * All rights reserved. 12 * All rights reserved.
13 * 13 *
14 * Redistribution and use in source and binary forms, with or without 14 * Redistribution and use in source and binary forms, with or without
@@ -98,7 +98,11 @@ acpi_os_table_override(struct acpi_table_header *existing_table,
98/* 98/*
99 * Spinlock primitives 99 * Spinlock primitives
100 */ 100 */
101acpi_status acpi_os_create_lock(acpi_spinlock * out_handle); 101
102#ifndef acpi_os_create_lock
103acpi_status
104acpi_os_create_lock(acpi_spinlock *out_handle);
105#endif
102 106
103void acpi_os_delete_lock(acpi_spinlock handle); 107void acpi_os_delete_lock(acpi_spinlock handle);
104 108
@@ -223,25 +227,15 @@ acpi_os_write_memory(acpi_physical_address address, u32 value, u32 width);
223 */ 227 */
224acpi_status 228acpi_status
225acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id, 229acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
226 u32 reg, u32 *value, u32 width); 230 u32 reg, u64 *value, u32 width);
227 231
228acpi_status 232acpi_status
229acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id, 233acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
230 u32 reg, u64 value, u32 width); 234 u32 reg, u64 value, u32 width);
231 235
232/* 236/*
233 * Interim function needed for PCI IRQ routing
234 */
235void
236acpi_os_derive_pci_id(acpi_handle device,
237 acpi_handle region, struct acpi_pci_id **pci_id);
238
239/*
240 * Miscellaneous 237 * Miscellaneous
241 */ 238 */
242acpi_status acpi_os_validate_interface(char *interface);
243acpi_status acpi_osi_invalidate(char* interface);
244
245acpi_status 239acpi_status
246acpi_os_validate_address(u8 space_id, acpi_physical_address address, 240acpi_os_validate_address(u8 space_id, acpi_physical_address address,
247 acpi_size length, char *name); 241 acpi_size length, char *name);
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 984cdc62e30b..2ed0a8486c19 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@
47 47
48/* Current ACPICA subsystem version in YYYYMMDD format */ 48/* Current ACPICA subsystem version in YYYYMMDD format */
49 49
50#define ACPI_CA_VERSION 0x20100702 50#define ACPI_CA_VERSION 0x20110413
51 51
52#include "actypes.h" 52#include "actypes.h"
53#include "actbl.h" 53#include "actbl.h"
@@ -72,6 +72,7 @@ extern u8 acpi_gbl_truncate_io_addresses;
72 72
73extern u32 acpi_current_gpe_count; 73extern u32 acpi_current_gpe_count;
74extern struct acpi_table_fadt acpi_gbl_FADT; 74extern struct acpi_table_fadt acpi_gbl_FADT;
75extern u8 acpi_gbl_system_awake_and_running;
75 76
76extern u32 acpi_rsdt_forced; 77extern u32 acpi_rsdt_forced;
77/* 78/*
@@ -105,6 +106,10 @@ const char *acpi_format_exception(acpi_status exception);
105 106
106acpi_status acpi_purge_cached_objects(void); 107acpi_status acpi_purge_cached_objects(void);
107 108
109acpi_status acpi_install_interface(acpi_string interface_name);
110
111acpi_status acpi_remove_interface(acpi_string interface_name);
112
108/* 113/*
109 * ACPI Memory management 114 * ACPI Memory management
110 */ 115 */
@@ -224,6 +229,10 @@ acpi_status
224acpi_install_initialization_handler(acpi_init_handler handler, u32 function); 229acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
225 230
226acpi_status 231acpi_status
232acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler,
233 void *context);
234
235acpi_status
227acpi_install_fixed_event_handler(u32 acpi_event, 236acpi_install_fixed_event_handler(u32 acpi_event,
228 acpi_event_handler handler, void *context); 237 acpi_event_handler handler, void *context);
229 238
@@ -253,16 +262,18 @@ acpi_remove_address_space_handler(acpi_handle device,
253acpi_status 262acpi_status
254acpi_install_gpe_handler(acpi_handle gpe_device, 263acpi_install_gpe_handler(acpi_handle gpe_device,
255 u32 gpe_number, 264 u32 gpe_number,
256 u32 type, acpi_event_handler address, void *context); 265 u32 type, acpi_gpe_handler address, void *context);
257 266
258acpi_status 267acpi_status
259acpi_remove_gpe_handler(acpi_handle gpe_device, 268acpi_remove_gpe_handler(acpi_handle gpe_device,
260 u32 gpe_number, acpi_event_handler address); 269 u32 gpe_number, acpi_gpe_handler address);
261 270
262#ifdef ACPI_FUTURE_USAGE 271#ifdef ACPI_FUTURE_USAGE
263acpi_status acpi_install_exception_handler(acpi_exception_handler handler); 272acpi_status acpi_install_exception_handler(acpi_exception_handler handler);
264#endif 273#endif
265 274
275acpi_status acpi_install_interface_handler(acpi_interface_handler handler);
276
266/* 277/*
267 * Event interfaces 278 * Event interfaces
268 */ 279 */
@@ -285,11 +296,13 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number);
285 296
286acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number); 297acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number);
287 298
288acpi_status acpi_gpe_can_wake(acpi_handle gpe_device, u32 gpe_number);
289
290acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number); 299acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number);
291 300
292acpi_status acpi_gpe_wakeup(acpi_handle gpe_device, u32 gpe_number, u8 action); 301acpi_status
302acpi_setup_gpe_for_wake(acpi_handle parent_device,
303 acpi_handle gpe_device, u32 gpe_number);
304
305acpi_status acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action);
293 306
294acpi_status 307acpi_status
295acpi_get_gpe_status(acpi_handle gpe_device, 308acpi_get_gpe_status(acpi_handle gpe_device,
@@ -308,6 +321,8 @@ acpi_install_gpe_block(acpi_handle gpe_device,
308 321
309acpi_status acpi_remove_gpe_block(acpi_handle gpe_device); 322acpi_status acpi_remove_gpe_block(acpi_handle gpe_device);
310 323
324acpi_status acpi_update_all_gpes(void);
325
311/* 326/*
312 * Resource interfaces 327 * Resource interfaces
313 */ 328 */
diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
index e5526354ba5e..0a66cc45dd6b 100644
--- a/include/acpi/acrestyp.h
+++ b/include/acpi/acrestyp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index ad2001683ba7..f1380287ed4d 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -290,7 +290,7 @@ struct acpi_table_fadt {
290#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: [V4] All local APICs must use cluster model (ACPI 3.0) */ 290#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: [V4] All local APICs must use cluster model (ACPI 3.0) */
291#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: [V4] All local x_aPICs must use physical dest mode (ACPI 3.0) */ 291#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: [V4] All local x_aPICs must use physical dest mode (ACPI 3.0) */
292 292
293/* Values for preferred_profile (Prefered Power Management Profiles) */ 293/* Values for preferred_profile (Preferred Power Management Profiles) */
294 294
295enum acpi_prefered_pm_profiles { 295enum acpi_prefered_pm_profiles {
296 PM_UNSPECIFIED = 0, 296 PM_UNSPECIFIED = 0,
@@ -343,4 +343,20 @@ struct acpi_table_desc {
343#include <acpi/actbl1.h> 343#include <acpi/actbl1.h>
344#include <acpi/actbl2.h> 344#include <acpi/actbl2.h>
345 345
346/*
347 * Sizes of the various flavors of FADT. We need to look closely
348 * at the FADT length because the version number essentially tells
349 * us nothing because of many BIOS bugs where the version does not
350 * match the expected length. In other words, the length of the
351 * FADT is the bottom line as to what the version really is.
352 *
353 * For reference, the values below are as follows:
354 * FADT V1 size: 0x74
355 * FADT V2 size: 0x84
356 * FADT V3+ size: 0xF4
357 */
358#define ACPI_FADT_V1_SIZE (u32) (ACPI_FADT_OFFSET (flags) + 4)
359#define ACPI_FADT_V2_SIZE (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3)
360#define ACPI_FADT_V3_SIZE (u32) (sizeof (struct acpi_table_fadt))
361
346#endif /* __ACTBL_H__ */ 362#endif /* __ACTBL_H__ */
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index c637b75b9f3f..7504bc99b29b 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -119,7 +119,7 @@ struct acpi_whea_header {
119struct acpi_table_bert { 119struct acpi_table_bert {
120 struct acpi_table_header header; /* Common ACPI table header */ 120 struct acpi_table_header header; /* Common ACPI table header */
121 u32 region_length; /* Length of the boot error region */ 121 u32 region_length; /* Length of the boot error region */
122 u64 address; /* Physical addresss of the error region */ 122 u64 address; /* Physical address of the error region */
123}; 123};
124 124
125/* Boot Error Region (not a subtable, pointed to by Address field above) */ 125/* Boot Error Region (not a subtable, pointed to by Address field above) */
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index d4136b28011f..58bdd0545c5a 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -1,11 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Name: actbl2.h - ACPI Specification Revision 2.0 Tables 3 * Name: actbl2.h - ACPI Table Definitions (tables not in ACPI spec)
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -716,6 +716,68 @@ struct acpi_table_mchi {
716 716
717/******************************************************************************* 717/*******************************************************************************
718 * 718 *
719 * SLIC - Software Licensing Description Table
720 * Version 1
721 *
722 * Conforms to "OEM Activation 2.0 for Windows Vista Operating Systems",
723 * Copyright 2006
724 *
725 ******************************************************************************/
726
727/* Basic SLIC table is only the common ACPI header */
728
729struct acpi_table_slic {
730 struct acpi_table_header header; /* Common ACPI table header */
731};
732
733/* Common SLIC subtable header */
734
735struct acpi_slic_header {
736 u32 type;
737 u32 length;
738};
739
740/* Values for Type field above */
741
742enum acpi_slic_type {
743 ACPI_SLIC_TYPE_PUBLIC_KEY = 0,
744 ACPI_SLIC_TYPE_WINDOWS_MARKER = 1,
745 ACPI_SLIC_TYPE_RESERVED = 2 /* 2 and greater are reserved */
746};
747
748/*
749 * SLIC Sub-tables, correspond to Type in struct acpi_slic_header
750 */
751
752/* 0: Public Key Structure */
753
754struct acpi_slic_key {
755 struct acpi_slic_header header;
756 u8 key_type;
757 u8 version;
758 u16 reserved;
759 u32 algorithm;
760 char magic[4];
761 u32 bit_length;
762 u32 exponent;
763 u8 modulus[128];
764};
765
766/* 1: Windows Marker Structure */
767
768struct acpi_slic_marker {
769 struct acpi_slic_header header;
770 u32 version;
771 char oem_id[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */
772 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */
773 char windows_flag[8];
774 u32 slic_version;
775 u8 reserved[16];
776 u8 signature[128];
777};
778
779/*******************************************************************************
780 *
719 * SPCR - Serial Port Console Redirection table 781 * SPCR - Serial Port Console Redirection table
720 * Version 1 782 * Version 1
721 * 783 *
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 5db8f472fec9..b67231bef632 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -115,7 +115,6 @@
115 * 115 *
116 * ACPI_SIZE 16/32/64-bit unsigned value 116 * ACPI_SIZE 16/32/64-bit unsigned value
117 * ACPI_NATIVE_INT 16/32/64-bit signed value 117 * ACPI_NATIVE_INT 16/32/64-bit signed value
118 *
119 */ 118 */
120 119
121/******************************************************************************* 120/*******************************************************************************
@@ -132,6 +131,16 @@ typedef COMPILER_DEPENDENT_INT64 INT64;
132 131
133/*! [End] no source code translation !*/ 132/*! [End] no source code translation !*/
134 133
134/*
135 * Value returned by acpi_os_get_thread_id. There is no standard "thread_id"
136 * across operating systems or even the various UNIX systems. Since ACPICA
137 * only needs the thread ID as a unique thread identifier, we use a u64
138 * as the only common data type - it will accommodate any type of pointer or
139 * any type of integer. It is up to the host-dependent OSL to cast the
140 * native thread ID type to a u64 (in acpi_os_get_thread_id).
141 */
142#define acpi_thread_id u64
143
135/******************************************************************************* 144/*******************************************************************************
136 * 145 *
137 * Types specific to 64-bit targets 146 * Types specific to 64-bit targets
@@ -211,12 +220,6 @@ typedef u32 acpi_physical_address;
211 * 220 *
212 ******************************************************************************/ 221 ******************************************************************************/
213 222
214/* Value returned by acpi_os_get_thread_id */
215
216#ifndef acpi_thread_id
217#define acpi_thread_id acpi_size
218#endif
219
220/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */ 223/* Flags for acpi_os_acquire_lock/acpi_os_release_lock */
221 224
222#ifndef acpi_cpu_flags 225#ifndef acpi_cpu_flags
@@ -375,16 +378,6 @@ typedef void *acpi_handle; /* Actually a ptr to a NS Node */
375typedef u8 acpi_owner_id; 378typedef u8 acpi_owner_id;
376#define ACPI_OWNER_ID_MAX 0xFF 379#define ACPI_OWNER_ID_MAX 0xFF
377 380
378struct uint64_struct {
379 u32 lo;
380 u32 hi;
381};
382
383union uint64_overlay {
384 u64 full;
385 struct uint64_struct part;
386};
387
388#define ACPI_INTEGER_BIT_SIZE 64 381#define ACPI_INTEGER_BIT_SIZE 64
389#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ 382#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */
390 383
@@ -508,8 +501,9 @@ typedef u64 acpi_integer;
508#define ACPI_STATE_D1 (u8) 1 501#define ACPI_STATE_D1 (u8) 1
509#define ACPI_STATE_D2 (u8) 2 502#define ACPI_STATE_D2 (u8) 2
510#define ACPI_STATE_D3 (u8) 3 503#define ACPI_STATE_D3 (u8) 3
511#define ACPI_D_STATES_MAX ACPI_STATE_D3 504#define ACPI_STATE_D3_COLD (u8) 4
512#define ACPI_D_STATE_COUNT 4 505#define ACPI_D_STATES_MAX ACPI_STATE_D3_COLD
506#define ACPI_D_STATE_COUNT 5
513 507
514#define ACPI_STATE_C0 (u8) 0 508#define ACPI_STATE_C0 (u8) 0
515#define ACPI_STATE_C1 (u8) 1 509#define ACPI_STATE_C1 (u8) 1
@@ -663,33 +657,34 @@ typedef u32 acpi_event_status;
663#define ACPI_GPE_MAX 0xFF 657#define ACPI_GPE_MAX 0xFF
664#define ACPI_NUM_GPE 256 658#define ACPI_NUM_GPE 256
665 659
666/* Actions for acpi_gpe_wakeup, acpi_hw_low_set_gpe */ 660/* Actions for acpi_set_gpe_wake_mask, acpi_hw_low_set_gpe */
667 661
668#define ACPI_GPE_ENABLE 0 662#define ACPI_GPE_ENABLE 0
669#define ACPI_GPE_DISABLE 1 663#define ACPI_GPE_DISABLE 1
670#define ACPI_GPE_COND_ENABLE 2 664#define ACPI_GPE_CONDITIONAL_ENABLE 2
671 665
672/* 666/*
673 * GPE info flags - Per GPE 667 * GPE info flags - Per GPE
674 * +-------+---+-+-+ 668 * +-------+-+-+---+
675 * | 7:4 |3:2|1|0| 669 * | 7:4 |3|2|1:0|
676 * +-------+---+-+-+ 670 * +-------+-+-+---+
677 * | | | | 671 * | | | |
678 * | | | +--- Interrupt type: edge or level triggered 672 * | | | +-- Type of dispatch:to method, handler, notify, or none
679 * | | +----- GPE can wake the system 673 * | | +----- Interrupt type: edge or level triggered
680 * | +-------- Type of dispatch:to method, handler, or none 674 * | +------- Is a Wake GPE
681 * +-------------- <Reserved> 675 * +------------ <Reserved>
682 */ 676 */
683#define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x01 677#define ACPI_GPE_DISPATCH_NONE (u8) 0x00
684#define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x01 678#define ACPI_GPE_DISPATCH_METHOD (u8) 0x01
685#define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00 679#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x02
680#define ACPI_GPE_DISPATCH_NOTIFY (u8) 0x03
681#define ACPI_GPE_DISPATCH_MASK (u8) 0x03
686 682
687#define ACPI_GPE_CAN_WAKE (u8) 0x02 683#define ACPI_GPE_LEVEL_TRIGGERED (u8) 0x04
684#define ACPI_GPE_EDGE_TRIGGERED (u8) 0x00
685#define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x04
688 686
689#define ACPI_GPE_DISPATCH_MASK (u8) 0x0C 687#define ACPI_GPE_CAN_WAKE (u8) 0x08
690#define ACPI_GPE_DISPATCH_HANDLER (u8) 0x04
691#define ACPI_GPE_DISPATCH_METHOD (u8) 0x08
692#define ACPI_GPE_DISPATCH_NOT_USED (u8) 0x00
693 688
694/* 689/*
695 * Flags for GPE and Lock interfaces 690 * Flags for GPE and Lock interfaces
@@ -718,8 +713,24 @@ typedef u8 acpi_adr_space_type;
718#define ACPI_ADR_SPACE_CMOS (acpi_adr_space_type) 5 713#define ACPI_ADR_SPACE_CMOS (acpi_adr_space_type) 5
719#define ACPI_ADR_SPACE_PCI_BAR_TARGET (acpi_adr_space_type) 6 714#define ACPI_ADR_SPACE_PCI_BAR_TARGET (acpi_adr_space_type) 6
720#define ACPI_ADR_SPACE_IPMI (acpi_adr_space_type) 7 715#define ACPI_ADR_SPACE_IPMI (acpi_adr_space_type) 7
721#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 8 716
722#define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 127 717#define ACPI_NUM_PREDEFINED_REGIONS 8
718
719/*
720 * Special Address Spaces
721 *
722 * Note: A Data Table region is a special type of operation region
723 * that has its own AML opcode. However, internally, the AML
724 * interpreter simply creates an operation region with an an address
725 * space type of ACPI_ADR_SPACE_DATA_TABLE.
726 */
727#define ACPI_ADR_SPACE_DATA_TABLE (acpi_adr_space_type) 0x7E /* Internal to ACPICA only */
728#define ACPI_ADR_SPACE_FIXED_HARDWARE (acpi_adr_space_type) 0x7F
729
730/* Values for _REG connection code */
731
732#define ACPI_REG_DISCONNECT 0
733#define ACPI_REG_CONNECT 1
723 734
724/* 735/*
725 * bit_register IDs 736 * bit_register IDs
@@ -901,9 +912,20 @@ typedef void
901/* 912/*
902 * Various handlers and callback procedures 913 * Various handlers and callback procedures
903 */ 914 */
915typedef
916void (*ACPI_GBL_EVENT_HANDLER) (u32 event_type,
917 acpi_handle device,
918 u32 event_number, void *context);
919
920#define ACPI_EVENT_TYPE_GPE 0
921#define ACPI_EVENT_TYPE_FIXED 1
922
904typedef u32(*acpi_event_handler) (void *context); 923typedef u32(*acpi_event_handler) (void *context);
905 924
906typedef 925typedef
926u32 (*acpi_gpe_handler) (acpi_handle gpe_device, u32 gpe_number, void *context);
927
928typedef
907void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context); 929void (*acpi_notify_handler) (acpi_handle device, u32 value, void *context);
908 930
909typedef 931typedef
@@ -950,11 +972,18 @@ acpi_status(*acpi_walk_callback) (acpi_handle object,
950 u32 nesting_level, 972 u32 nesting_level,
951 void *context, void **return_value); 973 void *context, void **return_value);
952 974
975typedef
976u32 (*acpi_interface_handler) (acpi_string interface_name, u32 supported);
977
953/* Interrupt handler return values */ 978/* Interrupt handler return values */
954 979
955#define ACPI_INTERRUPT_NOT_HANDLED 0x00 980#define ACPI_INTERRUPT_NOT_HANDLED 0x00
956#define ACPI_INTERRUPT_HANDLED 0x01 981#define ACPI_INTERRUPT_HANDLED 0x01
957 982
983/* GPE handler return values */
984
985#define ACPI_REENABLE_GPE 0x80
986
958/* Length of 32-bit EISAID values when converted back to a string */ 987/* Length of 32-bit EISAID values when converted back to a string */
959 988
960#define ACPI_EISAID_STRING_SIZE 8 /* Includes null terminator */ 989#define ACPI_EISAID_STRING_SIZE 8 /* Includes null terminator */
diff --git a/include/acpi/apei.h b/include/acpi/apei.h
index b3365025ff8d..e67b523a50e1 100644
--- a/include/acpi/apei.h
+++ b/include/acpi/apei.h
@@ -19,15 +19,22 @@
19extern int hest_disable; 19extern int hest_disable;
20extern int erst_disable; 20extern int erst_disable;
21 21
22#ifdef CONFIG_ACPI_APEI
23void __init acpi_hest_init(void);
24#else
25static inline void acpi_hest_init(void) { return; }
26#endif
27
22typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data); 28typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data);
23int apei_hest_parse(apei_hest_func_t func, void *data); 29int apei_hest_parse(apei_hest_func_t func, void *data);
24 30
25int erst_write(const struct cper_record_header *record); 31int erst_write(const struct cper_record_header *record);
26ssize_t erst_get_record_count(void); 32ssize_t erst_get_record_count(void);
27int erst_get_next_record_id(u64 *record_id); 33int erst_get_record_id_begin(int *pos);
34int erst_get_record_id_next(int *pos, u64 *record_id);
35void erst_get_record_id_end(void);
28ssize_t erst_read(u64 record_id, struct cper_record_header *record, 36ssize_t erst_read(u64 record_id, struct cper_record_header *record,
29 size_t buflen); 37 size_t buflen);
30ssize_t erst_read_next(struct cper_record_header *record, size_t buflen);
31int erst_clear(u64 record_id); 38int erst_clear(u64 record_id);
32 39
33#endif 40#endif
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index c05aeba9e8f0..5af3ed52ef98 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -193,6 +193,12 @@
193#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE 193#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
194#endif 194#endif
195 195
196/* "inline" keywords - configurable since inline is not standardized */
197
198#ifndef ACPI_INLINE
199#define ACPI_INLINE
200#endif
201
196/* 202/*
197 * Debugger threading model 203 * Debugger threading model
198 * Use single threaded if the entire subsystem is contained in an application 204 * Use single threaded if the entire subsystem is contained in an application
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index 0cd53e3cd1a3..e228893591a9 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,8 @@
44#ifndef __ACGCC_H__ 44#ifndef __ACGCC_H__
45#define __ACGCC_H__ 45#define __ACGCC_H__
46 46
47#define ACPI_INLINE __inline__
48
47/* Function name is used for debug output. Non-ANSI, compiler-dependent */ 49/* Function name is used for debug output. Non-ANSI, compiler-dependent */
48 50
49#define ACPI_GET_FUNCTION_NAME __func__ 51#define ACPI_GET_FUNCTION_NAME __func__
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 103f08aca764..2ce1be9f6291 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -75,7 +75,6 @@
75#define acpi_cache_t struct kmem_cache 75#define acpi_cache_t struct kmem_cache
76#define acpi_spinlock spinlock_t * 76#define acpi_spinlock spinlock_t *
77#define acpi_cpu_flags unsigned long 77#define acpi_cpu_flags unsigned long
78#define acpi_thread_id struct task_struct *
79 78
80#else /* !__KERNEL__ */ 79#else /* !__KERNEL__ */
81 80
@@ -88,7 +87,7 @@
88/* Host-dependent types and defines for user-space ACPICA */ 87/* Host-dependent types and defines for user-space ACPICA */
89 88
90#define ACPI_FLUSH_CPU_CACHE() 89#define ACPI_FLUSH_CPU_CACHE()
91#define acpi_thread_id pthread_t 90#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
92 91
93#if defined(__ia64__) || defined(__x86_64__) 92#if defined(__ia64__) || defined(__x86_64__)
94#define ACPI_MACHINE_WIDTH 64 93#define ACPI_MACHINE_WIDTH 64
@@ -113,12 +112,13 @@
113 112
114 113
115#ifdef __KERNEL__ 114#ifdef __KERNEL__
115#include <acpi/actypes.h>
116/* 116/*
117 * Overrides for in-kernel ACPICA 117 * Overrides for in-kernel ACPICA
118 */ 118 */
119static inline acpi_thread_id acpi_os_get_thread_id(void) 119static inline acpi_thread_id acpi_os_get_thread_id(void)
120{ 120{
121 return current; 121 return (acpi_thread_id)(unsigned long)current;
122} 122}
123 123
124/* 124/*
@@ -127,7 +127,6 @@ static inline acpi_thread_id acpi_os_get_thread_id(void)
127 * However, boot has (system_state != SYSTEM_RUNNING) 127 * However, boot has (system_state != SYSTEM_RUNNING)
128 * to quiet __might_sleep() in kmalloc() and resume does not. 128 * to quiet __might_sleep() in kmalloc() and resume does not.
129 */ 129 */
130#include <acpi/actypes.h>
131static inline void *acpi_os_allocate(acpi_size size) 130static inline void *acpi_os_allocate(acpi_size size)
132{ 131{
133 return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); 132 return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
@@ -160,6 +159,24 @@ static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
160 } while (0) 159 } while (0)
161#endif 160#endif
162 161
162/*
163 * When lockdep is enabled, the spin_lock_init() macro stringifies it's
164 * argument and uses that as a name for the lock in debugging.
165 * By executing spin_lock_init() in a macro the key changes from "lock" for
166 * all locks to the name of the argument of acpi_os_create_lock(), which
167 * prevents lockdep from reporting false positives for ACPICA locks.
168 */
169#define acpi_os_create_lock(__handle) \
170({ \
171 spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
172 \
173 if (lock) { \
174 *(__handle) = lock; \
175 spin_lock_init(*(__handle)); \
176 } \
177 lock ? AE_OK : AE_NO_MEMORY; \
178})
179
163#endif /* __KERNEL__ */ 180#endif /* __KERNEL__ */
164 181
165#endif /* __ACLINUX_H__ */ 182#endif /* __ACLINUX_H__ */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 1b62102fbb67..ba4928cae473 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -310,20 +310,19 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
310 310
311/* in processor_core.c */ 311/* in processor_core.c */
312void acpi_processor_set_pdc(acpi_handle handle); 312void acpi_processor_set_pdc(acpi_handle handle);
313#ifdef CONFIG_SMP
314int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 313int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
315#else
316static inline int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
317{
318 return -1;
319}
320#endif
321 314
322/* in processor_throttling.c */ 315/* in processor_throttling.c */
323int acpi_processor_tstate_has_changed(struct acpi_processor *pr); 316int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
324int acpi_processor_get_throttling_info(struct acpi_processor *pr); 317int acpi_processor_get_throttling_info(struct acpi_processor *pr);
325extern int acpi_processor_set_throttling(struct acpi_processor *pr, 318extern int acpi_processor_set_throttling(struct acpi_processor *pr,
326 int state, bool force); 319 int state, bool force);
320/*
321 * Reevaluate whether the T-state is invalid after one cpu is
322 * onlined/offlined. In such case the flags.throttling will be updated.
323 */
324extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
325 unsigned long action);
327extern const struct file_operations acpi_processor_throttling_fops; 326extern const struct file_operations acpi_processor_throttling_fops;
328extern void acpi_processor_throttling_init(void); 327extern void acpi_processor_throttling_init(void);
329/* in processor_idle.c */ 328/* in processor_idle.c */
diff --git a/include/acpi/video.h b/include/acpi/video.h
index 551793c9b6e8..0e98e679d3a7 100644
--- a/include/acpi/video.h
+++ b/include/acpi/video.h
@@ -1,6 +1,10 @@
1#ifndef __ACPI_VIDEO_H 1#ifndef __ACPI_VIDEO_H
2#define __ACPI_VIDEO_H 2#define __ACPI_VIDEO_H
3 3
4#include <linux/errno.h> /* for ENODEV */
5
6struct acpi_device;
7
4#define ACPI_VIDEO_DISPLAY_CRT 1 8#define ACPI_VIDEO_DISPLAY_CRT 1
5#define ACPI_VIDEO_DISPLAY_TV 2 9#define ACPI_VIDEO_DISPLAY_TV 2
6#define ACPI_VIDEO_DISPLAY_DVI 3 10#define ACPI_VIDEO_DISPLAY_DVI 3
@@ -26,4 +30,3 @@ static inline int acpi_video_get_edid(struct acpi_device *device, int type,
26#endif 30#endif
27 31
28#endif 32#endif
29
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index e53347fbf1da..e994197f84b7 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -43,6 +43,7 @@
43 */ 43 */
44#define atomic_set(v, i) (((v)->counter) = (i)) 44#define atomic_set(v, i) (((v)->counter) = (i))
45 45
46#include <linux/irqflags.h>
46#include <asm/system.h> 47#include <asm/system.h>
47 48
48/** 49/**
@@ -57,7 +58,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
57 unsigned long flags; 58 unsigned long flags;
58 int temp; 59 int temp;
59 60
60 raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */ 61 raw_local_irq_save(flags); /* Don't trace it in an irqsoff handler */
61 temp = v->counter; 62 temp = v->counter;
62 temp += i; 63 temp += i;
63 v->counter = temp; 64 v->counter = temp;
@@ -78,7 +79,7 @@ static inline int atomic_sub_return(int i, atomic_t *v)
78 unsigned long flags; 79 unsigned long flags;
79 int temp; 80 int temp;
80 81
81 raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */ 82 raw_local_irq_save(flags); /* Don't trace it in an irqsoff handler */
82 temp = v->counter; 83 temp = v->counter;
83 temp -= i; 84 temp -= i;
84 v->counter = temp; 85 v->counter = temp;
@@ -119,14 +120,23 @@ static inline void atomic_dec(atomic_t *v)
119#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) 120#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
120#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0) 121#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
121 122
122#define atomic_add_unless(v, a, u) \ 123#define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v)))
123({ \ 124#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
124 int c, old; \ 125
125 c = atomic_read(v); \ 126#define cmpxchg_local(ptr, o, n) \
126 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 127 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
127 c = old; \ 128 (unsigned long)(n), sizeof(*(ptr))))
128 c != (u); \ 129
129}) 130#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
131
132static inline int atomic_add_unless(atomic_t *v, int a, int u)
133{
134 int c, old;
135 c = atomic_read(v);
136 while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c)
137 c = old;
138 return c != u;
139}
130 140
131#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 141#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
132 142
@@ -140,15 +150,6 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
140 raw_local_irq_restore(flags); 150 raw_local_irq_restore(flags);
141} 151}
142 152
143#define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v)))
144#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
145
146#define cmpxchg_local(ptr, o, n) \
147 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
148 (unsigned long)(n), sizeof(*(ptr))))
149
150#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
151
152/* Assume that atomic operations are already serializing */ 153/* Assume that atomic operations are already serializing */
153#define smp_mb__before_atomic_dec() barrier() 154#define smp_mb__before_atomic_dec() barrier()
154#define smp_mb__after_atomic_dec() barrier() 155#define smp_mb__after_atomic_dec() barrier()
diff --git a/include/asm-generic/audit_change_attr.h b/include/asm-generic/audit_change_attr.h
index 50764550a60c..89b73e5d0fd0 100644
--- a/include/asm-generic/audit_change_attr.h
+++ b/include/asm-generic/audit_change_attr.h
@@ -1,4 +1,6 @@
1#ifdef __NR_chmod
1__NR_chmod, 2__NR_chmod,
3#endif
2__NR_fchmod, 4__NR_fchmod,
3#ifdef __NR_chown 5#ifdef __NR_chown
4__NR_chown, 6__NR_chown,
@@ -20,3 +22,9 @@ __NR_chown32,
20__NR_fchown32, 22__NR_fchown32,
21__NR_lchown32, 23__NR_lchown32,
22#endif 24#endif
25#ifdef __NR_link
26__NR_link,
27#endif
28#ifdef __NR_linkat
29__NR_linkat,
30#endif
diff --git a/include/asm-generic/audit_dir_write.h b/include/asm-generic/audit_dir_write.h
index 6621bd82cbe8..7b61db4fe72b 100644
--- a/include/asm-generic/audit_dir_write.h
+++ b/include/asm-generic/audit_dir_write.h
@@ -1,13 +1,27 @@
1#ifdef __NR_rename
1__NR_rename, 2__NR_rename,
3#endif
4#ifdef __NR_mkdir
2__NR_mkdir, 5__NR_mkdir,
6#endif
7#ifdef __NR_rmdir
3__NR_rmdir, 8__NR_rmdir,
9#endif
4#ifdef __NR_creat 10#ifdef __NR_creat
5__NR_creat, 11__NR_creat,
6#endif 12#endif
13#ifdef __NR_link
7__NR_link, 14__NR_link,
15#endif
16#ifdef __NR_unlink
8__NR_unlink, 17__NR_unlink,
18#endif
19#ifdef __NR_symlink
9__NR_symlink, 20__NR_symlink,
21#endif
22#ifdef __NR_mknod
10__NR_mknod, 23__NR_mknod,
24#endif
11#ifdef __NR_mkdirat 25#ifdef __NR_mkdirat
12__NR_mkdirat, 26__NR_mkdirat,
13__NR_mknodat, 27__NR_mknodat,
diff --git a/include/asm-generic/audit_read.h b/include/asm-generic/audit_read.h
index 0e87464d9847..3b249cb857dc 100644
--- a/include/asm-generic/audit_read.h
+++ b/include/asm-generic/audit_read.h
@@ -1,4 +1,6 @@
1#ifdef __NR_readlink
1__NR_readlink, 2__NR_readlink,
3#endif
2__NR_quotactl, 4__NR_quotactl,
3__NR_listxattr, 5__NR_listxattr,
4__NR_llistxattr, 6__NR_llistxattr,
@@ -6,3 +8,6 @@ __NR_flistxattr,
6__NR_getxattr, 8__NR_getxattr,
7__NR_lgetxattr, 9__NR_lgetxattr,
8__NR_fgetxattr, 10__NR_fgetxattr,
11#ifdef __NR_readlinkat
12__NR_readlinkat,
13#endif
diff --git a/include/asm-generic/audit_write.h b/include/asm-generic/audit_write.h
index c5f1c2c920e2..e7020c57b13b 100644
--- a/include/asm-generic/audit_write.h
+++ b/include/asm-generic/audit_write.h
@@ -4,7 +4,9 @@ __NR_acct,
4__NR_swapon, 4__NR_swapon,
5#endif 5#endif
6__NR_quotactl, 6__NR_quotactl,
7#ifdef __NR_truncate
7__NR_truncate, 8__NR_truncate,
9#endif
8#ifdef __NR_truncate64 10#ifdef __NR_truncate64
9__NR_truncate64, 11__NR_truncate64,
10#endif 12#endif
diff --git a/include/asm-generic/bitops.h b/include/asm-generic/bitops.h
index a54f4421a24d..280ca7a96f75 100644
--- a/include/asm-generic/bitops.h
+++ b/include/asm-generic/bitops.h
@@ -38,8 +38,7 @@
38 38
39#include <asm-generic/bitops/atomic.h> 39#include <asm-generic/bitops/atomic.h>
40#include <asm-generic/bitops/non-atomic.h> 40#include <asm-generic/bitops/non-atomic.h>
41#include <asm-generic/bitops/ext2-non-atomic.h> 41#include <asm-generic/bitops/le.h>
42#include <asm-generic/bitops/ext2-atomic.h> 42#include <asm-generic/bitops/ext2-atomic.h>
43#include <asm-generic/bitops/minix.h>
44 43
45#endif /* __ASM_GENERIC_BITOPS_H */ 44#endif /* __ASM_GENERIC_BITOPS_H */
diff --git a/include/asm-generic/bitops/ext2-atomic.h b/include/asm-generic/bitops/ext2-atomic.h
index ab1c875efb74..ecf1c9d8a7cc 100644
--- a/include/asm-generic/bitops/ext2-atomic.h
+++ b/include/asm-generic/bitops/ext2-atomic.h
@@ -5,7 +5,7 @@
5 ({ \ 5 ({ \
6 int ret; \ 6 int ret; \
7 spin_lock(lock); \ 7 spin_lock(lock); \
8 ret = ext2_set_bit((nr), (unsigned long *)(addr)); \ 8 ret = __test_and_set_bit_le(nr, addr); \
9 spin_unlock(lock); \ 9 spin_unlock(lock); \
10 ret; \ 10 ret; \
11 }) 11 })
@@ -14,7 +14,7 @@
14 ({ \ 14 ({ \
15 int ret; \ 15 int ret; \
16 spin_lock(lock); \ 16 spin_lock(lock); \
17 ret = ext2_clear_bit((nr), (unsigned long *)(addr)); \ 17 ret = __test_and_clear_bit_le(nr, addr); \
18 spin_unlock(lock); \ 18 spin_unlock(lock); \
19 ret; \ 19 ret; \
20 }) 20 })
diff --git a/include/asm-generic/bitops/ext2-non-atomic.h b/include/asm-generic/bitops/ext2-non-atomic.h
deleted file mode 100644
index 63cf822431a2..000000000000
--- a/include/asm-generic/bitops/ext2-non-atomic.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_
2#define _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_
3
4#include <asm-generic/bitops/le.h>
5
6#define ext2_set_bit(nr,addr) \
7 generic___test_and_set_le_bit((nr),(unsigned long *)(addr))
8#define ext2_clear_bit(nr,addr) \
9 generic___test_and_clear_le_bit((nr),(unsigned long *)(addr))
10
11#define ext2_test_bit(nr,addr) \
12 generic_test_le_bit((nr),(unsigned long *)(addr))
13#define ext2_find_first_zero_bit(addr, size) \
14 generic_find_first_zero_le_bit((unsigned long *)(addr), (size))
15#define ext2_find_next_zero_bit(addr, size, off) \
16 generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off))
17#define ext2_find_next_bit(addr, size, off) \
18 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
19
20#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */
diff --git a/include/asm-generic/bitops/find.h b/include/asm-generic/bitops/find.h
index 1914e9742512..71c778033f57 100644
--- a/include/asm-generic/bitops/find.h
+++ b/include/asm-generic/bitops/find.h
@@ -1,15 +1,54 @@
1#ifndef _ASM_GENERIC_BITOPS_FIND_H_ 1#ifndef _ASM_GENERIC_BITOPS_FIND_H_
2#define _ASM_GENERIC_BITOPS_FIND_H_ 2#define _ASM_GENERIC_BITOPS_FIND_H_
3 3
4#ifndef CONFIG_GENERIC_FIND_NEXT_BIT 4#ifndef find_next_bit
5/**
6 * find_next_bit - find the next set bit in a memory region
7 * @addr: The address to base the search on
8 * @offset: The bitnumber to start searching at
9 * @size: The bitmap size in bits
10 */
5extern unsigned long find_next_bit(const unsigned long *addr, unsigned long 11extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
6 size, unsigned long offset); 12 size, unsigned long offset);
13#endif
7 14
15#ifndef find_next_zero_bit
16/**
17 * find_next_zero_bit - find the next cleared bit in a memory region
18 * @addr: The address to base the search on
19 * @offset: The bitnumber to start searching at
20 * @size: The bitmap size in bits
21 */
8extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned 22extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
9 long size, unsigned long offset); 23 long size, unsigned long offset);
10#endif 24#endif
11 25
26#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
27
28/**
29 * find_first_bit - find the first set bit in a memory region
30 * @addr: The address to start the search at
31 * @size: The maximum size to search
32 *
33 * Returns the bit number of the first set bit.
34 */
35extern unsigned long find_first_bit(const unsigned long *addr,
36 unsigned long size);
37
38/**
39 * find_first_zero_bit - find the first cleared bit in a memory region
40 * @addr: The address to start the search at
41 * @size: The maximum size to search
42 *
43 * Returns the bit number of the first cleared bit.
44 */
45extern unsigned long find_first_zero_bit(const unsigned long *addr,
46 unsigned long size);
47#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
48
12#define find_first_bit(addr, size) find_next_bit((addr), (size), 0) 49#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
13#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) 50#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
14 51
52#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
53
15#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ 54#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index 80e3bf13b2b9..f95c663a6a41 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -4,54 +4,84 @@
4#include <asm/types.h> 4#include <asm/types.h>
5#include <asm/byteorder.h> 5#include <asm/byteorder.h>
6 6
7#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
8#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
9
10#if defined(__LITTLE_ENDIAN) 7#if defined(__LITTLE_ENDIAN)
11 8
12#define generic_test_le_bit(nr, addr) test_bit(nr, addr) 9#define BITOP_LE_SWIZZLE 0
13#define generic___set_le_bit(nr, addr) __set_bit(nr, addr)
14#define generic___clear_le_bit(nr, addr) __clear_bit(nr, addr)
15 10
16#define generic_test_and_set_le_bit(nr, addr) test_and_set_bit(nr, addr) 11static inline unsigned long find_next_zero_bit_le(const void *addr,
17#define generic_test_and_clear_le_bit(nr, addr) test_and_clear_bit(nr, addr) 12 unsigned long size, unsigned long offset)
13{
14 return find_next_zero_bit(addr, size, offset);
15}
18 16
19#define generic___test_and_set_le_bit(nr, addr) __test_and_set_bit(nr, addr) 17static inline unsigned long find_next_bit_le(const void *addr,
20#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr) 18 unsigned long size, unsigned long offset)
19{
20 return find_next_bit(addr, size, offset);
21}
21 22
22#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset) 23static inline unsigned long find_first_zero_bit_le(const void *addr,
23#define generic_find_next_le_bit(addr, size, offset) \ 24 unsigned long size)
24 find_next_bit(addr, size, offset) 25{
26 return find_first_zero_bit(addr, size);
27}
25 28
26#elif defined(__BIG_ENDIAN) 29#elif defined(__BIG_ENDIAN)
27 30
28#define generic_test_le_bit(nr, addr) \ 31#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
29 test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
30#define generic___set_le_bit(nr, addr) \
31 __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
32#define generic___clear_le_bit(nr, addr) \
33 __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
34
35#define generic_test_and_set_le_bit(nr, addr) \
36 test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
37#define generic_test_and_clear_le_bit(nr, addr) \
38 test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
39
40#define generic___test_and_set_le_bit(nr, addr) \
41 __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
42#define generic___test_and_clear_le_bit(nr, addr) \
43 __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
44 32
45extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, 33#ifndef find_next_zero_bit_le
34extern unsigned long find_next_zero_bit_le(const void *addr,
46 unsigned long size, unsigned long offset); 35 unsigned long size, unsigned long offset);
47extern unsigned long generic_find_next_le_bit(const unsigned long *addr, 36#endif
37
38#ifndef find_next_bit_le
39extern unsigned long find_next_bit_le(const void *addr,
48 unsigned long size, unsigned long offset); 40 unsigned long size, unsigned long offset);
41#endif
42
43#ifndef find_first_zero_bit_le
44#define find_first_zero_bit_le(addr, size) \
45 find_next_zero_bit_le((addr), (size), 0)
46#endif
49 47
50#else 48#else
51#error "Please fix <asm/byteorder.h>" 49#error "Please fix <asm/byteorder.h>"
52#endif 50#endif
53 51
54#define generic_find_first_zero_le_bit(addr, size) \ 52static inline int test_bit_le(int nr, const void *addr)
55 generic_find_next_zero_le_bit((addr), (size), 0) 53{
54 return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
55}
56
57static inline void __set_bit_le(int nr, void *addr)
58{
59 __set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
60}
61
62static inline void __clear_bit_le(int nr, void *addr)
63{
64 __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
65}
66
67static inline int test_and_set_bit_le(int nr, void *addr)
68{
69 return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
70}
71
72static inline int test_and_clear_bit_le(int nr, void *addr)
73{
74 return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
75}
76
77static inline int __test_and_set_bit_le(int nr, void *addr)
78{
79 return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
80}
81
82static inline int __test_and_clear_bit_le(int nr, void *addr)
83{
84 return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
85}
56 86
57#endif /* _ASM_GENERIC_BITOPS_LE_H_ */ 87#endif /* _ASM_GENERIC_BITOPS_LE_H_ */
diff --git a/include/asm-generic/bitops/minix-le.h b/include/asm-generic/bitops/minix-le.h
deleted file mode 100644
index 4a981c1bb1ae..000000000000
--- a/include/asm-generic/bitops/minix-le.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef _ASM_GENERIC_BITOPS_MINIX_LE_H_
2#define _ASM_GENERIC_BITOPS_MINIX_LE_H_
3
4#include <asm-generic/bitops/le.h>
5
6#define minix_test_and_set_bit(nr,addr) \
7 generic___test_and_set_le_bit((nr),(unsigned long *)(addr))
8#define minix_set_bit(nr,addr) \
9 generic___set_le_bit((nr),(unsigned long *)(addr))
10#define minix_test_and_clear_bit(nr,addr) \
11 generic___test_and_clear_le_bit((nr),(unsigned long *)(addr))
12#define minix_test_bit(nr,addr) \
13 generic_test_le_bit((nr),(unsigned long *)(addr))
14#define minix_find_first_zero_bit(addr,size) \
15 generic_find_first_zero_le_bit((unsigned long *)(addr),(size))
16
17#endif /* _ASM_GENERIC_BITOPS_MINIX_LE_H_ */
diff --git a/include/asm-generic/bitops/minix.h b/include/asm-generic/bitops/minix.h
deleted file mode 100644
index 91f42e87aa51..000000000000
--- a/include/asm-generic/bitops/minix.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _ASM_GENERIC_BITOPS_MINIX_H_
2#define _ASM_GENERIC_BITOPS_MINIX_H_
3
4#define minix_test_and_set_bit(nr,addr) \
5 __test_and_set_bit((nr),(unsigned long *)(addr))
6#define minix_set_bit(nr,addr) \
7 __set_bit((nr),(unsigned long *)(addr))
8#define minix_test_and_clear_bit(nr,addr) \
9 __test_and_clear_bit((nr),(unsigned long *)(addr))
10#define minix_test_bit(nr,addr) \
11 test_bit((nr),(unsigned long *)(addr))
12#define minix_find_first_zero_bit(addr,size) \
13 find_first_zero_bit((unsigned long *)(addr),(size))
14
15#endif /* _ASM_GENERIC_BITOPS_MINIX_H_ */
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index c2c9ba032d46..dfb0ec666c94 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -162,13 +162,43 @@ extern void warn_slowpath_null(const char *file, const int line);
162 unlikely(__ret_warn_once); \ 162 unlikely(__ret_warn_once); \
163}) 163})
164 164
165#define WARN_ON_RATELIMIT(condition, state) \ 165/*
166 WARN_ON((condition) && __ratelimit(state)) 166 * WARN_ON_SMP() is for cases that the warning is either
167 167 * meaningless for !SMP or may even cause failures.
168 * This is usually used for cases that we have
169 * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
170 * returns 0 for uniprocessor settings.
171 * It can also be used with values that are only defined
172 * on SMP:
173 *
174 * struct foo {
175 * [...]
176 * #ifdef CONFIG_SMP
177 * int bar;
178 * #endif
179 * };
180 *
181 * void func(struct foo *zoot)
182 * {
183 * WARN_ON_SMP(!zoot->bar);
184 *
185 * For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(),
186 * and should be a nop and return false for uniprocessor.
187 *
188 * if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set
189 * and x is true.
190 */
168#ifdef CONFIG_SMP 191#ifdef CONFIG_SMP
169# define WARN_ON_SMP(x) WARN_ON(x) 192# define WARN_ON_SMP(x) WARN_ON(x)
170#else 193#else
171# define WARN_ON_SMP(x) do { } while (0) 194/*
195 * Use of ({0;}) because WARN_ON_SMP(x) may be used either as
196 * a stand alone line statement or as a condition in an if ()
197 * statement.
198 * A simple "0" would cause gcc to give a "statement has no effect"
199 * warning.
200 */
201# define WARN_ON_SMP(x) ({0;})
172#endif 202#endif
173 203
174#endif 204#endif
diff --git a/include/asm-generic/cacheflush.h b/include/asm-generic/cacheflush.h
index 57b5c3c82e86..87bc536ccde3 100644
--- a/include/asm-generic/cacheflush.h
+++ b/include/asm-generic/cacheflush.h
@@ -24,7 +24,10 @@
24#define flush_cache_vunmap(start, end) do { } while (0) 24#define flush_cache_vunmap(start, end) do { } while (0)
25 25
26#define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 26#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
27 memcpy(dst, src, len) 27 do { \
28 memcpy(dst, src, len); \
29 flush_icache_user_range(vma, page, vaddr, len); \
30 } while (0)
28#define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 31#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
29 memcpy(dst, src, len) 32 memcpy(dst, src, len)
30 33
diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index b2ba2fc8829a..2533fddd34a6 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -2,6 +2,7 @@
2#define __ASM_GENERIC_CMPXCHG_LOCAL_H 2#define __ASM_GENERIC_CMPXCHG_LOCAL_H
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/irqflags.h>
5 6
6extern unsigned long wrong_size_cmpxchg(volatile void *ptr); 7extern unsigned long wrong_size_cmpxchg(volatile void *ptr);
7 8
diff --git a/include/asm-generic/cputime.h b/include/asm-generic/cputime.h
index ca0f239f0e13..61e03dd7939e 100644
--- a/include/asm-generic/cputime.h
+++ b/include/asm-generic/cputime.h
@@ -30,13 +30,16 @@ typedef u64 cputime64_t;
30#define cputime64_to_jiffies64(__ct) (__ct) 30#define cputime64_to_jiffies64(__ct) (__ct)
31#define jiffies64_to_cputime64(__jif) (__jif) 31#define jiffies64_to_cputime64(__jif) (__jif)
32#define cputime_to_cputime64(__ct) ((u64) __ct) 32#define cputime_to_cputime64(__ct) ((u64) __ct)
33#define cputime64_gt(__a, __b) ((__a) > (__b))
34
35#define nsecs_to_cputime64(__ct) nsecs_to_jiffies64(__ct)
33 36
34 37
35/* 38/*
36 * Convert cputime to milliseconds and back. 39 * Convert cputime to microseconds and back.
37 */ 40 */
38#define cputime_to_msecs(__ct) jiffies_to_msecs(__ct) 41#define cputime_to_usecs(__ct) jiffies_to_usecs(__ct);
39#define msecs_to_cputime(__msecs) msecs_to_jiffies(__msecs) 42#define usecs_to_cputime(__msecs) usecs_to_jiffies(__msecs);
40 43
41/* 44/*
42 * Convert cputime to seconds and back. 45 * Convert cputime to seconds and back.
diff --git a/include/asm-generic/errno.h b/include/asm-generic/errno.h
index 28cc03bf19e6..a1331ce50445 100644
--- a/include/asm-generic/errno.h
+++ b/include/asm-generic/errno.h
@@ -108,4 +108,6 @@
108 108
109#define ERFKILL 132 /* Operation not possible due to RF-kill */ 109#define ERFKILL 132 /* Operation not possible due to RF-kill */
110 110
111#define EHWPOISON 133 /* Memory page has hardware error */
112
111#endif 113#endif
diff --git a/include/asm-generic/fcntl.h b/include/asm-generic/fcntl.h
index a70b2d2bfc14..84793c7025e2 100644
--- a/include/asm-generic/fcntl.h
+++ b/include/asm-generic/fcntl.h
@@ -80,6 +80,10 @@
80#define O_SYNC (__O_SYNC|O_DSYNC) 80#define O_SYNC (__O_SYNC|O_DSYNC)
81#endif 81#endif
82 82
83#ifndef O_PATH
84#define O_PATH 010000000
85#endif
86
83#ifndef O_NDELAY 87#ifndef O_NDELAY
84#define O_NDELAY O_NONBLOCK 88#define O_NDELAY O_NONBLOCK
85#endif 89#endif
@@ -122,7 +126,7 @@
122 126
123struct f_owner_ex { 127struct f_owner_ex {
124 int type; 128 int type;
125 pid_t pid; 129 __kernel_pid_t pid;
126}; 130};
127 131
128/* for F_[GET|SET]FL */ 132/* for F_[GET|SET]FL */
diff --git a/include/asm-generic/ftrace.h b/include/asm-generic/ftrace.h
new file mode 100644
index 000000000000..51abba9ea7ad
--- /dev/null
+++ b/include/asm-generic/ftrace.h
@@ -0,0 +1,16 @@
1/*
2 * linux/include/asm-generic/ftrace.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_GENERIC_FTRACE_H__
9#define __ASM_GENERIC_FTRACE_H__
10
11/*
12 * Not all architectures need their own ftrace.h, the most
13 * common definitions are already in linux/ftrace.h.
14 */
15
16#endif /* __ASM_GENERIC_FTRACE_H__ */
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index 3c2344f48136..01f227e14254 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -6,7 +6,7 @@
6#include <asm/errno.h> 6#include <asm/errno.h>
7 7
8static inline int 8static inline int
9futex_atomic_op_inuser (int encoded_op, int __user *uaddr) 9futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
10{ 10{
11 int op = (encoded_op >> 28) & 7; 11 int op = (encoded_op >> 28) & 7;
12 int cmp = (encoded_op >> 24) & 15; 12 int cmp = (encoded_op >> 24) & 15;
@@ -16,7 +16,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
16 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 16 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
17 oparg = 1 << oparg; 17 oparg = 1 << oparg;
18 18
19 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 19 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32)))
20 return -EFAULT; 20 return -EFAULT;
21 21
22 pagefault_disable(); 22 pagefault_disable();
@@ -48,7 +48,8 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
48} 48}
49 49
50static inline int 50static inline int
51futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 51futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
52 u32 oldval, u32 newval)
52{ 53{
53 return -ENOSYS; 54 return -ENOSYS;
54} 55}
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 8ca18e26d7e3..d494001b1226 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -35,9 +35,9 @@
35 * platform data and other tables. 35 * platform data and other tables.
36 */ 36 */
37 37
38static inline int gpio_is_valid(int number) 38static inline bool gpio_is_valid(int number)
39{ 39{
40 return ((unsigned)number) < ARCH_NR_GPIOS; 40 return number >= 0 && number < ARCH_NR_GPIOS;
41} 41}
42 42
43struct device; 43struct device;
@@ -170,16 +170,6 @@ extern int __gpio_cansleep(unsigned gpio);
170 170
171extern int __gpio_to_irq(unsigned gpio); 171extern int __gpio_to_irq(unsigned gpio);
172 172
173#define GPIOF_DIR_OUT (0 << 0)
174#define GPIOF_DIR_IN (1 << 0)
175
176#define GPIOF_INIT_LOW (0 << 1)
177#define GPIOF_INIT_HIGH (1 << 1)
178
179#define GPIOF_IN (GPIOF_DIR_IN)
180#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
181#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
182
183/** 173/**
184 * struct gpio - a structure describing a GPIO with configuration 174 * struct gpio - a structure describing a GPIO with configuration
185 * @gpio: the GPIO number 175 * @gpio: the GPIO number
@@ -193,8 +183,8 @@ struct gpio {
193}; 183};
194 184
195extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); 185extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
196extern int gpio_request_array(struct gpio *array, size_t num); 186extern int gpio_request_array(const struct gpio *array, size_t num);
197extern void gpio_free_array(struct gpio *array, size_t num); 187extern void gpio_free_array(const struct gpio *array, size_t num);
198 188
199#ifdef CONFIG_GPIO_SYSFS 189#ifdef CONFIG_GPIO_SYSFS
200 190
@@ -210,9 +200,9 @@ extern void gpio_unexport(unsigned gpio);
210 200
211#endif /* CONFIG_GPIO_SYSFS */ 201#endif /* CONFIG_GPIO_SYSFS */
212 202
213#else /* !CONFIG_HAVE_GPIO_LIB */ 203#else /* !CONFIG_GPIOLIB */
214 204
215static inline int gpio_is_valid(int number) 205static inline bool gpio_is_valid(int number)
216{ 206{
217 /* only non-negative numbers are valid */ 207 /* only non-negative numbers are valid */
218 return number >= 0; 208 return number >= 0;
@@ -239,7 +229,7 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value)
239 gpio_set_value(gpio, value); 229 gpio_set_value(gpio, value);
240} 230}
241 231
242#endif /* !CONFIG_HAVE_GPIO_LIB */ 232#endif /* !CONFIG_GPIOLIB */
243 233
244#ifndef CONFIG_GPIO_SYSFS 234#ifndef CONFIG_GPIO_SYSFS
245 235
diff --git a/include/asm-generic/hardirq.h b/include/asm-generic/hardirq.h
index 62f59080e5cc..04d0a977cd43 100644
--- a/include/asm-generic/hardirq.h
+++ b/include/asm-generic/hardirq.h
@@ -3,13 +3,13 @@
3 3
4#include <linux/cache.h> 4#include <linux/cache.h>
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <linux/irq.h>
7 6
8typedef struct { 7typedef struct {
9 unsigned int __softirq_pending; 8 unsigned int __softirq_pending;
10} ____cacheline_aligned irq_cpustat_t; 9} ____cacheline_aligned irq_cpustat_t;
11 10
12#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ 11#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
12#include <linux/irq.h>
13 13
14#ifndef ack_bad_irq 14#ifndef ack_bad_irq
15static inline void ack_bad_irq(unsigned int irq) 15static inline void ack_bad_irq(unsigned int irq)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 118601fce92d..e0ffa3ddb02a 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -19,7 +19,9 @@
19#include <asm-generic/iomap.h> 19#include <asm-generic/iomap.h>
20#endif 20#endif
21 21
22#ifndef mmiowb
22#define mmiowb() do {} while (0) 23#define mmiowb() do {} while (0)
24#endif
23 25
24/*****************************************************************************/ 26/*****************************************************************************/
25/* 27/*
@@ -28,39 +30,51 @@
28 * differently. On the simple architectures, we just read/write the 30 * differently. On the simple architectures, we just read/write the
29 * memory location directly. 31 * memory location directly.
30 */ 32 */
33#ifndef __raw_readb
31static inline u8 __raw_readb(const volatile void __iomem *addr) 34static inline u8 __raw_readb(const volatile void __iomem *addr)
32{ 35{
33 return *(const volatile u8 __force *) addr; 36 return *(const volatile u8 __force *) addr;
34} 37}
38#endif
35 39
40#ifndef __raw_readw
36static inline u16 __raw_readw(const volatile void __iomem *addr) 41static inline u16 __raw_readw(const volatile void __iomem *addr)
37{ 42{
38 return *(const volatile u16 __force *) addr; 43 return *(const volatile u16 __force *) addr;
39} 44}
45#endif
40 46
47#ifndef __raw_readl
41static inline u32 __raw_readl(const volatile void __iomem *addr) 48static inline u32 __raw_readl(const volatile void __iomem *addr)
42{ 49{
43 return *(const volatile u32 __force *) addr; 50 return *(const volatile u32 __force *) addr;
44} 51}
52#endif
45 53
46#define readb __raw_readb 54#define readb __raw_readb
47#define readw(addr) __le16_to_cpu(__raw_readw(addr)) 55#define readw(addr) __le16_to_cpu(__raw_readw(addr))
48#define readl(addr) __le32_to_cpu(__raw_readl(addr)) 56#define readl(addr) __le32_to_cpu(__raw_readl(addr))
49 57
58#ifndef __raw_writeb
50static inline void __raw_writeb(u8 b, volatile void __iomem *addr) 59static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
51{ 60{
52 *(volatile u8 __force *) addr = b; 61 *(volatile u8 __force *) addr = b;
53} 62}
63#endif
54 64
65#ifndef __raw_writew
55static inline void __raw_writew(u16 b, volatile void __iomem *addr) 66static inline void __raw_writew(u16 b, volatile void __iomem *addr)
56{ 67{
57 *(volatile u16 __force *) addr = b; 68 *(volatile u16 __force *) addr = b;
58} 69}
70#endif
59 71
72#ifndef __raw_writel
60static inline void __raw_writel(u32 b, volatile void __iomem *addr) 73static inline void __raw_writel(u32 b, volatile void __iomem *addr)
61{ 74{
62 *(volatile u32 __force *) addr = b; 75 *(volatile u32 __force *) addr = b;
63} 76}
77#endif
64 78
65#define writeb __raw_writeb 79#define writeb __raw_writeb
66#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr) 80#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr)
@@ -80,6 +94,10 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr)
80#define writeq(b,addr) __raw_writeq(__cpu_to_le64(b),addr) 94#define writeq(b,addr) __raw_writeq(__cpu_to_le64(b),addr)
81#endif 95#endif
82 96
97#ifndef PCI_IOBASE
98#define PCI_IOBASE ((void __iomem *) 0)
99#endif
100
83/*****************************************************************************/ 101/*****************************************************************************/
84/* 102/*
85 * traditional input/output functions 103 * traditional input/output functions
@@ -87,32 +105,32 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr)
87 105
88static inline u8 inb(unsigned long addr) 106static inline u8 inb(unsigned long addr)
89{ 107{
90 return readb((volatile void __iomem *) addr); 108 return readb(addr + PCI_IOBASE);
91} 109}
92 110
93static inline u16 inw(unsigned long addr) 111static inline u16 inw(unsigned long addr)
94{ 112{
95 return readw((volatile void __iomem *) addr); 113 return readw(addr + PCI_IOBASE);
96} 114}
97 115
98static inline u32 inl(unsigned long addr) 116static inline u32 inl(unsigned long addr)
99{ 117{
100 return readl((volatile void __iomem *) addr); 118 return readl(addr + PCI_IOBASE);
101} 119}
102 120
103static inline void outb(u8 b, unsigned long addr) 121static inline void outb(u8 b, unsigned long addr)
104{ 122{
105 writeb(b, (volatile void __iomem *) addr); 123 writeb(b, addr + PCI_IOBASE);
106} 124}
107 125
108static inline void outw(u16 b, unsigned long addr) 126static inline void outw(u16 b, unsigned long addr)
109{ 127{
110 writew(b, (volatile void __iomem *) addr); 128 writew(b, addr + PCI_IOBASE);
111} 129}
112 130
113static inline void outl(u32 b, unsigned long addr) 131static inline void outl(u32 b, unsigned long addr)
114{ 132{
115 writel(b, (volatile void __iomem *) addr); 133 writel(b, addr + PCI_IOBASE);
116} 134}
117 135
118#define inb_p(addr) inb(addr) 136#define inb_p(addr) inb(addr)
@@ -122,6 +140,7 @@ static inline void outl(u32 b, unsigned long addr)
122#define outw_p(x, addr) outw((x), (addr)) 140#define outw_p(x, addr) outw((x), (addr))
123#define outl_p(x, addr) outl((x), (addr)) 141#define outl_p(x, addr) outl((x), (addr))
124 142
143#ifndef insb
125static inline void insb(unsigned long addr, void *buffer, int count) 144static inline void insb(unsigned long addr, void *buffer, int count)
126{ 145{
127 if (count) { 146 if (count) {
@@ -132,7 +151,9 @@ static inline void insb(unsigned long addr, void *buffer, int count)
132 } while (--count); 151 } while (--count);
133 } 152 }
134} 153}
154#endif
135 155
156#ifndef insw
136static inline void insw(unsigned long addr, void *buffer, int count) 157static inline void insw(unsigned long addr, void *buffer, int count)
137{ 158{
138 if (count) { 159 if (count) {
@@ -143,7 +164,9 @@ static inline void insw(unsigned long addr, void *buffer, int count)
143 } while (--count); 164 } while (--count);
144 } 165 }
145} 166}
167#endif
146 168
169#ifndef insl
147static inline void insl(unsigned long addr, void *buffer, int count) 170static inline void insl(unsigned long addr, void *buffer, int count)
148{ 171{
149 if (count) { 172 if (count) {
@@ -154,7 +177,9 @@ static inline void insl(unsigned long addr, void *buffer, int count)
154 } while (--count); 177 } while (--count);
155 } 178 }
156} 179}
180#endif
157 181
182#ifndef outsb
158static inline void outsb(unsigned long addr, const void *buffer, int count) 183static inline void outsb(unsigned long addr, const void *buffer, int count)
159{ 184{
160 if (count) { 185 if (count) {
@@ -164,7 +189,9 @@ static inline void outsb(unsigned long addr, const void *buffer, int count)
164 } while (--count); 189 } while (--count);
165 } 190 }
166} 191}
192#endif
167 193
194#ifndef outsw
168static inline void outsw(unsigned long addr, const void *buffer, int count) 195static inline void outsw(unsigned long addr, const void *buffer, int count)
169{ 196{
170 if (count) { 197 if (count) {
@@ -174,7 +201,9 @@ static inline void outsw(unsigned long addr, const void *buffer, int count)
174 } while (--count); 201 } while (--count);
175 } 202 }
176} 203}
204#endif
177 205
206#ifndef outsl
178static inline void outsl(unsigned long addr, const void *buffer, int count) 207static inline void outsl(unsigned long addr, const void *buffer, int count)
179{ 208{
180 if (count) { 209 if (count) {
@@ -184,6 +213,37 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
184 } while (--count); 213 } while (--count);
185 } 214 }
186} 215}
216#endif
217
218static inline void readsl(const void __iomem *addr, void *buf, int len)
219{
220 insl(addr - PCI_IOBASE, buf, len);
221}
222
223static inline void readsw(const void __iomem *addr, void *buf, int len)
224{
225 insw(addr - PCI_IOBASE, buf, len);
226}
227
228static inline void readsb(const void __iomem *addr, void *buf, int len)
229{
230 insb(addr - PCI_IOBASE, buf, len);
231}
232
233static inline void writesl(const void __iomem *addr, const void *buf, int len)
234{
235 outsl(addr - PCI_IOBASE, buf, len);
236}
237
238static inline void writesw(const void __iomem *addr, const void *buf, int len)
239{
240 outsw(addr - PCI_IOBASE, buf, len);
241}
242
243static inline void writesb(const void __iomem *addr, const void *buf, int len)
244{
245 outsb(addr - PCI_IOBASE, buf, len);
246}
187 247
188#ifndef CONFIG_GENERIC_IOMAP 248#ifndef CONFIG_GENERIC_IOMAP
189#define ioread8(addr) readb(addr) 249#define ioread8(addr) readb(addr)
@@ -213,8 +273,9 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
213 outsl((unsigned long) (p), (src), (count)) 273 outsl((unsigned long) (p), (src), (count))
214#endif /* CONFIG_GENERIC_IOMAP */ 274#endif /* CONFIG_GENERIC_IOMAP */
215 275
216 276#ifndef IO_SPACE_LIMIT
217#define IO_SPACE_LIMIT 0xffffffff 277#define IO_SPACE_LIMIT 0xffff
278#endif
218 279
219#ifdef __KERNEL__ 280#ifdef __KERNEL__
220 281
diff --git a/include/asm-generic/ioctls.h b/include/asm-generic/ioctls.h
index 8554cb6a81b9..199975fac395 100644
--- a/include/asm-generic/ioctls.h
+++ b/include/asm-generic/ioctls.h
@@ -62,14 +62,18 @@
62#define TCSETSW2 _IOW('T', 0x2C, struct termios2) 62#define TCSETSW2 _IOW('T', 0x2C, struct termios2)
63#define TCSETSF2 _IOW('T', 0x2D, struct termios2) 63#define TCSETSF2 _IOW('T', 0x2D, struct termios2)
64#define TIOCGRS485 0x542E 64#define TIOCGRS485 0x542E
65#ifndef TIOCSRS485
65#define TIOCSRS485 0x542F 66#define TIOCSRS485 0x542F
67#endif
66#define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 68#define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
67#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */ 69#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */
70#define TIOCGDEV _IOR('T', 0x32, unsigned int) /* Get primary device node of /dev/console */
68#define TCGETX 0x5432 /* SYS5 TCGETX compatibility */ 71#define TCGETX 0x5432 /* SYS5 TCGETX compatibility */
69#define TCSETX 0x5433 72#define TCSETX 0x5433
70#define TCSETXF 0x5434 73#define TCSETXF 0x5434
71#define TCSETXW 0x5435 74#define TCSETXW 0x5435
72#define TIOCSIG _IOW('T', 0x36, int) /* pty: generate signal */ 75#define TIOCSIG _IOW('T', 0x36, int) /* pty: generate signal */
76#define TIOCVHANGUP 0x5437
73 77
74#define FIONCLEX 0x5450 78#define FIONCLEX 0x5450
75#define FIOCLEX 0x5451 79#define FIOCLEX 0x5451
diff --git a/include/asm-generic/irq_regs.h b/include/asm-generic/irq_regs.h
index 5ae1d07d4a12..6bf9355fa7eb 100644
--- a/include/asm-generic/irq_regs.h
+++ b/include/asm-generic/irq_regs.h
@@ -22,15 +22,15 @@ DECLARE_PER_CPU(struct pt_regs *, __irq_regs);
22 22
23static inline struct pt_regs *get_irq_regs(void) 23static inline struct pt_regs *get_irq_regs(void)
24{ 24{
25 return __get_cpu_var(__irq_regs); 25 return __this_cpu_read(__irq_regs);
26} 26}
27 27
28static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs) 28static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs)
29{ 29{
30 struct pt_regs *old_regs, **pp_regs = &__get_cpu_var(__irq_regs); 30 struct pt_regs *old_regs;
31 31
32 old_regs = *pp_regs; 32 old_regs = __this_cpu_read(__irq_regs);
33 *pp_regs = new_regs; 33 __this_cpu_write(__irq_regs, new_regs);
34 return old_regs; 34 return old_regs;
35} 35}
36 36
diff --git a/include/asm-generic/irqflags.h b/include/asm-generic/irqflags.h
index 9aebf618275a..1f40d0024cf3 100644
--- a/include/asm-generic/irqflags.h
+++ b/include/asm-generic/irqflags.h
@@ -5,68 +5,62 @@
5 * All architectures should implement at least the first two functions, 5 * All architectures should implement at least the first two functions,
6 * usually inline assembly will be the best way. 6 * usually inline assembly will be the best way.
7 */ 7 */
8#ifndef RAW_IRQ_DISABLED 8#ifndef ARCH_IRQ_DISABLED
9#define RAW_IRQ_DISABLED 0 9#define ARCH_IRQ_DISABLED 0
10#define RAW_IRQ_ENABLED 1 10#define ARCH_IRQ_ENABLED 1
11#endif 11#endif
12 12
13/* read interrupt enabled status */ 13/* read interrupt enabled status */
14#ifndef __raw_local_save_flags 14#ifndef arch_local_save_flags
15unsigned long __raw_local_save_flags(void); 15unsigned long arch_local_save_flags(void);
16#endif 16#endif
17 17
18/* set interrupt enabled status */ 18/* set interrupt enabled status */
19#ifndef raw_local_irq_restore 19#ifndef arch_local_irq_restore
20void raw_local_irq_restore(unsigned long flags); 20void arch_local_irq_restore(unsigned long flags);
21#endif 21#endif
22 22
23/* get status and disable interrupts */ 23/* get status and disable interrupts */
24#ifndef __raw_local_irq_save 24#ifndef arch_local_irq_save
25static inline unsigned long __raw_local_irq_save(void) 25static inline unsigned long arch_local_irq_save(void)
26{ 26{
27 unsigned long flags; 27 unsigned long flags;
28 flags = __raw_local_save_flags(); 28 flags = arch_local_save_flags();
29 raw_local_irq_restore(RAW_IRQ_DISABLED); 29 arch_local_irq_restore(ARCH_IRQ_DISABLED);
30 return flags; 30 return flags;
31} 31}
32#endif 32#endif
33 33
34/* test flags */ 34/* test flags */
35#ifndef raw_irqs_disabled_flags 35#ifndef arch_irqs_disabled_flags
36static inline int raw_irqs_disabled_flags(unsigned long flags) 36static inline int arch_irqs_disabled_flags(unsigned long flags)
37{ 37{
38 return flags == RAW_IRQ_DISABLED; 38 return flags == ARCH_IRQ_DISABLED;
39} 39}
40#endif 40#endif
41 41
42/* unconditionally enable interrupts */ 42/* unconditionally enable interrupts */
43#ifndef raw_local_irq_enable 43#ifndef arch_local_irq_enable
44static inline void raw_local_irq_enable(void) 44static inline void arch_local_irq_enable(void)
45{ 45{
46 raw_local_irq_restore(RAW_IRQ_ENABLED); 46 arch_local_irq_restore(ARCH_IRQ_ENABLED);
47} 47}
48#endif 48#endif
49 49
50/* unconditionally disable interrupts */ 50/* unconditionally disable interrupts */
51#ifndef raw_local_irq_disable 51#ifndef arch_local_irq_disable
52static inline void raw_local_irq_disable(void) 52static inline void arch_local_irq_disable(void)
53{ 53{
54 raw_local_irq_restore(RAW_IRQ_DISABLED); 54 arch_local_irq_restore(ARCH_IRQ_DISABLED);
55} 55}
56#endif 56#endif
57 57
58/* test hardware interrupt enable bit */ 58/* test hardware interrupt enable bit */
59#ifndef raw_irqs_disabled 59#ifndef arch_irqs_disabled
60static inline int raw_irqs_disabled(void) 60static inline int arch_irqs_disabled(void)
61{ 61{
62 return raw_irqs_disabled_flags(__raw_local_save_flags()); 62 return arch_irqs_disabled_flags(arch_local_save_flags());
63} 63}
64#endif 64#endif
65 65
66#define raw_local_save_flags(flags) \
67 do { (flags) = __raw_local_save_flags(); } while (0)
68
69#define raw_local_irq_save(flags) \
70 do { (flags) = __raw_local_irq_save(); } while (0)
71
72#endif /* __ASM_GENERIC_IRQFLAGS_H */ 66#endif /* __ASM_GENERIC_IRQFLAGS_H */
diff --git a/include/asm-generic/kdebug.h b/include/asm-generic/kdebug.h
index 11e57b6a85fc..d1814497bcdb 100644
--- a/include/asm-generic/kdebug.h
+++ b/include/asm-generic/kdebug.h
@@ -3,7 +3,7 @@
3 3
4enum die_val { 4enum die_val {
5 DIE_UNUSED, 5 DIE_UNUSED,
6 DIE_OOPS=1 6 DIE_OOPS = 1,
7}; 7};
8 8
9#endif /* _ASM_GENERIC_KDEBUG_H */ 9#endif /* _ASM_GENERIC_KDEBUG_H */
diff --git a/include/asm-generic/mman-common.h b/include/asm-generic/mman-common.h
index 3da9e2742fa0..787abbb6d867 100644
--- a/include/asm-generic/mman-common.h
+++ b/include/asm-generic/mman-common.h
@@ -45,6 +45,9 @@
45#define MADV_MERGEABLE 12 /* KSM may merge identical pages */ 45#define MADV_MERGEABLE 12 /* KSM may merge identical pages */
46#define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ 46#define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */
47 47
48#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
49#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */
50
48/* compatibility flags */ 51/* compatibility flags */
49#define MAP_FILE 0 52#define MAP_FILE 0
50 53
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 08923b684768..d17784ea37ff 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -55,14 +55,18 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
55 */ 55 */
56#define per_cpu(var, cpu) \ 56#define per_cpu(var, cpu) \
57 (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu))) 57 (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu)))
58#define __get_cpu_var(var) \
59 (*SHIFT_PERCPU_PTR(&(var), my_cpu_offset))
60#define __raw_get_cpu_var(var) \
61 (*SHIFT_PERCPU_PTR(&(var), __my_cpu_offset))
62 58
63#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset) 59#ifndef __this_cpu_ptr
64#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset) 60#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
61#endif
62#ifdef CONFIG_DEBUG_PREEMPT
63#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset)
64#else
65#define this_cpu_ptr(ptr) __this_cpu_ptr(ptr)
66#endif
65 67
68#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
69#define __raw_get_cpu_var(var) (*__this_cpu_ptr(&(var)))
66 70
67#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA 71#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
68extern void setup_per_cpu_areas(void); 72extern void setup_per_cpu_areas(void);
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index e2bd73e8f9c0..76bff2bff15e 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -4,68 +4,103 @@
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5#ifdef CONFIG_MMU 5#ifdef CONFIG_MMU
6 6
7#include <linux/mm_types.h>
8
7#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS 9#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
8/* 10extern int ptep_set_access_flags(struct vm_area_struct *vma,
9 * Largely same as above, but only sets the access flags (dirty, 11 unsigned long address, pte_t *ptep,
10 * accessed, and writable). Furthermore, we know it always gets set 12 pte_t entry, int dirty);
11 * to a "more permissive" setting, which allows most architectures 13#endif
12 * to optimize this. We return whether the PTE actually changed, which 14
13 * in turn instructs the caller to do things like update__mmu_cache. 15#ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
14 * This used to be done in the caller, but sparc needs minor faults to 16extern int pmdp_set_access_flags(struct vm_area_struct *vma,
15 * force that call on sun4c so we changed this macro slightly 17 unsigned long address, pmd_t *pmdp,
16 */ 18 pmd_t entry, int dirty);
17#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
18({ \
19 int __changed = !pte_same(*(__ptep), __entry); \
20 if (__changed) { \
21 set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry); \
22 flush_tlb_page(__vma, __address); \
23 } \
24 __changed; \
25})
26#endif 19#endif
27 20
28#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 21#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
29#define ptep_test_and_clear_young(__vma, __address, __ptep) \ 22static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
30({ \ 23 unsigned long address,
31 pte_t __pte = *(__ptep); \ 24 pte_t *ptep)
32 int r = 1; \ 25{
33 if (!pte_young(__pte)) \ 26 pte_t pte = *ptep;
34 r = 0; \ 27 int r = 1;
35 else \ 28 if (!pte_young(pte))
36 set_pte_at((__vma)->vm_mm, (__address), \ 29 r = 0;
37 (__ptep), pte_mkold(__pte)); \ 30 else
38 r; \ 31 set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
39}) 32 return r;
33}
34#endif
35
36#ifndef __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
37#ifdef CONFIG_TRANSPARENT_HUGEPAGE
38static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
39 unsigned long address,
40 pmd_t *pmdp)
41{
42 pmd_t pmd = *pmdp;
43 int r = 1;
44 if (!pmd_young(pmd))
45 r = 0;
46 else
47 set_pmd_at(vma->vm_mm, address, pmdp, pmd_mkold(pmd));
48 return r;
49}
50#else /* CONFIG_TRANSPARENT_HUGEPAGE */
51static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
52 unsigned long address,
53 pmd_t *pmdp)
54{
55 BUG();
56 return 0;
57}
58#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
40#endif 59#endif
41 60
42#ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 61#ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
43#define ptep_clear_flush_young(__vma, __address, __ptep) \ 62int ptep_clear_flush_young(struct vm_area_struct *vma,
44({ \ 63 unsigned long address, pte_t *ptep);
45 int __young; \ 64#endif
46 __young = ptep_test_and_clear_young(__vma, __address, __ptep); \ 65
47 if (__young) \ 66#ifndef __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
48 flush_tlb_page(__vma, __address); \ 67int pmdp_clear_flush_young(struct vm_area_struct *vma,
49 __young; \ 68 unsigned long address, pmd_t *pmdp);
50})
51#endif 69#endif
52 70
53#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR 71#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
54#define ptep_get_and_clear(__mm, __address, __ptep) \ 72static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
55({ \ 73 unsigned long address,
56 pte_t __pte = *(__ptep); \ 74 pte_t *ptep)
57 pte_clear((__mm), (__address), (__ptep)); \ 75{
58 __pte; \ 76 pte_t pte = *ptep;
59}) 77 pte_clear(mm, address, ptep);
78 return pte;
79}
80#endif
81
82#ifndef __HAVE_ARCH_PMDP_GET_AND_CLEAR
83#ifdef CONFIG_TRANSPARENT_HUGEPAGE
84static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
85 unsigned long address,
86 pmd_t *pmdp)
87{
88 pmd_t pmd = *pmdp;
89 pmd_clear(mm, address, pmdp);
90 return pmd;
91}
92#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
60#endif 93#endif
61 94
62#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL 95#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
63#define ptep_get_and_clear_full(__mm, __address, __ptep, __full) \ 96static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm,
64({ \ 97 unsigned long address, pte_t *ptep,
65 pte_t __pte; \ 98 int full)
66 __pte = ptep_get_and_clear((__mm), (__address), (__ptep)); \ 99{
67 __pte; \ 100 pte_t pte;
68}) 101 pte = ptep_get_and_clear(mm, address, ptep);
102 return pte;
103}
69#endif 104#endif
70 105
71/* 106/*
@@ -74,20 +109,25 @@
74 * not present, or in the process of an address space destruction. 109 * not present, or in the process of an address space destruction.
75 */ 110 */
76#ifndef __HAVE_ARCH_PTE_CLEAR_NOT_PRESENT_FULL 111#ifndef __HAVE_ARCH_PTE_CLEAR_NOT_PRESENT_FULL
77#define pte_clear_not_present_full(__mm, __address, __ptep, __full) \ 112static inline void pte_clear_not_present_full(struct mm_struct *mm,
78do { \ 113 unsigned long address,
79 pte_clear((__mm), (__address), (__ptep)); \ 114 pte_t *ptep,
80} while (0) 115 int full)
116{
117 pte_clear(mm, address, ptep);
118}
81#endif 119#endif
82 120
83#ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH 121#ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
84#define ptep_clear_flush(__vma, __address, __ptep) \ 122extern pte_t ptep_clear_flush(struct vm_area_struct *vma,
85({ \ 123 unsigned long address,
86 pte_t __pte; \ 124 pte_t *ptep);
87 __pte = ptep_get_and_clear((__vma)->vm_mm, __address, __ptep); \ 125#endif
88 flush_tlb_page(__vma, __address); \ 126
89 __pte; \ 127#ifndef __HAVE_ARCH_PMDP_CLEAR_FLUSH
90}) 128extern pmd_t pmdp_clear_flush(struct vm_area_struct *vma,
129 unsigned long address,
130 pmd_t *pmdp);
91#endif 131#endif
92 132
93#ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT 133#ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT
@@ -99,26 +139,63 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
99} 139}
100#endif 140#endif
101 141
142#ifndef __HAVE_ARCH_PMDP_SET_WRPROTECT
143#ifdef CONFIG_TRANSPARENT_HUGEPAGE
144static inline void pmdp_set_wrprotect(struct mm_struct *mm,
145 unsigned long address, pmd_t *pmdp)
146{
147 pmd_t old_pmd = *pmdp;
148 set_pmd_at(mm, address, pmdp, pmd_wrprotect(old_pmd));
149}
150#else /* CONFIG_TRANSPARENT_HUGEPAGE */
151static inline void pmdp_set_wrprotect(struct mm_struct *mm,
152 unsigned long address, pmd_t *pmdp)
153{
154 BUG();
155}
156#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
157#endif
158
159#ifndef __HAVE_ARCH_PMDP_SPLITTING_FLUSH
160extern pmd_t pmdp_splitting_flush(struct vm_area_struct *vma,
161 unsigned long address,
162 pmd_t *pmdp);
163#endif
164
102#ifndef __HAVE_ARCH_PTE_SAME 165#ifndef __HAVE_ARCH_PTE_SAME
103#define pte_same(A,B) (pte_val(A) == pte_val(B)) 166static inline int pte_same(pte_t pte_a, pte_t pte_b)
167{
168 return pte_val(pte_a) == pte_val(pte_b);
169}
104#endif 170#endif
105 171
106#ifndef __HAVE_ARCH_PAGE_TEST_DIRTY 172#ifndef __HAVE_ARCH_PMD_SAME
107#define page_test_dirty(page) (0) 173#ifdef CONFIG_TRANSPARENT_HUGEPAGE
174static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
175{
176 return pmd_val(pmd_a) == pmd_val(pmd_b);
177}
178#else /* CONFIG_TRANSPARENT_HUGEPAGE */
179static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
180{
181 BUG();
182 return 0;
183}
184#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
108#endif 185#endif
109 186
110#ifndef __HAVE_ARCH_PAGE_CLEAR_DIRTY 187#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
111#define page_clear_dirty(page) do { } while (0) 188#define page_test_and_clear_dirty(pfn, mapped) (0)
112#endif 189#endif
113 190
114#ifndef __HAVE_ARCH_PAGE_TEST_DIRTY 191#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
115#define pte_maybe_dirty(pte) pte_dirty(pte) 192#define pte_maybe_dirty(pte) pte_dirty(pte)
116#else 193#else
117#define pte_maybe_dirty(pte) (1) 194#define pte_maybe_dirty(pte) (1)
118#endif 195#endif
119 196
120#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG 197#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
121#define page_test_and_clear_young(page) (0) 198#define page_test_and_clear_young(pfn) (0)
122#endif 199#endif
123 200
124#ifndef __HAVE_ARCH_PGD_OFFSET_GATE 201#ifndef __HAVE_ARCH_PGD_OFFSET_GATE
@@ -129,6 +206,10 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
129#define move_pte(pte, prot, old_addr, new_addr) (pte) 206#define move_pte(pte, prot, old_addr, new_addr) (pte)
130#endif 207#endif
131 208
209#ifndef flush_tlb_fix_spurious_fault
210#define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address)
211#endif
212
132#ifndef pgprot_noncached 213#ifndef pgprot_noncached
133#define pgprot_noncached(prot) (prot) 214#define pgprot_noncached(prot) (prot)
134#endif 215#endif
@@ -344,6 +425,24 @@ extern void untrack_pfn_vma(struct vm_area_struct *vma, unsigned long pfn,
344 unsigned long size); 425 unsigned long size);
345#endif 426#endif
346 427
428#ifndef CONFIG_TRANSPARENT_HUGEPAGE
429static inline int pmd_trans_huge(pmd_t pmd)
430{
431 return 0;
432}
433static inline int pmd_trans_splitting(pmd_t pmd)
434{
435 return 0;
436}
437#ifndef __HAVE_ARCH_PMD_WRITE
438static inline int pmd_write(pmd_t pmd)
439{
440 BUG();
441 return 0;
442}
443#endif /* __HAVE_ARCH_PMD_WRITE */
444#endif
445
347#endif /* !__ASSEMBLY__ */ 446#endif /* !__ASSEMBLY__ */
348 447
349#endif /* _ASM_GENERIC_PGTABLE_H */ 448#endif /* _ASM_GENERIC_PGTABLE_H */
diff --git a/include/asm-generic/ptrace.h b/include/asm-generic/ptrace.h
new file mode 100644
index 000000000000..82e674f6b337
--- /dev/null
+++ b/include/asm-generic/ptrace.h
@@ -0,0 +1,74 @@
1/*
2 * Common low level (register) ptrace helpers
3 *
4 * Copyright 2004-2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __ASM_GENERIC_PTRACE_H__
10#define __ASM_GENERIC_PTRACE_H__
11
12#ifndef __ASSEMBLY__
13
14/* Helpers for working with the instruction pointer */
15#ifndef GET_IP
16#define GET_IP(regs) ((regs)->pc)
17#endif
18#ifndef SET_IP
19#define SET_IP(regs, val) (GET_IP(regs) = (val))
20#endif
21
22static inline unsigned long instruction_pointer(struct pt_regs *regs)
23{
24 return GET_IP(regs);
25}
26static inline void instruction_pointer_set(struct pt_regs *regs,
27 unsigned long val)
28{
29 SET_IP(regs, val);
30}
31
32#ifndef profile_pc
33#define profile_pc(regs) instruction_pointer(regs)
34#endif
35
36/* Helpers for working with the user stack pointer */
37#ifndef GET_USP
38#define GET_USP(regs) ((regs)->usp)
39#endif
40#ifndef SET_USP
41#define SET_USP(regs, val) (GET_USP(regs) = (val))
42#endif
43
44static inline unsigned long user_stack_pointer(struct pt_regs *regs)
45{
46 return GET_USP(regs);
47}
48static inline void user_stack_pointer_set(struct pt_regs *regs,
49 unsigned long val)
50{
51 SET_USP(regs, val);
52}
53
54/* Helpers for working with the frame pointer */
55#ifndef GET_FP
56#define GET_FP(regs) ((regs)->fp)
57#endif
58#ifndef SET_FP
59#define SET_FP(regs, val) (GET_FP(regs) = (val))
60#endif
61
62static inline unsigned long frame_pointer(struct pt_regs *regs)
63{
64 return GET_FP(regs);
65}
66static inline void frame_pointer_set(struct pt_regs *regs,
67 unsigned long val)
68{
69 SET_FP(regs, val);
70}
71
72#endif /* __ASSEMBLY__ */
73
74#endif
diff --git a/include/asm-generic/resource.h b/include/asm-generic/resource.h
index 587566f95f6c..61fa862fe08d 100644
--- a/include/asm-generic/resource.h
+++ b/include/asm-generic/resource.h
@@ -78,7 +78,7 @@
78 [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \ 78 [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \
79 [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 79 [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \
80 [RLIMIT_NPROC] = { 0, 0 }, \ 80 [RLIMIT_NPROC] = { 0, 0 }, \
81 [RLIMIT_NOFILE] = { INR_OPEN, INR_OPEN }, \ 81 [RLIMIT_NOFILE] = { INR_OPEN_CUR, INR_OPEN_MAX }, \
82 [RLIMIT_MEMLOCK] = { MLOCK_LIMIT, MLOCK_LIMIT }, \ 82 [RLIMIT_MEMLOCK] = { MLOCK_LIMIT, MLOCK_LIMIT }, \
83 [RLIMIT_AS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 83 [RLIMIT_AS] = { RLIM_INFINITY, RLIM_INFINITY }, \
84 [RLIMIT_LOCKS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 84 [RLIMIT_LOCKS] = { RLIM_INFINITY, RLIM_INFINITY }, \
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index b3bfabc258f3..c1a1216e29ce 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -11,6 +11,7 @@ extern char _sinittext[], _einittext[];
11extern char _end[]; 11extern char _end[];
12extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[]; 12extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
13extern char __kprobes_text_start[], __kprobes_text_end[]; 13extern char __kprobes_text_start[], __kprobes_text_end[];
14extern char __entry_text_start[], __entry_text_end[];
14extern char __initdata_begin[], __initdata_end[]; 15extern char __initdata_begin[], __initdata_end[];
15extern char __start_rodata[], __end_rodata[]; 16extern char __start_rodata[], __end_rodata[];
16 17
diff --git a/include/asm-generic/siginfo.h b/include/asm-generic/siginfo.h
index 942d30b5aab1..0dd4e87f6fba 100644
--- a/include/asm-generic/siginfo.h
+++ b/include/asm-generic/siginfo.h
@@ -192,7 +192,7 @@ typedef struct siginfo {
192 * SIGBUS si_codes 192 * SIGBUS si_codes
193 */ 193 */
194#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ 194#define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */
195#define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */ 195#define BUS_ADRERR (__SI_FAULT|2) /* non-existent physical address */
196#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ 196#define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */
197/* hardware memory error consumed on a machine check: action required */ 197/* hardware memory error consumed on a machine check: action required */
198#define BUS_MCEERR_AR (__SI_FAULT|4) 198#define BUS_MCEERR_AR (__SI_FAULT|4)
diff --git a/include/asm-generic/sizes.h b/include/asm-generic/sizes.h
new file mode 100644
index 000000000000..ea5d4ef81061
--- /dev/null
+++ b/include/asm-generic/sizes.h
@@ -0,0 +1,47 @@
1/*
2 * linux/include/asm-generic/sizes.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#ifndef __ASM_GENERIC_SIZES_H__
9#define __ASM_GENERIC_SIZES_H__
10
11#define SZ_1 0x00000001
12#define SZ_2 0x00000002
13#define SZ_4 0x00000004
14#define SZ_8 0x00000008
15#define SZ_16 0x00000010
16#define SZ_32 0x00000020
17#define SZ_64 0x00000040
18#define SZ_128 0x00000080
19#define SZ_256 0x00000100
20#define SZ_512 0x00000200
21
22#define SZ_1K 0x00000400
23#define SZ_2K 0x00000800
24#define SZ_4K 0x00001000
25#define SZ_8K 0x00002000
26#define SZ_16K 0x00004000
27#define SZ_32K 0x00008000
28#define SZ_64K 0x00010000
29#define SZ_128K 0x00020000
30#define SZ_256K 0x00040000
31#define SZ_512K 0x00080000
32
33#define SZ_1M 0x00100000
34#define SZ_2M 0x00200000
35#define SZ_4M 0x00400000
36#define SZ_8M 0x00800000
37#define SZ_16M 0x01000000
38#define SZ_32M 0x02000000
39#define SZ_64M 0x04000000
40#define SZ_128M 0x08000000
41#define SZ_256M 0x10000000
42#define SZ_512M 0x20000000
43
44#define SZ_1G 0x40000000
45#define SZ_2G 0x80000000
46
47#endif /* __ASM_GENERIC_SIZES_H__ */
diff --git a/include/asm-generic/stat.h b/include/asm-generic/stat.h
index 47e64170305d..bd8cad21998e 100644
--- a/include/asm-generic/stat.h
+++ b/include/asm-generic/stat.h
@@ -33,18 +33,18 @@ struct stat {
33 int st_blksize; /* Optimal block size for I/O. */ 33 int st_blksize; /* Optimal block size for I/O. */
34 int __pad2; 34 int __pad2;
35 long st_blocks; /* Number 512-byte blocks allocated. */ 35 long st_blocks; /* Number 512-byte blocks allocated. */
36 int st_atime; /* Time of last access. */ 36 long st_atime; /* Time of last access. */
37 unsigned int st_atime_nsec; 37 unsigned long st_atime_nsec;
38 int st_mtime; /* Time of last modification. */ 38 long st_mtime; /* Time of last modification. */
39 unsigned int st_mtime_nsec; 39 unsigned long st_mtime_nsec;
40 int st_ctime; /* Time of last status change. */ 40 long st_ctime; /* Time of last status change. */
41 unsigned int st_ctime_nsec; 41 unsigned long st_ctime_nsec;
42 unsigned int __unused4; 42 unsigned int __unused4;
43 unsigned int __unused5; 43 unsigned int __unused5;
44}; 44};
45 45
46#if __BITS_PER_LONG != 64
47/* This matches struct stat64 in glibc2.1. Only used for 32 bit. */ 46/* This matches struct stat64 in glibc2.1. Only used for 32 bit. */
47#if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64)
48struct stat64 { 48struct stat64 {
49 unsigned long long st_dev; /* Device. */ 49 unsigned long long st_dev; /* Device. */
50 unsigned long long st_ino; /* File serial number. */ 50 unsigned long long st_ino; /* File serial number. */
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index efa403b5e121..4b0b9cbbfae5 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -21,6 +21,7 @@
21#include <linux/irqflags.h> 21#include <linux/irqflags.h>
22 22
23#include <asm/cmpxchg-local.h> 23#include <asm/cmpxchg-local.h>
24#include <asm/cmpxchg.h>
24 25
25struct task_struct; 26struct task_struct;
26 27
@@ -136,25 +137,6 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
136#define xchg(ptr, x) \ 137#define xchg(ptr, x) \
137 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr)))) 138 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
138 139
139static inline unsigned long __cmpxchg(volatile unsigned long *m,
140 unsigned long old, unsigned long new)
141{
142 unsigned long retval;
143 unsigned long flags;
144
145 local_irq_save(flags);
146 retval = *m;
147 if (retval == old)
148 *m = new;
149 local_irq_restore(flags);
150 return retval;
151}
152
153#define cmpxchg(ptr, o, n) \
154 ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
155 (unsigned long)(o), \
156 (unsigned long)(n)))
157
158#endif /* !__ASSEMBLY__ */ 140#endif /* !__ASSEMBLY__ */
159 141
160#endif /* __KERNEL__ */ 142#endif /* __KERNEL__ */
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index e43f9766259f..e58fa777fa09 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -5,6 +5,8 @@
5 * Copyright 2001 Red Hat, Inc. 5 * Copyright 2001 Red Hat, Inc.
6 * Based on code from mm/memory.c Copyright Linus Torvalds and others. 6 * Based on code from mm/memory.c Copyright Linus Torvalds and others.
7 * 7 *
8 * Copyright 2011 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
9 *
8 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 12 * as published by the Free Software Foundation; either version
@@ -17,97 +19,111 @@
17#include <asm/pgalloc.h> 19#include <asm/pgalloc.h>
18#include <asm/tlbflush.h> 20#include <asm/tlbflush.h>
19 21
22#ifdef CONFIG_HAVE_RCU_TABLE_FREE
20/* 23/*
21 * For UP we don't need to worry about TLB flush 24 * Semi RCU freeing of the page directories.
22 * and page free order so much.. 25 *
26 * This is needed by some architectures to implement software pagetable walkers.
27 *
28 * gup_fast() and other software pagetable walkers do a lockless page-table
29 * walk and therefore needs some synchronization with the freeing of the page
30 * directories. The chosen means to accomplish that is by disabling IRQs over
31 * the walk.
32 *
33 * Architectures that use IPIs to flush TLBs will then automagically DTRT,
34 * since we unlink the page, flush TLBs, free the page. Since the disabling of
35 * IRQs delays the completion of the TLB flush we can never observe an already
36 * freed page.
37 *
38 * Architectures that do not have this (PPC) need to delay the freeing by some
39 * other means, this is that means.
40 *
41 * What we do is batch the freed directory pages (tables) and RCU free them.
42 * We use the sched RCU variant, as that guarantees that IRQ/preempt disabling
43 * holds off grace periods.
44 *
45 * However, in order to batch these pages we need to allocate storage, this
46 * allocation is deep inside the MM code and can thus easily fail on memory
47 * pressure. To guarantee progress we fall back to single table freeing, see
48 * the implementation of tlb_remove_table_one().
49 *
23 */ 50 */
24#ifdef CONFIG_SMP 51struct mmu_table_batch {
25 #ifdef ARCH_FREE_PTR_NR 52 struct rcu_head rcu;
26 #define FREE_PTR_NR ARCH_FREE_PTR_NR 53 unsigned int nr;
27 #else 54 void *tables[0];
28 #define FREE_PTE_NR 506 55};
29 #endif 56
30 #define tlb_fast_mode(tlb) ((tlb)->nr == ~0U) 57#define MAX_TABLE_BATCH \
31#else 58 ((PAGE_SIZE - sizeof(struct mmu_table_batch)) / sizeof(void *))
32 #define FREE_PTE_NR 1 59
33 #define tlb_fast_mode(tlb) 1 60extern void tlb_table_flush(struct mmu_gather *tlb);
61extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
62
34#endif 63#endif
35 64
36/* struct mmu_gather is an opaque type used by the mm code for passing around 65/*
37 * any data needed by arch specific code for tlb_remove_page. 66 * If we can't allocate a page to make a big batch of page pointers
67 * to work on, then just handle a few from the on-stack structure.
38 */ 68 */
39struct mmu_gather { 69#define MMU_GATHER_BUNDLE 8
40 struct mm_struct *mm; 70
41 unsigned int nr; /* set to ~0U means fast mode */ 71struct mmu_gather_batch {
42 unsigned int need_flush;/* Really unmapped some ptes? */ 72 struct mmu_gather_batch *next;
43 unsigned int fullmm; /* non-zero means full mm flush */ 73 unsigned int nr;
44 struct page * pages[FREE_PTE_NR]; 74 unsigned int max;
75 struct page *pages[0];
45}; 76};
46 77
47/* Users of the generic TLB shootdown code must declare this storage space. */ 78#define MAX_GATHER_BATCH \
48DECLARE_PER_CPU(struct mmu_gather, mmu_gathers); 79 ((PAGE_SIZE - sizeof(struct mmu_gather_batch)) / sizeof(void *))
49 80
50/* tlb_gather_mmu 81/* struct mmu_gather is an opaque type used by the mm code for passing around
51 * Return a pointer to an initialized struct mmu_gather. 82 * any data needed by arch specific code for tlb_remove_page.
52 */ 83 */
53static inline struct mmu_gather * 84struct mmu_gather {
54tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush) 85 struct mm_struct *mm;
55{ 86#ifdef CONFIG_HAVE_RCU_TABLE_FREE
56 struct mmu_gather *tlb = &get_cpu_var(mmu_gathers); 87 struct mmu_table_batch *batch;
57 88#endif
58 tlb->mm = mm; 89 unsigned int need_flush : 1, /* Did free PTEs */
90 fast_mode : 1; /* No batching */
59 91
60 /* Use fast mode if only one CPU is online */ 92 unsigned int fullmm;
61 tlb->nr = num_online_cpus() > 1 ? 0U : ~0U;
62 93
63 tlb->fullmm = full_mm_flush; 94 struct mmu_gather_batch *active;
95 struct mmu_gather_batch local;
96 struct page *__pages[MMU_GATHER_BUNDLE];
97};
64 98
65 return tlb; 99#define HAVE_GENERIC_MMU_GATHER
66}
67 100
68static inline void 101static inline int tlb_fast_mode(struct mmu_gather *tlb)
69tlb_flush_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
70{ 102{
71 if (!tlb->need_flush) 103#ifdef CONFIG_SMP
72 return; 104 return tlb->fast_mode;
73 tlb->need_flush = 0; 105#else
74 tlb_flush(tlb); 106 /*
75 if (!tlb_fast_mode(tlb)) { 107 * For UP we don't need to worry about TLB flush
76 free_pages_and_swap_cache(tlb->pages, tlb->nr); 108 * and page free order so much..
77 tlb->nr = 0; 109 */
78 } 110 return 1;
111#endif
79} 112}
80 113
81/* tlb_finish_mmu 114void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm);
82 * Called at the end of the shootdown operation to free up any resources 115void tlb_flush_mmu(struct mmu_gather *tlb);
83 * that were required. 116void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end);
84 */ 117int __tlb_remove_page(struct mmu_gather *tlb, struct page *page);
85static inline void
86tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
87{
88 tlb_flush_mmu(tlb, start, end);
89
90 /* keep the page table cache within bounds */
91 check_pgt_cache();
92
93 put_cpu_var(mmu_gathers);
94}
95 118
96/* tlb_remove_page 119/* tlb_remove_page
97 * Must perform the equivalent to __free_pte(pte_get_and_clear(ptep)), while 120 * Similar to __tlb_remove_page but will call tlb_flush_mmu() itself when
98 * handling the additional races in SMP caused by other CPUs caching valid 121 * required.
99 * mappings in their TLBs.
100 */ 122 */
101static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) 123static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
102{ 124{
103 tlb->need_flush = 1; 125 if (!__tlb_remove_page(tlb, page))
104 if (tlb_fast_mode(tlb)) { 126 tlb_flush_mmu(tlb);
105 free_page_and_swap_cache(page);
106 return;
107 }
108 tlb->pages[tlb->nr++] = page;
109 if (tlb->nr >= FREE_PTE_NR)
110 tlb_flush_mmu(tlb, 0, 0);
111} 127}
112 128
113/** 129/**
diff --git a/include/asm-generic/types.h b/include/asm-generic/types.h
index fba7d33ca3f2..7a0f69e6c618 100644
--- a/include/asm-generic/types.h
+++ b/include/asm-generic/types.h
@@ -12,31 +12,4 @@ typedef unsigned short umode_t;
12 12
13#endif /* __ASSEMBLY__ */ 13#endif /* __ASSEMBLY__ */
14 14
15/*
16 * These aren't exported outside the kernel to avoid name space clashes
17 */
18#ifdef __KERNEL__
19#ifndef __ASSEMBLY__
20/*
21 * DMA addresses may be very different from physical addresses
22 * and pointers. i386 and powerpc may have 64 bit DMA on 32 bit
23 * systems, while sparc64 uses 32 bit DMA addresses for 64 bit
24 * physical addresses.
25 * This default defines dma_addr_t to have the same size as
26 * phys_addr_t, which is the most common way.
27 * Do not define the dma64_addr_t type, which never really
28 * worked.
29 */
30#ifndef dma_addr_t
31#ifdef CONFIG_PHYS_ADDR_T_64BIT
32typedef u64 dma_addr_t;
33#else
34typedef u32 dma_addr_t;
35#endif /* CONFIG_PHYS_ADDR_T_64BIT */
36#endif /* dma_addr_t */
37
38#endif /* __ASSEMBLY__ */
39
40#endif /* __KERNEL__ */
41
42#endif /* _ASM_GENERIC_TYPES_H */ 15#endif /* _ASM_GENERIC_TYPES_H */
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index b218b8513d04..ac68c999b6c2 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -288,14 +288,16 @@ strncpy_from_user(char *dst, const char __user *src, long count)
288 * 288 *
289 * Return 0 on exception, a value greater than N if too long 289 * Return 0 on exception, a value greater than N if too long
290 */ 290 */
291#ifndef strnlen_user 291#ifndef __strnlen_user
292#define __strnlen_user strnlen
293#endif
294
292static inline long strnlen_user(const char __user *src, long n) 295static inline long strnlen_user(const char __user *src, long n)
293{ 296{
294 if (!access_ok(VERIFY_READ, src, 1)) 297 if (!access_ok(VERIFY_READ, src, 1))
295 return 0; 298 return 0;
296 return strlen((void * __force)src) + 1; 299 return __strnlen_user(src, n);
297} 300}
298#endif
299 301
300static inline long strlen_user(const char __user *src) 302static inline long strlen_user(const char __user *src)
301{ 303{
diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h
index b969770196c2..4f76959397fa 100644
--- a/include/asm-generic/unistd.h
+++ b/include/asm-generic/unistd.h
@@ -24,16 +24,24 @@
24#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64) 24#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64)
25#endif 25#endif
26 26
27#ifdef __SYSCALL_COMPAT
28#define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _comp)
29#define __SC_COMP_3264(_nr, _32, _64, _comp) __SYSCALL(_nr, _comp)
30#else
31#define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
32#define __SC_COMP_3264(_nr, _32, _64, _comp) __SC_3264(_nr, _32, _64)
33#endif
34
27#define __NR_io_setup 0 35#define __NR_io_setup 0
28__SYSCALL(__NR_io_setup, sys_io_setup) 36__SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
29#define __NR_io_destroy 1 37#define __NR_io_destroy 1
30__SYSCALL(__NR_io_destroy, sys_io_destroy) 38__SYSCALL(__NR_io_destroy, sys_io_destroy)
31#define __NR_io_submit 2 39#define __NR_io_submit 2
32__SYSCALL(__NR_io_submit, sys_io_submit) 40__SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit)
33#define __NR_io_cancel 3 41#define __NR_io_cancel 3
34__SYSCALL(__NR_io_cancel, sys_io_cancel) 42__SYSCALL(__NR_io_cancel, sys_io_cancel)
35#define __NR_io_getevents 4 43#define __NR_io_getevents 4
36__SYSCALL(__NR_io_getevents, sys_io_getevents) 44__SC_COMP(__NR_io_getevents, sys_io_getevents, compat_sys_io_getevents)
37 45
38/* fs/xattr.c */ 46/* fs/xattr.c */
39#define __NR_setxattr 5 47#define __NR_setxattr 5
@@ -67,7 +75,7 @@ __SYSCALL(__NR_getcwd, sys_getcwd)
67 75
68/* fs/cookies.c */ 76/* fs/cookies.c */
69#define __NR_lookup_dcookie 18 77#define __NR_lookup_dcookie 18
70__SYSCALL(__NR_lookup_dcookie, sys_lookup_dcookie) 78__SC_COMP(__NR_lookup_dcookie, sys_lookup_dcookie, compat_sys_lookup_dcookie)
71 79
72/* fs/eventfd.c */ 80/* fs/eventfd.c */
73#define __NR_eventfd2 19 81#define __NR_eventfd2 19
@@ -79,7 +87,7 @@ __SYSCALL(__NR_epoll_create1, sys_epoll_create1)
79#define __NR_epoll_ctl 21 87#define __NR_epoll_ctl 21
80__SYSCALL(__NR_epoll_ctl, sys_epoll_ctl) 88__SYSCALL(__NR_epoll_ctl, sys_epoll_ctl)
81#define __NR_epoll_pwait 22 89#define __NR_epoll_pwait 22
82__SYSCALL(__NR_epoll_pwait, sys_epoll_pwait) 90__SC_COMP(__NR_epoll_pwait, sys_epoll_pwait, compat_sys_epoll_pwait)
83 91
84/* fs/fcntl.c */ 92/* fs/fcntl.c */
85#define __NR_dup 23 93#define __NR_dup 23
@@ -87,7 +95,7 @@ __SYSCALL(__NR_dup, sys_dup)
87#define __NR_dup3 24 95#define __NR_dup3 24
88__SYSCALL(__NR_dup3, sys_dup3) 96__SYSCALL(__NR_dup3, sys_dup3)
89#define __NR3264_fcntl 25 97#define __NR3264_fcntl 25
90__SC_3264(__NR3264_fcntl, sys_fcntl64, sys_fcntl) 98__SC_COMP_3264(__NR3264_fcntl, sys_fcntl64, sys_fcntl, compat_sys_fcntl64)
91 99
92/* fs/inotify_user.c */ 100/* fs/inotify_user.c */
93#define __NR_inotify_init1 26 101#define __NR_inotify_init1 26
@@ -99,7 +107,7 @@ __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)
99 107
100/* fs/ioctl.c */ 108/* fs/ioctl.c */
101#define __NR_ioctl 29 109#define __NR_ioctl 29
102__SYSCALL(__NR_ioctl, sys_ioctl) 110__SC_COMP(__NR_ioctl, sys_ioctl, compat_sys_ioctl)
103 111
104/* fs/ioprio.c */ 112/* fs/ioprio.c */
105#define __NR_ioprio_set 30 113#define __NR_ioprio_set 30
@@ -129,26 +137,30 @@ __SYSCALL(__NR_renameat, sys_renameat)
129#define __NR_umount2 39 137#define __NR_umount2 39
130__SYSCALL(__NR_umount2, sys_umount) 138__SYSCALL(__NR_umount2, sys_umount)
131#define __NR_mount 40 139#define __NR_mount 40
132__SYSCALL(__NR_mount, sys_mount) 140__SC_COMP(__NR_mount, sys_mount, compat_sys_mount)
133#define __NR_pivot_root 41 141#define __NR_pivot_root 41
134__SYSCALL(__NR_pivot_root, sys_pivot_root) 142__SYSCALL(__NR_pivot_root, sys_pivot_root)
135 143
136/* fs/nfsctl.c */ 144/* fs/nfsctl.c */
137#define __NR_nfsservctl 42 145#define __NR_nfsservctl 42
138__SYSCALL(__NR_nfsservctl, sys_nfsservctl) 146__SC_COMP(__NR_nfsservctl, sys_nfsservctl, compat_sys_nfsservctl)
139 147
140/* fs/open.c */ 148/* fs/open.c */
141#define __NR3264_statfs 43 149#define __NR3264_statfs 43
142__SC_3264(__NR3264_statfs, sys_statfs64, sys_statfs) 150__SC_COMP_3264(__NR3264_statfs, sys_statfs64, sys_statfs, \
151 compat_sys_statfs64)
143#define __NR3264_fstatfs 44 152#define __NR3264_fstatfs 44
144__SC_3264(__NR3264_fstatfs, sys_fstatfs64, sys_fstatfs) 153__SC_COMP_3264(__NR3264_fstatfs, sys_fstatfs64, sys_fstatfs, \
154 compat_sys_fstatfs64)
145#define __NR3264_truncate 45 155#define __NR3264_truncate 45
146__SC_3264(__NR3264_truncate, sys_truncate64, sys_truncate) 156__SC_COMP_3264(__NR3264_truncate, sys_truncate64, sys_truncate, \
157 compat_sys_truncate64)
147#define __NR3264_ftruncate 46 158#define __NR3264_ftruncate 46
148__SC_3264(__NR3264_ftruncate, sys_ftruncate64, sys_ftruncate) 159__SC_COMP_3264(__NR3264_ftruncate, sys_ftruncate64, sys_ftruncate, \
160 compat_sys_ftruncate64)
149 161
150#define __NR_fallocate 47 162#define __NR_fallocate 47
151__SYSCALL(__NR_fallocate, sys_fallocate) 163__SC_COMP(__NR_fallocate, sys_fallocate, compat_sys_fallocate)
152#define __NR_faccessat 48 164#define __NR_faccessat 48
153__SYSCALL(__NR_faccessat, sys_faccessat) 165__SYSCALL(__NR_faccessat, sys_faccessat)
154#define __NR_chdir 49 166#define __NR_chdir 49
@@ -166,7 +178,7 @@ __SYSCALL(__NR_fchownat, sys_fchownat)
166#define __NR_fchown 55 178#define __NR_fchown 55
167__SYSCALL(__NR_fchown, sys_fchown) 179__SYSCALL(__NR_fchown, sys_fchown)
168#define __NR_openat 56 180#define __NR_openat 56
169__SYSCALL(__NR_openat, sys_openat) 181__SC_COMP(__NR_openat, sys_openat, compat_sys_openat)
170#define __NR_close 57 182#define __NR_close 57
171__SYSCALL(__NR_close, sys_close) 183__SYSCALL(__NR_close, sys_close)
172#define __NR_vhangup 58 184#define __NR_vhangup 58
@@ -182,7 +194,7 @@ __SYSCALL(__NR_quotactl, sys_quotactl)
182 194
183/* fs/readdir.c */ 195/* fs/readdir.c */
184#define __NR_getdents64 61 196#define __NR_getdents64 61
185__SYSCALL(__NR_getdents64, sys_getdents64) 197__SC_COMP(__NR_getdents64, sys_getdents64, compat_sys_getdents64)
186 198
187/* fs/read_write.c */ 199/* fs/read_write.c */
188#define __NR3264_lseek 62 200#define __NR3264_lseek 62
@@ -192,17 +204,17 @@ __SYSCALL(__NR_read, sys_read)
192#define __NR_write 64 204#define __NR_write 64
193__SYSCALL(__NR_write, sys_write) 205__SYSCALL(__NR_write, sys_write)
194#define __NR_readv 65 206#define __NR_readv 65
195__SYSCALL(__NR_readv, sys_readv) 207__SC_COMP(__NR_readv, sys_readv, compat_sys_readv)
196#define __NR_writev 66 208#define __NR_writev 66
197__SYSCALL(__NR_writev, sys_writev) 209__SC_COMP(__NR_writev, sys_writev, compat_sys_writev)
198#define __NR_pread64 67 210#define __NR_pread64 67
199__SYSCALL(__NR_pread64, sys_pread64) 211__SC_COMP(__NR_pread64, sys_pread64, compat_sys_pread64)
200#define __NR_pwrite64 68 212#define __NR_pwrite64 68
201__SYSCALL(__NR_pwrite64, sys_pwrite64) 213__SC_COMP(__NR_pwrite64, sys_pwrite64, compat_sys_pwrite64)
202#define __NR_preadv 69 214#define __NR_preadv 69
203__SYSCALL(__NR_preadv, sys_preadv) 215__SC_COMP(__NR_preadv, sys_preadv, compat_sys_preadv)
204#define __NR_pwritev 70 216#define __NR_pwritev 70
205__SYSCALL(__NR_pwritev, sys_pwritev) 217__SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev)
206 218
207/* fs/sendfile.c */ 219/* fs/sendfile.c */
208#define __NR3264_sendfile 71 220#define __NR3264_sendfile 71
@@ -210,17 +222,17 @@ __SC_3264(__NR3264_sendfile, sys_sendfile64, sys_sendfile)
210 222
211/* fs/select.c */ 223/* fs/select.c */
212#define __NR_pselect6 72 224#define __NR_pselect6 72
213__SYSCALL(__NR_pselect6, sys_pselect6) 225__SC_COMP(__NR_pselect6, sys_pselect6, compat_sys_pselect6)
214#define __NR_ppoll 73 226#define __NR_ppoll 73
215__SYSCALL(__NR_ppoll, sys_ppoll) 227__SC_COMP(__NR_ppoll, sys_ppoll, compat_sys_ppoll)
216 228
217/* fs/signalfd.c */ 229/* fs/signalfd.c */
218#define __NR_signalfd4 74 230#define __NR_signalfd4 74
219__SYSCALL(__NR_signalfd4, sys_signalfd4) 231__SC_COMP(__NR_signalfd4, sys_signalfd4, compat_sys_signalfd4)
220 232
221/* fs/splice.c */ 233/* fs/splice.c */
222#define __NR_vmsplice 75 234#define __NR_vmsplice 75
223__SYSCALL(__NR_vmsplice, sys_vmsplice) 235__SC_COMP(__NR_vmsplice, sys_vmsplice, compat_sys_vmsplice)
224#define __NR_splice 76 236#define __NR_splice 76
225__SYSCALL(__NR_splice, sys_splice) 237__SYSCALL(__NR_splice, sys_splice)
226#define __NR_tee 77 238#define __NR_tee 77
@@ -243,23 +255,27 @@ __SYSCALL(__NR_fsync, sys_fsync)
243__SYSCALL(__NR_fdatasync, sys_fdatasync) 255__SYSCALL(__NR_fdatasync, sys_fdatasync)
244#ifdef __ARCH_WANT_SYNC_FILE_RANGE2 256#ifdef __ARCH_WANT_SYNC_FILE_RANGE2
245#define __NR_sync_file_range2 84 257#define __NR_sync_file_range2 84
246__SYSCALL(__NR_sync_file_range2, sys_sync_file_range2) 258__SC_COMP(__NR_sync_file_range2, sys_sync_file_range2, \
259 compat_sys_sync_file_range2)
247#else 260#else
248#define __NR_sync_file_range 84 261#define __NR_sync_file_range 84
249__SYSCALL(__NR_sync_file_range, sys_sync_file_range) 262__SC_COMP(__NR_sync_file_range, sys_sync_file_range, \
263 compat_sys_sync_file_range)
250#endif 264#endif
251 265
252/* fs/timerfd.c */ 266/* fs/timerfd.c */
253#define __NR_timerfd_create 85 267#define __NR_timerfd_create 85
254__SYSCALL(__NR_timerfd_create, sys_timerfd_create) 268__SYSCALL(__NR_timerfd_create, sys_timerfd_create)
255#define __NR_timerfd_settime 86 269#define __NR_timerfd_settime 86
256__SYSCALL(__NR_timerfd_settime, sys_timerfd_settime) 270__SC_COMP(__NR_timerfd_settime, sys_timerfd_settime, \
271 compat_sys_timerfd_settime)
257#define __NR_timerfd_gettime 87 272#define __NR_timerfd_gettime 87
258__SYSCALL(__NR_timerfd_gettime, sys_timerfd_gettime) 273__SC_COMP(__NR_timerfd_gettime, sys_timerfd_gettime, \
274 compat_sys_timerfd_gettime)
259 275
260/* fs/utimes.c */ 276/* fs/utimes.c */
261#define __NR_utimensat 88 277#define __NR_utimensat 88
262__SYSCALL(__NR_utimensat, sys_utimensat) 278__SC_COMP(__NR_utimensat, sys_utimensat, compat_sys_utimensat)
263 279
264/* kernel/acct.c */ 280/* kernel/acct.c */
265#define __NR_acct 89 281#define __NR_acct 89
@@ -281,7 +297,7 @@ __SYSCALL(__NR_exit, sys_exit)
281#define __NR_exit_group 94 297#define __NR_exit_group 94
282__SYSCALL(__NR_exit_group, sys_exit_group) 298__SYSCALL(__NR_exit_group, sys_exit_group)
283#define __NR_waitid 95 299#define __NR_waitid 95
284__SYSCALL(__NR_waitid, sys_waitid) 300__SC_COMP(__NR_waitid, sys_waitid, compat_sys_waitid)
285 301
286/* kernel/fork.c */ 302/* kernel/fork.c */
287#define __NR_set_tid_address 96 303#define __NR_set_tid_address 96
@@ -291,25 +307,27 @@ __SYSCALL(__NR_unshare, sys_unshare)
291 307
292/* kernel/futex.c */ 308/* kernel/futex.c */
293#define __NR_futex 98 309#define __NR_futex 98
294__SYSCALL(__NR_futex, sys_futex) 310__SC_COMP(__NR_futex, sys_futex, compat_sys_futex)
295#define __NR_set_robust_list 99 311#define __NR_set_robust_list 99
296__SYSCALL(__NR_set_robust_list, sys_set_robust_list) 312__SC_COMP(__NR_set_robust_list, sys_set_robust_list, \
313 compat_sys_set_robust_list)
297#define __NR_get_robust_list 100 314#define __NR_get_robust_list 100
298__SYSCALL(__NR_get_robust_list, sys_get_robust_list) 315__SC_COMP(__NR_get_robust_list, sys_get_robust_list, \
316 compat_sys_get_robust_list)
299 317
300/* kernel/hrtimer.c */ 318/* kernel/hrtimer.c */
301#define __NR_nanosleep 101 319#define __NR_nanosleep 101
302__SYSCALL(__NR_nanosleep, sys_nanosleep) 320__SC_COMP(__NR_nanosleep, sys_nanosleep, compat_sys_nanosleep)
303 321
304/* kernel/itimer.c */ 322/* kernel/itimer.c */
305#define __NR_getitimer 102 323#define __NR_getitimer 102
306__SYSCALL(__NR_getitimer, sys_getitimer) 324__SC_COMP(__NR_getitimer, sys_getitimer, compat_sys_getitimer)
307#define __NR_setitimer 103 325#define __NR_setitimer 103
308__SYSCALL(__NR_setitimer, sys_setitimer) 326__SC_COMP(__NR_setitimer, sys_setitimer, compat_sys_setitimer)
309 327
310/* kernel/kexec.c */ 328/* kernel/kexec.c */
311#define __NR_kexec_load 104 329#define __NR_kexec_load 104
312__SYSCALL(__NR_kexec_load, sys_kexec_load) 330__SC_COMP(__NR_kexec_load, sys_kexec_load, compat_sys_kexec_load)
313 331
314/* kernel/module.c */ 332/* kernel/module.c */
315#define __NR_init_module 105 333#define __NR_init_module 105
@@ -319,23 +337,24 @@ __SYSCALL(__NR_delete_module, sys_delete_module)
319 337
320/* kernel/posix-timers.c */ 338/* kernel/posix-timers.c */
321#define __NR_timer_create 107 339#define __NR_timer_create 107
322__SYSCALL(__NR_timer_create, sys_timer_create) 340__SC_COMP(__NR_timer_create, sys_timer_create, compat_sys_timer_create)
323#define __NR_timer_gettime 108 341#define __NR_timer_gettime 108
324__SYSCALL(__NR_timer_gettime, sys_timer_gettime) 342__SC_COMP(__NR_timer_gettime, sys_timer_gettime, compat_sys_timer_gettime)
325#define __NR_timer_getoverrun 109 343#define __NR_timer_getoverrun 109
326__SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun) 344__SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun)
327#define __NR_timer_settime 110 345#define __NR_timer_settime 110
328__SYSCALL(__NR_timer_settime, sys_timer_settime) 346__SC_COMP(__NR_timer_settime, sys_timer_settime, compat_sys_timer_settime)
329#define __NR_timer_delete 111 347#define __NR_timer_delete 111
330__SYSCALL(__NR_timer_delete, sys_timer_delete) 348__SYSCALL(__NR_timer_delete, sys_timer_delete)
331#define __NR_clock_settime 112 349#define __NR_clock_settime 112
332__SYSCALL(__NR_clock_settime, sys_clock_settime) 350__SC_COMP(__NR_clock_settime, sys_clock_settime, compat_sys_clock_settime)
333#define __NR_clock_gettime 113 351#define __NR_clock_gettime 113
334__SYSCALL(__NR_clock_gettime, sys_clock_gettime) 352__SC_COMP(__NR_clock_gettime, sys_clock_gettime, compat_sys_clock_gettime)
335#define __NR_clock_getres 114 353#define __NR_clock_getres 114
336__SYSCALL(__NR_clock_getres, sys_clock_getres) 354__SC_COMP(__NR_clock_getres, sys_clock_getres, compat_sys_clock_getres)
337#define __NR_clock_nanosleep 115 355#define __NR_clock_nanosleep 115
338__SYSCALL(__NR_clock_nanosleep, sys_clock_nanosleep) 356__SC_COMP(__NR_clock_nanosleep, sys_clock_nanosleep, \
357 compat_sys_clock_nanosleep)
339 358
340/* kernel/printk.c */ 359/* kernel/printk.c */
341#define __NR_syslog 116 360#define __NR_syslog 116
@@ -355,9 +374,11 @@ __SYSCALL(__NR_sched_getscheduler, sys_sched_getscheduler)
355#define __NR_sched_getparam 121 374#define __NR_sched_getparam 121
356__SYSCALL(__NR_sched_getparam, sys_sched_getparam) 375__SYSCALL(__NR_sched_getparam, sys_sched_getparam)
357#define __NR_sched_setaffinity 122 376#define __NR_sched_setaffinity 122
358__SYSCALL(__NR_sched_setaffinity, sys_sched_setaffinity) 377__SC_COMP(__NR_sched_setaffinity, sys_sched_setaffinity, \
378 compat_sys_sched_setaffinity)
359#define __NR_sched_getaffinity 123 379#define __NR_sched_getaffinity 123
360__SYSCALL(__NR_sched_getaffinity, sys_sched_getaffinity) 380__SC_COMP(__NR_sched_getaffinity, sys_sched_getaffinity, \
381 compat_sys_sched_getaffinity)
361#define __NR_sched_yield 124 382#define __NR_sched_yield 124
362__SYSCALL(__NR_sched_yield, sys_sched_yield) 383__SYSCALL(__NR_sched_yield, sys_sched_yield)
363#define __NR_sched_get_priority_max 125 384#define __NR_sched_get_priority_max 125
@@ -365,7 +386,8 @@ __SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max)
365#define __NR_sched_get_priority_min 126 386#define __NR_sched_get_priority_min 126
366__SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min) 387__SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min)
367#define __NR_sched_rr_get_interval 127 388#define __NR_sched_rr_get_interval 127
368__SYSCALL(__NR_sched_rr_get_interval, sys_sched_rr_get_interval) 389__SC_COMP(__NR_sched_rr_get_interval, sys_sched_rr_get_interval, \
390 compat_sys_sched_rr_get_interval)
369 391
370/* kernel/signal.c */ 392/* kernel/signal.c */
371#define __NR_restart_syscall 128 393#define __NR_restart_syscall 128
@@ -377,21 +399,23 @@ __SYSCALL(__NR_tkill, sys_tkill)
377#define __NR_tgkill 131 399#define __NR_tgkill 131
378__SYSCALL(__NR_tgkill, sys_tgkill) 400__SYSCALL(__NR_tgkill, sys_tgkill)
379#define __NR_sigaltstack 132 401#define __NR_sigaltstack 132
380__SYSCALL(__NR_sigaltstack, sys_sigaltstack) 402__SC_COMP(__NR_sigaltstack, sys_sigaltstack, compat_sys_sigaltstack)
381#define __NR_rt_sigsuspend 133 403#define __NR_rt_sigsuspend 133
382__SYSCALL(__NR_rt_sigsuspend, sys_rt_sigsuspend) /* __ARCH_WANT_SYS_RT_SIGSUSPEND */ 404__SC_COMP(__NR_rt_sigsuspend, sys_rt_sigsuspend, compat_sys_rt_sigsuspend)
383#define __NR_rt_sigaction 134 405#define __NR_rt_sigaction 134
384__SYSCALL(__NR_rt_sigaction, sys_rt_sigaction) /* __ARCH_WANT_SYS_RT_SIGACTION */ 406__SC_COMP(__NR_rt_sigaction, sys_rt_sigaction, compat_sys_rt_sigaction)
385#define __NR_rt_sigprocmask 135 407#define __NR_rt_sigprocmask 135
386__SYSCALL(__NR_rt_sigprocmask, sys_rt_sigprocmask) 408__SYSCALL(__NR_rt_sigprocmask, sys_rt_sigprocmask)
387#define __NR_rt_sigpending 136 409#define __NR_rt_sigpending 136
388__SYSCALL(__NR_rt_sigpending, sys_rt_sigpending) 410__SYSCALL(__NR_rt_sigpending, sys_rt_sigpending)
389#define __NR_rt_sigtimedwait 137 411#define __NR_rt_sigtimedwait 137
390__SYSCALL(__NR_rt_sigtimedwait, sys_rt_sigtimedwait) 412__SC_COMP(__NR_rt_sigtimedwait, sys_rt_sigtimedwait, \
413 compat_sys_rt_sigtimedwait)
391#define __NR_rt_sigqueueinfo 138 414#define __NR_rt_sigqueueinfo 138
392__SYSCALL(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo) 415__SC_COMP(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo, \
416 compat_sys_rt_sigqueueinfo)
393#define __NR_rt_sigreturn 139 417#define __NR_rt_sigreturn 139
394__SYSCALL(__NR_rt_sigreturn, sys_rt_sigreturn) /* sys_rt_sigreturn_wrapper, */ 418__SC_COMP(__NR_rt_sigreturn, sys_rt_sigreturn, compat_sys_rt_sigreturn)
395 419
396/* kernel/sys.c */ 420/* kernel/sys.c */
397#define __NR_setpriority 140 421#define __NR_setpriority 140
@@ -421,7 +445,7 @@ __SYSCALL(__NR_setfsuid, sys_setfsuid)
421#define __NR_setfsgid 152 445#define __NR_setfsgid 152
422__SYSCALL(__NR_setfsgid, sys_setfsgid) 446__SYSCALL(__NR_setfsgid, sys_setfsgid)
423#define __NR_times 153 447#define __NR_times 153
424__SYSCALL(__NR_times, sys_times) 448__SC_COMP(__NR_times, sys_times, compat_sys_times)
425#define __NR_setpgid 154 449#define __NR_setpgid 154
426__SYSCALL(__NR_setpgid, sys_setpgid) 450__SYSCALL(__NR_setpgid, sys_setpgid)
427#define __NR_getpgid 155 451#define __NR_getpgid 155
@@ -441,11 +465,11 @@ __SYSCALL(__NR_sethostname, sys_sethostname)
441#define __NR_setdomainname 162 465#define __NR_setdomainname 162
442__SYSCALL(__NR_setdomainname, sys_setdomainname) 466__SYSCALL(__NR_setdomainname, sys_setdomainname)
443#define __NR_getrlimit 163 467#define __NR_getrlimit 163
444__SYSCALL(__NR_getrlimit, sys_getrlimit) 468__SC_COMP(__NR_getrlimit, sys_getrlimit, compat_sys_getrlimit)
445#define __NR_setrlimit 164 469#define __NR_setrlimit 164
446__SYSCALL(__NR_setrlimit, sys_setrlimit) 470__SC_COMP(__NR_setrlimit, sys_setrlimit, compat_sys_setrlimit)
447#define __NR_getrusage 165 471#define __NR_getrusage 165
448__SYSCALL(__NR_getrusage, sys_getrusage) 472__SC_COMP(__NR_getrusage, sys_getrusage, compat_sys_getrusage)
449#define __NR_umask 166 473#define __NR_umask 166
450__SYSCALL(__NR_umask, sys_umask) 474__SYSCALL(__NR_umask, sys_umask)
451#define __NR_prctl 167 475#define __NR_prctl 167
@@ -455,11 +479,11 @@ __SYSCALL(__NR_getcpu, sys_getcpu)
455 479
456/* kernel/time.c */ 480/* kernel/time.c */
457#define __NR_gettimeofday 169 481#define __NR_gettimeofday 169
458__SYSCALL(__NR_gettimeofday, sys_gettimeofday) 482__SC_COMP(__NR_gettimeofday, sys_gettimeofday, compat_sys_gettimeofday)
459#define __NR_settimeofday 170 483#define __NR_settimeofday 170
460__SYSCALL(__NR_settimeofday, sys_settimeofday) 484__SC_COMP(__NR_settimeofday, sys_settimeofday, compat_sys_settimeofday)
461#define __NR_adjtimex 171 485#define __NR_adjtimex 171
462__SYSCALL(__NR_adjtimex, sys_adjtimex) 486__SC_COMP(__NR_adjtimex, sys_adjtimex, compat_sys_adjtimex)
463 487
464/* kernel/timer.c */ 488/* kernel/timer.c */
465#define __NR_getpid 172 489#define __NR_getpid 172
@@ -477,39 +501,40 @@ __SYSCALL(__NR_getegid, sys_getegid)
477#define __NR_gettid 178 501#define __NR_gettid 178
478__SYSCALL(__NR_gettid, sys_gettid) 502__SYSCALL(__NR_gettid, sys_gettid)
479#define __NR_sysinfo 179 503#define __NR_sysinfo 179
480__SYSCALL(__NR_sysinfo, sys_sysinfo) 504__SC_COMP(__NR_sysinfo, sys_sysinfo, compat_sys_sysinfo)
481 505
482/* ipc/mqueue.c */ 506/* ipc/mqueue.c */
483#define __NR_mq_open 180 507#define __NR_mq_open 180
484__SYSCALL(__NR_mq_open, sys_mq_open) 508__SC_COMP(__NR_mq_open, sys_mq_open, compat_sys_mq_open)
485#define __NR_mq_unlink 181 509#define __NR_mq_unlink 181
486__SYSCALL(__NR_mq_unlink, sys_mq_unlink) 510__SYSCALL(__NR_mq_unlink, sys_mq_unlink)
487#define __NR_mq_timedsend 182 511#define __NR_mq_timedsend 182
488__SYSCALL(__NR_mq_timedsend, sys_mq_timedsend) 512__SC_COMP(__NR_mq_timedsend, sys_mq_timedsend, compat_sys_mq_timedsend)
489#define __NR_mq_timedreceive 183 513#define __NR_mq_timedreceive 183
490__SYSCALL(__NR_mq_timedreceive, sys_mq_timedreceive) 514__SC_COMP(__NR_mq_timedreceive, sys_mq_timedreceive, \
515 compat_sys_mq_timedreceive)
491#define __NR_mq_notify 184 516#define __NR_mq_notify 184
492__SYSCALL(__NR_mq_notify, sys_mq_notify) 517__SC_COMP(__NR_mq_notify, sys_mq_notify, compat_sys_mq_notify)
493#define __NR_mq_getsetattr 185 518#define __NR_mq_getsetattr 185
494__SYSCALL(__NR_mq_getsetattr, sys_mq_getsetattr) 519__SC_COMP(__NR_mq_getsetattr, sys_mq_getsetattr, compat_sys_mq_getsetattr)
495 520
496/* ipc/msg.c */ 521/* ipc/msg.c */
497#define __NR_msgget 186 522#define __NR_msgget 186
498__SYSCALL(__NR_msgget, sys_msgget) 523__SYSCALL(__NR_msgget, sys_msgget)
499#define __NR_msgctl 187 524#define __NR_msgctl 187
500__SYSCALL(__NR_msgctl, sys_msgctl) 525__SC_COMP(__NR_msgctl, sys_msgctl, compat_sys_msgctl)
501#define __NR_msgrcv 188 526#define __NR_msgrcv 188
502__SYSCALL(__NR_msgrcv, sys_msgrcv) 527__SC_COMP(__NR_msgrcv, sys_msgrcv, compat_sys_msgrcv)
503#define __NR_msgsnd 189 528#define __NR_msgsnd 189
504__SYSCALL(__NR_msgsnd, sys_msgsnd) 529__SC_COMP(__NR_msgsnd, sys_msgsnd, compat_sys_msgsnd)
505 530
506/* ipc/sem.c */ 531/* ipc/sem.c */
507#define __NR_semget 190 532#define __NR_semget 190
508__SYSCALL(__NR_semget, sys_semget) 533__SYSCALL(__NR_semget, sys_semget)
509#define __NR_semctl 191 534#define __NR_semctl 191
510__SYSCALL(__NR_semctl, sys_semctl) 535__SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl)
511#define __NR_semtimedop 192 536#define __NR_semtimedop 192
512__SYSCALL(__NR_semtimedop, sys_semtimedop) 537__SC_COMP(__NR_semtimedop, sys_semtimedop, compat_sys_semtimedop)
513#define __NR_semop 193 538#define __NR_semop 193
514__SYSCALL(__NR_semop, sys_semop) 539__SYSCALL(__NR_semop, sys_semop)
515 540
@@ -517,9 +542,9 @@ __SYSCALL(__NR_semop, sys_semop)
517#define __NR_shmget 194 542#define __NR_shmget 194
518__SYSCALL(__NR_shmget, sys_shmget) 543__SYSCALL(__NR_shmget, sys_shmget)
519#define __NR_shmctl 195 544#define __NR_shmctl 195
520__SYSCALL(__NR_shmctl, sys_shmctl) 545__SC_COMP(__NR_shmctl, sys_shmctl, compat_sys_shmctl)
521#define __NR_shmat 196 546#define __NR_shmat 196
522__SYSCALL(__NR_shmat, sys_shmat) 547__SC_COMP(__NR_shmat, sys_shmat, compat_sys_shmat)
523#define __NR_shmdt 197 548#define __NR_shmdt 197
524__SYSCALL(__NR_shmdt, sys_shmdt) 549__SYSCALL(__NR_shmdt, sys_shmdt)
525 550
@@ -543,21 +568,21 @@ __SYSCALL(__NR_getpeername, sys_getpeername)
543#define __NR_sendto 206 568#define __NR_sendto 206
544__SYSCALL(__NR_sendto, sys_sendto) 569__SYSCALL(__NR_sendto, sys_sendto)
545#define __NR_recvfrom 207 570#define __NR_recvfrom 207
546__SYSCALL(__NR_recvfrom, sys_recvfrom) 571__SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom)
547#define __NR_setsockopt 208 572#define __NR_setsockopt 208
548__SYSCALL(__NR_setsockopt, sys_setsockopt) 573__SC_COMP(__NR_setsockopt, sys_setsockopt, compat_sys_setsockopt)
549#define __NR_getsockopt 209 574#define __NR_getsockopt 209
550__SYSCALL(__NR_getsockopt, sys_getsockopt) 575__SC_COMP(__NR_getsockopt, sys_getsockopt, compat_sys_getsockopt)
551#define __NR_shutdown 210 576#define __NR_shutdown 210
552__SYSCALL(__NR_shutdown, sys_shutdown) 577__SYSCALL(__NR_shutdown, sys_shutdown)
553#define __NR_sendmsg 211 578#define __NR_sendmsg 211
554__SYSCALL(__NR_sendmsg, sys_sendmsg) 579__SC_COMP(__NR_sendmsg, sys_sendmsg, compat_sys_sendmsg)
555#define __NR_recvmsg 212 580#define __NR_recvmsg 212
556__SYSCALL(__NR_recvmsg, sys_recvmsg) 581__SC_COMP(__NR_recvmsg, sys_recvmsg, compat_sys_recvmsg)
557 582
558/* mm/filemap.c */ 583/* mm/filemap.c */
559#define __NR_readahead 213 584#define __NR_readahead 213
560__SYSCALL(__NR_readahead, sys_readahead) 585__SC_COMP(__NR_readahead, sys_readahead, compat_sys_readahead)
561 586
562/* mm/nommu.c, also with MMU */ 587/* mm/nommu.c, also with MMU */
563#define __NR_brk 214 588#define __NR_brk 214
@@ -573,19 +598,19 @@ __SYSCALL(__NR_add_key, sys_add_key)
573#define __NR_request_key 218 598#define __NR_request_key 218
574__SYSCALL(__NR_request_key, sys_request_key) 599__SYSCALL(__NR_request_key, sys_request_key)
575#define __NR_keyctl 219 600#define __NR_keyctl 219
576__SYSCALL(__NR_keyctl, sys_keyctl) 601__SC_COMP(__NR_keyctl, sys_keyctl, compat_sys_keyctl)
577 602
578/* arch/example/kernel/sys_example.c */ 603/* arch/example/kernel/sys_example.c */
579#define __NR_clone 220 604#define __NR_clone 220
580__SYSCALL(__NR_clone, sys_clone) /* .long sys_clone_wrapper */ 605__SYSCALL(__NR_clone, sys_clone)
581#define __NR_execve 221 606#define __NR_execve 221
582__SYSCALL(__NR_execve, sys_execve) /* .long sys_execve_wrapper */ 607__SC_COMP(__NR_execve, sys_execve, compat_sys_execve)
583 608
584#define __NR3264_mmap 222 609#define __NR3264_mmap 222
585__SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap) 610__SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap)
586/* mm/fadvise.c */ 611/* mm/fadvise.c */
587#define __NR3264_fadvise64 223 612#define __NR3264_fadvise64 223
588__SYSCALL(__NR3264_fadvise64, sys_fadvise64_64) 613__SC_COMP(__NR3264_fadvise64, sys_fadvise64_64, compat_sys_fadvise64_64)
589 614
590/* mm/, CONFIG_MMU only */ 615/* mm/, CONFIG_MMU only */
591#ifndef __ARCH_NOMMU 616#ifndef __ARCH_NOMMU
@@ -612,25 +637,26 @@ __SYSCALL(__NR_madvise, sys_madvise)
612#define __NR_remap_file_pages 234 637#define __NR_remap_file_pages 234
613__SYSCALL(__NR_remap_file_pages, sys_remap_file_pages) 638__SYSCALL(__NR_remap_file_pages, sys_remap_file_pages)
614#define __NR_mbind 235 639#define __NR_mbind 235
615__SYSCALL(__NR_mbind, sys_mbind) 640__SC_COMP(__NR_mbind, sys_mbind, compat_sys_mbind)
616#define __NR_get_mempolicy 236 641#define __NR_get_mempolicy 236
617__SYSCALL(__NR_get_mempolicy, sys_get_mempolicy) 642__SC_COMP(__NR_get_mempolicy, sys_get_mempolicy, compat_sys_get_mempolicy)
618#define __NR_set_mempolicy 237 643#define __NR_set_mempolicy 237
619__SYSCALL(__NR_set_mempolicy, sys_set_mempolicy) 644__SC_COMP(__NR_set_mempolicy, sys_set_mempolicy, compat_sys_set_mempolicy)
620#define __NR_migrate_pages 238 645#define __NR_migrate_pages 238
621__SYSCALL(__NR_migrate_pages, sys_migrate_pages) 646__SC_COMP(__NR_migrate_pages, sys_migrate_pages, compat_sys_migrate_pages)
622#define __NR_move_pages 239 647#define __NR_move_pages 239
623__SYSCALL(__NR_move_pages, sys_move_pages) 648__SC_COMP(__NR_move_pages, sys_move_pages, compat_sys_move_pages)
624#endif 649#endif
625 650
626#define __NR_rt_tgsigqueueinfo 240 651#define __NR_rt_tgsigqueueinfo 240
627__SYSCALL(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo) 652__SC_COMP(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, \
653 compat_sys_rt_tgsigqueueinfo)
628#define __NR_perf_event_open 241 654#define __NR_perf_event_open 241
629__SYSCALL(__NR_perf_event_open, sys_perf_event_open) 655__SYSCALL(__NR_perf_event_open, sys_perf_event_open)
630#define __NR_accept4 242 656#define __NR_accept4 242
631__SYSCALL(__NR_accept4, sys_accept4) 657__SYSCALL(__NR_accept4, sys_accept4)
632#define __NR_recvmmsg 243 658#define __NR_recvmmsg 243
633__SYSCALL(__NR_recvmmsg, sys_recvmmsg) 659__SC_COMP(__NR_recvmmsg, sys_recvmmsg, compat_sys_recvmmsg)
634 660
635/* 661/*
636 * Architectures may provide up to 16 syscalls of their own 662 * Architectures may provide up to 16 syscalls of their own
@@ -639,16 +665,29 @@ __SYSCALL(__NR_recvmmsg, sys_recvmmsg)
639#define __NR_arch_specific_syscall 244 665#define __NR_arch_specific_syscall 244
640 666
641#define __NR_wait4 260 667#define __NR_wait4 260
642__SYSCALL(__NR_wait4, sys_wait4) 668__SC_COMP(__NR_wait4, sys_wait4, compat_sys_wait4)
643#define __NR_prlimit64 261 669#define __NR_prlimit64 261
644__SYSCALL(__NR_prlimit64, sys_prlimit64) 670__SYSCALL(__NR_prlimit64, sys_prlimit64)
645#define __NR_fanotify_init 262 671#define __NR_fanotify_init 262
646__SYSCALL(__NR_fanotify_init, sys_fanotify_init) 672__SYSCALL(__NR_fanotify_init, sys_fanotify_init)
647#define __NR_fanotify_mark 263 673#define __NR_fanotify_mark 263
648__SYSCALL(__NR_fanotify_mark, sys_fanotify_mark) 674__SYSCALL(__NR_fanotify_mark, sys_fanotify_mark)
675#define __NR_name_to_handle_at 264
676__SYSCALL(__NR_name_to_handle_at, sys_name_to_handle_at)
677#define __NR_open_by_handle_at 265
678__SC_COMP(__NR_open_by_handle_at, sys_open_by_handle_at, \
679 compat_sys_open_by_handle_at)
680#define __NR_clock_adjtime 266
681__SC_COMP(__NR_clock_adjtime, sys_clock_adjtime, compat_sys_clock_adjtime)
682#define __NR_syncfs 267
683__SYSCALL(__NR_syncfs, sys_syncfs)
684#define __NR_setns 268
685__SYSCALL(__NR_setns, sys_setns)
686#define __NR_sendmmsg 269
687__SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg)
649 688
650#undef __NR_syscalls 689#undef __NR_syscalls
651#define __NR_syscalls 264 690#define __NR_syscalls 270
652 691
653/* 692/*
654 * All syscalls below here should go away really, 693 * All syscalls below here should go away really,
diff --git a/include/asm-generic/user.h b/include/asm-generic/user.h
index 8b9c3c960aeb..35638c34700f 100644
--- a/include/asm-generic/user.h
+++ b/include/asm-generic/user.h
@@ -1,8 +1,8 @@
1#ifndef __ASM_GENERIC_USER_H 1#ifndef __ASM_GENERIC_USER_H
2#define __ASM_GENERIC_USER_H 2#define __ASM_GENERIC_USER_H
3/* 3/*
4 * This file may define a 'struct user' structure. However, it it only 4 * This file may define a 'struct user' structure. However, it is only
5 * used for a.out file, which are not supported on new architectures. 5 * used for a.out files, which are not supported on new architectures.
6 */ 6 */
7 7
8#endif /* __ASM_GENERIC_USER_H */ 8#endif /* __ASM_GENERIC_USER_H */
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 8a92a170fb7d..db22d136ad08 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -15,7 +15,7 @@
15 * HEAD_TEXT_SECTION 15 * HEAD_TEXT_SECTION
16 * INIT_TEXT_SECTION(PAGE_SIZE) 16 * INIT_TEXT_SECTION(PAGE_SIZE)
17 * INIT_DATA_SECTION(...) 17 * INIT_DATA_SECTION(...)
18 * PERCPU(PAGE_SIZE) 18 * PERCPU_SECTION(CACHELINE_SIZE)
19 * __init_end = .; 19 * __init_end = .;
20 * 20 *
21 * _stext = .; 21 * _stext = .;
@@ -67,7 +67,8 @@
67 * Align to a 32 byte boundary equal to the 67 * Align to a 32 byte boundary equal to the
68 * alignment gcc 4.5 uses for a struct 68 * alignment gcc 4.5 uses for a struct
69 */ 69 */
70#define STRUCT_ALIGN() . = ALIGN(32) 70#define STRUCT_ALIGNMENT 32
71#define STRUCT_ALIGN() . = ALIGN(STRUCT_ALIGNMENT)
71 72
72/* The actual configuration determine if the init/exit sections 73/* The actual configuration determine if the init/exit sections
73 * are handled as text/data or they can be discarded (which 74 * are handled as text/data or they can be discarded (which
@@ -123,7 +124,8 @@
123#endif 124#endif
124 125
125#ifdef CONFIG_EVENT_TRACING 126#ifdef CONFIG_EVENT_TRACING
126#define FTRACE_EVENTS() VMLINUX_SYMBOL(__start_ftrace_events) = .; \ 127#define FTRACE_EVENTS() . = ALIGN(8); \
128 VMLINUX_SYMBOL(__start_ftrace_events) = .; \
127 *(_ftrace_events) \ 129 *(_ftrace_events) \
128 VMLINUX_SYMBOL(__stop_ftrace_events) = .; 130 VMLINUX_SYMBOL(__stop_ftrace_events) = .;
129#else 131#else
@@ -139,41 +141,46 @@
139#endif 141#endif
140 142
141#ifdef CONFIG_FTRACE_SYSCALLS 143#ifdef CONFIG_FTRACE_SYSCALLS
142#define TRACE_SYSCALLS() VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \ 144#define TRACE_SYSCALLS() . = ALIGN(8); \
145 VMLINUX_SYMBOL(__start_syscalls_metadata) = .; \
143 *(__syscalls_metadata) \ 146 *(__syscalls_metadata) \
144 VMLINUX_SYMBOL(__stop_syscalls_metadata) = .; 147 VMLINUX_SYMBOL(__stop_syscalls_metadata) = .;
145#else 148#else
146#define TRACE_SYSCALLS() 149#define TRACE_SYSCALLS()
147#endif 150#endif
148 151
152
153#define KERNEL_DTB() \
154 STRUCT_ALIGN(); \
155 VMLINUX_SYMBOL(__dtb_start) = .; \
156 *(.dtb.init.rodata) \
157 VMLINUX_SYMBOL(__dtb_end) = .;
158
149/* .data section */ 159/* .data section */
150#define DATA_DATA \ 160#define DATA_DATA \
151 *(.data) \ 161 *(.data) \
152 *(.ref.data) \ 162 *(.ref.data) \
163 *(.data..shared_aligned) /* percpu related */ \
153 DEV_KEEP(init.data) \ 164 DEV_KEEP(init.data) \
154 DEV_KEEP(exit.data) \ 165 DEV_KEEP(exit.data) \
155 CPU_KEEP(init.data) \ 166 CPU_KEEP(init.data) \
156 CPU_KEEP(exit.data) \ 167 CPU_KEEP(exit.data) \
157 MEM_KEEP(init.data) \ 168 MEM_KEEP(init.data) \
158 MEM_KEEP(exit.data) \ 169 MEM_KEEP(exit.data) \
159 . = ALIGN(32); \ 170 STRUCT_ALIGN(); \
160 VMLINUX_SYMBOL(__start___tracepoints) = .; \
161 *(__tracepoints) \ 171 *(__tracepoints) \
162 VMLINUX_SYMBOL(__stop___tracepoints) = .; \
163 /* implement dynamic printk debug */ \ 172 /* implement dynamic printk debug */ \
173 . = ALIGN(8); \
174 VMLINUX_SYMBOL(__start___jump_table) = .; \
175 *(__jump_table) \
176 VMLINUX_SYMBOL(__stop___jump_table) = .; \
164 . = ALIGN(8); \ 177 . = ALIGN(8); \
165 VMLINUX_SYMBOL(__start___verbose) = .; \ 178 VMLINUX_SYMBOL(__start___verbose) = .; \
166 *(__verbose) \ 179 *(__verbose) \
167 VMLINUX_SYMBOL(__stop___verbose) = .; \ 180 VMLINUX_SYMBOL(__stop___verbose) = .; \
168 LIKELY_PROFILE() \ 181 LIKELY_PROFILE() \
169 BRANCH_PROFILE() \ 182 BRANCH_PROFILE() \
170 TRACE_PRINTKS() \ 183 TRACE_PRINTKS()
171 \
172 STRUCT_ALIGN(); \
173 FTRACE_EVENTS() \
174 \
175 STRUCT_ALIGN(); \
176 TRACE_SYSCALLS()
177 184
178/* 185/*
179 * Data section helpers 186 * Data section helpers
@@ -191,7 +198,8 @@
191 198
192#define READ_MOSTLY_DATA(align) \ 199#define READ_MOSTLY_DATA(align) \
193 . = ALIGN(align); \ 200 . = ALIGN(align); \
194 *(.data..read_mostly) 201 *(.data..read_mostly) \
202 . = ALIGN(align);
195 203
196#define CACHELINE_ALIGNED_DATA(align) \ 204#define CACHELINE_ALIGNED_DATA(align) \
197 . = ALIGN(align); \ 205 . = ALIGN(align); \
@@ -210,6 +218,10 @@
210 VMLINUX_SYMBOL(__start_rodata) = .; \ 218 VMLINUX_SYMBOL(__start_rodata) = .; \
211 *(.rodata) *(.rodata.*) \ 219 *(.rodata) *(.rodata.*) \
212 *(__vermagic) /* Kernel version magic */ \ 220 *(__vermagic) /* Kernel version magic */ \
221 . = ALIGN(8); \
222 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
223 *(__tracepoints_ptrs) /* Tracepoints: pointer array */\
224 VMLINUX_SYMBOL(__stop___tracepoints_ptrs) = .; \
213 *(__markers_strings) /* Markers: strings */ \ 225 *(__markers_strings) /* Markers: strings */ \
214 *(__tracepoints_strings)/* Tracepoints: strings */ \ 226 *(__tracepoints_strings)/* Tracepoints: strings */ \
215 } \ 227 } \
@@ -264,70 +276,70 @@
264 /* Kernel symbol table: Normal symbols */ \ 276 /* Kernel symbol table: Normal symbols */ \
265 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \ 277 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
266 VMLINUX_SYMBOL(__start___ksymtab) = .; \ 278 VMLINUX_SYMBOL(__start___ksymtab) = .; \
267 *(__ksymtab) \ 279 *(SORT(___ksymtab+*)) \
268 VMLINUX_SYMBOL(__stop___ksymtab) = .; \ 280 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
269 } \ 281 } \
270 \ 282 \
271 /* Kernel symbol table: GPL-only symbols */ \ 283 /* Kernel symbol table: GPL-only symbols */ \
272 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \ 284 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
273 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \ 285 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
274 *(__ksymtab_gpl) \ 286 *(SORT(___ksymtab_gpl+*)) \
275 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \ 287 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
276 } \ 288 } \
277 \ 289 \
278 /* Kernel symbol table: Normal unused symbols */ \ 290 /* Kernel symbol table: Normal unused symbols */ \
279 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \ 291 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
280 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \ 292 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
281 *(__ksymtab_unused) \ 293 *(SORT(___ksymtab_unused+*)) \
282 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \ 294 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
283 } \ 295 } \
284 \ 296 \
285 /* Kernel symbol table: GPL-only unused symbols */ \ 297 /* Kernel symbol table: GPL-only unused symbols */ \
286 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \ 298 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
287 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \ 299 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
288 *(__ksymtab_unused_gpl) \ 300 *(SORT(___ksymtab_unused_gpl+*)) \
289 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \ 301 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
290 } \ 302 } \
291 \ 303 \
292 /* Kernel symbol table: GPL-future-only symbols */ \ 304 /* Kernel symbol table: GPL-future-only symbols */ \
293 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \ 305 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
294 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \ 306 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
295 *(__ksymtab_gpl_future) \ 307 *(SORT(___ksymtab_gpl_future+*)) \
296 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \ 308 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
297 } \ 309 } \
298 \ 310 \
299 /* Kernel symbol table: Normal symbols */ \ 311 /* Kernel symbol table: Normal symbols */ \
300 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \ 312 __kcrctab : AT(ADDR(__kcrctab) - LOAD_OFFSET) { \
301 VMLINUX_SYMBOL(__start___kcrctab) = .; \ 313 VMLINUX_SYMBOL(__start___kcrctab) = .; \
302 *(__kcrctab) \ 314 *(SORT(___kcrctab+*)) \
303 VMLINUX_SYMBOL(__stop___kcrctab) = .; \ 315 VMLINUX_SYMBOL(__stop___kcrctab) = .; \
304 } \ 316 } \
305 \ 317 \
306 /* Kernel symbol table: GPL-only symbols */ \ 318 /* Kernel symbol table: GPL-only symbols */ \
307 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \ 319 __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - LOAD_OFFSET) { \
308 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \ 320 VMLINUX_SYMBOL(__start___kcrctab_gpl) = .; \
309 *(__kcrctab_gpl) \ 321 *(SORT(___kcrctab_gpl+*)) \
310 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \ 322 VMLINUX_SYMBOL(__stop___kcrctab_gpl) = .; \
311 } \ 323 } \
312 \ 324 \
313 /* Kernel symbol table: Normal unused symbols */ \ 325 /* Kernel symbol table: Normal unused symbols */ \
314 __kcrctab_unused : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) { \ 326 __kcrctab_unused : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) { \
315 VMLINUX_SYMBOL(__start___kcrctab_unused) = .; \ 327 VMLINUX_SYMBOL(__start___kcrctab_unused) = .; \
316 *(__kcrctab_unused) \ 328 *(SORT(___kcrctab_unused+*)) \
317 VMLINUX_SYMBOL(__stop___kcrctab_unused) = .; \ 329 VMLINUX_SYMBOL(__stop___kcrctab_unused) = .; \
318 } \ 330 } \
319 \ 331 \
320 /* Kernel symbol table: GPL-only unused symbols */ \ 332 /* Kernel symbol table: GPL-only unused symbols */ \
321 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \ 333 __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
322 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \ 334 VMLINUX_SYMBOL(__start___kcrctab_unused_gpl) = .; \
323 *(__kcrctab_unused_gpl) \ 335 *(SORT(___kcrctab_unused_gpl+*)) \
324 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \ 336 VMLINUX_SYMBOL(__stop___kcrctab_unused_gpl) = .; \
325 } \ 337 } \
326 \ 338 \
327 /* Kernel symbol table: GPL-future-only symbols */ \ 339 /* Kernel symbol table: GPL-future-only symbols */ \
328 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \ 340 __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
329 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \ 341 VMLINUX_SYMBOL(__start___kcrctab_gpl_future) = .; \
330 *(__kcrctab_gpl_future) \ 342 *(SORT(___kcrctab_gpl_future+*)) \
331 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \ 343 VMLINUX_SYMBOL(__stop___kcrctab_gpl_future) = .; \
332 } \ 344 } \
333 \ 345 \
@@ -352,6 +364,13 @@
352 VMLINUX_SYMBOL(__start___param) = .; \ 364 VMLINUX_SYMBOL(__start___param) = .; \
353 *(__param) \ 365 *(__param) \
354 VMLINUX_SYMBOL(__stop___param) = .; \ 366 VMLINUX_SYMBOL(__stop___param) = .; \
367 } \
368 \
369 /* Built-in module versions. */ \
370 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
371 VMLINUX_SYMBOL(__start___modver) = .; \
372 *(__modver) \
373 VMLINUX_SYMBOL(__stop___modver) = .; \
355 . = ALIGN((align)); \ 374 . = ALIGN((align)); \
356 VMLINUX_SYMBOL(__end_rodata) = .; \ 375 VMLINUX_SYMBOL(__end_rodata) = .; \
357 } \ 376 } \
@@ -407,6 +426,12 @@
407 *(.kprobes.text) \ 426 *(.kprobes.text) \
408 VMLINUX_SYMBOL(__kprobes_text_end) = .; 427 VMLINUX_SYMBOL(__kprobes_text_end) = .;
409 428
429#define ENTRY_TEXT \
430 ALIGN_FUNCTION(); \
431 VMLINUX_SYMBOL(__entry_text_start) = .; \
432 *(.entry.text) \
433 VMLINUX_SYMBOL(__entry_text_end) = .;
434
410#ifdef CONFIG_FUNCTION_GRAPH_TRACER 435#ifdef CONFIG_FUNCTION_GRAPH_TRACER
411#define IRQENTRY_TEXT \ 436#define IRQENTRY_TEXT \
412 ALIGN_FUNCTION(); \ 437 ALIGN_FUNCTION(); \
@@ -463,9 +488,12 @@
463 KERNEL_CTORS() \ 488 KERNEL_CTORS() \
464 *(.init.rodata) \ 489 *(.init.rodata) \
465 MCOUNT_REC() \ 490 MCOUNT_REC() \
491 FTRACE_EVENTS() \
492 TRACE_SYSCALLS() \
466 DEV_DISCARD(init.rodata) \ 493 DEV_DISCARD(init.rodata) \
467 CPU_DISCARD(init.rodata) \ 494 CPU_DISCARD(init.rodata) \
468 MEM_DISCARD(init.rodata) 495 MEM_DISCARD(init.rodata) \
496 KERNEL_DTB()
469 497
470#define INIT_TEXT \ 498#define INIT_TEXT \
471 *(.init.text) \ 499 *(.init.text) \
@@ -626,10 +654,11 @@
626 654
627#ifdef CONFIG_BLK_DEV_INITRD 655#ifdef CONFIG_BLK_DEV_INITRD
628#define INIT_RAM_FS \ 656#define INIT_RAM_FS \
629 . = ALIGN(PAGE_SIZE); \ 657 . = ALIGN(4); \
630 VMLINUX_SYMBOL(__initramfs_start) = .; \ 658 VMLINUX_SYMBOL(__initramfs_start) = .; \
631 *(.init.ramfs) \ 659 *(.init.ramfs) \
632 VMLINUX_SYMBOL(__initramfs_end) = .; 660 . = ALIGN(8); \
661 *(.init.ramfs.info)
633#else 662#else
634#define INIT_RAM_FS 663#define INIT_RAM_FS
635#endif 664#endif
@@ -653,14 +682,41 @@
653 } 682 }
654 683
655/** 684/**
685 * PERCPU_INPUT - the percpu input sections
686 * @cacheline: cacheline size
687 *
688 * The core percpu section names and core symbols which do not rely
689 * directly upon load addresses.
690 *
691 * @cacheline is used to align subsections to avoid false cacheline
692 * sharing between subsections for different purposes.
693 */
694#define PERCPU_INPUT(cacheline) \
695 VMLINUX_SYMBOL(__per_cpu_start) = .; \
696 *(.data..percpu..first) \
697 . = ALIGN(PAGE_SIZE); \
698 *(.data..percpu..page_aligned) \
699 . = ALIGN(cacheline); \
700 *(.data..percpu..readmostly) \
701 . = ALIGN(cacheline); \
702 *(.data..percpu) \
703 *(.data..percpu..shared_aligned) \
704 VMLINUX_SYMBOL(__per_cpu_end) = .;
705
706/**
656 * PERCPU_VADDR - define output section for percpu area 707 * PERCPU_VADDR - define output section for percpu area
708 * @cacheline: cacheline size
657 * @vaddr: explicit base address (optional) 709 * @vaddr: explicit base address (optional)
658 * @phdr: destination PHDR (optional) 710 * @phdr: destination PHDR (optional)
659 * 711 *
660 * Macro which expands to output section for percpu area. If @vaddr 712 * Macro which expands to output section for percpu area.
661 * is not blank, it specifies explicit base address and all percpu 713 *
662 * symbols will be offset from the given address. If blank, @vaddr 714 * @cacheline is used to align subsections to avoid false cacheline
663 * always equals @laddr + LOAD_OFFSET. 715 * sharing between subsections for different purposes.
716 *
717 * If @vaddr is not blank, it specifies explicit base address and all
718 * percpu symbols will be offset from the given address. If blank,
719 * @vaddr always equals @laddr + LOAD_OFFSET.
664 * 720 *
665 * @phdr defines the output PHDR to use if not blank. Be warned that 721 * @phdr defines the output PHDR to use if not blank. Be warned that
666 * output PHDR is sticky. If @phdr is specified, the next output 722 * output PHDR is sticky. If @phdr is specified, the next output
@@ -669,44 +725,33 @@
669 * 725 *
670 * Note that this macros defines __per_cpu_load as an absolute symbol. 726 * Note that this macros defines __per_cpu_load as an absolute symbol.
671 * If there is no need to put the percpu section at a predetermined 727 * If there is no need to put the percpu section at a predetermined
672 * address, use PERCPU(). 728 * address, use PERCPU_SECTION.
673 */ 729 */
674#define PERCPU_VADDR(vaddr, phdr) \ 730#define PERCPU_VADDR(cacheline, vaddr, phdr) \
675 VMLINUX_SYMBOL(__per_cpu_load) = .; \ 731 VMLINUX_SYMBOL(__per_cpu_load) = .; \
676 .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \ 732 .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
677 - LOAD_OFFSET) { \ 733 - LOAD_OFFSET) { \
678 VMLINUX_SYMBOL(__per_cpu_start) = .; \ 734 PERCPU_INPUT(cacheline) \
679 *(.data..percpu..first) \
680 *(.data..percpu..page_aligned) \
681 *(.data..percpu) \
682 *(.data..percpu..shared_aligned) \
683 VMLINUX_SYMBOL(__per_cpu_end) = .; \
684 } phdr \ 735 } phdr \
685 . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu); 736 . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
686 737
687/** 738/**
688 * PERCPU - define output section for percpu area, simple version 739 * PERCPU_SECTION - define output section for percpu area, simple version
689 * @align: required alignment 740 * @cacheline: cacheline size
690 * 741 *
691 * Align to @align and outputs output section for percpu area. This 742 * Align to PAGE_SIZE and outputs output section for percpu area. This
692 * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and 743 * macro doesn't manipulate @vaddr or @phdr and __per_cpu_load and
693 * __per_cpu_start will be identical. 744 * __per_cpu_start will be identical.
694 * 745 *
695 * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except 746 * This macro is equivalent to ALIGN(PAGE_SIZE); PERCPU_VADDR(@cacheline,,)
696 * that __per_cpu_load is defined as a relative symbol against 747 * except that __per_cpu_load is defined as a relative symbol against
697 * .data..percpu which is required for relocatable x86_32 748 * .data..percpu which is required for relocatable x86_32 configuration.
698 * configuration.
699 */ 749 */
700#define PERCPU(align) \ 750#define PERCPU_SECTION(cacheline) \
701 . = ALIGN(align); \ 751 . = ALIGN(PAGE_SIZE); \
702 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \ 752 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
703 VMLINUX_SYMBOL(__per_cpu_load) = .; \ 753 VMLINUX_SYMBOL(__per_cpu_load) = .; \
704 VMLINUX_SYMBOL(__per_cpu_start) = .; \ 754 PERCPU_INPUT(cacheline) \
705 *(.data..percpu..first) \
706 *(.data..percpu..page_aligned) \
707 *(.data..percpu) \
708 *(.data..percpu..shared_aligned) \
709 VMLINUX_SYMBOL(__per_cpu_end) = .; \
710 } 755 }
711 756
712 757
@@ -725,7 +770,7 @@
725 * the sections that has this restriction (or similar) 770 * the sections that has this restriction (or similar)
726 * is located before the ones requiring PAGE_SIZE alignment. 771 * is located before the ones requiring PAGE_SIZE alignment.
727 * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which 772 * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
728 * matches the requirment of PAGE_ALIGNED_DATA. 773 * matches the requirement of PAGE_ALIGNED_DATA.
729 * 774 *
730 * use 0 as page_align if page_aligned data is not used */ 775 * use 0 as page_align if page_aligned data is not used */
731#define RW_DATA_SECTION(cacheline, pagealigned, inittask) \ 776#define RW_DATA_SECTION(cacheline, pagealigned, inittask) \
diff --git a/include/asm-generic/xor.h b/include/asm-generic/xor.h
index aaab875e1a35..6028fb862254 100644
--- a/include/asm-generic/xor.h
+++ b/include/asm-generic/xor.h
@@ -13,7 +13,7 @@
13 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 13 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 */ 14 */
15 15
16#include <asm/processor.h> 16#include <linux/prefetch.h>
17 17
18static void 18static void
19xor_8regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) 19xor_8regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
diff --git a/include/crypto/cryptd.h b/include/crypto/cryptd.h
index 1c96b255017c..ba98918bbd9b 100644
--- a/include/crypto/cryptd.h
+++ b/include/crypto/cryptd.h
@@ -1,5 +1,12 @@
1/* 1/*
2 * Software async crypto daemon 2 * Software async crypto daemon
3 *
4 * Added AEAD support to cryptd.
5 * Authors: Tadeusz Struk (tadeusz.struk@intel.com)
6 * Adrian Hoban <adrian.hoban@intel.com>
7 * Gabriele Paoloni <gabriele.paoloni@intel.com>
8 * Aidan O'Mahony (aidan.o.mahony@intel.com)
9 * Copyright (c) 2010, Intel Corporation.
3 */ 10 */
4 11
5#ifndef _CRYPTO_CRYPT_H 12#ifndef _CRYPTO_CRYPT_H
@@ -42,4 +49,21 @@ struct crypto_shash *cryptd_ahash_child(struct cryptd_ahash *tfm);
42struct shash_desc *cryptd_shash_desc(struct ahash_request *req); 49struct shash_desc *cryptd_shash_desc(struct ahash_request *req);
43void cryptd_free_ahash(struct cryptd_ahash *tfm); 50void cryptd_free_ahash(struct cryptd_ahash *tfm);
44 51
52struct cryptd_aead {
53 struct crypto_aead base;
54};
55
56static inline struct cryptd_aead *__cryptd_aead_cast(
57 struct crypto_aead *tfm)
58{
59 return (struct cryptd_aead *)tfm;
60}
61
62struct cryptd_aead *cryptd_alloc_aead(const char *alg_name,
63 u32 type, u32 mask);
64
65struct crypto_aead *cryptd_aead_child(struct cryptd_aead *tfm);
66
67void cryptd_free_aead(struct cryptd_aead *tfm);
68
45#endif 69#endif
diff --git a/include/crypto/gf128mul.h b/include/crypto/gf128mul.h
index 4086b8ebfafe..da2530e34b26 100644
--- a/include/crypto/gf128mul.h
+++ b/include/crypto/gf128mul.h
@@ -54,8 +54,8 @@
54 54
55/* Comment by Rik: 55/* Comment by Rik:
56 * 56 *
57 * For some background on GF(2^128) see for example: http://- 57 * For some background on GF(2^128) see for example:
58 * csrc.nist.gov/CryptoToolkit/modes/proposedmodes/gcm/gcm-revised-spec.pdf 58 * http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf
59 * 59 *
60 * The elements of GF(2^128) := GF(2)[X]/(X^128-X^7-X^2-X^1-1) can 60 * The elements of GF(2^128) := GF(2)[X]/(X^128-X^7-X^2-X^1-1) can
61 * be mapped to computer memory in a variety of ways. Let's examine 61 * be mapped to computer memory in a variety of ways. Let's examine
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
new file mode 100644
index 000000000000..c5813c87de06
--- /dev/null
+++ b/include/crypto/if_alg.h
@@ -0,0 +1,92 @@
1/*
2 * if_alg: User-space algorithm interface
3 *
4 * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _CRYPTO_IF_ALG_H
14#define _CRYPTO_IF_ALG_H
15
16#include <linux/compiler.h>
17#include <linux/completion.h>
18#include <linux/if_alg.h>
19#include <linux/types.h>
20#include <net/sock.h>
21
22#define ALG_MAX_PAGES 16
23
24struct crypto_async_request;
25
26struct alg_sock {
27 /* struct sock must be the first member of struct alg_sock */
28 struct sock sk;
29
30 struct sock *parent;
31
32 const struct af_alg_type *type;
33 void *private;
34};
35
36struct af_alg_completion {
37 struct completion completion;
38 int err;
39};
40
41struct af_alg_control {
42 struct af_alg_iv *iv;
43 int op;
44};
45
46struct af_alg_type {
47 void *(*bind)(const char *name, u32 type, u32 mask);
48 void (*release)(void *private);
49 int (*setkey)(void *private, const u8 *key, unsigned int keylen);
50 int (*accept)(void *private, struct sock *sk);
51
52 struct proto_ops *ops;
53 struct module *owner;
54 char name[14];
55};
56
57struct af_alg_sgl {
58 struct scatterlist sg[ALG_MAX_PAGES];
59 struct page *pages[ALG_MAX_PAGES];
60};
61
62int af_alg_register_type(const struct af_alg_type *type);
63int af_alg_unregister_type(const struct af_alg_type *type);
64
65int af_alg_release(struct socket *sock);
66int af_alg_accept(struct sock *sk, struct socket *newsock);
67
68int af_alg_make_sg(struct af_alg_sgl *sgl, void __user *addr, int len,
69 int write);
70void af_alg_free_sg(struct af_alg_sgl *sgl);
71
72int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con);
73
74int af_alg_wait_for_completion(int err, struct af_alg_completion *completion);
75void af_alg_complete(struct crypto_async_request *req, int err);
76
77static inline struct alg_sock *alg_sk(struct sock *sk)
78{
79 return (struct alg_sock *)sk;
80}
81
82static inline void af_alg_release_parent(struct sock *sk)
83{
84 sock_put(alg_sk(sk)->parent);
85}
86
87static inline void af_alg_init_completion(struct af_alg_completion *completion)
88{
89 init_completion(&completion->completion);
90}
91
92#endif /* _CRYPTO_IF_ALG_H */
diff --git a/include/crypto/padlock.h b/include/crypto/padlock.h
new file mode 100644
index 000000000000..d2cfa2ef49e8
--- /dev/null
+++ b/include/crypto/padlock.h
@@ -0,0 +1,29 @@
1/*
2 * Driver for VIA PadLock
3 *
4 * Copyright (c) 2004 Michal Ludvig <michal@logix.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _CRYPTO_PADLOCK_H
14#define _CRYPTO_PADLOCK_H
15
16#define PADLOCK_ALIGNMENT 16
17
18#define PFX KBUILD_MODNAME ": "
19
20#define PADLOCK_CRA_PRIORITY 300
21#define PADLOCK_COMPOSITE_PRIORITY 400
22
23#ifdef CONFIG_64BIT
24#define STACK_ALIGN 16
25#else
26#define STACK_ALIGN 4
27#endif
28
29#endif /* _CRYPTO_PADLOCK_H */
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 833d208c25d6..4fd95a323beb 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -68,6 +68,21 @@ static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
68 return (++sg)->length ? sg : (void *)sg_page(sg); 68 return (++sg)->length ? sg : (void *)sg_page(sg);
69} 69}
70 70
71static inline void scatterwalk_crypto_chain(struct scatterlist *head,
72 struct scatterlist *sg,
73 int chain, int num)
74{
75 if (chain) {
76 head->length += sg->length;
77 sg = scatterwalk_sg_next(sg);
78 }
79
80 if (sg)
81 scatterwalk_sg_chain(head, num, sg);
82 else
83 sg_mark_end(head);
84}
85
71static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, 86static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in,
72 struct scatter_walk *walk_out) 87 struct scatter_walk *walk_out)
73{ 88{
diff --git a/include/drm/Kbuild b/include/drm/Kbuild
index ffec177f3481..3a60ac889520 100644
--- a/include/drm/Kbuild
+++ b/include/drm/Kbuild
@@ -2,7 +2,6 @@ header-y += drm.h
2header-y += drm_mode.h 2header-y += drm_mode.h
3header-y += drm_sarea.h 3header-y += drm_sarea.h
4header-y += i810_drm.h 4header-y += i810_drm.h
5header-y += i830_drm.h
6header-y += i915_drm.h 5header-y += i915_drm.h
7header-y += mga_drm.h 6header-y += mga_drm.h
8header-y += nouveau_drm.h 7header-y += nouveau_drm.h
diff --git a/include/drm/drm.h b/include/drm/drm.h
index e5f70617dec5..4be33b4ca2f8 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -463,12 +463,15 @@ struct drm_irq_busid {
463enum drm_vblank_seq_type { 463enum drm_vblank_seq_type {
464 _DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */ 464 _DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */
465 _DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */ 465 _DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */
466 /* bits 1-6 are reserved for high crtcs */
467 _DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
466 _DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */ 468 _DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */
467 _DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */ 469 _DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */
468 _DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */ 470 _DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */
469 _DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */ 471 _DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */
470 _DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking, unsupported */ 472 _DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking, unsupported */
471}; 473};
474#define _DRM_VBLANK_HIGH_CRTC_SHIFT 1
472 475
473#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE) 476#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
474#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \ 477#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \
@@ -608,6 +611,12 @@ struct drm_gem_open {
608 __u64 size; 611 __u64 size;
609}; 612};
610 613
614/** DRM_IOCTL_GET_CAP ioctl argument type */
615struct drm_get_cap {
616 __u64 capability;
617 __u64 value;
618};
619
611#include "drm_mode.h" 620#include "drm_mode.h"
612 621
613#define DRM_IOCTL_BASE 'd' 622#define DRM_IOCTL_BASE 'd'
@@ -628,6 +637,7 @@ struct drm_gem_open {
628#define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close) 637#define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close)
629#define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink) 638#define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink)
630#define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open) 639#define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open)
640#define DRM_IOCTL_GET_CAP DRM_IOWR(0x0c, struct drm_get_cap)
631 641
632#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique) 642#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique)
633#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth) 643#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth)
@@ -701,6 +711,10 @@ struct drm_gem_open {
701#define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip) 711#define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)
702#define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd) 712#define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)
703 713
714#define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)
715#define DRM_IOCTL_MODE_MAP_DUMB DRM_IOWR(0xB3, struct drm_mode_map_dumb)
716#define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
717
704/** 718/**
705 * Device specific ioctls should only be in their respective headers 719 * Device specific ioctls should only be in their respective headers
706 * The device specific ioctl range is from 0x40 to 0x99. 720 * The device specific ioctl range is from 0x40 to 0x99.
@@ -741,6 +755,9 @@ struct drm_event_vblank {
741 __u32 reserved; 755 __u32 reserved;
742}; 756};
743 757
758#define DRM_CAP_DUMB_BUFFER 0x1
759#define DRM_CAP_VBLANK_HIGH_CRTC 0x2
760
744/* typedef area */ 761/* typedef area */
745#ifndef __KERNEL__ 762#ifndef __KERNEL__
746typedef struct drm_clip_rect drm_clip_rect_t; 763typedef struct drm_clip_rect drm_clip_rect_t;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 4c9461a4f9e6..738b3a5faa12 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -95,7 +95,7 @@ struct drm_device;
95 * drm_core, drm_driver, drm_kms 95 * drm_core, drm_driver, drm_kms
96 * drm_core level can be used in the generic drm code. For example: 96 * drm_core level can be used in the generic drm code. For example:
97 * drm_ioctl, drm_mm, drm_memory 97 * drm_ioctl, drm_mm, drm_memory
98 * The macro definiton of DRM_DEBUG is used. 98 * The macro definition of DRM_DEBUG is used.
99 * DRM_DEBUG(fmt, args...) 99 * DRM_DEBUG(fmt, args...)
100 * The debug info by using the DRM_DEBUG can be obtained by adding 100 * The debug info by using the DRM_DEBUG can be obtained by adding
101 * the boot option of "drm.debug=1". 101 * the boot option of "drm.debug=1".
@@ -122,10 +122,14 @@ struct drm_device;
122 * using the DRM_DEBUG_KMS and DRM_DEBUG. 122 * using the DRM_DEBUG_KMS and DRM_DEBUG.
123 */ 123 */
124 124
125extern void drm_ut_debug_printk(unsigned int request_level, 125extern __attribute__((format (printf, 4, 5)))
126void drm_ut_debug_printk(unsigned int request_level,
126 const char *prefix, 127 const char *prefix,
127 const char *function_name, 128 const char *function_name,
128 const char *format, ...); 129 const char *format, ...);
130extern __attribute__((format (printf, 2, 3)))
131int drm_err(const char *func, const char *format, ...);
132
129/***********************************************************************/ 133/***********************************************************************/
130/** \name DRM template customization defaults */ 134/** \name DRM template customization defaults */
131/*@{*/ 135/*@{*/
@@ -145,7 +149,10 @@ extern void drm_ut_debug_printk(unsigned int request_level,
145#define DRIVER_IRQ_VBL2 0x800 149#define DRIVER_IRQ_VBL2 0x800
146#define DRIVER_GEM 0x1000 150#define DRIVER_GEM 0x1000
147#define DRIVER_MODESET 0x2000 151#define DRIVER_MODESET 0x2000
148#define DRIVER_USE_PLATFORM_DEVICE 0x4000 152
153#define DRIVER_BUS_PCI 0x1
154#define DRIVER_BUS_PLATFORM 0x2
155#define DRIVER_BUS_USB 0x3
149 156
150/***********************************************************************/ 157/***********************************************************************/
151/** \name Begin the DRM... */ 158/** \name Begin the DRM... */
@@ -178,21 +185,11 @@ extern void drm_ut_debug_printk(unsigned int request_level,
178 * \param fmt printf() like format string. 185 * \param fmt printf() like format string.
179 * \param arg arguments 186 * \param arg arguments
180 */ 187 */
181#define DRM_ERROR(fmt, arg...) \ 188#define DRM_ERROR(fmt, ...) \
182 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) 189 drm_err(__func__, fmt, ##__VA_ARGS__)
183 190
184/** 191#define DRM_INFO(fmt, ...) \
185 * Memory error output. 192 printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
186 *
187 * \param area memory area where the error occurred.
188 * \param fmt printf() like format string.
189 * \param arg arguments
190 */
191#define DRM_MEM_ERROR(area, fmt, arg...) \
192 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __func__, \
193 drm_mem_stats[area].name , ##arg)
194
195#define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
196 193
197/** 194/**
198 * Debug output. 195 * Debug output.
@@ -683,6 +680,34 @@ struct drm_master {
683 void *driver_priv; /**< Private structure for driver to use */ 680 void *driver_priv; /**< Private structure for driver to use */
684}; 681};
685 682
683/* Size of ringbuffer for vblank timestamps. Just double-buffer
684 * in initial implementation.
685 */
686#define DRM_VBLANKTIME_RBSIZE 2
687
688/* Flags and return codes for get_vblank_timestamp() driver function. */
689#define DRM_CALLED_FROM_VBLIRQ 1
690#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
691#define DRM_VBLANKTIME_INVBL (1 << 1)
692
693/* get_scanout_position() return flags */
694#define DRM_SCANOUTPOS_VALID (1 << 0)
695#define DRM_SCANOUTPOS_INVBL (1 << 1)
696#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
697
698struct drm_bus {
699 int bus_type;
700 int (*get_irq)(struct drm_device *dev);
701 const char *(*get_name)(struct drm_device *dev);
702 int (*set_busid)(struct drm_device *dev, struct drm_master *master);
703 int (*set_unique)(struct drm_device *dev, struct drm_master *master,
704 struct drm_unique *unique);
705 int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
706 /* hooks that are for PCI */
707 int (*agp_init)(struct drm_device *dev);
708
709};
710
686/** 711/**
687 * DRM driver structure. This structure represent the common code for 712 * DRM driver structure. This structure represent the common code for
688 * a family of cards. There will one drm_device for each card present 713 * a family of cards. There will one drm_device for each card present
@@ -699,13 +724,8 @@ struct drm_driver {
699 int (*suspend) (struct drm_device *, pm_message_t state); 724 int (*suspend) (struct drm_device *, pm_message_t state);
700 int (*resume) (struct drm_device *); 725 int (*resume) (struct drm_device *);
701 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); 726 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
702 void (*dma_ready) (struct drm_device *);
703 int (*dma_quiescent) (struct drm_device *); 727 int (*dma_quiescent) (struct drm_device *);
704 int (*context_ctor) (struct drm_device *dev, int context);
705 int (*context_dtor) (struct drm_device *dev, int context); 728 int (*context_dtor) (struct drm_device *dev, int context);
706 int (*kernel_context_switch) (struct drm_device *dev, int old,
707 int new);
708 void (*kernel_context_switch_unlock) (struct drm_device *dev);
709 729
710 /** 730 /**
711 * get_vblank_counter - get raw hardware vblank counter 731 * get_vblank_counter - get raw hardware vblank counter
@@ -765,6 +785,68 @@ struct drm_driver {
765 */ 785 */
766 int (*device_is_agp) (struct drm_device *dev); 786 int (*device_is_agp) (struct drm_device *dev);
767 787
788 /**
789 * Called by vblank timestamping code.
790 *
791 * Return the current display scanout position from a crtc.
792 *
793 * \param dev DRM device.
794 * \param crtc Id of the crtc to query.
795 * \param *vpos Target location for current vertical scanout position.
796 * \param *hpos Target location for current horizontal scanout position.
797 *
798 * Returns vpos as a positive number while in active scanout area.
799 * Returns vpos as a negative number inside vblank, counting the number
800 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
801 * until start of active scanout / end of vblank."
802 *
803 * \return Flags, or'ed together as follows:
804 *
805 * DRM_SCANOUTPOS_VALID = Query successful.
806 * DRM_SCANOUTPOS_INVBL = Inside vblank.
807 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
808 * this flag means that returned position may be offset by a constant
809 * but unknown small number of scanlines wrt. real scanout position.
810 *
811 */
812 int (*get_scanout_position) (struct drm_device *dev, int crtc,
813 int *vpos, int *hpos);
814
815 /**
816 * Called by \c drm_get_last_vbltimestamp. Should return a precise
817 * timestamp when the most recent VBLANK interval ended or will end.
818 *
819 * Specifically, the timestamp in @vblank_time should correspond as
820 * closely as possible to the time when the first video scanline of
821 * the video frame after the end of VBLANK will start scanning out,
822 * the time immmediately after end of the VBLANK interval. If the
823 * @crtc is currently inside VBLANK, this will be a time in the future.
824 * If the @crtc is currently scanning out a frame, this will be the
825 * past start time of the current scanout. This is meant to adhere
826 * to the OpenML OML_sync_control extension specification.
827 *
828 * \param dev dev DRM device handle.
829 * \param crtc crtc for which timestamp should be returned.
830 * \param *max_error Maximum allowable timestamp error in nanoseconds.
831 * Implementation should strive to provide timestamp
832 * with an error of at most *max_error nanoseconds.
833 * Returns true upper bound on error for timestamp.
834 * \param *vblank_time Target location for returned vblank timestamp.
835 * \param flags 0 = Defaults, no special treatment needed.
836 * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
837 * irq handler. Some drivers need to apply some workarounds
838 * for gpu-specific vblank irq quirks if flag is set.
839 *
840 * \returns
841 * Zero if timestamping isn't supported in current display mode or a
842 * negative number on failure. A positive status code on success,
843 * which describes how the vblank_time timestamp was computed.
844 */
845 int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
846 int *max_error,
847 struct timeval *vblank_time,
848 unsigned flags);
849
768 /* these have to be filled in */ 850 /* these have to be filled in */
769 851
770 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS); 852 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
@@ -777,8 +859,6 @@ struct drm_driver {
777 struct drm_file *file_priv); 859 struct drm_file *file_priv);
778 void (*reclaim_buffers_idlelocked) (struct drm_device *dev, 860 void (*reclaim_buffers_idlelocked) (struct drm_device *dev,
779 struct drm_file *file_priv); 861 struct drm_file *file_priv);
780 resource_size_t (*get_map_ofs) (struct drm_local_map * map);
781 resource_size_t (*get_reg_ofs) (struct drm_device *dev);
782 void (*set_version) (struct drm_device *dev, 862 void (*set_version) (struct drm_device *dev,
783 struct drm_set_version *sv); 863 struct drm_set_version *sv);
784 864
@@ -795,8 +875,6 @@ struct drm_driver {
795 void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv, 875 void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
796 bool from_release); 876 bool from_release);
797 877
798 int (*proc_init)(struct drm_minor *minor);
799 void (*proc_cleanup)(struct drm_minor *minor);
800 int (*debugfs_init)(struct drm_minor *minor); 878 int (*debugfs_init)(struct drm_minor *minor);
801 void (*debugfs_cleanup)(struct drm_minor *minor); 879 void (*debugfs_cleanup)(struct drm_minor *minor);
802 880
@@ -812,6 +890,17 @@ struct drm_driver {
812 /* vga arb irq handler */ 890 /* vga arb irq handler */
813 void (*vgaarb_irq)(struct drm_device *dev, bool state); 891 void (*vgaarb_irq)(struct drm_device *dev, bool state);
814 892
893 /* dumb alloc support */
894 int (*dumb_create)(struct drm_file *file_priv,
895 struct drm_device *dev,
896 struct drm_mode_create_dumb *args);
897 int (*dumb_map_offset)(struct drm_file *file_priv,
898 struct drm_device *dev, uint32_t handle,
899 uint64_t *offset);
900 int (*dumb_destroy)(struct drm_file *file_priv,
901 struct drm_device *dev,
902 uint32_t handle);
903
815 /* Driver private ops for this object */ 904 /* Driver private ops for this object */
816 struct vm_operations_struct *gem_vm_ops; 905 struct vm_operations_struct *gem_vm_ops;
817 906
@@ -827,8 +916,13 @@ struct drm_driver {
827 struct drm_ioctl_desc *ioctls; 916 struct drm_ioctl_desc *ioctls;
828 int num_ioctls; 917 int num_ioctls;
829 struct file_operations fops; 918 struct file_operations fops;
830 struct pci_driver pci_driver; 919 union {
831 struct platform_device *platform_device; 920 struct pci_driver *pci;
921 struct platform_device *platform_device;
922 struct usb_driver *usb;
923 } kdriver;
924 struct drm_bus *bus;
925
832 /* List of devices hanging off this driver */ 926 /* List of devices hanging off this driver */
833 struct list_head device_list; 927 struct list_head device_list;
834}; 928};
@@ -900,6 +994,22 @@ struct drm_minor {
900 struct drm_mode_group mode_group; 994 struct drm_mode_group mode_group;
901}; 995};
902 996
997/* mode specified on the command line */
998struct drm_cmdline_mode {
999 bool specified;
1000 bool refresh_specified;
1001 bool bpp_specified;
1002 int xres, yres;
1003 int bpp;
1004 int refresh;
1005 bool rb;
1006 bool interlace;
1007 bool cvt;
1008 bool margins;
1009 enum drm_connector_force force;
1010};
1011
1012
903struct drm_pending_vblank_event { 1013struct drm_pending_vblank_event {
904 struct drm_pending_event base; 1014 struct drm_pending_event base;
905 int pipe; 1015 int pipe;
@@ -972,7 +1082,6 @@ struct drm_device {
972 __volatile__ long context_flag; /**< Context swapping flag */ 1082 __volatile__ long context_flag; /**< Context swapping flag */
973 __volatile__ long interrupt_flag; /**< Interruption handler flag */ 1083 __volatile__ long interrupt_flag; /**< Interruption handler flag */
974 __volatile__ long dma_flag; /**< DMA dispatch flag */ 1084 __volatile__ long dma_flag; /**< DMA dispatch flag */
975 struct timer_list timer; /**< Timer for delaying ctx switch */
976 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ 1085 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
977 int last_checked; /**< Last context checked for DMA */ 1086 int last_checked; /**< Last context checked for DMA */
978 int last_context; /**< Last current context */ 1087 int last_context; /**< Last current context */
@@ -993,6 +1102,8 @@ struct drm_device {
993 1102
994 wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */ 1103 wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */
995 atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */ 1104 atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */
1105 struct timeval *_vblank_time; /**< timestamp of current vblank_count (drivers must alloc right number of fields) */
1106 spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
996 spinlock_t vbl_lock; 1107 spinlock_t vbl_lock;
997 atomic_t *vblank_refcount; /* number of users of vblank interruptsper crtc */ 1108 atomic_t *vblank_refcount; /* number of users of vblank interruptsper crtc */
998 u32 *last_vblank; /* protected by dev->vbl_lock, used */ 1109 u32 *last_vblank; /* protected by dev->vbl_lock, used */
@@ -1030,9 +1141,10 @@ struct drm_device {
1030#endif 1141#endif
1031 1142
1032 struct platform_device *platformdev; /**< Platform device struture */ 1143 struct platform_device *platformdev; /**< Platform device struture */
1144 struct usb_device *usbdev;
1033 1145
1034 struct drm_sg_mem *sg; /**< Scatter gather memory */ 1146 struct drm_sg_mem *sg; /**< Scatter gather memory */
1035 int num_crtcs; /**< Number of CRTCs on this device */ 1147 unsigned int num_crtcs; /**< Number of CRTCs on this device */
1036 void *dev_private; /**< device private data */ 1148 void *dev_private; /**< device private data */
1037 void *mm_private; 1149 void *mm_private;
1038 struct address_space *dev_mapping; 1150 struct address_space *dev_mapping;
@@ -1045,31 +1157,20 @@ struct drm_device {
1045 struct drm_minor *control; /**< Control node for card */ 1157 struct drm_minor *control; /**< Control node for card */
1046 struct drm_minor *primary; /**< render type primary screen head */ 1158 struct drm_minor *primary; /**< render type primary screen head */
1047 1159
1048 /** \name Drawable information */
1049 /*@{ */
1050 spinlock_t drw_lock;
1051 struct idr drw_idr;
1052 /*@} */
1053
1054 struct drm_mode_config mode_config; /**< Current mode config */ 1160 struct drm_mode_config mode_config; /**< Current mode config */
1055 1161
1056 /** \name GEM information */ 1162 /** \name GEM information */
1057 /*@{ */ 1163 /*@{ */
1058 spinlock_t object_name_lock; 1164 spinlock_t object_name_lock;
1059 struct idr object_name_idr; 1165 struct idr object_name_idr;
1060 atomic_t object_count;
1061 atomic_t object_memory;
1062 atomic_t pin_count;
1063 atomic_t pin_memory;
1064 atomic_t gtt_count;
1065 atomic_t gtt_memory;
1066 uint32_t gtt_total;
1067 uint32_t invalidate_domains; /* domains pending invalidation */
1068 uint32_t flush_domains; /* domains pending flush */
1069 /*@} */ 1166 /*@} */
1070 1167 int switch_power_state;
1071}; 1168};
1072 1169
1170#define DRM_SWITCH_POWER_ON 0
1171#define DRM_SWITCH_POWER_OFF 1
1172#define DRM_SWITCH_POWER_CHANGING 2
1173
1073static __inline__ int drm_core_check_feature(struct drm_device *dev, 1174static __inline__ int drm_core_check_feature(struct drm_device *dev,
1074 int feature) 1175 int feature)
1075{ 1176{
@@ -1078,28 +1179,9 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
1078 1179
1079static inline int drm_dev_to_irq(struct drm_device *dev) 1180static inline int drm_dev_to_irq(struct drm_device *dev)
1080{ 1181{
1081 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) 1182 return dev->driver->bus->get_irq(dev);
1082 return platform_get_irq(dev->platformdev, 0);
1083 else
1084 return dev->pdev->irq;
1085} 1183}
1086 1184
1087static inline int drm_get_pci_domain(struct drm_device *dev)
1088{
1089 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1090 return 0;
1091
1092#ifndef __alpha__
1093 /* For historical reasons, drm_get_pci_domain() is busticated
1094 * on most archs and has to remain so for userspace interface
1095 * < 1.4, except on alpha which was right from the beginning
1096 */
1097 if (dev->if_version < 0x10004)
1098 return 0;
1099#endif /* __alpha__ */
1100
1101 return pci_domain_nr(dev->pdev->bus);
1102}
1103 1185
1104#if __OS_HAS_AGP 1186#if __OS_HAS_AGP
1105static inline int drm_core_has_AGP(struct drm_device *dev) 1187static inline int drm_core_has_AGP(struct drm_device *dev)
@@ -1153,8 +1235,6 @@ static inline int drm_mtrr_del(int handle, unsigned long offset,
1153/*@{*/ 1235/*@{*/
1154 1236
1155 /* Driver support (drm_drv.h) */ 1237 /* Driver support (drm_drv.h) */
1156extern int drm_init(struct drm_driver *driver);
1157extern void drm_exit(struct drm_driver *driver);
1158extern long drm_ioctl(struct file *filp, 1238extern long drm_ioctl(struct file *filp,
1159 unsigned int cmd, unsigned long arg); 1239 unsigned int cmd, unsigned long arg);
1160extern long drm_compat_ioctl(struct file *filp, 1240extern long drm_compat_ioctl(struct file *filp,
@@ -1175,8 +1255,6 @@ extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1175extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); 1255extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1176extern void drm_vm_open_locked(struct vm_area_struct *vma); 1256extern void drm_vm_open_locked(struct vm_area_struct *vma);
1177extern void drm_vm_close_locked(struct vm_area_struct *vma); 1257extern void drm_vm_close_locked(struct vm_area_struct *vma);
1178extern resource_size_t drm_core_get_map_ofs(struct drm_local_map * map);
1179extern resource_size_t drm_core_get_reg_ofs(struct drm_device *dev);
1180extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 1258extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1181 1259
1182 /* Memory management support (drm_memory.h) */ 1260 /* Memory management support (drm_memory.h) */
@@ -1186,8 +1264,7 @@ extern int drm_mem_info(char *buf, char **start, off_t offset,
1186 int request, int *eof, void *data); 1264 int request, int *eof, void *data);
1187extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); 1265extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
1188 1266
1189extern DRM_AGP_MEM *drm_alloc_agp(struct drm_device *dev, int pages, u32 type); 1267extern void drm_free_agp(DRM_AGP_MEM * handle, int pages);
1190extern int drm_free_agp(DRM_AGP_MEM * handle, int pages);
1191extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); 1268extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
1192extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, 1269extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
1193 struct page **pages, 1270 struct page **pages,
@@ -1209,6 +1286,8 @@ extern int drm_getclient(struct drm_device *dev, void *data,
1209 struct drm_file *file_priv); 1286 struct drm_file *file_priv);
1210extern int drm_getstats(struct drm_device *dev, void *data, 1287extern int drm_getstats(struct drm_device *dev, void *data,
1211 struct drm_file *file_priv); 1288 struct drm_file *file_priv);
1289extern int drm_getcap(struct drm_device *dev, void *data,
1290 struct drm_file *file_priv);
1212extern int drm_setversion(struct drm_device *dev, void *data, 1291extern int drm_setversion(struct drm_device *dev, void *data,
1213 struct drm_file *file_priv); 1292 struct drm_file *file_priv);
1214extern int drm_noop(struct drm_device *dev, void *data, 1293extern int drm_noop(struct drm_device *dev, void *data,
@@ -1239,17 +1318,6 @@ extern int drm_setsareactx(struct drm_device *dev, void *data,
1239extern int drm_getsareactx(struct drm_device *dev, void *data, 1318extern int drm_getsareactx(struct drm_device *dev, void *data,
1240 struct drm_file *file_priv); 1319 struct drm_file *file_priv);
1241 1320
1242 /* Drawable IOCTL support (drm_drawable.h) */
1243extern int drm_adddraw(struct drm_device *dev, void *data,
1244 struct drm_file *file_priv);
1245extern int drm_rmdraw(struct drm_device *dev, void *data,
1246 struct drm_file *file_priv);
1247extern int drm_update_drawable_info(struct drm_device *dev, void *data,
1248 struct drm_file *file_priv);
1249extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
1250 drm_drawable_t id);
1251extern void drm_drawable_free_all(struct drm_device *dev);
1252
1253 /* Authentication IOCTL support (drm_auth.h) */ 1321 /* Authentication IOCTL support (drm_auth.h) */
1254extern int drm_getmagic(struct drm_device *dev, void *data, 1322extern int drm_getmagic(struct drm_device *dev, void *data,
1255 struct drm_file *file_priv); 1323 struct drm_file *file_priv);
@@ -1264,7 +1332,6 @@ extern int drm_lock(struct drm_device *dev, void *data,
1264 struct drm_file *file_priv); 1332 struct drm_file *file_priv);
1265extern int drm_unlock(struct drm_device *dev, void *data, 1333extern int drm_unlock(struct drm_device *dev, void *data,
1266 struct drm_file *file_priv); 1334 struct drm_file *file_priv);
1267extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
1268extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); 1335extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
1269extern void drm_idlelock_take(struct drm_lock_data *lock_data); 1336extern void drm_idlelock_take(struct drm_lock_data *lock_data);
1270extern void drm_idlelock_release(struct drm_lock_data *lock_data); 1337extern void drm_idlelock_release(struct drm_lock_data *lock_data);
@@ -1322,11 +1389,31 @@ extern int drm_wait_vblank(struct drm_device *dev, void *data,
1322 struct drm_file *filp); 1389 struct drm_file *filp);
1323extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); 1390extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
1324extern u32 drm_vblank_count(struct drm_device *dev, int crtc); 1391extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1325extern void drm_handle_vblank(struct drm_device *dev, int crtc); 1392extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
1393 struct timeval *vblanktime);
1394extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
1326extern int drm_vblank_get(struct drm_device *dev, int crtc); 1395extern int drm_vblank_get(struct drm_device *dev, int crtc);
1327extern void drm_vblank_put(struct drm_device *dev, int crtc); 1396extern void drm_vblank_put(struct drm_device *dev, int crtc);
1328extern void drm_vblank_off(struct drm_device *dev, int crtc); 1397extern void drm_vblank_off(struct drm_device *dev, int crtc);
1329extern void drm_vblank_cleanup(struct drm_device *dev); 1398extern void drm_vblank_cleanup(struct drm_device *dev);
1399extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
1400 struct timeval *tvblank, unsigned flags);
1401extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1402 int crtc, int *max_error,
1403 struct timeval *vblank_time,
1404 unsigned flags,
1405 struct drm_crtc *refcrtc);
1406extern void drm_calc_timestamping_constants(struct drm_crtc *crtc);
1407
1408extern bool
1409drm_mode_parse_command_line_for_connector(const char *mode_option,
1410 struct drm_connector *connector,
1411 struct drm_cmdline_mode *mode);
1412
1413extern struct drm_display_mode *
1414drm_mode_create_from_cmdline_mode(struct drm_device *dev,
1415 struct drm_cmdline_mode *cmd);
1416
1330/* Modesetting support */ 1417/* Modesetting support */
1331extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); 1418extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1332extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); 1419extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
@@ -1359,11 +1446,6 @@ extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
1359extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); 1446extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
1360extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, 1447extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
1361 struct drm_file *file_priv); 1448 struct drm_file *file_priv);
1362extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type);
1363extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
1364extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
1365extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
1366extern void drm_agp_chipset_flush(struct drm_device *dev);
1367 1449
1368 /* Stub support (drm_stub.h) */ 1450 /* Stub support (drm_stub.h) */
1369extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, 1451extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
@@ -1373,15 +1455,14 @@ extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1373struct drm_master *drm_master_create(struct drm_minor *minor); 1455struct drm_master *drm_master_create(struct drm_minor *minor);
1374extern struct drm_master *drm_master_get(struct drm_master *master); 1456extern struct drm_master *drm_master_get(struct drm_master *master);
1375extern void drm_master_put(struct drm_master **master); 1457extern void drm_master_put(struct drm_master **master);
1376extern int drm_get_pci_dev(struct pci_dev *pdev, 1458
1377 const struct pci_device_id *ent,
1378 struct drm_driver *driver);
1379extern int drm_get_platform_dev(struct platform_device *pdev,
1380 struct drm_driver *driver);
1381extern void drm_put_dev(struct drm_device *dev); 1459extern void drm_put_dev(struct drm_device *dev);
1382extern int drm_put_minor(struct drm_minor **minor); 1460extern int drm_put_minor(struct drm_minor **minor);
1383extern unsigned int drm_debug; 1461extern unsigned int drm_debug;
1384 1462
1463extern unsigned int drm_vblank_offdelay;
1464extern unsigned int drm_timestamp_precision;
1465
1385extern struct class *drm_class; 1466extern struct class *drm_class;
1386extern struct proc_dir_entry *drm_proc_root; 1467extern struct proc_dir_entry *drm_proc_root;
1387extern struct dentry *drm_debugfs_root; 1468extern struct dentry *drm_debugfs_root;
@@ -1414,7 +1495,6 @@ extern int drm_bufs_info(struct seq_file *m, void *data);
1414extern int drm_vblank_info(struct seq_file *m, void *data); 1495extern int drm_vblank_info(struct seq_file *m, void *data);
1415extern int drm_clients_info(struct seq_file *m, void* data); 1496extern int drm_clients_info(struct seq_file *m, void* data);
1416extern int drm_gem_name_info(struct seq_file *m, void *data); 1497extern int drm_gem_name_info(struct seq_file *m, void *data);
1417extern int drm_gem_object_info(struct seq_file *m, void* data);
1418 1498
1419#if DRM_DEBUG_CODE 1499#if DRM_DEBUG_CODE
1420extern int drm_vma_info(struct seq_file *m, void *data); 1500extern int drm_vma_info(struct seq_file *m, void *data);
@@ -1493,6 +1573,7 @@ drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1493int drm_gem_handle_create(struct drm_file *file_priv, 1573int drm_gem_handle_create(struct drm_file *file_priv,
1494 struct drm_gem_object *obj, 1574 struct drm_gem_object *obj,
1495 u32 *handlep); 1575 u32 *handlep);
1576int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
1496 1577
1497static inline void 1578static inline void
1498drm_gem_object_handle_reference(struct drm_gem_object *obj) 1579drm_gem_object_handle_reference(struct drm_gem_object *obj)
@@ -1565,11 +1646,21 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1565 return NULL; 1646 return NULL;
1566} 1647}
1567 1648
1568static __inline__ int drm_device_is_agp(struct drm_device *dev) 1649static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1569{ 1650{
1570 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) 1651}
1571 return 0;
1572 1652
1653#include "drm_mem_util.h"
1654
1655extern int drm_fill_in_dev(struct drm_device *dev,
1656 const struct pci_device_id *ent,
1657 struct drm_driver *driver);
1658int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
1659/*@}*/
1660
1661/* PCI section */
1662static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
1663{
1573 if (dev->driver->device_is_agp != NULL) { 1664 if (dev->driver->device_is_agp != NULL) {
1574 int err = (*dev->driver->device_is_agp) (dev); 1665 int err = (*dev->driver->device_is_agp) (dev);
1575 1666
@@ -1581,35 +1672,26 @@ static __inline__ int drm_device_is_agp(struct drm_device *dev)
1581 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); 1672 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
1582} 1673}
1583 1674
1584static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1585{
1586 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1587 return 0;
1588 else
1589 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1590}
1591 1675
1592static __inline__ void drm_core_dropmap(struct drm_local_map *map) 1676static __inline__ int drm_pci_device_is_pcie(struct drm_device *dev)
1593{ 1677{
1678 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1594} 1679}
1595 1680
1596#include "drm_mem_util.h"
1597
1598static inline void *drm_get_device(struct drm_device *dev)
1599{
1600 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1601 return dev->platformdev;
1602 else
1603 return dev->pdev;
1604}
1605 1681
1606extern int drm_platform_init(struct drm_driver *driver); 1682extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
1607extern int drm_pci_init(struct drm_driver *driver); 1683extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
1608extern int drm_fill_in_dev(struct drm_device *dev, 1684extern int drm_get_pci_dev(struct pci_dev *pdev,
1609 const struct pci_device_id *ent, 1685 const struct pci_device_id *ent,
1610 struct drm_driver *driver); 1686 struct drm_driver *driver);
1611int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); 1687
1612/*@}*/ 1688
1689/* platform section */
1690extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
1691extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device);
1692
1693extern int drm_get_platform_dev(struct platform_device *pdev,
1694 struct drm_driver *driver);
1613 1695
1614#endif /* __KERNEL__ */ 1696#endif /* __KERNEL__ */
1615#endif 1697#endif
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 3e5a51af757c..33d12f87f0e0 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -65,7 +65,7 @@ enum drm_mode_status {
65 MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ 65 MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
66 MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ 66 MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
67 MODE_BAD_WIDTH, /* requires an unsupported linepitch */ 67 MODE_BAD_WIDTH, /* requires an unsupported linepitch */
68 MODE_NOMODE, /* no mode with a maching name */ 68 MODE_NOMODE, /* no mode with a matching name */
69 MODE_NO_INTERLACE, /* interlaced mode not supported */ 69 MODE_NO_INTERLACE, /* interlaced mode not supported */
70 MODE_NO_DBLESCAN, /* doublescan mode not supported */ 70 MODE_NO_DBLESCAN, /* doublescan mode not supported */
71 MODE_NO_VSCAN, /* multiscan mode not supported */ 71 MODE_NO_VSCAN, /* multiscan mode not supported */
@@ -183,7 +183,9 @@ enum subpixel_order {
183 SubPixelNone, 183 SubPixelNone,
184}; 184};
185 185
186 186#define DRM_COLOR_FORMAT_RGB444 (1<<0)
187#define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
188#define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
187/* 189/*
188 * Describes a given display (e.g. CRT or flat panel) and its limitations. 190 * Describes a given display (e.g. CRT or flat panel) and its limitations.
189 */ 191 */
@@ -198,8 +200,10 @@ struct drm_display_info {
198 unsigned int min_vfreq, max_vfreq; 200 unsigned int min_vfreq, max_vfreq;
199 unsigned int min_hfreq, max_hfreq; 201 unsigned int min_hfreq, max_hfreq;
200 unsigned int pixel_clock; 202 unsigned int pixel_clock;
203 unsigned int bpc;
201 204
202 enum subpixel_order subpixel_order; 205 enum subpixel_order subpixel_order;
206 u32 color_formats;
203 207
204 char *raw_edid; /* if any */ 208 char *raw_edid; /* if any */
205}; 209};
@@ -221,7 +225,8 @@ struct drm_framebuffer_funcs {
221 * the semantics and arguments have a one to one mapping 225 * the semantics and arguments have a one to one mapping
222 * on this function. 226 * on this function.
223 */ 227 */
224 int (*dirty)(struct drm_framebuffer *framebuffer, unsigned flags, 228 int (*dirty)(struct drm_framebuffer *framebuffer,
229 struct drm_file *file_priv, unsigned flags,
225 unsigned color, struct drm_clip_rect *clips, 230 unsigned color, struct drm_clip_rect *clips,
226 unsigned num_clips); 231 unsigned num_clips);
227}; 232};
@@ -274,6 +279,7 @@ struct drm_pending_vblank_event;
274 279
275/** 280/**
276 * drm_crtc_funcs - control CRTCs for a given device 281 * drm_crtc_funcs - control CRTCs for a given device
282 * @reset: reset CRTC after state has been invalidate (e.g. resume)
277 * @dpms: control display power levels 283 * @dpms: control display power levels
278 * @save: save CRTC state 284 * @save: save CRTC state
279 * @resore: restore CRTC state 285 * @resore: restore CRTC state
@@ -301,6 +307,8 @@ struct drm_crtc_funcs {
301 void (*save)(struct drm_crtc *crtc); /* suspend? */ 307 void (*save)(struct drm_crtc *crtc); /* suspend? */
302 /* Restore CRTC state */ 308 /* Restore CRTC state */
303 void (*restore)(struct drm_crtc *crtc); /* resume? */ 309 void (*restore)(struct drm_crtc *crtc); /* resume? */
310 /* Reset CRTC state */
311 void (*reset)(struct drm_crtc *crtc);
304 312
305 /* cursor controls */ 313 /* cursor controls */
306 int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, 314 int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
@@ -317,7 +325,7 @@ struct drm_crtc_funcs {
317 325
318 /* 326 /*
319 * Flip to the given framebuffer. This implements the page 327 * Flip to the given framebuffer. This implements the page
320 * flip ioctl descibed in drm_mode.h, specifically, the 328 * flip ioctl described in drm_mode.h, specifically, the
321 * implementation must return immediately and block all 329 * implementation must return immediately and block all
322 * rendering to the current fb until the flip has completed. 330 * rendering to the current fb until the flip has completed.
323 * If userspace set the event flag in the ioctl, the event 331 * If userspace set the event flag in the ioctl, the event
@@ -350,8 +358,14 @@ struct drm_crtc {
350 358
351 bool enabled; 359 bool enabled;
352 360
361 /* Requested mode from modesetting. */
353 struct drm_display_mode mode; 362 struct drm_display_mode mode;
354 363
364 /* Programmed mode in hw, after adjustments for encoders,
365 * crtc, panel scaling etc. Needed for timestamping etc.
366 */
367 struct drm_display_mode hwmode;
368
355 int x, y; 369 int x, y;
356 const struct drm_crtc_funcs *funcs; 370 const struct drm_crtc_funcs *funcs;
357 371
@@ -359,6 +373,9 @@ struct drm_crtc {
359 uint32_t gamma_size; 373 uint32_t gamma_size;
360 uint16_t *gamma_store; 374 uint16_t *gamma_store;
361 375
376 /* Constants needed for precise vblank and swap timestamping. */
377 s64 framedur_ns, linedur_ns, pixeldur_ns;
378
362 /* if you are using the helper */ 379 /* if you are using the helper */
363 void *helper_private; 380 void *helper_private;
364}; 381};
@@ -369,6 +386,7 @@ struct drm_crtc {
369 * @dpms: set power state (see drm_crtc_funcs above) 386 * @dpms: set power state (see drm_crtc_funcs above)
370 * @save: save connector state 387 * @save: save connector state
371 * @restore: restore connector state 388 * @restore: restore connector state
389 * @reset: reset connector after state has been invalidate (e.g. resume)
372 * @mode_valid: is this mode valid on the given connector? 390 * @mode_valid: is this mode valid on the given connector?
373 * @mode_fixup: try to fixup proposed mode for this connector 391 * @mode_fixup: try to fixup proposed mode for this connector
374 * @mode_set: set this mode 392 * @mode_set: set this mode
@@ -386,6 +404,7 @@ struct drm_connector_funcs {
386 void (*dpms)(struct drm_connector *connector, int mode); 404 void (*dpms)(struct drm_connector *connector, int mode);
387 void (*save)(struct drm_connector *connector); 405 void (*save)(struct drm_connector *connector);
388 void (*restore)(struct drm_connector *connector); 406 void (*restore)(struct drm_connector *connector);
407 void (*reset)(struct drm_connector *connector);
389 408
390 /* Check to see if anything is attached to the connector. 409 /* Check to see if anything is attached to the connector.
391 * @force is set to false whilst polling, true when checking the 410 * @force is set to false whilst polling, true when checking the
@@ -403,6 +422,7 @@ struct drm_connector_funcs {
403}; 422};
404 423
405struct drm_encoder_funcs { 424struct drm_encoder_funcs {
425 void (*reset)(struct drm_encoder *encoder);
406 void (*destroy)(struct drm_encoder *encoder); 426 void (*destroy)(struct drm_encoder *encoder);
407}; 427};
408 428
@@ -500,6 +520,8 @@ struct drm_connector {
500 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; 520 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
501 uint32_t force_encoder_id; 521 uint32_t force_encoder_id;
502 struct drm_encoder *encoder; /* currently active encoder */ 522 struct drm_encoder *encoder; /* currently active encoder */
523
524 int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
503}; 525};
504 526
505/** 527/**
@@ -643,9 +665,10 @@ extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid
643extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode); 665extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
644extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode); 666extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
645extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, 667extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
646 struct drm_display_mode *mode); 668 const struct drm_display_mode *mode);
647extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode); 669extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
648extern void drm_mode_config_init(struct drm_device *dev); 670extern void drm_mode_config_init(struct drm_device *dev);
671extern void drm_mode_config_reset(struct drm_device *dev);
649extern void drm_mode_config_cleanup(struct drm_device *dev); 672extern void drm_mode_config_cleanup(struct drm_device *dev);
650extern void drm_mode_set_name(struct drm_display_mode *mode); 673extern void drm_mode_set_name(struct drm_display_mode *mode);
651extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2); 674extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
@@ -668,8 +691,8 @@ extern void drm_mode_validate_size(struct drm_device *dev,
668extern void drm_mode_prune_invalid(struct drm_device *dev, 691extern void drm_mode_prune_invalid(struct drm_device *dev,
669 struct list_head *mode_list, bool verbose); 692 struct list_head *mode_list, bool verbose);
670extern void drm_mode_sort(struct list_head *mode_list); 693extern void drm_mode_sort(struct list_head *mode_list);
671extern int drm_mode_hsync(struct drm_display_mode *mode); 694extern int drm_mode_hsync(const struct drm_display_mode *mode);
672extern int drm_mode_vrefresh(struct drm_display_mode *mode); 695extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
673extern void drm_mode_set_crtcinfo(struct drm_display_mode *p, 696extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
674 int adjust_flags); 697 int adjust_flags);
675extern void drm_mode_connector_list_update(struct drm_connector *connector); 698extern void drm_mode_connector_list_update(struct drm_connector *connector);
@@ -761,7 +784,9 @@ extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
761 void *data, struct drm_file *file_priv); 784 void *data, struct drm_file *file_priv);
762extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, 785extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
763 void *data, struct drm_file *file_priv); 786 void *data, struct drm_file *file_priv);
787extern u8 *drm_find_cea_extension(struct edid *edid);
764extern bool drm_detect_hdmi_monitor(struct edid *edid); 788extern bool drm_detect_hdmi_monitor(struct edid *edid);
789extern bool drm_detect_monitor_audio(struct edid *edid);
765extern int drm_mode_page_flip_ioctl(struct drm_device *dev, 790extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
766 void *data, struct drm_file *file_priv); 791 void *data, struct drm_file *file_priv);
767extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, 792extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
@@ -780,4 +805,11 @@ extern int drm_add_modes_noedid(struct drm_connector *connector,
780extern bool drm_edid_is_valid(struct edid *edid); 805extern bool drm_edid_is_valid(struct edid *edid);
781struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, 806struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
782 int hsize, int vsize, int fresh); 807 int hsize, int vsize, int fresh);
808
809extern int drm_mode_create_dumb_ioctl(struct drm_device *dev,
810 void *data, struct drm_file *file_priv);
811extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
812 void *data, struct drm_file *file_priv);
813extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
814 void *data, struct drm_file *file_priv);
783#endif /* __DRM_CRTC_H__ */ 815#endif /* __DRM_CRTC_H__ */
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index 59b7073b13fe..73b071203dcc 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -39,6 +39,11 @@
39 39
40#include <linux/fb.h> 40#include <linux/fb.h>
41 41
42enum mode_set_atomic {
43 LEAVE_ATOMIC_MODE_SET,
44 ENTER_ATOMIC_MODE_SET,
45};
46
42struct drm_crtc_helper_funcs { 47struct drm_crtc_helper_funcs {
43 /* 48 /*
44 * Control power levels on the CRTC. If the mode passed in is 49 * Control power levels on the CRTC. If the mode passed in is
@@ -61,7 +66,8 @@ struct drm_crtc_helper_funcs {
61 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y, 66 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
62 struct drm_framebuffer *old_fb); 67 struct drm_framebuffer *old_fb);
63 int (*mode_set_base_atomic)(struct drm_crtc *crtc, 68 int (*mode_set_base_atomic)(struct drm_crtc *crtc,
64 struct drm_framebuffer *fb, int x, int y); 69 struct drm_framebuffer *fb, int x, int y,
70 enum mode_set_atomic);
65 71
66 /* reload the current crtc LUT */ 72 /* reload the current crtc LUT */
67 void (*load_lut)(struct drm_crtc *crtc); 73 void (*load_lut)(struct drm_crtc *crtc);
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index a49e791db0b0..91567bbdb027 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -23,6 +23,9 @@
23#ifndef _DRM_DP_HELPER_H_ 23#ifndef _DRM_DP_HELPER_H_
24#define _DRM_DP_HELPER_H_ 24#define _DRM_DP_HELPER_H_
25 25
26#include <linux/types.h>
27#include <linux/i2c.h>
28
26/* From the VESA DisplayPort spec */ 29/* From the VESA DisplayPort spec */
27 30
28#define AUX_NATIVE_WRITE 0x8 31#define AUX_NATIVE_WRITE 0x8
@@ -50,6 +53,7 @@
50 53
51#define DP_MAX_LANE_COUNT 0x002 54#define DP_MAX_LANE_COUNT 0x002
52# define DP_MAX_LANE_COUNT_MASK 0x1f 55# define DP_MAX_LANE_COUNT_MASK 0x1f
56# define DP_TPS3_SUPPORTED (1 << 6)
53# define DP_ENHANCED_FRAME_CAP (1 << 7) 57# define DP_ENHANCED_FRAME_CAP (1 << 7)
54 58
55#define DP_MAX_DOWNSPREAD 0x003 59#define DP_MAX_DOWNSPREAD 0x003
@@ -68,10 +72,13 @@
68 72
69#define DP_MAIN_LINK_CHANNEL_CODING 0x006 73#define DP_MAIN_LINK_CHANNEL_CODING 0x006
70 74
75#define DP_TRAINING_AUX_RD_INTERVAL 0x00e
76
71/* link configuration */ 77/* link configuration */
72#define DP_LINK_BW_SET 0x100 78#define DP_LINK_BW_SET 0x100
73# define DP_LINK_BW_1_62 0x06 79# define DP_LINK_BW_1_62 0x06
74# define DP_LINK_BW_2_7 0x0a 80# define DP_LINK_BW_2_7 0x0a
81# define DP_LINK_BW_5_4 0x14
75 82
76#define DP_LANE_COUNT_SET 0x101 83#define DP_LANE_COUNT_SET 0x101
77# define DP_LANE_COUNT_MASK 0x0f 84# define DP_LANE_COUNT_MASK 0x0f
@@ -81,6 +88,7 @@
81# define DP_TRAINING_PATTERN_DISABLE 0 88# define DP_TRAINING_PATTERN_DISABLE 0
82# define DP_TRAINING_PATTERN_1 1 89# define DP_TRAINING_PATTERN_1 1
83# define DP_TRAINING_PATTERN_2 2 90# define DP_TRAINING_PATTERN_2 2
91# define DP_TRAINING_PATTERN_3 3
84# define DP_TRAINING_PATTERN_MASK 0x3 92# define DP_TRAINING_PATTERN_MASK 0x3
85 93
86# define DP_LINK_QUAL_PATTERN_DISABLE (0 << 2) 94# define DP_LINK_QUAL_PATTERN_DISABLE (0 << 2)
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 5881fad91faa..eacb415b309a 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -155,12 +155,35 @@ struct detailed_timing {
155#define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3) 155#define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3)
156#define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 4) 156#define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 4)
157#define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 5) 157#define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 5)
158#define DRM_EDID_INPUT_DIGITAL (1 << 7) /* bits below must be zero if set */ 158#define DRM_EDID_INPUT_DIGITAL (1 << 7)
159#define DRM_EDID_DIGITAL_DEPTH_MASK (7 << 4)
160#define DRM_EDID_DIGITAL_DEPTH_UNDEF (0 << 4)
161#define DRM_EDID_DIGITAL_DEPTH_6 (1 << 4)
162#define DRM_EDID_DIGITAL_DEPTH_8 (2 << 4)
163#define DRM_EDID_DIGITAL_DEPTH_10 (3 << 4)
164#define DRM_EDID_DIGITAL_DEPTH_12 (4 << 4)
165#define DRM_EDID_DIGITAL_DEPTH_14 (5 << 4)
166#define DRM_EDID_DIGITAL_DEPTH_16 (6 << 4)
167#define DRM_EDID_DIGITAL_DEPTH_RSVD (7 << 4)
168#define DRM_EDID_DIGITAL_TYPE_UNDEF (0)
169#define DRM_EDID_DIGITAL_TYPE_DVI (1)
170#define DRM_EDID_DIGITAL_TYPE_HDMI_A (2)
171#define DRM_EDID_DIGITAL_TYPE_HDMI_B (3)
172#define DRM_EDID_DIGITAL_TYPE_MDDI (4)
173#define DRM_EDID_DIGITAL_TYPE_DP (5)
159 174
160#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 0) 175#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 0)
161#define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 1) 176#define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 1)
162#define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 2) 177#define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 2)
178/* If analog */
163#define DRM_EDID_FEATURE_DISPLAY_TYPE (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */ 179#define DRM_EDID_FEATURE_DISPLAY_TYPE (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
180/* If digital */
181#define DRM_EDID_FEATURE_COLOR_MASK (3 << 3)
182#define DRM_EDID_FEATURE_RGB (0 << 3)
183#define DRM_EDID_FEATURE_RGB_YCRCB444 (1 << 3)
184#define DRM_EDID_FEATURE_RGB_YCRCB422 (2 << 3)
185#define DRM_EDID_FEATURE_RGB_YCRCB (3 << 3) /* both 4:4:4 and 4:2:2 */
186
164#define DRM_EDID_FEATURE_PM_ACTIVE_OFF (1 << 5) 187#define DRM_EDID_FEATURE_PM_ACTIVE_OFF (1 << 5)
165#define DRM_EDID_FEATURE_PM_SUSPEND (1 << 6) 188#define DRM_EDID_FEATURE_PM_SUSPEND (1 << 6)
166#define DRM_EDID_FEATURE_PM_STANDBY (1 << 7) 189#define DRM_EDID_FEATURE_PM_STANDBY (1 << 7)
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index f22e7fe4b6db..6e3076ad646e 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -40,20 +40,6 @@ struct drm_fb_helper_crtc {
40 struct drm_display_mode *desired_mode; 40 struct drm_display_mode *desired_mode;
41}; 41};
42 42
43/* mode specified on the command line */
44struct drm_fb_helper_cmdline_mode {
45 bool specified;
46 bool refresh_specified;
47 bool bpp_specified;
48 int xres, yres;
49 int bpp;
50 int refresh;
51 bool rb;
52 bool interlace;
53 bool cvt;
54 bool margins;
55};
56
57struct drm_fb_helper_surface_size { 43struct drm_fb_helper_surface_size {
58 u32 fb_width; 44 u32 fb_width;
59 u32 fb_height; 45 u32 fb_height;
@@ -74,8 +60,8 @@ struct drm_fb_helper_funcs {
74}; 60};
75 61
76struct drm_fb_helper_connector { 62struct drm_fb_helper_connector {
77 struct drm_fb_helper_cmdline_mode cmdline_mode;
78 struct drm_connector *connector; 63 struct drm_connector *connector;
64 struct drm_cmdline_mode cmdline_mode;
79}; 65};
80 66
81struct drm_fb_helper { 67struct drm_fb_helper {
@@ -118,6 +104,7 @@ int drm_fb_helper_setcolreg(unsigned regno,
118 unsigned transp, 104 unsigned transp,
119 struct fb_info *info); 105 struct fb_info *info);
120 106
107bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper);
121void drm_fb_helper_restore(void); 108void drm_fb_helper_restore(void);
122void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper, 109void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper,
123 uint32_t fb_width, uint32_t fb_height); 110 uint32_t fb_width, uint32_t fb_height);
@@ -126,7 +113,7 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
126 113
127int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); 114int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
128 115
129bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper); 116int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
130bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel); 117bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel);
131int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper); 118int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper);
132int drm_fb_helper_debug_enter(struct fb_info *info); 119int drm_fb_helper_debug_enter(struct fb_info *info);
diff --git a/include/drm/drm_hashtab.h b/include/drm/drm_hashtab.h
index 0af087a4d3b3..3650d5d011ee 100644
--- a/include/drm/drm_hashtab.h
+++ b/include/drm/drm_hashtab.h
@@ -45,14 +45,10 @@ struct drm_hash_item {
45}; 45};
46 46
47struct drm_open_hash { 47struct drm_open_hash {
48 unsigned int size;
49 unsigned int order;
50 unsigned int fill;
51 struct hlist_head *table; 48 struct hlist_head *table;
52 int use_vmalloc; 49 u8 order;
53}; 50};
54 51
55
56extern int drm_ht_create(struct drm_open_hash *ht, unsigned int order); 52extern int drm_ht_create(struct drm_open_hash *ht, unsigned int order);
57extern int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item); 53extern int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item);
58extern int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, 54extern int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index bf01531193d5..564b14aa7e16 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -42,33 +42,58 @@
42#endif 42#endif
43 43
44struct drm_mm_node { 44struct drm_mm_node {
45 struct list_head free_stack;
46 struct list_head node_list; 45 struct list_head node_list;
47 unsigned free : 1; 46 struct list_head hole_stack;
47 unsigned hole_follows : 1;
48 unsigned scanned_block : 1; 48 unsigned scanned_block : 1;
49 unsigned scanned_prev_free : 1; 49 unsigned scanned_prev_free : 1;
50 unsigned scanned_next_free : 1; 50 unsigned scanned_next_free : 1;
51 unsigned scanned_preceeds_hole : 1;
52 unsigned allocated : 1;
51 unsigned long start; 53 unsigned long start;
52 unsigned long size; 54 unsigned long size;
53 struct drm_mm *mm; 55 struct drm_mm *mm;
54}; 56};
55 57
56struct drm_mm { 58struct drm_mm {
57 /* List of free memory blocks, most recently freed ordered. */ 59 /* List of all memory nodes that immediately precede a free hole. */
58 struct list_head free_stack; 60 struct list_head hole_stack;
59 /* List of all memory nodes, ordered according to the (increasing) start 61 /* head_node.node_list is the list of all memory nodes, ordered
60 * address of the memory node. */ 62 * according to the (increasing) start address of the memory node. */
61 struct list_head node_list; 63 struct drm_mm_node head_node;
62 struct list_head unused_nodes; 64 struct list_head unused_nodes;
63 int num_unused; 65 int num_unused;
64 spinlock_t unused_lock; 66 spinlock_t unused_lock;
67 unsigned int scan_check_range : 1;
65 unsigned scan_alignment; 68 unsigned scan_alignment;
66 unsigned long scan_size; 69 unsigned long scan_size;
67 unsigned long scan_hit_start; 70 unsigned long scan_hit_start;
68 unsigned scan_hit_size; 71 unsigned scan_hit_size;
69 unsigned scanned_blocks; 72 unsigned scanned_blocks;
73 unsigned long scan_start;
74 unsigned long scan_end;
75 struct drm_mm_node *prev_scanned_node;
70}; 76};
71 77
78static inline bool drm_mm_node_allocated(struct drm_mm_node *node)
79{
80 return node->allocated;
81}
82
83static inline bool drm_mm_initialized(struct drm_mm *mm)
84{
85 return mm->hole_stack.next;
86}
87#define drm_mm_for_each_node(entry, mm) list_for_each_entry(entry, \
88 &(mm)->head_node.node_list, \
89 node_list)
90#define drm_mm_for_each_scanned_node_reverse(entry, n, mm) \
91 for (entry = (mm)->prev_scanned_node, \
92 next = entry ? list_entry(entry->node_list.next, \
93 struct drm_mm_node, node_list) : NULL; \
94 entry != NULL; entry = next, \
95 next = entry ? list_entry(entry->node_list.next, \
96 struct drm_mm_node, node_list) : NULL) \
72/* 97/*
73 * Basic range manager support (drm_mm.c) 98 * Basic range manager support (drm_mm.c)
74 */ 99 */
@@ -115,7 +140,15 @@ static inline struct drm_mm_node *drm_mm_get_block_atomic_range(
115 return drm_mm_get_block_range_generic(parent, size, alignment, 140 return drm_mm_get_block_range_generic(parent, size, alignment,
116 start, end, 1); 141 start, end, 1);
117} 142}
143extern int drm_mm_insert_node(struct drm_mm *mm, struct drm_mm_node *node,
144 unsigned long size, unsigned alignment);
145extern int drm_mm_insert_node_in_range(struct drm_mm *mm,
146 struct drm_mm_node *node,
147 unsigned long size, unsigned alignment,
148 unsigned long start, unsigned long end);
118extern void drm_mm_put_block(struct drm_mm_node *cur); 149extern void drm_mm_put_block(struct drm_mm_node *cur);
150extern void drm_mm_remove_node(struct drm_mm_node *node);
151extern void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
119extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, 152extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
120 unsigned long size, 153 unsigned long size,
121 unsigned alignment, 154 unsigned alignment,
@@ -131,11 +164,6 @@ extern int drm_mm_init(struct drm_mm *mm, unsigned long start,
131 unsigned long size); 164 unsigned long size);
132extern void drm_mm_takedown(struct drm_mm *mm); 165extern void drm_mm_takedown(struct drm_mm *mm);
133extern int drm_mm_clean(struct drm_mm *mm); 166extern int drm_mm_clean(struct drm_mm *mm);
134extern unsigned long drm_mm_tail_space(struct drm_mm *mm);
135extern int drm_mm_remove_space_from_tail(struct drm_mm *mm,
136 unsigned long size);
137extern int drm_mm_add_space_to_tail(struct drm_mm *mm,
138 unsigned long size, int atomic);
139extern int drm_mm_pre_get(struct drm_mm *mm); 167extern int drm_mm_pre_get(struct drm_mm *mm);
140 168
141static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block) 169static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block)
@@ -145,6 +173,10 @@ static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block)
145 173
146void drm_mm_init_scan(struct drm_mm *mm, unsigned long size, 174void drm_mm_init_scan(struct drm_mm *mm, unsigned long size,
147 unsigned alignment); 175 unsigned alignment);
176void drm_mm_init_scan_with_range(struct drm_mm *mm, unsigned long size,
177 unsigned alignment,
178 unsigned long start,
179 unsigned long end);
148int drm_mm_scan_add_block(struct drm_mm_node *node); 180int drm_mm_scan_add_block(struct drm_mm_node *node);
149int drm_mm_scan_remove_block(struct drm_mm_node *node); 181int drm_mm_scan_remove_block(struct drm_mm_node *node);
150 182
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index 0fc7397c8f1f..c4961ea50a49 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -277,7 +277,7 @@ struct drm_mode_mode_cmd {
277#define DRM_MODE_CURSOR_MOVE (1<<1) 277#define DRM_MODE_CURSOR_MOVE (1<<1)
278 278
279/* 279/*
280 * depending on the value in flags diffrent members are used. 280 * depending on the value in flags different members are used.
281 * 281 *
282 * CURSOR_BO uses 282 * CURSOR_BO uses
283 * crtc 283 * crtc
@@ -344,4 +344,33 @@ struct drm_mode_crtc_page_flip {
344 __u64 user_data; 344 __u64 user_data;
345}; 345};
346 346
347/* create a dumb scanout buffer */
348struct drm_mode_create_dumb {
349 uint32_t height;
350 uint32_t width;
351 uint32_t bpp;
352 uint32_t flags;
353 /* handle, pitch, size will be returned */
354 uint32_t handle;
355 uint32_t pitch;
356 uint64_t size;
357};
358
359/* set up for mmap of a dumb scanout buffer */
360struct drm_mode_map_dumb {
361 /** Handle for the object being mapped. */
362 __u32 handle;
363 __u32 pad;
364 /**
365 * Fake offset to use for subsequent mmap call
366 *
367 * This is a fixed-size type for 32/64 compatibility.
368 */
369 __u64 offset;
370};
371
372struct drm_mode_destroy_dumb {
373 uint32_t handle;
374};
375
347#endif 376#endif
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index 883c1d439899..3d53efd25ab9 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -28,7 +28,6 @@
28 {0x1002, 0x4156, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ 28 {0x1002, 0x4156, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
29 {0x1002, 0x4237, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP}, \ 29 {0x1002, 0x4237, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP}, \
30 {0x1002, 0x4242, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \ 30 {0x1002, 0x4242, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
31 {0x1002, 0x4243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
32 {0x1002, 0x4336, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ 31 {0x1002, 0x4336, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
33 {0x1002, 0x4337, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ 32 {0x1002, 0x4337, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
34 {0x1002, 0x4437, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ 33 {0x1002, 0x4437, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
@@ -142,6 +141,60 @@
142 {0x1002, 0x5e4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ 141 {0x1002, 0x5e4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
143 {0x1002, 0x5e4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ 142 {0x1002, 0x5e4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
144 {0x1002, 0x5e4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ 143 {0x1002, 0x5e4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \
144 {0x1002, 0x6700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
145 {0x1002, 0x6701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
146 {0x1002, 0x6702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
147 {0x1002, 0x6703, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
148 {0x1002, 0x6704, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
149 {0x1002, 0x6705, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
150 {0x1002, 0x6706, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
151 {0x1002, 0x6707, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
152 {0x1002, 0x6708, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
153 {0x1002, 0x6709, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
154 {0x1002, 0x6718, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
155 {0x1002, 0x6719, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
156 {0x1002, 0x671c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
157 {0x1002, 0x671d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
158 {0x1002, 0x671f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \
159 {0x1002, 0x6720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
160 {0x1002, 0x6721, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
161 {0x1002, 0x6722, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
162 {0x1002, 0x6723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
163 {0x1002, 0x6724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
164 {0x1002, 0x6725, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
165 {0x1002, 0x6726, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
166 {0x1002, 0x6727, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
167 {0x1002, 0x6728, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
168 {0x1002, 0x6729, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
169 {0x1002, 0x6738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
170 {0x1002, 0x6739, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
171 {0x1002, 0x673e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \
172 {0x1002, 0x6740, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
173 {0x1002, 0x6741, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
174 {0x1002, 0x6742, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
175 {0x1002, 0x6743, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
176 {0x1002, 0x6744, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
177 {0x1002, 0x6745, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
178 {0x1002, 0x6746, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
179 {0x1002, 0x6747, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
180 {0x1002, 0x6748, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
181 {0x1002, 0x6749, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
182 {0x1002, 0x6750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
183 {0x1002, 0x6758, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
184 {0x1002, 0x6759, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
185 {0x1002, 0x675F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \
186 {0x1002, 0x6760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
187 {0x1002, 0x6761, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
188 {0x1002, 0x6762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
189 {0x1002, 0x6763, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
190 {0x1002, 0x6764, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
191 {0x1002, 0x6765, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
192 {0x1002, 0x6766, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
193 {0x1002, 0x6767, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
194 {0x1002, 0x6768, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
195 {0x1002, 0x6770, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
196 {0x1002, 0x6778, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
197 {0x1002, 0x6779, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \
145 {0x1002, 0x6880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 198 {0x1002, 0x6880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
146 {0x1002, 0x6888, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ 199 {0x1002, 0x6888, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
147 {0x1002, 0x6889, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ 200 {0x1002, 0x6889, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
@@ -150,6 +203,7 @@
150 {0x1002, 0x688D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ 203 {0x1002, 0x688D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
151 {0x1002, 0x6898, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ 204 {0x1002, 0x6898, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
152 {0x1002, 0x6899, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ 205 {0x1002, 0x6899, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
206 {0x1002, 0x689b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
153 {0x1002, 0x689c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ 207 {0x1002, 0x689c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \
154 {0x1002, 0x689d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ 208 {0x1002, 0x689d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \
155 {0x1002, 0x689e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ 209 {0x1002, 0x689e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \
@@ -160,7 +214,9 @@
160 {0x1002, 0x68b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 214 {0x1002, 0x68b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
161 {0x1002, 0x68b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ 215 {0x1002, 0x68b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
162 {0x1002, 0x68b9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ 216 {0x1002, 0x68b9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
217 {0x1002, 0x68ba, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
163 {0x1002, 0x68be, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ 218 {0x1002, 0x68be, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
219 {0x1002, 0x68bf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \
164 {0x1002, 0x68c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 220 {0x1002, 0x68c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
165 {0x1002, 0x68c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 221 {0x1002, 0x68c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
166 {0x1002, 0x68c7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 222 {0x1002, 0x68c7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
@@ -413,12 +469,29 @@
413 {0x1002, 0x9614, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 469 {0x1002, 0x9614, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
414 {0x1002, 0x9615, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 470 {0x1002, 0x9615, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
415 {0x1002, 0x9616, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 471 {0x1002, 0x9616, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
472 {0x1002, 0x9640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
473 {0x1002, 0x9641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
474 {0x1002, 0x9642, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
475 {0x1002, 0x9643, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
476 {0x1002, 0x9644, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
477 {0x1002, 0x9645, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
478 {0x1002, 0x9647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\
479 {0x1002, 0x9648, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\
480 {0x1002, 0x964a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
481 {0x1002, 0x964e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\
482 {0x1002, 0x964f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\
416 {0x1002, 0x9710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 483 {0x1002, 0x9710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
417 {0x1002, 0x9711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 484 {0x1002, 0x9711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
418 {0x1002, 0x9712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 485 {0x1002, 0x9712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
419 {0x1002, 0x9713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 486 {0x1002, 0x9713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
420 {0x1002, 0x9714, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 487 {0x1002, 0x9714, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
421 {0x1002, 0x9715, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 488 {0x1002, 0x9715, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
489 {0x1002, 0x9802, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
490 {0x1002, 0x9803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
491 {0x1002, 0x9804, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
492 {0x1002, 0x9805, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
493 {0x1002, 0x9806, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
494 {0x1002, 0x9807, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
422 {0, 0, 0} 495 {0, 0, 0}
423 496
424#define r128_PCI_IDS \ 497#define r128_PCI_IDS \
diff --git a/include/drm/drm_usb.h b/include/drm/drm_usb.h
new file mode 100644
index 000000000000..33506c11da8b
--- /dev/null
+++ b/include/drm/drm_usb.h
@@ -0,0 +1,15 @@
1#ifndef DRM_USB_H
2#define DRM_USB_H
3
4#include <drmP.h>
5
6#include <linux/usb.h>
7
8extern int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver);
9extern void drm_usb_exit(struct drm_driver *driver, struct usb_driver *udriver);
10
11int drm_get_usb_dev(struct usb_interface *interface,
12 const struct usb_device_id *id,
13 struct drm_driver *driver);
14
15#endif
diff --git a/include/drm/i830_drm.h b/include/drm/i830_drm.h
deleted file mode 100644
index 61315c29b8f3..000000000000
--- a/include/drm/i830_drm.h
+++ /dev/null
@@ -1,342 +0,0 @@
1#ifndef _I830_DRM_H_
2#define _I830_DRM_H_
3
4/* WARNING: These defines must be the same as what the Xserver uses.
5 * if you change them, you must change the defines in the Xserver.
6 *
7 * KW: Actually, you can't ever change them because doing so would
8 * break backwards compatibility.
9 */
10
11#ifndef _I830_DEFINES_
12#define _I830_DEFINES_
13
14#define I830_DMA_BUF_ORDER 12
15#define I830_DMA_BUF_SZ (1<<I830_DMA_BUF_ORDER)
16#define I830_DMA_BUF_NR 256
17#define I830_NR_SAREA_CLIPRECTS 8
18
19/* Each region is a minimum of 64k, and there are at most 64 of them.
20 */
21#define I830_NR_TEX_REGIONS 64
22#define I830_LOG_MIN_TEX_REGION_SIZE 16
23
24/* KW: These aren't correct but someone set them to two and then
25 * released the module. Now we can't change them as doing so would
26 * break backwards compatibility.
27 */
28#define I830_TEXTURE_COUNT 2
29#define I830_TEXBLEND_COUNT I830_TEXTURE_COUNT
30
31#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
32
33#define I830_UPLOAD_CTX 0x1
34#define I830_UPLOAD_BUFFERS 0x2
35#define I830_UPLOAD_CLIPRECTS 0x4
36#define I830_UPLOAD_TEX0_IMAGE 0x100 /* handled clientside */
37#define I830_UPLOAD_TEX0_CUBE 0x200 /* handled clientside */
38#define I830_UPLOAD_TEX1_IMAGE 0x400 /* handled clientside */
39#define I830_UPLOAD_TEX1_CUBE 0x800 /* handled clientside */
40#define I830_UPLOAD_TEX2_IMAGE 0x1000 /* handled clientside */
41#define I830_UPLOAD_TEX2_CUBE 0x2000 /* handled clientside */
42#define I830_UPLOAD_TEX3_IMAGE 0x4000 /* handled clientside */
43#define I830_UPLOAD_TEX3_CUBE 0x8000 /* handled clientside */
44#define I830_UPLOAD_TEX_N_IMAGE(n) (0x100 << (n * 2))
45#define I830_UPLOAD_TEX_N_CUBE(n) (0x200 << (n * 2))
46#define I830_UPLOAD_TEXIMAGE_MASK 0xff00
47#define I830_UPLOAD_TEX0 0x10000
48#define I830_UPLOAD_TEX1 0x20000
49#define I830_UPLOAD_TEX2 0x40000
50#define I830_UPLOAD_TEX3 0x80000
51#define I830_UPLOAD_TEX_N(n) (0x10000 << (n))
52#define I830_UPLOAD_TEX_MASK 0xf0000
53#define I830_UPLOAD_TEXBLEND0 0x100000
54#define I830_UPLOAD_TEXBLEND1 0x200000
55#define I830_UPLOAD_TEXBLEND2 0x400000
56#define I830_UPLOAD_TEXBLEND3 0x800000
57#define I830_UPLOAD_TEXBLEND_N(n) (0x100000 << (n))
58#define I830_UPLOAD_TEXBLEND_MASK 0xf00000
59#define I830_UPLOAD_TEX_PALETTE_N(n) (0x1000000 << (n))
60#define I830_UPLOAD_TEX_PALETTE_SHARED 0x4000000
61#define I830_UPLOAD_STIPPLE 0x8000000
62
63/* Indices into buf.Setup where various bits of state are mirrored per
64 * context and per buffer. These can be fired at the card as a unit,
65 * or in a piecewise fashion as required.
66 */
67
68/* Destbuffer state
69 * - backbuffer linear offset and pitch -- invarient in the current dri
70 * - zbuffer linear offset and pitch -- also invarient
71 * - drawing origin in back and depth buffers.
72 *
73 * Keep the depth/back buffer state here to accommodate private buffers
74 * in the future.
75 */
76
77#define I830_DESTREG_CBUFADDR 0
78#define I830_DESTREG_DBUFADDR 1
79#define I830_DESTREG_DV0 2
80#define I830_DESTREG_DV1 3
81#define I830_DESTREG_SENABLE 4
82#define I830_DESTREG_SR0 5
83#define I830_DESTREG_SR1 6
84#define I830_DESTREG_SR2 7
85#define I830_DESTREG_DR0 8
86#define I830_DESTREG_DR1 9
87#define I830_DESTREG_DR2 10
88#define I830_DESTREG_DR3 11
89#define I830_DESTREG_DR4 12
90#define I830_DEST_SETUP_SIZE 13
91
92/* Context state
93 */
94#define I830_CTXREG_STATE1 0
95#define I830_CTXREG_STATE2 1
96#define I830_CTXREG_STATE3 2
97#define I830_CTXREG_STATE4 3
98#define I830_CTXREG_STATE5 4
99#define I830_CTXREG_IALPHAB 5
100#define I830_CTXREG_STENCILTST 6
101#define I830_CTXREG_ENABLES_1 7
102#define I830_CTXREG_ENABLES_2 8
103#define I830_CTXREG_AA 9
104#define I830_CTXREG_FOGCOLOR 10
105#define I830_CTXREG_BLENDCOLR0 11
106#define I830_CTXREG_BLENDCOLR 12 /* Dword 1 of 2 dword command */
107#define I830_CTXREG_VF 13
108#define I830_CTXREG_VF2 14
109#define I830_CTXREG_MCSB0 15
110#define I830_CTXREG_MCSB1 16
111#define I830_CTX_SETUP_SIZE 17
112
113/* 1.3: Stipple state
114 */
115#define I830_STPREG_ST0 0
116#define I830_STPREG_ST1 1
117#define I830_STP_SETUP_SIZE 2
118
119/* Texture state (per tex unit)
120 */
121
122#define I830_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (6 dwords) */
123#define I830_TEXREG_MI1 1
124#define I830_TEXREG_MI2 2
125#define I830_TEXREG_MI3 3
126#define I830_TEXREG_MI4 4
127#define I830_TEXREG_MI5 5
128#define I830_TEXREG_MF 6 /* GFX_OP_MAP_FILTER */
129#define I830_TEXREG_MLC 7 /* GFX_OP_MAP_LOD_CTL */
130#define I830_TEXREG_MLL 8 /* GFX_OP_MAP_LOD_LIMITS */
131#define I830_TEXREG_MCS 9 /* GFX_OP_MAP_COORD_SETS */
132#define I830_TEX_SETUP_SIZE 10
133
134#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
135#define I830_TEXREG_TM0S0 1
136#define I830_TEXREG_TM0S1 2
137#define I830_TEXREG_TM0S2 3
138#define I830_TEXREG_TM0S3 4
139#define I830_TEXREG_TM0S4 5
140#define I830_TEXREG_NOP0 6 /* noop */
141#define I830_TEXREG_NOP1 7 /* noop */
142#define I830_TEXREG_NOP2 8 /* noop */
143#define __I830_TEXREG_MCS 9 /* GFX_OP_MAP_COORD_SETS -- shared */
144#define __I830_TEX_SETUP_SIZE 10
145
146#define I830_FRONT 0x1
147#define I830_BACK 0x2
148#define I830_DEPTH 0x4
149
150#endif /* _I830_DEFINES_ */
151
152typedef struct _drm_i830_init {
153 enum {
154 I830_INIT_DMA = 0x01,
155 I830_CLEANUP_DMA = 0x02
156 } func;
157 unsigned int mmio_offset;
158 unsigned int buffers_offset;
159 int sarea_priv_offset;
160 unsigned int ring_start;
161 unsigned int ring_end;
162 unsigned int ring_size;
163 unsigned int front_offset;
164 unsigned int back_offset;
165 unsigned int depth_offset;
166 unsigned int w;
167 unsigned int h;
168 unsigned int pitch;
169 unsigned int pitch_bits;
170 unsigned int back_pitch;
171 unsigned int depth_pitch;
172 unsigned int cpp;
173} drm_i830_init_t;
174
175/* Warning: If you change the SAREA structure you must change the Xserver
176 * structure as well */
177
178typedef struct _drm_i830_tex_region {
179 unsigned char next, prev; /* indices to form a circular LRU */
180 unsigned char in_use; /* owned by a client, or free? */
181 int age; /* tracked by clients to update local LRU's */
182} drm_i830_tex_region_t;
183
184typedef struct _drm_i830_sarea {
185 unsigned int ContextState[I830_CTX_SETUP_SIZE];
186 unsigned int BufferState[I830_DEST_SETUP_SIZE];
187 unsigned int TexState[I830_TEXTURE_COUNT][I830_TEX_SETUP_SIZE];
188 unsigned int TexBlendState[I830_TEXBLEND_COUNT][I830_TEXBLEND_SIZE];
189 unsigned int TexBlendStateWordsUsed[I830_TEXBLEND_COUNT];
190 unsigned int Palette[2][256];
191 unsigned int dirty;
192
193 unsigned int nbox;
194 struct drm_clip_rect boxes[I830_NR_SAREA_CLIPRECTS];
195
196 /* Maintain an LRU of contiguous regions of texture space. If
197 * you think you own a region of texture memory, and it has an
198 * age different to the one you set, then you are mistaken and
199 * it has been stolen by another client. If global texAge
200 * hasn't changed, there is no need to walk the list.
201 *
202 * These regions can be used as a proxy for the fine-grained
203 * texture information of other clients - by maintaining them
204 * in the same lru which is used to age their own textures,
205 * clients have an approximate lru for the whole of global
206 * texture space, and can make informed decisions as to which
207 * areas to kick out. There is no need to choose whether to
208 * kick out your own texture or someone else's - simply eject
209 * them all in LRU order.
210 */
211
212 drm_i830_tex_region_t texList[I830_NR_TEX_REGIONS + 1];
213 /* Last elt is sentinal */
214 int texAge; /* last time texture was uploaded */
215 int last_enqueue; /* last time a buffer was enqueued */
216 int last_dispatch; /* age of the most recently dispatched buffer */
217 int last_quiescent; /* */
218 int ctxOwner; /* last context to upload state */
219
220 int vertex_prim;
221
222 int pf_enabled; /* is pageflipping allowed? */
223 int pf_active;
224 int pf_current_page; /* which buffer is being displayed? */
225
226 int perf_boxes; /* performance boxes to be displayed */
227
228 /* Here's the state for texunits 2,3:
229 */
230 unsigned int TexState2[I830_TEX_SETUP_SIZE];
231 unsigned int TexBlendState2[I830_TEXBLEND_SIZE];
232 unsigned int TexBlendStateWordsUsed2;
233
234 unsigned int TexState3[I830_TEX_SETUP_SIZE];
235 unsigned int TexBlendState3[I830_TEXBLEND_SIZE];
236 unsigned int TexBlendStateWordsUsed3;
237
238 unsigned int StippleState[I830_STP_SETUP_SIZE];
239} drm_i830_sarea_t;
240
241/* Flags for perf_boxes
242 */
243#define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */
244#define I830_BOX_FLIP 0x2 /* populated by kernel */
245#define I830_BOX_WAIT 0x4 /* populated by kernel & client */
246#define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */
247#define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */
248
249/* I830 specific ioctls
250 * The device specific ioctl range is 0x40 to 0x79.
251 */
252#define DRM_I830_INIT 0x00
253#define DRM_I830_VERTEX 0x01
254#define DRM_I830_CLEAR 0x02
255#define DRM_I830_FLUSH 0x03
256#define DRM_I830_GETAGE 0x04
257#define DRM_I830_GETBUF 0x05
258#define DRM_I830_SWAP 0x06
259#define DRM_I830_COPY 0x07
260#define DRM_I830_DOCOPY 0x08
261#define DRM_I830_FLIP 0x09
262#define DRM_I830_IRQ_EMIT 0x0a
263#define DRM_I830_IRQ_WAIT 0x0b
264#define DRM_I830_GETPARAM 0x0c
265#define DRM_I830_SETPARAM 0x0d
266
267#define DRM_IOCTL_I830_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I830_INIT, drm_i830_init_t)
268#define DRM_IOCTL_I830_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_I830_VERTEX, drm_i830_vertex_t)
269#define DRM_IOCTL_I830_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_I830_CLEAR, drm_i830_clear_t)
270#define DRM_IOCTL_I830_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I830_FLUSH)
271#define DRM_IOCTL_I830_GETAGE DRM_IO ( DRM_COMMAND_BASE + DRM_I830_GETAGE)
272#define DRM_IOCTL_I830_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_I830_GETBUF, drm_i830_dma_t)
273#define DRM_IOCTL_I830_SWAP DRM_IO ( DRM_COMMAND_BASE + DRM_I830_SWAP)
274#define DRM_IOCTL_I830_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_I830_COPY, drm_i830_copy_t)
275#define DRM_IOCTL_I830_DOCOPY DRM_IO ( DRM_COMMAND_BASE + DRM_I830_DOCOPY)
276#define DRM_IOCTL_I830_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I830_FLIP)
277#define DRM_IOCTL_I830_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I830_IRQ_EMIT, drm_i830_irq_emit_t)
278#define DRM_IOCTL_I830_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I830_IRQ_WAIT, drm_i830_irq_wait_t)
279#define DRM_IOCTL_I830_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I830_GETPARAM, drm_i830_getparam_t)
280#define DRM_IOCTL_I830_SETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I830_SETPARAM, drm_i830_setparam_t)
281
282typedef struct _drm_i830_clear {
283 int clear_color;
284 int clear_depth;
285 int flags;
286 unsigned int clear_colormask;
287 unsigned int clear_depthmask;
288} drm_i830_clear_t;
289
290/* These may be placeholders if we have more cliprects than
291 * I830_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
292 * false, indicating that the buffer will be dispatched again with a
293 * new set of cliprects.
294 */
295typedef struct _drm_i830_vertex {
296 int idx; /* buffer index */
297 int used; /* nr bytes in use */
298 int discard; /* client is finished with the buffer? */
299} drm_i830_vertex_t;
300
301typedef struct _drm_i830_copy_t {
302 int idx; /* buffer index */
303 int used; /* nr bytes in use */
304 void __user *address; /* Address to copy from */
305} drm_i830_copy_t;
306
307typedef struct drm_i830_dma {
308 void __user *virtual;
309 int request_idx;
310 int request_size;
311 int granted;
312} drm_i830_dma_t;
313
314/* 1.3: Userspace can request & wait on irq's:
315 */
316typedef struct drm_i830_irq_emit {
317 int __user *irq_seq;
318} drm_i830_irq_emit_t;
319
320typedef struct drm_i830_irq_wait {
321 int irq_seq;
322} drm_i830_irq_wait_t;
323
324/* 1.3: New ioctl to query kernel params:
325 */
326#define I830_PARAM_IRQ_ACTIVE 1
327
328typedef struct drm_i830_getparam {
329 int param;
330 int __user *value;
331} drm_i830_getparam_t;
332
333/* 1.3: New ioctl to set kernel params:
334 */
335#define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1
336
337typedef struct drm_i830_setparam {
338 int param;
339 int value;
340} drm_i830_setparam_t;
341
342#endif /* _I830_DRM_H_ */
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index e41c74facb6a..c4d6dbfa3ff4 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -286,6 +286,11 @@ typedef struct drm_i915_irq_wait {
286#define I915_PARAM_HAS_PAGEFLIPPING 8 286#define I915_PARAM_HAS_PAGEFLIPPING 8
287#define I915_PARAM_HAS_EXECBUF2 9 287#define I915_PARAM_HAS_EXECBUF2 9
288#define I915_PARAM_HAS_BSD 10 288#define I915_PARAM_HAS_BSD 10
289#define I915_PARAM_HAS_BLT 11
290#define I915_PARAM_HAS_RELAXED_FENCING 12
291#define I915_PARAM_HAS_COHERENT_RINGS 13
292#define I915_PARAM_HAS_EXEC_CONSTANTS 14
293#define I915_PARAM_HAS_RELAXED_DELTA 15
289 294
290typedef struct drm_i915_getparam { 295typedef struct drm_i915_getparam {
291 int param; 296 int param;
@@ -627,8 +632,22 @@ struct drm_i915_gem_execbuffer2 {
627 __u32 num_cliprects; 632 __u32 num_cliprects;
628 /** This is a struct drm_clip_rect *cliprects */ 633 /** This is a struct drm_clip_rect *cliprects */
629 __u64 cliprects_ptr; 634 __u64 cliprects_ptr;
635#define I915_EXEC_RING_MASK (7<<0)
636#define I915_EXEC_DEFAULT (0<<0)
630#define I915_EXEC_RENDER (1<<0) 637#define I915_EXEC_RENDER (1<<0)
631#define I915_EXEC_BSD (1<<1) 638#define I915_EXEC_BSD (2<<0)
639#define I915_EXEC_BLT (3<<0)
640
641/* Used for switching the constants addressing mode on gen4+ RENDER ring.
642 * Gen6+ only supports relative addressing to dynamic state (default) and
643 * absolute addressing.
644 *
645 * These flags are ignored for the BSD and BLT rings.
646 */
647#define I915_EXEC_CONSTANTS_MASK (3<<6)
648#define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
649#define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)
650#define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
632 __u64 flags; 651 __u64 flags;
633 __u64 rsvd1; 652 __u64 rsvd1;
634 __u64 rsvd2; 653 __u64 rsvd2;
diff --git a/include/drm/intel-gtt.h b/include/drm/intel-gtt.h
new file mode 100644
index 000000000000..9e343c0998b4
--- /dev/null
+++ b/include/drm/intel-gtt.h
@@ -0,0 +1,41 @@
1/* Common header for intel-gtt.ko and i915.ko */
2
3#ifndef _DRM_INTEL_GTT_H
4#define _DRM_INTEL_GTT_H
5
6const struct intel_gtt {
7 /* Size of memory reserved for graphics by the BIOS */
8 unsigned int stolen_size;
9 /* Total number of gtt entries. */
10 unsigned int gtt_total_entries;
11 /* Part of the gtt that is mappable by the cpu, for those chips where
12 * this is not the full gtt. */
13 unsigned int gtt_mappable_entries;
14 /* Whether i915 needs to use the dmar apis or not. */
15 unsigned int needs_dmar : 1;
16} *intel_gtt_get(void);
17
18void intel_gtt_chipset_flush(void);
19void intel_gtt_unmap_memory(struct scatterlist *sg_list, int num_sg);
20void intel_gtt_clear_range(unsigned int first_entry, unsigned int num_entries);
21int intel_gtt_map_memory(struct page **pages, unsigned int num_entries,
22 struct scatterlist **sg_list, int *num_sg);
23void intel_gtt_insert_sg_entries(struct scatterlist *sg_list,
24 unsigned int sg_len,
25 unsigned int pg_start,
26 unsigned int flags);
27void intel_gtt_insert_pages(unsigned int first_entry, unsigned int num_entries,
28 struct page **pages, unsigned int flags);
29
30/* Special gtt memory types */
31#define AGP_DCACHE_MEMORY 1
32#define AGP_PHYS_MEMORY 2
33
34/* New caching attributes for gen6/sandybridge */
35#define AGP_USER_CACHED_MEMORY_LLC_MLC (AGP_USER_TYPES + 2)
36#define AGP_USER_UNCACHED_MEMORY (AGP_USER_TYPES + 4)
37
38/* flag for GFDT type */
39#define AGP_USER_CACHED_MEMORY_GFDT (1 << 3)
40
41#endif
diff --git a/include/drm/mga_drm.h b/include/drm/mga_drm.h
index c16097f99be0..fca817009e13 100644
--- a/include/drm/mga_drm.h
+++ b/include/drm/mga_drm.h
@@ -107,7 +107,7 @@
107 */ 107 */
108#define MGA_NR_SAREA_CLIPRECTS 8 108#define MGA_NR_SAREA_CLIPRECTS 8
109 109
110/* 2 heaps (1 for card, 1 for agp), each divided into upto 128 110/* 2 heaps (1 for card, 1 for agp), each divided into up to 128
111 * regions, subject to a minimum region size of (1<<16) == 64k. 111 * regions, subject to a minimum region size of (1<<16) == 64k.
112 * 112 *
113 * Clients may subdivide regions internally, but when sharing between 113 * Clients may subdivide regions internally, but when sharing between
diff --git a/include/drm/nouveau_drm.h b/include/drm/nouveau_drm.h
index 01a714119506..5edd3a76fffa 100644
--- a/include/drm/nouveau_drm.h
+++ b/include/drm/nouveau_drm.h
@@ -71,15 +71,14 @@ struct drm_nouveau_gpuobj_free {
71#define NOUVEAU_GETPARAM_PCI_VENDOR 3 71#define NOUVEAU_GETPARAM_PCI_VENDOR 3
72#define NOUVEAU_GETPARAM_PCI_DEVICE 4 72#define NOUVEAU_GETPARAM_PCI_DEVICE 4
73#define NOUVEAU_GETPARAM_BUS_TYPE 5 73#define NOUVEAU_GETPARAM_BUS_TYPE 5
74#define NOUVEAU_GETPARAM_FB_PHYSICAL 6
75#define NOUVEAU_GETPARAM_AGP_PHYSICAL 7
76#define NOUVEAU_GETPARAM_FB_SIZE 8 74#define NOUVEAU_GETPARAM_FB_SIZE 8
77#define NOUVEAU_GETPARAM_AGP_SIZE 9 75#define NOUVEAU_GETPARAM_AGP_SIZE 9
78#define NOUVEAU_GETPARAM_PCI_PHYSICAL 10
79#define NOUVEAU_GETPARAM_CHIPSET_ID 11 76#define NOUVEAU_GETPARAM_CHIPSET_ID 11
80#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12 77#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
81#define NOUVEAU_GETPARAM_GRAPH_UNITS 13 78#define NOUVEAU_GETPARAM_GRAPH_UNITS 13
82#define NOUVEAU_GETPARAM_PTIMER_TIME 14 79#define NOUVEAU_GETPARAM_PTIMER_TIME 14
80#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
81#define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16
83struct drm_nouveau_getparam { 82struct drm_nouveau_getparam {
84 uint64_t param; 83 uint64_t param;
85 uint64_t value; 84 uint64_t value;
@@ -95,6 +94,13 @@ struct drm_nouveau_setparam {
95#define NOUVEAU_GEM_DOMAIN_GART (1 << 2) 94#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
96#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) 95#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
97 96
97#define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */
98#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
99#define NOUVEAU_GEM_TILE_16BPP 0x00000001
100#define NOUVEAU_GEM_TILE_32BPP 0x00000002
101#define NOUVEAU_GEM_TILE_ZETA 0x00000004
102#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
103
98struct drm_nouveau_gem_info { 104struct drm_nouveau_gem_info {
99 uint32_t handle; 105 uint32_t handle;
100 uint32_t domain; 106 uint32_t domain;
@@ -164,7 +170,6 @@ struct drm_nouveau_gem_pushbuf {
164}; 170};
165 171
166#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001 172#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
167#define NOUVEAU_GEM_CPU_PREP_NOBLOCK 0x00000002
168#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004 173#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
169struct drm_nouveau_gem_cpu_prep { 174struct drm_nouveau_gem_cpu_prep {
170 uint32_t handle; 175 uint32_t handle;
diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h
index 10f8b53bdd40..787f7b6fd622 100644
--- a/include/drm/radeon_drm.h
+++ b/include/drm/radeon_drm.h
@@ -641,7 +641,7 @@ typedef struct drm_radeon_vertex2 {
641} drm_radeon_vertex2_t; 641} drm_radeon_vertex2_t;
642 642
643/* v1.3 - obsoletes drm_radeon_vertex2 643/* v1.3 - obsoletes drm_radeon_vertex2
644 * - allows arbitarily large cliprect list 644 * - allows arbitrarily large cliprect list
645 * - allows updating of tcl packet, vector and scalar state 645 * - allows updating of tcl packet, vector and scalar state
646 * - allows memory-efficient description of state updates 646 * - allows memory-efficient description of state updates
647 * - allows state to be emitted without a primitive 647 * - allows state to be emitted without a primitive
@@ -906,6 +906,11 @@ struct drm_radeon_cs {
906#define RADEON_INFO_ACCEL_WORKING2 0x05 906#define RADEON_INFO_ACCEL_WORKING2 0x05
907#define RADEON_INFO_TILING_CONFIG 0x06 907#define RADEON_INFO_TILING_CONFIG 0x06
908#define RADEON_INFO_WANT_HYPERZ 0x07 908#define RADEON_INFO_WANT_HYPERZ 0x07
909#define RADEON_INFO_WANT_CMASK 0x08 /* get access to CMASK on r300 */
910#define RADEON_INFO_CLOCK_CRYSTAL_FREQ 0x09 /* clock crystal frequency */
911#define RADEON_INFO_NUM_BACKENDS 0x0a /* DB/backends for r600+ - need for OQ */
912#define RADEON_INFO_NUM_TILE_PIPES 0x0b /* tile pipes for r600+ */
913#define RADEON_INFO_FUSION_GART_WORKING 0x0c /* fusion writes to GTT were broken before this */
909 914
910struct drm_radeon_info { 915struct drm_radeon_info {
911 uint32_t request; 916 uint32_t request;
diff --git a/include/drm/savage_drm.h b/include/drm/savage_drm.h
index 4863cf6bf96f..818d49be2e6e 100644
--- a/include/drm/savage_drm.h
+++ b/include/drm/savage_drm.h
@@ -29,7 +29,7 @@
29#ifndef __SAVAGE_SAREA_DEFINES__ 29#ifndef __SAVAGE_SAREA_DEFINES__
30#define __SAVAGE_SAREA_DEFINES__ 30#define __SAVAGE_SAREA_DEFINES__
31 31
32/* 2 heaps (1 for card, 1 for agp), each divided into upto 128 32/* 2 heaps (1 for card, 1 for agp), each divided into up to 128
33 * regions, subject to a minimum region size of (1<<16) == 64k. 33 * regions, subject to a minimum region size of (1<<16) == 64k.
34 * 34 *
35 * Clients may subdivide regions internally, but when sharing between 35 * Clients may subdivide regions internally, but when sharing between
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 2040e6c4f172..62a0e4c4ceee 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -50,10 +50,10 @@ struct drm_mm_node;
50 * 50 *
51 * @fpfn: first valid page frame number to put the object 51 * @fpfn: first valid page frame number to put the object
52 * @lpfn: last valid page frame number to put the object 52 * @lpfn: last valid page frame number to put the object
53 * @num_placement: number of prefered placements 53 * @num_placement: number of preferred placements
54 * @placement: prefered placements 54 * @placement: preferred placements
55 * @num_busy_placement: number of prefered placements when need to evict buffer 55 * @num_busy_placement: number of preferred placements when need to evict buffer
56 * @busy_placement: prefered placements when need to evict buffer 56 * @busy_placement: preferred placements when need to evict buffer
57 * 57 *
58 * Structure indicating the placement you request for an object. 58 * Structure indicating the placement you request for an object.
59 */ 59 */
@@ -74,6 +74,8 @@ struct ttm_placement {
74 * @is_iomem: is this io memory ? 74 * @is_iomem: is this io memory ?
75 * @size: size in byte 75 * @size: size in byte
76 * @offset: offset from the base address 76 * @offset: offset from the base address
77 * @io_reserved_vm: The VM system has a refcount in @io_reserved_count
78 * @io_reserved_count: Refcounting the numbers of callers to ttm_mem_io_reserve
77 * 79 *
78 * Structure indicating the bus placement of an object. 80 * Structure indicating the bus placement of an object.
79 */ 81 */
@@ -83,7 +85,8 @@ struct ttm_bus_placement {
83 unsigned long size; 85 unsigned long size;
84 unsigned long offset; 86 unsigned long offset;
85 bool is_iomem; 87 bool is_iomem;
86 bool io_reserved; 88 bool io_reserved_vm;
89 uint64_t io_reserved_count;
87}; 90};
88 91
89 92
@@ -102,7 +105,8 @@ struct ttm_bus_placement {
102 */ 105 */
103 106
104struct ttm_mem_reg { 107struct ttm_mem_reg {
105 struct drm_mm_node *mm_node; 108 void *mm_node;
109 unsigned long start;
106 unsigned long size; 110 unsigned long size;
107 unsigned long num_pages; 111 unsigned long num_pages;
108 uint32_t page_alignment; 112 uint32_t page_alignment;
@@ -153,11 +157,10 @@ struct ttm_tt;
153 * keeps one refcount. When this refcount reaches zero, 157 * keeps one refcount. When this refcount reaches zero,
154 * the object is destroyed. 158 * the object is destroyed.
155 * @event_queue: Queue for processes waiting on buffer object status change. 159 * @event_queue: Queue for processes waiting on buffer object status change.
156 * @lock: spinlock protecting mostly synchronization members.
157 * @mem: structure describing current placement. 160 * @mem: structure describing current placement.
158 * @persistant_swap_storage: Usually the swap storage is deleted for buffers 161 * @persistent_swap_storage: Usually the swap storage is deleted for buffers
159 * pinned in physical memory. If this behaviour is not desired, this member 162 * pinned in physical memory. If this behaviour is not desired, this member
160 * holds a pointer to a persistant shmem object. 163 * holds a pointer to a persistent shmem object.
161 * @ttm: TTM structure holding system pages. 164 * @ttm: TTM structure holding system pages.
162 * @evicted: Whether the object was evicted without user-space knowing. 165 * @evicted: Whether the object was evicted without user-space knowing.
163 * @cpu_writes: For synchronization. Number of cpu writers. 166 * @cpu_writes: For synchronization. Number of cpu writers.
@@ -212,14 +215,13 @@ struct ttm_buffer_object {
212 struct kref kref; 215 struct kref kref;
213 struct kref list_kref; 216 struct kref list_kref;
214 wait_queue_head_t event_queue; 217 wait_queue_head_t event_queue;
215 spinlock_t lock;
216 218
217 /** 219 /**
218 * Members protected by the bo::reserved lock. 220 * Members protected by the bo::reserved lock.
219 */ 221 */
220 222
221 struct ttm_mem_reg mem; 223 struct ttm_mem_reg mem;
222 struct file *persistant_swap_storage; 224 struct file *persistent_swap_storage;
223 struct ttm_tt *ttm; 225 struct ttm_tt *ttm;
224 bool evicted; 226 bool evicted;
225 227
@@ -236,6 +238,7 @@ struct ttm_buffer_object {
236 struct list_head lru; 238 struct list_head lru;
237 struct list_head ddestroy; 239 struct list_head ddestroy;
238 struct list_head swap; 240 struct list_head swap;
241 struct list_head io_reserve_lru;
239 uint32_t val_seq; 242 uint32_t val_seq;
240 bool seq_valid; 243 bool seq_valid;
241 244
@@ -247,10 +250,10 @@ struct ttm_buffer_object {
247 atomic_t reserved; 250 atomic_t reserved;
248 251
249 /** 252 /**
250 * Members protected by the bo::lock 253 * Members protected by struct buffer_object_device::fence_lock
251 * In addition, setting sync_obj to anything else 254 * In addition, setting sync_obj to anything else
252 * than NULL requires bo::reserved to be held. This allows for 255 * than NULL requires bo::reserved to be held. This allows for
253 * checking NULL while reserved but not holding bo::lock. 256 * checking NULL while reserved but not holding the mentioned lock.
254 */ 257 */
255 258
256 void *sync_obj_arg; 259 void *sync_obj_arg;
@@ -363,6 +366,44 @@ extern int ttm_bo_validate(struct ttm_buffer_object *bo,
363 */ 366 */
364extern void ttm_bo_unref(struct ttm_buffer_object **bo); 367extern void ttm_bo_unref(struct ttm_buffer_object **bo);
365 368
369
370/**
371 * ttm_bo_list_ref_sub
372 *
373 * @bo: The buffer object.
374 * @count: The number of references with which to decrease @bo::list_kref;
375 * @never_free: The refcount should not reach zero with this operation.
376 *
377 * Release @count lru list references to this buffer object.
378 */
379extern void ttm_bo_list_ref_sub(struct ttm_buffer_object *bo, int count,
380 bool never_free);
381
382/**
383 * ttm_bo_add_to_lru
384 *
385 * @bo: The buffer object.
386 *
387 * Add this bo to the relevant mem type lru and, if it's backed by
388 * system pages (ttms) to the swap list.
389 * This function must be called with struct ttm_bo_global::lru_lock held, and
390 * is typically called immediately prior to unreserving a bo.
391 */
392extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
393
394/**
395 * ttm_bo_del_from_lru
396 *
397 * @bo: The buffer object.
398 *
399 * Remove this bo from all lru lists used to lookup and reserve an object.
400 * This function must be called with struct ttm_bo_global::lru_lock held,
401 * and is usually called just immediately after the bo has been reserved to
402 * avoid recursive reservation from lru lists.
403 */
404extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
405
406
366/** 407/**
367 * ttm_bo_lock_delayed_workqueue 408 * ttm_bo_lock_delayed_workqueue
368 * 409 *
@@ -418,9 +459,9 @@ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
418 * user buffer object. 459 * user buffer object.
419 * @interruptible: If needing to sleep to wait for GPU resources, 460 * @interruptible: If needing to sleep to wait for GPU resources,
420 * sleep interruptible. 461 * sleep interruptible.
421 * @persistant_swap_storage: Usually the swap storage is deleted for buffers 462 * @persistent_swap_storage: Usually the swap storage is deleted for buffers
422 * pinned in physical memory. If this behaviour is not desired, this member 463 * pinned in physical memory. If this behaviour is not desired, this member
423 * holds a pointer to a persistant shmem object. Typically, this would 464 * holds a pointer to a persistent shmem object. Typically, this would
424 * point to the shmem object backing a GEM object if TTM is used to back a 465 * point to the shmem object backing a GEM object if TTM is used to back a
425 * GEM user interface. 466 * GEM user interface.
426 * @acc_size: Accounted size for this object. 467 * @acc_size: Accounted size for this object.
@@ -431,6 +472,10 @@ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
431 * together with the @destroy function, 472 * together with the @destroy function,
432 * enables driver-specific objects derived from a ttm_buffer_object. 473 * enables driver-specific objects derived from a ttm_buffer_object.
433 * On successful return, the object kref and list_kref are set to 1. 474 * On successful return, the object kref and list_kref are set to 1.
475 * If a failure occurs, the function will call the @destroy function, or
476 * kfree() if @destroy is NULL. Thus, after a failure, dereferencing @bo is
477 * illegal and will likely cause memory corruption.
478 *
434 * Returns 479 * Returns
435 * -ENOMEM: Out of memory. 480 * -ENOMEM: Out of memory.
436 * -EINVAL: Invalid placement flags. 481 * -EINVAL: Invalid placement flags.
@@ -445,7 +490,7 @@ extern int ttm_bo_init(struct ttm_bo_device *bdev,
445 uint32_t page_alignment, 490 uint32_t page_alignment,
446 unsigned long buffer_start, 491 unsigned long buffer_start,
447 bool interrubtible, 492 bool interrubtible,
448 struct file *persistant_swap_storage, 493 struct file *persistent_swap_storage,
449 size_t acc_size, 494 size_t acc_size,
450 void (*destroy) (struct ttm_buffer_object *)); 495 void (*destroy) (struct ttm_buffer_object *));
451/** 496/**
@@ -461,9 +506,9 @@ extern int ttm_bo_init(struct ttm_bo_device *bdev,
461 * user buffer object. 506 * user buffer object.
462 * @interruptible: If needing to sleep while waiting for GPU resources, 507 * @interruptible: If needing to sleep while waiting for GPU resources,
463 * sleep interruptible. 508 * sleep interruptible.
464 * @persistant_swap_storage: Usually the swap storage is deleted for buffers 509 * @persistent_swap_storage: Usually the swap storage is deleted for buffers
465 * pinned in physical memory. If this behaviour is not desired, this member 510 * pinned in physical memory. If this behaviour is not desired, this member
466 * holds a pointer to a persistant shmem object. Typically, this would 511 * holds a pointer to a persistent shmem object. Typically, this would
467 * point to the shmem object backing a GEM object if TTM is used to back a 512 * point to the shmem object backing a GEM object if TTM is used to back a
468 * GEM user interface. 513 * GEM user interface.
469 * @p_bo: On successful completion *p_bo points to the created object. 514 * @p_bo: On successful completion *p_bo points to the created object.
@@ -483,7 +528,7 @@ extern int ttm_bo_create(struct ttm_bo_device *bdev,
483 uint32_t page_alignment, 528 uint32_t page_alignment,
484 unsigned long buffer_start, 529 unsigned long buffer_start,
485 bool interruptible, 530 bool interruptible,
486 struct file *persistant_swap_storage, 531 struct file *persistent_swap_storage,
487 struct ttm_buffer_object **p_bo); 532 struct ttm_buffer_object **p_bo);
488 533
489/** 534/**
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index b87504235f18..09af2d746d1c 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -50,13 +50,15 @@ struct ttm_backend_func {
50 * @pages: Array of pointers to ttm pages. 50 * @pages: Array of pointers to ttm pages.
51 * @dummy_read_page: Page to be used instead of NULL pages in the 51 * @dummy_read_page: Page to be used instead of NULL pages in the
52 * array @pages. 52 * array @pages.
53 * @dma_addrs: Array of DMA (bus) address of the ttm pages.
53 * 54 *
54 * Populate the backend with ttm pages. Depending on the backend, 55 * Populate the backend with ttm pages. Depending on the backend,
55 * it may or may not copy the @pages array. 56 * it may or may not copy the @pages array.
56 */ 57 */
57 int (*populate) (struct ttm_backend *backend, 58 int (*populate) (struct ttm_backend *backend,
58 unsigned long num_pages, struct page **pages, 59 unsigned long num_pages, struct page **pages,
59 struct page *dummy_read_page); 60 struct page *dummy_read_page,
61 dma_addr_t *dma_addrs);
60 /** 62 /**
61 * struct ttm_backend_func member clear 63 * struct ttm_backend_func member clear
62 * 64 *
@@ -120,7 +122,7 @@ struct ttm_backend {
120#define TTM_PAGE_FLAG_USER_DIRTY (1 << 2) 122#define TTM_PAGE_FLAG_USER_DIRTY (1 << 2)
121#define TTM_PAGE_FLAG_WRITE (1 << 3) 123#define TTM_PAGE_FLAG_WRITE (1 << 3)
122#define TTM_PAGE_FLAG_SWAPPED (1 << 4) 124#define TTM_PAGE_FLAG_SWAPPED (1 << 4)
123#define TTM_PAGE_FLAG_PERSISTANT_SWAP (1 << 5) 125#define TTM_PAGE_FLAG_PERSISTENT_SWAP (1 << 5)
124#define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6) 126#define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6)
125#define TTM_PAGE_FLAG_DMA32 (1 << 7) 127#define TTM_PAGE_FLAG_DMA32 (1 << 7)
126 128
@@ -149,6 +151,7 @@ enum ttm_caching_state {
149 * @swap_storage: Pointer to shmem struct file for swap storage. 151 * @swap_storage: Pointer to shmem struct file for swap storage.
150 * @caching_state: The current caching state of the pages. 152 * @caching_state: The current caching state of the pages.
151 * @state: The current binding state of the pages. 153 * @state: The current binding state of the pages.
154 * @dma_address: The DMA (bus) addresses of the pages (if TTM_PAGE_FLAG_DMA32)
152 * 155 *
153 * This is a structure holding the pages, caching- and aperture binding 156 * This is a structure holding the pages, caching- and aperture binding
154 * status for a buffer object that isn't backed by fixed (VRAM / AGP) 157 * status for a buffer object that isn't backed by fixed (VRAM / AGP)
@@ -173,12 +176,97 @@ struct ttm_tt {
173 tt_unbound, 176 tt_unbound,
174 tt_unpopulated, 177 tt_unpopulated,
175 } state; 178 } state;
179 dma_addr_t *dma_address;
176}; 180};
177 181
178#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ 182#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */
179#define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ 183#define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */
180#define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ 184#define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */
181 185
186struct ttm_mem_type_manager;
187
188struct ttm_mem_type_manager_func {
189 /**
190 * struct ttm_mem_type_manager member init
191 *
192 * @man: Pointer to a memory type manager.
193 * @p_size: Implementation dependent, but typically the size of the
194 * range to be managed in pages.
195 *
196 * Called to initialize a private range manager. The function is
197 * expected to initialize the man::priv member.
198 * Returns 0 on success, negative error code on failure.
199 */
200 int (*init)(struct ttm_mem_type_manager *man, unsigned long p_size);
201
202 /**
203 * struct ttm_mem_type_manager member takedown
204 *
205 * @man: Pointer to a memory type manager.
206 *
207 * Called to undo the setup done in init. All allocated resources
208 * should be freed.
209 */
210 int (*takedown)(struct ttm_mem_type_manager *man);
211
212 /**
213 * struct ttm_mem_type_manager member get_node
214 *
215 * @man: Pointer to a memory type manager.
216 * @bo: Pointer to the buffer object we're allocating space for.
217 * @placement: Placement details.
218 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
219 *
220 * This function should allocate space in the memory type managed
221 * by @man. Placement details if
222 * applicable are given by @placement. If successful,
223 * @mem::mm_node should be set to a non-null value, and
224 * @mem::start should be set to a value identifying the beginning
225 * of the range allocated, and the function should return zero.
226 * If the memory region accommodate the buffer object, @mem::mm_node
227 * should be set to NULL, and the function should return 0.
228 * If a system error occurred, preventing the request to be fulfilled,
229 * the function should return a negative error code.
230 *
231 * Note that @mem::mm_node will only be dereferenced by
232 * struct ttm_mem_type_manager functions and optionally by the driver,
233 * which has knowledge of the underlying type.
234 *
235 * This function may not be called from within atomic context, so
236 * an implementation can and must use either a mutex or a spinlock to
237 * protect any data structures managing the space.
238 */
239 int (*get_node)(struct ttm_mem_type_manager *man,
240 struct ttm_buffer_object *bo,
241 struct ttm_placement *placement,
242 struct ttm_mem_reg *mem);
243
244 /**
245 * struct ttm_mem_type_manager member put_node
246 *
247 * @man: Pointer to a memory type manager.
248 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
249 *
250 * This function frees memory type resources previously allocated
251 * and that are identified by @mem::mm_node and @mem::start. May not
252 * be called from within atomic context.
253 */
254 void (*put_node)(struct ttm_mem_type_manager *man,
255 struct ttm_mem_reg *mem);
256
257 /**
258 * struct ttm_mem_type_manager member debug
259 *
260 * @man: Pointer to a memory type manager.
261 * @prefix: Prefix to be used in printout to identify the caller.
262 *
263 * This function is called to print out the state of the memory
264 * type manager to aid debugging of out-of-memory conditions.
265 * It may not be called from within atomic context.
266 */
267 void (*debug)(struct ttm_mem_type_manager *man, const char *prefix);
268};
269
182/** 270/**
183 * struct ttm_mem_type_manager 271 * struct ttm_mem_type_manager
184 * 272 *
@@ -193,17 +281,24 @@ struct ttm_tt {
193 * as defined in ttm_placement_common.h 281 * as defined in ttm_placement_common.h
194 * @default_caching: The default caching policy used for a buffer object 282 * @default_caching: The default caching policy used for a buffer object
195 * placed in this memory type if the user doesn't provide one. 283 * placed in this memory type if the user doesn't provide one.
196 * @manager: The range manager used for this memory type. FIXME: If the aperture 284 * @func: structure pointer implementing the range manager. See above
197 * has a page size different from the underlying system, the granularity 285 * @priv: Driver private closure for @func.
198 * of this manager should take care of this. But the range allocating code 286 * @io_reserve_mutex: Mutex optionally protecting shared io_reserve structures
199 * in ttm_bo.c needs to be modified for this. 287 * @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions
288 * reserved by the TTM vm system.
289 * @io_reserve_lru: Optional lru list for unreserving io mem regions.
290 * @io_reserve_fastpath: Only use bdev::driver::io_mem_reserve to obtain
291 * static information. bdev::driver::io_mem_free is never used.
200 * @lru: The lru list for this memory type. 292 * @lru: The lru list for this memory type.
201 * 293 *
202 * This structure is used to identify and manage memory types for a device. 294 * This structure is used to identify and manage memory types for a device.
203 * It's set up by the ttm_bo_driver::init_mem_type method. 295 * It's set up by the ttm_bo_driver::init_mem_type method.
204 */ 296 */
205 297
298
299
206struct ttm_mem_type_manager { 300struct ttm_mem_type_manager {
301 struct ttm_bo_device *bdev;
207 302
208 /* 303 /*
209 * No protection. Constant from start. 304 * No protection. Constant from start.
@@ -216,14 +311,22 @@ struct ttm_mem_type_manager {
216 uint64_t size; 311 uint64_t size;
217 uint32_t available_caching; 312 uint32_t available_caching;
218 uint32_t default_caching; 313 uint32_t default_caching;
314 const struct ttm_mem_type_manager_func *func;
315 void *priv;
316 struct mutex io_reserve_mutex;
317 bool use_io_reserve_lru;
318 bool io_reserve_fastpath;
319
320 /*
321 * Protected by @io_reserve_mutex:
322 */
323
324 struct list_head io_reserve_lru;
219 325
220 /* 326 /*
221 * Protected by the bdev->lru_lock. 327 * Protected by the global->lru_lock.
222 * TODO: Consider one lru_lock per ttm_mem_type_manager.
223 * Plays ill with list removal, though.
224 */ 328 */
225 329
226 struct drm_mm manager;
227 struct list_head lru; 330 struct list_head lru;
228}; 331};
229 332
@@ -426,9 +529,12 @@ struct ttm_bo_global {
426 * 529 *
427 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver. 530 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
428 * @man: An array of mem_type_managers. 531 * @man: An array of mem_type_managers.
532 * @fence_lock: Protects the synchronizing members on *all* bos belonging
533 * to this device.
429 * @addr_space_mm: Range manager for the device address space. 534 * @addr_space_mm: Range manager for the device address space.
430 * lru_lock: Spinlock that protects the buffer+device lru lists and 535 * lru_lock: Spinlock that protects the buffer+device lru lists and
431 * ddestroy lists. 536 * ddestroy lists.
537 * @val_seq: Current validation sequence.
432 * @nice_mode: Try nicely to wait for buffer idle when cleaning a manager. 538 * @nice_mode: Try nicely to wait for buffer idle when cleaning a manager.
433 * If a GPU lockup has been detected, this is forced to 0. 539 * If a GPU lockup has been detected, this is forced to 0.
434 * @dev_mapping: A pointer to the struct address_space representing the 540 * @dev_mapping: A pointer to the struct address_space representing the
@@ -447,6 +553,7 @@ struct ttm_bo_device {
447 struct ttm_bo_driver *driver; 553 struct ttm_bo_driver *driver;
448 rwlock_t vm_lock; 554 rwlock_t vm_lock;
449 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; 555 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
556 spinlock_t fence_lock;
450 /* 557 /*
451 * Protected by the vm lock. 558 * Protected by the vm lock.
452 */ 559 */
@@ -457,6 +564,7 @@ struct ttm_bo_device {
457 * Protected by the global:lru lock. 564 * Protected by the global:lru lock.
458 */ 565 */
459 struct list_head ddestroy; 566 struct list_head ddestroy;
567 uint32_t val_seq;
460 568
461 /* 569 /*
462 * Protected by load / firstopen / lastclose /unload sync. 570 * Protected by load / firstopen / lastclose /unload sync.
@@ -606,7 +714,7 @@ extern void ttm_tt_cache_flush(struct page *pages[], unsigned long num_pages);
606 */ 714 */
607extern int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement); 715extern int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement);
608extern int ttm_tt_swapout(struct ttm_tt *ttm, 716extern int ttm_tt_swapout(struct ttm_tt *ttm,
609 struct file *persistant_swap_storage); 717 struct file *persistent_swap_storage);
610 718
611/* 719/*
612 * ttm_bo.c 720 * ttm_bo.c
@@ -649,6 +757,12 @@ extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
649 struct ttm_mem_reg *mem, 757 struct ttm_mem_reg *mem,
650 bool interruptible, 758 bool interruptible,
651 bool no_wait_reserve, bool no_wait_gpu); 759 bool no_wait_reserve, bool no_wait_gpu);
760
761extern void ttm_bo_mem_put(struct ttm_buffer_object *bo,
762 struct ttm_mem_reg *mem);
763extern void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo,
764 struct ttm_mem_reg *mem);
765
652/** 766/**
653 * ttm_bo_wait_for_cpu 767 * ttm_bo_wait_for_cpu
654 * 768 *
@@ -663,31 +777,6 @@ extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
663 777
664extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait); 778extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait);
665 779
666/**
667 * ttm_bo_pci_offset - Get the PCI offset for the buffer object memory.
668 *
669 * @bo Pointer to a struct ttm_buffer_object.
670 * @bus_base On return the base of the PCI region
671 * @bus_offset On return the byte offset into the PCI region
672 * @bus_size On return the byte size of the buffer object or zero if
673 * the buffer object memory is not accessible through a PCI region.
674 *
675 * Returns:
676 * -EINVAL if the buffer object is currently not mappable.
677 * 0 otherwise.
678 */
679
680extern int ttm_bo_pci_offset(struct ttm_bo_device *bdev,
681 struct ttm_mem_reg *mem,
682 unsigned long *bus_base,
683 unsigned long *bus_offset,
684 unsigned long *bus_size);
685
686extern int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
687 struct ttm_mem_reg *mem);
688extern void ttm_mem_io_free(struct ttm_bo_device *bdev,
689 struct ttm_mem_reg *mem);
690
691extern void ttm_bo_global_release(struct drm_global_reference *ref); 780extern void ttm_bo_global_release(struct drm_global_reference *ref);
692extern int ttm_bo_global_init(struct drm_global_reference *ref); 781extern int ttm_bo_global_init(struct drm_global_reference *ref);
693 782
@@ -720,6 +809,22 @@ extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
720extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo); 809extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo);
721 810
722/** 811/**
812 * ttm_bo_unmap_virtual
813 *
814 * @bo: tear down the virtual mappings for this BO
815 *
816 * The caller must take ttm_mem_io_lock before calling this function.
817 */
818extern void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo);
819
820extern int ttm_mem_io_reserve_vm(struct ttm_buffer_object *bo);
821extern void ttm_mem_io_free_vm(struct ttm_buffer_object *bo);
822extern int ttm_mem_io_lock(struct ttm_mem_type_manager *man,
823 bool interruptible);
824extern void ttm_mem_io_unlock(struct ttm_mem_type_manager *man);
825
826
827/**
723 * ttm_bo_reserve: 828 * ttm_bo_reserve:
724 * 829 *
725 * @bo: A pointer to a struct ttm_buffer_object. 830 * @bo: A pointer to a struct ttm_buffer_object.
@@ -736,7 +841,7 @@ extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo);
736 * different order, either by will or as a result of a buffer being evicted 841 * different order, either by will or as a result of a buffer being evicted
737 * to make room for a buffer already reserved. (Buffers are reserved before 842 * to make room for a buffer already reserved. (Buffers are reserved before
738 * they are evicted). The following algorithm prevents such deadlocks from 843 * they are evicted). The following algorithm prevents such deadlocks from
739 * occuring: 844 * occurring:
740 * 1) Buffers are reserved with the lru spinlock held. Upon successful 845 * 1) Buffers are reserved with the lru spinlock held. Upon successful
741 * reservation they are removed from the lru list. This stops a reserved buffer 846 * reservation they are removed from the lru list. This stops a reserved buffer
742 * from being evicted. However the lru spinlock is released between the time 847 * from being evicted. However the lru spinlock is released between the time
@@ -769,11 +874,44 @@ extern void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo);
769 * try again. (only if use_sequence == 1). 874 * try again. (only if use_sequence == 1).
770 * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by 875 * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
771 * a signal. Release all buffer reservations and return to user-space. 876 * a signal. Release all buffer reservations and return to user-space.
877 * -EBUSY: The function needed to sleep, but @no_wait was true
878 * -EDEADLK: Bo already reserved using @sequence. This error code will only
879 * be returned if @use_sequence is set to true.
772 */ 880 */
773extern int ttm_bo_reserve(struct ttm_buffer_object *bo, 881extern int ttm_bo_reserve(struct ttm_buffer_object *bo,
774 bool interruptible, 882 bool interruptible,
775 bool no_wait, bool use_sequence, uint32_t sequence); 883 bool no_wait, bool use_sequence, uint32_t sequence);
776 884
885
886/**
887 * ttm_bo_reserve_locked:
888 *
889 * @bo: A pointer to a struct ttm_buffer_object.
890 * @interruptible: Sleep interruptible if waiting.
891 * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY.
892 * @use_sequence: If @bo is already reserved, Only sleep waiting for
893 * it to become unreserved if @sequence < (@bo)->sequence.
894 *
895 * Must be called with struct ttm_bo_global::lru_lock held,
896 * and will not remove reserved buffers from the lru lists.
897 * The function may release the LRU spinlock if it needs to sleep.
898 * Otherwise identical to ttm_bo_reserve.
899 *
900 * Returns:
901 * -EAGAIN: The reservation may cause a deadlock.
902 * Release all buffer reservations, wait for @bo to become unreserved and
903 * try again. (only if use_sequence == 1).
904 * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
905 * a signal. Release all buffer reservations and return to user-space.
906 * -EBUSY: The function needed to sleep, but @no_wait was true
907 * -EDEADLK: Bo already reserved using @sequence. This error code will only
908 * be returned if @use_sequence is set to true.
909 */
910extern int ttm_bo_reserve_locked(struct ttm_buffer_object *bo,
911 bool interruptible,
912 bool no_wait, bool use_sequence,
913 uint32_t sequence);
914
777/** 915/**
778 * ttm_bo_unreserve 916 * ttm_bo_unreserve
779 * 917 *
@@ -784,6 +922,16 @@ extern int ttm_bo_reserve(struct ttm_buffer_object *bo,
784extern void ttm_bo_unreserve(struct ttm_buffer_object *bo); 922extern void ttm_bo_unreserve(struct ttm_buffer_object *bo);
785 923
786/** 924/**
925 * ttm_bo_unreserve_locked
926 *
927 * @bo: A pointer to a struct ttm_buffer_object.
928 *
929 * Unreserve a previous reservation of @bo.
930 * Needs to be called with struct ttm_bo_global::lru_lock held.
931 */
932extern void ttm_bo_unreserve_locked(struct ttm_buffer_object *bo);
933
934/**
787 * ttm_bo_wait_unreserved 935 * ttm_bo_wait_unreserved
788 * 936 *
789 * @bo: A pointer to a struct ttm_buffer_object. 937 * @bo: A pointer to a struct ttm_buffer_object.
@@ -891,6 +1039,8 @@ extern int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
891 */ 1039 */
892extern pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); 1040extern pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
893 1041
1042extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
1043
894#if (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) 1044#if (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
895#define TTM_HAS_AGP 1045#define TTM_HAS_AGP
896#include <linux/agp_backend.h> 1046#include <linux/agp_backend.h>
diff --git a/include/drm/ttm/ttm_execbuf_util.h b/include/drm/ttm/ttm_execbuf_util.h
index cd2c475da9ea..26cc7f9ffa41 100644
--- a/include/drm/ttm/ttm_execbuf_util.h
+++ b/include/drm/ttm/ttm_execbuf_util.h
@@ -41,7 +41,10 @@
41 * @bo: refcounted buffer object pointer. 41 * @bo: refcounted buffer object pointer.
42 * @new_sync_obj_arg: New sync_obj_arg for @bo, to be used once 42 * @new_sync_obj_arg: New sync_obj_arg for @bo, to be used once
43 * adding a new sync object. 43 * adding a new sync object.
44 * @reservied: Indicates whether @bo has been reserved for validation. 44 * @reserved: Indicates whether @bo has been reserved for validation.
45 * @removed: Indicates whether @bo has been removed from lru lists.
46 * @put_count: Number of outstanding references on bo::list_kref.
47 * @old_sync_obj: Pointer to a sync object about to be unreferenced
45 */ 48 */
46 49
47struct ttm_validate_buffer { 50struct ttm_validate_buffer {
@@ -49,6 +52,9 @@ struct ttm_validate_buffer {
49 struct ttm_buffer_object *bo; 52 struct ttm_buffer_object *bo;
50 void *new_sync_obj_arg; 53 void *new_sync_obj_arg;
51 bool reserved; 54 bool reserved;
55 bool removed;
56 int put_count;
57 void *old_sync_obj;
52}; 58};
53 59
54/** 60/**
@@ -66,7 +72,6 @@ extern void ttm_eu_backoff_reservation(struct list_head *list);
66 * function ttm_eu_reserve_buffers 72 * function ttm_eu_reserve_buffers
67 * 73 *
68 * @list: thread private list of ttm_validate_buffer structs. 74 * @list: thread private list of ttm_validate_buffer structs.
69 * @val_seq: A unique sequence number.
70 * 75 *
71 * Tries to reserve bos pointed to by the list entries for validation. 76 * Tries to reserve bos pointed to by the list entries for validation.
72 * If the function returns 0, all buffers are marked as "unfenced", 77 * If the function returns 0, all buffers are marked as "unfenced",
@@ -88,7 +93,7 @@ extern void ttm_eu_backoff_reservation(struct list_head *list);
88 * has failed. 93 * has failed.
89 */ 94 */
90 95
91extern int ttm_eu_reserve_buffers(struct list_head *list, uint32_t val_seq); 96extern int ttm_eu_reserve_buffers(struct list_head *list);
92 97
93/** 98/**
94 * function ttm_eu_fence_buffer_objects. 99 * function ttm_eu_fence_buffer_objects.
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
index 116821448c38..8062890f725e 100644
--- a/include/drm/ttm/ttm_page_alloc.h
+++ b/include/drm/ttm/ttm_page_alloc.h
@@ -36,11 +36,13 @@
36 * @flags: ttm flags for page allocation. 36 * @flags: ttm flags for page allocation.
37 * @cstate: ttm caching state for the page. 37 * @cstate: ttm caching state for the page.
38 * @count: number of pages to allocate. 38 * @count: number of pages to allocate.
39 * @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set).
39 */ 40 */
40int ttm_get_pages(struct list_head *pages, 41int ttm_get_pages(struct list_head *pages,
41 int flags, 42 int flags,
42 enum ttm_caching_state cstate, 43 enum ttm_caching_state cstate,
43 unsigned count); 44 unsigned count,
45 dma_addr_t *dma_address);
44/** 46/**
45 * Put linked list of pages to pool. 47 * Put linked list of pages to pool.
46 * 48 *
@@ -49,11 +51,13 @@ int ttm_get_pages(struct list_head *pages,
49 * count. 51 * count.
50 * @flags: ttm flags for page allocation. 52 * @flags: ttm flags for page allocation.
51 * @cstate: ttm caching state. 53 * @cstate: ttm caching state.
54 * @dma_address: The DMA (bus) address of pages (if TTM_PAGE_FLAG_DMA32 set).
52 */ 55 */
53void ttm_put_pages(struct list_head *pages, 56void ttm_put_pages(struct list_head *pages,
54 unsigned page_count, 57 unsigned page_count,
55 int flags, 58 int flags,
56 enum ttm_caching_state cstate); 59 enum ttm_caching_state cstate,
60 dma_addr_t *dma_address);
57/** 61/**
58 * Initialize pool allocator. 62 * Initialize pool allocator.
59 */ 63 */
diff --git a/include/drm/vmwgfx_drm.h b/include/drm/vmwgfx_drm.h
index 4d0842391edc..5c36432d9ce5 100644
--- a/include/drm/vmwgfx_drm.h
+++ b/include/drm/vmwgfx_drm.h
@@ -72,6 +72,7 @@
72#define DRM_VMW_PARAM_FIFO_OFFSET 3 72#define DRM_VMW_PARAM_FIFO_OFFSET 3
73#define DRM_VMW_PARAM_HW_CAPS 4 73#define DRM_VMW_PARAM_HW_CAPS 4
74#define DRM_VMW_PARAM_FIFO_CAPS 5 74#define DRM_VMW_PARAM_FIFO_CAPS 5
75#define DRM_VMW_PARAM_MAX_FB_SIZE 6
75 76
76/** 77/**
77 * struct drm_vmw_getparam_arg 78 * struct drm_vmw_getparam_arg
@@ -591,7 +592,7 @@ struct drm_vmw_stream_arg {
591/** 592/**
592 * DRM_VMW_UPDATE_LAYOUT - Update layout 593 * DRM_VMW_UPDATE_LAYOUT - Update layout
593 * 594 *
594 * Updates the prefered modes and connection status for connectors. The 595 * Updates the preferred modes and connection status for connectors. The
595 * command conisits of one drm_vmw_update_layout_arg pointing out a array 596 * command conisits of one drm_vmw_update_layout_arg pointing out a array
596 * of num_outputs drm_vmw_rect's. 597 * of num_outputs drm_vmw_rect's.
597 */ 598 */
diff --git a/include/keys/ceph-type.h b/include/keys/ceph-type.h
new file mode 100644
index 000000000000..f69c4ac197a0
--- /dev/null
+++ b/include/keys/ceph-type.h
@@ -0,0 +1,8 @@
1#ifndef _KEYS_CEPH_TYPE_H
2#define _KEYS_CEPH_TYPE_H
3
4#include <linux/key.h>
5
6extern struct key_type key_type_ceph;
7
8#endif
diff --git a/include/keys/encrypted-type.h b/include/keys/encrypted-type.h
new file mode 100644
index 000000000000..95855017a32b
--- /dev/null
+++ b/include/keys/encrypted-type.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2010 IBM Corporation
3 * Author: Mimi Zohar <zohar@us.ibm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
8 */
9
10#ifndef _KEYS_ENCRYPTED_TYPE_H
11#define _KEYS_ENCRYPTED_TYPE_H
12
13#include <linux/key.h>
14#include <linux/rcupdate.h>
15
16struct encrypted_key_payload {
17 struct rcu_head rcu;
18 char *master_desc; /* datablob: master key name */
19 char *datalen; /* datablob: decrypted key length */
20 u8 *iv; /* datablob: iv */
21 u8 *encrypted_data; /* datablob: encrypted data */
22 unsigned short datablob_len; /* length of datablob */
23 unsigned short decrypted_datalen; /* decrypted data length */
24 u8 decrypted_data[0]; /* decrypted data + datablob + hmac */
25};
26
27extern struct key_type key_type_encrypted;
28
29#endif /* _KEYS_ENCRYPTED_TYPE_H */
diff --git a/include/keys/rxrpc-type.h b/include/keys/rxrpc-type.h
index 5cb86c307f5d..fc4875433817 100644
--- a/include/keys/rxrpc-type.h
+++ b/include/keys/rxrpc-type.h
@@ -99,7 +99,6 @@ struct rxrpc_key_token {
99 * structure of raw payloads passed to add_key() or instantiate key 99 * structure of raw payloads passed to add_key() or instantiate key
100 */ 100 */
101struct rxrpc_key_data_v1 { 101struct rxrpc_key_data_v1 {
102 u32 kif_version; /* 1 */
103 u16 security_index; 102 u16 security_index;
104 u16 ticket_length; 103 u16 ticket_length;
105 u32 expiry; /* time_t */ 104 u32 expiry; /* time_t */
diff --git a/include/keys/trusted-type.h b/include/keys/trusted-type.h
new file mode 100644
index 000000000000..56f82e5c9975
--- /dev/null
+++ b/include/keys/trusted-type.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2010 IBM Corporation
3 * Author: David Safford <safford@us.ibm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
8 */
9
10#ifndef _KEYS_TRUSTED_TYPE_H
11#define _KEYS_TRUSTED_TYPE_H
12
13#include <linux/key.h>
14#include <linux/rcupdate.h>
15
16#define MIN_KEY_SIZE 32
17#define MAX_KEY_SIZE 128
18#define MAX_BLOB_SIZE 320
19
20struct trusted_key_payload {
21 struct rcu_head rcu;
22 unsigned int key_len;
23 unsigned int blob_len;
24 unsigned char migratable;
25 unsigned char key[MAX_KEY_SIZE + 1];
26 unsigned char blob[MAX_BLOB_SIZE];
27};
28
29extern struct key_type key_type_trusted;
30
31#endif /* _KEYS_TRUSTED_TYPE_H */
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 4e8ea8c8ec1e..01f636275057 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -1,8 +1,10 @@
1header-y += byteorder/ 1header-y += byteorder/
2header-y += can/ 2header-y += can/
3header-y += caif/
3header-y += dvb/ 4header-y += dvb/
4header-y += hdlc/ 5header-y += hdlc/
5header-y += isdn/ 6header-y += isdn/
7header-y += mmc/
6header-y += nfsd/ 8header-y += nfsd/
7header-y += raid/ 9header-y += raid/
8header-y += spi/ 10header-y += spi/
@@ -20,15 +22,18 @@ header-y += wimax/
20objhdr-y += version.h 22objhdr-y += version.h
21 23
22ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \ 24ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
23 $(srctree)/include/asm-$(SRCARCH)/a.out.h),) 25 $(srctree)/include/asm-$(SRCARCH)/a.out.h \
26 $(INSTALL_HDR_PATH)/include/asm-*/a.out.h),)
24header-y += a.out.h 27header-y += a.out.h
25endif 28endif
26ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \ 29ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
27 $(srctree)/include/asm-$(SRCARCH)/kvm.h),) 30 $(srctree)/include/asm-$(SRCARCH)/kvm.h \
31 $(INSTALL_HDR_PATH)/include/asm-*/kvm.h),)
28header-y += kvm.h 32header-y += kvm.h
29endif 33endif
30ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \ 34ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
31 $(srctree)/include/asm-$(SRCARCH)/kvm_para.h),) 35 $(srctree)/include/asm-$(SRCARCH)/kvm_para.h \
36 $(INSTALL_HDR_PATH)/include/asm-*/kvm_para.h),)
32header-y += kvm_para.h 37header-y += kvm_para.h
33endif 38endif
34 39
@@ -118,6 +123,7 @@ header-y += eventpoll.h
118header-y += ext2_fs.h 123header-y += ext2_fs.h
119header-y += fadvise.h 124header-y += fadvise.h
120header-y += falloc.h 125header-y += falloc.h
126header-y += fanotify.h
121header-y += fb.h 127header-y += fb.h
122header-y += fcntl.h 128header-y += fcntl.h
123header-y += fd.h 129header-y += fd.h
@@ -154,6 +160,7 @@ header-y += icmpv6.h
154header-y += if.h 160header-y += if.h
155header-y += if_addr.h 161header-y += if_addr.h
156header-y += if_addrlabel.h 162header-y += if_addrlabel.h
163header-y += if_alg.h
157header-y += if_arcnet.h 164header-y += if_arcnet.h
158header-y += if_arp.h 165header-y += if_arp.h
159header-y += if_bonding.h 166header-y += if_bonding.h
@@ -227,6 +234,7 @@ header-y += magic.h
227header-y += major.h 234header-y += major.h
228header-y += map_to_7segment.h 235header-y += map_to_7segment.h
229header-y += matroxfb.h 236header-y += matroxfb.h
237header-y += media.h
230header-y += mempolicy.h 238header-y += mempolicy.h
231header-y += meye.h 239header-y += meye.h
232header-y += mii.h 240header-y += mii.h
@@ -270,6 +278,7 @@ header-y += nfsacl.h
270header-y += nl80211.h 278header-y += nl80211.h
271header-y += nubus.h 279header-y += nubus.h
272header-y += nvram.h 280header-y += nvram.h
281header-y += omap3isp.h
273header-y += omapfb.h 282header-y += omapfb.h
274header-y += oom.h 283header-y += oom.h
275header-y += param.h 284header-y += param.h
@@ -294,6 +303,7 @@ header-y += ppp-comp.h
294header-y += ppp_defs.h 303header-y += ppp_defs.h
295header-y += pps.h 304header-y += pps.h
296header-y += prctl.h 305header-y += prctl.h
306header-y += ptp_clock.h
297header-y += ptrace.h 307header-y += ptrace.h
298header-y += qnx4_fs.h 308header-y += qnx4_fs.h
299header-y += qnxtypes.h 309header-y += qnxtypes.h
@@ -301,6 +311,7 @@ header-y += quota.h
301header-y += radeonfb.h 311header-y += radeonfb.h
302header-y += random.h 312header-y += random.h
303header-y += raw.h 313header-y += raw.h
314header-y += rds.h
304header-y += reboot.h 315header-y += reboot.h
305header-y += reiserfs_fs.h 316header-y += reiserfs_fs.h
306header-y += reiserfs_xattr.h 317header-y += reiserfs_xattr.h
@@ -325,10 +336,6 @@ header-y += serio.h
325header-y += shm.h 336header-y += shm.h
326header-y += signal.h 337header-y += signal.h
327header-y += signalfd.h 338header-y += signalfd.h
328header-y += smb.h
329header-y += smb_fs.h
330header-y += smb_mount.h
331header-y += smbno.h
332header-y += snmp.h 339header-y += snmp.h
333header-y += socket.h 340header-y += socket.h
334header-y += sockios.h 341header-y += sockios.h
@@ -367,11 +374,12 @@ header-y += unistd.h
367header-y += usbdevice_fs.h 374header-y += usbdevice_fs.h
368header-y += utime.h 375header-y += utime.h
369header-y += utsname.h 376header-y += utsname.h
377header-y += uvcvideo.h
378header-y += v4l2-mediabus.h
379header-y += v4l2-subdev.h
370header-y += veth.h 380header-y += veth.h
371header-y += vhost.h 381header-y += vhost.h
372header-y += videodev.h
373header-y += videodev2.h 382header-y += videodev2.h
374header-y += videotext.h
375header-y += virtio_9p.h 383header-y += virtio_9p.h
376header-y += virtio_balloon.h 384header-y += virtio_balloon.h
377header-y += virtio_blk.h 385header-y += virtio_blk.h
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index c227757feb06..1deb2a73c2da 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -150,8 +150,7 @@ extern int ec_read(u8 addr, u8 *val);
150extern int ec_write(u8 addr, u8 val); 150extern int ec_write(u8 addr, u8 val);
151extern int ec_transaction(u8 command, 151extern int ec_transaction(u8 command,
152 const u8 *wdata, unsigned wdata_len, 152 const u8 *wdata, unsigned wdata_len,
153 u8 *rdata, unsigned rdata_len, 153 u8 *rdata, unsigned rdata_len);
154 int force_poll);
155 154
156#if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE) 155#if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
157 156
@@ -219,7 +218,7 @@ static inline int acpi_video_display_switch_support(void)
219 218
220extern int acpi_blacklisted(void); 219extern int acpi_blacklisted(void);
221extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); 220extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d);
222extern int acpi_osi_setup(char *str); 221extern void acpi_osi_setup(char *str);
223 222
224#ifdef CONFIG_ACPI_NUMA 223#ifdef CONFIG_ACPI_NUMA
225int acpi_get_pxm(acpi_handle handle); 224int acpi_get_pxm(acpi_handle handle);
@@ -245,8 +244,6 @@ int acpi_check_resource_conflict(const struct resource *res);
245 244
246int acpi_check_region(resource_size_t start, resource_size_t n, 245int acpi_check_region(resource_size_t start, resource_size_t n,
247 const char *name); 246 const char *name);
248int acpi_check_mem_region(resource_size_t start, resource_size_t n,
249 const char *name);
250 247
251int acpi_resources_are_enforced(void); 248int acpi_resources_are_enforced(void);
252 249
@@ -344,12 +341,6 @@ static inline int acpi_check_region(resource_size_t start, resource_size_t n,
344 return 0; 341 return 0;
345} 342}
346 343
347static inline int acpi_check_mem_region(resource_size_t start,
348 resource_size_t n, const char *name)
349{
350 return 0;
351}
352
353struct acpi_table_header; 344struct acpi_table_header;
354static inline int acpi_table_parse(char *id, 345static inline int acpi_table_parse(char *id,
355 int (*handler)(struct acpi_table_header *)) 346 int (*handler)(struct acpi_table_header *))
@@ -357,4 +348,14 @@ static inline int acpi_table_parse(char *id,
357 return -1; 348 return -1;
358} 349}
359#endif /* !CONFIG_ACPI */ 350#endif /* !CONFIG_ACPI */
351
352#ifdef CONFIG_ACPI_SLEEP
353int suspend_nvs_register(unsigned long start, unsigned long size);
354#else
355static inline int suspend_nvs_register(unsigned long a, unsigned long b)
356{
357 return 0;
358}
359#endif
360
360#endif /*_LINUX_ACPI_H*/ 361#endif /*_LINUX_ACPI_H*/
diff --git a/include/linux/acpi_io.h b/include/linux/acpi_io.h
new file mode 100644
index 000000000000..4afd7102459d
--- /dev/null
+++ b/include/linux/acpi_io.h
@@ -0,0 +1,15 @@
1#ifndef _ACPI_IO_H_
2#define _ACPI_IO_H_
3
4#include <linux/io.h>
5#include <acpi/acpi.h>
6
7static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
8 acpi_size size)
9{
10 return ioremap_cache(phys, size);
11}
12
13void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size);
14
15#endif
diff --git a/include/linux/acpi_pmtmr.h b/include/linux/acpi_pmtmr.h
index 7e3d2859be50..1d0ef1ae8036 100644
--- a/include/linux/acpi_pmtmr.h
+++ b/include/linux/acpi_pmtmr.h
@@ -25,8 +25,6 @@ static inline u32 acpi_pm_read_early(void)
25 return acpi_pm_read_verified() & ACPI_PM_MASK; 25 return acpi_pm_read_verified() & ACPI_PM_MASK;
26} 26}
27 27
28extern void pmtimer_wait(unsigned);
29
30#else 28#else
31 29
32static inline u32 acpi_pm_read_early(void) 30static inline u32 acpi_pm_read_early(void)
diff --git a/include/linux/aer.h b/include/linux/aer.h
index f7df1eefc107..8414de22a779 100644
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -7,6 +7,28 @@
7#ifndef _AER_H_ 7#ifndef _AER_H_
8#define _AER_H_ 8#define _AER_H_
9 9
10struct aer_header_log_regs {
11 unsigned int dw0;
12 unsigned int dw1;
13 unsigned int dw2;
14 unsigned int dw3;
15};
16
17struct aer_capability_regs {
18 u32 header;
19 u32 uncor_status;
20 u32 uncor_mask;
21 u32 uncor_severity;
22 u32 cor_status;
23 u32 cor_mask;
24 u32 cap_control;
25 struct aer_header_log_regs header_log;
26 u32 root_command;
27 u32 root_status;
28 u16 cor_err_source;
29 u16 uncor_err_source;
30};
31
10#if defined(CONFIG_PCIEAER) 32#if defined(CONFIG_PCIEAER)
11/* pci-e port driver needs this function to enable aer */ 33/* pci-e port driver needs this function to enable aer */
12extern int pci_enable_pcie_error_reporting(struct pci_dev *dev); 34extern int pci_enable_pcie_error_reporting(struct pci_dev *dev);
@@ -27,5 +49,7 @@ static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
27} 49}
28#endif 50#endif
29 51
52extern void cper_print_aer(const char *prefix, int cper_severity,
53 struct aer_capability_regs *aer);
30#endif //_AER_H_ 54#endif //_AER_H_
31 55
diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h
index 09ea4a1e9505..eaf6cd75a1b1 100644
--- a/include/linux/agp_backend.h
+++ b/include/linux/agp_backend.h
@@ -102,10 +102,8 @@ extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t,
102extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *); 102extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *);
103extern int agp_bind_memory(struct agp_memory *, off_t); 103extern int agp_bind_memory(struct agp_memory *, off_t);
104extern int agp_unbind_memory(struct agp_memory *); 104extern int agp_unbind_memory(struct agp_memory *);
105extern int agp_rebind_memory(void);
106extern void agp_enable(struct agp_bridge_data *, u32); 105extern void agp_enable(struct agp_bridge_data *, u32);
107extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *); 106extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
108extern void agp_backend_release(struct agp_bridge_data *); 107extern void agp_backend_release(struct agp_bridge_data *);
109extern void agp_flush_chipset(struct agp_bridge_data *);
110 108
111#endif /* _AGP_BACKEND_H */ 109#endif /* _AGP_BACKEND_H */
diff --git a/include/linux/alarmtimer.h b/include/linux/alarmtimer.h
new file mode 100644
index 000000000000..c5d6095b46f8
--- /dev/null
+++ b/include/linux/alarmtimer.h
@@ -0,0 +1,40 @@
1#ifndef _LINUX_ALARMTIMER_H
2#define _LINUX_ALARMTIMER_H
3
4#include <linux/time.h>
5#include <linux/hrtimer.h>
6#include <linux/timerqueue.h>
7#include <linux/rtc.h>
8
9enum alarmtimer_type {
10 ALARM_REALTIME,
11 ALARM_BOOTTIME,
12
13 ALARM_NUMTYPE,
14};
15
16/**
17 * struct alarm - Alarm timer structure
18 * @node: timerqueue node for adding to the event list this value
19 * also includes the expiration time.
20 * @period: Period for recuring alarms
21 * @function: Function pointer to be executed when the timer fires.
22 * @type: Alarm type (BOOTTIME/REALTIME)
23 * @enabled: Flag that represents if the alarm is set to fire or not
24 * @data: Internal data value.
25 */
26struct alarm {
27 struct timerqueue_node node;
28 ktime_t period;
29 void (*function)(struct alarm *);
30 enum alarmtimer_type type;
31 bool enabled;
32 void *data;
33};
34
35void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
36 void (*function)(struct alarm *));
37void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
38void alarm_cancel(struct alarm *alarm);
39
40#endif
diff --git a/include/linux/altera_uart.h b/include/linux/altera_uart.h
index 8d441064a30d..a10a90791976 100644
--- a/include/linux/altera_uart.h
+++ b/include/linux/altera_uart.h
@@ -5,10 +5,15 @@
5#ifndef __ALTUART_H 5#ifndef __ALTUART_H
6#define __ALTUART_H 6#define __ALTUART_H
7 7
8#include <linux/init.h>
9
8struct altera_uart_platform_uart { 10struct altera_uart_platform_uart {
9 unsigned long mapbase; /* Physical address base */ 11 unsigned long mapbase; /* Physical address base */
10 unsigned int irq; /* Interrupt vector */ 12 unsigned int irq; /* Interrupt vector */
11 unsigned int uartclk; /* UART clock rate */ 13 unsigned int uartclk; /* UART clock rate */
14 unsigned int bus_shift; /* Bus shift (address stride) */
12}; 15};
13 16
17int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp);
18
14#endif /* __ALTUART_H */ 19#endif /* __ALTUART_H */
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index b0c174012436..fcbbe71a3cc1 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -18,8 +18,10 @@
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/resource.h> 20#include <linux/resource.h>
21#include <linux/regulator/consumer.h>
21 22
22#define AMBA_NR_IRQS 2 23#define AMBA_NR_IRQS 2
24#define AMBA_CID 0xb105f00d
23 25
24struct clk; 26struct clk;
25 27
@@ -27,6 +29,7 @@ struct amba_device {
27 struct device dev; 29 struct device dev;
28 struct resource res; 30 struct resource res;
29 struct clk *pclk; 31 struct clk *pclk;
32 struct regulator *vcore;
30 u64 dma_mask; 33 u64 dma_mask;
31 unsigned int periphid; 34 unsigned int periphid;
32 unsigned int irq[AMBA_NR_IRQS]; 35 unsigned int irq[AMBA_NR_IRQS];
@@ -40,12 +43,12 @@ struct amba_id {
40 43
41struct amba_driver { 44struct amba_driver {
42 struct device_driver drv; 45 struct device_driver drv;
43 int (*probe)(struct amba_device *, struct amba_id *); 46 int (*probe)(struct amba_device *, const struct amba_id *);
44 int (*remove)(struct amba_device *); 47 int (*remove)(struct amba_device *);
45 void (*shutdown)(struct amba_device *); 48 void (*shutdown)(struct amba_device *);
46 int (*suspend)(struct amba_device *, pm_message_t); 49 int (*suspend)(struct amba_device *, pm_message_t);
47 int (*resume)(struct amba_device *); 50 int (*resume)(struct amba_device *);
48 struct amba_id *id_table; 51 const struct amba_id *id_table;
49}; 52};
50 53
51enum amba_vendor { 54enum amba_vendor {
@@ -53,6 +56,10 @@ enum amba_vendor {
53 AMBA_VENDOR_ST = 0x80, 56 AMBA_VENDOR_ST = 0x80,
54}; 57};
55 58
59extern struct bus_type amba_bustype;
60
61#define to_amba_device(d) container_of(d, struct amba_device, dev)
62
56#define amba_get_drvdata(d) dev_get_drvdata(&d->dev) 63#define amba_get_drvdata(d) dev_get_drvdata(&d->dev)
57#define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p) 64#define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p)
58 65
@@ -70,9 +77,21 @@ void amba_release_regions(struct amba_device *);
70#define amba_pclk_disable(d) \ 77#define amba_pclk_disable(d) \
71 do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0) 78 do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0)
72 79
73#define amba_config(d) (((d)->periphid >> 24) & 0xff) 80#define amba_vcore_enable(d) \
74#define amba_rev(d) (((d)->periphid >> 20) & 0x0f) 81 (IS_ERR((d)->vcore) ? 0 : regulator_enable((d)->vcore))
75#define amba_manf(d) (((d)->periphid >> 12) & 0xff) 82
76#define amba_part(d) ((d)->periphid & 0xfff) 83#define amba_vcore_disable(d) \
84 do { if (!IS_ERR((d)->vcore)) regulator_disable((d)->vcore); } while (0)
85
86/* Some drivers don't use the struct amba_device */
87#define AMBA_CONFIG_BITS(a) (((a) >> 24) & 0xff)
88#define AMBA_REV_BITS(a) (((a) >> 20) & 0x0f)
89#define AMBA_MANF_BITS(a) (((a) >> 12) & 0xff)
90#define AMBA_PART_BITS(a) ((a) & 0xfff)
91
92#define amba_config(d) AMBA_CONFIG_BITS((d)->periphid)
93#define amba_rev(d) AMBA_REV_BITS((d)->periphid)
94#define amba_manf(d) AMBA_MANF_BITS((d)->periphid)
95#define amba_part(d) AMBA_PART_BITS((d)->periphid)
77 96
78#endif 97#endif
diff --git a/include/linux/amba/clcd.h b/include/linux/amba/clcd.h
index be33b3affc8a..e82e3ee2c54a 100644
--- a/include/linux/amba/clcd.h
+++ b/include/linux/amba/clcd.h
@@ -53,6 +53,7 @@
53#define CNTL_LCDBPP8 (3 << 1) 53#define CNTL_LCDBPP8 (3 << 1)
54#define CNTL_LCDBPP16 (4 << 1) 54#define CNTL_LCDBPP16 (4 << 1)
55#define CNTL_LCDBPP16_565 (6 << 1) 55#define CNTL_LCDBPP16_565 (6 << 1)
56#define CNTL_LCDBPP16_444 (7 << 1)
56#define CNTL_LCDBPP24 (5 << 1) 57#define CNTL_LCDBPP24 (5 << 1)
57#define CNTL_LCDBW (1 << 4) 58#define CNTL_LCDBW (1 << 4)
58#define CNTL_LCDTFT (1 << 5) 59#define CNTL_LCDTFT (1 << 5)
@@ -66,6 +67,32 @@
66#define CNTL_LDMAFIFOTIME (1 << 15) 67#define CNTL_LDMAFIFOTIME (1 << 15)
67#define CNTL_WATERMARK (1 << 16) 68#define CNTL_WATERMARK (1 << 16)
68 69
70enum {
71 /* individual formats */
72 CLCD_CAP_RGB444 = (1 << 0),
73 CLCD_CAP_RGB5551 = (1 << 1),
74 CLCD_CAP_RGB565 = (1 << 2),
75 CLCD_CAP_RGB888 = (1 << 3),
76 CLCD_CAP_BGR444 = (1 << 4),
77 CLCD_CAP_BGR5551 = (1 << 5),
78 CLCD_CAP_BGR565 = (1 << 6),
79 CLCD_CAP_BGR888 = (1 << 7),
80
81 /* connection layouts */
82 CLCD_CAP_444 = CLCD_CAP_RGB444 | CLCD_CAP_BGR444,
83 CLCD_CAP_5551 = CLCD_CAP_RGB5551 | CLCD_CAP_BGR5551,
84 CLCD_CAP_565 = CLCD_CAP_RGB565 | CLCD_CAP_BGR565,
85 CLCD_CAP_888 = CLCD_CAP_RGB888 | CLCD_CAP_BGR888,
86
87 /* red/blue ordering */
88 CLCD_CAP_RGB = CLCD_CAP_RGB444 | CLCD_CAP_RGB5551 |
89 CLCD_CAP_RGB565 | CLCD_CAP_RGB888,
90 CLCD_CAP_BGR = CLCD_CAP_BGR444 | CLCD_CAP_BGR5551 |
91 CLCD_CAP_BGR565 | CLCD_CAP_BGR888,
92
93 CLCD_CAP_ALL = CLCD_CAP_BGR | CLCD_CAP_RGB,
94};
95
69struct clcd_panel { 96struct clcd_panel {
70 struct fb_videomode mode; 97 struct fb_videomode mode;
71 signed short width; /* width in mm */ 98 signed short width; /* width in mm */
@@ -73,6 +100,7 @@ struct clcd_panel {
73 u32 tim2; 100 u32 tim2;
74 u32 tim3; 101 u32 tim3;
75 u32 cntl; 102 u32 cntl;
103 u32 caps;
76 unsigned int bpp:8, 104 unsigned int bpp:8,
77 fixedtimings:1, 105 fixedtimings:1,
78 grayscale:1; 106 grayscale:1;
@@ -97,13 +125,18 @@ struct clcd_board {
97 const char *name; 125 const char *name;
98 126
99 /* 127 /*
128 * Optional. Hardware capability flags.
129 */
130 u32 caps;
131
132 /*
100 * Optional. Check whether the var structure is acceptable 133 * Optional. Check whether the var structure is acceptable
101 * for this display. 134 * for this display.
102 */ 135 */
103 int (*check)(struct clcd_fb *fb, struct fb_var_screeninfo *var); 136 int (*check)(struct clcd_fb *fb, struct fb_var_screeninfo *var);
104 137
105 /* 138 /*
106 * Compulsary. Decode fb->fb.var into regs->*. In the case of 139 * Compulsory. Decode fb->fb.var into regs->*. In the case of
107 * fixed timing, set regs->* to the register values required. 140 * fixed timing, set regs->* to the register values required.
108 */ 141 */
109 void (*decode)(struct clcd_fb *fb, struct clcd_regs *regs); 142 void (*decode)(struct clcd_fb *fb, struct clcd_regs *regs);
@@ -155,34 +188,35 @@ struct clcd_fb {
155 188
156static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs) 189static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
157{ 190{
191 struct fb_var_screeninfo *var = &fb->fb.var;
158 u32 val, cpl; 192 u32 val, cpl;
159 193
160 /* 194 /*
161 * Program the CLCD controller registers and start the CLCD 195 * Program the CLCD controller registers and start the CLCD
162 */ 196 */
163 val = ((fb->fb.var.xres / 16) - 1) << 2; 197 val = ((var->xres / 16) - 1) << 2;
164 val |= (fb->fb.var.hsync_len - 1) << 8; 198 val |= (var->hsync_len - 1) << 8;
165 val |= (fb->fb.var.right_margin - 1) << 16; 199 val |= (var->right_margin - 1) << 16;
166 val |= (fb->fb.var.left_margin - 1) << 24; 200 val |= (var->left_margin - 1) << 24;
167 regs->tim0 = val; 201 regs->tim0 = val;
168 202
169 val = fb->fb.var.yres; 203 val = var->yres;
170 if (fb->panel->cntl & CNTL_LCDDUAL) 204 if (fb->panel->cntl & CNTL_LCDDUAL)
171 val /= 2; 205 val /= 2;
172 val -= 1; 206 val -= 1;
173 val |= (fb->fb.var.vsync_len - 1) << 10; 207 val |= (var->vsync_len - 1) << 10;
174 val |= fb->fb.var.lower_margin << 16; 208 val |= var->lower_margin << 16;
175 val |= fb->fb.var.upper_margin << 24; 209 val |= var->upper_margin << 24;
176 regs->tim1 = val; 210 regs->tim1 = val;
177 211
178 val = fb->panel->tim2; 212 val = fb->panel->tim2;
179 val |= fb->fb.var.sync & FB_SYNC_HOR_HIGH_ACT ? 0 : TIM2_IHS; 213 val |= var->sync & FB_SYNC_HOR_HIGH_ACT ? 0 : TIM2_IHS;
180 val |= fb->fb.var.sync & FB_SYNC_VERT_HIGH_ACT ? 0 : TIM2_IVS; 214 val |= var->sync & FB_SYNC_VERT_HIGH_ACT ? 0 : TIM2_IVS;
181 215
182 cpl = fb->fb.var.xres_virtual; 216 cpl = var->xres_virtual;
183 if (fb->panel->cntl & CNTL_LCDTFT) /* TFT */ 217 if (fb->panel->cntl & CNTL_LCDTFT) /* TFT */
184 /* / 1 */; 218 /* / 1 */;
185 else if (!fb->fb.var.grayscale) /* STN color */ 219 else if (!var->grayscale) /* STN color */
186 cpl = cpl * 8 / 3; 220 cpl = cpl * 8 / 3;
187 else if (fb->panel->cntl & CNTL_LCDMONO8) /* STN monochrome, 8bit */ 221 else if (fb->panel->cntl & CNTL_LCDMONO8) /* STN monochrome, 8bit */
188 cpl /= 8; 222 cpl /= 8;
@@ -194,10 +228,22 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
194 regs->tim3 = fb->panel->tim3; 228 regs->tim3 = fb->panel->tim3;
195 229
196 val = fb->panel->cntl; 230 val = fb->panel->cntl;
197 if (fb->fb.var.grayscale) 231 if (var->grayscale)
198 val |= CNTL_LCDBW; 232 val |= CNTL_LCDBW;
199 233
200 switch (fb->fb.var.bits_per_pixel) { 234 if (fb->panel->caps && fb->board->caps &&
235 var->bits_per_pixel >= 16) {
236 /*
237 * if board and panel supply capabilities, we can support
238 * changing BGR/RGB depending on supplied parameters
239 */
240 if (var->red.offset == 0)
241 val &= ~CNTL_BGR;
242 else
243 val |= CNTL_BGR;
244 }
245
246 switch (var->bits_per_pixel) {
201 case 1: 247 case 1:
202 val |= CNTL_LCDBPP1; 248 val |= CNTL_LCDBPP1;
203 break; 249 break;
@@ -212,15 +258,17 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
212 break; 258 break;
213 case 16: 259 case 16:
214 /* 260 /*
215 * PL110 cannot choose between 5551 and 565 modes in 261 * PL110 cannot choose between 5551 and 565 modes in its
216 * its control register 262 * control register. It is possible to use 565 with
263 * custom external wiring.
217 */ 264 */
218 if ((fb->dev->periphid & 0x000fffff) == 0x00041110) 265 if (amba_part(fb->dev) == 0x110 ||
266 var->green.length == 5)
219 val |= CNTL_LCDBPP16; 267 val |= CNTL_LCDBPP16;
220 else if (fb->fb.var.green.length == 5) 268 else if (var->green.length == 6)
221 val |= CNTL_LCDBPP16;
222 else
223 val |= CNTL_LCDBPP16_565; 269 val |= CNTL_LCDBPP16_565;
270 else
271 val |= CNTL_LCDBPP16_444;
224 break; 272 break;
225 case 32: 273 case 32:
226 val |= CNTL_LCDBPP24; 274 val |= CNTL_LCDBPP24;
@@ -228,7 +276,7 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
228 } 276 }
229 277
230 regs->cntl = val; 278 regs->cntl = val;
231 regs->pixclock = fb->fb.var.pixclock; 279 regs->pixclock = var->pixclock;
232} 280}
233 281
234static inline int clcdfb_check(struct clcd_fb *fb, struct fb_var_screeninfo *var) 282static inline int clcdfb_check(struct clcd_fb *fb, struct fb_var_screeninfo *var)
diff --git a/include/linux/amba/mmci.h b/include/linux/amba/mmci.h
index ca84ce70d5d5..21114810c7c0 100644
--- a/include/linux/amba/mmci.h
+++ b/include/linux/amba/mmci.h
@@ -6,6 +6,9 @@
6 6
7#include <linux/mmc/host.h> 7#include <linux/mmc/host.h>
8 8
9/* Just some dummy forwarding */
10struct dma_chan;
11
9/** 12/**
10 * struct mmci_platform_data - platform configuration for the MMCI 13 * struct mmci_platform_data - platform configuration for the MMCI
11 * (also known as PL180) block. 14 * (also known as PL180) block.
@@ -24,8 +27,20 @@
24 * whether a card is present in the MMC slot or not 27 * whether a card is present in the MMC slot or not
25 * @gpio_wp: read this GPIO pin to see if the card is write protected 28 * @gpio_wp: read this GPIO pin to see if the card is write protected
26 * @gpio_cd: read this GPIO pin to detect card insertion 29 * @gpio_cd: read this GPIO pin to detect card insertion
30 * @cd_invert: true if the gpio_cd pin value is active low
27 * @capabilities: the capabilities of the block as implemented in 31 * @capabilities: the capabilities of the block as implemented in
28 * this platform, signify anything MMC_CAP_* from mmc/host.h 32 * this platform, signify anything MMC_CAP_* from mmc/host.h
33 * @dma_filter: function used to select an appropriate RX and TX
34 * DMA channel to be used for DMA, if and only if you're deploying the
35 * generic DMA engine
36 * @dma_rx_param: parameter passed to the DMA allocation
37 * filter in order to select an appropriate RX channel. If
38 * there is a bidirectional RX+TX channel, then just specify
39 * this and leave dma_tx_param set to NULL
40 * @dma_tx_param: parameter passed to the DMA allocation
41 * filter in order to select an appropriate TX channel. If this
42 * is NULL the driver will attempt to use the RX channel as a
43 * bidirectional channel
29 */ 44 */
30struct mmci_platform_data { 45struct mmci_platform_data {
31 unsigned int f_max; 46 unsigned int f_max;
@@ -35,7 +50,11 @@ struct mmci_platform_data {
35 unsigned int (*status)(struct device *); 50 unsigned int (*status)(struct device *);
36 int gpio_wp; 51 int gpio_wp;
37 int gpio_cd; 52 int gpio_cd;
53 bool cd_invert;
38 unsigned long capabilities; 54 unsigned long capabilities;
55 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
56 void *dma_rx_param;
57 void *dma_tx_param;
39}; 58};
40 59
41#endif 60#endif
diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h
index abf26cc47a2b..4ce98f54186b 100644
--- a/include/linux/amba/pl022.h
+++ b/include/linux/amba/pl022.h
@@ -228,6 +228,7 @@ enum ssp_chip_select {
228}; 228};
229 229
230 230
231struct dma_chan;
231/** 232/**
232 * struct pl022_ssp_master - device.platform_data for SPI controller devices. 233 * struct pl022_ssp_master - device.platform_data for SPI controller devices.
233 * @num_chipselect: chipselects are used to distinguish individual 234 * @num_chipselect: chipselects are used to distinguish individual
@@ -235,11 +236,16 @@ enum ssp_chip_select {
235 * each slave has a chipselect signal, but it's common that not 236 * each slave has a chipselect signal, but it's common that not
236 * every chipselect is connected to a slave. 237 * every chipselect is connected to a slave.
237 * @enable_dma: if true enables DMA driven transfers. 238 * @enable_dma: if true enables DMA driven transfers.
239 * @dma_rx_param: parameter to locate an RX DMA channel.
240 * @dma_tx_param: parameter to locate a TX DMA channel.
238 */ 241 */
239struct pl022_ssp_controller { 242struct pl022_ssp_controller {
240 u16 bus_id; 243 u16 bus_id;
241 u8 num_chipselect; 244 u8 num_chipselect;
242 u8 enable_dma:1; 245 u8 enable_dma:1;
246 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
247 void *dma_rx_param;
248 void *dma_tx_param;
243}; 249};
244 250
245/** 251/**
@@ -270,20 +276,13 @@ struct pl022_ssp_controller {
270 * @dma_config: DMA configuration for SSP controller and peripheral 276 * @dma_config: DMA configuration for SSP controller and peripheral
271 */ 277 */
272struct pl022_config_chip { 278struct pl022_config_chip {
273 struct device *dev;
274 enum ssp_loopback lbm;
275 enum ssp_interface iface; 279 enum ssp_interface iface;
276 enum ssp_hierarchy hierarchy; 280 enum ssp_hierarchy hierarchy;
277 bool slave_tx_disable; 281 bool slave_tx_disable;
278 struct ssp_clock_params clk_freq; 282 struct ssp_clock_params clk_freq;
279 enum ssp_rx_endian endian_rx;
280 enum ssp_tx_endian endian_tx;
281 enum ssp_data_size data_size;
282 enum ssp_mode com_mode; 283 enum ssp_mode com_mode;
283 enum ssp_rx_level_trig rx_lev_trig; 284 enum ssp_rx_level_trig rx_lev_trig;
284 enum ssp_tx_level_trig tx_lev_trig; 285 enum ssp_tx_level_trig tx_lev_trig;
285 enum ssp_spi_clk_phase clk_phase;
286 enum ssp_spi_clk_pol clk_pol;
287 enum ssp_microwire_ctrl_len ctrl_len; 286 enum ssp_microwire_ctrl_len ctrl_len;
288 enum ssp_microwire_wait_state wait_state; 287 enum ssp_microwire_wait_state wait_state;
289 enum ssp_duplex duplex; 288 enum ssp_duplex duplex;
diff --git a/include/linux/amba/pl08x.h b/include/linux/amba/pl08x.h
new file mode 100644
index 000000000000..3111385b8ca7
--- /dev/null
+++ b/include/linux/amba/pl08x.h
@@ -0,0 +1,223 @@
1/*
2 * linux/amba/pl08x.h - ARM PrimeCell DMA Controller driver
3 *
4 * Copyright (C) 2005 ARM Ltd
5 * Copyright (C) 2010 ST-Ericsson SA
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * pl08x information required by platform code
12 *
13 * Please credit ARM.com
14 * Documentation: ARM DDI 0196D
15 */
16
17#ifndef AMBA_PL08X_H
18#define AMBA_PL08X_H
19
20/* We need sizes of structs from this header */
21#include <linux/dmaengine.h>
22#include <linux/interrupt.h>
23
24struct pl08x_lli;
25struct pl08x_driver_data;
26
27/* Bitmasks for selecting AHB ports for DMA transfers */
28enum {
29 PL08X_AHB1 = (1 << 0),
30 PL08X_AHB2 = (1 << 1)
31};
32
33/**
34 * struct pl08x_channel_data - data structure to pass info between
35 * platform and PL08x driver regarding channel configuration
36 * @bus_id: name of this device channel, not just a device name since
37 * devices may have more than one channel e.g. "foo_tx"
38 * @min_signal: the minimum DMA signal number to be muxed in for this
39 * channel (for platforms supporting muxed signals). If you have
40 * static assignments, make sure this is set to the assigned signal
41 * number, PL08x have 16 possible signals in number 0 thru 15 so
42 * when these are not enough they often get muxed (in hardware)
43 * disabling simultaneous use of the same channel for two devices.
44 * @max_signal: the maximum DMA signal number to be muxed in for
45 * the channel. Set to the same as min_signal for
46 * devices with static assignments
47 * @muxval: a number usually used to poke into some mux regiser to
48 * mux in the signal to this channel
49 * @cctl_opt: default options for the channel control register
50 * @addr: source/target address in physical memory for this DMA channel,
51 * can be the address of a FIFO register for burst requests for example.
52 * This can be left undefined if the PrimeCell API is used for configuring
53 * this.
54 * @circular_buffer: whether the buffer passed in is circular and
55 * shall simply be looped round round (like a record baby round
56 * round round round)
57 * @single: the device connected to this channel will request single DMA
58 * transfers, not bursts. (Bursts are default.)
59 * @periph_buses: the device connected to this channel is accessible via
60 * these buses (use PL08X_AHB1 | PL08X_AHB2).
61 */
62struct pl08x_channel_data {
63 char *bus_id;
64 int min_signal;
65 int max_signal;
66 u32 muxval;
67 u32 cctl;
68 dma_addr_t addr;
69 bool circular_buffer;
70 bool single;
71 u8 periph_buses;
72};
73
74/**
75 * Struct pl08x_bus_data - information of source or destination
76 * busses for a transfer
77 * @addr: current address
78 * @maxwidth: the maximum width of a transfer on this bus
79 * @buswidth: the width of this bus in bytes: 1, 2 or 4
80 * @fill_bytes: bytes required to fill to the next bus memory boundary
81 */
82struct pl08x_bus_data {
83 dma_addr_t addr;
84 u8 maxwidth;
85 u8 buswidth;
86 size_t fill_bytes;
87};
88
89/**
90 * struct pl08x_phy_chan - holder for the physical channels
91 * @id: physical index to this channel
92 * @lock: a lock to use when altering an instance of this struct
93 * @signal: the physical signal (aka channel) serving this physical channel
94 * right now
95 * @serving: the virtual channel currently being served by this physical
96 * channel
97 */
98struct pl08x_phy_chan {
99 unsigned int id;
100 void __iomem *base;
101 spinlock_t lock;
102 int signal;
103 struct pl08x_dma_chan *serving;
104};
105
106/**
107 * struct pl08x_txd - wrapper for struct dma_async_tx_descriptor
108 * @llis_bus: DMA memory address (physical) start for the LLIs
109 * @llis_va: virtual memory address start for the LLIs
110 */
111struct pl08x_txd {
112 struct dma_async_tx_descriptor tx;
113 struct list_head node;
114 enum dma_data_direction direction;
115 dma_addr_t src_addr;
116 dma_addr_t dst_addr;
117 size_t len;
118 dma_addr_t llis_bus;
119 struct pl08x_lli *llis_va;
120 /* Default cctl value for LLIs */
121 u32 cctl;
122 /*
123 * Settings to be put into the physical channel when we
124 * trigger this txd. Other registers are in llis_va[0].
125 */
126 u32 ccfg;
127};
128
129/**
130 * struct pl08x_dma_chan_state - holds the PL08x specific virtual channel
131 * states
132 * @PL08X_CHAN_IDLE: the channel is idle
133 * @PL08X_CHAN_RUNNING: the channel has allocated a physical transport
134 * channel and is running a transfer on it
135 * @PL08X_CHAN_PAUSED: the channel has allocated a physical transport
136 * channel, but the transfer is currently paused
137 * @PL08X_CHAN_WAITING: the channel is waiting for a physical transport
138 * channel to become available (only pertains to memcpy channels)
139 */
140enum pl08x_dma_chan_state {
141 PL08X_CHAN_IDLE,
142 PL08X_CHAN_RUNNING,
143 PL08X_CHAN_PAUSED,
144 PL08X_CHAN_WAITING,
145};
146
147/**
148 * struct pl08x_dma_chan - this structure wraps a DMA ENGINE channel
149 * @chan: wrappped abstract channel
150 * @phychan: the physical channel utilized by this channel, if there is one
151 * @phychan_hold: if non-zero, hold on to the physical channel even if we
152 * have no pending entries
153 * @tasklet: tasklet scheduled by the IRQ to handle actual work etc
154 * @name: name of channel
155 * @cd: channel platform data
156 * @runtime_addr: address for RX/TX according to the runtime config
157 * @runtime_direction: current direction of this channel according to
158 * runtime config
159 * @lc: last completed transaction on this channel
160 * @pend_list: queued transactions pending on this channel
161 * @at: active transaction on this channel
162 * @lock: a lock for this channel data
163 * @host: a pointer to the host (internal use)
164 * @state: whether the channel is idle, paused, running etc
165 * @slave: whether this channel is a device (slave) or for memcpy
166 * @waiting: a TX descriptor on this channel which is waiting for a physical
167 * channel to become available
168 */
169struct pl08x_dma_chan {
170 struct dma_chan chan;
171 struct pl08x_phy_chan *phychan;
172 int phychan_hold;
173 struct tasklet_struct tasklet;
174 char *name;
175 struct pl08x_channel_data *cd;
176 dma_addr_t runtime_addr;
177 enum dma_data_direction runtime_direction;
178 dma_cookie_t lc;
179 struct list_head pend_list;
180 struct pl08x_txd *at;
181 spinlock_t lock;
182 struct pl08x_driver_data *host;
183 enum pl08x_dma_chan_state state;
184 bool slave;
185 struct pl08x_txd *waiting;
186};
187
188/**
189 * struct pl08x_platform_data - the platform configuration for the PL08x
190 * PrimeCells.
191 * @slave_channels: the channels defined for the different devices on the
192 * platform, all inclusive, including multiplexed channels. The available
193 * physical channels will be multiplexed around these signals as they are
194 * requested, just enumerate all possible channels.
195 * @get_signal: request a physical signal to be used for a DMA transfer
196 * immediately: if there is some multiplexing or similar blocking the use
197 * of the channel the transfer can be denied by returning less than zero,
198 * else it returns the allocated signal number
199 * @put_signal: indicate to the platform that this physical signal is not
200 * running any DMA transfer and multiplexing can be recycled
201 * @lli_buses: buses which LLIs can be fetched from: PL08X_AHB1 | PL08X_AHB2
202 * @mem_buses: buses which memory can be accessed from: PL08X_AHB1 | PL08X_AHB2
203 */
204struct pl08x_platform_data {
205 struct pl08x_channel_data *slave_channels;
206 unsigned int num_slave_channels;
207 struct pl08x_channel_data memcpy_channel;
208 int (*get_signal)(struct pl08x_dma_chan *);
209 void (*put_signal)(struct pl08x_dma_chan *);
210 u8 lli_buses;
211 u8 mem_buses;
212};
213
214#ifdef CONFIG_AMBA_PL08X
215bool pl08x_filter_id(struct dma_chan *chan, void *chan_id);
216#else
217static inline bool pl08x_filter_id(struct dma_chan *chan, void *chan_id)
218{
219 return false;
220}
221#endif
222
223#endif /* AMBA_PL08X_H */
diff --git a/include/linux/amba/serial.h b/include/linux/amba/serial.h
index e1b634b635f2..514ed45c462e 100644
--- a/include/linux/amba/serial.h
+++ b/include/linux/amba/serial.h
@@ -32,7 +32,9 @@
32#define UART01x_RSR 0x04 /* Receive status register (Read). */ 32#define UART01x_RSR 0x04 /* Receive status register (Read). */
33#define UART01x_ECR 0x04 /* Error clear register (Write). */ 33#define UART01x_ECR 0x04 /* Error clear register (Write). */
34#define UART010_LCRH 0x08 /* Line control register, high byte. */ 34#define UART010_LCRH 0x08 /* Line control register, high byte. */
35#define ST_UART011_DMAWM 0x08 /* DMA watermark configure register. */
35#define UART010_LCRM 0x0C /* Line control register, middle byte. */ 36#define UART010_LCRM 0x0C /* Line control register, middle byte. */
37#define ST_UART011_TIMEOUT 0x0C /* Timeout period register. */
36#define UART010_LCRL 0x10 /* Line control register, low byte. */ 38#define UART010_LCRL 0x10 /* Line control register, low byte. */
37#define UART010_CR 0x14 /* Control register. */ 39#define UART010_CR 0x14 /* Control register. */
38#define UART01x_FR 0x18 /* Flag register (Read only). */ 40#define UART01x_FR 0x18 /* Flag register (Read only). */
@@ -51,6 +53,15 @@
51#define UART011_MIS 0x40 /* Masked interrupt status. */ 53#define UART011_MIS 0x40 /* Masked interrupt status. */
52#define UART011_ICR 0x44 /* Interrupt clear register. */ 54#define UART011_ICR 0x44 /* Interrupt clear register. */
53#define UART011_DMACR 0x48 /* DMA control register. */ 55#define UART011_DMACR 0x48 /* DMA control register. */
56#define ST_UART011_XFCR 0x50 /* XON/XOFF control register. */
57#define ST_UART011_XON1 0x54 /* XON1 register. */
58#define ST_UART011_XON2 0x58 /* XON2 register. */
59#define ST_UART011_XOFF1 0x5C /* XON1 register. */
60#define ST_UART011_XOFF2 0x60 /* XON2 register. */
61#define ST_UART011_ITCR 0x80 /* Integration test control register. */
62#define ST_UART011_ITIP 0x84 /* Integration test input register. */
63#define ST_UART011_ABCR 0x100 /* Autobaud control register. */
64#define ST_UART011_ABIMSC 0x15C /* Autobaud interrupt mask/clear register. */
54 65
55#define UART011_DR_OE (1 << 11) 66#define UART011_DR_OE (1 << 11)
56#define UART011_DR_BE (1 << 10) 67#define UART011_DR_BE (1 << 10)
@@ -102,6 +113,21 @@
102#define UART01x_LCRH_PEN 0x02 113#define UART01x_LCRH_PEN 0x02
103#define UART01x_LCRH_BRK 0x01 114#define UART01x_LCRH_BRK 0x01
104 115
116#define ST_UART011_DMAWM_RX_1 (0 << 3)
117#define ST_UART011_DMAWM_RX_2 (1 << 3)
118#define ST_UART011_DMAWM_RX_4 (2 << 3)
119#define ST_UART011_DMAWM_RX_8 (3 << 3)
120#define ST_UART011_DMAWM_RX_16 (4 << 3)
121#define ST_UART011_DMAWM_RX_32 (5 << 3)
122#define ST_UART011_DMAWM_RX_48 (6 << 3)
123#define ST_UART011_DMAWM_TX_1 0
124#define ST_UART011_DMAWM_TX_2 1
125#define ST_UART011_DMAWM_TX_4 2
126#define ST_UART011_DMAWM_TX_8 3
127#define ST_UART011_DMAWM_TX_16 4
128#define ST_UART011_DMAWM_TX_32 5
129#define ST_UART011_DMAWM_TX_48 6
130
105#define UART010_IIR_RTIS 0x08 131#define UART010_IIR_RTIS 0x08
106#define UART010_IIR_TIS 0x04 132#define UART010_IIR_TIS 0x04
107#define UART010_IIR_RIS 0x02 133#define UART010_IIR_RIS 0x02
@@ -169,6 +195,16 @@ struct amba_device; /* in uncompress this is included but amba/bus.h is not */
169struct amba_pl010_data { 195struct amba_pl010_data {
170 void (*set_mctrl)(struct amba_device *dev, void __iomem *base, unsigned int mctrl); 196 void (*set_mctrl)(struct amba_device *dev, void __iomem *base, unsigned int mctrl);
171}; 197};
198
199struct dma_chan;
200struct amba_pl011_data {
201 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
202 void *dma_rx_param;
203 void *dma_tx_param;
204 void (*init) (void);
205 void (*exit) (void);
206 void (*reset) (void);
207};
172#endif 208#endif
173 209
174#endif 210#endif
diff --git a/include/linux/ata.h b/include/linux/ata.h
index fe6e681a9d74..32df2b6ef0e0 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -89,6 +89,8 @@ enum {
89 ATA_ID_SPG = 98, 89 ATA_ID_SPG = 98,
90 ATA_ID_LBA_CAPACITY_2 = 100, 90 ATA_ID_LBA_CAPACITY_2 = 100,
91 ATA_ID_SECTOR_SIZE = 106, 91 ATA_ID_SECTOR_SIZE = 106,
92 ATA_ID_WWN = 108,
93 ATA_ID_LOGICAL_SECTOR_SIZE = 117, /* and 118 */
92 ATA_ID_LAST_LUN = 126, 94 ATA_ID_LAST_LUN = 126,
93 ATA_ID_DLF = 128, 95 ATA_ID_DLF = 128,
94 ATA_ID_CSFO = 129, 96 ATA_ID_CSFO = 129,
@@ -102,6 +104,7 @@ enum {
102 ATA_ID_SERNO_LEN = 20, 104 ATA_ID_SERNO_LEN = 20,
103 ATA_ID_FW_REV_LEN = 8, 105 ATA_ID_FW_REV_LEN = 8,
104 ATA_ID_PROD_LEN = 40, 106 ATA_ID_PROD_LEN = 40,
107 ATA_ID_WWN_LEN = 8,
105 108
106 ATA_PCI_CTL_OFS = 2, 109 ATA_PCI_CTL_OFS = 2,
107 110
@@ -597,42 +600,42 @@ static inline bool ata_id_has_dipm(const u16 *id)
597} 600}
598 601
599 602
600static inline int ata_id_has_fua(const u16 *id) 603static inline bool ata_id_has_fua(const u16 *id)
601{ 604{
602 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000) 605 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000)
603 return 0; 606 return false;
604 return id[ATA_ID_CFSSE] & (1 << 6); 607 return id[ATA_ID_CFSSE] & (1 << 6);
605} 608}
606 609
607static inline int ata_id_has_flush(const u16 *id) 610static inline bool ata_id_has_flush(const u16 *id)
608{ 611{
609 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 612 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
610 return 0; 613 return false;
611 return id[ATA_ID_COMMAND_SET_2] & (1 << 12); 614 return id[ATA_ID_COMMAND_SET_2] & (1 << 12);
612} 615}
613 616
614static inline int ata_id_flush_enabled(const u16 *id) 617static inline bool ata_id_flush_enabled(const u16 *id)
615{ 618{
616 if (ata_id_has_flush(id) == 0) 619 if (ata_id_has_flush(id) == 0)
617 return 0; 620 return false;
618 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 621 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
619 return 0; 622 return false;
620 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12); 623 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12);
621} 624}
622 625
623static inline int ata_id_has_flush_ext(const u16 *id) 626static inline bool ata_id_has_flush_ext(const u16 *id)
624{ 627{
625 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 628 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
626 return 0; 629 return false;
627 return id[ATA_ID_COMMAND_SET_2] & (1 << 13); 630 return id[ATA_ID_COMMAND_SET_2] & (1 << 13);
628} 631}
629 632
630static inline int ata_id_flush_ext_enabled(const u16 *id) 633static inline bool ata_id_flush_ext_enabled(const u16 *id)
631{ 634{
632 if (ata_id_has_flush_ext(id) == 0) 635 if (ata_id_has_flush_ext(id) == 0)
633 return 0; 636 return false;
634 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 637 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
635 return 0; 638 return false;
636 /* 639 /*
637 * some Maxtor disks have bit 13 defined incorrectly 640 * some Maxtor disks have bit 13 defined incorrectly
638 * so check bit 10 too 641 * so check bit 10 too
@@ -640,76 +643,109 @@ static inline int ata_id_flush_ext_enabled(const u16 *id)
640 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400; 643 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400;
641} 644}
642 645
643static inline int ata_id_has_large_logical_sectors(const u16 *id) 646static inline u32 ata_id_logical_sector_size(const u16 *id)
644{ 647{
645 if ((id[ATA_ID_SECTOR_SIZE] & 0xc000) != 0x4000) 648 /* T13/1699-D Revision 6a, Sep 6, 2008. Page 128.
646 return 0; 649 * IDENTIFY DEVICE data, word 117-118.
647 return id[ATA_ID_SECTOR_SIZE] & (1 << 13); 650 * 0xd000 ignores bit 13 (logical:physical > 1)
651 */
652 if ((id[ATA_ID_SECTOR_SIZE] & 0xd000) == 0x5000)
653 return (((id[ATA_ID_LOGICAL_SECTOR_SIZE+1] << 16)
654 + id[ATA_ID_LOGICAL_SECTOR_SIZE]) * sizeof(u16)) ;
655 return ATA_SECT_SIZE;
648} 656}
649 657
650static inline u16 ata_id_logical_per_physical_sectors(const u16 *id) 658static inline u8 ata_id_log2_per_physical_sector(const u16 *id)
651{ 659{
652 return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf); 660 /* T13/1699-D Revision 6a, Sep 6, 2008. Page 128.
661 * IDENTIFY DEVICE data, word 106.
662 * 0xe000 ignores bit 12 (logical sector > 512 bytes)
663 */
664 if ((id[ATA_ID_SECTOR_SIZE] & 0xe000) == 0x6000)
665 return (id[ATA_ID_SECTOR_SIZE] & 0xf);
666 return 0;
667}
668
669/* Offset of logical sectors relative to physical sectors.
670 *
671 * If device has more than one logical sector per physical sector
672 * (aka 512 byte emulation), vendors might offset the "sector 0" address
673 * so sector 63 is "naturally aligned" - e.g. FAT partition table.
674 * This avoids Read/Mod/Write penalties when using FAT partition table
675 * and updating "well aligned" (FS perspective) physical sectors on every
676 * transaction.
677 */
678static inline u16 ata_id_logical_sector_offset(const u16 *id,
679 u8 log2_per_phys)
680{
681 u16 word_209 = id[209];
682
683 if ((log2_per_phys > 1) && (word_209 & 0xc000) == 0x4000) {
684 u16 first = word_209 & 0x3fff;
685 if (first > 0)
686 return (1 << log2_per_phys) - first;
687 }
688 return 0;
653} 689}
654 690
655static inline int ata_id_has_lba48(const u16 *id) 691static inline bool ata_id_has_lba48(const u16 *id)
656{ 692{
657 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 693 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
658 return 0; 694 return false;
659 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2)) 695 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2))
660 return 0; 696 return false;
661 return id[ATA_ID_COMMAND_SET_2] & (1 << 10); 697 return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
662} 698}
663 699
664static inline int ata_id_lba48_enabled(const u16 *id) 700static inline bool ata_id_lba48_enabled(const u16 *id)
665{ 701{
666 if (ata_id_has_lba48(id) == 0) 702 if (ata_id_has_lba48(id) == 0)
667 return 0; 703 return false;
668 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 704 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
669 return 0; 705 return false;
670 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10); 706 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10);
671} 707}
672 708
673static inline int ata_id_hpa_enabled(const u16 *id) 709static inline bool ata_id_hpa_enabled(const u16 *id)
674{ 710{
675 /* Yes children, word 83 valid bits cover word 82 data */ 711 /* Yes children, word 83 valid bits cover word 82 data */
676 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 712 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
677 return 0; 713 return false;
678 /* And 87 covers 85-87 */ 714 /* And 87 covers 85-87 */
679 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 715 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
680 return 0; 716 return false;
681 /* Check command sets enabled as well as supported */ 717 /* Check command sets enabled as well as supported */
682 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0) 718 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0)
683 return 0; 719 return false;
684 return id[ATA_ID_COMMAND_SET_1] & (1 << 10); 720 return id[ATA_ID_COMMAND_SET_1] & (1 << 10);
685} 721}
686 722
687static inline int ata_id_has_wcache(const u16 *id) 723static inline bool ata_id_has_wcache(const u16 *id)
688{ 724{
689 /* Yes children, word 83 valid bits cover word 82 data */ 725 /* Yes children, word 83 valid bits cover word 82 data */
690 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 726 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
691 return 0; 727 return false;
692 return id[ATA_ID_COMMAND_SET_1] & (1 << 5); 728 return id[ATA_ID_COMMAND_SET_1] & (1 << 5);
693} 729}
694 730
695static inline int ata_id_has_pm(const u16 *id) 731static inline bool ata_id_has_pm(const u16 *id)
696{ 732{
697 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 733 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
698 return 0; 734 return false;
699 return id[ATA_ID_COMMAND_SET_1] & (1 << 3); 735 return id[ATA_ID_COMMAND_SET_1] & (1 << 3);
700} 736}
701 737
702static inline int ata_id_rahead_enabled(const u16 *id) 738static inline bool ata_id_rahead_enabled(const u16 *id)
703{ 739{
704 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 740 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
705 return 0; 741 return false;
706 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6); 742 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6);
707} 743}
708 744
709static inline int ata_id_wcache_enabled(const u16 *id) 745static inline bool ata_id_wcache_enabled(const u16 *id)
710{ 746{
711 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 747 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
712 return 0; 748 return false;
713 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5); 749 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5);
714} 750}
715 751
@@ -739,7 +775,7 @@ static inline unsigned int ata_id_major_version(const u16 *id)
739 return mver; 775 return mver;
740} 776}
741 777
742static inline int ata_id_is_sata(const u16 *id) 778static inline bool ata_id_is_sata(const u16 *id)
743{ 779{
744 /* 780 /*
745 * See if word 93 is 0 AND drive is at least ATA-5 compatible 781 * See if word 93 is 0 AND drive is at least ATA-5 compatible
@@ -748,37 +784,40 @@ static inline int ata_id_is_sata(const u16 *id)
748 * 0x0000 and 0xffff along with the earlier ATA revisions... 784 * 0x0000 and 0xffff along with the earlier ATA revisions...
749 */ 785 */
750 if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020) 786 if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020)
751 return 1; 787 return true;
752 return 0; 788 return false;
753} 789}
754 790
755static inline int ata_id_has_tpm(const u16 *id) 791static inline bool ata_id_has_tpm(const u16 *id)
756{ 792{
757 /* The TPM bits are only valid on ATA8 */ 793 /* The TPM bits are only valid on ATA8 */
758 if (ata_id_major_version(id) < 8) 794 if (ata_id_major_version(id) < 8)
759 return 0; 795 return false;
760 if ((id[48] & 0xC000) != 0x4000) 796 if ((id[48] & 0xC000) != 0x4000)
761 return 0; 797 return false;
762 return id[48] & (1 << 0); 798 return id[48] & (1 << 0);
763} 799}
764 800
765static inline int ata_id_has_dword_io(const u16 *id) 801static inline bool ata_id_has_dword_io(const u16 *id)
766{ 802{
767 /* ATA 8 reuses this flag for "trusted" computing */ 803 /* ATA 8 reuses this flag for "trusted" computing */
768 if (ata_id_major_version(id) > 7) 804 if (ata_id_major_version(id) > 7)
769 return 0; 805 return false;
770 if (id[ATA_ID_DWORD_IO] & (1 << 0)) 806 return id[ATA_ID_DWORD_IO] & (1 << 0);
771 return 1;
772 return 0;
773} 807}
774 808
775static inline int ata_id_has_unload(const u16 *id) 809static inline bool ata_id_has_unload(const u16 *id)
776{ 810{
777 if (ata_id_major_version(id) >= 7 && 811 if (ata_id_major_version(id) >= 7 &&
778 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 && 812 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 &&
779 id[ATA_ID_CFSSE] & (1 << 13)) 813 id[ATA_ID_CFSSE] & (1 << 13))
780 return 1; 814 return true;
781 return 0; 815 return false;
816}
817
818static inline bool ata_id_has_wwn(const u16 *id)
819{
820 return (id[ATA_ID_CSF_DEFAULT] & 0xC100) == 0x4100;
782} 821}
783 822
784static inline int ata_id_form_factor(const u16 *id) 823static inline int ata_id_form_factor(const u16 *id)
@@ -809,25 +848,25 @@ static inline int ata_id_rotation_rate(const u16 *id)
809 return val; 848 return val;
810} 849}
811 850
812static inline int ata_id_has_trim(const u16 *id) 851static inline bool ata_id_has_trim(const u16 *id)
813{ 852{
814 if (ata_id_major_version(id) >= 7 && 853 if (ata_id_major_version(id) >= 7 &&
815 (id[ATA_ID_DATA_SET_MGMT] & 1)) 854 (id[ATA_ID_DATA_SET_MGMT] & 1))
816 return 1; 855 return true;
817 return 0; 856 return false;
818} 857}
819 858
820static inline int ata_id_has_zero_after_trim(const u16 *id) 859static inline bool ata_id_has_zero_after_trim(const u16 *id)
821{ 860{
822 /* DSM supported, deterministic read, and read zero after trim set */ 861 /* DSM supported, deterministic read, and read zero after trim set */
823 if (ata_id_has_trim(id) && 862 if (ata_id_has_trim(id) &&
824 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020) 863 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020)
825 return 1; 864 return true;
826 865
827 return 0; 866 return false;
828} 867}
829 868
830static inline int ata_id_current_chs_valid(const u16 *id) 869static inline bool ata_id_current_chs_valid(const u16 *id)
831{ 870{
832 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 871 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
833 has not been issued to the device then the values of 872 has not been issued to the device then the values of
@@ -839,11 +878,11 @@ static inline int ata_id_current_chs_valid(const u16 *id)
839 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */ 878 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */
840} 879}
841 880
842static inline int ata_id_is_cfa(const u16 *id) 881static inline bool ata_id_is_cfa(const u16 *id)
843{ 882{
844 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */ 883 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */
845 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */ 884 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */
846 return 1; 885 return true;
847 /* 886 /*
848 * CF specs don't require specific value in the word 0 anymore and yet 887 * CF specs don't require specific value in the word 0 anymore and yet
849 * they forbid to report the ATA version in the word 80 and require the 888 * they forbid to report the ATA version in the word 80 and require the
@@ -852,44 +891,40 @@ static inline int ata_id_is_cfa(const u16 *id)
852 * and while those that don't indicate CFA feature support need some 891 * and while those that don't indicate CFA feature support need some
853 * sort of quirk list, it seems impractical for the ones that do... 892 * sort of quirk list, it seems impractical for the ones that do...
854 */ 893 */
855 if ((id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004) 894 return (id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004;
856 return 1;
857 return 0;
858} 895}
859 896
860static inline int ata_id_is_ssd(const u16 *id) 897static inline bool ata_id_is_ssd(const u16 *id)
861{ 898{
862 return id[ATA_ID_ROT_SPEED] == 0x01; 899 return id[ATA_ID_ROT_SPEED] == 0x01;
863} 900}
864 901
865static inline int ata_id_pio_need_iordy(const u16 *id, const u8 pio) 902static inline bool ata_id_pio_need_iordy(const u16 *id, const u8 pio)
866{ 903{
867 /* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */ 904 /* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */
868 if (pio > 4 && ata_id_is_cfa(id)) 905 if (pio > 4 && ata_id_is_cfa(id))
869 return 0; 906 return false;
870 /* For PIO3 and higher it is mandatory. */ 907 /* For PIO3 and higher it is mandatory. */
871 if (pio > 2) 908 if (pio > 2)
872 return 1; 909 return true;
873 /* Turn it on when possible. */ 910 /* Turn it on when possible. */
874 if (ata_id_has_iordy(id)) 911 return ata_id_has_iordy(id);
875 return 1;
876 return 0;
877} 912}
878 913
879static inline int ata_drive_40wire(const u16 *dev_id) 914static inline bool ata_drive_40wire(const u16 *dev_id)
880{ 915{
881 if (ata_id_is_sata(dev_id)) 916 if (ata_id_is_sata(dev_id))
882 return 0; /* SATA */ 917 return false; /* SATA */
883 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000) 918 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000)
884 return 0; /* 80 wire */ 919 return false; /* 80 wire */
885 return 1; 920 return true;
886} 921}
887 922
888static inline int ata_drive_40wire_relaxed(const u16 *dev_id) 923static inline bool ata_drive_40wire_relaxed(const u16 *dev_id)
889{ 924{
890 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000) 925 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000)
891 return 0; /* 80 wire */ 926 return false; /* 80 wire */
892 return 1; 927 return true;
893} 928}
894 929
895static inline int atapi_cdb_len(const u16 *dev_id) 930static inline int atapi_cdb_len(const u16 *dev_id)
@@ -902,12 +937,12 @@ static inline int atapi_cdb_len(const u16 *dev_id)
902 } 937 }
903} 938}
904 939
905static inline int atapi_command_packet_set(const u16 *dev_id) 940static inline bool atapi_command_packet_set(const u16 *dev_id)
906{ 941{
907 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f; 942 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f;
908} 943}
909 944
910static inline int atapi_id_dmadir(const u16 *dev_id) 945static inline bool atapi_id_dmadir(const u16 *dev_id)
911{ 946{
912 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); 947 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000);
913} 948}
@@ -920,13 +955,13 @@ static inline int atapi_id_dmadir(const u16 *dev_id)
920 * 955 *
921 * It is called only once for each device. 956 * It is called only once for each device.
922 */ 957 */
923static inline int ata_id_is_lba_capacity_ok(u16 *id) 958static inline bool ata_id_is_lba_capacity_ok(u16 *id)
924{ 959{
925 unsigned long lba_sects, chs_sects, head, tail; 960 unsigned long lba_sects, chs_sects, head, tail;
926 961
927 /* No non-LBA info .. so valid! */ 962 /* No non-LBA info .. so valid! */
928 if (id[ATA_ID_CYLS] == 0) 963 if (id[ATA_ID_CYLS] == 0)
929 return 1; 964 return true;
930 965
931 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); 966 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
932 967
@@ -941,13 +976,13 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
941 id[ATA_ID_SECTORS] == 63 && 976 id[ATA_ID_SECTORS] == 63 &&
942 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && 977 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) &&
943 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) 978 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS]))
944 return 1; 979 return true;
945 980
946 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; 981 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS];
947 982
948 /* perform a rough sanity check on lba_sects: within 10% is OK */ 983 /* perform a rough sanity check on lba_sects: within 10% is OK */
949 if (lba_sects - chs_sects < chs_sects/10) 984 if (lba_sects - chs_sects < chs_sects/10)
950 return 1; 985 return true;
951 986
952 /* some drives have the word order reversed */ 987 /* some drives have the word order reversed */
953 head = (lba_sects >> 16) & 0xffff; 988 head = (lba_sects >> 16) & 0xffff;
@@ -956,10 +991,10 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
956 991
957 if (lba_sects - chs_sects < chs_sects/10) { 992 if (lba_sects - chs_sects < chs_sects/10) {
958 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); 993 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects);
959 return 1; /* LBA capacity is (now) good */ 994 return true; /* LBA capacity is (now) good */
960 } 995 }
961 996
962 return 0; /* LBA capacity value may be bad */ 997 return false; /* LBA capacity value may be bad */
963} 998}
964 999
965static inline void ata_id_to_hd_driveid(u16 *id) 1000static inline void ata_id_to_hd_driveid(u16 *id)
@@ -1017,19 +1052,19 @@ static inline int is_multi_taskfile(struct ata_taskfile *tf)
1017 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT); 1052 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
1018} 1053}
1019 1054
1020static inline int ata_ok(u8 status) 1055static inline bool ata_ok(u8 status)
1021{ 1056{
1022 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) 1057 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
1023 == ATA_DRDY); 1058 == ATA_DRDY);
1024} 1059}
1025 1060
1026static inline int lba_28_ok(u64 block, u32 n_block) 1061static inline bool lba_28_ok(u64 block, u32 n_block)
1027{ 1062{
1028 /* check the ending block number: must be LESS THAN 0x0fffffff */ 1063 /* check the ending block number: must be LESS THAN 0x0fffffff */
1029 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256); 1064 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256);
1030} 1065}
1031 1066
1032static inline int lba_48_ok(u64 block, u32 n_block) 1067static inline bool lba_48_ok(u64 block, u32 n_block)
1033{ 1068{
1034 /* check the ending block number */ 1069 /* check the ending block number */
1035 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); 1070 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);
diff --git a/include/linux/ath9k_platform.h b/include/linux/ath9k_platform.h
index b847fc7b93f9..60a7c49dcb49 100644
--- a/include/linux/ath9k_platform.h
+++ b/include/linux/ath9k_platform.h
@@ -23,6 +23,13 @@
23 23
24struct ath9k_platform_data { 24struct ath9k_platform_data {
25 u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS]; 25 u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
26 u8 *macaddr;
27
28 int led_pin;
29 u32 gpio_mask;
30 u32 gpio_val;
31
32 bool is_clk_25mhz;
26}; 33};
27 34
28#endif /* _LINUX_ATH9K_PLATFORM_H */ 35#endif /* _LINUX_ATH9K_PLATFORM_H */
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index f6481daf6e52..381f4cec8260 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -427,8 +427,10 @@ extern rwlock_t vcc_sklist_lock;
427 427
428#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb)) 428#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb))
429 429
430struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops, 430struct atm_dev *atm_dev_register(const char *type, struct device *parent,
431 int number,unsigned long *flags); /* number == -1: pick first available */ 431 const struct atmdev_ops *ops,
432 int number, /* -1 == pick first available */
433 unsigned long *flags);
432struct atm_dev *atm_dev_lookup(int number); 434struct atm_dev *atm_dev_lookup(int number);
433void atm_dev_deregister(struct atm_dev *dev); 435void atm_dev_deregister(struct atm_dev *dev);
434 436
@@ -441,6 +443,7 @@ void atm_dev_signal_change(struct atm_dev *dev, char signal);
441 443
442void vcc_insert_socket(struct sock *sk); 444void vcc_insert_socket(struct sock *sk);
443 445
446void atm_dev_release_vccs(struct atm_dev *dev);
444 447
445/* 448/*
446 * This is approximately the algorithm used by alloc_skb. 449 * This is approximately the algorithm used by alloc_skb.
@@ -449,7 +452,7 @@ void vcc_insert_socket(struct sock *sk);
449 452
450static inline int atm_guess_pdu2truesize(int size) 453static inline int atm_guess_pdu2truesize(int size)
451{ 454{
452 return (SKB_DATA_ALIGN(size) + sizeof(struct skb_shared_info)); 455 return SKB_DATA_ALIGN(size) + sizeof(struct skb_shared_info);
453} 456}
454 457
455 458
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
new file mode 100644
index 000000000000..ee456c79b0e6
--- /dev/null
+++ b/include/linux/atomic.h
@@ -0,0 +1,50 @@
1#ifndef _LINUX_ATOMIC_H
2#define _LINUX_ATOMIC_H
3#include <asm/atomic.h>
4
5/**
6 * atomic_inc_not_zero_hint - increment if not null
7 * @v: pointer of type atomic_t
8 * @hint: probable value of the atomic before the increment
9 *
10 * This version of atomic_inc_not_zero() gives a hint of probable
11 * value of the atomic. This helps processor to not read the memory
12 * before doing the atomic read/modify/write cycle, lowering
13 * number of bus transactions on some arches.
14 *
15 * Returns: 0 if increment was not done, 1 otherwise.
16 */
17#ifndef atomic_inc_not_zero_hint
18static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
19{
20 int val, c = hint;
21
22 /* sanity test, should be removed by compiler if hint is a constant */
23 if (!hint)
24 return atomic_inc_not_zero(v);
25
26 do {
27 val = atomic_cmpxchg(v, c, c + 1);
28 if (val == c)
29 return 1;
30 c = val;
31 } while (c);
32
33 return 0;
34}
35#endif
36
37#ifndef CONFIG_ARCH_HAS_ATOMIC_OR
38static inline void atomic_or(int i, atomic_t *v)
39{
40 int old;
41 int new;
42
43 do {
44 old = atomic_read(v);
45 new = old | i;
46 } while (atomic_cmpxchg(v, old, new) != old);
47}
48#endif /* #ifndef CONFIG_ARCH_HAS_ATOMIC_OR */
49
50#endif /* _LINUX_ATOMIC_H */
diff --git a/include/linux/audit.h b/include/linux/audit.h
index e24afabc548f..9d339eb27881 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -102,6 +102,9 @@
102#define AUDIT_EOE 1320 /* End of multi-record event */ 102#define AUDIT_EOE 1320 /* End of multi-record event */
103#define AUDIT_BPRM_FCAPS 1321 /* Information about fcaps increasing perms */ 103#define AUDIT_BPRM_FCAPS 1321 /* Information about fcaps increasing perms */
104#define AUDIT_CAPSET 1322 /* Record showing argument to sys_capset */ 104#define AUDIT_CAPSET 1322 /* Record showing argument to sys_capset */
105#define AUDIT_MMAP 1323 /* Record showing descriptor and flags in mmap */
106#define AUDIT_NETFILTER_PKT 1324 /* Packets traversing netfilter chains */
107#define AUDIT_NETFILTER_CFG 1325 /* Netfilter chain modifications */
105 108
106#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ 109#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
107#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ 110#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
@@ -371,6 +374,7 @@ struct audit_buffer;
371struct audit_context; 374struct audit_context;
372struct inode; 375struct inode;
373struct netlink_skb_parms; 376struct netlink_skb_parms;
377struct path;
374struct linux_binprm; 378struct linux_binprm;
375struct mq_attr; 379struct mq_attr;
376struct mqstat; 380struct mqstat;
@@ -478,6 +482,7 @@ extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
478 const struct cred *new, 482 const struct cred *new,
479 const struct cred *old); 483 const struct cred *old);
480extern void __audit_log_capset(pid_t pid, const struct cred *new, const struct cred *old); 484extern void __audit_log_capset(pid_t pid, const struct cred *new, const struct cred *old);
485extern void __audit_mmap_fd(int fd, int flags);
481 486
482static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) 487static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
483{ 488{
@@ -531,6 +536,12 @@ static inline void audit_log_capset(pid_t pid, const struct cred *new,
531 __audit_log_capset(pid, new, old); 536 __audit_log_capset(pid, new, old);
532} 537}
533 538
539static inline void audit_mmap_fd(int fd, int flags)
540{
541 if (unlikely(!audit_dummy_context()))
542 __audit_mmap_fd(fd, flags);
543}
544
534extern int audit_n_rules; 545extern int audit_n_rules;
535extern int audit_signals; 546extern int audit_signals;
536#else 547#else
@@ -564,6 +575,7 @@ extern int audit_signals;
564#define audit_mq_getsetattr(d,s) ((void)0) 575#define audit_mq_getsetattr(d,s) ((void)0)
565#define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; }) 576#define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; })
566#define audit_log_capset(pid, ncr, ocr) ((void)0) 577#define audit_log_capset(pid, ncr, ocr) ((void)0)
578#define audit_mmap_fd(fd, flags) ((void)0)
567#define audit_ptrace(t) ((void)0) 579#define audit_ptrace(t) ((void)0)
568#define audit_n_rules 0 580#define audit_n_rules 0
569#define audit_signals 0 581#define audit_signals 0
diff --git a/include/linux/auto_fs4.h b/include/linux/auto_fs4.h
index 8b49ac48a5b7..e02982fa2953 100644
--- a/include/linux/auto_fs4.h
+++ b/include/linux/auto_fs4.h
@@ -24,7 +24,7 @@
24#define AUTOFS_MIN_PROTO_VERSION 3 24#define AUTOFS_MIN_PROTO_VERSION 3
25#define AUTOFS_MAX_PROTO_VERSION 5 25#define AUTOFS_MAX_PROTO_VERSION 5
26 26
27#define AUTOFS_PROTO_SUBVERSION 1 27#define AUTOFS_PROTO_SUBVERSION 2
28 28
29/* Mask for expire behaviour */ 29/* Mask for expire behaviour */
30#define AUTOFS_EXP_IMMEDIATE 1 30#define AUTOFS_EXP_IMMEDIATE 1
diff --git a/include/linux/average.h b/include/linux/average.h
new file mode 100644
index 000000000000..c6028fd742c1
--- /dev/null
+++ b/include/linux/average.h
@@ -0,0 +1,30 @@
1#ifndef _LINUX_AVERAGE_H
2#define _LINUX_AVERAGE_H
3
4/* Exponentially weighted moving average (EWMA) */
5
6/* For more documentation see lib/average.c */
7
8struct ewma {
9 unsigned long internal;
10 unsigned long factor;
11 unsigned long weight;
12};
13
14extern void ewma_init(struct ewma *avg, unsigned long factor,
15 unsigned long weight);
16
17extern struct ewma *ewma_add(struct ewma *avg, unsigned long val);
18
19/**
20 * ewma_read() - Get average value
21 * @avg: Average structure
22 *
23 * Returns the average value held in @avg.
24 */
25static inline unsigned long ewma_read(const struct ewma *avg)
26{
27 return avg->internal >> avg->factor;
28}
29
30#endif /* _LINUX_AVERAGE_H */
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 35b00746c712..96f4094b706d 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -66,8 +66,6 @@ struct backing_dev_info {
66 unsigned int capabilities; /* Device capabilities */ 66 unsigned int capabilities; /* Device capabilities */
67 congested_fn *congested_fn; /* Function pointer if device is md/dm */ 67 congested_fn *congested_fn; /* Function pointer if device is md/dm */
68 void *congested_data; /* Pointer to aux data for congested func */ 68 void *congested_data; /* Pointer to aux data for congested func */
69 void (*unplug_io_fn)(struct backing_dev_info *, struct page *);
70 void *unplug_io_data;
71 69
72 char *name; 70 char *name;
73 71
@@ -111,6 +109,7 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi);
111 109
112extern spinlock_t bdi_lock; 110extern spinlock_t bdi_lock;
113extern struct list_head bdi_list; 111extern struct list_head bdi_list;
112extern struct list_head bdi_pending_list;
114 113
115static inline int wb_has_dirty_io(struct bdi_writeback *wb) 114static inline int wb_has_dirty_io(struct bdi_writeback *wb)
116{ 115{
@@ -250,7 +249,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
250 249
251extern struct backing_dev_info default_backing_dev_info; 250extern struct backing_dev_info default_backing_dev_info;
252extern struct backing_dev_info noop_backing_dev_info; 251extern struct backing_dev_info noop_backing_dev_info;
253void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page);
254 252
255int writeback_in_progress(struct backing_dev_info *bdi); 253int writeback_in_progress(struct backing_dev_info *bdi);
256 254
@@ -285,7 +283,7 @@ enum {
285void clear_bdi_congested(struct backing_dev_info *bdi, int sync); 283void clear_bdi_congested(struct backing_dev_info *bdi, int sync);
286void set_bdi_congested(struct backing_dev_info *bdi, int sync); 284void set_bdi_congested(struct backing_dev_info *bdi, int sync);
287long congestion_wait(int sync, long timeout); 285long congestion_wait(int sync, long timeout);
288 286long wait_iff_congested(struct zone *zone, int sync, long timeout);
289 287
290static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi) 288static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi)
291{ 289{
@@ -335,17 +333,4 @@ static inline int bdi_sched_wait(void *word)
335 return 0; 333 return 0;
336} 334}
337 335
338static inline void blk_run_backing_dev(struct backing_dev_info *bdi,
339 struct page *page)
340{
341 if (bdi && bdi->unplug_io_fn)
342 bdi->unplug_io_fn(bdi, page);
343}
344
345static inline void blk_run_address_space(struct address_space *mapping)
346{
347 if (mapping)
348 blk_run_backing_dev(mapping->backing_dev_info, NULL);
349}
350
351#endif /* _LINUX_BACKING_DEV_H */ 336#endif /* _LINUX_BACKING_DEV_H */
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 4a3d52e545e1..5ffc6dda4675 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -32,6 +32,13 @@ enum backlight_update_reason {
32 BACKLIGHT_UPDATE_SYSFS, 32 BACKLIGHT_UPDATE_SYSFS,
33}; 33};
34 34
35enum backlight_type {
36 BACKLIGHT_RAW = 1,
37 BACKLIGHT_PLATFORM,
38 BACKLIGHT_FIRMWARE,
39 BACKLIGHT_TYPE_MAX,
40};
41
35struct backlight_device; 42struct backlight_device;
36struct fb_info; 43struct fb_info;
37 44
@@ -62,6 +69,8 @@ struct backlight_properties {
62 /* FB Blanking active? (values as for power) */ 69 /* FB Blanking active? (values as for power) */
63 /* Due to be removed, please use (state & BL_CORE_FBBLANK) */ 70 /* Due to be removed, please use (state & BL_CORE_FBBLANK) */
64 int fb_blank; 71 int fb_blank;
72 /* Backlight type */
73 enum backlight_type type;
65 /* Flags used to signal drivers of state changes */ 74 /* Flags used to signal drivers of state changes */
66 /* Upper 4 bits are reserved for driver internal use */ 75 /* Upper 4 bits are reserved for driver internal use */
67 unsigned int state; 76 unsigned int state;
diff --git a/include/linux/basic_mmio_gpio.h b/include/linux/basic_mmio_gpio.h
new file mode 100644
index 000000000000..98999cf107ce
--- /dev/null
+++ b/include/linux/basic_mmio_gpio.h
@@ -0,0 +1,77 @@
1/*
2 * Basic memory-mapped GPIO controllers.
3 *
4 * Copyright 2008 MontaVista Software, Inc.
5 * Copyright 2008,2010 Anton Vorontsov <cbouatmailru@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#ifndef __BASIC_MMIO_GPIO_H
14#define __BASIC_MMIO_GPIO_H
15
16#include <linux/gpio.h>
17#include <linux/types.h>
18#include <linux/compiler.h>
19#include <linux/spinlock_types.h>
20
21struct bgpio_pdata {
22 int base;
23 int ngpio;
24};
25
26struct device;
27
28struct bgpio_chip {
29 struct gpio_chip gc;
30
31 unsigned long (*read_reg)(void __iomem *reg);
32 void (*write_reg)(void __iomem *reg, unsigned long data);
33
34 void __iomem *reg_dat;
35 void __iomem *reg_set;
36 void __iomem *reg_clr;
37 void __iomem *reg_dir;
38
39 /* Number of bits (GPIOs): <register width> * 8. */
40 int bits;
41
42 /*
43 * Some GPIO controllers work with the big-endian bits notation,
44 * e.g. in a 8-bits register, GPIO7 is the least significant bit.
45 */
46 unsigned long (*pin2mask)(struct bgpio_chip *bgc, unsigned int pin);
47
48 /*
49 * Used to lock bgpio_chip->data. Also, this is needed to keep
50 * shadowed and real data registers writes together.
51 */
52 spinlock_t lock;
53
54 /* Shadowed data register to clear/set bits safely. */
55 unsigned long data;
56
57 /* Shadowed direction registers to clear/set direction safely. */
58 unsigned long dir;
59};
60
61static inline struct bgpio_chip *to_bgpio_chip(struct gpio_chip *gc)
62{
63 return container_of(gc, struct bgpio_chip, gc);
64}
65
66int __devexit bgpio_remove(struct bgpio_chip *bgc);
67int __devinit bgpio_init(struct bgpio_chip *bgc,
68 struct device *dev,
69 unsigned long sz,
70 void __iomem *dat,
71 void __iomem *set,
72 void __iomem *clr,
73 void __iomem *dirout,
74 void __iomem *dirin,
75 bool big_endian);
76
77#endif /* __BASIC_MMIO_GPIO_H */
diff --git a/include/linux/bch.h b/include/linux/bch.h
new file mode 100644
index 000000000000..295b4ef153bb
--- /dev/null
+++ b/include/linux/bch.h
@@ -0,0 +1,79 @@
1/*
2 * Generic binary BCH encoding/decoding library
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Copyright © 2011 Parrot S.A.
18 *
19 * Author: Ivan Djelic <ivan.djelic@parrot.com>
20 *
21 * Description:
22 *
23 * This library provides runtime configurable encoding/decoding of binary
24 * Bose-Chaudhuri-Hocquenghem (BCH) codes.
25*/
26#ifndef _BCH_H
27#define _BCH_H
28
29#include <linux/types.h>
30
31/**
32 * struct bch_control - BCH control structure
33 * @m: Galois field order
34 * @n: maximum codeword size in bits (= 2^m-1)
35 * @t: error correction capability in bits
36 * @ecc_bits: ecc exact size in bits, i.e. generator polynomial degree (<=m*t)
37 * @ecc_bytes: ecc max size (m*t bits) in bytes
38 * @a_pow_tab: Galois field GF(2^m) exponentiation lookup table
39 * @a_log_tab: Galois field GF(2^m) log lookup table
40 * @mod8_tab: remainder generator polynomial lookup tables
41 * @ecc_buf: ecc parity words buffer
42 * @ecc_buf2: ecc parity words buffer
43 * @xi_tab: GF(2^m) base for solving degree 2 polynomial roots
44 * @syn: syndrome buffer
45 * @cache: log-based polynomial representation buffer
46 * @elp: error locator polynomial
47 * @poly_2t: temporary polynomials of degree 2t
48 */
49struct bch_control {
50 unsigned int m;
51 unsigned int n;
52 unsigned int t;
53 unsigned int ecc_bits;
54 unsigned int ecc_bytes;
55/* private: */
56 uint16_t *a_pow_tab;
57 uint16_t *a_log_tab;
58 uint32_t *mod8_tab;
59 uint32_t *ecc_buf;
60 uint32_t *ecc_buf2;
61 unsigned int *xi_tab;
62 unsigned int *syn;
63 int *cache;
64 struct gf_poly *elp;
65 struct gf_poly *poly_2t[4];
66};
67
68struct bch_control *init_bch(int m, int t, unsigned int prim_poly);
69
70void free_bch(struct bch_control *bch);
71
72void encode_bch(struct bch_control *bch, const uint8_t *data,
73 unsigned int len, uint8_t *ecc);
74
75int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len,
76 const uint8_t *recv_ecc, const uint8_t *calc_ecc,
77 const unsigned int *syn, unsigned int *errloc);
78
79#endif /* _BCH_H */
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
new file mode 100644
index 000000000000..08763e4e848f
--- /dev/null
+++ b/include/linux/bcma/bcma.h
@@ -0,0 +1,224 @@
1#ifndef LINUX_BCMA_H_
2#define LINUX_BCMA_H_
3
4#include <linux/pci.h>
5#include <linux/mod_devicetable.h>
6
7#include <linux/bcma/bcma_driver_chipcommon.h>
8#include <linux/bcma/bcma_driver_pci.h>
9
10#include "bcma_regs.h"
11
12struct bcma_device;
13struct bcma_bus;
14
15enum bcma_hosttype {
16 BCMA_HOSTTYPE_NONE,
17 BCMA_HOSTTYPE_PCI,
18 BCMA_HOSTTYPE_SDIO,
19};
20
21struct bcma_chipinfo {
22 u16 id;
23 u8 rev;
24 u8 pkg;
25};
26
27struct bcma_host_ops {
28 u8 (*read8)(struct bcma_device *core, u16 offset);
29 u16 (*read16)(struct bcma_device *core, u16 offset);
30 u32 (*read32)(struct bcma_device *core, u16 offset);
31 void (*write8)(struct bcma_device *core, u16 offset, u8 value);
32 void (*write16)(struct bcma_device *core, u16 offset, u16 value);
33 void (*write32)(struct bcma_device *core, u16 offset, u32 value);
34 /* Agent ops */
35 u32 (*aread32)(struct bcma_device *core, u16 offset);
36 void (*awrite32)(struct bcma_device *core, u16 offset, u32 value);
37};
38
39/* Core manufacturers */
40#define BCMA_MANUF_ARM 0x43B
41#define BCMA_MANUF_MIPS 0x4A7
42#define BCMA_MANUF_BCM 0x4BF
43
44/* Core class values. */
45#define BCMA_CL_SIM 0x0
46#define BCMA_CL_EROM 0x1
47#define BCMA_CL_CORESIGHT 0x9
48#define BCMA_CL_VERIF 0xB
49#define BCMA_CL_OPTIMO 0xD
50#define BCMA_CL_GEN 0xE
51#define BCMA_CL_PRIMECELL 0xF
52
53/* Core-ID values. */
54#define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
55#define BCMA_CORE_INVALID 0x700
56#define BCMA_CORE_CHIPCOMMON 0x800
57#define BCMA_CORE_ILINE20 0x801
58#define BCMA_CORE_SRAM 0x802
59#define BCMA_CORE_SDRAM 0x803
60#define BCMA_CORE_PCI 0x804
61#define BCMA_CORE_MIPS 0x805
62#define BCMA_CORE_ETHERNET 0x806
63#define BCMA_CORE_V90 0x807
64#define BCMA_CORE_USB11_HOSTDEV 0x808
65#define BCMA_CORE_ADSL 0x809
66#define BCMA_CORE_ILINE100 0x80A
67#define BCMA_CORE_IPSEC 0x80B
68#define BCMA_CORE_UTOPIA 0x80C
69#define BCMA_CORE_PCMCIA 0x80D
70#define BCMA_CORE_INTERNAL_MEM 0x80E
71#define BCMA_CORE_MEMC_SDRAM 0x80F
72#define BCMA_CORE_OFDM 0x810
73#define BCMA_CORE_EXTIF 0x811
74#define BCMA_CORE_80211 0x812
75#define BCMA_CORE_PHY_A 0x813
76#define BCMA_CORE_PHY_B 0x814
77#define BCMA_CORE_PHY_G 0x815
78#define BCMA_CORE_MIPS_3302 0x816
79#define BCMA_CORE_USB11_HOST 0x817
80#define BCMA_CORE_USB11_DEV 0x818
81#define BCMA_CORE_USB20_HOST 0x819
82#define BCMA_CORE_USB20_DEV 0x81A
83#define BCMA_CORE_SDIO_HOST 0x81B
84#define BCMA_CORE_ROBOSWITCH 0x81C
85#define BCMA_CORE_PARA_ATA 0x81D
86#define BCMA_CORE_SATA_XORDMA 0x81E
87#define BCMA_CORE_ETHERNET_GBIT 0x81F
88#define BCMA_CORE_PCIE 0x820
89#define BCMA_CORE_PHY_N 0x821
90#define BCMA_CORE_SRAM_CTL 0x822
91#define BCMA_CORE_MINI_MACPHY 0x823
92#define BCMA_CORE_ARM_1176 0x824
93#define BCMA_CORE_ARM_7TDMI 0x825
94#define BCMA_CORE_PHY_LP 0x826
95#define BCMA_CORE_PMU 0x827
96#define BCMA_CORE_PHY_SSN 0x828
97#define BCMA_CORE_SDIO_DEV 0x829
98#define BCMA_CORE_ARM_CM3 0x82A
99#define BCMA_CORE_PHY_HT 0x82B
100#define BCMA_CORE_MIPS_74K 0x82C
101#define BCMA_CORE_MAC_GBIT 0x82D
102#define BCMA_CORE_DDR12_MEM_CTL 0x82E
103#define BCMA_CORE_PCIE_RC 0x82F /* PCIe Root Complex */
104#define BCMA_CORE_OCP_OCP_BRIDGE 0x830
105#define BCMA_CORE_SHARED_COMMON 0x831
106#define BCMA_CORE_OCP_AHB_BRIDGE 0x832
107#define BCMA_CORE_SPI_HOST 0x833
108#define BCMA_CORE_I2S 0x834
109#define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
110#define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
111#define BCMA_CORE_DEFAULT 0xFFF
112
113#define BCMA_MAX_NR_CORES 16
114
115struct bcma_device {
116 struct bcma_bus *bus;
117 struct bcma_device_id id;
118
119 struct device dev;
120 bool dev_registered;
121
122 u8 core_index;
123
124 u32 addr;
125 u32 wrap;
126
127 void *drvdata;
128 struct list_head list;
129};
130
131static inline void *bcma_get_drvdata(struct bcma_device *core)
132{
133 return core->drvdata;
134}
135static inline void bcma_set_drvdata(struct bcma_device *core, void *drvdata)
136{
137 core->drvdata = drvdata;
138}
139
140struct bcma_driver {
141 const char *name;
142 const struct bcma_device_id *id_table;
143
144 int (*probe)(struct bcma_device *dev);
145 void (*remove)(struct bcma_device *dev);
146 int (*suspend)(struct bcma_device *dev, pm_message_t state);
147 int (*resume)(struct bcma_device *dev);
148 void (*shutdown)(struct bcma_device *dev);
149
150 struct device_driver drv;
151};
152extern
153int __bcma_driver_register(struct bcma_driver *drv, struct module *owner);
154static inline int bcma_driver_register(struct bcma_driver *drv)
155{
156 return __bcma_driver_register(drv, THIS_MODULE);
157}
158extern void bcma_driver_unregister(struct bcma_driver *drv);
159
160struct bcma_bus {
161 /* The MMIO area. */
162 void __iomem *mmio;
163
164 const struct bcma_host_ops *ops;
165
166 enum bcma_hosttype hosttype;
167 union {
168 /* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
169 struct pci_dev *host_pci;
170 /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
171 struct sdio_func *host_sdio;
172 };
173
174 struct bcma_chipinfo chipinfo;
175
176 struct bcma_device *mapped_core;
177 struct list_head cores;
178 u8 nr_cores;
179
180 struct bcma_drv_cc drv_cc;
181 struct bcma_drv_pci drv_pci;
182};
183
184extern inline u32 bcma_read8(struct bcma_device *core, u16 offset)
185{
186 return core->bus->ops->read8(core, offset);
187}
188extern inline u32 bcma_read16(struct bcma_device *core, u16 offset)
189{
190 return core->bus->ops->read16(core, offset);
191}
192extern inline u32 bcma_read32(struct bcma_device *core, u16 offset)
193{
194 return core->bus->ops->read32(core, offset);
195}
196extern inline
197void bcma_write8(struct bcma_device *core, u16 offset, u32 value)
198{
199 core->bus->ops->write8(core, offset, value);
200}
201extern inline
202void bcma_write16(struct bcma_device *core, u16 offset, u32 value)
203{
204 core->bus->ops->write16(core, offset, value);
205}
206extern inline
207void bcma_write32(struct bcma_device *core, u16 offset, u32 value)
208{
209 core->bus->ops->write32(core, offset, value);
210}
211extern inline u32 bcma_aread32(struct bcma_device *core, u16 offset)
212{
213 return core->bus->ops->aread32(core, offset);
214}
215extern inline
216void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value)
217{
218 core->bus->ops->awrite32(core, offset, value);
219}
220
221extern bool bcma_core_is_enabled(struct bcma_device *core);
222extern int bcma_core_enable(struct bcma_device *core, u32 flags);
223
224#endif /* LINUX_BCMA_H_ */
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
new file mode 100644
index 000000000000..083c3b6cd5ce
--- /dev/null
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -0,0 +1,302 @@
1#ifndef LINUX_BCMA_DRIVER_CC_H_
2#define LINUX_BCMA_DRIVER_CC_H_
3
4/** ChipCommon core registers. **/
5#define BCMA_CC_ID 0x0000
6#define BCMA_CC_ID_ID 0x0000FFFF
7#define BCMA_CC_ID_ID_SHIFT 0
8#define BCMA_CC_ID_REV 0x000F0000
9#define BCMA_CC_ID_REV_SHIFT 16
10#define BCMA_CC_ID_PKG 0x00F00000
11#define BCMA_CC_ID_PKG_SHIFT 20
12#define BCMA_CC_ID_NRCORES 0x0F000000
13#define BCMA_CC_ID_NRCORES_SHIFT 24
14#define BCMA_CC_ID_TYPE 0xF0000000
15#define BCMA_CC_ID_TYPE_SHIFT 28
16#define BCMA_CC_CAP 0x0004 /* Capabilities */
17#define BCMA_CC_CAP_NRUART 0x00000003 /* # of UARTs */
18#define BCMA_CC_CAP_MIPSEB 0x00000004 /* MIPS in BigEndian Mode */
19#define BCMA_CC_CAP_UARTCLK 0x00000018 /* UART clock select */
20#define BCMA_CC_CAP_UARTCLK_INT 0x00000008 /* UARTs are driven by internal divided clock */
21#define BCMA_CC_CAP_UARTGPIO 0x00000020 /* UARTs on GPIO 15-12 */
22#define BCMA_CC_CAP_EXTBUS 0x000000C0 /* External buses present */
23#define BCMA_CC_CAP_FLASHT 0x00000700 /* Flash Type */
24#define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
25#define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
26#define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
27#define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
28#define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
29#define BCMA_PLLTYPE_NONE 0x00000000
30#define BCMA_PLLTYPE_1 0x00010000 /* 48Mhz base, 3 dividers */
31#define BCMA_PLLTYPE_2 0x00020000 /* 48Mhz, 4 dividers */
32#define BCMA_PLLTYPE_3 0x00030000 /* 25Mhz, 2 dividers */
33#define BCMA_PLLTYPE_4 0x00008000 /* 48Mhz, 4 dividers */
34#define BCMA_PLLTYPE_5 0x00018000 /* 25Mhz, 4 dividers */
35#define BCMA_PLLTYPE_6 0x00028000 /* 100/200 or 120/240 only */
36#define BCMA_PLLTYPE_7 0x00038000 /* 25Mhz, 4 dividers */
37#define BCMA_CC_CAP_PCTL 0x00040000 /* Power Control */
38#define BCMA_CC_CAP_OTPS 0x00380000 /* OTP size */
39#define BCMA_CC_CAP_OTPS_SHIFT 19
40#define BCMA_CC_CAP_OTPS_BASE 5
41#define BCMA_CC_CAP_JTAGM 0x00400000 /* JTAG master present */
42#define BCMA_CC_CAP_BROM 0x00800000 /* Internal boot ROM active */
43#define BCMA_CC_CAP_64BIT 0x08000000 /* 64-bit Backplane */
44#define BCMA_CC_CAP_PMU 0x10000000 /* PMU available (rev >= 20) */
45#define BCMA_CC_CAP_ECI 0x20000000 /* ECI available (rev >= 20) */
46#define BCMA_CC_CAP_SPROM 0x40000000 /* SPROM present */
47#define BCMA_CC_CORECTL 0x0008
48#define BCMA_CC_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */
49#define BCMA_CC_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
50#define BCMA_CC_CORECTL_UARTCLKEN 0x00000008 /* UART clock enable (rev >= 21) */
51#define BCMA_CC_BIST 0x000C
52#define BCMA_CC_OTPS 0x0010 /* OTP status */
53#define BCMA_CC_OTPS_PROGFAIL 0x80000000
54#define BCMA_CC_OTPS_PROTECT 0x00000007
55#define BCMA_CC_OTPS_HW_PROTECT 0x00000001
56#define BCMA_CC_OTPS_SW_PROTECT 0x00000002
57#define BCMA_CC_OTPS_CID_PROTECT 0x00000004
58#define BCMA_CC_OTPC 0x0014 /* OTP control */
59#define BCMA_CC_OTPC_RECWAIT 0xFF000000
60#define BCMA_CC_OTPC_PROGWAIT 0x00FFFF00
61#define BCMA_CC_OTPC_PRW_SHIFT 8
62#define BCMA_CC_OTPC_MAXFAIL 0x00000038
63#define BCMA_CC_OTPC_VSEL 0x00000006
64#define BCMA_CC_OTPC_SELVL 0x00000001
65#define BCMA_CC_OTPP 0x0018 /* OTP prog */
66#define BCMA_CC_OTPP_COL 0x000000FF
67#define BCMA_CC_OTPP_ROW 0x0000FF00
68#define BCMA_CC_OTPP_ROW_SHIFT 8
69#define BCMA_CC_OTPP_READERR 0x10000000
70#define BCMA_CC_OTPP_VALUE 0x20000000
71#define BCMA_CC_OTPP_READ 0x40000000
72#define BCMA_CC_OTPP_START 0x80000000
73#define BCMA_CC_OTPP_BUSY 0x80000000
74#define BCMA_CC_IRQSTAT 0x0020
75#define BCMA_CC_IRQMASK 0x0024
76#define BCMA_CC_IRQ_GPIO 0x00000001 /* gpio intr */
77#define BCMA_CC_IRQ_EXT 0x00000002 /* ro: ext intr pin (corerev >= 3) */
78#define BCMA_CC_IRQ_WDRESET 0x80000000 /* watchdog reset occurred */
79#define BCMA_CC_CHIPCTL 0x0028 /* Rev >= 11 only */
80#define BCMA_CC_CHIPSTAT 0x002C /* Rev >= 11 only */
81#define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
82#define BCMA_CC_JCMD_START 0x80000000
83#define BCMA_CC_JCMD_BUSY 0x80000000
84#define BCMA_CC_JCMD_PAUSE 0x40000000
85#define BCMA_CC_JCMD0_ACC_MASK 0x0000F000
86#define BCMA_CC_JCMD0_ACC_IRDR 0x00000000
87#define BCMA_CC_JCMD0_ACC_DR 0x00001000
88#define BCMA_CC_JCMD0_ACC_IR 0x00002000
89#define BCMA_CC_JCMD0_ACC_RESET 0x00003000
90#define BCMA_CC_JCMD0_ACC_IRPDR 0x00004000
91#define BCMA_CC_JCMD0_ACC_PDR 0x00005000
92#define BCMA_CC_JCMD0_IRW_MASK 0x00000F00
93#define BCMA_CC_JCMD_ACC_MASK 0x000F0000 /* Changes for corerev 11 */
94#define BCMA_CC_JCMD_ACC_IRDR 0x00000000
95#define BCMA_CC_JCMD_ACC_DR 0x00010000
96#define BCMA_CC_JCMD_ACC_IR 0x00020000
97#define BCMA_CC_JCMD_ACC_RESET 0x00030000
98#define BCMA_CC_JCMD_ACC_IRPDR 0x00040000
99#define BCMA_CC_JCMD_ACC_PDR 0x00050000
100#define BCMA_CC_JCMD_IRW_MASK 0x00001F00
101#define BCMA_CC_JCMD_IRW_SHIFT 8
102#define BCMA_CC_JCMD_DRW_MASK 0x0000003F
103#define BCMA_CC_JIR 0x0034 /* Rev >= 10 only */
104#define BCMA_CC_JDR 0x0038 /* Rev >= 10 only */
105#define BCMA_CC_JCTL 0x003C /* Rev >= 10 only */
106#define BCMA_CC_JCTL_FORCE_CLK 4 /* Force clock */
107#define BCMA_CC_JCTL_EXT_EN 2 /* Enable external targets */
108#define BCMA_CC_JCTL_EN 1 /* Enable Jtag master */
109#define BCMA_CC_FLASHCTL 0x0040
110#define BCMA_CC_FLASHCTL_START 0x80000000
111#define BCMA_CC_FLASHCTL_BUSY BCMA_CC_FLASHCTL_START
112#define BCMA_CC_FLASHADDR 0x0044
113#define BCMA_CC_FLASHDATA 0x0048
114#define BCMA_CC_BCAST_ADDR 0x0050
115#define BCMA_CC_BCAST_DATA 0x0054
116#define BCMA_CC_GPIOPULLUP 0x0058 /* Rev >= 20 only */
117#define BCMA_CC_GPIOPULLDOWN 0x005C /* Rev >= 20 only */
118#define BCMA_CC_GPIOIN 0x0060
119#define BCMA_CC_GPIOOUT 0x0064
120#define BCMA_CC_GPIOOUTEN 0x0068
121#define BCMA_CC_GPIOCTL 0x006C
122#define BCMA_CC_GPIOPOL 0x0070
123#define BCMA_CC_GPIOIRQ 0x0074
124#define BCMA_CC_WATCHDOG 0x0080
125#define BCMA_CC_GPIOTIMER 0x0088 /* LED powersave (corerev >= 16) */
126#define BCMA_CC_GPIOTIMER_OFFTIME 0x0000FFFF
127#define BCMA_CC_GPIOTIMER_OFFTIME_SHIFT 0
128#define BCMA_CC_GPIOTIMER_ONTIME 0xFFFF0000
129#define BCMA_CC_GPIOTIMER_ONTIME_SHIFT 16
130#define BCMA_CC_GPIOTOUTM 0x008C /* LED powersave (corerev >= 16) */
131#define BCMA_CC_CLOCK_N 0x0090
132#define BCMA_CC_CLOCK_SB 0x0094
133#define BCMA_CC_CLOCK_PCI 0x0098
134#define BCMA_CC_CLOCK_M2 0x009C
135#define BCMA_CC_CLOCK_MIPS 0x00A0
136#define BCMA_CC_CLKDIV 0x00A4 /* Rev >= 3 only */
137#define BCMA_CC_CLKDIV_SFLASH 0x0F000000
138#define BCMA_CC_CLKDIV_SFLASH_SHIFT 24
139#define BCMA_CC_CLKDIV_OTP 0x000F0000
140#define BCMA_CC_CLKDIV_OTP_SHIFT 16
141#define BCMA_CC_CLKDIV_JTAG 0x00000F00
142#define BCMA_CC_CLKDIV_JTAG_SHIFT 8
143#define BCMA_CC_CLKDIV_UART 0x000000FF
144#define BCMA_CC_CAP_EXT 0x00AC /* Capabilities */
145#define BCMA_CC_PLLONDELAY 0x00B0 /* Rev >= 4 only */
146#define BCMA_CC_FREFSELDELAY 0x00B4 /* Rev >= 4 only */
147#define BCMA_CC_SLOWCLKCTL 0x00B8 /* 6 <= Rev <= 9 only */
148#define BCMA_CC_SLOWCLKCTL_SRC 0x00000007 /* slow clock source mask */
149#define BCMA_CC_SLOWCLKCTL_SRC_LPO 0x00000000 /* source of slow clock is LPO */
150#define BCMA_CC_SLOWCLKCTL_SRC_XTAL 0x00000001 /* source of slow clock is crystal */
151#define BCMA_CC_SLOECLKCTL_SRC_PCI 0x00000002 /* source of slow clock is PCI */
152#define BCMA_CC_SLOWCLKCTL_LPOFREQ 0x00000200 /* LPOFreqSel, 1: 160Khz, 0: 32KHz */
153#define BCMA_CC_SLOWCLKCTL_LPOPD 0x00000400 /* LPOPowerDown, 1: LPO is disabled, 0: LPO is enabled */
154#define BCMA_CC_SLOWCLKCTL_FSLOW 0x00000800 /* ForceSlowClk, 1: sb/cores running on slow clock, 0: power logic control */
155#define BCMA_CC_SLOWCLKCTL_IPLL 0x00001000 /* IgnorePllOffReq, 1/0: power logic ignores/honors PLL clock disable requests from core */
156#define BCMA_CC_SLOWCLKCTL_ENXTAL 0x00002000 /* XtalControlEn, 1/0: power logic does/doesn't disable crystal when appropriate */
157#define BCMA_CC_SLOWCLKCTL_XTALPU 0x00004000 /* XtalPU (RO), 1/0: crystal running/disabled */
158#define BCMA_CC_SLOWCLKCTL_CLKDIV 0xFFFF0000 /* ClockDivider (SlowClk = 1/(4+divisor)) */
159#define BCMA_CC_SLOWCLKCTL_CLKDIV_SHIFT 16
160#define BCMA_CC_SYSCLKCTL 0x00C0 /* Rev >= 3 only */
161#define BCMA_CC_SYSCLKCTL_IDLPEN 0x00000001 /* ILPen: Enable Idle Low Power */
162#define BCMA_CC_SYSCLKCTL_ALPEN 0x00000002 /* ALPen: Enable Active Low Power */
163#define BCMA_CC_SYSCLKCTL_PLLEN 0x00000004 /* ForcePLLOn */
164#define BCMA_CC_SYSCLKCTL_FORCEALP 0x00000008 /* Force ALP (or HT if ALPen is not set */
165#define BCMA_CC_SYSCLKCTL_FORCEHT 0x00000010 /* Force HT */
166#define BCMA_CC_SYSCLKCTL_CLKDIV 0xFFFF0000 /* ClkDiv (ILP = 1/(4+divisor)) */
167#define BCMA_CC_SYSCLKCTL_CLKDIV_SHIFT 16
168#define BCMA_CC_CLKSTSTR 0x00C4 /* Rev >= 3 only */
169#define BCMA_CC_EROM 0x00FC
170#define BCMA_CC_PCMCIA_CFG 0x0100
171#define BCMA_CC_PCMCIA_MEMWAIT 0x0104
172#define BCMA_CC_PCMCIA_ATTRWAIT 0x0108
173#define BCMA_CC_PCMCIA_IOWAIT 0x010C
174#define BCMA_CC_IDE_CFG 0x0110
175#define BCMA_CC_IDE_MEMWAIT 0x0114
176#define BCMA_CC_IDE_ATTRWAIT 0x0118
177#define BCMA_CC_IDE_IOWAIT 0x011C
178#define BCMA_CC_PROG_CFG 0x0120
179#define BCMA_CC_PROG_WAITCNT 0x0124
180#define BCMA_CC_FLASH_CFG 0x0128
181#define BCMA_CC_FLASH_WAITCNT 0x012C
182#define BCMA_CC_CLKCTLST 0x01E0 /* Clock control and status (rev >= 20) */
183#define BCMA_CC_CLKCTLST_FORCEALP 0x00000001 /* Force ALP request */
184#define BCMA_CC_CLKCTLST_FORCEHT 0x00000002 /* Force HT request */
185#define BCMA_CC_CLKCTLST_FORCEILP 0x00000004 /* Force ILP request */
186#define BCMA_CC_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
187#define BCMA_CC_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
188#define BCMA_CC_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
189#define BCMA_CC_CLKCTLST_HAVEHT 0x00010000 /* HT available */
190#define BCMA_CC_CLKCTLST_HAVEALP 0x00020000 /* APL available */
191#define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
192#define BCMA_CC_UART0_DATA 0x0300
193#define BCMA_CC_UART0_IMR 0x0304
194#define BCMA_CC_UART0_FCR 0x0308
195#define BCMA_CC_UART0_LCR 0x030C
196#define BCMA_CC_UART0_MCR 0x0310
197#define BCMA_CC_UART0_LSR 0x0314
198#define BCMA_CC_UART0_MSR 0x0318
199#define BCMA_CC_UART0_SCRATCH 0x031C
200#define BCMA_CC_UART1_DATA 0x0400
201#define BCMA_CC_UART1_IMR 0x0404
202#define BCMA_CC_UART1_FCR 0x0408
203#define BCMA_CC_UART1_LCR 0x040C
204#define BCMA_CC_UART1_MCR 0x0410
205#define BCMA_CC_UART1_LSR 0x0414
206#define BCMA_CC_UART1_MSR 0x0418
207#define BCMA_CC_UART1_SCRATCH 0x041C
208/* PMU registers (rev >= 20) */
209#define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
210#define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
211#define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
212#define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
213#define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
214#define BCMA_CC_PMU_CTL_ALPREQEN 0x00000080 /* ALP req enable */
215#define BCMA_CC_PMU_CTL_XTALFREQ 0x0000007C /* Crystal freq */
216#define BCMA_CC_PMU_CTL_XTALFREQ_SHIFT 2
217#define BCMA_CC_PMU_CTL_ILPDIVEN 0x00000002 /* ILP div enable */
218#define BCMA_CC_PMU_CTL_LPOSEL 0x00000001 /* LPO sel */
219#define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
220#define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
221#define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
222#define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
223#define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
224#define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
225#define BCMA_CC_PMU_STAT_HAVEHT 0x00000004 /* HT available */
226#define BCMA_CC_PMU_STAT_RESINIT 0x00000003 /* Res init */
227#define BCMA_CC_PMU_RES_STAT 0x060C /* PMU res status */
228#define BCMA_CC_PMU_RES_PEND 0x0610 /* PMU res pending */
229#define BCMA_CC_PMU_TIMER 0x0614 /* PMU timer */
230#define BCMA_CC_PMU_MINRES_MSK 0x0618 /* PMU min res mask */
231#define BCMA_CC_PMU_MAXRES_MSK 0x061C /* PMU max res mask */
232#define BCMA_CC_PMU_RES_TABSEL 0x0620 /* PMU res table sel */
233#define BCMA_CC_PMU_RES_DEPMSK 0x0624 /* PMU res dep mask */
234#define BCMA_CC_PMU_RES_UPDNTM 0x0628 /* PMU res updown timer */
235#define BCMA_CC_PMU_RES_TIMER 0x062C /* PMU res timer */
236#define BCMA_CC_PMU_CLKSTRETCH 0x0630 /* PMU clockstretch */
237#define BCMA_CC_PMU_WATCHDOG 0x0634 /* PMU watchdog */
238#define BCMA_CC_PMU_RES_REQTS 0x0640 /* PMU res req timer sel */
239#define BCMA_CC_PMU_RES_REQT 0x0644 /* PMU res req timer */
240#define BCMA_CC_PMU_RES_REQM 0x0648 /* PMU res req mask */
241#define BCMA_CC_CHIPCTL_ADDR 0x0650
242#define BCMA_CC_CHIPCTL_DATA 0x0654
243#define BCMA_CC_REGCTL_ADDR 0x0658
244#define BCMA_CC_REGCTL_DATA 0x065C
245#define BCMA_CC_PLLCTL_ADDR 0x0660
246#define BCMA_CC_PLLCTL_DATA 0x0664
247
248/* Data for the PMU, if available.
249 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
250 */
251struct bcma_chipcommon_pmu {
252 u8 rev; /* PMU revision */
253 u32 crystalfreq; /* The active crystal frequency (in kHz) */
254};
255
256struct bcma_drv_cc {
257 struct bcma_device *core;
258 u32 status;
259 u32 capabilities;
260 u32 capabilities_ext;
261 /* Fast Powerup Delay constant */
262 u16 fast_pwrup_delay;
263 struct bcma_chipcommon_pmu pmu;
264};
265
266/* Register access */
267#define bcma_cc_read32(cc, offset) \
268 bcma_read32((cc)->core, offset)
269#define bcma_cc_write32(cc, offset, val) \
270 bcma_write32((cc)->core, offset, val)
271
272#define bcma_cc_mask32(cc, offset, mask) \
273 bcma_cc_write32(cc, offset, bcma_cc_read32(cc, offset) & (mask))
274#define bcma_cc_set32(cc, offset, set) \
275 bcma_cc_write32(cc, offset, bcma_cc_read32(cc, offset) | (set))
276#define bcma_cc_maskset32(cc, offset, mask, set) \
277 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
278
279extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
280
281extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
282extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
283
284extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
285 u32 ticks);
286
287void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
288
289u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask);
290
291/* Chipcommon GPIO pin access. */
292u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask);
293u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value);
294u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value);
295u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
296u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
297u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
298
299/* PMU support */
300extern void bcma_pmu_init(struct bcma_drv_cc *cc);
301
302#endif /* LINUX_BCMA_DRIVER_CC_H_ */
diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h
new file mode 100644
index 000000000000..b7e191cf00ec
--- /dev/null
+++ b/include/linux/bcma/bcma_driver_pci.h
@@ -0,0 +1,89 @@
1#ifndef LINUX_BCMA_DRIVER_PCI_H_
2#define LINUX_BCMA_DRIVER_PCI_H_
3
4#include <linux/types.h>
5
6struct pci_dev;
7
8/** PCI core registers. **/
9#define BCMA_CORE_PCI_CTL 0x0000 /* PCI Control */
10#define BCMA_CORE_PCI_CTL_RST_OE 0x00000001 /* PCI_RESET Output Enable */
11#define BCMA_CORE_PCI_CTL_RST 0x00000002 /* PCI_RESET driven out to pin */
12#define BCMA_CORE_PCI_CTL_CLK_OE 0x00000004 /* Clock gate Output Enable */
13#define BCMA_CORE_PCI_CTL_CLK 0x00000008 /* Gate for clock driven out to pin */
14#define BCMA_CORE_PCI_ARBCTL 0x0010 /* PCI Arbiter Control */
15#define BCMA_CORE_PCI_ARBCTL_INTERN 0x00000001 /* Use internal arbiter */
16#define BCMA_CORE_PCI_ARBCTL_EXTERN 0x00000002 /* Use external arbiter */
17#define BCMA_CORE_PCI_ARBCTL_PARKID 0x00000006 /* Mask, selects which agent is parked on an idle bus */
18#define BCMA_CORE_PCI_ARBCTL_PARKID_LAST 0x00000000 /* Last requestor */
19#define BCMA_CORE_PCI_ARBCTL_PARKID_4710 0x00000002 /* 4710 */
20#define BCMA_CORE_PCI_ARBCTL_PARKID_EXT0 0x00000004 /* External requestor 0 */
21#define BCMA_CORE_PCI_ARBCTL_PARKID_EXT1 0x00000006 /* External requestor 1 */
22#define BCMA_CORE_PCI_ISTAT 0x0020 /* Interrupt status */
23#define BCMA_CORE_PCI_ISTAT_INTA 0x00000001 /* PCI INTA# */
24#define BCMA_CORE_PCI_ISTAT_INTB 0x00000002 /* PCI INTB# */
25#define BCMA_CORE_PCI_ISTAT_SERR 0x00000004 /* PCI SERR# (write to clear) */
26#define BCMA_CORE_PCI_ISTAT_PERR 0x00000008 /* PCI PERR# (write to clear) */
27#define BCMA_CORE_PCI_ISTAT_PME 0x00000010 /* PCI PME# */
28#define BCMA_CORE_PCI_IMASK 0x0024 /* Interrupt mask */
29#define BCMA_CORE_PCI_IMASK_INTA 0x00000001 /* PCI INTA# */
30#define BCMA_CORE_PCI_IMASK_INTB 0x00000002 /* PCI INTB# */
31#define BCMA_CORE_PCI_IMASK_SERR 0x00000004 /* PCI SERR# */
32#define BCMA_CORE_PCI_IMASK_PERR 0x00000008 /* PCI PERR# */
33#define BCMA_CORE_PCI_IMASK_PME 0x00000010 /* PCI PME# */
34#define BCMA_CORE_PCI_MBOX 0x0028 /* Backplane to PCI Mailbox */
35#define BCMA_CORE_PCI_MBOX_F0_0 0x00000100 /* PCI function 0, INT 0 */
36#define BCMA_CORE_PCI_MBOX_F0_1 0x00000200 /* PCI function 0, INT 1 */
37#define BCMA_CORE_PCI_MBOX_F1_0 0x00000400 /* PCI function 1, INT 0 */
38#define BCMA_CORE_PCI_MBOX_F1_1 0x00000800 /* PCI function 1, INT 1 */
39#define BCMA_CORE_PCI_MBOX_F2_0 0x00001000 /* PCI function 2, INT 0 */
40#define BCMA_CORE_PCI_MBOX_F2_1 0x00002000 /* PCI function 2, INT 1 */
41#define BCMA_CORE_PCI_MBOX_F3_0 0x00004000 /* PCI function 3, INT 0 */
42#define BCMA_CORE_PCI_MBOX_F3_1 0x00008000 /* PCI function 3, INT 1 */
43#define BCMA_CORE_PCI_BCAST_ADDR 0x0050 /* Backplane Broadcast Address */
44#define BCMA_CORE_PCI_BCAST_ADDR_MASK 0x000000FF
45#define BCMA_CORE_PCI_BCAST_DATA 0x0054 /* Backplane Broadcast Data */
46#define BCMA_CORE_PCI_GPIO_IN 0x0060 /* rev >= 2 only */
47#define BCMA_CORE_PCI_GPIO_OUT 0x0064 /* rev >= 2 only */
48#define BCMA_CORE_PCI_GPIO_ENABLE 0x0068 /* rev >= 2 only */
49#define BCMA_CORE_PCI_GPIO_CTL 0x006C /* rev >= 2 only */
50#define BCMA_CORE_PCI_SBTOPCI0 0x0100 /* Backplane to PCI translation 0 (sbtopci0) */
51#define BCMA_CORE_PCI_SBTOPCI0_MASK 0xFC000000
52#define BCMA_CORE_PCI_SBTOPCI1 0x0104 /* Backplane to PCI translation 1 (sbtopci1) */
53#define BCMA_CORE_PCI_SBTOPCI1_MASK 0xFC000000
54#define BCMA_CORE_PCI_SBTOPCI2 0x0108 /* Backplane to PCI translation 2 (sbtopci2) */
55#define BCMA_CORE_PCI_SBTOPCI2_MASK 0xC0000000
56#define BCMA_CORE_PCI_PCICFG0 0x0400 /* PCI config space 0 (rev >= 8) */
57#define BCMA_CORE_PCI_PCICFG1 0x0500 /* PCI config space 1 (rev >= 8) */
58#define BCMA_CORE_PCI_PCICFG2 0x0600 /* PCI config space 2 (rev >= 8) */
59#define BCMA_CORE_PCI_PCICFG3 0x0700 /* PCI config space 3 (rev >= 8) */
60#define BCMA_CORE_PCI_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
61
62/* SBtoPCIx */
63#define BCMA_CORE_PCI_SBTOPCI_MEM 0x00000000
64#define BCMA_CORE_PCI_SBTOPCI_IO 0x00000001
65#define BCMA_CORE_PCI_SBTOPCI_CFG0 0x00000002
66#define BCMA_CORE_PCI_SBTOPCI_CFG1 0x00000003
67#define BCMA_CORE_PCI_SBTOPCI_PREF 0x00000004 /* Prefetch enable */
68#define BCMA_CORE_PCI_SBTOPCI_BURST 0x00000008 /* Burst enable */
69#define BCMA_CORE_PCI_SBTOPCI_MRM 0x00000020 /* Memory Read Multiple */
70#define BCMA_CORE_PCI_SBTOPCI_RC 0x00000030 /* Read Command mask (rev >= 11) */
71#define BCMA_CORE_PCI_SBTOPCI_RC_READ 0x00000000 /* Memory read */
72#define BCMA_CORE_PCI_SBTOPCI_RC_READL 0x00000010 /* Memory read line */
73#define BCMA_CORE_PCI_SBTOPCI_RC_READM 0x00000020 /* Memory read multiple */
74
75/* PCIcore specific boardflags */
76#define BCMA_CORE_PCI_BFL_NOPCI 0x00000400 /* Board leaves PCI floating */
77
78struct bcma_drv_pci {
79 struct bcma_device *core;
80 u8 setup_done:1;
81};
82
83/* Register access */
84#define pcicore_read32(pc, offset) bcma_read32((pc)->core, offset)
85#define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
86
87extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
88
89#endif /* LINUX_BCMA_DRIVER_PCI_H_ */
diff --git a/include/linux/bcma/bcma_regs.h b/include/linux/bcma/bcma_regs.h
new file mode 100644
index 000000000000..f82d88a960ce
--- /dev/null
+++ b/include/linux/bcma/bcma_regs.h
@@ -0,0 +1,34 @@
1#ifndef LINUX_BCMA_REGS_H_
2#define LINUX_BCMA_REGS_H_
3
4/* Agent registers (common for every core) */
5#define BCMA_IOCTL 0x0408
6#define BCMA_IOCTL_CLK 0x0001
7#define BCMA_IOCTL_FGC 0x0002
8#define BCMA_IOCTL_CORE_BITS 0x3FFC
9#define BCMA_IOCTL_PME_EN 0x4000
10#define BCMA_IOCTL_BIST_EN 0x8000
11#define BCMA_RESET_CTL 0x0800
12#define BCMA_RESET_CTL_RESET 0x0001
13
14/* BCMA PCI config space registers. */
15#define BCMA_PCI_PMCSR 0x44
16#define BCMA_PCI_PE 0x100
17#define BCMA_PCI_BAR0_WIN 0x80 /* Backplane address space 0 */
18#define BCMA_PCI_BAR1_WIN 0x84 /* Backplane address space 1 */
19#define BCMA_PCI_SPROMCTL 0x88 /* SPROM control */
20#define BCMA_PCI_SPROMCTL_WE 0x10 /* SPROM write enable */
21#define BCMA_PCI_BAR1_CONTROL 0x8c /* Address space 1 burst control */
22#define BCMA_PCI_IRQS 0x90 /* PCI interrupts */
23#define BCMA_PCI_IRQMASK 0x94 /* PCI IRQ control and mask (pcirev >= 6 only) */
24#define BCMA_PCI_BACKPLANE_IRQS 0x98 /* Backplane Interrupts */
25#define BCMA_PCI_BAR0_WIN2 0xAC
26#define BCMA_PCI_GPIO_IN 0xB0 /* GPIO Input (pcirev >= 3 only) */
27#define BCMA_PCI_GPIO_OUT 0xB4 /* GPIO Output (pcirev >= 3 only) */
28#define BCMA_PCI_GPIO_OUT_ENABLE 0xB8 /* GPIO Output Enable/Disable (pcirev >= 3 only) */
29#define BCMA_PCI_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */
30#define BCMA_PCI_GPIO_HWRAD 0x20 /* PCI config space GPIO 13 for hw radio disable */
31#define BCMA_PCI_GPIO_XTAL 0x40 /* PCI config space GPIO 14 for Xtal powerup */
32#define BCMA_PCI_GPIO_PLL 0x80 /* PCI config space GPIO 15 for PLL powerdown */
33
34#endif /* LINUX_BCMA_REGS_H_ */
diff --git a/include/linux/bfin_mac.h b/include/linux/bfin_mac.h
new file mode 100644
index 000000000000..a69554ef8476
--- /dev/null
+++ b/include/linux/bfin_mac.h
@@ -0,0 +1,30 @@
1/*
2 * Blackfin On-Chip MAC Driver
3 *
4 * Copyright 2004-2010 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 */
10
11#ifndef _LINUX_BFIN_MAC_H_
12#define _LINUX_BFIN_MAC_H_
13
14#include <linux/phy.h>
15
16struct bfin_phydev_platform_data {
17 unsigned short addr;
18 int irq;
19};
20
21struct bfin_mii_bus_platform_data {
22 int phydev_number;
23 struct bfin_phydev_platform_data *phydev_data;
24 const unsigned short *mac_peripherals;
25 int phy_mode;
26 unsigned int phy_mask;
27 unsigned short vlan1_mask, vlan2_mask;
28};
29
30#endif
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index a065612fc928..8845613fd7e3 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -25,10 +25,11 @@ struct pt_regs;
25/* 25/*
26 * This structure is used to hold the arguments that are used when loading binaries. 26 * This structure is used to hold the arguments that are used when loading binaries.
27 */ 27 */
28struct linux_binprm{ 28struct linux_binprm {
29 char buf[BINPRM_BUF_SIZE]; 29 char buf[BINPRM_BUF_SIZE];
30#ifdef CONFIG_MMU 30#ifdef CONFIG_MMU
31 struct vm_area_struct *vma; 31 struct vm_area_struct *vma;
32 unsigned long vma_pages;
32#else 33#else
33# define MAX_ARG_PAGES 32 34# define MAX_ARG_PAGES 32
34 struct page *page[MAX_ARG_PAGES]; 35 struct page *page[MAX_ARG_PAGES];
@@ -88,7 +89,6 @@ struct linux_binfmt {
88 int (*load_shlib)(struct file *); 89 int (*load_shlib)(struct file *);
89 int (*core_dump)(struct coredump_params *cprm); 90 int (*core_dump)(struct coredump_params *cprm);
90 unsigned long min_coredump; /* minimal dump size */ 91 unsigned long min_coredump; /* minimal dump size */
91 int hasvdso;
92}; 92};
93 93
94extern int __register_binfmt(struct linux_binfmt *fmt, int insert); 94extern int __register_binfmt(struct linux_binfmt *fmt, int insert);
@@ -108,7 +108,7 @@ extern void unregister_binfmt(struct linux_binfmt *);
108 108
109extern int prepare_binprm(struct linux_binprm *); 109extern int prepare_binprm(struct linux_binprm *);
110extern int __must_check remove_arg_zero(struct linux_binprm *); 110extern int __must_check remove_arg_zero(struct linux_binprm *);
111extern int search_binary_handler(struct linux_binprm *,struct pt_regs *); 111extern int search_binary_handler(struct linux_binprm *, struct pt_regs *);
112extern int flush_old_exec(struct linux_binprm * bprm); 112extern int flush_old_exec(struct linux_binprm * bprm);
113extern void setup_new_exec(struct linux_binprm * bprm); 113extern void setup_new_exec(struct linux_binprm * bprm);
114 114
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 5274103434ad..ce33e6868a2f 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -66,10 +66,6 @@
66#define bio_offset(bio) bio_iovec((bio))->bv_offset 66#define bio_offset(bio) bio_iovec((bio))->bv_offset
67#define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx) 67#define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx)
68#define bio_sectors(bio) ((bio)->bi_size >> 9) 68#define bio_sectors(bio) ((bio)->bi_size >> 9)
69#define bio_empty_barrier(bio) \
70 ((bio->bi_rw & REQ_HARDBARRIER) && \
71 !bio_has_data(bio) && \
72 !(bio->bi_rw & REQ_DISCARD))
73 69
74static inline unsigned int bio_cur_bytes(struct bio *bio) 70static inline unsigned int bio_cur_bytes(struct bio *bio)
75{ 71{
@@ -308,7 +304,6 @@ struct biovec_slab {
308}; 304};
309 305
310extern struct bio_set *fs_bio_set; 306extern struct bio_set *fs_bio_set;
311extern struct biovec_slab bvec_slabs[BIOVEC_NR_POOLS] __read_mostly;
312 307
313/* 308/*
314 * a small number of entries is fine, not going to be performance critical. 309 * a small number of entries is fine, not going to be performance critical.
@@ -346,8 +341,15 @@ static inline void bvec_kunmap_irq(char *buffer, unsigned long *flags)
346} 341}
347 342
348#else 343#else
349#define bvec_kmap_irq(bvec, flags) (page_address((bvec)->bv_page) + (bvec)->bv_offset) 344static inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags)
350#define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0) 345{
346 return page_address(bvec->bv_page) + bvec->bv_offset;
347}
348
349static inline void bvec_kunmap_irq(char *buffer, unsigned long *flags)
350{
351 *flags = 0;
352}
351#endif 353#endif
352 354
353static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, 355static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
@@ -496,6 +498,10 @@ static inline struct bio *bio_list_get(struct bio_list *bl)
496#define bip_for_each_vec(bvl, bip, i) \ 498#define bip_for_each_vec(bvl, bip, i) \
497 __bip_for_each_vec(bvl, bip, i, (bip)->bip_idx) 499 __bip_for_each_vec(bvl, bip, i, (bip)->bip_idx)
498 500
501#define bio_for_each_integrity_vec(_bvl, _bio, _iter) \
502 for_each_bio(_bio) \
503 bip_for_each_vec(_bvl, _bio->bi_integrity, _iter)
504
499#define bio_integrity(bio) (bio->bi_integrity != NULL) 505#define bio_integrity(bio) (bio->bi_integrity != NULL)
500 506
501extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *); 507extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h
index 7113a32a86ea..b4326bfa684f 100644
--- a/include/linux/bit_spinlock.h
+++ b/include/linux/bit_spinlock.h
@@ -1,6 +1,10 @@
1#ifndef __LINUX_BIT_SPINLOCK_H 1#ifndef __LINUX_BIT_SPINLOCK_H
2#define __LINUX_BIT_SPINLOCK_H 2#define __LINUX_BIT_SPINLOCK_H
3 3
4#include <linux/kernel.h>
5#include <linux/preempt.h>
6#include <asm/atomic.h>
7
4/* 8/*
5 * bit-based spin_lock() 9 * bit-based spin_lock()
6 * 10 *
@@ -19,11 +23,11 @@ static inline void bit_spin_lock(int bitnum, unsigned long *addr)
19 preempt_disable(); 23 preempt_disable();
20#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 24#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
21 while (unlikely(test_and_set_bit_lock(bitnum, addr))) { 25 while (unlikely(test_and_set_bit_lock(bitnum, addr))) {
22 while (test_bit(bitnum, addr)) { 26 preempt_enable();
23 preempt_enable(); 27 do {
24 cpu_relax(); 28 cpu_relax();
25 preempt_disable(); 29 } while (test_bit(bitnum, addr));
26 } 30 preempt_disable();
27 } 31 }
28#endif 32#endif
29 __acquire(bitlock); 33 __acquire(bitlock);
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index daf8c480c786..dcafe0bf0005 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -55,7 +55,8 @@
55 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf 55 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
56 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf 56 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
57 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf 57 * bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf
58 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list 58 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf
59 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf
59 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region 60 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
60 * bitmap_release_region(bitmap, pos, order) Free specified bit region 61 * bitmap_release_region(bitmap, pos, order) Free specified bit region
61 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region 62 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
@@ -129,6 +130,8 @@ extern int bitmap_scnlistprintf(char *buf, unsigned int len,
129 const unsigned long *src, int nbits); 130 const unsigned long *src, int nbits);
130extern int bitmap_parselist(const char *buf, unsigned long *maskp, 131extern int bitmap_parselist(const char *buf, unsigned long *maskp,
131 int nmaskbits); 132 int nmaskbits);
133extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
134 unsigned long *dst, int nbits);
132extern void bitmap_remap(unsigned long *dst, const unsigned long *src, 135extern void bitmap_remap(unsigned long *dst, const unsigned long *src,
133 const unsigned long *old, const unsigned long *new, int bits); 136 const unsigned long *old, const unsigned long *new, int bits);
134extern int bitmap_bitremap(int oldbit, 137extern int bitmap_bitremap(int oldbit,
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index fc68053378ce..a3ef66a2a083 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -109,6 +109,17 @@ static inline __u8 ror8(__u8 word, unsigned int shift)
109 return (word >> shift) | (word << (8 - shift)); 109 return (word >> shift) | (word << (8 - shift));
110} 110}
111 111
112/**
113 * sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit
114 * @value: value to sign extend
115 * @index: 0 based bit index (0<=index<32) to sign bit
116 */
117static inline __s32 sign_extend32(__u32 value, int index)
118{
119 __u8 shift = 31 - index;
120 return (__s32)(value << shift) >> shift;
121}
122
112static inline unsigned fls_long(unsigned long l) 123static inline unsigned fls_long(unsigned long l)
113{ 124{
114 if (sizeof(l) == 4) 125 if (sizeof(l) == 4)
@@ -136,30 +147,8 @@ static inline unsigned long __ffs64(u64 word)
136} 147}
137 148
138#ifdef __KERNEL__ 149#ifdef __KERNEL__
139#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
140
141/**
142 * find_first_bit - find the first set bit in a memory region
143 * @addr: The address to start the search at
144 * @size: The maximum size to search
145 *
146 * Returns the bit number of the first set bit.
147 */
148extern unsigned long find_first_bit(const unsigned long *addr,
149 unsigned long size);
150
151/**
152 * find_first_zero_bit - find the first cleared bit in a memory region
153 * @addr: The address to start the search at
154 * @size: The maximum size to search
155 *
156 * Returns the bit number of the first cleared bit.
157 */
158extern unsigned long find_first_zero_bit(const unsigned long *addr,
159 unsigned long size);
160#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
161 150
162#ifdef CONFIG_GENERIC_FIND_LAST_BIT 151#ifndef find_last_bit
163/** 152/**
164 * find_last_bit - find the last set bit in a memory region 153 * find_last_bit - find the last set bit in a memory region
165 * @addr: The address to start the search at 154 * @addr: The address to start the search at
@@ -169,30 +158,7 @@ extern unsigned long find_first_zero_bit(const unsigned long *addr,
169 */ 158 */
170extern unsigned long find_last_bit(const unsigned long *addr, 159extern unsigned long find_last_bit(const unsigned long *addr,
171 unsigned long size); 160 unsigned long size);
172#endif /* CONFIG_GENERIC_FIND_LAST_BIT */ 161#endif
173
174#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
175
176/**
177 * find_next_bit - find the next set bit in a memory region
178 * @addr: The address to base the search on
179 * @offset: The bitnumber to start searching at
180 * @size: The bitmap size in bits
181 */
182extern unsigned long find_next_bit(const unsigned long *addr,
183 unsigned long size, unsigned long offset);
184
185/**
186 * find_next_zero_bit - find the next cleared bit in a memory region
187 * @addr: The address to base the search on
188 * @offset: The bitnumber to start searching at
189 * @size: The bitmap size in bits
190 */
191
192extern unsigned long find_next_zero_bit(const unsigned long *addr,
193 unsigned long size,
194 unsigned long offset);
195 162
196#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */
197#endif /* __KERNEL__ */ 163#endif /* __KERNEL__ */
198#endif 164#endif
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index ca83a97c9715..6395692b2e7a 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -97,6 +97,7 @@ struct bio {
97#define BIO_NULL_MAPPED 9 /* contains invalid user pages */ 97#define BIO_NULL_MAPPED 9 /* contains invalid user pages */
98#define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */ 98#define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */
99#define BIO_QUIET 11 /* Make BIO Quiet */ 99#define BIO_QUIET 11 /* Make BIO Quiet */
100#define BIO_MAPPED_INTEGRITY 12/* integrity metadata has been remapped */
100#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) 101#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag)))
101 102
102/* 103/*
@@ -121,15 +122,15 @@ enum rq_flag_bits {
121 __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */ 122 __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */
122 __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */ 123 __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */
123 124
124 __REQ_HARDBARRIER, /* may not be passed by drive either */
125 __REQ_SYNC, /* request is sync (sync write or read) */ 125 __REQ_SYNC, /* request is sync (sync write or read) */
126 __REQ_META, /* metadata io request */ 126 __REQ_META, /* metadata io request */
127 __REQ_DISCARD, /* request to discard sectors */ 127 __REQ_DISCARD, /* request to discard sectors */
128 __REQ_NOIDLE, /* don't anticipate more IO after this one */ 128 __REQ_NOIDLE, /* don't anticipate more IO after this one */
129 129
130 /* bio only flags */ 130 /* bio only flags */
131 __REQ_UNPLUG, /* unplug the immediately after submission */
132 __REQ_RAHEAD, /* read ahead, can fail anytime */ 131 __REQ_RAHEAD, /* read ahead, can fail anytime */
132 __REQ_THROTTLED, /* This bio has already been subjected to
133 * throttling rules. Don't do it again. */
133 134
134 /* request only flags */ 135 /* request only flags */
135 __REQ_SORTED, /* elevator knows about this request */ 136 __REQ_SORTED, /* elevator knows about this request */
@@ -143,11 +144,10 @@ enum rq_flag_bits {
143 __REQ_FAILED, /* set if the request failed */ 144 __REQ_FAILED, /* set if the request failed */
144 __REQ_QUIET, /* don't worry about errors */ 145 __REQ_QUIET, /* don't worry about errors */
145 __REQ_PREEMPT, /* set for "ide_preempt" requests */ 146 __REQ_PREEMPT, /* set for "ide_preempt" requests */
146 __REQ_ORDERED_COLOR, /* is before or after barrier */
147 __REQ_ALLOCED, /* request came from our alloc pool */ 147 __REQ_ALLOCED, /* request came from our alloc pool */
148 __REQ_COPY_USER, /* contains copies of user pages */ 148 __REQ_COPY_USER, /* contains copies of user pages */
149 __REQ_INTEGRITY, /* integrity metadata has been remapped */
150 __REQ_FLUSH, /* request for cache flush */ 149 __REQ_FLUSH, /* request for cache flush */
150 __REQ_FLUSH_SEQ, /* request for flush sequence */
151 __REQ_IO_STAT, /* account I/O stat */ 151 __REQ_IO_STAT, /* account I/O stat */
152 __REQ_MIXED_MERGE, /* merge of different types, fail separately */ 152 __REQ_MIXED_MERGE, /* merge of different types, fail separately */
153 __REQ_SECURE, /* secure discard (used with __REQ_DISCARD) */ 153 __REQ_SECURE, /* secure discard (used with __REQ_DISCARD) */
@@ -158,7 +158,6 @@ enum rq_flag_bits {
158#define REQ_FAILFAST_DEV (1 << __REQ_FAILFAST_DEV) 158#define REQ_FAILFAST_DEV (1 << __REQ_FAILFAST_DEV)
159#define REQ_FAILFAST_TRANSPORT (1 << __REQ_FAILFAST_TRANSPORT) 159#define REQ_FAILFAST_TRANSPORT (1 << __REQ_FAILFAST_TRANSPORT)
160#define REQ_FAILFAST_DRIVER (1 << __REQ_FAILFAST_DRIVER) 160#define REQ_FAILFAST_DRIVER (1 << __REQ_FAILFAST_DRIVER)
161#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER)
162#define REQ_SYNC (1 << __REQ_SYNC) 161#define REQ_SYNC (1 << __REQ_SYNC)
163#define REQ_META (1 << __REQ_META) 162#define REQ_META (1 << __REQ_META)
164#define REQ_DISCARD (1 << __REQ_DISCARD) 163#define REQ_DISCARD (1 << __REQ_DISCARD)
@@ -167,11 +166,12 @@ enum rq_flag_bits {
167#define REQ_FAILFAST_MASK \ 166#define REQ_FAILFAST_MASK \
168 (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) 167 (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
169#define REQ_COMMON_MASK \ 168#define REQ_COMMON_MASK \
170 (REQ_WRITE | REQ_FAILFAST_MASK | REQ_HARDBARRIER | REQ_SYNC | \ 169 (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \
171 REQ_META| REQ_DISCARD | REQ_NOIDLE) 170 REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
171#define REQ_CLONE_MASK REQ_COMMON_MASK
172 172
173#define REQ_UNPLUG (1 << __REQ_UNPLUG)
174#define REQ_RAHEAD (1 << __REQ_RAHEAD) 173#define REQ_RAHEAD (1 << __REQ_RAHEAD)
174#define REQ_THROTTLED (1 << __REQ_THROTTLED)
175 175
176#define REQ_SORTED (1 << __REQ_SORTED) 176#define REQ_SORTED (1 << __REQ_SORTED)
177#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) 177#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER)
@@ -184,11 +184,10 @@ enum rq_flag_bits {
184#define REQ_FAILED (1 << __REQ_FAILED) 184#define REQ_FAILED (1 << __REQ_FAILED)
185#define REQ_QUIET (1 << __REQ_QUIET) 185#define REQ_QUIET (1 << __REQ_QUIET)
186#define REQ_PREEMPT (1 << __REQ_PREEMPT) 186#define REQ_PREEMPT (1 << __REQ_PREEMPT)
187#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR)
188#define REQ_ALLOCED (1 << __REQ_ALLOCED) 187#define REQ_ALLOCED (1 << __REQ_ALLOCED)
189#define REQ_COPY_USER (1 << __REQ_COPY_USER) 188#define REQ_COPY_USER (1 << __REQ_COPY_USER)
190#define REQ_INTEGRITY (1 << __REQ_INTEGRITY)
191#define REQ_FLUSH (1 << __REQ_FLUSH) 189#define REQ_FLUSH (1 << __REQ_FLUSH)
190#define REQ_FLUSH_SEQ (1 << __REQ_FLUSH_SEQ)
192#define REQ_IO_STAT (1 << __REQ_IO_STAT) 191#define REQ_IO_STAT (1 << __REQ_IO_STAT)
193#define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE) 192#define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE)
194#define REQ_SECURE (1 << __REQ_SECURE) 193#define REQ_SECURE (1 << __REQ_SECURE)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2c54906f678f..1a23722e8878 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -108,13 +108,20 @@ struct request {
108 108
109 /* 109 /*
110 * Three pointers are available for the IO schedulers, if they need 110 * Three pointers are available for the IO schedulers, if they need
111 * more they have to dynamically allocate it. 111 * more they have to dynamically allocate it. Flush requests are
112 * never put on the IO scheduler. So let the flush fields share
113 * space with the three elevator_private pointers.
112 */ 114 */
113 void *elevator_private; 115 union {
114 void *elevator_private2; 116 void *elevator_private[3];
115 void *elevator_private3; 117 struct {
118 unsigned int seq;
119 struct list_head list;
120 } flush;
121 };
116 122
117 struct gendisk *rq_disk; 123 struct gendisk *rq_disk;
124 struct hd_struct *part;
118 unsigned long start_time; 125 unsigned long start_time;
119#ifdef CONFIG_BLK_CGROUP 126#ifdef CONFIG_BLK_CGROUP
120 unsigned long long start_time_ns; 127 unsigned long long start_time_ns;
@@ -124,6 +131,9 @@ struct request {
124 * physical address coalescing is performed. 131 * physical address coalescing is performed.
125 */ 132 */
126 unsigned short nr_phys_segments; 133 unsigned short nr_phys_segments;
134#if defined(CONFIG_BLK_DEV_INTEGRITY)
135 unsigned short nr_integrity_segments;
136#endif
127 137
128 unsigned short ioprio; 138 unsigned short ioprio;
129 139
@@ -186,7 +196,6 @@ typedef void (request_fn_proc) (struct request_queue *q);
186typedef int (make_request_fn) (struct request_queue *q, struct bio *bio); 196typedef int (make_request_fn) (struct request_queue *q, struct bio *bio);
187typedef int (prep_rq_fn) (struct request_queue *, struct request *); 197typedef int (prep_rq_fn) (struct request_queue *, struct request *);
188typedef void (unprep_rq_fn) (struct request_queue *, struct request *); 198typedef void (unprep_rq_fn) (struct request_queue *, struct request *);
189typedef void (unplug_fn) (struct request_queue *);
190 199
191struct bio_vec; 200struct bio_vec;
192struct bvec_merge_data { 201struct bvec_merge_data {
@@ -243,11 +252,12 @@ struct queue_limits {
243 252
244 unsigned short logical_block_size; 253 unsigned short logical_block_size;
245 unsigned short max_segments; 254 unsigned short max_segments;
255 unsigned short max_integrity_segments;
246 256
247 unsigned char misaligned; 257 unsigned char misaligned;
248 unsigned char discard_misaligned; 258 unsigned char discard_misaligned;
249 unsigned char no_cluster; 259 unsigned char cluster;
250 signed char discard_zeroes_data; 260 unsigned char discard_zeroes_data;
251}; 261};
252 262
253struct request_queue 263struct request_queue
@@ -268,7 +278,6 @@ struct request_queue
268 make_request_fn *make_request_fn; 278 make_request_fn *make_request_fn;
269 prep_rq_fn *prep_rq_fn; 279 prep_rq_fn *prep_rq_fn;
270 unprep_rq_fn *unprep_rq_fn; 280 unprep_rq_fn *unprep_rq_fn;
271 unplug_fn *unplug_fn;
272 merge_bvec_fn *merge_bvec_fn; 281 merge_bvec_fn *merge_bvec_fn;
273 softirq_done_fn *softirq_done_fn; 282 softirq_done_fn *softirq_done_fn;
274 rq_timed_out_fn *rq_timed_out_fn; 283 rq_timed_out_fn *rq_timed_out_fn;
@@ -282,12 +291,9 @@ struct request_queue
282 struct request *boundary_rq; 291 struct request *boundary_rq;
283 292
284 /* 293 /*
285 * Auto-unplugging state 294 * Delayed queue handling
286 */ 295 */
287 struct timer_list unplug_timer; 296 struct delayed_work delay_work;
288 int unplug_thresh; /* After this many requests */
289 unsigned long unplug_delay; /* After this many jiffies */
290 struct work_struct unplug_work;
291 297
292 struct backing_dev_info backing_dev_info; 298 struct backing_dev_info backing_dev_info;
293 299
@@ -355,44 +361,50 @@ struct request_queue
355 struct blk_trace *blk_trace; 361 struct blk_trace *blk_trace;
356#endif 362#endif
357 /* 363 /*
358 * reserved for flush operations 364 * for flush operations
359 */ 365 */
360 unsigned int ordered, next_ordered, ordseq; 366 unsigned int flush_flags;
361 int orderr, ordcolor; 367 unsigned int flush_not_queueable:1;
362 struct request pre_flush_rq, bar_rq, post_flush_rq; 368 unsigned int flush_queue_delayed:1;
363 struct request *orig_bar_rq; 369 unsigned int flush_pending_idx:1;
370 unsigned int flush_running_idx:1;
371 unsigned long flush_pending_since;
372 struct list_head flush_queue[2];
373 struct list_head flush_data_in_flight;
374 struct request flush_rq;
364 375
365 struct mutex sysfs_lock; 376 struct mutex sysfs_lock;
366 377
367#if defined(CONFIG_BLK_DEV_BSG) 378#if defined(CONFIG_BLK_DEV_BSG)
368 struct bsg_class_device bsg_dev; 379 struct bsg_class_device bsg_dev;
369#endif 380#endif
381
382#ifdef CONFIG_BLK_DEV_THROTTLING
383 /* Throttle data */
384 struct throtl_data *td;
385#endif
370}; 386};
371 387
372#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */
373#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ 388#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */
374#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */ 389#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */
375#define QUEUE_FLAG_SYNCFULL 3 /* read queue has been filled */ 390#define QUEUE_FLAG_SYNCFULL 3 /* read queue has been filled */
376#define QUEUE_FLAG_ASYNCFULL 4 /* write queue has been filled */ 391#define QUEUE_FLAG_ASYNCFULL 4 /* write queue has been filled */
377#define QUEUE_FLAG_DEAD 5 /* queue being torn down */ 392#define QUEUE_FLAG_DEAD 5 /* queue being torn down */
378#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ 393#define QUEUE_FLAG_ELVSWITCH 6 /* don't use elevator, just do FIFO */
379#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ 394#define QUEUE_FLAG_BIDI 7 /* queue supports bidi requests */
380#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ 395#define QUEUE_FLAG_NOMERGES 8 /* disable merge attempts */
381#define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ 396#define QUEUE_FLAG_SAME_COMP 9 /* force complete on same CPU */
382#define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */ 397#define QUEUE_FLAG_FAIL_IO 10 /* fake timeout */
383#define QUEUE_FLAG_SAME_COMP 11 /* force complete on same CPU */ 398#define QUEUE_FLAG_STACKABLE 11 /* supports request stacking */
384#define QUEUE_FLAG_FAIL_IO 12 /* fake timeout */ 399#define QUEUE_FLAG_NONROT 12 /* non-rotational device (SSD) */
385#define QUEUE_FLAG_STACKABLE 13 /* supports request stacking */
386#define QUEUE_FLAG_NONROT 14 /* non-rotational device (SSD) */
387#define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */ 400#define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */
388#define QUEUE_FLAG_IO_STAT 15 /* do IO stats */ 401#define QUEUE_FLAG_IO_STAT 13 /* do IO stats */
389#define QUEUE_FLAG_DISCARD 16 /* supports DISCARD */ 402#define QUEUE_FLAG_DISCARD 14 /* supports DISCARD */
390#define QUEUE_FLAG_NOXMERGES 17 /* No extended merges */ 403#define QUEUE_FLAG_NOXMERGES 15 /* No extended merges */
391#define QUEUE_FLAG_ADD_RANDOM 18 /* Contributes to random pool */ 404#define QUEUE_FLAG_ADD_RANDOM 16 /* Contributes to random pool */
392#define QUEUE_FLAG_SECDISCARD 19 /* supports SECDISCARD */ 405#define QUEUE_FLAG_SECDISCARD 17 /* supports SECDISCARD */
393 406
394#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ 407#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
395 (1 << QUEUE_FLAG_CLUSTER) | \
396 (1 << QUEUE_FLAG_STACKABLE) | \ 408 (1 << QUEUE_FLAG_STACKABLE) | \
397 (1 << QUEUE_FLAG_SAME_COMP) | \ 409 (1 << QUEUE_FLAG_SAME_COMP) | \
398 (1 << QUEUE_FLAG_ADD_RANDOM)) 410 (1 << QUEUE_FLAG_ADD_RANDOM))
@@ -462,57 +474,6 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
462 __clear_bit(flag, &q->queue_flags); 474 __clear_bit(flag, &q->queue_flags);
463} 475}
464 476
465enum {
466 /*
467 * Hardbarrier is supported with one of the following methods.
468 *
469 * NONE : hardbarrier unsupported
470 * DRAIN : ordering by draining is enough
471 * DRAIN_FLUSH : ordering by draining w/ pre and post flushes
472 * DRAIN_FUA : ordering by draining w/ pre flush and FUA write
473 * TAG : ordering by tag is enough
474 * TAG_FLUSH : ordering by tag w/ pre and post flushes
475 * TAG_FUA : ordering by tag w/ pre flush and FUA write
476 */
477 QUEUE_ORDERED_BY_DRAIN = 0x01,
478 QUEUE_ORDERED_BY_TAG = 0x02,
479 QUEUE_ORDERED_DO_PREFLUSH = 0x10,
480 QUEUE_ORDERED_DO_BAR = 0x20,
481 QUEUE_ORDERED_DO_POSTFLUSH = 0x40,
482 QUEUE_ORDERED_DO_FUA = 0x80,
483
484 QUEUE_ORDERED_NONE = 0x00,
485
486 QUEUE_ORDERED_DRAIN = QUEUE_ORDERED_BY_DRAIN |
487 QUEUE_ORDERED_DO_BAR,
488 QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN |
489 QUEUE_ORDERED_DO_PREFLUSH |
490 QUEUE_ORDERED_DO_POSTFLUSH,
491 QUEUE_ORDERED_DRAIN_FUA = QUEUE_ORDERED_DRAIN |
492 QUEUE_ORDERED_DO_PREFLUSH |
493 QUEUE_ORDERED_DO_FUA,
494
495 QUEUE_ORDERED_TAG = QUEUE_ORDERED_BY_TAG |
496 QUEUE_ORDERED_DO_BAR,
497 QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG |
498 QUEUE_ORDERED_DO_PREFLUSH |
499 QUEUE_ORDERED_DO_POSTFLUSH,
500 QUEUE_ORDERED_TAG_FUA = QUEUE_ORDERED_TAG |
501 QUEUE_ORDERED_DO_PREFLUSH |
502 QUEUE_ORDERED_DO_FUA,
503
504 /*
505 * Ordered operation sequence
506 */
507 QUEUE_ORDSEQ_STARTED = 0x01, /* flushing in progress */
508 QUEUE_ORDSEQ_DRAIN = 0x02, /* waiting for the queue to be drained */
509 QUEUE_ORDSEQ_PREFLUSH = 0x04, /* pre-flushing in progress */
510 QUEUE_ORDSEQ_BAR = 0x08, /* original barrier req in progress */
511 QUEUE_ORDSEQ_POSTFLUSH = 0x10, /* post-flushing in progress */
512 QUEUE_ORDSEQ_DONE = 0x20,
513};
514
515#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
516#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) 477#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
517#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) 478#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
518#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags) 479#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)
@@ -521,7 +482,6 @@ enum {
521#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags) 482#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags)
522#define blk_queue_io_stat(q) test_bit(QUEUE_FLAG_IO_STAT, &(q)->queue_flags) 483#define blk_queue_io_stat(q) test_bit(QUEUE_FLAG_IO_STAT, &(q)->queue_flags)
523#define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags) 484#define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags)
524#define blk_queue_flushing(q) ((q)->ordseq)
525#define blk_queue_stackable(q) \ 485#define blk_queue_stackable(q) \
526 test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags) 486 test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags)
527#define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) 487#define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags)
@@ -550,6 +510,11 @@ enum {
550 510
551#define rq_data_dir(rq) ((rq)->cmd_flags & 1) 511#define rq_data_dir(rq) ((rq)->cmd_flags & 1)
552 512
513static inline unsigned int blk_queue_cluster(struct request_queue *q)
514{
515 return q->limits.cluster;
516}
517
553/* 518/*
554 * We regard a request as sync, if either a read or a sync write 519 * We regard a request as sync, if either a read or a sync write
555 */ 520 */
@@ -592,7 +557,7 @@ static inline void blk_clear_queue_full(struct request_queue *q, int sync)
592 * it already be started by driver. 557 * it already be started by driver.
593 */ 558 */
594#define RQ_NOMERGE_FLAGS \ 559#define RQ_NOMERGE_FLAGS \
595 (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER) 560 (REQ_NOMERGE | REQ_STARTED | REQ_SOFTBARRIER | REQ_FLUSH | REQ_FUA)
596#define rq_mergeable(rq) \ 561#define rq_mergeable(rq) \
597 (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && \ 562 (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && \
598 (((rq)->cmd_flags & REQ_DISCARD) || \ 563 (((rq)->cmd_flags & REQ_DISCARD) || \
@@ -683,7 +648,6 @@ static inline void rq_flush_dcache_pages(struct request *rq)
683 648
684extern int blk_register_queue(struct gendisk *disk); 649extern int blk_register_queue(struct gendisk *disk);
685extern void blk_unregister_queue(struct gendisk *disk); 650extern void blk_unregister_queue(struct gendisk *disk);
686extern void register_disk(struct gendisk *dev);
687extern void generic_make_request(struct bio *bio); 651extern void generic_make_request(struct bio *bio);
688extern void blk_rq_init(struct request_queue *q, struct request *rq); 652extern void blk_rq_init(struct request_queue *q, struct request *rq);
689extern void blk_put_request(struct request *); 653extern void blk_put_request(struct request *);
@@ -704,9 +668,7 @@ extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
704extern void blk_rq_unprep_clone(struct request *rq); 668extern void blk_rq_unprep_clone(struct request *rq);
705extern int blk_insert_cloned_request(struct request_queue *q, 669extern int blk_insert_cloned_request(struct request_queue *q,
706 struct request *rq); 670 struct request *rq);
707extern void blk_plug_device(struct request_queue *); 671extern void blk_delay_queue(struct request_queue *, unsigned long);
708extern void blk_plug_device_unlocked(struct request_queue *);
709extern int blk_remove_plug(struct request_queue *);
710extern void blk_recount_segments(struct request_queue *, struct bio *); 672extern void blk_recount_segments(struct request_queue *, struct bio *);
711extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t, 673extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t,
712 unsigned int, void __user *); 674 unsigned int, void __user *);
@@ -736,8 +698,9 @@ extern void blk_start_queue(struct request_queue *q);
736extern void blk_stop_queue(struct request_queue *q); 698extern void blk_stop_queue(struct request_queue *q);
737extern void blk_sync_queue(struct request_queue *q); 699extern void blk_sync_queue(struct request_queue *q);
738extern void __blk_stop_queue(struct request_queue *q); 700extern void __blk_stop_queue(struct request_queue *q);
739extern void __blk_run_queue(struct request_queue *); 701extern void __blk_run_queue(struct request_queue *q);
740extern void blk_run_queue(struct request_queue *); 702extern void blk_run_queue(struct request_queue *);
703extern void blk_run_queue_async(struct request_queue *q);
741extern int blk_rq_map_user(struct request_queue *, struct request *, 704extern int blk_rq_map_user(struct request_queue *, struct request *,
742 struct rq_map_data *, void __user *, unsigned long, 705 struct rq_map_data *, void __user *, unsigned long,
743 gfp_t); 706 gfp_t);
@@ -750,7 +713,6 @@ extern int blk_execute_rq(struct request_queue *, struct gendisk *,
750 struct request *, int); 713 struct request *, int);
751extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, 714extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
752 struct request *, int, rq_end_io_fn *); 715 struct request *, int, rq_end_io_fn *);
753extern void blk_unplug(struct request_queue *q);
754 716
755static inline struct request_queue *bdev_get_queue(struct block_device *bdev) 717static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
756{ 718{
@@ -845,13 +807,14 @@ extern struct request_queue *blk_init_allocated_queue(struct request_queue *,
845extern void blk_cleanup_queue(struct request_queue *); 807extern void blk_cleanup_queue(struct request_queue *);
846extern void blk_queue_make_request(struct request_queue *, make_request_fn *); 808extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
847extern void blk_queue_bounce_limit(struct request_queue *, u64); 809extern void blk_queue_bounce_limit(struct request_queue *, u64);
810extern void blk_limits_max_hw_sectors(struct queue_limits *, unsigned int);
848extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int); 811extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);
849extern void blk_queue_max_segments(struct request_queue *, unsigned short); 812extern void blk_queue_max_segments(struct request_queue *, unsigned short);
850extern void blk_queue_max_segment_size(struct request_queue *, unsigned int); 813extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
851extern void blk_queue_max_discard_sectors(struct request_queue *q, 814extern void blk_queue_max_discard_sectors(struct request_queue *q,
852 unsigned int max_discard_sectors); 815 unsigned int max_discard_sectors);
853extern void blk_queue_logical_block_size(struct request_queue *, unsigned short); 816extern void blk_queue_logical_block_size(struct request_queue *, unsigned short);
854extern void blk_queue_physical_block_size(struct request_queue *, unsigned short); 817extern void blk_queue_physical_block_size(struct request_queue *, unsigned int);
855extern void blk_queue_alignment_offset(struct request_queue *q, 818extern void blk_queue_alignment_offset(struct request_queue *q,
856 unsigned int alignment); 819 unsigned int alignment);
857extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min); 820extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min);
@@ -881,16 +844,12 @@ extern void blk_queue_update_dma_alignment(struct request_queue *, int);
881extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *); 844extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
882extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *); 845extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *);
883extern void blk_queue_rq_timeout(struct request_queue *, unsigned int); 846extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
847extern void blk_queue_flush(struct request_queue *q, unsigned int flush);
848extern void blk_queue_flush_queueable(struct request_queue *q, bool queueable);
884extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); 849extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
885extern int blk_queue_ordered(struct request_queue *, unsigned);
886extern bool blk_do_ordered(struct request_queue *, struct request **);
887extern unsigned blk_ordered_cur_seq(struct request_queue *);
888extern unsigned blk_ordered_req_seq(struct request *);
889extern bool blk_ordered_complete_seq(struct request_queue *, unsigned, int);
890 850
891extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *); 851extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *);
892extern void blk_dump_rq_flags(struct request *, char *); 852extern void blk_dump_rq_flags(struct request *, char *);
893extern void generic_unplug_device(struct request_queue *);
894extern long nr_blockdev_pages(void); 853extern long nr_blockdev_pages(void);
895 854
896int blk_get_queue(struct request_queue *); 855int blk_get_queue(struct request_queue *);
@@ -898,6 +857,44 @@ struct request_queue *blk_alloc_queue(gfp_t);
898struct request_queue *blk_alloc_queue_node(gfp_t, int); 857struct request_queue *blk_alloc_queue_node(gfp_t, int);
899extern void blk_put_queue(struct request_queue *); 858extern void blk_put_queue(struct request_queue *);
900 859
860struct blk_plug {
861 unsigned long magic;
862 struct list_head list;
863 struct list_head cb_list;
864 unsigned int should_sort;
865};
866struct blk_plug_cb {
867 struct list_head list;
868 void (*callback)(struct blk_plug_cb *);
869};
870
871extern void blk_start_plug(struct blk_plug *);
872extern void blk_finish_plug(struct blk_plug *);
873extern void blk_flush_plug_list(struct blk_plug *, bool);
874
875static inline void blk_flush_plug(struct task_struct *tsk)
876{
877 struct blk_plug *plug = tsk->plug;
878
879 if (plug)
880 blk_flush_plug_list(plug, false);
881}
882
883static inline void blk_schedule_flush_plug(struct task_struct *tsk)
884{
885 struct blk_plug *plug = tsk->plug;
886
887 if (plug)
888 blk_flush_plug_list(plug, true);
889}
890
891static inline bool blk_needs_flush_plug(struct task_struct *tsk)
892{
893 struct blk_plug *plug = tsk->plug;
894
895 return plug && (!list_empty(&plug->list) || !list_empty(&plug->cb_list));
896}
897
901/* 898/*
902 * tag stuff 899 * tag stuff
903 */ 900 */
@@ -919,27 +916,28 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
919 return NULL; 916 return NULL;
920 return bqt->tag_index[tag]; 917 return bqt->tag_index[tag];
921} 918}
922enum{ 919
923 BLKDEV_WAIT, /* wait for completion */ 920#define BLKDEV_DISCARD_SECURE 0x01 /* secure discard */
924 BLKDEV_BARRIER, /* issue request with barrier */ 921
925 BLKDEV_SECURE, /* secure discard */ 922extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *);
926};
927#define BLKDEV_IFL_WAIT (1 << BLKDEV_WAIT)
928#define BLKDEV_IFL_BARRIER (1 << BLKDEV_BARRIER)
929#define BLKDEV_IFL_SECURE (1 << BLKDEV_SECURE)
930extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *,
931 unsigned long);
932extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector, 923extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
933 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags); 924 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags);
934extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, 925extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
935 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags); 926 sector_t nr_sects, gfp_t gfp_mask);
936static inline int sb_issue_discard(struct super_block *sb, 927static inline int sb_issue_discard(struct super_block *sb, sector_t block,
937 sector_t block, sector_t nr_blocks) 928 sector_t nr_blocks, gfp_t gfp_mask, unsigned long flags)
938{ 929{
939 block <<= (sb->s_blocksize_bits - 9); 930 return blkdev_issue_discard(sb->s_bdev, block << (sb->s_blocksize_bits - 9),
940 nr_blocks <<= (sb->s_blocksize_bits - 9); 931 nr_blocks << (sb->s_blocksize_bits - 9),
941 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_NOFS, 932 gfp_mask, flags);
942 BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER); 933}
934static inline int sb_issue_zeroout(struct super_block *sb, sector_t block,
935 sector_t nr_blocks, gfp_t gfp_mask)
936{
937 return blkdev_issue_zeroout(sb->s_bdev,
938 block << (sb->s_blocksize_bits - 9),
939 nr_blocks << (sb->s_blocksize_bits - 9),
940 gfp_mask);
943} 941}
944 942
945extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm); 943extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);
@@ -1004,7 +1002,7 @@ static inline unsigned int queue_physical_block_size(struct request_queue *q)
1004 return q->limits.physical_block_size; 1002 return q->limits.physical_block_size;
1005} 1003}
1006 1004
1007static inline int bdev_physical_block_size(struct block_device *bdev) 1005static inline unsigned int bdev_physical_block_size(struct block_device *bdev)
1008{ 1006{
1009 return queue_physical_block_size(bdev_get_queue(bdev)); 1007 return queue_physical_block_size(bdev_get_queue(bdev));
1010} 1008}
@@ -1071,13 +1069,16 @@ static inline int queue_limit_discard_alignment(struct queue_limits *lim, sector
1071{ 1069{
1072 unsigned int alignment = (sector << 9) & (lim->discard_granularity - 1); 1070 unsigned int alignment = (sector << 9) & (lim->discard_granularity - 1);
1073 1071
1072 if (!lim->max_discard_sectors)
1073 return 0;
1074
1074 return (lim->discard_granularity + lim->discard_alignment - alignment) 1075 return (lim->discard_granularity + lim->discard_alignment - alignment)
1075 & (lim->discard_granularity - 1); 1076 & (lim->discard_granularity - 1);
1076} 1077}
1077 1078
1078static inline unsigned int queue_discard_zeroes_data(struct request_queue *q) 1079static inline unsigned int queue_discard_zeroes_data(struct request_queue *q)
1079{ 1080{
1080 if (q->limits.discard_zeroes_data == 1) 1081 if (q->limits.max_discard_sectors && q->limits.discard_zeroes_data == 1)
1081 return 1; 1082 return 1;
1082 1083
1083 return 0; 1084 return 0;
@@ -1093,11 +1094,11 @@ static inline int queue_dma_alignment(struct request_queue *q)
1093 return q ? q->dma_alignment : 511; 1094 return q ? q->dma_alignment : 511;
1094} 1095}
1095 1096
1096static inline int blk_rq_aligned(struct request_queue *q, void *addr, 1097static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
1097 unsigned int len) 1098 unsigned int len)
1098{ 1099{
1099 unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask; 1100 unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask;
1100 return !((unsigned long)addr & alignment) && !(len & alignment); 1101 return !(addr & alignment) && !(len & alignment);
1101} 1102}
1102 1103
1103/* assumes size > 256 */ 1104/* assumes size > 256 */
@@ -1116,6 +1117,11 @@ static inline unsigned int block_size(struct block_device *bdev)
1116 return bdev->bd_block_size; 1117 return bdev->bd_block_size;
1117} 1118}
1118 1119
1120static inline bool queue_flush_queueable(struct request_queue *q)
1121{
1122 return !q->flush_not_queueable;
1123}
1124
1119typedef struct {struct page *v;} Sector; 1125typedef struct {struct page *v;} Sector;
1120 1126
1121unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *); 1127unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *);
@@ -1170,6 +1176,20 @@ static inline uint64_t rq_io_start_time_ns(struct request *req)
1170} 1176}
1171#endif 1177#endif
1172 1178
1179#ifdef CONFIG_BLK_DEV_THROTTLING
1180extern int blk_throtl_init(struct request_queue *q);
1181extern void blk_throtl_exit(struct request_queue *q);
1182extern int blk_throtl_bio(struct request_queue *q, struct bio **bio);
1183#else /* CONFIG_BLK_DEV_THROTTLING */
1184static inline int blk_throtl_bio(struct request_queue *q, struct bio **bio)
1185{
1186 return 0;
1187}
1188
1189static inline int blk_throtl_init(struct request_queue *q) { return 0; }
1190static inline int blk_throtl_exit(struct request_queue *q) { return 0; }
1191#endif /* CONFIG_BLK_DEV_THROTTLING */
1192
1173#define MODULE_ALIAS_BLOCKDEV(major,minor) \ 1193#define MODULE_ALIAS_BLOCKDEV(major,minor) \
1174 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor)) 1194 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
1175#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \ 1195#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
@@ -1210,11 +1230,17 @@ struct blk_integrity {
1210 struct kobject kobj; 1230 struct kobject kobj;
1211}; 1231};
1212 1232
1233extern bool blk_integrity_is_initialized(struct gendisk *);
1213extern int blk_integrity_register(struct gendisk *, struct blk_integrity *); 1234extern int blk_integrity_register(struct gendisk *, struct blk_integrity *);
1214extern void blk_integrity_unregister(struct gendisk *); 1235extern void blk_integrity_unregister(struct gendisk *);
1215extern int blk_integrity_compare(struct gendisk *, struct gendisk *); 1236extern int blk_integrity_compare(struct gendisk *, struct gendisk *);
1216extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); 1237extern int blk_rq_map_integrity_sg(struct request_queue *, struct bio *,
1217extern int blk_rq_count_integrity_sg(struct request *); 1238 struct scatterlist *);
1239extern int blk_rq_count_integrity_sg(struct request_queue *, struct bio *);
1240extern int blk_integrity_merge_rq(struct request_queue *, struct request *,
1241 struct request *);
1242extern int blk_integrity_merge_bio(struct request_queue *, struct request *,
1243 struct bio *);
1218 1244
1219static inline 1245static inline
1220struct blk_integrity *bdev_get_integrity(struct block_device *bdev) 1246struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
@@ -1235,16 +1261,33 @@ static inline int blk_integrity_rq(struct request *rq)
1235 return bio_integrity(rq->bio); 1261 return bio_integrity(rq->bio);
1236} 1262}
1237 1263
1264static inline void blk_queue_max_integrity_segments(struct request_queue *q,
1265 unsigned int segs)
1266{
1267 q->limits.max_integrity_segments = segs;
1268}
1269
1270static inline unsigned short
1271queue_max_integrity_segments(struct request_queue *q)
1272{
1273 return q->limits.max_integrity_segments;
1274}
1275
1238#else /* CONFIG_BLK_DEV_INTEGRITY */ 1276#else /* CONFIG_BLK_DEV_INTEGRITY */
1239 1277
1240#define blk_integrity_rq(rq) (0) 1278#define blk_integrity_rq(rq) (0)
1241#define blk_rq_count_integrity_sg(a) (0) 1279#define blk_rq_count_integrity_sg(a, b) (0)
1242#define blk_rq_map_integrity_sg(a, b) (0) 1280#define blk_rq_map_integrity_sg(a, b, c) (0)
1243#define bdev_get_integrity(a) (0) 1281#define bdev_get_integrity(a) (0)
1244#define blk_get_integrity(a) (0) 1282#define blk_get_integrity(a) (0)
1245#define blk_integrity_compare(a, b) (0) 1283#define blk_integrity_compare(a, b) (0)
1246#define blk_integrity_register(a, b) (0) 1284#define blk_integrity_register(a, b) (0)
1247#define blk_integrity_unregister(a) do { } while (0); 1285#define blk_integrity_unregister(a) do { } while (0)
1286#define blk_queue_max_integrity_segments(a, b) do { } while (0)
1287#define queue_max_integrity_segments(a) (0)
1288#define blk_integrity_merge_rq(a, b, c) (0)
1289#define blk_integrity_merge_bio(a, b, c) (0)
1290#define blk_integrity_is_initialized(a) (0)
1248 1291
1249#endif /* CONFIG_BLK_DEV_INTEGRITY */ 1292#endif /* CONFIG_BLK_DEV_INTEGRITY */
1250 1293
@@ -1255,6 +1298,9 @@ struct block_device_operations {
1255 int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); 1298 int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
1256 int (*direct_access) (struct block_device *, sector_t, 1299 int (*direct_access) (struct block_device *, sector_t,
1257 void **, unsigned long *); 1300 void **, unsigned long *);
1301 unsigned int (*check_events) (struct gendisk *disk,
1302 unsigned int clearing);
1303 /* ->media_changed() is DEPRECATED, use ->check_events() instead */
1258 int (*media_changed) (struct gendisk *); 1304 int (*media_changed) (struct gendisk *);
1259 void (*unlock_native_capacity) (struct gendisk *); 1305 void (*unlock_native_capacity) (struct gendisk *);
1260 int (*revalidate_disk) (struct gendisk *); 1306 int (*revalidate_disk) (struct gendisk *);
@@ -1277,6 +1323,31 @@ static inline long nr_blockdev_pages(void)
1277 return 0; 1323 return 0;
1278} 1324}
1279 1325
1326struct blk_plug {
1327};
1328
1329static inline void blk_start_plug(struct blk_plug *plug)
1330{
1331}
1332
1333static inline void blk_finish_plug(struct blk_plug *plug)
1334{
1335}
1336
1337static inline void blk_flush_plug(struct task_struct *task)
1338{
1339}
1340
1341static inline void blk_schedule_flush_plug(struct task_struct *task)
1342{
1343}
1344
1345
1346static inline bool blk_needs_flush_plug(struct task_struct *tsk)
1347{
1348 return false;
1349}
1350
1280#endif /* CONFIG_BLOCK */ 1351#endif /* CONFIG_BLOCK */
1281 1352
1282#endif 1353#endif
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 3395cf7130f5..8c7c2de7631a 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -169,7 +169,8 @@ extern void blk_trace_shutdown(struct request_queue *);
169extern int do_blk_trace_setup(struct request_queue *q, char *name, 169extern int do_blk_trace_setup(struct request_queue *q, char *name,
170 dev_t dev, struct block_device *bdev, 170 dev_t dev, struct block_device *bdev,
171 struct blk_user_trace_setup *buts); 171 struct blk_user_trace_setup *buts);
172extern void __trace_note_message(struct blk_trace *, const char *fmt, ...); 172extern __attribute__((format(printf, 2, 3)))
173void __trace_note_message(struct blk_trace *, const char *fmt, ...);
173 174
174/** 175/**
175 * blk_add_trace_msg - Add a (simple) message to the blktrace stream 176 * blk_add_trace_msg - Add a (simple) message to the blktrace stream
@@ -245,7 +246,6 @@ static inline int blk_cmd_buf_len(struct request *rq)
245 246
246extern void blk_dump_cmd(char *buf, struct request *rq); 247extern void blk_dump_cmd(char *buf, struct request *rq);
247extern void blk_fill_rwbs(char *rwbs, u32 rw, int bytes); 248extern void blk_fill_rwbs(char *rwbs, u32 rw, int bytes);
248extern void blk_fill_rwbs_rq(char *rwbs, struct request *rq);
249 249
250#endif /* CONFIG_EVENT_TRACING && CONFIG_BLOCK */ 250#endif /* CONFIG_EVENT_TRACING && CONFIG_BLOCK */
251 251
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 266ab9291232..ab344a521105 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -19,10 +19,6 @@ extern unsigned long min_low_pfn;
19 */ 19 */
20extern unsigned long max_pfn; 20extern unsigned long max_pfn;
21 21
22#ifdef CONFIG_CRASH_DUMP
23extern unsigned long saved_max_pfn;
24#endif
25
26#ifndef CONFIG_NO_BOOTMEM 22#ifndef CONFIG_NO_BOOTMEM
27/* 23/*
28 * node_bootmem_map is a map pointer - the bits represent all physical 24 * node_bootmem_map is a map pointer - the bits represent all physical
@@ -103,20 +99,31 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
103 unsigned long align, 99 unsigned long align,
104 unsigned long goal); 100 unsigned long goal);
105 101
102#ifdef CONFIG_NO_BOOTMEM
103/* We are using top down, so it is safe to use 0 here */
104#define BOOTMEM_LOW_LIMIT 0
105#else
106#define BOOTMEM_LOW_LIMIT __pa(MAX_DMA_ADDRESS)
107#endif
108
106#define alloc_bootmem(x) \ 109#define alloc_bootmem(x) \
107 __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 110 __alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
111#define alloc_bootmem_align(x, align) \
112 __alloc_bootmem(x, align, BOOTMEM_LOW_LIMIT)
108#define alloc_bootmem_nopanic(x) \ 113#define alloc_bootmem_nopanic(x) \
109 __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 114 __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
110#define alloc_bootmem_pages(x) \ 115#define alloc_bootmem_pages(x) \
111 __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 116 __alloc_bootmem(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
112#define alloc_bootmem_pages_nopanic(x) \ 117#define alloc_bootmem_pages_nopanic(x) \
113 __alloc_bootmem_nopanic(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 118 __alloc_bootmem_nopanic(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
114#define alloc_bootmem_node(pgdat, x) \ 119#define alloc_bootmem_node(pgdat, x) \
115 __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 120 __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
121#define alloc_bootmem_node_nopanic(pgdat, x) \
122 __alloc_bootmem_node_nopanic(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
116#define alloc_bootmem_pages_node(pgdat, x) \ 123#define alloc_bootmem_pages_node(pgdat, x) \
117 __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 124 __alloc_bootmem_node(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
118#define alloc_bootmem_pages_node_nopanic(pgdat, x) \ 125#define alloc_bootmem_pages_node_nopanic(pgdat, x) \
119 __alloc_bootmem_node_nopanic(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 126 __alloc_bootmem_node_nopanic(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
120 127
121#define alloc_bootmem_low(x) \ 128#define alloc_bootmem_low(x) \
122 __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0) 129 __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
diff --git a/include/linux/bsearch.h b/include/linux/bsearch.h
new file mode 100644
index 000000000000..90b1aa867224
--- /dev/null
+++ b/include/linux/bsearch.h
@@ -0,0 +1,9 @@
1#ifndef _LINUX_BSEARCH_H
2#define _LINUX_BSEARCH_H
3
4#include <linux/types.h>
5
6void *bsearch(const void *key, const void *base, size_t num, size_t size,
7 int (*cmp)(const void *key, const void *elt));
8
9#endif /* _LINUX_BSEARCH_H */
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index ec94c12f21da..503c8a6b3079 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -32,7 +32,6 @@ enum bh_state_bits {
32 BH_Delay, /* Buffer is not yet allocated on disk */ 32 BH_Delay, /* Buffer is not yet allocated on disk */
33 BH_Boundary, /* Block is followed by a discontiguity */ 33 BH_Boundary, /* Block is followed by a discontiguity */
34 BH_Write_EIO, /* I/O error on write */ 34 BH_Write_EIO, /* I/O error on write */
35 BH_Eopnotsupp, /* operation not supported (barrier) */
36 BH_Unwritten, /* Buffer is allocated on disk but not written */ 35 BH_Unwritten, /* Buffer is allocated on disk but not written */
37 BH_Quiet, /* Buffer Error Prinks to be quiet */ 36 BH_Quiet, /* Buffer Error Prinks to be quiet */
38 37
@@ -124,7 +123,6 @@ BUFFER_FNS(Async_Write, async_write)
124BUFFER_FNS(Delay, delay) 123BUFFER_FNS(Delay, delay)
125BUFFER_FNS(Boundary, boundary) 124BUFFER_FNS(Boundary, boundary)
126BUFFER_FNS(Write_EIO, write_io_error) 125BUFFER_FNS(Write_EIO, write_io_error)
127BUFFER_FNS(Eopnotsupp, eopnotsupp)
128BUFFER_FNS(Unwritten, unwritten) 126BUFFER_FNS(Unwritten, unwritten)
129 127
130#define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK) 128#define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
@@ -214,15 +212,29 @@ int generic_write_end(struct file *, struct address_space *,
214 loff_t, unsigned, unsigned, 212 loff_t, unsigned, unsigned,
215 struct page *, void *); 213 struct page *, void *);
216void page_zero_new_buffers(struct page *page, unsigned from, unsigned to); 214void page_zero_new_buffers(struct page *page, unsigned from, unsigned to);
217int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
218int cont_write_begin(struct file *, struct address_space *, loff_t, 215int cont_write_begin(struct file *, struct address_space *, loff_t,
219 unsigned, unsigned, struct page **, void **, 216 unsigned, unsigned, struct page **, void **,
220 get_block_t *, loff_t *); 217 get_block_t *, loff_t *);
221int generic_cont_expand_simple(struct inode *inode, loff_t size); 218int generic_cont_expand_simple(struct inode *inode, loff_t size);
222int block_commit_write(struct page *page, unsigned from, unsigned to); 219int block_commit_write(struct page *page, unsigned from, unsigned to);
220int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
221 get_block_t get_block);
223int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, 222int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
224 get_block_t get_block); 223 get_block_t get_block);
225void block_sync_page(struct page *); 224/* Convert errno to return value from ->page_mkwrite() call */
225static inline int block_page_mkwrite_return(int err)
226{
227 if (err == 0)
228 return VM_FAULT_LOCKED;
229 if (err == -EFAULT)
230 return VM_FAULT_NOPAGE;
231 if (err == -ENOMEM)
232 return VM_FAULT_OOM;
233 if (err == -EAGAIN)
234 return VM_FAULT_RETRY;
235 /* -ENOSPC, -EDQUOT, -EIO ... */
236 return VM_FAULT_SIGBUS;
237}
226sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *); 238sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
227int block_truncate_page(struct address_space *, loff_t, get_block_t *); 239int block_truncate_page(struct address_space *, loff_t, get_block_t *);
228int nobh_write_begin(struct address_space *, loff_t, unsigned, unsigned, 240int nobh_write_begin(struct address_space *, loff_t, unsigned, unsigned,
diff --git a/include/linux/c2port.h b/include/linux/c2port.h
index 2a5cd867c365..a2f7d7413f30 100644
--- a/include/linux/c2port.h
+++ b/include/linux/c2port.h
@@ -60,9 +60,6 @@ struct c2port_ops {
60 * Exported functions 60 * Exported functions
61 */ 61 */
62 62
63#define to_class_dev(obj) container_of((obj), struct class_device, kobj)
64#define to_c2port_device(obj) container_of((obj), struct c2port_device, class)
65
66extern struct c2port_device *c2port_device_register(char *name, 63extern struct c2port_device *c2port_device_register(char *name,
67 struct c2port_ops *ops, void *devdata); 64 struct c2port_ops *ops, void *devdata);
68extern void c2port_device_unregister(struct c2port_device *dev); 65extern void c2port_device_unregister(struct c2port_device *dev);
diff --git a/include/linux/caif/Kbuild b/include/linux/caif/Kbuild
new file mode 100644
index 000000000000..a9cf250689dc
--- /dev/null
+++ b/include/linux/caif/Kbuild
@@ -0,0 +1,2 @@
1header-y += caif_socket.h
2header-y += if_caif.h
diff --git a/include/linux/can/core.h b/include/linux/can/core.h
index 6c507bea275f..5ce6b5d62ecc 100644
--- a/include/linux/can/core.h
+++ b/include/linux/can/core.h
@@ -36,16 +36,16 @@
36 * @prot: pointer to struct proto structure. 36 * @prot: pointer to struct proto structure.
37 */ 37 */
38struct can_proto { 38struct can_proto {
39 int type; 39 int type;
40 int protocol; 40 int protocol;
41 struct proto_ops *ops; 41 const struct proto_ops *ops;
42 struct proto *prot; 42 struct proto *prot;
43}; 43};
44 44
45/* function prototypes for the CAN networklayer core (af_can.c) */ 45/* function prototypes for the CAN networklayer core (af_can.c) */
46 46
47extern int can_proto_register(struct can_proto *cp); 47extern int can_proto_register(const struct can_proto *cp);
48extern void can_proto_unregister(struct can_proto *cp); 48extern void can_proto_unregister(const struct can_proto *cp);
49 49
50extern int can_rx_register(struct net_device *dev, canid_t can_id, 50extern int can_rx_register(struct net_device *dev, canid_t can_id,
51 canid_t mask, 51 canid_t mask,
@@ -58,5 +58,6 @@ extern void can_rx_unregister(struct net_device *dev, canid_t can_id,
58 void *data); 58 void *data);
59 59
60extern int can_send(struct sk_buff *skb, int loop); 60extern int can_send(struct sk_buff *skb, int loop);
61extern int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
61 62
62#endif /* CAN_CORE_H */ 63#endif /* CAN_CORE_H */
diff --git a/include/linux/can/error.h b/include/linux/can/error.h
index d4127fd9e681..5958074302a4 100644
--- a/include/linux/can/error.h
+++ b/include/linux/can/error.h
@@ -51,7 +51,7 @@
51#define CAN_ERR_PROT_BIT1 0x10 /* unable to send recessive bit */ 51#define CAN_ERR_PROT_BIT1 0x10 /* unable to send recessive bit */
52#define CAN_ERR_PROT_OVERLOAD 0x20 /* bus overload */ 52#define CAN_ERR_PROT_OVERLOAD 0x20 /* bus overload */
53#define CAN_ERR_PROT_ACTIVE 0x40 /* active error announcement */ 53#define CAN_ERR_PROT_ACTIVE 0x40 /* active error announcement */
54#define CAN_ERR_PROT_TX 0x80 /* error occured on transmission */ 54#define CAN_ERR_PROT_TX 0x80 /* error occurred on transmission */
55 55
56/* error in CAN protocol (location) / data[3] */ 56/* error in CAN protocol (location) / data[3] */
57#define CAN_ERR_PROT_LOC_UNSPEC 0x00 /* unspecified */ 57#define CAN_ERR_PROT_LOC_UNSPEC 0x00 /* unspecified */
diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h
index 3250de935e1a..34542d374dd8 100644
--- a/include/linux/can/netlink.h
+++ b/include/linux/can/netlink.h
@@ -17,7 +17,7 @@
17/* 17/*
18 * CAN bit-timing parameters 18 * CAN bit-timing parameters
19 * 19 *
20 * For futher information, please read chapter "8 BIT TIMING 20 * For further information, please read chapter "8 BIT TIMING
21 * REQUIREMENTS" of the "Bosch CAN Specification version 2.0" 21 * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
22 * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf. 22 * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
23 */ 23 */
diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h
index dba28268e651..089fe43211a4 100644
--- a/include/linux/can/platform/mcp251x.h
+++ b/include/linux/can/platform/mcp251x.h
@@ -12,7 +12,7 @@
12/** 12/**
13 * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data 13 * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data
14 * @oscillator_frequency: - oscillator frequency in Hz 14 * @oscillator_frequency: - oscillator frequency in Hz
15 * @model: - actual type of chip 15 * @irq_flags: - IRQF configuration flags
16 * @board_specific_setup: - called before probing the chip (power,reset) 16 * @board_specific_setup: - called before probing the chip (power,reset)
17 * @transceiver_enable: - called to power on/off the transceiver 17 * @transceiver_enable: - called to power on/off the transceiver
18 * @power_enable: - called to power on/off the mcp *and* the 18 * @power_enable: - called to power on/off the mcp *and* the
@@ -25,9 +25,7 @@
25 25
26struct mcp251x_platform_data { 26struct mcp251x_platform_data {
27 unsigned long oscillator_frequency; 27 unsigned long oscillator_frequency;
28 int model; 28 unsigned long irq_flags;
29#define CAN_MCP251X_MCP2510 0x2510
30#define CAN_MCP251X_MCP2515 0x2515
31 int (*board_specific_setup)(struct spi_device *spi); 29 int (*board_specific_setup)(struct spi_device *spi);
32 int (*transceiver_enable)(int enable); 30 int (*transceiver_enable)(int enable);
33 int (*power_enable) (int enable); 31 int (*power_enable) (int enable);
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 90012b9ddbf3..c42112350003 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -246,7 +246,6 @@ struct cpu_vfs_cap_data {
246/* Allow configuration of the secure attention key */ 246/* Allow configuration of the secure attention key */
247/* Allow administration of the random device */ 247/* Allow administration of the random device */
248/* Allow examination and configuration of disk quotas */ 248/* Allow examination and configuration of disk quotas */
249/* Allow configuring the kernel's syslog (printk behaviour) */
250/* Allow setting the domainname */ 249/* Allow setting the domainname */
251/* Allow setting the hostname */ 250/* Allow setting the hostname */
252/* Allow calling bdflush() */ 251/* Allow calling bdflush() */
@@ -352,7 +351,16 @@ struct cpu_vfs_cap_data {
352 351
353#define CAP_MAC_ADMIN 33 352#define CAP_MAC_ADMIN 33
354 353
355#define CAP_LAST_CAP CAP_MAC_ADMIN 354/* Allow configuring the kernel's syslog (printk behaviour) */
355
356#define CAP_SYSLOG 34
357
358/* Allow triggering something that will wake the system */
359
360#define CAP_WAKE_ALARM 35
361
362
363#define CAP_LAST_CAP CAP_WAKE_ALARM
356 364
357#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP) 365#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
358 366
@@ -365,6 +373,15 @@ struct cpu_vfs_cap_data {
365 373
366#ifdef __KERNEL__ 374#ifdef __KERNEL__
367 375
376struct dentry;
377struct user_namespace;
378
379struct user_namespace *current_user_ns(void);
380
381extern const kernel_cap_t __cap_empty_set;
382extern const kernel_cap_t __cap_full_set;
383extern const kernel_cap_t __cap_init_eff_set;
384
368/* 385/*
369 * Internal kernel functions only 386 * Internal kernel functions only
370 */ 387 */
@@ -400,7 +417,6 @@ struct cpu_vfs_cap_data {
400 417
401# define CAP_EMPTY_SET ((kernel_cap_t){{ 0, 0 }}) 418# define CAP_EMPTY_SET ((kernel_cap_t){{ 0, 0 }})
402# define CAP_FULL_SET ((kernel_cap_t){{ ~0, ~0 }}) 419# define CAP_FULL_SET ((kernel_cap_t){{ ~0, ~0 }})
403# define CAP_INIT_EFF_SET ((kernel_cap_t){{ ~CAP_TO_MASK(CAP_SETPCAP), ~0 }})
404# define CAP_FS_SET ((kernel_cap_t){{ CAP_FS_MASK_B0 \ 420# define CAP_FS_SET ((kernel_cap_t){{ CAP_FS_MASK_B0 \
405 | CAP_TO_MASK(CAP_LINUX_IMMUTABLE), \ 421 | CAP_TO_MASK(CAP_LINUX_IMMUTABLE), \
406 CAP_FS_MASK_B1 } }) 422 CAP_FS_MASK_B1 } })
@@ -410,11 +426,7 @@ struct cpu_vfs_cap_data {
410 426
411#endif /* _KERNEL_CAPABILITY_U32S != 2 */ 427#endif /* _KERNEL_CAPABILITY_U32S != 2 */
412 428
413#define CAP_INIT_INH_SET CAP_EMPTY_SET
414
415# define cap_clear(c) do { (c) = __cap_empty_set; } while (0) 429# define cap_clear(c) do { (c) = __cap_empty_set; } while (0)
416# define cap_set_full(c) do { (c) = __cap_full_set; } while (0)
417# define cap_set_init_eff(c) do { (c) = __cap_init_eff_set; } while (0)
418 430
419#define cap_raise(c, flag) ((c).cap[CAP_TO_INDEX(flag)] |= CAP_TO_MASK(flag)) 431#define cap_raise(c, flag) ((c).cap[CAP_TO_INDEX(flag)] |= CAP_TO_MASK(flag))
420#define cap_lower(c, flag) ((c).cap[CAP_TO_INDEX(flag)] &= ~CAP_TO_MASK(flag)) 432#define cap_lower(c, flag) ((c).cap[CAP_TO_INDEX(flag)] &= ~CAP_TO_MASK(flag))
@@ -527,40 +539,16 @@ static inline kernel_cap_t cap_raise_nfsd_set(const kernel_cap_t a,
527 cap_intersect(permitted, __cap_nfsd_set)); 539 cap_intersect(permitted, __cap_nfsd_set));
528} 540}
529 541
530extern const kernel_cap_t __cap_empty_set; 542extern bool has_capability(struct task_struct *t, int cap);
531extern const kernel_cap_t __cap_full_set; 543extern bool has_ns_capability(struct task_struct *t,
532extern const kernel_cap_t __cap_init_eff_set; 544 struct user_namespace *ns, int cap);
533 545extern bool has_capability_noaudit(struct task_struct *t, int cap);
534/** 546extern bool capable(int cap);
535 * has_capability - Determine if a task has a superior capability available 547extern bool ns_capable(struct user_namespace *ns, int cap);
536 * @t: The task in question 548extern bool task_ns_capable(struct task_struct *t, int cap);
537 * @cap: The capability to be tested for 549extern bool nsown_capable(int cap);
538 *
539 * Return true if the specified task has the given superior capability
540 * currently in effect, false if not.
541 *
542 * Note that this does not set PF_SUPERPRIV on the task.
543 */
544#define has_capability(t, cap) (security_real_capable((t), (cap)) == 0)
545
546/**
547 * has_capability_noaudit - Determine if a task has a superior capability available (unaudited)
548 * @t: The task in question
549 * @cap: The capability to be tested for
550 *
551 * Return true if the specified task has the given superior capability
552 * currently in effect, false if not, but don't write an audit message for the
553 * check.
554 *
555 * Note that this does not set PF_SUPERPRIV on the task.
556 */
557#define has_capability_noaudit(t, cap) \
558 (security_real_capable_noaudit((t), (cap)) == 0)
559
560extern int capable(int cap);
561 550
562/* audit system wants to get cap info from files as well */ 551/* audit system wants to get cap info from files as well */
563struct dentry;
564extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps); 552extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
565 553
566#endif /* __KERNEL__ */ 554#endif /* __KERNEL__ */
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index f389e319a454..fb4591977b03 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -28,8 +28,6 @@ int cdev_add(struct cdev *, dev_t, unsigned);
28 28
29void cdev_del(struct cdev *); 29void cdev_del(struct cdev *);
30 30
31int cdev_index(struct inode *inode);
32
33void cd_forget(struct inode *); 31void cd_forget(struct inode *);
34 32
35extern struct backing_dev_info directly_mappable_cdev_bdi; 33extern struct backing_dev_info directly_mappable_cdev_bdi;
diff --git a/include/linux/cdk.h b/include/linux/cdk.h
index 0908daf7bf56..80093a8d4f64 100644
--- a/include/linux/cdk.h
+++ b/include/linux/cdk.h
@@ -149,7 +149,7 @@ typedef struct cdkhdr {
149/* 149/*
150 * Define the memory mapping structure. This structure is pointed to by 150 * Define the memory mapping structure. This structure is pointed to by
151 * the memp field in the stlcdkhdr struct. As many as these structures 151 * the memp field in the stlcdkhdr struct. As many as these structures
152 * as required are layed out in shared memory to define how the rest of 152 * as required are laid out in shared memory to define how the rest of
153 * shared memory is divided up. There will be one for each port. 153 * shared memory is divided up. There will be one for each port.
154 */ 154 */
155typedef struct cdkmem { 155typedef struct cdkmem {
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 78e904796622..35eae4b67503 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -946,6 +946,8 @@ struct cdrom_device_info {
946/* device-related storage */ 946/* device-related storage */
947 unsigned int options : 30; /* options flags */ 947 unsigned int options : 30; /* options flags */
948 unsigned mc_flags : 2; /* media change buffer flags */ 948 unsigned mc_flags : 2; /* media change buffer flags */
949 unsigned int vfs_events; /* cached events for vfs path */
950 unsigned int ioctl_events; /* cached events for ioctl path */
949 int use_count; /* number of times device opened */ 951 int use_count; /* number of times device opened */
950 char name[20]; /* name of the device type */ 952 char name[20]; /* name of the device type */
951/* per-device flags */ 953/* per-device flags */
@@ -965,6 +967,8 @@ struct cdrom_device_ops {
965 int (*open) (struct cdrom_device_info *, int); 967 int (*open) (struct cdrom_device_info *, int);
966 void (*release) (struct cdrom_device_info *); 968 void (*release) (struct cdrom_device_info *);
967 int (*drive_status) (struct cdrom_device_info *, int); 969 int (*drive_status) (struct cdrom_device_info *, int);
970 unsigned int (*check_events) (struct cdrom_device_info *cdi,
971 unsigned int clearing, int slot);
968 int (*media_changed) (struct cdrom_device_info *, int); 972 int (*media_changed) (struct cdrom_device_info *, int);
969 int (*tray_move) (struct cdrom_device_info *, int); 973 int (*tray_move) (struct cdrom_device_info *, int);
970 int (*lock_door) (struct cdrom_device_info *, int); 974 int (*lock_door) (struct cdrom_device_info *, int);
@@ -993,6 +997,8 @@ extern int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
993extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode); 997extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode);
994extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev, 998extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
995 fmode_t mode, unsigned int cmd, unsigned long arg); 999 fmode_t mode, unsigned int cmd, unsigned long arg);
1000extern unsigned int cdrom_check_events(struct cdrom_device_info *cdi,
1001 unsigned int clearing);
996extern int cdrom_media_changed(struct cdrom_device_info *); 1002extern int cdrom_media_changed(struct cdrom_device_info *);
997 1003
998extern int register_cdrom(struct cdrom_device_info *cdi); 1004extern int register_cdrom(struct cdrom_device_info *cdi);
diff --git a/include/linux/ceph/auth.h b/include/linux/ceph/auth.h
new file mode 100644
index 000000000000..aa13392a7efb
--- /dev/null
+++ b/include/linux/ceph/auth.h
@@ -0,0 +1,92 @@
1#ifndef _FS_CEPH_AUTH_H
2#define _FS_CEPH_AUTH_H
3
4#include <linux/ceph/types.h>
5#include <linux/ceph/buffer.h>
6
7/*
8 * Abstract interface for communicating with the authenticate module.
9 * There is some handshake that takes place between us and the monitor
10 * to acquire the necessary keys. These are used to generate an
11 * 'authorizer' that we use when connecting to a service (mds, osd).
12 */
13
14struct ceph_auth_client;
15struct ceph_authorizer;
16
17struct ceph_auth_client_ops {
18 const char *name;
19
20 /*
21 * true if we are authenticated and can connect to
22 * services.
23 */
24 int (*is_authenticated)(struct ceph_auth_client *ac);
25
26 /*
27 * true if we should (re)authenticate, e.g., when our tickets
28 * are getting old and crusty.
29 */
30 int (*should_authenticate)(struct ceph_auth_client *ac);
31
32 /*
33 * build requests and process replies during monitor
34 * handshake. if handle_reply returns -EAGAIN, we build
35 * another request.
36 */
37 int (*build_request)(struct ceph_auth_client *ac, void *buf, void *end);
38 int (*handle_reply)(struct ceph_auth_client *ac, int result,
39 void *buf, void *end);
40
41 /*
42 * Create authorizer for connecting to a service, and verify
43 * the response to authenticate the service.
44 */
45 int (*create_authorizer)(struct ceph_auth_client *ac, int peer_type,
46 struct ceph_authorizer **a,
47 void **buf, size_t *len,
48 void **reply_buf, size_t *reply_len);
49 int (*verify_authorizer_reply)(struct ceph_auth_client *ac,
50 struct ceph_authorizer *a, size_t len);
51 void (*destroy_authorizer)(struct ceph_auth_client *ac,
52 struct ceph_authorizer *a);
53 void (*invalidate_authorizer)(struct ceph_auth_client *ac,
54 int peer_type);
55
56 /* reset when we (re)connect to a monitor */
57 void (*reset)(struct ceph_auth_client *ac);
58
59 void (*destroy)(struct ceph_auth_client *ac);
60};
61
62struct ceph_auth_client {
63 u32 protocol; /* CEPH_AUTH_* */
64 void *private; /* for use by protocol implementation */
65 const struct ceph_auth_client_ops *ops; /* null iff protocol==0 */
66
67 bool negotiating; /* true if negotiating protocol */
68 const char *name; /* entity name */
69 u64 global_id; /* our unique id in system */
70 const struct ceph_crypto_key *key; /* our secret key */
71 unsigned want_keys; /* which services we want */
72};
73
74extern struct ceph_auth_client *ceph_auth_init(const char *name,
75 const struct ceph_crypto_key *key);
76extern void ceph_auth_destroy(struct ceph_auth_client *ac);
77
78extern void ceph_auth_reset(struct ceph_auth_client *ac);
79
80extern int ceph_auth_build_hello(struct ceph_auth_client *ac,
81 void *buf, size_t len);
82extern int ceph_handle_auth_reply(struct ceph_auth_client *ac,
83 void *buf, size_t len,
84 void *reply_buf, size_t reply_len);
85extern int ceph_entity_name_encode(const char *name, void **p, void *end);
86
87extern int ceph_build_auth(struct ceph_auth_client *ac,
88 void *msg_buf, size_t msg_len);
89
90extern int ceph_auth_is_authenticated(struct ceph_auth_client *ac);
91
92#endif
diff --git a/include/linux/ceph/buffer.h b/include/linux/ceph/buffer.h
new file mode 100644
index 000000000000..58d19014068f
--- /dev/null
+++ b/include/linux/ceph/buffer.h
@@ -0,0 +1,39 @@
1#ifndef __FS_CEPH_BUFFER_H
2#define __FS_CEPH_BUFFER_H
3
4#include <linux/kref.h>
5#include <linux/mm.h>
6#include <linux/vmalloc.h>
7#include <linux/types.h>
8#include <linux/uio.h>
9
10/*
11 * a simple reference counted buffer.
12 *
13 * use kmalloc for small sizes (<= one page), vmalloc for larger
14 * sizes.
15 */
16struct ceph_buffer {
17 struct kref kref;
18 struct kvec vec;
19 size_t alloc_len;
20 bool is_vmalloc;
21};
22
23extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp);
24extern void ceph_buffer_release(struct kref *kref);
25
26static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
27{
28 kref_get(&b->kref);
29 return b;
30}
31
32static inline void ceph_buffer_put(struct ceph_buffer *b)
33{
34 kref_put(&b->kref, ceph_buffer_release);
35}
36
37extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);
38
39#endif
diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h
new file mode 100644
index 000000000000..aa2e19182d99
--- /dev/null
+++ b/include/linux/ceph/ceph_debug.h
@@ -0,0 +1,38 @@
1#ifndef _FS_CEPH_DEBUG_H
2#define _FS_CEPH_DEBUG_H
3
4#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
5
6#ifdef CONFIG_CEPH_LIB_PRETTYDEBUG
7
8/*
9 * wrap pr_debug to include a filename:lineno prefix on each line.
10 * this incurs some overhead (kernel size and execution time) due to
11 * the extra function call at each call site.
12 */
13
14# if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
15extern const char *ceph_file_part(const char *s, int len);
16# define dout(fmt, ...) \
17 pr_debug("%.*s %12.12s:%-4d : " fmt, \
18 8 - (int)sizeof(KBUILD_MODNAME), " ", \
19 ceph_file_part(__FILE__, sizeof(__FILE__)), \
20 __LINE__, ##__VA_ARGS__)
21# else
22/* faux printk call just to see any compiler warnings. */
23# define dout(fmt, ...) do { \
24 if (0) \
25 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
26 } while (0)
27# endif
28
29#else
30
31/*
32 * or, just wrap pr_debug
33 */
34# define dout(fmt, ...) pr_debug(" " fmt, ##__VA_ARGS__)
35
36#endif
37
38#endif
diff --git a/include/linux/ceph/ceph_frag.h b/include/linux/ceph/ceph_frag.h
new file mode 100644
index 000000000000..5babb8e95352
--- /dev/null
+++ b/include/linux/ceph/ceph_frag.h
@@ -0,0 +1,109 @@
1#ifndef FS_CEPH_FRAG_H
2#define FS_CEPH_FRAG_H
3
4/*
5 * "Frags" are a way to describe a subset of a 32-bit number space,
6 * using a mask and a value to match against that mask. Any given frag
7 * (subset of the number space) can be partitioned into 2^n sub-frags.
8 *
9 * Frags are encoded into a 32-bit word:
10 * 8 upper bits = "bits"
11 * 24 lower bits = "value"
12 * (We could go to 5+27 bits, but who cares.)
13 *
14 * We use the _most_ significant bits of the 24 bit value. This makes
15 * values logically sort.
16 *
17 * Unfortunately, because the "bits" field is still in the high bits, we
18 * can't sort encoded frags numerically. However, it does allow you
19 * to feed encoded frags as values into frag_contains_value.
20 */
21static inline __u32 ceph_frag_make(__u32 b, __u32 v)
22{
23 return (b << 24) |
24 (v & (0xffffffu << (24-b)) & 0xffffffu);
25}
26static inline __u32 ceph_frag_bits(__u32 f)
27{
28 return f >> 24;
29}
30static inline __u32 ceph_frag_value(__u32 f)
31{
32 return f & 0xffffffu;
33}
34static inline __u32 ceph_frag_mask(__u32 f)
35{
36 return (0xffffffu << (24-ceph_frag_bits(f))) & 0xffffffu;
37}
38static inline __u32 ceph_frag_mask_shift(__u32 f)
39{
40 return 24 - ceph_frag_bits(f);
41}
42
43static inline int ceph_frag_contains_value(__u32 f, __u32 v)
44{
45 return (v & ceph_frag_mask(f)) == ceph_frag_value(f);
46}
47static inline int ceph_frag_contains_frag(__u32 f, __u32 sub)
48{
49 /* is sub as specific as us, and contained by us? */
50 return ceph_frag_bits(sub) >= ceph_frag_bits(f) &&
51 (ceph_frag_value(sub) & ceph_frag_mask(f)) == ceph_frag_value(f);
52}
53
54static inline __u32 ceph_frag_parent(__u32 f)
55{
56 return ceph_frag_make(ceph_frag_bits(f) - 1,
57 ceph_frag_value(f) & (ceph_frag_mask(f) << 1));
58}
59static inline int ceph_frag_is_left_child(__u32 f)
60{
61 return ceph_frag_bits(f) > 0 &&
62 (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 0;
63}
64static inline int ceph_frag_is_right_child(__u32 f)
65{
66 return ceph_frag_bits(f) > 0 &&
67 (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 1;
68}
69static inline __u32 ceph_frag_sibling(__u32 f)
70{
71 return ceph_frag_make(ceph_frag_bits(f),
72 ceph_frag_value(f) ^ (0x1000000 >> ceph_frag_bits(f)));
73}
74static inline __u32 ceph_frag_left_child(__u32 f)
75{
76 return ceph_frag_make(ceph_frag_bits(f)+1, ceph_frag_value(f));
77}
78static inline __u32 ceph_frag_right_child(__u32 f)
79{
80 return ceph_frag_make(ceph_frag_bits(f)+1,
81 ceph_frag_value(f) | (0x1000000 >> (1+ceph_frag_bits(f))));
82}
83static inline __u32 ceph_frag_make_child(__u32 f, int by, int i)
84{
85 int newbits = ceph_frag_bits(f) + by;
86 return ceph_frag_make(newbits,
87 ceph_frag_value(f) | (i << (24 - newbits)));
88}
89static inline int ceph_frag_is_leftmost(__u32 f)
90{
91 return ceph_frag_value(f) == 0;
92}
93static inline int ceph_frag_is_rightmost(__u32 f)
94{
95 return ceph_frag_value(f) == ceph_frag_mask(f);
96}
97static inline __u32 ceph_frag_next(__u32 f)
98{
99 return ceph_frag_make(ceph_frag_bits(f),
100 ceph_frag_value(f) + (0x1000000 >> ceph_frag_bits(f)));
101}
102
103/*
104 * comparator to sort frags logically, as when traversing the
105 * number space in ascending order...
106 */
107int ceph_frag_compare(__u32 a, __u32 b);
108
109#endif
diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h
new file mode 100644
index 000000000000..b8c60694b2b0
--- /dev/null
+++ b/include/linux/ceph/ceph_fs.h
@@ -0,0 +1,751 @@
1/*
2 * ceph_fs.h - Ceph constants and data types to share between kernel and
3 * user space.
4 *
5 * Most types in this file are defined as little-endian, and are
6 * primarily intended to describe data structures that pass over the
7 * wire or that are stored on disk.
8 *
9 * LGPL2
10 */
11
12#ifndef CEPH_FS_H
13#define CEPH_FS_H
14
15#include "msgr.h"
16#include "rados.h"
17
18/*
19 * subprotocol versions. when specific messages types or high-level
20 * protocols change, bump the affected components. we keep rev
21 * internal cluster protocols separately from the public,
22 * client-facing protocol.
23 */
24#define CEPH_OSD_PROTOCOL 8 /* cluster internal */
25#define CEPH_MDS_PROTOCOL 12 /* cluster internal */
26#define CEPH_MON_PROTOCOL 5 /* cluster internal */
27#define CEPH_OSDC_PROTOCOL 24 /* server/client */
28#define CEPH_MDSC_PROTOCOL 32 /* server/client */
29#define CEPH_MONC_PROTOCOL 15 /* server/client */
30
31
32#define CEPH_INO_ROOT 1
33#define CEPH_INO_CEPH 2 /* hidden .ceph dir */
34
35/* arbitrary limit on max # of monitors (cluster of 3 is typical) */
36#define CEPH_MAX_MON 31
37
38
39/*
40 * feature bits
41 */
42#define CEPH_FEATURE_UID (1<<0)
43#define CEPH_FEATURE_NOSRCADDR (1<<1)
44#define CEPH_FEATURE_MONCLOCKCHECK (1<<2)
45#define CEPH_FEATURE_FLOCK (1<<3)
46#define CEPH_FEATURE_SUBSCRIBE2 (1<<4)
47#define CEPH_FEATURE_MONNAMES (1<<5)
48#define CEPH_FEATURE_RECONNECT_SEQ (1<<6)
49#define CEPH_FEATURE_DIRLAYOUTHASH (1<<7)
50
51
52/*
53 * ceph_file_layout - describe data layout for a file/inode
54 */
55struct ceph_file_layout {
56 /* file -> object mapping */
57 __le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple
58 of page size. */
59 __le32 fl_stripe_count; /* over this many objects */
60 __le32 fl_object_size; /* until objects are this big, then move to
61 new objects */
62 __le32 fl_cas_hash; /* UNUSED. 0 = none; 1 = sha256 */
63
64 /* pg -> disk layout */
65 __le32 fl_object_stripe_unit; /* UNUSED. for per-object parity, if any */
66
67 /* object -> pg layout */
68 __le32 fl_pg_preferred; /* preferred primary for pg (-1 for none) */
69 __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
70} __attribute__ ((packed));
71
72#define CEPH_MIN_STRIPE_UNIT 65536
73
74int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
75
76struct ceph_dir_layout {
77 __u8 dl_dir_hash; /* see ceph_hash.h for ids */
78 __u8 dl_unused1;
79 __u16 dl_unused2;
80 __u32 dl_unused3;
81} __attribute__ ((packed));
82
83/* crypto algorithms */
84#define CEPH_CRYPTO_NONE 0x0
85#define CEPH_CRYPTO_AES 0x1
86
87#define CEPH_AES_IV "cephsageyudagreg"
88
89/* security/authentication protocols */
90#define CEPH_AUTH_UNKNOWN 0x0
91#define CEPH_AUTH_NONE 0x1
92#define CEPH_AUTH_CEPHX 0x2
93
94#define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
95
96
97/*********************************************
98 * message layer
99 */
100
101/*
102 * message types
103 */
104
105/* misc */
106#define CEPH_MSG_SHUTDOWN 1
107#define CEPH_MSG_PING 2
108
109/* client <-> monitor */
110#define CEPH_MSG_MON_MAP 4
111#define CEPH_MSG_MON_GET_MAP 5
112#define CEPH_MSG_STATFS 13
113#define CEPH_MSG_STATFS_REPLY 14
114#define CEPH_MSG_MON_SUBSCRIBE 15
115#define CEPH_MSG_MON_SUBSCRIBE_ACK 16
116#define CEPH_MSG_AUTH 17
117#define CEPH_MSG_AUTH_REPLY 18
118
119/* client <-> mds */
120#define CEPH_MSG_MDS_MAP 21
121
122#define CEPH_MSG_CLIENT_SESSION 22
123#define CEPH_MSG_CLIENT_RECONNECT 23
124
125#define CEPH_MSG_CLIENT_REQUEST 24
126#define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
127#define CEPH_MSG_CLIENT_REPLY 26
128#define CEPH_MSG_CLIENT_CAPS 0x310
129#define CEPH_MSG_CLIENT_LEASE 0x311
130#define CEPH_MSG_CLIENT_SNAP 0x312
131#define CEPH_MSG_CLIENT_CAPRELEASE 0x313
132
133/* pool ops */
134#define CEPH_MSG_POOLOP_REPLY 48
135#define CEPH_MSG_POOLOP 49
136
137
138/* osd */
139#define CEPH_MSG_OSD_MAP 41
140#define CEPH_MSG_OSD_OP 42
141#define CEPH_MSG_OSD_OPREPLY 43
142#define CEPH_MSG_WATCH_NOTIFY 44
143
144
145/* watch-notify operations */
146enum {
147 WATCH_NOTIFY = 1, /* notifying watcher */
148 WATCH_NOTIFY_COMPLETE = 2, /* notifier notified when done */
149};
150
151
152/* pool operations */
153enum {
154 POOL_OP_CREATE = 0x01,
155 POOL_OP_DELETE = 0x02,
156 POOL_OP_AUID_CHANGE = 0x03,
157 POOL_OP_CREATE_SNAP = 0x11,
158 POOL_OP_DELETE_SNAP = 0x12,
159 POOL_OP_CREATE_UNMANAGED_SNAP = 0x21,
160 POOL_OP_DELETE_UNMANAGED_SNAP = 0x22,
161};
162
163struct ceph_mon_request_header {
164 __le64 have_version;
165 __le16 session_mon;
166 __le64 session_mon_tid;
167} __attribute__ ((packed));
168
169struct ceph_mon_statfs {
170 struct ceph_mon_request_header monhdr;
171 struct ceph_fsid fsid;
172} __attribute__ ((packed));
173
174struct ceph_statfs {
175 __le64 kb, kb_used, kb_avail;
176 __le64 num_objects;
177} __attribute__ ((packed));
178
179struct ceph_mon_statfs_reply {
180 struct ceph_fsid fsid;
181 __le64 version;
182 struct ceph_statfs st;
183} __attribute__ ((packed));
184
185const char *ceph_pool_op_name(int op);
186
187struct ceph_mon_poolop {
188 struct ceph_mon_request_header monhdr;
189 struct ceph_fsid fsid;
190 __le32 pool;
191 __le32 op;
192 __le64 auid;
193 __le64 snapid;
194 __le32 name_len;
195} __attribute__ ((packed));
196
197struct ceph_mon_poolop_reply {
198 struct ceph_mon_request_header monhdr;
199 struct ceph_fsid fsid;
200 __le32 reply_code;
201 __le32 epoch;
202 char has_data;
203 char data[0];
204} __attribute__ ((packed));
205
206struct ceph_mon_unmanaged_snap {
207 __le64 snapid;
208} __attribute__ ((packed));
209
210struct ceph_osd_getmap {
211 struct ceph_mon_request_header monhdr;
212 struct ceph_fsid fsid;
213 __le32 start;
214} __attribute__ ((packed));
215
216struct ceph_mds_getmap {
217 struct ceph_mon_request_header monhdr;
218 struct ceph_fsid fsid;
219} __attribute__ ((packed));
220
221struct ceph_client_mount {
222 struct ceph_mon_request_header monhdr;
223} __attribute__ ((packed));
224
225#define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
226
227struct ceph_mon_subscribe_item {
228 __le64 have_version; __le64 have;
229 __u8 onetime;
230} __attribute__ ((packed));
231
232struct ceph_mon_subscribe_ack {
233 __le32 duration; /* seconds */
234 struct ceph_fsid fsid;
235} __attribute__ ((packed));
236
237/*
238 * mds states
239 * > 0 -> in
240 * <= 0 -> out
241 */
242#define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
243#define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
244 empty log. */
245#define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
246#define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
247#define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
248#define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
249#define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
250
251#define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
252#define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
253 operations (import, rename, etc.) */
254#define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
255#define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
256#define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
257#define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
258#define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
259
260extern const char *ceph_mds_state_name(int s);
261
262
263/*
264 * metadata lock types.
265 * - these are bitmasks.. we can compose them
266 * - they also define the lock ordering by the MDS
267 * - a few of these are internal to the mds
268 */
269#define CEPH_LOCK_DVERSION 1
270#define CEPH_LOCK_DN 2
271#define CEPH_LOCK_ISNAP 16
272#define CEPH_LOCK_IVERSION 32 /* mds internal */
273#define CEPH_LOCK_IFILE 64
274#define CEPH_LOCK_IAUTH 128
275#define CEPH_LOCK_ILINK 256
276#define CEPH_LOCK_IDFT 512 /* dir frag tree */
277#define CEPH_LOCK_INEST 1024 /* mds internal */
278#define CEPH_LOCK_IXATTR 2048
279#define CEPH_LOCK_IFLOCK 4096 /* advisory file locks */
280#define CEPH_LOCK_INO 8192 /* immutable inode bits; not a lock */
281
282/* client_session ops */
283enum {
284 CEPH_SESSION_REQUEST_OPEN,
285 CEPH_SESSION_OPEN,
286 CEPH_SESSION_REQUEST_CLOSE,
287 CEPH_SESSION_CLOSE,
288 CEPH_SESSION_REQUEST_RENEWCAPS,
289 CEPH_SESSION_RENEWCAPS,
290 CEPH_SESSION_STALE,
291 CEPH_SESSION_RECALL_STATE,
292};
293
294extern const char *ceph_session_op_name(int op);
295
296struct ceph_mds_session_head {
297 __le32 op;
298 __le64 seq;
299 struct ceph_timespec stamp;
300 __le32 max_caps, max_leases;
301} __attribute__ ((packed));
302
303/* client_request */
304/*
305 * metadata ops.
306 * & 0x001000 -> write op
307 * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
308 & & 0x100000 -> use weird ino/path trace
309 */
310#define CEPH_MDS_OP_WRITE 0x001000
311enum {
312 CEPH_MDS_OP_LOOKUP = 0x00100,
313 CEPH_MDS_OP_GETATTR = 0x00101,
314 CEPH_MDS_OP_LOOKUPHASH = 0x00102,
315 CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
316 CEPH_MDS_OP_LOOKUPINO = 0x00104,
317
318 CEPH_MDS_OP_SETXATTR = 0x01105,
319 CEPH_MDS_OP_RMXATTR = 0x01106,
320 CEPH_MDS_OP_SETLAYOUT = 0x01107,
321 CEPH_MDS_OP_SETATTR = 0x01108,
322 CEPH_MDS_OP_SETFILELOCK= 0x01109,
323 CEPH_MDS_OP_GETFILELOCK= 0x00110,
324 CEPH_MDS_OP_SETDIRLAYOUT=0x0110a,
325
326 CEPH_MDS_OP_MKNOD = 0x01201,
327 CEPH_MDS_OP_LINK = 0x01202,
328 CEPH_MDS_OP_UNLINK = 0x01203,
329 CEPH_MDS_OP_RENAME = 0x01204,
330 CEPH_MDS_OP_MKDIR = 0x01220,
331 CEPH_MDS_OP_RMDIR = 0x01221,
332 CEPH_MDS_OP_SYMLINK = 0x01222,
333
334 CEPH_MDS_OP_CREATE = 0x01301,
335 CEPH_MDS_OP_OPEN = 0x00302,
336 CEPH_MDS_OP_READDIR = 0x00305,
337
338 CEPH_MDS_OP_LOOKUPSNAP = 0x00400,
339 CEPH_MDS_OP_MKSNAP = 0x01400,
340 CEPH_MDS_OP_RMSNAP = 0x01401,
341 CEPH_MDS_OP_LSSNAP = 0x00402,
342};
343
344extern const char *ceph_mds_op_name(int op);
345
346
347#define CEPH_SETATTR_MODE 1
348#define CEPH_SETATTR_UID 2
349#define CEPH_SETATTR_GID 4
350#define CEPH_SETATTR_MTIME 8
351#define CEPH_SETATTR_ATIME 16
352#define CEPH_SETATTR_SIZE 32
353#define CEPH_SETATTR_CTIME 64
354
355union ceph_mds_request_args {
356 struct {
357 __le32 mask; /* CEPH_CAP_* */
358 } __attribute__ ((packed)) getattr;
359 struct {
360 __le32 mode;
361 __le32 uid;
362 __le32 gid;
363 struct ceph_timespec mtime;
364 struct ceph_timespec atime;
365 __le64 size, old_size; /* old_size needed by truncate */
366 __le32 mask; /* CEPH_SETATTR_* */
367 } __attribute__ ((packed)) setattr;
368 struct {
369 __le32 frag; /* which dir fragment */
370 __le32 max_entries; /* how many dentries to grab */
371 __le32 max_bytes;
372 } __attribute__ ((packed)) readdir;
373 struct {
374 __le32 mode;
375 __le32 rdev;
376 } __attribute__ ((packed)) mknod;
377 struct {
378 __le32 mode;
379 } __attribute__ ((packed)) mkdir;
380 struct {
381 __le32 flags;
382 __le32 mode;
383 __le32 stripe_unit; /* layout for newly created file */
384 __le32 stripe_count; /* ... */
385 __le32 object_size;
386 __le32 file_replication;
387 __le32 preferred;
388 } __attribute__ ((packed)) open;
389 struct {
390 __le32 flags;
391 } __attribute__ ((packed)) setxattr;
392 struct {
393 struct ceph_file_layout layout;
394 } __attribute__ ((packed)) setlayout;
395 struct {
396 __u8 rule; /* currently fcntl or flock */
397 __u8 type; /* shared, exclusive, remove*/
398 __le64 pid; /* process id requesting the lock */
399 __le64 pid_namespace;
400 __le64 start; /* initial location to lock */
401 __le64 length; /* num bytes to lock from start */
402 __u8 wait; /* will caller wait for lock to become available? */
403 } __attribute__ ((packed)) filelock_change;
404} __attribute__ ((packed));
405
406#define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
407#define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
408
409struct ceph_mds_request_head {
410 __le64 oldest_client_tid;
411 __le32 mdsmap_epoch; /* on client */
412 __le32 flags; /* CEPH_MDS_FLAG_* */
413 __u8 num_retry, num_fwd; /* count retry, fwd attempts */
414 __le16 num_releases; /* # include cap/lease release records */
415 __le32 op; /* mds op code */
416 __le32 caller_uid, caller_gid;
417 __le64 ino; /* use this ino for openc, mkdir, mknod,
418 etc. (if replaying) */
419 union ceph_mds_request_args args;
420} __attribute__ ((packed));
421
422/* cap/lease release record */
423struct ceph_mds_request_release {
424 __le64 ino, cap_id; /* ino and unique cap id */
425 __le32 caps, wanted; /* new issued, wanted */
426 __le32 seq, issue_seq, mseq;
427 __le32 dname_seq; /* if releasing a dentry lease, a */
428 __le32 dname_len; /* string follows. */
429} __attribute__ ((packed));
430
431/* client reply */
432struct ceph_mds_reply_head {
433 __le32 op;
434 __le32 result;
435 __le32 mdsmap_epoch;
436 __u8 safe; /* true if committed to disk */
437 __u8 is_dentry, is_target; /* true if dentry, target inode records
438 are included with reply */
439} __attribute__ ((packed));
440
441/* one for each node split */
442struct ceph_frag_tree_split {
443 __le32 frag; /* this frag splits... */
444 __le32 by; /* ...by this many bits */
445} __attribute__ ((packed));
446
447struct ceph_frag_tree_head {
448 __le32 nsplits; /* num ceph_frag_tree_split records */
449 struct ceph_frag_tree_split splits[];
450} __attribute__ ((packed));
451
452/* capability issue, for bundling with mds reply */
453struct ceph_mds_reply_cap {
454 __le32 caps, wanted; /* caps issued, wanted */
455 __le64 cap_id;
456 __le32 seq, mseq;
457 __le64 realm; /* snap realm */
458 __u8 flags; /* CEPH_CAP_FLAG_* */
459} __attribute__ ((packed));
460
461#define CEPH_CAP_FLAG_AUTH 1 /* cap is issued by auth mds */
462
463/* inode record, for bundling with mds reply */
464struct ceph_mds_reply_inode {
465 __le64 ino;
466 __le64 snapid;
467 __le32 rdev;
468 __le64 version; /* inode version */
469 __le64 xattr_version; /* version for xattr blob */
470 struct ceph_mds_reply_cap cap; /* caps issued for this inode */
471 struct ceph_file_layout layout;
472 struct ceph_timespec ctime, mtime, atime;
473 __le32 time_warp_seq;
474 __le64 size, max_size, truncate_size;
475 __le32 truncate_seq;
476 __le32 mode, uid, gid;
477 __le32 nlink;
478 __le64 files, subdirs, rbytes, rfiles, rsubdirs; /* dir stats */
479 struct ceph_timespec rctime;
480 struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */
481} __attribute__ ((packed));
482/* followed by frag array, symlink string, dir layout, xattr blob */
483
484/* reply_lease follows dname, and reply_inode */
485struct ceph_mds_reply_lease {
486 __le16 mask; /* lease type(s) */
487 __le32 duration_ms; /* lease duration */
488 __le32 seq;
489} __attribute__ ((packed));
490
491struct ceph_mds_reply_dirfrag {
492 __le32 frag; /* fragment */
493 __le32 auth; /* auth mds, if this is a delegation point */
494 __le32 ndist; /* number of mds' this is replicated on */
495 __le32 dist[];
496} __attribute__ ((packed));
497
498#define CEPH_LOCK_FCNTL 1
499#define CEPH_LOCK_FLOCK 2
500
501#define CEPH_LOCK_SHARED 1
502#define CEPH_LOCK_EXCL 2
503#define CEPH_LOCK_UNLOCK 4
504
505struct ceph_filelock {
506 __le64 start;/* file offset to start lock at */
507 __le64 length; /* num bytes to lock; 0 for all following start */
508 __le64 client; /* which client holds the lock */
509 __le64 pid; /* process id holding the lock on the client */
510 __le64 pid_namespace;
511 __u8 type; /* shared lock, exclusive lock, or unlock */
512} __attribute__ ((packed));
513
514
515/* file access modes */
516#define CEPH_FILE_MODE_PIN 0
517#define CEPH_FILE_MODE_RD 1
518#define CEPH_FILE_MODE_WR 2
519#define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
520#define CEPH_FILE_MODE_LAZY 4 /* lazy io */
521#define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */
522
523int ceph_flags_to_mode(int flags);
524
525
526/* capability bits */
527#define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
528
529/* generic cap bits */
530#define CEPH_CAP_GSHARED 1 /* client can reads */
531#define CEPH_CAP_GEXCL 2 /* client can read and update */
532#define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
533#define CEPH_CAP_GRD 8 /* (file) client can read */
534#define CEPH_CAP_GWR 16 /* (file) client can write */
535#define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
536#define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
537#define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
538
539/* per-lock shift */
540#define CEPH_CAP_SAUTH 2
541#define CEPH_CAP_SLINK 4
542#define CEPH_CAP_SXATTR 6
543#define CEPH_CAP_SFILE 8
544#define CEPH_CAP_SFLOCK 20
545
546#define CEPH_CAP_BITS 22
547
548/* composed values */
549#define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
550#define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
551#define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
552#define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
553#define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
554#define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
555#define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE)
556#define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
557#define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
558#define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
559#define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
560#define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
561#define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
562#define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
563#define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
564#define CEPH_CAP_FLOCK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFLOCK)
565#define CEPH_CAP_FLOCK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFLOCK)
566
567
568/* cap masks (for getattr) */
569#define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
570#define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
571#define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
572#define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
573#define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
574#define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
575#define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
576#define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
577#define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
578#define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
579#define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
580#define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
581#define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
582 CEPH_CAP_AUTH_SHARED | \
583 CEPH_CAP_LINK_SHARED | \
584 CEPH_CAP_FILE_SHARED | \
585 CEPH_CAP_XATTR_SHARED)
586
587#define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
588 CEPH_CAP_LINK_SHARED | \
589 CEPH_CAP_XATTR_SHARED | \
590 CEPH_CAP_FILE_SHARED)
591#define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
592 CEPH_CAP_FILE_CACHE)
593
594#define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
595 CEPH_CAP_LINK_EXCL | \
596 CEPH_CAP_XATTR_EXCL | \
597 CEPH_CAP_FILE_EXCL)
598#define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
599 CEPH_CAP_FILE_EXCL)
600#define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
601#define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
602 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
603 CEPH_CAP_PIN)
604
605#define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
606 CEPH_LOCK_IXATTR)
607
608int ceph_caps_for_mode(int mode);
609
610enum {
611 CEPH_CAP_OP_GRANT, /* mds->client grant */
612 CEPH_CAP_OP_REVOKE, /* mds->client revoke */
613 CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */
614 CEPH_CAP_OP_EXPORT, /* mds has exported the cap */
615 CEPH_CAP_OP_IMPORT, /* mds has imported the cap */
616 CEPH_CAP_OP_UPDATE, /* client->mds update */
617 CEPH_CAP_OP_DROP, /* client->mds drop cap bits */
618 CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */
619 CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */
620 CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */
621 CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */
622 CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */
623 CEPH_CAP_OP_RENEW, /* client->mds renewal request */
624};
625
626extern const char *ceph_cap_op_name(int op);
627
628/*
629 * caps message, used for capability callbacks, acks, requests, etc.
630 */
631struct ceph_mds_caps {
632 __le32 op; /* CEPH_CAP_OP_* */
633 __le64 ino, realm;
634 __le64 cap_id;
635 __le32 seq, issue_seq;
636 __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */
637 __le32 migrate_seq;
638 __le64 snap_follows;
639 __le32 snap_trace_len;
640
641 /* authlock */
642 __le32 uid, gid, mode;
643
644 /* linklock */
645 __le32 nlink;
646
647 /* xattrlock */
648 __le32 xattr_len;
649 __le64 xattr_version;
650
651 /* filelock */
652 __le64 size, max_size, truncate_size;
653 __le32 truncate_seq;
654 struct ceph_timespec mtime, atime, ctime;
655 struct ceph_file_layout layout;
656 __le32 time_warp_seq;
657} __attribute__ ((packed));
658
659/* cap release msg head */
660struct ceph_mds_cap_release {
661 __le32 num; /* number of cap_items that follow */
662} __attribute__ ((packed));
663
664struct ceph_mds_cap_item {
665 __le64 ino;
666 __le64 cap_id;
667 __le32 migrate_seq, seq;
668} __attribute__ ((packed));
669
670#define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
671#define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
672#define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
673#define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
674
675extern const char *ceph_lease_op_name(int o);
676
677/* lease msg header */
678struct ceph_mds_lease {
679 __u8 action; /* CEPH_MDS_LEASE_* */
680 __le16 mask; /* which lease */
681 __le64 ino;
682 __le64 first, last; /* snap range */
683 __le32 seq;
684 __le32 duration_ms; /* duration of renewal */
685} __attribute__ ((packed));
686/* followed by a __le32+string for dname */
687
688/* client reconnect */
689struct ceph_mds_cap_reconnect {
690 __le64 cap_id;
691 __le32 wanted;
692 __le32 issued;
693 __le64 snaprealm;
694 __le64 pathbase; /* base ino for our path to this ino */
695 __le32 flock_len; /* size of flock state blob, if any */
696} __attribute__ ((packed));
697/* followed by flock blob */
698
699struct ceph_mds_cap_reconnect_v1 {
700 __le64 cap_id;
701 __le32 wanted;
702 __le32 issued;
703 __le64 size;
704 struct ceph_timespec mtime, atime;
705 __le64 snaprealm;
706 __le64 pathbase; /* base ino for our path to this ino */
707} __attribute__ ((packed));
708
709struct ceph_mds_snaprealm_reconnect {
710 __le64 ino; /* snap realm base */
711 __le64 seq; /* snap seq for this snap realm */
712 __le64 parent; /* parent realm */
713} __attribute__ ((packed));
714
715/*
716 * snaps
717 */
718enum {
719 CEPH_SNAP_OP_UPDATE, /* CREATE or DESTROY */
720 CEPH_SNAP_OP_CREATE,
721 CEPH_SNAP_OP_DESTROY,
722 CEPH_SNAP_OP_SPLIT,
723};
724
725extern const char *ceph_snap_op_name(int o);
726
727/* snap msg header */
728struct ceph_mds_snap_head {
729 __le32 op; /* CEPH_SNAP_OP_* */
730 __le64 split; /* ino to split off, if any */
731 __le32 num_split_inos; /* # inos belonging to new child realm */
732 __le32 num_split_realms; /* # child realms udner new child realm */
733 __le32 trace_len; /* size of snap trace blob */
734} __attribute__ ((packed));
735/* followed by split ino list, then split realms, then the trace blob */
736
737/*
738 * encode info about a snaprealm, as viewed by a client
739 */
740struct ceph_mds_snap_realm {
741 __le64 ino; /* ino */
742 __le64 created; /* snap: when created */
743 __le64 parent; /* ino: parent realm */
744 __le64 parent_since; /* snap: same parent since */
745 __le64 seq; /* snap: version */
746 __le32 num_snaps;
747 __le32 num_prior_parent_snaps;
748} __attribute__ ((packed));
749/* followed by my snap list, then prior parent snap list */
750
751#endif
diff --git a/include/linux/ceph/ceph_hash.h b/include/linux/ceph/ceph_hash.h
new file mode 100644
index 000000000000..d099c3f90236
--- /dev/null
+++ b/include/linux/ceph/ceph_hash.h
@@ -0,0 +1,13 @@
1#ifndef FS_CEPH_HASH_H
2#define FS_CEPH_HASH_H
3
4#define CEPH_STR_HASH_LINUX 0x1 /* linux dcache hash */
5#define CEPH_STR_HASH_RJENKINS 0x2 /* robert jenkins' */
6
7extern unsigned ceph_str_hash_linux(const char *s, unsigned len);
8extern unsigned ceph_str_hash_rjenkins(const char *s, unsigned len);
9
10extern unsigned ceph_str_hash(int type, const char *s, unsigned len);
11extern const char *ceph_str_hash_name(int type);
12
13#endif
diff --git a/include/linux/ceph/debugfs.h b/include/linux/ceph/debugfs.h
new file mode 100644
index 000000000000..2a79702e092b
--- /dev/null
+++ b/include/linux/ceph/debugfs.h
@@ -0,0 +1,33 @@
1#ifndef _FS_CEPH_DEBUGFS_H
2#define _FS_CEPH_DEBUGFS_H
3
4#include "ceph_debug.h"
5#include "types.h"
6
7#define CEPH_DEFINE_SHOW_FUNC(name) \
8static int name##_open(struct inode *inode, struct file *file) \
9{ \
10 struct seq_file *sf; \
11 int ret; \
12 \
13 ret = single_open(file, name, NULL); \
14 sf = file->private_data; \
15 sf->private = inode->i_private; \
16 return ret; \
17} \
18 \
19static const struct file_operations name##_fops = { \
20 .open = name##_open, \
21 .read = seq_read, \
22 .llseek = seq_lseek, \
23 .release = single_release, \
24};
25
26/* debugfs.c */
27extern int ceph_debugfs_init(void);
28extern void ceph_debugfs_cleanup(void);
29extern int ceph_debugfs_client_init(struct ceph_client *client);
30extern void ceph_debugfs_client_cleanup(struct ceph_client *client);
31
32#endif
33
diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h
new file mode 100644
index 000000000000..c5b6939fb32a
--- /dev/null
+++ b/include/linux/ceph/decode.h
@@ -0,0 +1,201 @@
1#ifndef __CEPH_DECODE_H
2#define __CEPH_DECODE_H
3
4#include <asm/unaligned.h>
5#include <linux/time.h>
6
7#include "types.h"
8
9/*
10 * in all cases,
11 * void **p pointer to position pointer
12 * void *end pointer to end of buffer (last byte + 1)
13 */
14
15static inline u64 ceph_decode_64(void **p)
16{
17 u64 v = get_unaligned_le64(*p);
18 *p += sizeof(u64);
19 return v;
20}
21static inline u32 ceph_decode_32(void **p)
22{
23 u32 v = get_unaligned_le32(*p);
24 *p += sizeof(u32);
25 return v;
26}
27static inline u16 ceph_decode_16(void **p)
28{
29 u16 v = get_unaligned_le16(*p);
30 *p += sizeof(u16);
31 return v;
32}
33static inline u8 ceph_decode_8(void **p)
34{
35 u8 v = *(u8 *)*p;
36 (*p)++;
37 return v;
38}
39static inline void ceph_decode_copy(void **p, void *pv, size_t n)
40{
41 memcpy(pv, *p, n);
42 *p += n;
43}
44
45/*
46 * bounds check input.
47 */
48#define ceph_decode_need(p, end, n, bad) \
49 do { \
50 if (unlikely(*(p) + (n) > (end))) \
51 goto bad; \
52 } while (0)
53
54#define ceph_decode_64_safe(p, end, v, bad) \
55 do { \
56 ceph_decode_need(p, end, sizeof(u64), bad); \
57 v = ceph_decode_64(p); \
58 } while (0)
59#define ceph_decode_32_safe(p, end, v, bad) \
60 do { \
61 ceph_decode_need(p, end, sizeof(u32), bad); \
62 v = ceph_decode_32(p); \
63 } while (0)
64#define ceph_decode_16_safe(p, end, v, bad) \
65 do { \
66 ceph_decode_need(p, end, sizeof(u16), bad); \
67 v = ceph_decode_16(p); \
68 } while (0)
69#define ceph_decode_8_safe(p, end, v, bad) \
70 do { \
71 ceph_decode_need(p, end, sizeof(u8), bad); \
72 v = ceph_decode_8(p); \
73 } while (0)
74
75#define ceph_decode_copy_safe(p, end, pv, n, bad) \
76 do { \
77 ceph_decode_need(p, end, n, bad); \
78 ceph_decode_copy(p, pv, n); \
79 } while (0)
80
81/*
82 * struct ceph_timespec <-> struct timespec
83 */
84static inline void ceph_decode_timespec(struct timespec *ts,
85 const struct ceph_timespec *tv)
86{
87 ts->tv_sec = le32_to_cpu(tv->tv_sec);
88 ts->tv_nsec = le32_to_cpu(tv->tv_nsec);
89}
90static inline void ceph_encode_timespec(struct ceph_timespec *tv,
91 const struct timespec *ts)
92{
93 tv->tv_sec = cpu_to_le32(ts->tv_sec);
94 tv->tv_nsec = cpu_to_le32(ts->tv_nsec);
95}
96
97/*
98 * sockaddr_storage <-> ceph_sockaddr
99 */
100static inline void ceph_encode_addr(struct ceph_entity_addr *a)
101{
102 __be16 ss_family = htons(a->in_addr.ss_family);
103 a->in_addr.ss_family = *(__u16 *)&ss_family;
104}
105static inline void ceph_decode_addr(struct ceph_entity_addr *a)
106{
107 __be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
108 a->in_addr.ss_family = ntohs(ss_family);
109 WARN_ON(a->in_addr.ss_family == 512);
110}
111
112/*
113 * encoders
114 */
115static inline void ceph_encode_64(void **p, u64 v)
116{
117 put_unaligned_le64(v, (__le64 *)*p);
118 *p += sizeof(u64);
119}
120static inline void ceph_encode_32(void **p, u32 v)
121{
122 put_unaligned_le32(v, (__le32 *)*p);
123 *p += sizeof(u32);
124}
125static inline void ceph_encode_16(void **p, u16 v)
126{
127 put_unaligned_le16(v, (__le16 *)*p);
128 *p += sizeof(u16);
129}
130static inline void ceph_encode_8(void **p, u8 v)
131{
132 *(u8 *)*p = v;
133 (*p)++;
134}
135static inline void ceph_encode_copy(void **p, const void *s, int len)
136{
137 memcpy(*p, s, len);
138 *p += len;
139}
140
141/*
142 * filepath, string encoders
143 */
144static inline void ceph_encode_filepath(void **p, void *end,
145 u64 ino, const char *path)
146{
147 u32 len = path ? strlen(path) : 0;
148 BUG_ON(*p + sizeof(ino) + sizeof(len) + len > end);
149 ceph_encode_8(p, 1);
150 ceph_encode_64(p, ino);
151 ceph_encode_32(p, len);
152 if (len)
153 memcpy(*p, path, len);
154 *p += len;
155}
156
157static inline void ceph_encode_string(void **p, void *end,
158 const char *s, u32 len)
159{
160 BUG_ON(*p + sizeof(len) + len > end);
161 ceph_encode_32(p, len);
162 if (len)
163 memcpy(*p, s, len);
164 *p += len;
165}
166
167#define ceph_encode_need(p, end, n, bad) \
168 do { \
169 if (unlikely(*(p) + (n) > (end))) \
170 goto bad; \
171 } while (0)
172
173#define ceph_encode_64_safe(p, end, v, bad) \
174 do { \
175 ceph_encode_need(p, end, sizeof(u64), bad); \
176 ceph_encode_64(p, v); \
177 } while (0)
178#define ceph_encode_32_safe(p, end, v, bad) \
179 do { \
180 ceph_encode_need(p, end, sizeof(u32), bad); \
181 ceph_encode_32(p, v); \
182 } while (0)
183#define ceph_encode_16_safe(p, end, v, bad) \
184 do { \
185 ceph_encode_need(p, end, sizeof(u16), bad); \
186 ceph_encode_16(p, v); \
187 } while (0)
188
189#define ceph_encode_copy_safe(p, end, pv, n, bad) \
190 do { \
191 ceph_encode_need(p, end, n, bad); \
192 ceph_encode_copy(p, pv, n); \
193 } while (0)
194#define ceph_encode_string_safe(p, end, s, n, bad) \
195 do { \
196 ceph_encode_need(p, end, n, bad); \
197 ceph_encode_string(p, end, s, n); \
198 } while (0)
199
200
201#endif
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
new file mode 100644
index 000000000000..6365f041745b
--- /dev/null
+++ b/include/linux/ceph/libceph.h
@@ -0,0 +1,249 @@
1#ifndef _FS_CEPH_LIBCEPH_H
2#define _FS_CEPH_LIBCEPH_H
3
4#include "ceph_debug.h"
5
6#include <asm/unaligned.h>
7#include <linux/backing-dev.h>
8#include <linux/completion.h>
9#include <linux/exportfs.h>
10#include <linux/fs.h>
11#include <linux/mempool.h>
12#include <linux/pagemap.h>
13#include <linux/wait.h>
14#include <linux/writeback.h>
15#include <linux/slab.h>
16
17#include "types.h"
18#include "messenger.h"
19#include "msgpool.h"
20#include "mon_client.h"
21#include "osd_client.h"
22#include "ceph_fs.h"
23
24/*
25 * Supported features
26 */
27#define CEPH_FEATURE_SUPPORTED_DEFAULT CEPH_FEATURE_NOSRCADDR
28#define CEPH_FEATURE_REQUIRED_DEFAULT CEPH_FEATURE_NOSRCADDR
29
30/*
31 * mount options
32 */
33#define CEPH_OPT_FSID (1<<0)
34#define CEPH_OPT_NOSHARE (1<<1) /* don't share client with other sbs */
35#define CEPH_OPT_MYIP (1<<2) /* specified my ip */
36#define CEPH_OPT_NOCRC (1<<3) /* no data crc on writes */
37
38#define CEPH_OPT_DEFAULT (0);
39
40#define ceph_set_opt(client, opt) \
41 (client)->options->flags |= CEPH_OPT_##opt;
42#define ceph_test_opt(client, opt) \
43 (!!((client)->options->flags & CEPH_OPT_##opt))
44
45struct ceph_options {
46 int flags;
47 struct ceph_fsid fsid;
48 struct ceph_entity_addr my_addr;
49 int mount_timeout;
50 int osd_idle_ttl;
51 int osd_timeout;
52 int osd_keepalive_timeout;
53
54 /*
55 * any type that can't be simply compared or doesn't need need
56 * to be compared should go beyond this point,
57 * ceph_compare_options() should be updated accordingly
58 */
59
60 struct ceph_entity_addr *mon_addr; /* should be the first
61 pointer type of args */
62 int num_mon;
63 char *name;
64 struct ceph_crypto_key *key;
65};
66
67/*
68 * defaults
69 */
70#define CEPH_MOUNT_TIMEOUT_DEFAULT 60
71#define CEPH_OSD_TIMEOUT_DEFAULT 60 /* seconds */
72#define CEPH_OSD_KEEPALIVE_DEFAULT 5
73#define CEPH_OSD_IDLE_TTL_DEFAULT 60
74
75#define CEPH_MSG_MAX_FRONT_LEN (16*1024*1024)
76#define CEPH_MSG_MAX_DATA_LEN (16*1024*1024)
77
78#define CEPH_AUTH_NAME_DEFAULT "guest"
79
80/*
81 * Delay telling the MDS we no longer want caps, in case we reopen
82 * the file. Delay a minimum amount of time, even if we send a cap
83 * message for some other reason. Otherwise, take the oppotunity to
84 * update the mds to avoid sending another message later.
85 */
86#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT 5 /* cap release delay */
87#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT 60 /* cap release delay */
88
89#define CEPH_CAP_RELEASE_SAFETY_DEFAULT (CEPH_CAPS_PER_RELEASE * 4)
90
91/* mount state */
92enum {
93 CEPH_MOUNT_MOUNTING,
94 CEPH_MOUNT_MOUNTED,
95 CEPH_MOUNT_UNMOUNTING,
96 CEPH_MOUNT_UNMOUNTED,
97 CEPH_MOUNT_SHUTDOWN,
98};
99
100/*
101 * subtract jiffies
102 */
103static inline unsigned long time_sub(unsigned long a, unsigned long b)
104{
105 BUG_ON(time_after(b, a));
106 return (long)a - (long)b;
107}
108
109struct ceph_mds_client;
110
111/*
112 * per client state
113 *
114 * possibly shared by multiple mount points, if they are
115 * mounting the same ceph filesystem/cluster.
116 */
117struct ceph_client {
118 struct ceph_fsid fsid;
119 bool have_fsid;
120
121 void *private;
122
123 struct ceph_options *options;
124
125 struct mutex mount_mutex; /* serialize mount attempts */
126 wait_queue_head_t auth_wq;
127 int auth_err;
128
129 int (*extra_mon_dispatch)(struct ceph_client *, struct ceph_msg *);
130
131 u32 supported_features;
132 u32 required_features;
133
134 struct ceph_messenger *msgr; /* messenger instance */
135 struct ceph_mon_client monc;
136 struct ceph_osd_client osdc;
137
138#ifdef CONFIG_DEBUG_FS
139 struct dentry *debugfs_dir;
140 struct dentry *debugfs_monmap;
141 struct dentry *debugfs_osdmap;
142#endif
143};
144
145
146
147/*
148 * snapshots
149 */
150
151/*
152 * A "snap context" is the set of existing snapshots when we
153 * write data. It is used by the OSD to guide its COW behavior.
154 *
155 * The ceph_snap_context is refcounted, and attached to each dirty
156 * page, indicating which context the dirty data belonged when it was
157 * dirtied.
158 */
159struct ceph_snap_context {
160 atomic_t nref;
161 u64 seq;
162 int num_snaps;
163 u64 snaps[];
164};
165
166static inline struct ceph_snap_context *
167ceph_get_snap_context(struct ceph_snap_context *sc)
168{
169 /*
170 printk("get_snap_context %p %d -> %d\n", sc, atomic_read(&sc->nref),
171 atomic_read(&sc->nref)+1);
172 */
173 if (sc)
174 atomic_inc(&sc->nref);
175 return sc;
176}
177
178static inline void ceph_put_snap_context(struct ceph_snap_context *sc)
179{
180 if (!sc)
181 return;
182 /*
183 printk("put_snap_context %p %d -> %d\n", sc, atomic_read(&sc->nref),
184 atomic_read(&sc->nref)-1);
185 */
186 if (atomic_dec_and_test(&sc->nref)) {
187 /*printk(" deleting snap_context %p\n", sc);*/
188 kfree(sc);
189 }
190}
191
192/*
193 * calculate the number of pages a given length and offset map onto,
194 * if we align the data.
195 */
196static inline int calc_pages_for(u64 off, u64 len)
197{
198 return ((off+len+PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT) -
199 (off >> PAGE_CACHE_SHIFT);
200}
201
202/* ceph_common.c */
203extern const char *ceph_msg_type_name(int type);
204extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid);
205extern struct kmem_cache *ceph_inode_cachep;
206extern struct kmem_cache *ceph_cap_cachep;
207extern struct kmem_cache *ceph_dentry_cachep;
208extern struct kmem_cache *ceph_file_cachep;
209
210extern int ceph_parse_options(struct ceph_options **popt, char *options,
211 const char *dev_name, const char *dev_name_end,
212 int (*parse_extra_token)(char *c, void *private),
213 void *private);
214extern void ceph_destroy_options(struct ceph_options *opt);
215extern int ceph_compare_options(struct ceph_options *new_opt,
216 struct ceph_client *client);
217extern struct ceph_client *ceph_create_client(struct ceph_options *opt,
218 void *private);
219extern u64 ceph_client_id(struct ceph_client *client);
220extern void ceph_destroy_client(struct ceph_client *client);
221extern int __ceph_open_session(struct ceph_client *client,
222 unsigned long started);
223extern int ceph_open_session(struct ceph_client *client);
224
225/* pagevec.c */
226extern void ceph_release_page_vector(struct page **pages, int num_pages);
227
228extern struct page **ceph_get_direct_page_vector(const char __user *data,
229 int num_pages,
230 bool write_page);
231extern void ceph_put_page_vector(struct page **pages, int num_pages,
232 bool dirty);
233extern void ceph_release_page_vector(struct page **pages, int num_pages);
234extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags);
235extern int ceph_copy_user_to_page_vector(struct page **pages,
236 const char __user *data,
237 loff_t off, size_t len);
238extern int ceph_copy_to_page_vector(struct page **pages,
239 const char *data,
240 loff_t off, size_t len);
241extern int ceph_copy_from_page_vector(struct page **pages,
242 char *data,
243 loff_t off, size_t len);
244extern int ceph_copy_page_vector_to_user(struct page **pages, char __user *data,
245 loff_t off, size_t len);
246extern void ceph_zero_page_vector_range(int off, int len, struct page **pages);
247
248
249#endif /* _FS_CEPH_SUPER_H */
diff --git a/include/linux/ceph/mdsmap.h b/include/linux/ceph/mdsmap.h
new file mode 100644
index 000000000000..4c5cb0880bba
--- /dev/null
+++ b/include/linux/ceph/mdsmap.h
@@ -0,0 +1,62 @@
1#ifndef _FS_CEPH_MDSMAP_H
2#define _FS_CEPH_MDSMAP_H
3
4#include "types.h"
5
6/*
7 * mds map - describe servers in the mds cluster.
8 *
9 * we limit fields to those the client actually xcares about
10 */
11struct ceph_mds_info {
12 u64 global_id;
13 struct ceph_entity_addr addr;
14 s32 state;
15 int num_export_targets;
16 bool laggy;
17 u32 *export_targets;
18};
19
20struct ceph_mdsmap {
21 u32 m_epoch, m_client_epoch, m_last_failure;
22 u32 m_root;
23 u32 m_session_timeout; /* seconds */
24 u32 m_session_autoclose; /* seconds */
25 u64 m_max_file_size;
26 u32 m_max_mds; /* size of m_addr, m_state arrays */
27 struct ceph_mds_info *m_info;
28
29 /* which object pools file data can be stored in */
30 int m_num_data_pg_pools;
31 u32 *m_data_pg_pools;
32 u32 m_cas_pg_pool;
33};
34
35static inline struct ceph_entity_addr *
36ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
37{
38 if (w >= m->m_max_mds)
39 return NULL;
40 return &m->m_info[w].addr;
41}
42
43static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
44{
45 BUG_ON(w < 0);
46 if (w >= m->m_max_mds)
47 return CEPH_MDS_STATE_DNE;
48 return m->m_info[w].state;
49}
50
51static inline bool ceph_mdsmap_is_laggy(struct ceph_mdsmap *m, int w)
52{
53 if (w >= 0 && w < m->m_max_mds)
54 return m->m_info[w].laggy;
55 return false;
56}
57
58extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
59extern struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end);
60extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
61
62#endif
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
new file mode 100644
index 000000000000..31d91a64838b
--- /dev/null
+++ b/include/linux/ceph/messenger.h
@@ -0,0 +1,257 @@
1#ifndef __FS_CEPH_MESSENGER_H
2#define __FS_CEPH_MESSENGER_H
3
4#include <linux/kref.h>
5#include <linux/mutex.h>
6#include <linux/net.h>
7#include <linux/radix-tree.h>
8#include <linux/uio.h>
9#include <linux/version.h>
10#include <linux/workqueue.h>
11
12#include "types.h"
13#include "buffer.h"
14
15struct ceph_msg;
16struct ceph_connection;
17
18extern struct workqueue_struct *ceph_msgr_wq; /* receive work queue */
19
20/*
21 * Ceph defines these callbacks for handling connection events.
22 */
23struct ceph_connection_operations {
24 struct ceph_connection *(*get)(struct ceph_connection *);
25 void (*put)(struct ceph_connection *);
26
27 /* handle an incoming message. */
28 void (*dispatch) (struct ceph_connection *con, struct ceph_msg *m);
29
30 /* authorize an outgoing connection */
31 int (*get_authorizer) (struct ceph_connection *con,
32 void **buf, int *len, int *proto,
33 void **reply_buf, int *reply_len, int force_new);
34 int (*verify_authorizer_reply) (struct ceph_connection *con, int len);
35 int (*invalidate_authorizer)(struct ceph_connection *con);
36
37 /* protocol version mismatch */
38 void (*bad_proto) (struct ceph_connection *con);
39
40 /* there was some error on the socket (disconnect, whatever) */
41 void (*fault) (struct ceph_connection *con);
42
43 /* a remote host as terminated a message exchange session, and messages
44 * we sent (or they tried to send us) may be lost. */
45 void (*peer_reset) (struct ceph_connection *con);
46
47 struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,
48 struct ceph_msg_header *hdr,
49 int *skip);
50};
51
52/* use format string %s%d */
53#define ENTITY_NAME(n) ceph_entity_type_name((n).type), le64_to_cpu((n).num)
54
55struct ceph_messenger {
56 struct ceph_entity_inst inst; /* my name+address */
57 struct ceph_entity_addr my_enc_addr;
58 struct page *zero_page; /* used in certain error cases */
59
60 bool nocrc;
61
62 /*
63 * the global_seq counts connections i (attempt to) initiate
64 * in order to disambiguate certain connect race conditions.
65 */
66 u32 global_seq;
67 spinlock_t global_seq_lock;
68
69 u32 supported_features;
70 u32 required_features;
71};
72
73/*
74 * a single message. it contains a header (src, dest, message type, etc.),
75 * footer (crc values, mainly), a "front" message body, and possibly a
76 * data payload (stored in some number of pages).
77 */
78struct ceph_msg {
79 struct ceph_msg_header hdr; /* header */
80 struct ceph_msg_footer footer; /* footer */
81 struct kvec front; /* unaligned blobs of message */
82 struct ceph_buffer *middle;
83 struct page **pages; /* data payload. NOT OWNER. */
84 unsigned nr_pages; /* size of page array */
85 unsigned page_alignment; /* io offset in first page */
86 struct ceph_pagelist *pagelist; /* instead of pages */
87 struct list_head list_head;
88 struct kref kref;
89 struct bio *bio; /* instead of pages/pagelist */
90 struct bio *bio_iter; /* bio iterator */
91 int bio_seg; /* current bio segment */
92 struct ceph_pagelist *trail; /* the trailing part of the data */
93 bool front_is_vmalloc;
94 bool more_to_follow;
95 bool needs_out_seq;
96 int front_max;
97
98 struct ceph_msgpool *pool;
99};
100
101struct ceph_msg_pos {
102 int page, page_pos; /* which page; offset in page */
103 int data_pos; /* offset in data payload */
104 int did_page_crc; /* true if we've calculated crc for current page */
105};
106
107/* ceph connection fault delay defaults, for exponential backoff */
108#define BASE_DELAY_INTERVAL (HZ/2)
109#define MAX_DELAY_INTERVAL (5 * 60 * HZ)
110
111/*
112 * ceph_connection state bit flags
113 */
114#define LOSSYTX 0 /* we can close channel or drop messages on errors */
115#define CONNECTING 1
116#define NEGOTIATING 2
117#define KEEPALIVE_PENDING 3
118#define WRITE_PENDING 4 /* we have data ready to send */
119#define STANDBY 8 /* no outgoing messages, socket closed. we keep
120 * the ceph_connection around to maintain shared
121 * state with the peer. */
122#define CLOSED 10 /* we've closed the connection */
123#define SOCK_CLOSED 11 /* socket state changed to closed */
124#define OPENING 13 /* open connection w/ (possibly new) peer */
125#define DEAD 14 /* dead, about to kfree */
126#define BACKOFF 15
127
128/*
129 * A single connection with another host.
130 *
131 * We maintain a queue of outgoing messages, and some session state to
132 * ensure that we can preserve the lossless, ordered delivery of
133 * messages in the case of a TCP disconnect.
134 */
135struct ceph_connection {
136 void *private;
137 atomic_t nref;
138
139 const struct ceph_connection_operations *ops;
140
141 struct ceph_messenger *msgr;
142 struct socket *sock;
143 unsigned long state; /* connection state (see flags above) */
144 const char *error_msg; /* error message, if any */
145
146 struct ceph_entity_addr peer_addr; /* peer address */
147 struct ceph_entity_name peer_name; /* peer name */
148 struct ceph_entity_addr peer_addr_for_me;
149 unsigned peer_features;
150 u32 connect_seq; /* identify the most recent connection
151 attempt for this connection, client */
152 u32 peer_global_seq; /* peer's global seq for this connection */
153
154 int auth_retry; /* true if we need a newer authorizer */
155 void *auth_reply_buf; /* where to put the authorizer reply */
156 int auth_reply_buf_len;
157
158 struct mutex mutex;
159
160 /* out queue */
161 struct list_head out_queue;
162 struct list_head out_sent; /* sending or sent but unacked */
163 u64 out_seq; /* last message queued for send */
164
165 u64 in_seq, in_seq_acked; /* last message received, acked */
166
167 /* connection negotiation temps */
168 char in_banner[CEPH_BANNER_MAX_LEN];
169 union {
170 struct { /* outgoing connection */
171 struct ceph_msg_connect out_connect;
172 struct ceph_msg_connect_reply in_reply;
173 };
174 struct { /* incoming */
175 struct ceph_msg_connect in_connect;
176 struct ceph_msg_connect_reply out_reply;
177 };
178 };
179 struct ceph_entity_addr actual_peer_addr;
180
181 /* message out temps */
182 struct ceph_msg *out_msg; /* sending message (== tail of
183 out_sent) */
184 bool out_msg_done;
185 struct ceph_msg_pos out_msg_pos;
186
187 struct kvec out_kvec[8], /* sending header/footer data */
188 *out_kvec_cur;
189 int out_kvec_left; /* kvec's left in out_kvec */
190 int out_skip; /* skip this many bytes */
191 int out_kvec_bytes; /* total bytes left */
192 bool out_kvec_is_msg; /* kvec refers to out_msg */
193 int out_more; /* there is more data after the kvecs */
194 __le64 out_temp_ack; /* for writing an ack */
195
196 /* message in temps */
197 struct ceph_msg_header in_hdr;
198 struct ceph_msg *in_msg;
199 struct ceph_msg_pos in_msg_pos;
200 u32 in_front_crc, in_middle_crc, in_data_crc; /* calculated crc */
201
202 char in_tag; /* protocol control byte */
203 int in_base_pos; /* bytes read */
204 __le64 in_temp_ack; /* for reading an ack */
205
206 struct delayed_work work; /* send|recv work */
207 unsigned long delay; /* current delay interval */
208};
209
210
211extern const char *ceph_pr_addr(const struct sockaddr_storage *ss);
212extern int ceph_parse_ips(const char *c, const char *end,
213 struct ceph_entity_addr *addr,
214 int max_count, int *count);
215
216
217extern int ceph_msgr_init(void);
218extern void ceph_msgr_exit(void);
219extern void ceph_msgr_flush(void);
220
221extern struct ceph_messenger *ceph_messenger_create(
222 struct ceph_entity_addr *myaddr,
223 u32 features, u32 required);
224extern void ceph_messenger_destroy(struct ceph_messenger *);
225
226extern void ceph_con_init(struct ceph_messenger *msgr,
227 struct ceph_connection *con);
228extern void ceph_con_open(struct ceph_connection *con,
229 struct ceph_entity_addr *addr);
230extern bool ceph_con_opened(struct ceph_connection *con);
231extern void ceph_con_close(struct ceph_connection *con);
232extern void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg);
233extern void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg);
234extern void ceph_con_revoke_message(struct ceph_connection *con,
235 struct ceph_msg *msg);
236extern void ceph_con_keepalive(struct ceph_connection *con);
237extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
238extern void ceph_con_put(struct ceph_connection *con);
239
240extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags);
241extern void ceph_msg_kfree(struct ceph_msg *m);
242
243
244static inline struct ceph_msg *ceph_msg_get(struct ceph_msg *msg)
245{
246 kref_get(&msg->kref);
247 return msg;
248}
249extern void ceph_msg_last_put(struct kref *kref);
250static inline void ceph_msg_put(struct ceph_msg *msg)
251{
252 kref_put(&msg->kref, ceph_msg_last_put);
253}
254
255extern void ceph_msg_dump(struct ceph_msg *msg);
256
257#endif
diff --git a/include/linux/ceph/mon_client.h b/include/linux/ceph/mon_client.h
new file mode 100644
index 000000000000..545f85917780
--- /dev/null
+++ b/include/linux/ceph/mon_client.h
@@ -0,0 +1,122 @@
1#ifndef _FS_CEPH_MON_CLIENT_H
2#define _FS_CEPH_MON_CLIENT_H
3
4#include <linux/completion.h>
5#include <linux/kref.h>
6#include <linux/rbtree.h>
7
8#include "messenger.h"
9
10struct ceph_client;
11struct ceph_mount_args;
12struct ceph_auth_client;
13
14/*
15 * The monitor map enumerates the set of all monitors.
16 */
17struct ceph_monmap {
18 struct ceph_fsid fsid;
19 u32 epoch;
20 u32 num_mon;
21 struct ceph_entity_inst mon_inst[0];
22};
23
24struct ceph_mon_client;
25struct ceph_mon_generic_request;
26
27
28/*
29 * Generic mechanism for resending monitor requests.
30 */
31typedef void (*ceph_monc_request_func_t)(struct ceph_mon_client *monc,
32 int newmon);
33
34/* a pending monitor request */
35struct ceph_mon_request {
36 struct ceph_mon_client *monc;
37 struct delayed_work delayed_work;
38 unsigned long delay;
39 ceph_monc_request_func_t do_request;
40};
41
42/*
43 * ceph_mon_generic_request is being used for the statfs and poolop requests
44 * which are bening done a bit differently because we need to get data back
45 * to the caller
46 */
47struct ceph_mon_generic_request {
48 struct kref kref;
49 u64 tid;
50 struct rb_node node;
51 int result;
52 void *buf;
53 int buf_len;
54 struct completion completion;
55 struct ceph_msg *request; /* original request */
56 struct ceph_msg *reply; /* and reply */
57};
58
59struct ceph_mon_client {
60 struct ceph_client *client;
61 struct ceph_monmap *monmap;
62
63 struct mutex mutex;
64 struct delayed_work delayed_work;
65
66 struct ceph_auth_client *auth;
67 struct ceph_msg *m_auth, *m_auth_reply, *m_subscribe, *m_subscribe_ack;
68 int pending_auth;
69
70 bool hunting;
71 int cur_mon; /* last monitor i contacted */
72 unsigned long sub_sent, sub_renew_after;
73 struct ceph_connection *con;
74 bool have_fsid;
75
76 /* pending generic requests */
77 struct rb_root generic_request_tree;
78 int num_generic_requests;
79 u64 last_tid;
80
81 /* mds/osd map */
82 int want_mdsmap;
83 int want_next_osdmap; /* 1 = want, 2 = want+asked */
84 u32 have_osdmap, have_mdsmap;
85
86#ifdef CONFIG_DEBUG_FS
87 struct dentry *debugfs_file;
88#endif
89};
90
91extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
92extern int ceph_monmap_contains(struct ceph_monmap *m,
93 struct ceph_entity_addr *addr);
94
95extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
96extern void ceph_monc_stop(struct ceph_mon_client *monc);
97
98/*
99 * The model here is to indicate that we need a new map of at least
100 * epoch @want, and also call in when we receive a map. We will
101 * periodically rerequest the map from the monitor cluster until we
102 * get what we want.
103 */
104extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
105extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
106
107extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
108
109extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
110 struct ceph_statfs *buf);
111
112extern int ceph_monc_open_session(struct ceph_mon_client *monc);
113
114extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
115
116extern int ceph_monc_create_snapid(struct ceph_mon_client *monc,
117 u32 pool, u64 *snapid);
118
119extern int ceph_monc_delete_snapid(struct ceph_mon_client *monc,
120 u32 pool, u64 snapid);
121
122#endif
diff --git a/include/linux/ceph/msgpool.h b/include/linux/ceph/msgpool.h
new file mode 100644
index 000000000000..a362605f9368
--- /dev/null
+++ b/include/linux/ceph/msgpool.h
@@ -0,0 +1,25 @@
1#ifndef _FS_CEPH_MSGPOOL
2#define _FS_CEPH_MSGPOOL
3
4#include <linux/mempool.h>
5#include "messenger.h"
6
7/*
8 * we use memory pools for preallocating messages we may receive, to
9 * avoid unexpected OOM conditions.
10 */
11struct ceph_msgpool {
12 const char *name;
13 mempool_t *pool;
14 int front_len; /* preallocated payload size */
15};
16
17extern int ceph_msgpool_init(struct ceph_msgpool *pool,
18 int front_len, int size, bool blocking,
19 const char *name);
20extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
21extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *,
22 int front_len);
23extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
24
25#endif
diff --git a/include/linux/ceph/msgr.h b/include/linux/ceph/msgr.h
new file mode 100644
index 000000000000..680d3d648cac
--- /dev/null
+++ b/include/linux/ceph/msgr.h
@@ -0,0 +1,175 @@
1#ifndef CEPH_MSGR_H
2#define CEPH_MSGR_H
3
4/*
5 * Data types for message passing layer used by Ceph.
6 */
7
8#define CEPH_MON_PORT 6789 /* default monitor port */
9
10/*
11 * client-side processes will try to bind to ports in this
12 * range, simply for the benefit of tools like nmap or wireshark
13 * that would like to identify the protocol.
14 */
15#define CEPH_PORT_FIRST 6789
16#define CEPH_PORT_START 6800 /* non-monitors start here */
17#define CEPH_PORT_LAST 6900
18
19/*
20 * tcp connection banner. include a protocol version. and adjust
21 * whenever the wire protocol changes. try to keep this string length
22 * constant.
23 */
24#define CEPH_BANNER "ceph v027"
25#define CEPH_BANNER_MAX_LEN 30
26
27
28/*
29 * Rollover-safe type and comparator for 32-bit sequence numbers.
30 * Comparator returns -1, 0, or 1.
31 */
32typedef __u32 ceph_seq_t;
33
34static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
35{
36 return (__s32)a - (__s32)b;
37}
38
39
40/*
41 * entity_name -- logical name for a process participating in the
42 * network, e.g. 'mds0' or 'osd3'.
43 */
44struct ceph_entity_name {
45 __u8 type; /* CEPH_ENTITY_TYPE_* */
46 __le64 num;
47} __attribute__ ((packed));
48
49#define CEPH_ENTITY_TYPE_MON 0x01
50#define CEPH_ENTITY_TYPE_MDS 0x02
51#define CEPH_ENTITY_TYPE_OSD 0x04
52#define CEPH_ENTITY_TYPE_CLIENT 0x08
53#define CEPH_ENTITY_TYPE_AUTH 0x20
54
55#define CEPH_ENTITY_TYPE_ANY 0xFF
56
57extern const char *ceph_entity_type_name(int type);
58
59/*
60 * entity_addr -- network address
61 */
62struct ceph_entity_addr {
63 __le32 type;
64 __le32 nonce; /* unique id for process (e.g. pid) */
65 struct sockaddr_storage in_addr;
66} __attribute__ ((packed));
67
68struct ceph_entity_inst {
69 struct ceph_entity_name name;
70 struct ceph_entity_addr addr;
71} __attribute__ ((packed));
72
73
74/* used by message exchange protocol */
75#define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
76#define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
77#define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
78 incoming connection */
79#define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
80 with higher cseq */
81#define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
82 with higher gseq */
83#define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
84#define CEPH_MSGR_TAG_MSG 7 /* message */
85#define CEPH_MSGR_TAG_ACK 8 /* message ack */
86#define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
87#define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
88#define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
89#define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
90
91
92/*
93 * connection negotiation
94 */
95struct ceph_msg_connect {
96 __le64 features; /* supported feature bits */
97 __le32 host_type; /* CEPH_ENTITY_TYPE_* */
98 __le32 global_seq; /* count connections initiated by this host */
99 __le32 connect_seq; /* count connections initiated in this session */
100 __le32 protocol_version;
101 __le32 authorizer_protocol;
102 __le32 authorizer_len;
103 __u8 flags; /* CEPH_MSG_CONNECT_* */
104} __attribute__ ((packed));
105
106struct ceph_msg_connect_reply {
107 __u8 tag;
108 __le64 features; /* feature bits for this session */
109 __le32 global_seq;
110 __le32 connect_seq;
111 __le32 protocol_version;
112 __le32 authorizer_len;
113 __u8 flags;
114} __attribute__ ((packed));
115
116#define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
117
118
119/*
120 * message header
121 */
122struct ceph_msg_header_old {
123 __le64 seq; /* message seq# for this session */
124 __le64 tid; /* transaction id */
125 __le16 type; /* message type */
126 __le16 priority; /* priority. higher value == higher priority */
127 __le16 version; /* version of message encoding */
128
129 __le32 front_len; /* bytes in main payload */
130 __le32 middle_len;/* bytes in middle payload */
131 __le32 data_len; /* bytes of data payload */
132 __le16 data_off; /* sender: include full offset;
133 receiver: mask against ~PAGE_MASK */
134
135 struct ceph_entity_inst src, orig_src;
136 __le32 reserved;
137 __le32 crc; /* header crc32c */
138} __attribute__ ((packed));
139
140struct ceph_msg_header {
141 __le64 seq; /* message seq# for this session */
142 __le64 tid; /* transaction id */
143 __le16 type; /* message type */
144 __le16 priority; /* priority. higher value == higher priority */
145 __le16 version; /* version of message encoding */
146
147 __le32 front_len; /* bytes in main payload */
148 __le32 middle_len;/* bytes in middle payload */
149 __le32 data_len; /* bytes of data payload */
150 __le16 data_off; /* sender: include full offset;
151 receiver: mask against ~PAGE_MASK */
152
153 struct ceph_entity_name src;
154 __le32 reserved;
155 __le32 crc; /* header crc32c */
156} __attribute__ ((packed));
157
158#define CEPH_MSG_PRIO_LOW 64
159#define CEPH_MSG_PRIO_DEFAULT 127
160#define CEPH_MSG_PRIO_HIGH 196
161#define CEPH_MSG_PRIO_HIGHEST 255
162
163/*
164 * follows data payload
165 */
166struct ceph_msg_footer {
167 __le32 front_crc, middle_crc, data_crc;
168 __u8 flags;
169} __attribute__ ((packed));
170
171#define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
172#define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
173
174
175#endif
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
new file mode 100644
index 000000000000..f88eacb111d4
--- /dev/null
+++ b/include/linux/ceph/osd_client.h
@@ -0,0 +1,290 @@
1#ifndef _FS_CEPH_OSD_CLIENT_H
2#define _FS_CEPH_OSD_CLIENT_H
3
4#include <linux/completion.h>
5#include <linux/kref.h>
6#include <linux/mempool.h>
7#include <linux/rbtree.h>
8
9#include "types.h"
10#include "osdmap.h"
11#include "messenger.h"
12
13struct ceph_msg;
14struct ceph_snap_context;
15struct ceph_osd_request;
16struct ceph_osd_client;
17struct ceph_authorizer;
18struct ceph_pagelist;
19
20/*
21 * completion callback for async writepages
22 */
23typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *,
24 struct ceph_msg *);
25
26/* a given osd we're communicating with */
27struct ceph_osd {
28 atomic_t o_ref;
29 struct ceph_osd_client *o_osdc;
30 int o_osd;
31 int o_incarnation;
32 struct rb_node o_node;
33 struct ceph_connection o_con;
34 struct list_head o_requests;
35 struct list_head o_linger_requests;
36 struct list_head o_osd_lru;
37 struct ceph_authorizer *o_authorizer;
38 void *o_authorizer_buf, *o_authorizer_reply_buf;
39 size_t o_authorizer_buf_len, o_authorizer_reply_buf_len;
40 unsigned long lru_ttl;
41 int o_marked_for_keepalive;
42 struct list_head o_keepalive_item;
43};
44
45/* an in-flight request */
46struct ceph_osd_request {
47 u64 r_tid; /* unique for this client */
48 struct rb_node r_node;
49 struct list_head r_req_lru_item;
50 struct list_head r_osd_item;
51 struct list_head r_linger_item;
52 struct list_head r_linger_osd;
53 struct ceph_osd *r_osd;
54 struct ceph_pg r_pgid;
55 int r_pg_osds[CEPH_PG_MAX_SIZE];
56 int r_num_pg_osds;
57
58 struct ceph_connection *r_con_filling_msg;
59
60 struct ceph_msg *r_request, *r_reply;
61 int r_result;
62 int r_flags; /* any additional flags for the osd */
63 u32 r_sent; /* >0 if r_request is sending/sent */
64 int r_got_reply;
65 int r_linger;
66
67 struct ceph_osd_client *r_osdc;
68 struct kref r_kref;
69 bool r_mempool;
70 struct completion r_completion, r_safe_completion;
71 ceph_osdc_callback_t r_callback, r_safe_callback;
72 struct ceph_eversion r_reassert_version;
73 struct list_head r_unsafe_item;
74
75 struct inode *r_inode; /* for use by callbacks */
76 void *r_priv; /* ditto */
77
78 char r_oid[40]; /* object name */
79 int r_oid_len;
80 unsigned long r_stamp; /* send OR check time */
81
82 struct ceph_file_layout r_file_layout;
83 struct ceph_snap_context *r_snapc; /* snap context for writes */
84 unsigned r_num_pages; /* size of page array (follows) */
85 unsigned r_page_alignment; /* io offset in first page */
86 struct page **r_pages; /* pages for data payload */
87 int r_pages_from_pool;
88 int r_own_pages; /* if true, i own page list */
89#ifdef CONFIG_BLOCK
90 struct bio *r_bio; /* instead of pages */
91#endif
92
93 struct ceph_pagelist *r_trail; /* trailing part of the data */
94};
95
96struct ceph_osd_event {
97 u64 cookie;
98 int one_shot;
99 struct ceph_osd_client *osdc;
100 void (*cb)(u64, u64, u8, void *);
101 void *data;
102 struct rb_node node;
103 struct list_head osd_node;
104 struct kref kref;
105 struct completion completion;
106};
107
108struct ceph_osd_event_work {
109 struct work_struct work;
110 struct ceph_osd_event *event;
111 u64 ver;
112 u64 notify_id;
113 u8 opcode;
114};
115
116struct ceph_osd_client {
117 struct ceph_client *client;
118
119 struct ceph_osdmap *osdmap; /* current map */
120 struct rw_semaphore map_sem;
121 struct completion map_waiters;
122 u64 last_requested_map;
123
124 struct mutex request_mutex;
125 struct rb_root osds; /* osds */
126 struct list_head osd_lru; /* idle osds */
127 u64 timeout_tid; /* tid of timeout triggering rq */
128 u64 last_tid; /* tid of last request */
129 struct rb_root requests; /* pending requests */
130 struct list_head req_lru; /* in-flight lru */
131 struct list_head req_unsent; /* unsent/need-resend queue */
132 struct list_head req_notarget; /* map to no osd */
133 struct list_head req_linger; /* lingering requests */
134 int num_requests;
135 struct delayed_work timeout_work;
136 struct delayed_work osds_timeout_work;
137#ifdef CONFIG_DEBUG_FS
138 struct dentry *debugfs_file;
139#endif
140
141 mempool_t *req_mempool;
142
143 struct ceph_msgpool msgpool_op;
144 struct ceph_msgpool msgpool_op_reply;
145
146 spinlock_t event_lock;
147 struct rb_root event_tree;
148 u64 event_count;
149
150 struct workqueue_struct *notify_wq;
151};
152
153struct ceph_osd_req_op {
154 u16 op; /* CEPH_OSD_OP_* */
155 u32 flags; /* CEPH_OSD_FLAG_* */
156 union {
157 struct {
158 u64 offset, length;
159 u64 truncate_size;
160 u32 truncate_seq;
161 } extent;
162 struct {
163 const char *name;
164 u32 name_len;
165 const char *val;
166 u32 value_len;
167 __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */
168 __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */
169 } xattr;
170 struct {
171 const char *class_name;
172 __u8 class_len;
173 const char *method_name;
174 __u8 method_len;
175 __u8 argc;
176 const char *indata;
177 u32 indata_len;
178 } cls;
179 struct {
180 u64 cookie, count;
181 } pgls;
182 struct {
183 u64 snapid;
184 } snap;
185 struct {
186 u64 cookie;
187 u64 ver;
188 __u8 flag;
189 u32 prot_ver;
190 u32 timeout;
191 } watch;
192 };
193 u32 payload_len;
194};
195
196extern int ceph_osdc_init(struct ceph_osd_client *osdc,
197 struct ceph_client *client);
198extern void ceph_osdc_stop(struct ceph_osd_client *osdc);
199
200extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
201 struct ceph_msg *msg);
202extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
203 struct ceph_msg *msg);
204
205extern void ceph_calc_raw_layout(struct ceph_osd_client *osdc,
206 struct ceph_file_layout *layout,
207 u64 snapid,
208 u64 off, u64 *plen, u64 *bno,
209 struct ceph_osd_request *req,
210 struct ceph_osd_req_op *op);
211
212extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
213 int flags,
214 struct ceph_snap_context *snapc,
215 struct ceph_osd_req_op *ops,
216 bool use_mempool,
217 gfp_t gfp_flags,
218 struct page **pages,
219 struct bio *bio);
220
221extern void ceph_osdc_build_request(struct ceph_osd_request *req,
222 u64 off, u64 *plen,
223 struct ceph_osd_req_op *src_ops,
224 struct ceph_snap_context *snapc,
225 struct timespec *mtime,
226 const char *oid,
227 int oid_len);
228
229extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
230 struct ceph_file_layout *layout,
231 struct ceph_vino vino,
232 u64 offset, u64 *len, int op, int flags,
233 struct ceph_snap_context *snapc,
234 int do_sync, u32 truncate_seq,
235 u64 truncate_size,
236 struct timespec *mtime,
237 bool use_mempool, int num_reply,
238 int page_align);
239
240extern void ceph_osdc_set_request_linger(struct ceph_osd_client *osdc,
241 struct ceph_osd_request *req);
242extern void ceph_osdc_unregister_linger_request(struct ceph_osd_client *osdc,
243 struct ceph_osd_request *req);
244
245static inline void ceph_osdc_get_request(struct ceph_osd_request *req)
246{
247 kref_get(&req->r_kref);
248}
249extern void ceph_osdc_release_request(struct kref *kref);
250static inline void ceph_osdc_put_request(struct ceph_osd_request *req)
251{
252 kref_put(&req->r_kref, ceph_osdc_release_request);
253}
254
255extern int ceph_osdc_start_request(struct ceph_osd_client *osdc,
256 struct ceph_osd_request *req,
257 bool nofail);
258extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
259 struct ceph_osd_request *req);
260extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
261
262extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
263 struct ceph_vino vino,
264 struct ceph_file_layout *layout,
265 u64 off, u64 *plen,
266 u32 truncate_seq, u64 truncate_size,
267 struct page **pages, int nr_pages,
268 int page_align);
269
270extern int ceph_osdc_writepages(struct ceph_osd_client *osdc,
271 struct ceph_vino vino,
272 struct ceph_file_layout *layout,
273 struct ceph_snap_context *sc,
274 u64 off, u64 len,
275 u32 truncate_seq, u64 truncate_size,
276 struct timespec *mtime,
277 struct page **pages, int nr_pages,
278 int flags, int do_sync, bool nofail);
279
280/* watch/notify events */
281extern int ceph_osdc_create_event(struct ceph_osd_client *osdc,
282 void (*event_cb)(u64, u64, u8, void *),
283 int one_shot, void *data,
284 struct ceph_osd_event **pevent);
285extern void ceph_osdc_cancel_event(struct ceph_osd_event *event);
286extern int ceph_osdc_wait_event(struct ceph_osd_event *event,
287 unsigned long timeout);
288extern void ceph_osdc_put_event(struct ceph_osd_event *event);
289#endif
290
diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
new file mode 100644
index 000000000000..ba4c205cbb01
--- /dev/null
+++ b/include/linux/ceph/osdmap.h
@@ -0,0 +1,130 @@
1#ifndef _FS_CEPH_OSDMAP_H
2#define _FS_CEPH_OSDMAP_H
3
4#include <linux/rbtree.h>
5#include "types.h"
6#include "ceph_fs.h"
7#include <linux/crush/crush.h>
8
9/*
10 * The osd map describes the current membership of the osd cluster and
11 * specifies the mapping of objects to placement groups and placement
12 * groups to (sets of) osds. That is, it completely specifies the
13 * (desired) distribution of all data objects in the system at some
14 * point in time.
15 *
16 * Each map version is identified by an epoch, which increases monotonically.
17 *
18 * The map can be updated either via an incremental map (diff) describing
19 * the change between two successive epochs, or as a fully encoded map.
20 */
21struct ceph_pg_pool_info {
22 struct rb_node node;
23 int id;
24 struct ceph_pg_pool v;
25 int pg_num_mask, pgp_num_mask, lpg_num_mask, lpgp_num_mask;
26 char *name;
27};
28
29struct ceph_pg_mapping {
30 struct rb_node node;
31 struct ceph_pg pgid;
32 int len;
33 int osds[];
34};
35
36struct ceph_osdmap {
37 struct ceph_fsid fsid;
38 u32 epoch;
39 u32 mkfs_epoch;
40 struct ceph_timespec created, modified;
41
42 u32 flags; /* CEPH_OSDMAP_* */
43
44 u32 max_osd; /* size of osd_state, _offload, _addr arrays */
45 u8 *osd_state; /* CEPH_OSD_* */
46 u32 *osd_weight; /* 0 = failed, 0x10000 = 100% normal */
47 struct ceph_entity_addr *osd_addr;
48
49 struct rb_root pg_temp;
50 struct rb_root pg_pools;
51 u32 pool_max;
52
53 /* the CRUSH map specifies the mapping of placement groups to
54 * the list of osds that store+replicate them. */
55 struct crush_map *crush;
56};
57
58/*
59 * file layout helpers
60 */
61#define ceph_file_layout_su(l) ((__s32)le32_to_cpu((l).fl_stripe_unit))
62#define ceph_file_layout_stripe_count(l) \
63 ((__s32)le32_to_cpu((l).fl_stripe_count))
64#define ceph_file_layout_object_size(l) ((__s32)le32_to_cpu((l).fl_object_size))
65#define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash))
66#define ceph_file_layout_object_su(l) \
67 ((__s32)le32_to_cpu((l).fl_object_stripe_unit))
68#define ceph_file_layout_pg_preferred(l) \
69 ((__s32)le32_to_cpu((l).fl_pg_preferred))
70#define ceph_file_layout_pg_pool(l) \
71 ((__s32)le32_to_cpu((l).fl_pg_pool))
72
73static inline unsigned ceph_file_layout_stripe_width(struct ceph_file_layout *l)
74{
75 return le32_to_cpu(l->fl_stripe_unit) *
76 le32_to_cpu(l->fl_stripe_count);
77}
78
79/* "period" == bytes before i start on a new set of objects */
80static inline unsigned ceph_file_layout_period(struct ceph_file_layout *l)
81{
82 return le32_to_cpu(l->fl_object_size) *
83 le32_to_cpu(l->fl_stripe_count);
84}
85
86
87static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd)
88{
89 return (osd < map->max_osd) && (map->osd_state[osd] & CEPH_OSD_UP);
90}
91
92static inline bool ceph_osdmap_flag(struct ceph_osdmap *map, int flag)
93{
94 return map && (map->flags & flag);
95}
96
97extern char *ceph_osdmap_state_str(char *str, int len, int state);
98
99static inline struct ceph_entity_addr *ceph_osd_addr(struct ceph_osdmap *map,
100 int osd)
101{
102 if (osd >= map->max_osd)
103 return NULL;
104 return &map->osd_addr[osd];
105}
106
107extern struct ceph_osdmap *osdmap_decode(void **p, void *end);
108extern struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
109 struct ceph_osdmap *map,
110 struct ceph_messenger *msgr);
111extern void ceph_osdmap_destroy(struct ceph_osdmap *map);
112
113/* calculate mapping of a file extent to an object */
114extern void ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
115 u64 off, u64 *plen,
116 u64 *bno, u64 *oxoff, u64 *oxlen);
117
118/* calculate mapping of object to a placement group */
119extern int ceph_calc_object_layout(struct ceph_object_layout *ol,
120 const char *oid,
121 struct ceph_file_layout *fl,
122 struct ceph_osdmap *osdmap);
123extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
124 int *acting);
125extern int ceph_calc_pg_primary(struct ceph_osdmap *osdmap,
126 struct ceph_pg pgid);
127
128extern int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name);
129
130#endif
diff --git a/include/linux/ceph/pagelist.h b/include/linux/ceph/pagelist.h
new file mode 100644
index 000000000000..9660d6b0a35d
--- /dev/null
+++ b/include/linux/ceph/pagelist.h
@@ -0,0 +1,75 @@
1#ifndef __FS_CEPH_PAGELIST_H
2#define __FS_CEPH_PAGELIST_H
3
4#include <linux/list.h>
5
6struct ceph_pagelist {
7 struct list_head head;
8 void *mapped_tail;
9 size_t length;
10 size_t room;
11 struct list_head free_list;
12 size_t num_pages_free;
13};
14
15struct ceph_pagelist_cursor {
16 struct ceph_pagelist *pl; /* pagelist, for error checking */
17 struct list_head *page_lru; /* page in list */
18 size_t room; /* room remaining to reset to */
19};
20
21static inline void ceph_pagelist_init(struct ceph_pagelist *pl)
22{
23 INIT_LIST_HEAD(&pl->head);
24 pl->mapped_tail = NULL;
25 pl->length = 0;
26 pl->room = 0;
27 INIT_LIST_HEAD(&pl->free_list);
28 pl->num_pages_free = 0;
29}
30
31extern int ceph_pagelist_release(struct ceph_pagelist *pl);
32
33extern int ceph_pagelist_append(struct ceph_pagelist *pl, const void *d, size_t l);
34
35extern int ceph_pagelist_reserve(struct ceph_pagelist *pl, size_t space);
36
37extern int ceph_pagelist_free_reserve(struct ceph_pagelist *pl);
38
39extern void ceph_pagelist_set_cursor(struct ceph_pagelist *pl,
40 struct ceph_pagelist_cursor *c);
41
42extern int ceph_pagelist_truncate(struct ceph_pagelist *pl,
43 struct ceph_pagelist_cursor *c);
44
45static inline int ceph_pagelist_encode_64(struct ceph_pagelist *pl, u64 v)
46{
47 __le64 ev = cpu_to_le64(v);
48 return ceph_pagelist_append(pl, &ev, sizeof(ev));
49}
50static inline int ceph_pagelist_encode_32(struct ceph_pagelist *pl, u32 v)
51{
52 __le32 ev = cpu_to_le32(v);
53 return ceph_pagelist_append(pl, &ev, sizeof(ev));
54}
55static inline int ceph_pagelist_encode_16(struct ceph_pagelist *pl, u16 v)
56{
57 __le16 ev = cpu_to_le16(v);
58 return ceph_pagelist_append(pl, &ev, sizeof(ev));
59}
60static inline int ceph_pagelist_encode_8(struct ceph_pagelist *pl, u8 v)
61{
62 return ceph_pagelist_append(pl, &v, 1);
63}
64static inline int ceph_pagelist_encode_string(struct ceph_pagelist *pl,
65 char *s, size_t len)
66{
67 int ret = ceph_pagelist_encode_32(pl, len);
68 if (ret)
69 return ret;
70 if (len)
71 return ceph_pagelist_append(pl, s, len);
72 return 0;
73}
74
75#endif
diff --git a/include/linux/ceph/rados.h b/include/linux/ceph/rados.h
new file mode 100644
index 000000000000..0a99099801a4
--- /dev/null
+++ b/include/linux/ceph/rados.h
@@ -0,0 +1,426 @@
1#ifndef CEPH_RADOS_H
2#define CEPH_RADOS_H
3
4/*
5 * Data types for the Ceph distributed object storage layer RADOS
6 * (Reliable Autonomic Distributed Object Store).
7 */
8
9#include "msgr.h"
10
11/*
12 * osdmap encoding versions
13 */
14#define CEPH_OSDMAP_INC_VERSION 5
15#define CEPH_OSDMAP_INC_VERSION_EXT 6
16#define CEPH_OSDMAP_VERSION 5
17#define CEPH_OSDMAP_VERSION_EXT 6
18
19/*
20 * fs id
21 */
22struct ceph_fsid {
23 unsigned char fsid[16];
24};
25
26static inline int ceph_fsid_compare(const struct ceph_fsid *a,
27 const struct ceph_fsid *b)
28{
29 return memcmp(a, b, sizeof(*a));
30}
31
32/*
33 * ino, object, etc.
34 */
35typedef __le64 ceph_snapid_t;
36#define CEPH_SNAPDIR ((__u64)(-1)) /* reserved for hidden .snap dir */
37#define CEPH_NOSNAP ((__u64)(-2)) /* "head", "live" revision */
38#define CEPH_MAXSNAP ((__u64)(-3)) /* largest valid snapid */
39
40struct ceph_timespec {
41 __le32 tv_sec;
42 __le32 tv_nsec;
43} __attribute__ ((packed));
44
45
46/*
47 * object layout - how objects are mapped into PGs
48 */
49#define CEPH_OBJECT_LAYOUT_HASH 1
50#define CEPH_OBJECT_LAYOUT_LINEAR 2
51#define CEPH_OBJECT_LAYOUT_HASHINO 3
52
53/*
54 * pg layout -- how PGs are mapped onto (sets of) OSDs
55 */
56#define CEPH_PG_LAYOUT_CRUSH 0
57#define CEPH_PG_LAYOUT_HASH 1
58#define CEPH_PG_LAYOUT_LINEAR 2
59#define CEPH_PG_LAYOUT_HYBRID 3
60
61#define CEPH_PG_MAX_SIZE 16 /* max # osds in a single pg */
62
63/*
64 * placement group.
65 * we encode this into one __le64.
66 */
67struct ceph_pg {
68 __le16 preferred; /* preferred primary osd */
69 __le16 ps; /* placement seed */
70 __le32 pool; /* object pool */
71} __attribute__ ((packed));
72
73/*
74 * pg_pool is a set of pgs storing a pool of objects
75 *
76 * pg_num -- base number of pseudorandomly placed pgs
77 *
78 * pgp_num -- effective number when calculating pg placement. this
79 * is used for pg_num increases. new pgs result in data being "split"
80 * into new pgs. for this to proceed smoothly, new pgs are intiially
81 * colocated with their parents; that is, pgp_num doesn't increase
82 * until the new pgs have successfully split. only _then_ are the new
83 * pgs placed independently.
84 *
85 * lpg_num -- localized pg count (per device). replicas are randomly
86 * selected.
87 *
88 * lpgp_num -- as above.
89 */
90#define CEPH_PG_TYPE_REP 1
91#define CEPH_PG_TYPE_RAID4 2
92#define CEPH_PG_POOL_VERSION 2
93struct ceph_pg_pool {
94 __u8 type; /* CEPH_PG_TYPE_* */
95 __u8 size; /* number of osds in each pg */
96 __u8 crush_ruleset; /* crush placement rule */
97 __u8 object_hash; /* hash mapping object name to ps */
98 __le32 pg_num, pgp_num; /* number of pg's */
99 __le32 lpg_num, lpgp_num; /* number of localized pg's */
100 __le32 last_change; /* most recent epoch changed */
101 __le64 snap_seq; /* seq for per-pool snapshot */
102 __le32 snap_epoch; /* epoch of last snap */
103 __le32 num_snaps;
104 __le32 num_removed_snap_intervals; /* if non-empty, NO per-pool snaps */
105 __le64 auid; /* who owns the pg */
106} __attribute__ ((packed));
107
108/*
109 * stable_mod func is used to control number of placement groups.
110 * similar to straight-up modulo, but produces a stable mapping as b
111 * increases over time. b is the number of bins, and bmask is the
112 * containing power of 2 minus 1.
113 *
114 * b <= bmask and bmask=(2**n)-1
115 * e.g., b=12 -> bmask=15, b=123 -> bmask=127
116 */
117static inline int ceph_stable_mod(int x, int b, int bmask)
118{
119 if ((x & bmask) < b)
120 return x & bmask;
121 else
122 return x & (bmask >> 1);
123}
124
125/*
126 * object layout - how a given object should be stored.
127 */
128struct ceph_object_layout {
129 struct ceph_pg ol_pgid; /* raw pg, with _full_ ps precision. */
130 __le32 ol_stripe_unit; /* for per-object parity, if any */
131} __attribute__ ((packed));
132
133/*
134 * compound epoch+version, used by storage layer to serialize mutations
135 */
136struct ceph_eversion {
137 __le32 epoch;
138 __le64 version;
139} __attribute__ ((packed));
140
141/*
142 * osd map bits
143 */
144
145/* status bits */
146#define CEPH_OSD_EXISTS 1
147#define CEPH_OSD_UP 2
148
149/* osd weights. fixed point value: 0x10000 == 1.0 ("in"), 0 == "out" */
150#define CEPH_OSD_IN 0x10000
151#define CEPH_OSD_OUT 0
152
153
154/*
155 * osd map flag bits
156 */
157#define CEPH_OSDMAP_NEARFULL (1<<0) /* sync writes (near ENOSPC) */
158#define CEPH_OSDMAP_FULL (1<<1) /* no data writes (ENOSPC) */
159#define CEPH_OSDMAP_PAUSERD (1<<2) /* pause all reads */
160#define CEPH_OSDMAP_PAUSEWR (1<<3) /* pause all writes */
161#define CEPH_OSDMAP_PAUSEREC (1<<4) /* pause recovery */
162
163/*
164 * osd ops
165 */
166#define CEPH_OSD_OP_MODE 0xf000
167#define CEPH_OSD_OP_MODE_RD 0x1000
168#define CEPH_OSD_OP_MODE_WR 0x2000
169#define CEPH_OSD_OP_MODE_RMW 0x3000
170#define CEPH_OSD_OP_MODE_SUB 0x4000
171
172#define CEPH_OSD_OP_TYPE 0x0f00
173#define CEPH_OSD_OP_TYPE_LOCK 0x0100
174#define CEPH_OSD_OP_TYPE_DATA 0x0200
175#define CEPH_OSD_OP_TYPE_ATTR 0x0300
176#define CEPH_OSD_OP_TYPE_EXEC 0x0400
177#define CEPH_OSD_OP_TYPE_PG 0x0500
178
179enum {
180 /** data **/
181 /* read */
182 CEPH_OSD_OP_READ = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 1,
183 CEPH_OSD_OP_STAT = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 2,
184 CEPH_OSD_OP_MAPEXT = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 3,
185
186 /* fancy read */
187 CEPH_OSD_OP_MASKTRUNC = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 4,
188 CEPH_OSD_OP_SPARSE_READ = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 5,
189
190 CEPH_OSD_OP_NOTIFY = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 6,
191 CEPH_OSD_OP_NOTIFY_ACK = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 7,
192
193 /* versioning */
194 CEPH_OSD_OP_ASSERT_VER = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 8,
195
196 /* write */
197 CEPH_OSD_OP_WRITE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 1,
198 CEPH_OSD_OP_WRITEFULL = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 2,
199 CEPH_OSD_OP_TRUNCATE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 3,
200 CEPH_OSD_OP_ZERO = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 4,
201 CEPH_OSD_OP_DELETE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 5,
202
203 /* fancy write */
204 CEPH_OSD_OP_APPEND = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 6,
205 CEPH_OSD_OP_STARTSYNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 7,
206 CEPH_OSD_OP_SETTRUNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 8,
207 CEPH_OSD_OP_TRIMTRUNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 9,
208
209 CEPH_OSD_OP_TMAPUP = CEPH_OSD_OP_MODE_RMW | CEPH_OSD_OP_TYPE_DATA | 10,
210 CEPH_OSD_OP_TMAPPUT = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 11,
211 CEPH_OSD_OP_TMAPGET = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 12,
212
213 CEPH_OSD_OP_CREATE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 13,
214 CEPH_OSD_OP_ROLLBACK= CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 14,
215
216 CEPH_OSD_OP_WATCH = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 15,
217
218 /** attrs **/
219 /* read */
220 CEPH_OSD_OP_GETXATTR = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 1,
221 CEPH_OSD_OP_GETXATTRS = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 2,
222 CEPH_OSD_OP_CMPXATTR = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 3,
223
224 /* write */
225 CEPH_OSD_OP_SETXATTR = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 1,
226 CEPH_OSD_OP_SETXATTRS = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 2,
227 CEPH_OSD_OP_RESETXATTRS = CEPH_OSD_OP_MODE_WR|CEPH_OSD_OP_TYPE_ATTR | 3,
228 CEPH_OSD_OP_RMXATTR = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 4,
229
230 /** subop **/
231 CEPH_OSD_OP_PULL = CEPH_OSD_OP_MODE_SUB | 1,
232 CEPH_OSD_OP_PUSH = CEPH_OSD_OP_MODE_SUB | 2,
233 CEPH_OSD_OP_BALANCEREADS = CEPH_OSD_OP_MODE_SUB | 3,
234 CEPH_OSD_OP_UNBALANCEREADS = CEPH_OSD_OP_MODE_SUB | 4,
235 CEPH_OSD_OP_SCRUB = CEPH_OSD_OP_MODE_SUB | 5,
236 CEPH_OSD_OP_SCRUB_RESERVE = CEPH_OSD_OP_MODE_SUB | 6,
237 CEPH_OSD_OP_SCRUB_UNRESERVE = CEPH_OSD_OP_MODE_SUB | 7,
238 CEPH_OSD_OP_SCRUB_STOP = CEPH_OSD_OP_MODE_SUB | 8,
239
240 /** lock **/
241 CEPH_OSD_OP_WRLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 1,
242 CEPH_OSD_OP_WRUNLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 2,
243 CEPH_OSD_OP_RDLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 3,
244 CEPH_OSD_OP_RDUNLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 4,
245 CEPH_OSD_OP_UPLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 5,
246 CEPH_OSD_OP_DNLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 6,
247
248 /** exec **/
249 CEPH_OSD_OP_CALL = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_EXEC | 1,
250
251 /** pg **/
252 CEPH_OSD_OP_PGLS = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_PG | 1,
253};
254
255static inline int ceph_osd_op_type_lock(int op)
256{
257 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_LOCK;
258}
259static inline int ceph_osd_op_type_data(int op)
260{
261 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA;
262}
263static inline int ceph_osd_op_type_attr(int op)
264{
265 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR;
266}
267static inline int ceph_osd_op_type_exec(int op)
268{
269 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC;
270}
271static inline int ceph_osd_op_type_pg(int op)
272{
273 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG;
274}
275
276static inline int ceph_osd_op_mode_subop(int op)
277{
278 return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB;
279}
280static inline int ceph_osd_op_mode_read(int op)
281{
282 return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_RD;
283}
284static inline int ceph_osd_op_mode_modify(int op)
285{
286 return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_WR;
287}
288
289/*
290 * note that the following tmap stuff is also defined in the ceph librados.h
291 * any modification here needs to be updated there
292 */
293#define CEPH_OSD_TMAP_HDR 'h'
294#define CEPH_OSD_TMAP_SET 's'
295#define CEPH_OSD_TMAP_RM 'r'
296
297extern const char *ceph_osd_op_name(int op);
298
299
300/*
301 * osd op flags
302 *
303 * An op may be READ, WRITE, or READ|WRITE.
304 */
305enum {
306 CEPH_OSD_FLAG_ACK = 1, /* want (or is) "ack" ack */
307 CEPH_OSD_FLAG_ONNVRAM = 2, /* want (or is) "onnvram" ack */
308 CEPH_OSD_FLAG_ONDISK = 4, /* want (or is) "ondisk" ack */
309 CEPH_OSD_FLAG_RETRY = 8, /* resend attempt */
310 CEPH_OSD_FLAG_READ = 16, /* op may read */
311 CEPH_OSD_FLAG_WRITE = 32, /* op may write */
312 CEPH_OSD_FLAG_ORDERSNAP = 64, /* EOLDSNAP if snapc is out of order */
313 CEPH_OSD_FLAG_PEERSTAT = 128, /* msg includes osd_peer_stat */
314 CEPH_OSD_FLAG_BALANCE_READS = 256,
315 CEPH_OSD_FLAG_PARALLELEXEC = 512, /* execute op in parallel */
316 CEPH_OSD_FLAG_PGOP = 1024, /* pg op, no object */
317 CEPH_OSD_FLAG_EXEC = 2048, /* op may exec */
318 CEPH_OSD_FLAG_EXEC_PUBLIC = 4096, /* op may exec (public) */
319};
320
321enum {
322 CEPH_OSD_OP_FLAG_EXCL = 1, /* EXCL object create */
323};
324
325#define EOLDSNAPC ERESTART /* ORDERSNAP flag set; writer has old snapc*/
326#define EBLACKLISTED ESHUTDOWN /* blacklisted */
327
328/* xattr comparison */
329enum {
330 CEPH_OSD_CMPXATTR_OP_NOP = 0,
331 CEPH_OSD_CMPXATTR_OP_EQ = 1,
332 CEPH_OSD_CMPXATTR_OP_NE = 2,
333 CEPH_OSD_CMPXATTR_OP_GT = 3,
334 CEPH_OSD_CMPXATTR_OP_GTE = 4,
335 CEPH_OSD_CMPXATTR_OP_LT = 5,
336 CEPH_OSD_CMPXATTR_OP_LTE = 6
337};
338
339enum {
340 CEPH_OSD_CMPXATTR_MODE_STRING = 1,
341 CEPH_OSD_CMPXATTR_MODE_U64 = 2
342};
343
344#define RADOS_NOTIFY_VER 1
345
346/*
347 * an individual object operation. each may be accompanied by some data
348 * payload
349 */
350struct ceph_osd_op {
351 __le16 op; /* CEPH_OSD_OP_* */
352 __le32 flags; /* CEPH_OSD_FLAG_* */
353 union {
354 struct {
355 __le64 offset, length;
356 __le64 truncate_size;
357 __le32 truncate_seq;
358 } __attribute__ ((packed)) extent;
359 struct {
360 __le32 name_len;
361 __le32 value_len;
362 __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */
363 __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */
364 } __attribute__ ((packed)) xattr;
365 struct {
366 __u8 class_len;
367 __u8 method_len;
368 __u8 argc;
369 __le32 indata_len;
370 } __attribute__ ((packed)) cls;
371 struct {
372 __le64 cookie, count;
373 } __attribute__ ((packed)) pgls;
374 struct {
375 __le64 snapid;
376 } __attribute__ ((packed)) snap;
377 struct {
378 __le64 cookie;
379 __le64 ver;
380 __u8 flag; /* 0 = unwatch, 1 = watch */
381 } __attribute__ ((packed)) watch;
382};
383 __le32 payload_len;
384} __attribute__ ((packed));
385
386/*
387 * osd request message header. each request may include multiple
388 * ceph_osd_op object operations.
389 */
390struct ceph_osd_request_head {
391 __le32 client_inc; /* client incarnation */
392 struct ceph_object_layout layout; /* pgid */
393 __le32 osdmap_epoch; /* client's osdmap epoch */
394
395 __le32 flags;
396
397 struct ceph_timespec mtime; /* for mutations only */
398 struct ceph_eversion reassert_version; /* if we are replaying op */
399
400 __le32 object_len; /* length of object name */
401
402 __le64 snapid; /* snapid to read */
403 __le64 snap_seq; /* writer's snap context */
404 __le32 num_snaps;
405
406 __le16 num_ops;
407 struct ceph_osd_op ops[]; /* followed by ops[], obj, ticket, snaps */
408} __attribute__ ((packed));
409
410struct ceph_osd_reply_head {
411 __le32 client_inc; /* client incarnation */
412 __le32 flags;
413 struct ceph_object_layout layout;
414 __le32 osdmap_epoch;
415 struct ceph_eversion reassert_version; /* for replaying uncommitted */
416
417 __le32 result; /* result code */
418
419 __le32 object_len; /* length of object name */
420 __le32 num_ops;
421 struct ceph_osd_op ops[0]; /* ops[], object */
422} __attribute__ ((packed));
423
424
425
426#endif
diff --git a/include/linux/ceph/types.h b/include/linux/ceph/types.h
new file mode 100644
index 000000000000..28b35a005ec2
--- /dev/null
+++ b/include/linux/ceph/types.h
@@ -0,0 +1,29 @@
1#ifndef _FS_CEPH_TYPES_H
2#define _FS_CEPH_TYPES_H
3
4/* needed before including ceph_fs.h */
5#include <linux/in.h>
6#include <linux/types.h>
7#include <linux/fcntl.h>
8#include <linux/string.h>
9
10#include "ceph_fs.h"
11#include "ceph_frag.h"
12#include "ceph_hash.h"
13
14/*
15 * Identify inodes by both their ino AND snapshot id (a u64).
16 */
17struct ceph_vino {
18 u64 ino;
19 u64 snap;
20};
21
22
23/* context for the caps reservation mechanism */
24struct ceph_cap_reservation {
25 int count;
26};
27
28
29#endif
diff --git a/include/linux/cfag12864b.h b/include/linux/cfag12864b.h
index 6f9f19d66591..b454dfce60d9 100644
--- a/include/linux/cfag12864b.h
+++ b/include/linux/cfag12864b.h
@@ -44,7 +44,7 @@ extern unsigned char * cfag12864b_buffer;
44/* 44/*
45 * Get the refresh rate of the LCD 45 * Get the refresh rate of the LCD
46 * 46 *
47 * Returns the refresh rate (hertzs). 47 * Returns the refresh rate (hertz).
48 */ 48 */
49extern unsigned int cfag12864b_getrate(void); 49extern unsigned int cfag12864b_getrate(void);
50 50
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 0c991023ee47..ab4ac0ccb857 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -75,7 +75,7 @@ struct cgroup_subsys_state {
75 75
76 unsigned long flags; 76 unsigned long flags;
77 /* ID for this css, if possible */ 77 /* ID for this css, if possible */
78 struct css_id *id; 78 struct css_id __rcu *id;
79}; 79};
80 80
81/* bits in struct cgroup_subsys_state flags field */ 81/* bits in struct cgroup_subsys_state flags field */
@@ -154,6 +154,10 @@ enum {
154 * A thread in rmdir() is wating for this cgroup. 154 * A thread in rmdir() is wating for this cgroup.
155 */ 155 */
156 CGRP_WAIT_ON_RMDIR, 156 CGRP_WAIT_ON_RMDIR,
157 /*
158 * Clone cgroup values when creating a new child cgroup
159 */
160 CGRP_CLONE_CHILDREN,
157}; 161};
158 162
159/* which pidlist file are we talking about? */ 163/* which pidlist file are we talking about? */
@@ -205,7 +209,7 @@ struct cgroup {
205 struct list_head children; /* my children */ 209 struct list_head children; /* my children */
206 210
207 struct cgroup *parent; /* my parent */ 211 struct cgroup *parent; /* my parent */
208 struct dentry *dentry; /* cgroup fs entry, RCU protected */ 212 struct dentry __rcu *dentry; /* cgroup fs entry, RCU protected */
209 213
210 /* Private pointers for each registered subsystem */ 214 /* Private pointers for each registered subsystem */
211 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT]; 215 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
@@ -236,7 +240,7 @@ struct cgroup {
236 /* For RCU-protected deletion */ 240 /* For RCU-protected deletion */
237 struct rcu_head rcu_head; 241 struct rcu_head rcu_head;
238 242
239 /* List of events which userspace want to recieve */ 243 /* List of events which userspace want to receive */
240 struct list_head event_list; 244 struct list_head event_list;
241 spinlock_t event_list_lock; 245 spinlock_t event_list_lock;
242}; 246};
@@ -463,14 +467,17 @@ struct cgroup_subsys {
463 int (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); 467 int (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp);
464 void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); 468 void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp);
465 int (*can_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 469 int (*can_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
466 struct task_struct *tsk, bool threadgroup); 470 struct task_struct *tsk);
471 int (*can_attach_task)(struct cgroup *cgrp, struct task_struct *tsk);
467 void (*cancel_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 472 void (*cancel_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
468 struct task_struct *tsk, bool threadgroup); 473 struct task_struct *tsk);
474 void (*pre_attach)(struct cgroup *cgrp);
475 void (*attach_task)(struct cgroup *cgrp, struct task_struct *tsk);
469 void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 476 void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
470 struct cgroup *old_cgrp, struct task_struct *tsk, 477 struct cgroup *old_cgrp, struct task_struct *tsk);
471 bool threadgroup);
472 void (*fork)(struct cgroup_subsys *ss, struct task_struct *task); 478 void (*fork)(struct cgroup_subsys *ss, struct task_struct *task);
473 void (*exit)(struct cgroup_subsys *ss, struct task_struct *task); 479 void (*exit)(struct cgroup_subsys *ss, struct cgroup *cgrp,
480 struct cgroup *old_cgrp, struct task_struct *task);
474 int (*populate)(struct cgroup_subsys *ss, 481 int (*populate)(struct cgroup_subsys *ss,
475 struct cgroup *cgrp); 482 struct cgroup *cgrp);
476 void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp); 483 void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp);
@@ -548,9 +555,6 @@ static inline struct cgroup* task_cgroup(struct task_struct *task,
548 return task_subsys_state(task, subsys_id)->cgroup; 555 return task_subsys_state(task, subsys_id)->cgroup;
549} 556}
550 557
551int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *ss,
552 char *nodename);
553
554/* A cgroup_iter should be treated as an opaque object */ 558/* A cgroup_iter should be treated as an opaque object */
555struct cgroup_iter { 559struct cgroup_iter {
556 struct list_head *cg_link; 560 struct list_head *cg_link;
@@ -560,7 +564,7 @@ struct cgroup_iter {
560/* 564/*
561 * To iterate across the tasks in a cgroup: 565 * To iterate across the tasks in a cgroup:
562 * 566 *
563 * 1) call cgroup_iter_start to intialize an iterator 567 * 1) call cgroup_iter_start to initialize an iterator
564 * 568 *
565 * 2) call cgroup_iter_next() to retrieve member tasks until it 569 * 2) call cgroup_iter_next() to retrieve member tasks until it
566 * returns NULL or until you want to end the iteration 570 * returns NULL or until you want to end the iteration
@@ -622,6 +626,7 @@ bool css_is_ancestor(struct cgroup_subsys_state *cg,
622/* Get id and depth of css */ 626/* Get id and depth of css */
623unsigned short css_id(struct cgroup_subsys_state *css); 627unsigned short css_id(struct cgroup_subsys_state *css);
624unsigned short css_depth(struct cgroup_subsys_state *css); 628unsigned short css_depth(struct cgroup_subsys_state *css);
629struct cgroup_subsys_state *cgroup_css_from_dir(struct file *f, int id);
625 630
626#else /* !CONFIG_CGROUPS */ 631#else /* !CONFIG_CGROUPS */
627 632
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index ccefff02b6cb..ac663c18776c 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -19,12 +19,6 @@ SUBSYS(debug)
19 19
20/* */ 20/* */
21 21
22#ifdef CONFIG_CGROUP_NS
23SUBSYS(ns)
24#endif
25
26/* */
27
28#ifdef CONFIG_CGROUP_SCHED 22#ifdef CONFIG_CGROUP_SCHED
29SUBSYS(cpu_cgroup) 23SUBSYS(cpu_cgroup)
30#endif 24#endif
@@ -65,4 +59,8 @@ SUBSYS(net_cls)
65SUBSYS(blkio) 59SUBSYS(blkio)
66#endif 60#endif
67 61
62#ifdef CONFIG_CGROUP_PERF
63SUBSYS(perf)
64#endif
65
68/* */ 66/* */
diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
new file mode 100644
index 000000000000..04ffb2e6c9d0
--- /dev/null
+++ b/include/linux/cleancache.h
@@ -0,0 +1,122 @@
1#ifndef _LINUX_CLEANCACHE_H
2#define _LINUX_CLEANCACHE_H
3
4#include <linux/fs.h>
5#include <linux/exportfs.h>
6#include <linux/mm.h>
7
8#define CLEANCACHE_KEY_MAX 6
9
10/*
11 * cleancache requires every file with a page in cleancache to have a
12 * unique key unless/until the file is removed/truncated. For some
13 * filesystems, the inode number is unique, but for "modern" filesystems
14 * an exportable filehandle is required (see exportfs.h)
15 */
16struct cleancache_filekey {
17 union {
18 ino_t ino;
19 __u32 fh[CLEANCACHE_KEY_MAX];
20 u32 key[CLEANCACHE_KEY_MAX];
21 } u;
22};
23
24struct cleancache_ops {
25 int (*init_fs)(size_t);
26 int (*init_shared_fs)(char *uuid, size_t);
27 int (*get_page)(int, struct cleancache_filekey,
28 pgoff_t, struct page *);
29 void (*put_page)(int, struct cleancache_filekey,
30 pgoff_t, struct page *);
31 void (*flush_page)(int, struct cleancache_filekey, pgoff_t);
32 void (*flush_inode)(int, struct cleancache_filekey);
33 void (*flush_fs)(int);
34};
35
36extern struct cleancache_ops
37 cleancache_register_ops(struct cleancache_ops *ops);
38extern void __cleancache_init_fs(struct super_block *);
39extern void __cleancache_init_shared_fs(char *, struct super_block *);
40extern int __cleancache_get_page(struct page *);
41extern void __cleancache_put_page(struct page *);
42extern void __cleancache_flush_page(struct address_space *, struct page *);
43extern void __cleancache_flush_inode(struct address_space *);
44extern void __cleancache_flush_fs(struct super_block *);
45extern int cleancache_enabled;
46
47#ifdef CONFIG_CLEANCACHE
48static inline bool cleancache_fs_enabled(struct page *page)
49{
50 return page->mapping->host->i_sb->cleancache_poolid >= 0;
51}
52static inline bool cleancache_fs_enabled_mapping(struct address_space *mapping)
53{
54 return mapping->host->i_sb->cleancache_poolid >= 0;
55}
56#else
57#define cleancache_enabled (0)
58#define cleancache_fs_enabled(_page) (0)
59#define cleancache_fs_enabled_mapping(_page) (0)
60#endif
61
62/*
63 * The shim layer provided by these inline functions allows the compiler
64 * to reduce all cleancache hooks to nothingness if CONFIG_CLEANCACHE
65 * is disabled, to a single global variable check if CONFIG_CLEANCACHE
66 * is enabled but no cleancache "backend" has dynamically enabled it,
67 * and, for the most frequent cleancache ops, to a single global variable
68 * check plus a superblock element comparison if CONFIG_CLEANCACHE is enabled
69 * and a cleancache backend has dynamically enabled cleancache, but the
70 * filesystem referenced by that cleancache op has not enabled cleancache.
71 * As a result, CONFIG_CLEANCACHE can be enabled by default with essentially
72 * no measurable performance impact.
73 */
74
75static inline void cleancache_init_fs(struct super_block *sb)
76{
77 if (cleancache_enabled)
78 __cleancache_init_fs(sb);
79}
80
81static inline void cleancache_init_shared_fs(char *uuid, struct super_block *sb)
82{
83 if (cleancache_enabled)
84 __cleancache_init_shared_fs(uuid, sb);
85}
86
87static inline int cleancache_get_page(struct page *page)
88{
89 int ret = -1;
90
91 if (cleancache_enabled && cleancache_fs_enabled(page))
92 ret = __cleancache_get_page(page);
93 return ret;
94}
95
96static inline void cleancache_put_page(struct page *page)
97{
98 if (cleancache_enabled && cleancache_fs_enabled(page))
99 __cleancache_put_page(page);
100}
101
102static inline void cleancache_flush_page(struct address_space *mapping,
103 struct page *page)
104{
105 /* careful... page->mapping is NULL sometimes when this is called */
106 if (cleancache_enabled && cleancache_fs_enabled_mapping(mapping))
107 __cleancache_flush_page(mapping, page);
108}
109
110static inline void cleancache_flush_inode(struct address_space *mapping)
111{
112 if (cleancache_enabled && cleancache_fs_enabled_mapping(mapping))
113 __cleancache_flush_inode(mapping);
114}
115
116static inline void cleancache_flush_fs(struct super_block *sb)
117{
118 if (cleancache_enabled)
119 __cleancache_flush_fs(sb);
120}
121
122#endif /* _LINUX_CLEANCACHE_H */
diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h
new file mode 100644
index 000000000000..457bcb0a310a
--- /dev/null
+++ b/include/linux/clkdev.h
@@ -0,0 +1,36 @@
1/*
2 * include/linux/clkdev.h
3 *
4 * Copyright (C) 2008 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Helper for the clk API to assist looking up a struct clk.
11 */
12#ifndef __CLKDEV_H
13#define __CLKDEV_H
14
15#include <asm/clkdev.h>
16
17struct clk;
18struct device;
19
20struct clk_lookup {
21 struct list_head node;
22 const char *dev_id;
23 const char *con_id;
24 struct clk *clk;
25};
26
27struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
28 const char *dev_fmt, ...);
29
30void clkdev_add(struct clk_lookup *cl);
31void clkdev_drop(struct clk_lookup *cl);
32
33void clkdev_add_table(struct clk_lookup *, size_t);
34int clk_add_alias(const char *, const char *, char *, struct device *);
35
36#endif
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index fc53492b6ad7..d6733e27af34 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -56,46 +56,52 @@ enum clock_event_nofitiers {
56 56
57/** 57/**
58 * struct clock_event_device - clock event device descriptor 58 * struct clock_event_device - clock event device descriptor
59 * @name: ptr to clock event name 59 * @event_handler: Assigned by the framework to be called by the low
60 * @features: features 60 * level handler of the event source
61 * @set_next_event: set next event function
62 * @next_event: local storage for the next event in oneshot mode
61 * @max_delta_ns: maximum delta value in ns 63 * @max_delta_ns: maximum delta value in ns
62 * @min_delta_ns: minimum delta value in ns 64 * @min_delta_ns: minimum delta value in ns
63 * @mult: nanosecond to cycles multiplier 65 * @mult: nanosecond to cycles multiplier
64 * @shift: nanoseconds to cycles divisor (power of two) 66 * @shift: nanoseconds to cycles divisor (power of two)
67 * @mode: operating mode assigned by the management code
68 * @features: features
69 * @retries: number of forced programming retries
70 * @set_mode: set mode function
71 * @broadcast: function to broadcast events
72 * @min_delta_ticks: minimum delta value in ticks stored for reconfiguration
73 * @max_delta_ticks: maximum delta value in ticks stored for reconfiguration
74 * @name: ptr to clock event name
65 * @rating: variable to rate clock event devices 75 * @rating: variable to rate clock event devices
66 * @irq: IRQ number (only for non CPU local devices) 76 * @irq: IRQ number (only for non CPU local devices)
67 * @cpumask: cpumask to indicate for which CPUs this device works 77 * @cpumask: cpumask to indicate for which CPUs this device works
68 * @set_next_event: set next event function
69 * @set_mode: set mode function
70 * @event_handler: Assigned by the framework to be called by the low
71 * level handler of the event source
72 * @broadcast: function to broadcast events
73 * @list: list head for the management code 78 * @list: list head for the management code
74 * @mode: operating mode assigned by the management code
75 * @next_event: local storage for the next event in oneshot mode
76 * @retries: number of forced programming retries
77 */ 79 */
78struct clock_event_device { 80struct clock_event_device {
79 const char *name; 81 void (*event_handler)(struct clock_event_device *);
80 unsigned int features; 82 int (*set_next_event)(unsigned long evt,
83 struct clock_event_device *);
84 ktime_t next_event;
81 u64 max_delta_ns; 85 u64 max_delta_ns;
82 u64 min_delta_ns; 86 u64 min_delta_ns;
83 u32 mult; 87 u32 mult;
84 u32 shift; 88 u32 shift;
89 enum clock_event_mode mode;
90 unsigned int features;
91 unsigned long retries;
92
93 void (*broadcast)(const struct cpumask *mask);
94 void (*set_mode)(enum clock_event_mode mode,
95 struct clock_event_device *);
96 unsigned long min_delta_ticks;
97 unsigned long max_delta_ticks;
98
99 const char *name;
85 int rating; 100 int rating;
86 int irq; 101 int irq;
87 const struct cpumask *cpumask; 102 const struct cpumask *cpumask;
88 int (*set_next_event)(unsigned long evt,
89 struct clock_event_device *);
90 void (*set_mode)(enum clock_event_mode mode,
91 struct clock_event_device *);
92 void (*event_handler)(struct clock_event_device *);
93 void (*broadcast)(const struct cpumask *mask);
94 struct list_head list; 103 struct list_head list;
95 enum clock_event_mode mode; 104} ____cacheline_aligned;
96 ktime_t next_event;
97 unsigned long retries;
98};
99 105
100/* 106/*
101 * Calculate a multiplication factor for scaled math, which is used to convert 107 * Calculate a multiplication factor for scaled math, which is used to convert
@@ -122,6 +128,12 @@ extern u64 clockevent_delta2ns(unsigned long latch,
122 struct clock_event_device *evt); 128 struct clock_event_device *evt);
123extern void clockevents_register_device(struct clock_event_device *dev); 129extern void clockevents_register_device(struct clock_event_device *dev);
124 130
131extern void clockevents_config_and_register(struct clock_event_device *dev,
132 u32 freq, unsigned long min_delta,
133 unsigned long max_delta);
134
135extern int clockevents_update_freq(struct clock_event_device *ce, u32 freq);
136
125extern void clockevents_exchange_device(struct clock_event_device *old, 137extern void clockevents_exchange_device(struct clock_event_device *old,
126 struct clock_event_device *new); 138 struct clock_event_device *new);
127extern void clockevents_set_mode(struct clock_event_device *dev, 139extern void clockevents_set_mode(struct clock_event_device *dev,
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index c37b21ad5a3b..18a1baf31f2d 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -159,42 +159,39 @@ extern u64 timecounter_cyc2time(struct timecounter *tc,
159 */ 159 */
160struct clocksource { 160struct clocksource {
161 /* 161 /*
162 * First part of structure is read mostly 162 * Hotpath data, fits in a single cache line when the
163 * clocksource itself is cacheline aligned.
163 */ 164 */
164 char *name;
165 struct list_head list;
166 int rating;
167 cycle_t (*read)(struct clocksource *cs); 165 cycle_t (*read)(struct clocksource *cs);
168 int (*enable)(struct clocksource *cs); 166 cycle_t cycle_last;
169 void (*disable)(struct clocksource *cs);
170 cycle_t mask; 167 cycle_t mask;
171 u32 mult; 168 u32 mult;
172 u32 shift; 169 u32 shift;
173 u64 max_idle_ns; 170 u64 max_idle_ns;
174 unsigned long flags; 171
175 cycle_t (*vread)(void);
176 void (*suspend)(struct clocksource *cs);
177 void (*resume)(struct clocksource *cs);
178#ifdef CONFIG_IA64 172#ifdef CONFIG_IA64
179 void *fsys_mmio; /* used by fsyscall asm code */ 173 void *fsys_mmio; /* used by fsyscall asm code */
180#define CLKSRC_FSYS_MMIO_SET(mmio, addr) ((mmio) = (addr)) 174#define CLKSRC_FSYS_MMIO_SET(mmio, addr) ((mmio) = (addr))
181#else 175#else
182#define CLKSRC_FSYS_MMIO_SET(mmio, addr) do { } while (0) 176#define CLKSRC_FSYS_MMIO_SET(mmio, addr) do { } while (0)
183#endif 177#endif
184 178 const char *name;
185 /* 179 struct list_head list;
186 * Second part is written at each timer interrupt 180 int rating;
187 * Keep it in a different cache line to dirty no 181 cycle_t (*vread)(void);
188 * more than one cache line. 182 int (*enable)(struct clocksource *cs);
189 */ 183 void (*disable)(struct clocksource *cs);
190 cycle_t cycle_last ____cacheline_aligned_in_smp; 184 unsigned long flags;
185 void (*suspend)(struct clocksource *cs);
186 void (*resume)(struct clocksource *cs);
191 187
192#ifdef CONFIG_CLOCKSOURCE_WATCHDOG 188#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
193 /* Watchdog related data, used by the framework */ 189 /* Watchdog related data, used by the framework */
194 struct list_head wd_list; 190 struct list_head wd_list;
191 cycle_t cs_last;
195 cycle_t wd_last; 192 cycle_t wd_last;
196#endif 193#endif
197}; 194} ____cacheline_aligned;
198 195
199/* 196/*
200 * Clock source flags bits:: 197 * Clock source flags bits::
@@ -341,4 +338,14 @@ static inline void update_vsyscall_tz(void)
341 338
342extern void timekeeping_notify(struct clocksource *clock); 339extern void timekeeping_notify(struct clocksource *clock);
343 340
341extern cycle_t clocksource_mmio_readl_up(struct clocksource *);
342extern cycle_t clocksource_mmio_readl_down(struct clocksource *);
343extern cycle_t clocksource_mmio_readw_up(struct clocksource *);
344extern cycle_t clocksource_mmio_readw_down(struct clocksource *);
345
346extern int clocksource_mmio_init(void __iomem *, const char *,
347 unsigned long, int, unsigned, cycle_t (*)(struct clocksource *));
348
349extern int clocksource_i8253_init(void);
350
344#endif /* _LINUX_CLOCKSOURCE_H */ 351#endif /* _LINUX_CLOCKSOURCE_H */
diff --git a/include/linux/cm4000_cs.h b/include/linux/cm4000_cs.h
index 72bfefdbd767..3c4aac406175 100644
--- a/include/linux/cm4000_cs.h
+++ b/include/linux/cm4000_cs.h
@@ -20,7 +20,7 @@ typedef struct atreq {
20} atreq_t; 20} atreq_t;
21 21
22 22
23/* what is particularly stupid in the original driver is the arch-dependant 23/* what is particularly stupid in the original driver is the arch-dependent
24 * member sizes. This leads to CONFIG_COMPAT breakage, since 32bit userspace 24 * member sizes. This leads to CONFIG_COMPAT breakage, since 32bit userspace
25 * will lay out the structure members differently than the 64bit kernel. 25 * will lay out the structure members differently than the 64bit kernel.
26 * 26 *
diff --git a/include/linux/cnt32_to_63.h b/include/linux/cnt32_to_63.h
index 7605fdd1eb65..e3d8bf26e5eb 100644
--- a/include/linux/cnt32_to_63.h
+++ b/include/linux/cnt32_to_63.h
@@ -61,13 +61,31 @@ union cnt32_to_63 {
61 * 61 *
62 * 2) this code must not be preempted for a duration longer than the 62 * 2) this code must not be preempted for a duration longer than the
63 * 32-bit counter half period minus the longest period between two 63 * 32-bit counter half period minus the longest period between two
64 * calls to this code. 64 * calls to this code;
65 * 65 *
66 * Those requirements ensure proper update to the state bit in memory. 66 * Those requirements ensure proper update to the state bit in memory.
67 * This is usually not a problem in practice, but if it is then a kernel 67 * This is usually not a problem in practice, but if it is then a kernel
68 * timer should be scheduled to manage for this code to be executed often 68 * timer should be scheduled to manage for this code to be executed often
69 * enough. 69 * enough.
70 * 70 *
71 * And finally:
72 *
73 * 3) the cnt_lo argument must be seen as a globally incrementing value,
74 * meaning that it should be a direct reference to the counter data which
75 * can be evaluated according to a specific ordering within the macro,
76 * and not the result of a previous evaluation stored in a variable.
77 *
78 * For example, this is wrong:
79 *
80 * u32 partial = get_hw_count();
81 * u64 full = cnt32_to_63(partial);
82 * return full;
83 *
84 * This is fine:
85 *
86 * u64 full = cnt32_to_63(get_hw_count());
87 * return full;
88 *
71 * Note that the top bit (bit 63) in the returned value should be considered 89 * Note that the top bit (bit 63) in the returned value should be considered
72 * as garbage. It is not cleared here because callers are likely to use a 90 * as garbage. It is not cleared here because callers are likely to use a
73 * multiplier on the returned value which can get rid of the top bit 91 * multiplier on the returned value which can get rid of the top bit
diff --git a/include/linux/coda_cache.h b/include/linux/coda_cache.h
deleted file mode 100644
index c910b5eb1ceb..000000000000
--- a/include/linux/coda_cache.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/* Coda filesystem -- Linux Minicache
2 *
3 * Copyright (C) 1989 - 1997 Carnegie Mellon University
4 *
5 * Carnegie Mellon University encourages users of this software to
6 * contribute improvements to the Coda project. Contact Peter Braam
7 * <coda@cs.cmu.edu>
8 */
9
10#ifndef _CFSNC_HEADER_
11#define _CFSNC_HEADER_
12
13/* credential cache */
14void coda_cache_enter(struct inode *inode, int mask);
15void coda_cache_clear_inode(struct inode *);
16void coda_cache_clear_all(struct super_block *sb);
17int coda_cache_check(struct inode *inode, int mask);
18
19/* for downcalls and attributes and lookups */
20void coda_flag_inode_children(struct inode *inode, int flag);
21
22#endif /* _CFSNC_HEADER_ */
diff --git a/include/linux/coda_fs_i.h b/include/linux/coda_fs_i.h
deleted file mode 100644
index b3ef0c461578..000000000000
--- a/include/linux/coda_fs_i.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * coda_fs_i.h
3 *
4 * Copyright (C) 1998 Carnegie Mellon University
5 *
6 */
7
8#ifndef _LINUX_CODA_FS_I
9#define _LINUX_CODA_FS_I
10
11#include <linux/types.h>
12#include <linux/list.h>
13#include <linux/coda.h>
14
15/*
16 * coda fs inode data
17 */
18struct coda_inode_info {
19 struct CodaFid c_fid; /* Coda identifier */
20 u_short c_flags; /* flags (see below) */
21 struct list_head c_cilist; /* list of all coda inodes */
22 unsigned int c_mapcount; /* nr of times this inode is mapped */
23 unsigned int c_cached_epoch; /* epoch for cached permissions */
24 vuid_t c_uid; /* fsuid for cached permissions */
25 unsigned int c_cached_perm; /* cached access permissions */
26 struct inode vfs_inode;
27};
28
29/*
30 * coda fs file private data
31 */
32#define CODA_MAGIC 0xC0DAC0DA
33struct coda_file_info {
34 int cfi_magic; /* magic number */
35 struct file *cfi_container; /* container file for this cnode */
36 unsigned int cfi_mapcount; /* nr of times this file is mapped */
37};
38
39#define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data))
40
41/* flags */
42#define C_VATTR 0x1 /* Validity of vattr in inode */
43#define C_FLUSH 0x2 /* used after a flush */
44#define C_DYING 0x4 /* from venus (which died) */
45#define C_PURGE 0x8
46
47int coda_cnode_make(struct inode **, struct CodaFid *, struct super_block *);
48struct inode *coda_iget(struct super_block *sb, struct CodaFid *fid, struct coda_vattr *attr);
49int coda_cnode_makectl(struct inode **inode, struct super_block *sb);
50struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb);
51void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);
52
53#endif
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
deleted file mode 100644
index dcc228aa335a..000000000000
--- a/include/linux/coda_linux.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * Coda File System, Linux Kernel module
3 *
4 * Original version, adapted from cfs_mach.c, (C) Carnegie Mellon University
5 * Linux modifications (C) 1996, Peter J. Braam
6 * Rewritten for Linux 2.1 (C) 1997 Carnegie Mellon University
7 *
8 * Carnegie Mellon University encourages users of this software to
9 * contribute improvements to the Coda project.
10 */
11
12#ifndef _LINUX_CODA_FS
13#define _LINUX_CODA_FS
14
15#include <linux/kernel.h>
16#include <linux/param.h>
17#include <linux/mm.h>
18#include <linux/vmalloc.h>
19#include <linux/slab.h>
20#include <linux/wait.h>
21#include <linux/types.h>
22#include <linux/fs.h>
23#include <linux/coda_fs_i.h>
24
25/* operations */
26extern const struct inode_operations coda_dir_inode_operations;
27extern const struct inode_operations coda_file_inode_operations;
28extern const struct inode_operations coda_ioctl_inode_operations;
29
30extern const struct address_space_operations coda_file_aops;
31extern const struct address_space_operations coda_symlink_aops;
32
33extern const struct file_operations coda_dir_operations;
34extern const struct file_operations coda_file_operations;
35extern const struct file_operations coda_ioctl_operations;
36
37/* operations shared over more than one file */
38int coda_open(struct inode *i, struct file *f);
39int coda_release(struct inode *i, struct file *f);
40int coda_permission(struct inode *inode, int mask);
41int coda_revalidate_inode(struct dentry *);
42int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
43int coda_setattr(struct dentry *, struct iattr *);
44
45/* this file: heloers */
46char *coda_f2s(struct CodaFid *f);
47int coda_isroot(struct inode *i);
48int coda_iscontrol(const char *name, size_t length);
49
50void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
51void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
52unsigned short coda_flags_to_cflags(unsigned short);
53
54/* sysctl.h */
55void coda_sysctl_init(void);
56void coda_sysctl_clean(void);
57
58#define CODA_ALLOC(ptr, cast, size) do { \
59 if (size < PAGE_SIZE) \
60 ptr = kmalloc((unsigned long) size, GFP_KERNEL); \
61 else \
62 ptr = (cast)vmalloc((unsigned long) size); \
63 if (!ptr) \
64 printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
65 else memset( ptr, 0, size ); \
66} while (0)
67
68
69#define CODA_FREE(ptr,size) \
70 do { if (size < PAGE_SIZE) kfree((ptr)); else vfree((ptr)); } while (0)
71
72/* inode to cnode access functions */
73
74static inline struct coda_inode_info *ITOC(struct inode *inode)
75{
76 return list_entry(inode, struct coda_inode_info, vfs_inode);
77}
78
79static __inline__ struct CodaFid *coda_i2f(struct inode *inode)
80{
81 return &(ITOC(inode)->c_fid);
82}
83
84static __inline__ char *coda_i2s(struct inode *inode)
85{
86 return coda_f2s(&(ITOC(inode)->c_fid));
87}
88
89/* this will not zap the inode away */
90static __inline__ void coda_flag_inode(struct inode *inode, int flag)
91{
92 ITOC(inode)->c_flags |= flag;
93}
94
95#endif
diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h
index 284b520934a0..72f2d2f0af91 100644
--- a/include/linux/coda_psdev.h
+++ b/include/linux/coda_psdev.h
@@ -8,6 +8,7 @@
8 8
9#ifdef __KERNEL__ 9#ifdef __KERNEL__
10#include <linux/backing-dev.h> 10#include <linux/backing-dev.h>
11#include <linux/mutex.h>
11 12
12struct kstatfs; 13struct kstatfs;
13 14
@@ -20,6 +21,7 @@ struct venus_comm {
20 int vc_inuse; 21 int vc_inuse;
21 struct super_block *vc_sb; 22 struct super_block *vc_sb;
22 struct backing_dev_info bdi; 23 struct backing_dev_info bdi;
24 struct mutex vc_mutex;
23}; 25};
24 26
25 27
@@ -63,7 +65,7 @@ int venus_symlink(struct super_block *sb, struct CodaFid *fid,
63int venus_access(struct super_block *sb, struct CodaFid *fid, int mask); 65int venus_access(struct super_block *sb, struct CodaFid *fid, int mask);
64int venus_pioctl(struct super_block *sb, struct CodaFid *fid, 66int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
65 unsigned int cmd, struct PioctlData *data); 67 unsigned int cmd, struct PioctlData *data);
66int coda_downcall(int opcode, union outputArgs *out, struct super_block *sb); 68int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out);
67int venus_fsync(struct super_block *sb, struct CodaFid *fid); 69int venus_fsync(struct super_block *sb, struct CodaFid *fid);
68int venus_statfs(struct dentry *dentry, struct kstatfs *sfs); 70int venus_statfs(struct dentry *dentry, struct kstatfs *sfs);
69 71
diff --git a/include/linux/compaction.h b/include/linux/compaction.h
index 5ac51552d908..cc9f7a428649 100644
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -21,7 +21,11 @@ extern int sysctl_extfrag_handler(struct ctl_table *table, int write,
21 21
22extern int fragmentation_index(struct zone *zone, unsigned int order); 22extern int fragmentation_index(struct zone *zone, unsigned int order);
23extern unsigned long try_to_compact_pages(struct zonelist *zonelist, 23extern unsigned long try_to_compact_pages(struct zonelist *zonelist,
24 int order, gfp_t gfp_mask, nodemask_t *mask); 24 int order, gfp_t gfp_mask, nodemask_t *mask,
25 bool sync);
26extern unsigned long compaction_suitable(struct zone *zone, int order);
27extern unsigned long compact_zone_order(struct zone *zone, int order,
28 gfp_t gfp_mask, bool sync);
25 29
26/* Do not skip compaction more than 64 times */ 30/* Do not skip compaction more than 64 times */
27#define COMPACT_MAX_DEFER_SHIFT 6 31#define COMPACT_MAX_DEFER_SHIFT 6
@@ -54,7 +58,19 @@ static inline bool compaction_deferred(struct zone *zone)
54 58
55#else 59#else
56static inline unsigned long try_to_compact_pages(struct zonelist *zonelist, 60static inline unsigned long try_to_compact_pages(struct zonelist *zonelist,
57 int order, gfp_t gfp_mask, nodemask_t *nodemask) 61 int order, gfp_t gfp_mask, nodemask_t *nodemask,
62 bool sync)
63{
64 return COMPACT_CONTINUE;
65}
66
67static inline unsigned long compaction_suitable(struct zone *zone, int order)
68{
69 return COMPACT_SKIPPED;
70}
71
72static inline unsigned long compact_zone_order(struct zone *zone, int order,
73 gfp_t gfp_mask, bool sync)
58{ 74{
59 return COMPACT_CONTINUE; 75 return COMPACT_CONTINUE;
60} 76}
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 5778b559d59c..846bb1792572 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -12,6 +12,8 @@
12#include <linux/sem.h> 12#include <linux/sem.h>
13#include <linux/socket.h> 13#include <linux/socket.h>
14#include <linux/if.h> 14#include <linux/if.h>
15#include <linux/fs.h>
16#include <linux/aio_abi.h> /* for aio_context_t */
15 17
16#include <asm/compat.h> 18#include <asm/compat.h>
17#include <asm/siginfo.h> 19#include <asm/siginfo.h>
@@ -26,7 +28,7 @@ typedef __compat_gid32_t compat_gid_t;
26struct compat_sel_arg_struct; 28struct compat_sel_arg_struct;
27struct rusage; 29struct rusage;
28 30
29struct compat_itimerspec { 31struct compat_itimerspec {
30 struct compat_timespec it_interval; 32 struct compat_timespec it_interval;
31 struct compat_timespec it_value; 33 struct compat_timespec it_value;
32}; 34};
@@ -70,9 +72,9 @@ struct compat_timex {
70 compat_long_t stbcnt; 72 compat_long_t stbcnt;
71 compat_int_t tai; 73 compat_int_t tai;
72 74
73 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 75 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
74 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 76 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
75 compat_int_t :32; compat_int_t :32; compat_int_t :32; 77 compat_int_t:32; compat_int_t:32; compat_int_t:32;
76}; 78};
77 79
78#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) 80#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
@@ -81,8 +83,10 @@ typedef struct {
81 compat_sigset_word sig[_COMPAT_NSIG_WORDS]; 83 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
82} compat_sigset_t; 84} compat_sigset_t;
83 85
84extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *); 86extern int get_compat_timespec(struct timespec *,
85extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *); 87 const struct compat_timespec __user *);
88extern int put_compat_timespec(const struct timespec *,
89 struct compat_timespec __user *);
86 90
87struct compat_iovec { 91struct compat_iovec {
88 compat_uptr_t iov_base; 92 compat_uptr_t iov_base;
@@ -113,7 +117,8 @@ struct compat_rusage {
113 compat_long_t ru_nivcsw; 117 compat_long_t ru_nivcsw;
114}; 118};
115 119
116extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *); 120extern int put_compat_rusage(const struct rusage *,
121 struct compat_rusage __user *);
117 122
118struct compat_siginfo; 123struct compat_siginfo;
119 124
@@ -166,8 +171,7 @@ struct compat_ifmap {
166 unsigned char port; 171 unsigned char port;
167}; 172};
168 173
169struct compat_if_settings 174struct compat_if_settings {
170{
171 unsigned int type; /* Type of physical device or protocol */ 175 unsigned int type; /* Type of physical device or protocol */
172 unsigned int size; /* Size of the data allocated by the caller */ 176 unsigned int size; /* Size of the data allocated by the caller */
173 compat_uptr_t ifs_ifsu; /* union of pointers */ 177 compat_uptr_t ifs_ifsu; /* union of pointers */
@@ -195,8 +199,8 @@ struct compat_ifreq {
195}; 199};
196 200
197struct compat_ifconf { 201struct compat_ifconf {
198 compat_int_t ifc_len; /* size of buffer */ 202 compat_int_t ifc_len; /* size of buffer */
199 compat_caddr_t ifcbuf; 203 compat_caddr_t ifcbuf;
200}; 204};
201 205
202struct compat_robust_list { 206struct compat_robust_list {
@@ -209,6 +213,18 @@ struct compat_robust_list_head {
209 compat_uptr_t list_op_pending; 213 compat_uptr_t list_op_pending;
210}; 214};
211 215
216struct compat_statfs;
217struct compat_statfs64;
218struct compat_old_linux_dirent;
219struct compat_linux_dirent;
220struct linux_dirent64;
221struct compat_msghdr;
222struct compat_mmsghdr;
223struct compat_sysinfo;
224struct compat_sysctl_args;
225struct compat_kexec_segment;
226struct compat_mq_attr;
227
212extern void compat_exit_robust_list(struct task_struct *curr); 228extern void compat_exit_robust_list(struct task_struct *curr);
213 229
214asmlinkage long 230asmlinkage long
@@ -243,8 +259,8 @@ asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
243 const struct compat_iovec __user *vec, 259 const struct compat_iovec __user *vec,
244 unsigned long vlen, u32 pos_low, u32 pos_high); 260 unsigned long vlen, u32 pos_low, u32 pos_high);
245 261
246int compat_do_execve(char * filename, compat_uptr_t __user *argv, 262int compat_do_execve(char *filename, compat_uptr_t __user *argv,
247 compat_uptr_t __user *envp, struct pt_regs * regs); 263 compat_uptr_t __user *envp, struct pt_regs *regs);
248 264
249asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, 265asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
250 compat_ulong_t __user *outp, compat_ulong_t __user *exp, 266 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
@@ -331,12 +347,18 @@ asmlinkage long compat_sys_epoll_pwait(int epfd,
331 const compat_sigset_t __user *sigmask, 347 const compat_sigset_t __user *sigmask,
332 compat_size_t sigsetsize); 348 compat_size_t sigsetsize);
333 349
334asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, 350asmlinkage long compat_sys_utime(const char __user *filename,
335 struct compat_timespec __user *t, int flags); 351 struct compat_utimbuf __user *t);
352asmlinkage long compat_sys_utimensat(unsigned int dfd,
353 const char __user *filename,
354 struct compat_timespec __user *t,
355 int flags);
336 356
357asmlinkage long compat_sys_time(compat_time_t __user *tloc);
358asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
337asmlinkage long compat_sys_signalfd(int ufd, 359asmlinkage long compat_sys_signalfd(int ufd,
338 const compat_sigset_t __user *sigmask, 360 const compat_sigset_t __user *sigmask,
339 compat_size_t sigsetsize); 361 compat_size_t sigsetsize);
340asmlinkage long compat_sys_timerfd_settime(int ufd, int flags, 362asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
341 const struct compat_itimerspec __user *utmr, 363 const struct compat_itimerspec __user *utmr,
342 struct compat_itimerspec __user *otmr); 364 struct compat_itimerspec __user *otmr);
@@ -348,16 +370,192 @@ asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
348 const int __user *nodes, 370 const int __user *nodes,
349 int __user *status, 371 int __user *status,
350 int flags); 372 int flags);
351asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, 373asmlinkage long compat_sys_futimesat(unsigned int dfd,
374 const char __user *filename,
352 struct compat_timeval __user *t); 375 struct compat_timeval __user *t);
353asmlinkage long compat_sys_newfstatat(unsigned int dfd, const char __user * filename, 376asmlinkage long compat_sys_utimes(const char __user *filename,
377 struct compat_timeval __user *t);
378asmlinkage long compat_sys_newstat(const char __user *filename,
379 struct compat_stat __user *statbuf);
380asmlinkage long compat_sys_newlstat(const char __user *filename,
381 struct compat_stat __user *statbuf);
382asmlinkage long compat_sys_newfstatat(unsigned int dfd,
383 const char __user *filename,
354 struct compat_stat __user *statbuf, 384 struct compat_stat __user *statbuf,
355 int flag); 385 int flag);
386asmlinkage long compat_sys_newfstat(unsigned int fd,
387 struct compat_stat __user *statbuf);
388asmlinkage long compat_sys_statfs(const char __user *pathname,
389 struct compat_statfs __user *buf);
390asmlinkage long compat_sys_fstatfs(unsigned int fd,
391 struct compat_statfs __user *buf);
392asmlinkage long compat_sys_statfs64(const char __user *pathname,
393 compat_size_t sz,
394 struct compat_statfs64 __user *buf);
395asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
396 struct compat_statfs64 __user *buf);
397asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
398 unsigned long arg);
399asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
400 unsigned long arg);
401asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
402asmlinkage long compat_sys_io_getevents(aio_context_t ctx_id,
403 unsigned long min_nr,
404 unsigned long nr,
405 struct io_event __user *events,
406 struct compat_timespec __user *timeout);
407asmlinkage long compat_sys_io_submit(aio_context_t ctx_id, int nr,
408 u32 __user *iocb);
409asmlinkage long compat_sys_mount(const char __user *dev_name,
410 const char __user *dir_name,
411 const char __user *type, unsigned long flags,
412 const void __user *data);
413asmlinkage long compat_sys_old_readdir(unsigned int fd,
414 struct compat_old_linux_dirent __user *,
415 unsigned int count);
416asmlinkage long compat_sys_getdents(unsigned int fd,
417 struct compat_linux_dirent __user *dirent,
418 unsigned int count);
419asmlinkage long compat_sys_getdents64(unsigned int fd,
420 struct linux_dirent64 __user *dirent,
421 unsigned int count);
422asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
423 unsigned int nr_segs, unsigned int flags);
424asmlinkage long compat_sys_open(const char __user *filename, int flags,
425 int mode);
356asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename, 426asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
357 int flags, int mode); 427 int flags, int mode);
428asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
429 struct file_handle __user *handle,
430 int flags);
431asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
432 compat_ulong_t __user *outp,
433 compat_ulong_t __user *exp,
434 struct compat_timespec __user *tsp,
435 void __user *sig);
436asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
437 unsigned int nfds,
438 struct compat_timespec __user *tsp,
439 const compat_sigset_t __user *sigmask,
440 compat_size_t sigsetsize);
441#if (defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE)) && \
442 !defined(CONFIG_NFSD_DEPRECATED)
443union compat_nfsctl_res;
444struct compat_nfsctl_arg;
445asmlinkage long compat_sys_nfsservctl(int cmd,
446 struct compat_nfsctl_arg __user *arg,
447 union compat_nfsctl_res __user *res);
448#else
449asmlinkage long compat_sys_nfsservctl(int cmd, void *notused, void *notused2);
450#endif
451asmlinkage long compat_sys_signalfd4(int ufd,
452 const compat_sigset_t __user *sigmask,
453 compat_size_t sigsetsize, int flags);
454asmlinkage long compat_sys_get_mempolicy(int __user *policy,
455 compat_ulong_t __user *nmask,
456 compat_ulong_t maxnode,
457 compat_ulong_t addr,
458 compat_ulong_t flags);
459asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
460 compat_ulong_t maxnode);
461asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
462 compat_ulong_t mode,
463 compat_ulong_t __user *nmask,
464 compat_ulong_t maxnode, compat_ulong_t flags);
465
466asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
467 char __user *optval, unsigned int optlen);
468asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
469 unsigned flags);
470asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
471 unsigned vlen, unsigned int flags);
472asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
473 unsigned int flags);
474asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len,
475 unsigned flags);
476asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
477 unsigned flags, struct sockaddr __user *addr,
478 int __user *addrlen);
479asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
480 unsigned vlen, unsigned int flags,
481 struct compat_timespec __user *timeout);
482asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
483 struct compat_timespec __user *rmtp);
484asmlinkage long compat_sys_getitimer(int which,
485 struct compat_itimerval __user *it);
486asmlinkage long compat_sys_setitimer(int which,
487 struct compat_itimerval __user *in,
488 struct compat_itimerval __user *out);
489asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
490asmlinkage long compat_sys_setrlimit(unsigned int resource,
491 struct compat_rlimit __user *rlim);
492asmlinkage long compat_sys_getrlimit(unsigned int resource,
493 struct compat_rlimit __user *rlim);
494asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
495asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
496 unsigned int len,
497 compat_ulong_t __user *user_mask_ptr);
498asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
499 unsigned int len,
500 compat_ulong_t __user *user_mask_ptr);
501asmlinkage long compat_sys_timer_create(clockid_t which_clock,
502 struct compat_sigevent __user *timer_event_spec,
503 timer_t __user *created_timer_id);
504asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
505 struct compat_itimerspec __user *new,
506 struct compat_itimerspec __user *old);
507asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
508 struct compat_itimerspec __user *setting);
509asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
510 struct compat_timespec __user *tp);
511asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
512 struct compat_timespec __user *tp);
513asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock,
514 struct compat_timex __user *tp);
515asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
516 struct compat_timespec __user *tp);
517asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
518 struct compat_timespec __user *rqtp,
519 struct compat_timespec __user *rmtp);
520asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
521 struct compat_siginfo __user *uinfo,
522 struct compat_timespec __user *uts, compat_size_t sigsetsize);
523asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
524 compat_size_t sigsetsize);
525asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
526asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
527 unsigned long arg);
528asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
529 struct compat_timespec __user *utime, u32 __user *uaddr2,
530 u32 val3);
531asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
532 char __user *optval, int __user *optlen);
533asmlinkage long compat_sys_kexec_load(unsigned long entry,
534 unsigned long nr_segments,
535 struct compat_kexec_segment __user *,
536 unsigned long flags);
537asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
538 const struct compat_mq_attr __user *u_mqstat,
539 struct compat_mq_attr __user *u_omqstat);
540asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
541 const struct compat_sigevent __user *u_notification);
542asmlinkage long compat_sys_mq_open(const char __user *u_name,
543 int oflag, compat_mode_t mode,
544 struct compat_mq_attr __user *u_attr);
545asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
546 const char __user *u_msg_ptr,
547 size_t msg_len, unsigned int msg_prio,
548 const struct compat_timespec __user *u_abs_timeout);
549asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
550 char __user *u_msg_ptr,
551 size_t msg_len, unsigned int __user *u_msg_prio,
552 const struct compat_timespec __user *u_abs_timeout);
553asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
554asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
358 555
359extern ssize_t compat_rw_copy_check_uvector(int type, 556extern ssize_t compat_rw_copy_check_uvector(int type,
360 const struct compat_iovec __user *uvector, unsigned long nr_segs, 557 const struct compat_iovec __user *uvector,
558 unsigned long nr_segs,
361 unsigned long fast_segs, struct iovec *fast_pointer, 559 unsigned long fast_segs, struct iovec *fast_pointer,
362 struct iovec **ret_pointer); 560 struct iovec **ret_pointer);
363 561
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 16508bcddacc..59e4028e833d 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -34,8 +34,12 @@
34 __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ 34 __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \
35 (typeof(ptr)) (__ptr + (off)); }) 35 (typeof(ptr)) (__ptr + (off)); })
36 36
37#ifdef __CHECKER__
38#define __must_be_array(arr) 0
39#else
37/* &a[0] degrades to a pointer: a different type from an array */ 40/* &a[0] degrades to a pointer: a different type from an array */
38#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) 41#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
42#endif
39 43
40/* 44/*
41 * Force always-inline if the user requests it so via the .config, 45 * Force always-inline if the user requests it so via the .config,
@@ -92,3 +96,11 @@
92#if !defined(__noclone) 96#if !defined(__noclone)
93#define __noclone /* not needed */ 97#define __noclone /* not needed */
94#endif 98#endif
99
100/*
101 * A trick to suppress uninitialized variable warning without generating any
102 * code
103 */
104#define uninitialized_var(x) x = x
105
106#define __always_inline inline __attribute__((always_inline))
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
index b721129e0469..37d412436d0f 100644
--- a/include/linux/compiler-gcc3.h
+++ b/include/linux/compiler-gcc3.h
@@ -21,11 +21,3 @@
21# error "GCOV profiling support for gcc versions below 3.4 not included" 21# error "GCOV profiling support for gcc versions below 3.4 not included"
22# endif /* __GNUC_MINOR__ */ 22# endif /* __GNUC_MINOR__ */
23#endif /* CONFIG_GCOV_KERNEL */ 23#endif /* CONFIG_GCOV_KERNEL */
24
25/*
26 * A trick to suppress uninitialized variable warning without generating any
27 * code
28 */
29#define uninitialized_var(x) x = x
30
31#define __always_inline inline __attribute__((always_inline))
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index fcfa5b9a4317..dfadc96e9d63 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -12,13 +12,6 @@
12#define __used __attribute__((__used__)) 12#define __used __attribute__((__used__))
13#define __must_check __attribute__((warn_unused_result)) 13#define __must_check __attribute__((warn_unused_result))
14#define __compiler_offsetof(a,b) __builtin_offsetof(a,b) 14#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
15#define __always_inline inline __attribute__((always_inline))
16
17/*
18 * A trick to suppress uninitialized variable warning without generating any
19 * code
20 */
21#define uninitialized_var(x) x = x
22 15
23#if __GNUC_MINOR__ >= 3 16#if __GNUC_MINOR__ >= 3
24/* Mark functions as cold. gcc will assume any path leading to a call 17/* Mark functions as cold. gcc will assume any path leading to a call
@@ -53,13 +46,12 @@
53#define __noclone __attribute__((__noclone__)) 46#define __noclone __attribute__((__noclone__))
54 47
55#endif 48#endif
56
57#endif 49#endif
58 50
59#if __GNUC_MINOR__ > 0 51#if __GNUC_MINOR__ > 0
60#define __compiletime_object_size(obj) __builtin_object_size(obj, 0) 52#define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
61#endif 53#endif
62#if __GNUC_MINOR__ >= 4 54#if __GNUC_MINOR__ >= 4 && !defined(__CHECKER__)
63#define __compiletime_warning(message) __attribute__((warning(message))) 55#define __compiletime_warning(message) __attribute__((warning(message)))
64#define __compiletime_error(message) __attribute__((error(message))) 56#define __compiletime_error(message) __attribute__((error(message)))
65#endif 57#endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index c1a62c56a660..320d6c94ff84 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -16,7 +16,11 @@
16# define __release(x) __context__(x,-1) 16# define __release(x) __context__(x,-1)
17# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0) 17# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
18# define __percpu __attribute__((noderef, address_space(3))) 18# define __percpu __attribute__((noderef, address_space(3)))
19#ifdef CONFIG_SPARSE_RCU_POINTER
20# define __rcu __attribute__((noderef, address_space(4)))
21#else
19# define __rcu 22# define __rcu
23#endif
20extern void __chk_user_ptr(const volatile void __user *); 24extern void __chk_user_ptr(const volatile void __user *);
21extern void __chk_io_ptr(const volatile void __iomem *); 25extern void __chk_io_ptr(const volatile void __iomem *);
22#else 26#else
diff --git a/include/linux/completion.h b/include/linux/completion.h
index c63950e8a863..9d727271c9fe 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -10,7 +10,7 @@
10 10
11#include <linux/wait.h> 11#include <linux/wait.h>
12 12
13/** 13/*
14 * struct completion - structure used to maintain state for a "completion" 14 * struct completion - structure used to maintain state for a "completion"
15 * 15 *
16 * This is the opaque structure used to maintain the state for a "completion". 16 * This is the opaque structure used to maintain the state for a "completion".
@@ -34,7 +34,7 @@ struct completion {
34 ({ init_completion(&work); work; }) 34 ({ init_completion(&work); work; })
35 35
36/** 36/**
37 * DECLARE_COMPLETION: - declare and initialize a completion structure 37 * DECLARE_COMPLETION - declare and initialize a completion structure
38 * @work: identifier for the completion structure 38 * @work: identifier for the completion structure
39 * 39 *
40 * This macro declares and initializes a completion structure. Generally used 40 * This macro declares and initializes a completion structure. Generally used
@@ -50,7 +50,7 @@ struct completion {
50 * are on the kernel stack: 50 * are on the kernel stack:
51 */ 51 */
52/** 52/**
53 * DECLARE_COMPLETION_ONSTACK: - declare and initialize a completion structure 53 * DECLARE_COMPLETION_ONSTACK - declare and initialize a completion structure
54 * @work: identifier for the completion structure 54 * @work: identifier for the completion structure
55 * 55 *
56 * This macro declares and initializes a completion structure on the kernel 56 * This macro declares and initializes a completion structure on the kernel
@@ -64,7 +64,7 @@ struct completion {
64#endif 64#endif
65 65
66/** 66/**
67 * init_completion: - Initialize a dynamically allocated completion 67 * init_completion - Initialize a dynamically allocated completion
68 * @x: completion structure that is to be initialized 68 * @x: completion structure that is to be initialized
69 * 69 *
70 * This inline function will initialize a dynamically created completion 70 * This inline function will initialize a dynamically created completion
@@ -81,10 +81,10 @@ extern int wait_for_completion_interruptible(struct completion *x);
81extern int wait_for_completion_killable(struct completion *x); 81extern int wait_for_completion_killable(struct completion *x);
82extern unsigned long wait_for_completion_timeout(struct completion *x, 82extern unsigned long wait_for_completion_timeout(struct completion *x,
83 unsigned long timeout); 83 unsigned long timeout);
84extern unsigned long wait_for_completion_interruptible_timeout( 84extern long wait_for_completion_interruptible_timeout(
85 struct completion *x, unsigned long timeout); 85 struct completion *x, unsigned long timeout);
86extern unsigned long wait_for_completion_killable_timeout( 86extern long wait_for_completion_killable_timeout(
87 struct completion *x, unsigned long timeout); 87 struct completion *x, unsigned long timeout);
88extern bool try_wait_for_completion(struct completion *x); 88extern bool try_wait_for_completion(struct completion *x);
89extern bool completion_done(struct completion *x); 89extern bool completion_done(struct completion *x);
90 90
@@ -93,7 +93,7 @@ extern void complete_all(struct completion *);
93extern void complete_n(struct completion *, int n); 93extern void complete_n(struct completion *, int n);
94 94
95/** 95/**
96 * INIT_COMPLETION: - reinitialize a completion structure 96 * INIT_COMPLETION - reinitialize a completion structure
97 * @x: completion structure to be reinitialized 97 * @x: completion structure to be reinitialized
98 * 98 *
99 * This macro should be used to reinitialize a completion structure so it can 99 * This macro should be used to reinitialize a completion structure so it can
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index ddb7a97c78c2..645778ad899b 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -218,7 +218,7 @@ static ssize_t _item##_attr_store(struct config_item *item, \
218 * group children. default_groups may coexist alongsize make_group() or 218 * group children. default_groups may coexist alongsize make_group() or
219 * make_item(), but if the group wishes to have only default_groups 219 * make_item(), but if the group wishes to have only default_groups
220 * children (disallowing mkdir(2)), it need not provide either function. 220 * children (disallowing mkdir(2)), it need not provide either function.
221 * If the group has commit(), it supports pending and commited (active) 221 * If the group has commit(), it supports pending and committed (active)
222 * items. 222 * items.
223 */ 223 */
224struct configfs_item_operations { 224struct configfs_item_operations {
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 3a779ffba60b..f696bccd48cb 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -42,8 +42,9 @@
42#define CN_VAL_DM_USERSPACE_LOG 0x1 42#define CN_VAL_DM_USERSPACE_LOG 0x1
43#define CN_IDX_DRBD 0x8 43#define CN_IDX_DRBD 0x8
44#define CN_VAL_DRBD 0x1 44#define CN_VAL_DRBD 0x1
45#define CN_KVP_IDX 0x9 /* HyperV KVP */
45 46
46#define CN_NETLINK_USERS 8 47#define CN_NETLINK_USERS 10 /* Highest index + 1 */
47 48
48/* 49/*
49 * Maximum connector's message size. 50 * Maximum connector's message size.
@@ -87,14 +88,6 @@ struct cn_queue_dev {
87 atomic_t refcnt; 88 atomic_t refcnt;
88 unsigned char name[CN_CBQ_NAMELEN]; 89 unsigned char name[CN_CBQ_NAMELEN];
89 90
90 struct workqueue_struct *cn_queue;
91 /* Sent to kevent to create cn_queue only when needed */
92 struct work_struct wq_creation;
93 /* Tell if the wq_creation job is pending/completed */
94 atomic_t wq_requested;
95 /* Wait for cn_queue to be created */
96 wait_queue_head_t wq_created;
97
98 struct list_head queue_list; 91 struct list_head queue_list;
99 spinlock_t queue_lock; 92 spinlock_t queue_lock;
100 93
@@ -106,20 +99,13 @@ struct cn_callback_id {
106 struct cb_id id; 99 struct cb_id id;
107}; 100};
108 101
109struct cn_callback_data {
110 struct sk_buff *skb;
111 void (*callback) (struct cn_msg *, struct netlink_skb_parms *);
112
113 void *free;
114};
115
116struct cn_callback_entry { 102struct cn_callback_entry {
117 struct list_head callback_entry; 103 struct list_head callback_entry;
118 struct work_struct work; 104 atomic_t refcnt;
119 struct cn_queue_dev *pdev; 105 struct cn_queue_dev *pdev;
120 106
121 struct cn_callback_id id; 107 struct cn_callback_id id;
122 struct cn_callback_data data; 108 void (*callback) (struct cn_msg *, struct netlink_skb_parms *);
123 109
124 u32 seq, group; 110 u32 seq, group;
125}; 111};
@@ -134,21 +120,21 @@ struct cn_dev {
134 struct cn_queue_dev *cbdev; 120 struct cn_queue_dev *cbdev;
135}; 121};
136 122
137int cn_add_callback(struct cb_id *, char *, void (*callback) (struct cn_msg *, struct netlink_skb_parms *)); 123int cn_add_callback(struct cb_id *id, const char *name,
124 void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
138void cn_del_callback(struct cb_id *); 125void cn_del_callback(struct cb_id *);
139int cn_netlink_send(struct cn_msg *, u32, gfp_t); 126int cn_netlink_send(struct cn_msg *, u32, gfp_t);
140 127
141int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(struct cn_msg *, struct netlink_skb_parms *)); 128int cn_queue_add_callback(struct cn_queue_dev *dev, const char *name,
129 struct cb_id *id,
130 void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
142void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id); 131void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
132void cn_queue_release_callback(struct cn_callback_entry *);
143 133
144int queue_cn_work(struct cn_callback_entry *cbq, struct work_struct *work); 134struct cn_queue_dev *cn_queue_alloc_dev(const char *name, struct sock *);
145
146struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *);
147void cn_queue_free_dev(struct cn_queue_dev *dev); 135void cn_queue_free_dev(struct cn_queue_dev *dev);
148 136
149int cn_cb_equal(struct cb_id *, struct cb_id *); 137int cn_cb_equal(struct cb_id *, struct cb_id *);
150 138
151void cn_queue_wrapper(struct work_struct *work);
152
153#endif /* __KERNEL__ */ 139#endif /* __KERNEL__ */
154#endif /* __CONNECTOR_H */ 140#endif /* __CONNECTOR_H */
diff --git a/include/linux/console.h b/include/linux/console.h
index 95cf6f08a59d..7453cfd593c8 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -126,6 +126,12 @@ struct console {
126 struct console *next; 126 struct console *next;
127}; 127};
128 128
129/*
130 * for_each_console() allows you to iterate on each console
131 */
132#define for_each_console(con) \
133 for (con = console_drivers; con != NULL; con = con->next)
134
129extern int console_set_on_cmdline; 135extern int console_set_on_cmdline;
130 136
131extern int add_preferred_console(char *name, int idx, char *options); 137extern int add_preferred_console(char *name, int idx, char *options);
@@ -133,9 +139,9 @@ extern int update_console_cmdline(char *name, int idx, char *name_new, int idx_n
133extern void register_console(struct console *); 139extern void register_console(struct console *);
134extern int unregister_console(struct console *); 140extern int unregister_console(struct console *);
135extern struct console *console_drivers; 141extern struct console *console_drivers;
136extern void acquire_console_sem(void); 142extern void console_lock(void);
137extern int try_acquire_console_sem(void); 143extern int console_trylock(void);
138extern void release_console_sem(void); 144extern void console_unlock(void);
139extern void console_conditional_schedule(void); 145extern void console_conditional_schedule(void);
140extern void console_unblank(void); 146extern void console_unblank(void);
141extern struct tty_driver *console_device(int *); 147extern struct tty_driver *console_device(int *);
@@ -145,7 +151,7 @@ extern int is_console_locked(void);
145extern int braille_register_console(struct console *, int index, 151extern int braille_register_console(struct console *, int index,
146 char *console_options, char *braille_options); 152 char *console_options, char *braille_options);
147extern int braille_unregister_console(struct console *); 153extern int braille_unregister_console(struct console *);
148 154extern void console_sysfs_notify(void);
149extern int console_suspend_enabled; 155extern int console_suspend_enabled;
150 156
151/* Suspend and resume console messages over PM events */ 157/* Suspend and resume console messages over PM events */
diff --git a/include/linux/cper.h b/include/linux/cper.h
index bf972f81e2a7..c23049496531 100644
--- a/include/linux/cper.h
+++ b/include/linux/cper.h
@@ -39,10 +39,12 @@
39 * Severity difinition for error_severity in struct cper_record_header 39 * Severity difinition for error_severity in struct cper_record_header
40 * and section_severity in struct cper_section_descriptor 40 * and section_severity in struct cper_section_descriptor
41 */ 41 */
42#define CPER_SEV_RECOVERABLE 0x0 42enum {
43#define CPER_SEV_FATAL 0x1 43 CPER_SEV_RECOVERABLE,
44#define CPER_SEV_CORRECTED 0x2 44 CPER_SEV_FATAL,
45#define CPER_SEV_INFORMATIONAL 0x3 45 CPER_SEV_CORRECTED,
46 CPER_SEV_INFORMATIONAL,
47};
46 48
47/* 49/*
48 * Validation bits difinition for validation_bits in struct 50 * Validation bits difinition for validation_bits in struct
@@ -201,6 +203,47 @@
201 UUID_LE(0x036F84E1, 0x7F37, 0x428c, 0xA7, 0x9E, 0x57, 0x5F, \ 203 UUID_LE(0x036F84E1, 0x7F37, 0x428c, 0xA7, 0x9E, 0x57, 0x5F, \
202 0xDF, 0xAA, 0x84, 0xEC) 204 0xDF, 0xAA, 0x84, 0xEC)
203 205
206#define CPER_PROC_VALID_TYPE 0x0001
207#define CPER_PROC_VALID_ISA 0x0002
208#define CPER_PROC_VALID_ERROR_TYPE 0x0004
209#define CPER_PROC_VALID_OPERATION 0x0008
210#define CPER_PROC_VALID_FLAGS 0x0010
211#define CPER_PROC_VALID_LEVEL 0x0020
212#define CPER_PROC_VALID_VERSION 0x0040
213#define CPER_PROC_VALID_BRAND_INFO 0x0080
214#define CPER_PROC_VALID_ID 0x0100
215#define CPER_PROC_VALID_TARGET_ADDRESS 0x0200
216#define CPER_PROC_VALID_REQUESTOR_ID 0x0400
217#define CPER_PROC_VALID_RESPONDER_ID 0x0800
218#define CPER_PROC_VALID_IP 0x1000
219
220#define CPER_MEM_VALID_ERROR_STATUS 0x0001
221#define CPER_MEM_VALID_PHYSICAL_ADDRESS 0x0002
222#define CPER_MEM_VALID_PHYSICAL_ADDRESS_MASK 0x0004
223#define CPER_MEM_VALID_NODE 0x0008
224#define CPER_MEM_VALID_CARD 0x0010
225#define CPER_MEM_VALID_MODULE 0x0020
226#define CPER_MEM_VALID_BANK 0x0040
227#define CPER_MEM_VALID_DEVICE 0x0080
228#define CPER_MEM_VALID_ROW 0x0100
229#define CPER_MEM_VALID_COLUMN 0x0200
230#define CPER_MEM_VALID_BIT_POSITION 0x0400
231#define CPER_MEM_VALID_REQUESTOR_ID 0x0800
232#define CPER_MEM_VALID_RESPONDER_ID 0x1000
233#define CPER_MEM_VALID_TARGET_ID 0x2000
234#define CPER_MEM_VALID_ERROR_TYPE 0x4000
235
236#define CPER_PCIE_VALID_PORT_TYPE 0x0001
237#define CPER_PCIE_VALID_VERSION 0x0002
238#define CPER_PCIE_VALID_COMMAND_STATUS 0x0004
239#define CPER_PCIE_VALID_DEVICE_ID 0x0008
240#define CPER_PCIE_VALID_SERIAL_NUMBER 0x0010
241#define CPER_PCIE_VALID_BRIDGE_CONTROL_STATUS 0x0020
242#define CPER_PCIE_VALID_CAPABILITY 0x0040
243#define CPER_PCIE_VALID_AER_INFO 0x0080
244
245#define CPER_PCIE_SLOT_SHIFT 3
246
204/* 247/*
205 * All tables and structs must be byte-packed to match CPER 248 * All tables and structs must be byte-packed to match CPER
206 * specification, since the tables are provided by the system BIOS 249 * specification, since the tables are provided by the system BIOS
@@ -267,7 +310,7 @@ struct cper_sec_proc_ia {
267 __u8 cpuid[48]; 310 __u8 cpuid[48];
268}; 311};
269 312
270/* IA32/X64 Processor Error Infomation Structure */ 313/* IA32/X64 Processor Error Information Structure */
271struct cper_ia_err_info { 314struct cper_ia_err_info {
272 uuid_le err_type; 315 uuid_le err_type;
273 __u64 validation_bits; 316 __u64 validation_bits;
@@ -306,9 +349,46 @@ struct cper_sec_mem_err {
306 __u8 error_type; 349 __u8 error_type;
307}; 350};
308 351
352struct cper_sec_pcie {
353 __u64 validation_bits;
354 __u32 port_type;
355 struct {
356 __u8 minor;
357 __u8 major;
358 __u8 reserved[2];
359 } version;
360 __u16 command;
361 __u16 status;
362 __u32 reserved;
363 struct {
364 __u16 vendor_id;
365 __u16 device_id;
366 __u8 class_code[3];
367 __u8 function;
368 __u8 device;
369 __u16 segment;
370 __u8 bus;
371 __u8 secondary_bus;
372 __u16 slot;
373 __u8 reserved;
374 } device_id;
375 struct {
376 __u32 lower;
377 __u32 upper;
378 } serial_number;
379 struct {
380 __u16 secondary_status;
381 __u16 control;
382 } bridge;
383 __u8 capability[60];
384 __u8 aer_info[96];
385};
386
309/* Reset to default packing */ 387/* Reset to default packing */
310#pragma pack() 388#pragma pack()
311 389
312u64 cper_next_record_id(void); 390u64 cper_next_record_id(void);
391void cper_print_bits(const char *prefix, unsigned int bits,
392 const char *strs[], unsigned int strs_size);
313 393
314#endif 394#endif
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 4823af64e9db..5f09323ee880 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -10,11 +10,6 @@
10 * 10 *
11 * CPUs are exported via sysfs in the class/cpu/devices/ 11 * CPUs are exported via sysfs in the class/cpu/devices/
12 * directory. 12 * directory.
13 *
14 * Per-cpu interfaces can be implemented using a struct device_interface.
15 * See the following for how to do this:
16 * - drivers/base/intf.c
17 * - Documentation/driver-model/interface.txt
18 */ 13 */
19#ifndef _LINUX_CPU_H_ 14#ifndef _LINUX_CPU_H_
20#define _LINUX_CPU_H_ 15#define _LINUX_CPU_H_
diff --git a/include/linux/cpu_rmap.h b/include/linux/cpu_rmap.h
new file mode 100644
index 000000000000..473771a528c0
--- /dev/null
+++ b/include/linux/cpu_rmap.h
@@ -0,0 +1,73 @@
1/*
2 * cpu_rmap.c: CPU affinity reverse-map support
3 * Copyright 2011 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#include <linux/cpumask.h>
11#include <linux/gfp.h>
12#include <linux/slab.h>
13
14/**
15 * struct cpu_rmap - CPU affinity reverse-map
16 * @size: Number of objects to be reverse-mapped
17 * @used: Number of objects added
18 * @obj: Pointer to array of object pointers
19 * @near: For each CPU, the index and distance to the nearest object,
20 * based on affinity masks
21 */
22struct cpu_rmap {
23 u16 size, used;
24 void **obj;
25 struct {
26 u16 index;
27 u16 dist;
28 } near[0];
29};
30#define CPU_RMAP_DIST_INF 0xffff
31
32extern struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags);
33
34/**
35 * free_cpu_rmap - free CPU affinity reverse-map
36 * @rmap: Reverse-map allocated with alloc_cpu_rmap(), or %NULL
37 */
38static inline void free_cpu_rmap(struct cpu_rmap *rmap)
39{
40 kfree(rmap);
41}
42
43extern int cpu_rmap_add(struct cpu_rmap *rmap, void *obj);
44extern int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
45 const struct cpumask *affinity);
46
47static inline u16 cpu_rmap_lookup_index(struct cpu_rmap *rmap, unsigned int cpu)
48{
49 return rmap->near[cpu].index;
50}
51
52static inline void *cpu_rmap_lookup_obj(struct cpu_rmap *rmap, unsigned int cpu)
53{
54 return rmap->obj[rmap->near[cpu].index];
55}
56
57#ifdef CONFIG_GENERIC_HARDIRQS
58
59/**
60 * alloc_irq_cpu_rmap - allocate CPU affinity reverse-map for IRQs
61 * @size: Number of objects to be mapped
62 *
63 * Must be called in process context.
64 */
65static inline struct cpu_rmap *alloc_irq_cpu_rmap(unsigned int size)
66{
67 return alloc_cpu_rmap(size, GFP_KERNEL);
68}
69extern void free_irq_cpu_rmap(struct cpu_rmap *rmap);
70
71extern int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq);
72
73#endif
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index c3e9de8321c6..11be48e0d168 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001 Russell King 4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
@@ -56,9 +56,9 @@ static inline int cpufreq_unregister_notifier(struct notifier_block *nb,
56#define CPUFREQ_POLICY_POWERSAVE (1) 56#define CPUFREQ_POLICY_POWERSAVE (1)
57#define CPUFREQ_POLICY_PERFORMANCE (2) 57#define CPUFREQ_POLICY_PERFORMANCE (2)
58 58
59/* Frequency values here are CPU kHz so that hardware which doesn't run 59/* Frequency values here are CPU kHz so that hardware which doesn't run
60 * with some frequencies can complain without having to guess what per 60 * with some frequencies can complain without having to guess what per
61 * cent / per mille means. 61 * cent / per mille means.
62 * Maximum transition latency is in nanoseconds - if it's unknown, 62 * Maximum transition latency is in nanoseconds - if it's unknown,
63 * CPUFREQ_ETERNAL shall be used. 63 * CPUFREQ_ETERNAL shall be used.
64 */ 64 */
@@ -72,13 +72,15 @@ extern struct kobject *cpufreq_global_kobject;
72struct cpufreq_cpuinfo { 72struct cpufreq_cpuinfo {
73 unsigned int max_freq; 73 unsigned int max_freq;
74 unsigned int min_freq; 74 unsigned int min_freq;
75 unsigned int transition_latency; /* in 10^(-9) s = nanoseconds */ 75
76 /* in 10^(-9) s = nanoseconds */
77 unsigned int transition_latency;
76}; 78};
77 79
78struct cpufreq_real_policy { 80struct cpufreq_real_policy {
79 unsigned int min; /* in kHz */ 81 unsigned int min; /* in kHz */
80 unsigned int max; /* in kHz */ 82 unsigned int max; /* in kHz */
81 unsigned int policy; /* see above */ 83 unsigned int policy; /* see above */
82 struct cpufreq_governor *governor; /* see below */ 84 struct cpufreq_governor *governor; /* see below */
83}; 85};
84 86
@@ -94,7 +96,7 @@ struct cpufreq_policy {
94 unsigned int max; /* in kHz */ 96 unsigned int max; /* in kHz */
95 unsigned int cur; /* in kHz, only needed if cpufreq 97 unsigned int cur; /* in kHz, only needed if cpufreq
96 * governors are used */ 98 * governors are used */
97 unsigned int policy; /* see above */ 99 unsigned int policy; /* see above */
98 struct cpufreq_governor *governor; /* see below */ 100 struct cpufreq_governor *governor; /* see below */
99 101
100 struct work_struct update; /* if update_policy() needs to be 102 struct work_struct update; /* if update_policy() needs to be
@@ -167,11 +169,11 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu
167 169
168struct cpufreq_governor { 170struct cpufreq_governor {
169 char name[CPUFREQ_NAME_LEN]; 171 char name[CPUFREQ_NAME_LEN];
170 int (*governor) (struct cpufreq_policy *policy, 172 int (*governor) (struct cpufreq_policy *policy,
171 unsigned int event); 173 unsigned int event);
172 ssize_t (*show_setspeed) (struct cpufreq_policy *policy, 174 ssize_t (*show_setspeed) (struct cpufreq_policy *policy,
173 char *buf); 175 char *buf);
174 int (*store_setspeed) (struct cpufreq_policy *policy, 176 int (*store_setspeed) (struct cpufreq_policy *policy,
175 unsigned int freq); 177 unsigned int freq);
176 unsigned int max_transition_latency; /* HW must be able to switch to 178 unsigned int max_transition_latency; /* HW must be able to switch to
177 next freq faster than this value in nano secs or we 179 next freq faster than this value in nano secs or we
@@ -180,7 +182,8 @@ struct cpufreq_governor {
180 struct module *owner; 182 struct module *owner;
181}; 183};
182 184
183/* pass a target to the cpufreq driver 185/*
186 * Pass a target to the cpufreq driver.
184 */ 187 */
185extern int cpufreq_driver_target(struct cpufreq_policy *policy, 188extern int cpufreq_driver_target(struct cpufreq_policy *policy,
186 unsigned int target_freq, 189 unsigned int target_freq,
@@ -230,16 +233,16 @@ struct cpufreq_driver {
230 int (*bios_limit) (int cpu, unsigned int *limit); 233 int (*bios_limit) (int cpu, unsigned int *limit);
231 234
232 int (*exit) (struct cpufreq_policy *policy); 235 int (*exit) (struct cpufreq_policy *policy);
233 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg); 236 int (*suspend) (struct cpufreq_policy *policy);
234 int (*resume) (struct cpufreq_policy *policy); 237 int (*resume) (struct cpufreq_policy *policy);
235 struct freq_attr **attr; 238 struct freq_attr **attr;
236}; 239};
237 240
238/* flags */ 241/* flags */
239 242
240#define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if 243#define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
241 * all ->init() calls failed */ 244 * all ->init() calls failed */
242#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel 245#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel
243 * "constants" aren't affected by 246 * "constants" aren't affected by
244 * frequency transitions */ 247 * frequency transitions */
245#define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed 248#define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed
@@ -252,7 +255,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
252void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state); 255void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state);
253 256
254 257
255static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) 258static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max)
256{ 259{
257 if (policy->min < min) 260 if (policy->min < min)
258 policy->min = min; 261 policy->min = min;
@@ -281,19 +284,10 @@ __ATTR(_name, 0444, show_##_name, NULL)
281static struct freq_attr _name = \ 284static struct freq_attr _name = \
282__ATTR(_name, _perm, show_##_name, NULL) 285__ATTR(_name, _perm, show_##_name, NULL)
283 286
284#define cpufreq_freq_attr_ro_old(_name) \
285static struct freq_attr _name##_old = \
286__ATTR(_name, 0444, show_##_name##_old, NULL)
287
288#define cpufreq_freq_attr_rw(_name) \ 287#define cpufreq_freq_attr_rw(_name) \
289static struct freq_attr _name = \ 288static struct freq_attr _name = \
290__ATTR(_name, 0644, show_##_name, store_##_name) 289__ATTR(_name, 0644, show_##_name, store_##_name)
291 290
292#define cpufreq_freq_attr_rw_old(_name) \
293static struct freq_attr _name##_old = \
294__ATTR(_name, 0644, show_##_name##_old, store_##_name##_old)
295
296
297struct global_attr { 291struct global_attr {
298 struct attribute attr; 292 struct attribute attr;
299 ssize_t (*show)(struct kobject *kobj, 293 ssize_t (*show)(struct kobject *kobj,
@@ -395,34 +389,15 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
395/* the following 3 funtions are for cpufreq core use only */ 389/* the following 3 funtions are for cpufreq core use only */
396struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu); 390struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
397struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); 391struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
398void cpufreq_cpu_put (struct cpufreq_policy *data); 392void cpufreq_cpu_put(struct cpufreq_policy *data);
399 393
400/* the following are really really optional */ 394/* the following are really really optional */
401extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; 395extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
402 396
403void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, 397void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
404 unsigned int cpu); 398 unsigned int cpu);
405 399
406void cpufreq_frequency_table_put_attr(unsigned int cpu); 400void cpufreq_frequency_table_put_attr(unsigned int cpu);
407 401
408 402
409/*********************************************************************
410 * UNIFIED DEBUG HELPERS *
411 *********************************************************************/
412
413#define CPUFREQ_DEBUG_CORE 1
414#define CPUFREQ_DEBUG_DRIVER 2
415#define CPUFREQ_DEBUG_GOVERNOR 4
416
417#ifdef CONFIG_CPU_FREQ_DEBUG
418
419extern void cpufreq_debug_printk(unsigned int type, const char *prefix,
420 const char *fmt, ...);
421
422#else
423
424#define cpufreq_debug_printk(msg...) do { } while(0)
425
426#endif /* CONFIG_CPU_FREQ_DEBUG */
427
428#endif /* _LINUX_CPUFREQ_H */ 403#endif /* _LINUX_CPUFREQ_H */
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 1be416bbbb82..36719ead50e8 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -47,13 +47,7 @@ struct cpuidle_state {
47 47
48/* Idle State Flags */ 48/* Idle State Flags */
49#define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */ 49#define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
50#define CPUIDLE_FLAG_CHECK_BM (0x02) /* BM activity will exit state */
51#define CPUIDLE_FLAG_POLL (0x10) /* no latency, no savings */
52#define CPUIDLE_FLAG_SHALLOW (0x20) /* low latency, minimal savings */
53#define CPUIDLE_FLAG_BALANCED (0x40) /* medium latency, moderate savings */
54#define CPUIDLE_FLAG_DEEP (0x80) /* high latency, large savings */
55#define CPUIDLE_FLAG_IGNORE (0x100) /* ignore during this idle period */ 50#define CPUIDLE_FLAG_IGNORE (0x100) /* ignore during this idle period */
56#define CPUIDLE_FLAG_TLB_FLUSHED (0x200) /* tlb will be flushed */
57 51
58#define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) 52#define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000)
59 53
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index bae6fe24d1f9..b24ac56477b4 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -547,6 +547,21 @@ static inline int cpumask_parse_user(const char __user *buf, int len,
547} 547}
548 548
549/** 549/**
550 * cpumask_parselist_user - extract a cpumask from a user string
551 * @buf: the buffer to extract from
552 * @len: the length of the buffer
553 * @dstp: the cpumask to set.
554 *
555 * Returns -errno, or 0 for success.
556 */
557static inline int cpumask_parselist_user(const char __user *buf, int len,
558 struct cpumask *dstp)
559{
560 return bitmap_parselist_user(buf, len, cpumask_bits(dstp),
561 nr_cpumask_bits);
562}
563
564/**
550 * cpulist_scnprintf - print a cpumask into a string as comma-separated list 565 * cpulist_scnprintf - print a cpumask into a string as comma-separated list
551 * @buf: the buffer to sprintf into 566 * @buf: the buffer to sprintf into
552 * @len: the length of the buffer 567 * @len: the length of the buffer
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index f20eb8f16025..e9eaec522655 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -146,7 +146,7 @@ static inline void cpuset_cpus_allowed(struct task_struct *p,
146 146
147static inline int cpuset_cpus_allowed_fallback(struct task_struct *p) 147static inline int cpuset_cpus_allowed_fallback(struct task_struct *p)
148{ 148{
149 cpumask_copy(&p->cpus_allowed, cpu_possible_mask); 149 do_set_cpus_allowed(p, cpu_possible_mask);
150 return cpumask_any(cpu_active_mask); 150 return cpumask_any(cpu_active_mask);
151} 151}
152 152
diff --git a/include/linux/cramfs_fs.h b/include/linux/cramfs_fs.h
index 6fc2bed368b8..0e7bf272ec2f 100644
--- a/include/linux/cramfs_fs.h
+++ b/include/linux/cramfs_fs.h
@@ -84,9 +84,11 @@ struct cramfs_super {
84 | CRAMFS_FLAG_WRONG_SIGNATURE \ 84 | CRAMFS_FLAG_WRONG_SIGNATURE \
85 | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET ) 85 | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET )
86 86
87#ifdef __KERNEL__
87/* Uncompression interfaces to the underlying zlib */ 88/* Uncompression interfaces to the underlying zlib */
88int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen); 89int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen);
89int cramfs_uncompress_init(void); 90int cramfs_uncompress_init(void);
90void cramfs_uncompress_exit(void); 91void cramfs_uncompress_exit(void);
92#endif /* __KERNEL__ */
91 93
92#endif 94#endif
diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h
index 0026f267da20..74054074e876 100644
--- a/include/linux/crash_dump.h
+++ b/include/linux/crash_dump.h
@@ -20,7 +20,14 @@ extern ssize_t copy_oldmem_page(unsigned long, char *, size_t,
20#define vmcore_elf_check_arch_cross(x) 0 20#define vmcore_elf_check_arch_cross(x) 0
21#endif 21#endif
22 22
23#define vmcore_elf_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x)) 23/*
24 * Architecture code can redefine this if there are any special checks
25 * needed for 64-bit ELF vmcores. In case of 32-bit only architecture,
26 * this can be set to zero.
27 */
28#ifndef vmcore_elf64_check_arch
29#define vmcore_elf64_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))
30#endif
24 31
25/* 32/*
26 * is_kdump_kernel() checks whether this kernel is booting after a panic of 33 * is_kdump_kernel() checks whether this kernel is booting after a panic of
@@ -59,6 +66,11 @@ static inline void vmcore_unusable(void)
59 if (is_kdump_kernel()) 66 if (is_kdump_kernel())
60 elfcorehdr_addr = ELFCORE_ADDR_ERR; 67 elfcorehdr_addr = ELFCORE_ADDR_ERR;
61} 68}
69
70#define HAVE_OLDMEM_PFN_IS_RAM 1
71extern int register_oldmem_pfn_is_ram(int (*fn)(unsigned long pfn));
72extern void unregister_oldmem_pfn_is_ram(void);
73
62#else /* !CONFIG_CRASH_DUMP */ 74#else /* !CONFIG_CRASH_DUMP */
63static inline int is_kdump_kernel(void) { return 0; } 75static inline int is_kdump_kernel(void) { return 0; }
64#endif /* CONFIG_CRASH_DUMP */ 76#endif /* CONFIG_CRASH_DUMP */
diff --git a/include/linux/crc32.h b/include/linux/crc32.h
index e20dd1f9b40a..391a259b2cc9 100644
--- a/include/linux/crc32.h
+++ b/include/linux/crc32.h
@@ -11,7 +11,7 @@
11extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len); 11extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);
12extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len); 12extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len);
13 13
14#define crc32(seed, data, length) crc32_le(seed, (unsigned char const *)data, length) 14#define crc32(seed, data, length) crc32_le(seed, (unsigned char const *)(data), length)
15 15
16/* 16/*
17 * Helpers for hash table generation of ethernet nics: 17 * Helpers for hash table generation of ethernet nics:
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 4d2c39573f36..82607992f308 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -1,4 +1,4 @@
1/* Credentials management - see Documentation/credentials.txt 1/* Credentials management - see Documentation/security/credentials.txt
2 * 2 *
3 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
@@ -84,7 +84,7 @@ struct thread_group_cred {
84 atomic_t usage; 84 atomic_t usage;
85 pid_t tgid; /* thread group process ID */ 85 pid_t tgid; /* thread group process ID */
86 spinlock_t lock; 86 spinlock_t lock;
87 struct key *session_keyring; /* keyring inherited over fork */ 87 struct key __rcu *session_keyring; /* keyring inherited over fork */
88 struct key *process_keyring; /* keyring private to this process */ 88 struct key *process_keyring; /* keyring private to this process */
89 struct rcu_head rcu; /* RCU deletion hook */ 89 struct rcu_head rcu; /* RCU deletion hook */
90}; 90};
@@ -146,6 +146,7 @@ struct cred {
146 void *security; /* subjective LSM security */ 146 void *security; /* subjective LSM security */
147#endif 147#endif
148 struct user_struct *user; /* real user ID subscription */ 148 struct user_struct *user; /* real user ID subscription */
149 struct user_namespace *user_ns; /* cached user->user_ns */
149 struct group_info *group_info; /* supplementary groups for euid/fsgid */ 150 struct group_info *group_info; /* supplementary groups for euid/fsgid */
150 struct rcu_head rcu; /* RCU deletion hook */ 151 struct rcu_head rcu; /* RCU deletion hook */
151}; 152};
@@ -354,9 +355,16 @@ static inline void put_cred(const struct cred *_cred)
354#define current_fsgid() (current_cred_xxx(fsgid)) 355#define current_fsgid() (current_cred_xxx(fsgid))
355#define current_cap() (current_cred_xxx(cap_effective)) 356#define current_cap() (current_cred_xxx(cap_effective))
356#define current_user() (current_cred_xxx(user)) 357#define current_user() (current_cred_xxx(user))
357#define current_user_ns() (current_cred_xxx(user)->user_ns)
358#define current_security() (current_cred_xxx(security)) 358#define current_security() (current_cred_xxx(security))
359 359
360#ifdef CONFIG_USER_NS
361#define current_user_ns() (current_cred_xxx(user_ns))
362#else
363extern struct user_namespace init_user_ns;
364#define current_user_ns() (&init_user_ns)
365#endif
366
367
360#define current_uid_gid(_uid, _gid) \ 368#define current_uid_gid(_uid, _gid) \
361do { \ 369do { \
362 const struct cred *__cred; \ 370 const struct cred *__cred; \
diff --git a/include/linux/crush/crush.h b/include/linux/crush/crush.h
new file mode 100644
index 000000000000..97e435b191f4
--- /dev/null
+++ b/include/linux/crush/crush.h
@@ -0,0 +1,180 @@
1#ifndef CEPH_CRUSH_CRUSH_H
2#define CEPH_CRUSH_CRUSH_H
3
4#include <linux/types.h>
5
6/*
7 * CRUSH is a pseudo-random data distribution algorithm that
8 * efficiently distributes input values (typically, data objects)
9 * across a heterogeneous, structured storage cluster.
10 *
11 * The algorithm was originally described in detail in this paper
12 * (although the algorithm has evolved somewhat since then):
13 *
14 * http://www.ssrc.ucsc.edu/Papers/weil-sc06.pdf
15 *
16 * LGPL2
17 */
18
19
20#define CRUSH_MAGIC 0x00010000ul /* for detecting algorithm revisions */
21
22
23#define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */
24#define CRUSH_MAX_SET 10 /* max size of a mapping result */
25
26
27/*
28 * CRUSH uses user-defined "rules" to describe how inputs should be
29 * mapped to devices. A rule consists of sequence of steps to perform
30 * to generate the set of output devices.
31 */
32struct crush_rule_step {
33 __u32 op;
34 __s32 arg1;
35 __s32 arg2;
36};
37
38/* step op codes */
39enum {
40 CRUSH_RULE_NOOP = 0,
41 CRUSH_RULE_TAKE = 1, /* arg1 = value to start with */
42 CRUSH_RULE_CHOOSE_FIRSTN = 2, /* arg1 = num items to pick */
43 /* arg2 = type */
44 CRUSH_RULE_CHOOSE_INDEP = 3, /* same */
45 CRUSH_RULE_EMIT = 4, /* no args */
46 CRUSH_RULE_CHOOSE_LEAF_FIRSTN = 6,
47 CRUSH_RULE_CHOOSE_LEAF_INDEP = 7,
48};
49
50/*
51 * for specifying choose num (arg1) relative to the max parameter
52 * passed to do_rule
53 */
54#define CRUSH_CHOOSE_N 0
55#define CRUSH_CHOOSE_N_MINUS(x) (-(x))
56
57/*
58 * The rule mask is used to describe what the rule is intended for.
59 * Given a ruleset and size of output set, we search through the
60 * rule list for a matching rule_mask.
61 */
62struct crush_rule_mask {
63 __u8 ruleset;
64 __u8 type;
65 __u8 min_size;
66 __u8 max_size;
67};
68
69struct crush_rule {
70 __u32 len;
71 struct crush_rule_mask mask;
72 struct crush_rule_step steps[0];
73};
74
75#define crush_rule_size(len) (sizeof(struct crush_rule) + \
76 (len)*sizeof(struct crush_rule_step))
77
78
79
80/*
81 * A bucket is a named container of other items (either devices or
82 * other buckets). Items within a bucket are chosen using one of a
83 * few different algorithms. The table summarizes how the speed of
84 * each option measures up against mapping stability when items are
85 * added or removed.
86 *
87 * Bucket Alg Speed Additions Removals
88 * ------------------------------------------------
89 * uniform O(1) poor poor
90 * list O(n) optimal poor
91 * tree O(log n) good good
92 * straw O(n) optimal optimal
93 */
94enum {
95 CRUSH_BUCKET_UNIFORM = 1,
96 CRUSH_BUCKET_LIST = 2,
97 CRUSH_BUCKET_TREE = 3,
98 CRUSH_BUCKET_STRAW = 4
99};
100extern const char *crush_bucket_alg_name(int alg);
101
102struct crush_bucket {
103 __s32 id; /* this'll be negative */
104 __u16 type; /* non-zero; type=0 is reserved for devices */
105 __u8 alg; /* one of CRUSH_BUCKET_* */
106 __u8 hash; /* which hash function to use, CRUSH_HASH_* */
107 __u32 weight; /* 16-bit fixed point */
108 __u32 size; /* num items */
109 __s32 *items;
110
111 /*
112 * cached random permutation: used for uniform bucket and for
113 * the linear search fallback for the other bucket types.
114 */
115 __u32 perm_x; /* @x for which *perm is defined */
116 __u32 perm_n; /* num elements of *perm that are permuted/defined */
117 __u32 *perm;
118};
119
120struct crush_bucket_uniform {
121 struct crush_bucket h;
122 __u32 item_weight; /* 16-bit fixed point; all items equally weighted */
123};
124
125struct crush_bucket_list {
126 struct crush_bucket h;
127 __u32 *item_weights; /* 16-bit fixed point */
128 __u32 *sum_weights; /* 16-bit fixed point. element i is sum
129 of weights 0..i, inclusive */
130};
131
132struct crush_bucket_tree {
133 struct crush_bucket h; /* note: h.size is _tree_ size, not number of
134 actual items */
135 __u8 num_nodes;
136 __u32 *node_weights;
137};
138
139struct crush_bucket_straw {
140 struct crush_bucket h;
141 __u32 *item_weights; /* 16-bit fixed point */
142 __u32 *straws; /* 16-bit fixed point */
143};
144
145
146
147/*
148 * CRUSH map includes all buckets, rules, etc.
149 */
150struct crush_map {
151 struct crush_bucket **buckets;
152 struct crush_rule **rules;
153
154 /*
155 * Parent pointers to identify the parent bucket a device or
156 * bucket in the hierarchy. If an item appears more than
157 * once, this is the _last_ time it appeared (where buckets
158 * are processed in bucket id order, from -1 on down to
159 * -max_buckets.
160 */
161 __u32 *bucket_parents;
162 __u32 *device_parents;
163
164 __s32 max_buckets;
165 __u32 max_rules;
166 __s32 max_devices;
167};
168
169
170/* crush.c */
171extern int crush_get_bucket_item_weight(struct crush_bucket *b, int pos);
172extern void crush_calc_parents(struct crush_map *map);
173extern void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b);
174extern void crush_destroy_bucket_list(struct crush_bucket_list *b);
175extern void crush_destroy_bucket_tree(struct crush_bucket_tree *b);
176extern void crush_destroy_bucket_straw(struct crush_bucket_straw *b);
177extern void crush_destroy_bucket(struct crush_bucket *b);
178extern void crush_destroy(struct crush_map *map);
179
180#endif
diff --git a/include/linux/crush/hash.h b/include/linux/crush/hash.h
new file mode 100644
index 000000000000..91e884230d5d
--- /dev/null
+++ b/include/linux/crush/hash.h
@@ -0,0 +1,17 @@
1#ifndef CEPH_CRUSH_HASH_H
2#define CEPH_CRUSH_HASH_H
3
4#define CRUSH_HASH_RJENKINS1 0
5
6#define CRUSH_HASH_DEFAULT CRUSH_HASH_RJENKINS1
7
8extern const char *crush_hash_name(int type);
9
10extern __u32 crush_hash32(int type, __u32 a);
11extern __u32 crush_hash32_2(int type, __u32 a, __u32 b);
12extern __u32 crush_hash32_3(int type, __u32 a, __u32 b, __u32 c);
13extern __u32 crush_hash32_4(int type, __u32 a, __u32 b, __u32 c, __u32 d);
14extern __u32 crush_hash32_5(int type, __u32 a, __u32 b, __u32 c, __u32 d,
15 __u32 e);
16
17#endif
diff --git a/include/linux/crush/mapper.h b/include/linux/crush/mapper.h
new file mode 100644
index 000000000000..c46b99c18bb0
--- /dev/null
+++ b/include/linux/crush/mapper.h
@@ -0,0 +1,20 @@
1#ifndef CEPH_CRUSH_MAPPER_H
2#define CEPH_CRUSH_MAPPER_H
3
4/*
5 * CRUSH functions for find rules and then mapping an input to an
6 * output set.
7 *
8 * LGPL2
9 */
10
11#include "crush.h"
12
13extern int crush_find_rule(struct crush_map *map, int pool, int type, int size);
14extern int crush_do_rule(struct crush_map *map,
15 int ruleno,
16 int x, int *result, int result_max,
17 int forcefeed, /* -1 for none */
18 __u32 *weights);
19
20#endif
diff --git a/include/linux/cs5535.h b/include/linux/cs5535.h
index d5a1d4810b80..6fe2114f8ad2 100644
--- a/include/linux/cs5535.h
+++ b/include/linux/cs5535.h
@@ -103,14 +103,20 @@ static inline int cs5535_has_vsa2(void)
103#define GPIO_POSITIVE_EDGE_STS 0x48 103#define GPIO_POSITIVE_EDGE_STS 0x48
104#define GPIO_NEGATIVE_EDGE_STS 0x4C 104#define GPIO_NEGATIVE_EDGE_STS 0x4C
105 105
106#define GPIO_FLTR7_AMOUNT 0xD8
107
106#define GPIO_MAP_X 0xE0 108#define GPIO_MAP_X 0xE0
107#define GPIO_MAP_Y 0xE4 109#define GPIO_MAP_Y 0xE4
108#define GPIO_MAP_Z 0xE8 110#define GPIO_MAP_Z 0xE8
109#define GPIO_MAP_W 0xEC 111#define GPIO_MAP_W 0xEC
110 112
113#define GPIO_FE7_SEL 0xF7
114
111void cs5535_gpio_set(unsigned offset, unsigned int reg); 115void cs5535_gpio_set(unsigned offset, unsigned int reg);
112void cs5535_gpio_clear(unsigned offset, unsigned int reg); 116void cs5535_gpio_clear(unsigned offset, unsigned int reg);
113int cs5535_gpio_isset(unsigned offset, unsigned int reg); 117int cs5535_gpio_isset(unsigned offset, unsigned int reg);
118int cs5535_gpio_set_irq(unsigned group, unsigned irq);
119void cs5535_gpio_setup_event(unsigned offset, int pair, int pme);
114 120
115/* MFGPTs */ 121/* MFGPTs */
116 122
diff --git a/include/linux/davinci_emac.h b/include/linux/davinci_emac.h
index 7c930dba477c..542888504994 100644
--- a/include/linux/davinci_emac.h
+++ b/include/linux/davinci_emac.h
@@ -14,18 +14,29 @@
14#include <linux/if_ether.h> 14#include <linux/if_ether.h>
15#include <linux/memory.h> 15#include <linux/memory.h>
16 16
17struct mdio_platform_data {
18 unsigned long bus_freq;
19};
20
17struct emac_platform_data { 21struct emac_platform_data {
18 char mac_addr[ETH_ALEN]; 22 char mac_addr[ETH_ALEN];
19 u32 ctrl_reg_offset; 23 u32 ctrl_reg_offset;
20 u32 ctrl_mod_reg_offset; 24 u32 ctrl_mod_reg_offset;
21 u32 ctrl_ram_offset; 25 u32 ctrl_ram_offset;
22 u32 hw_ram_addr; 26 u32 hw_ram_addr;
23 u32 mdio_reg_offset;
24 u32 ctrl_ram_size; 27 u32 ctrl_ram_size;
25 u32 phy_mask; 28
26 u32 mdio_max_freq; 29 /*
30 * phy_id can be one of the following:
31 * - NULL : use the first phy on the bus,
32 * - "" : force to 100/full, no mdio control
33 * - "<bus>:<addr>" : use the specified bus and phy
34 */
35 const char *phy_id;
36
27 u8 rmii_en; 37 u8 rmii_en;
28 u8 version; 38 u8 version;
39 bool no_bd_ram;
29 void (*interrupt_enable) (void); 40 void (*interrupt_enable) (void);
30 void (*interrupt_disable) (void); 41 void (*interrupt_disable) (void);
31}; 42};
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 6a4aea30aa09..19d90a55541d 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -4,7 +4,9 @@
4#include <asm/atomic.h> 4#include <asm/atomic.h>
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/rculist.h> 6#include <linux/rculist.h>
7#include <linux/rculist_bl.h>
7#include <linux/spinlock.h> 8#include <linux/spinlock.h>
9#include <linux/seqlock.h>
8#include <linux/cache.h> 10#include <linux/cache.h>
9#include <linux/rcupdate.h> 11#include <linux/rcupdate.h>
10 12
@@ -45,6 +47,27 @@ struct dentry_stat_t {
45}; 47};
46extern struct dentry_stat_t dentry_stat; 48extern struct dentry_stat_t dentry_stat;
47 49
50/*
51 * Compare 2 name strings, return 0 if they match, otherwise non-zero.
52 * The strings are both count bytes long, and count is non-zero.
53 */
54static inline int dentry_cmp(const unsigned char *cs, size_t scount,
55 const unsigned char *ct, size_t tcount)
56{
57 int ret;
58 if (scount != tcount)
59 return 1;
60 do {
61 ret = (*cs != *ct);
62 if (ret)
63 break;
64 cs++;
65 ct++;
66 tcount--;
67 } while (tcount);
68 return ret;
69}
70
48/* Name hashing routines. Initial hash value */ 71/* Name hashing routines. Initial hash value */
49/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */ 72/* Hash courtesy of the R5 hash in reiserfs modulo sign bits */
50#define init_name_hash() 0 73#define init_name_hash() 0
@@ -81,25 +104,33 @@ full_name_hash(const unsigned char *name, unsigned int len)
81 * large memory footprint increase). 104 * large memory footprint increase).
82 */ 105 */
83#ifdef CONFIG_64BIT 106#ifdef CONFIG_64BIT
84#define DNAME_INLINE_LEN_MIN 32 /* 192 bytes */ 107# define DNAME_INLINE_LEN 32 /* 192 bytes */
85#else 108#else
86#define DNAME_INLINE_LEN_MIN 40 /* 128 bytes */ 109# ifdef CONFIG_SMP
110# define DNAME_INLINE_LEN 36 /* 128 bytes */
111# else
112# define DNAME_INLINE_LEN 40 /* 128 bytes */
113# endif
87#endif 114#endif
88 115
89struct dentry { 116struct dentry {
90 atomic_t d_count; 117 /* RCU lookup touched fields */
91 unsigned int d_flags; /* protected by d_lock */ 118 unsigned int d_flags; /* protected by d_lock */
92 spinlock_t d_lock; /* per dentry lock */ 119 seqcount_t d_seq; /* per dentry seqlock */
93 int d_mounted; 120 struct hlist_bl_node d_hash; /* lookup hash list */
94 struct inode *d_inode; /* Where the name belongs to - NULL is
95 * negative */
96 /*
97 * The next three fields are touched by __d_lookup. Place them here
98 * so they all fit in a cache line.
99 */
100 struct hlist_node d_hash; /* lookup hash list */
101 struct dentry *d_parent; /* parent directory */ 121 struct dentry *d_parent; /* parent directory */
102 struct qstr d_name; 122 struct qstr d_name;
123 struct inode *d_inode; /* Where the name belongs to - NULL is
124 * negative */
125 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
126
127 /* Ref lookup also touches following */
128 unsigned int d_count; /* protected by d_lock */
129 spinlock_t d_lock; /* per dentry lock */
130 const struct dentry_operations *d_op;
131 struct super_block *d_sb; /* The root of the dentry tree */
132 unsigned long d_time; /* used by d_revalidate */
133 void *d_fsdata; /* fs-specific data */
103 134
104 struct list_head d_lru; /* LRU list */ 135 struct list_head d_lru; /* LRU list */
105 /* 136 /*
@@ -111,12 +142,6 @@ struct dentry {
111 } d_u; 142 } d_u;
112 struct list_head d_subdirs; /* our children */ 143 struct list_head d_subdirs; /* our children */
113 struct list_head d_alias; /* inode alias list */ 144 struct list_head d_alias; /* inode alias list */
114 unsigned long d_time; /* used by d_revalidate */
115 const struct dentry_operations *d_op;
116 struct super_block *d_sb; /* The root of the dentry tree */
117 void *d_fsdata; /* fs-specific data */
118
119 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */
120}; 145};
121 146
122/* 147/*
@@ -133,96 +158,68 @@ enum dentry_d_lock_class
133 158
134struct dentry_operations { 159struct dentry_operations {
135 int (*d_revalidate)(struct dentry *, struct nameidata *); 160 int (*d_revalidate)(struct dentry *, struct nameidata *);
136 int (*d_hash) (struct dentry *, struct qstr *); 161 int (*d_hash)(const struct dentry *, const struct inode *,
137 int (*d_compare) (struct dentry *, struct qstr *, struct qstr *); 162 struct qstr *);
138 int (*d_delete)(struct dentry *); 163 int (*d_compare)(const struct dentry *, const struct inode *,
164 const struct dentry *, const struct inode *,
165 unsigned int, const char *, const struct qstr *);
166 int (*d_delete)(const struct dentry *);
139 void (*d_release)(struct dentry *); 167 void (*d_release)(struct dentry *);
140 void (*d_iput)(struct dentry *, struct inode *); 168 void (*d_iput)(struct dentry *, struct inode *);
141 char *(*d_dname)(struct dentry *, char *, int); 169 char *(*d_dname)(struct dentry *, char *, int);
142}; 170 struct vfsmount *(*d_automount)(struct path *);
143 171 int (*d_manage)(struct dentry *, bool);
144/* the dentry parameter passed to d_hash and d_compare is the parent 172} ____cacheline_aligned;
145 * directory of the entries to be compared. It is used in case these
146 * functions need any directory specific information for determining
147 * equivalency classes. Using the dentry itself might not work, as it
148 * might be a negative dentry which has no information associated with
149 * it */
150 173
151/* 174/*
152locking rules: 175 * Locking rules for dentry_operations callbacks are to be found in
153 big lock dcache_lock d_lock may block 176 * Documentation/filesystems/Locking. Keep it updated!
154d_revalidate: no no no yes 177 *
155d_hash no no no yes 178 * FUrther descriptions are found in Documentation/filesystems/vfs.txt.
156d_compare: no yes yes no 179 * Keep it updated too!
157d_delete: no yes no no
158d_release: no no no yes
159d_iput: no no no yes
160 */ 180 */
161 181
162/* d_flags entries */ 182/* d_flags entries */
163#define DCACHE_AUTOFS_PENDING 0x0001 /* autofs: "under construction" */ 183#define DCACHE_AUTOFS_PENDING 0x0001 /* autofs: "under construction" */
164#define DCACHE_NFSFS_RENAMED 0x0002 /* this dentry has been "silly 184#define DCACHE_NFSFS_RENAMED 0x0002
165 * renamed" and has to be 185 /* this dentry has been "silly renamed" and has to be deleted on the last
166 * deleted on the last dput() 186 * dput() */
167 */ 187
168#define DCACHE_DISCONNECTED 0x0004 188#define DCACHE_DISCONNECTED 0x0004
169 /* This dentry is possibly not currently connected to the dcache tree, 189 /* This dentry is possibly not currently connected to the dcache tree, in
170 * in which case its parent will either be itself, or will have this 190 * which case its parent will either be itself, or will have this flag as
171 * flag as well. nfsd will not use a dentry with this bit set, but will 191 * well. nfsd will not use a dentry with this bit set, but will first
172 * first endeavour to clear the bit either by discovering that it is 192 * endeavour to clear the bit either by discovering that it is connected,
173 * connected, or by performing lookup operations. Any filesystem which 193 * or by performing lookup operations. Any filesystem which supports
174 * supports nfsd_operations MUST have a lookup function which, if it finds 194 * nfsd_operations MUST have a lookup function which, if it finds a
175 * a directory inode with a DCACHE_DISCONNECTED dentry, will d_move 195 * directory inode with a DCACHE_DISCONNECTED dentry, will d_move that
176 * that dentry into place and return that dentry rather than the passed one, 196 * dentry into place and return that dentry rather than the passed one,
177 * typically using d_splice_alias. 197 * typically using d_splice_alias. */
178 */
179 198
180#define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */ 199#define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
181#define DCACHE_UNHASHED 0x0010 200#define DCACHE_RCUACCESS 0x0010 /* Entry has ever been RCU-visible */
182 201#define DCACHE_INOTIFY_PARENT_WATCHED 0x0020
183#define DCACHE_INOTIFY_PARENT_WATCHED 0x0020 /* Parent inode is watched by inotify */ 202 /* Parent inode is watched by inotify */
184 203
185#define DCACHE_COOKIE 0x0040 /* For use by dcookie subsystem */ 204#define DCACHE_COOKIE 0x0040 /* For use by dcookie subsystem */
186 205#define DCACHE_FSNOTIFY_PARENT_WATCHED 0x0080
187#define DCACHE_FSNOTIFY_PARENT_WATCHED 0x0080 /* Parent inode is watched by some fsnotify listener */ 206 /* Parent inode is watched by some fsnotify listener */
188 207
189#define DCACHE_CANT_MOUNT 0x0100 208#define DCACHE_CANT_MOUNT 0x0100
209#define DCACHE_GENOCIDE 0x0200
190 210
191extern spinlock_t dcache_lock; 211#define DCACHE_OP_HASH 0x1000
192extern seqlock_t rename_lock; 212#define DCACHE_OP_COMPARE 0x2000
193 213#define DCACHE_OP_REVALIDATE 0x4000
194/** 214#define DCACHE_OP_DELETE 0x8000
195 * d_drop - drop a dentry
196 * @dentry: dentry to drop
197 *
198 * d_drop() unhashes the entry from the parent dentry hashes, so that it won't
199 * be found through a VFS lookup any more. Note that this is different from
200 * deleting the dentry - d_delete will try to mark the dentry negative if
201 * possible, giving a successful _negative_ lookup, while d_drop will
202 * just make the cache lookup fail.
203 *
204 * d_drop() is used mainly for stuff that wants to invalidate a dentry for some
205 * reason (NFS timeouts or autofs deletes).
206 *
207 * __d_drop requires dentry->d_lock.
208 */
209 215
210static inline void __d_drop(struct dentry *dentry) 216#define DCACHE_MOUNTED 0x10000 /* is a mountpoint */
211{ 217#define DCACHE_NEED_AUTOMOUNT 0x20000 /* handle automount on this dir */
212 if (!(dentry->d_flags & DCACHE_UNHASHED)) { 218#define DCACHE_MANAGE_TRANSIT 0x40000 /* manage transit from this dirent */
213 dentry->d_flags |= DCACHE_UNHASHED; 219#define DCACHE_MANAGED_DENTRY \
214 hlist_del_rcu(&dentry->d_hash); 220 (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT)
215 }
216}
217 221
218static inline void d_drop(struct dentry *dentry) 222extern seqlock_t rename_lock;
219{
220 spin_lock(&dcache_lock);
221 spin_lock(&dentry->d_lock);
222 __d_drop(dentry);
223 spin_unlock(&dentry->d_lock);
224 spin_unlock(&dcache_lock);
225}
226 223
227static inline int dname_external(struct dentry *dentry) 224static inline int dname_external(struct dentry *dentry)
228{ 225{
@@ -235,10 +232,14 @@ static inline int dname_external(struct dentry *dentry)
235extern void d_instantiate(struct dentry *, struct inode *); 232extern void d_instantiate(struct dentry *, struct inode *);
236extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *); 233extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *);
237extern struct dentry * d_materialise_unique(struct dentry *, struct inode *); 234extern struct dentry * d_materialise_unique(struct dentry *, struct inode *);
235extern void __d_drop(struct dentry *dentry);
236extern void d_drop(struct dentry *dentry);
238extern void d_delete(struct dentry *); 237extern void d_delete(struct dentry *);
238extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op);
239 239
240/* allocate/de-allocate */ 240/* allocate/de-allocate */
241extern struct dentry * d_alloc(struct dentry *, const struct qstr *); 241extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
242extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
242extern struct dentry * d_splice_alias(struct inode *, struct dentry *); 243extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
243extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *); 244extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
244extern struct dentry * d_obtain_alias(struct inode *); 245extern struct dentry * d_obtain_alias(struct inode *);
@@ -296,14 +297,40 @@ static inline struct dentry *d_add_unique(struct dentry *entry, struct inode *in
296 return res; 297 return res;
297} 298}
298 299
300extern void dentry_update_name_case(struct dentry *, struct qstr *);
301
299/* used for rename() and baskets */ 302/* used for rename() and baskets */
300extern void d_move(struct dentry *, struct dentry *); 303extern void d_move(struct dentry *, struct dentry *);
301extern struct dentry *d_ancestor(struct dentry *, struct dentry *); 304extern struct dentry *d_ancestor(struct dentry *, struct dentry *);
302 305
303/* appendix may either be NULL or be used for transname suffixes */ 306/* appendix may either be NULL or be used for transname suffixes */
304extern struct dentry * d_lookup(struct dentry *, struct qstr *); 307extern struct dentry *d_lookup(struct dentry *, struct qstr *);
305extern struct dentry * __d_lookup(struct dentry *, struct qstr *); 308extern struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *);
306extern struct dentry * d_hash_and_lookup(struct dentry *, struct qstr *); 309extern struct dentry *__d_lookup(struct dentry *, struct qstr *);
310extern struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name,
311 unsigned *seq, struct inode **inode);
312
313/**
314 * __d_rcu_to_refcount - take a refcount on dentry if sequence check is ok
315 * @dentry: dentry to take a ref on
316 * @seq: seqcount to verify against
317 * Returns: 0 on failure, else 1.
318 *
319 * __d_rcu_to_refcount operates on a dentry,seq pair that was returned
320 * by __d_lookup_rcu, to get a reference on an rcu-walk dentry.
321 */
322static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq)
323{
324 int ret = 0;
325
326 assert_spin_locked(&dentry->d_lock);
327 if (!read_seqcount_retry(&dentry->d_seq, seq)) {
328 ret = 1;
329 dentry->d_count++;
330 }
331
332 return ret;
333}
307 334
308/* validate "insecure" dentry pointer */ 335/* validate "insecure" dentry pointer */
309extern int d_validate(struct dentry *, struct dentry *); 336extern int d_validate(struct dentry *, struct dentry *);
@@ -316,34 +343,37 @@ extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
316extern char *__d_path(const struct path *path, struct path *root, char *, int); 343extern char *__d_path(const struct path *path, struct path *root, char *, int);
317extern char *d_path(const struct path *, char *, int); 344extern char *d_path(const struct path *, char *, int);
318extern char *d_path_with_unreachable(const struct path *, char *, int); 345extern char *d_path_with_unreachable(const struct path *, char *, int);
319extern char *__dentry_path(struct dentry *, char *, int); 346extern char *dentry_path_raw(struct dentry *, char *, int);
320extern char *dentry_path(struct dentry *, char *, int); 347extern char *dentry_path(struct dentry *, char *, int);
321 348
322/* Allocation counts.. */ 349/* Allocation counts.. */
323 350
324/** 351/**
325 * dget, dget_locked - get a reference to a dentry 352 * dget, dget_dlock - get a reference to a dentry
326 * @dentry: dentry to get a reference to 353 * @dentry: dentry to get a reference to
327 * 354 *
328 * Given a dentry or %NULL pointer increment the reference count 355 * Given a dentry or %NULL pointer increment the reference count
329 * if appropriate and return the dentry. A dentry will not be 356 * if appropriate and return the dentry. A dentry will not be
330 * destroyed when it has references. dget() should never be 357 * destroyed when it has references.
331 * called for dentries with zero reference counter. For these cases
332 * (preferably none, functions in dcache.c are sufficient for normal
333 * needs and they take necessary precautions) you should hold dcache_lock
334 * and call dget_locked() instead of dget().
335 */ 358 */
336 359static inline struct dentry *dget_dlock(struct dentry *dentry)
360{
361 if (dentry)
362 dentry->d_count++;
363 return dentry;
364}
365
337static inline struct dentry *dget(struct dentry *dentry) 366static inline struct dentry *dget(struct dentry *dentry)
338{ 367{
339 if (dentry) { 368 if (dentry) {
340 BUG_ON(!atomic_read(&dentry->d_count)); 369 spin_lock(&dentry->d_lock);
341 atomic_inc(&dentry->d_count); 370 dget_dlock(dentry);
371 spin_unlock(&dentry->d_lock);
342 } 372 }
343 return dentry; 373 return dentry;
344} 374}
345 375
346extern struct dentry * dget_locked(struct dentry *); 376extern struct dentry *dget_parent(struct dentry *dentry);
347 377
348/** 378/**
349 * d_unhashed - is dentry hashed 379 * d_unhashed - is dentry hashed
@@ -354,7 +384,7 @@ extern struct dentry * dget_locked(struct dentry *);
354 384
355static inline int d_unhashed(struct dentry *dentry) 385static inline int d_unhashed(struct dentry *dentry)
356{ 386{
357 return (dentry->d_flags & DCACHE_UNHASHED); 387 return hlist_bl_unhashed(&dentry->d_hash);
358} 388}
359 389
360static inline int d_unlinked(struct dentry *dentry) 390static inline int d_unlinked(struct dentry *dentry)
@@ -374,24 +404,18 @@ static inline void dont_mount(struct dentry *dentry)
374 spin_unlock(&dentry->d_lock); 404 spin_unlock(&dentry->d_lock);
375} 405}
376 406
377static inline struct dentry *dget_parent(struct dentry *dentry) 407extern void dput(struct dentry *);
378{
379 struct dentry *ret;
380 408
381 spin_lock(&dentry->d_lock); 409static inline bool d_managed(struct dentry *dentry)
382 ret = dget(dentry->d_parent); 410{
383 spin_unlock(&dentry->d_lock); 411 return dentry->d_flags & DCACHE_MANAGED_DENTRY;
384 return ret;
385} 412}
386 413
387extern void dput(struct dentry *); 414static inline bool d_mountpoint(struct dentry *dentry)
388
389static inline int d_mountpoint(struct dentry *dentry)
390{ 415{
391 return dentry->d_mounted; 416 return dentry->d_flags & DCACHE_MOUNTED;
392} 417}
393 418
394extern struct vfsmount *lookup_mnt(struct path *);
395extern struct dentry *lookup_create(struct nameidata *nd, int is_dir); 419extern struct dentry *lookup_create(struct nameidata *nd, int is_dir);
396 420
397extern int sysctl_vfs_cache_pressure; 421extern int sysctl_vfs_cache_pressure;
diff --git a/include/linux/dcbnl.h b/include/linux/dcbnl.h
index 8723491f7dfd..c52280047e2c 100644
--- a/include/linux/dcbnl.h
+++ b/include/linux/dcbnl.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2008, Intel Corporation. 2 * Copyright (c) 2008-2011, Intel Corporation.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 5 * under the terms and conditions of the GNU General Public License,
@@ -22,6 +22,152 @@
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24 24
25/* IEEE 802.1Qaz std supported values */
26#define IEEE_8021QAZ_MAX_TCS 8
27
28#define IEEE_8021QAZ_TSA_STRICT 0
29#define IEEE_8021QAZ_TSA_CB_SHAPER 1
30#define IEEE_8021QAZ_TSA_ETS 2
31#define IEEE_8021QAZ_TSA_VENDOR 255
32
33/* This structure contains the IEEE 802.1Qaz ETS managed object
34 *
35 * @willing: willing bit in ETS configuration TLV
36 * @ets_cap: indicates supported capacity of ets feature
37 * @cbs: credit based shaper ets algorithm supported
38 * @tc_tx_bw: tc tx bandwidth indexed by traffic class
39 * @tc_rx_bw: tc rx bandwidth indexed by traffic class
40 * @tc_tsa: TSA Assignment table, indexed by traffic class
41 * @prio_tc: priority assignment table mapping 8021Qp to traffic class
42 * @tc_reco_bw: recommended tc bandwidth indexed by traffic class for TLV
43 * @tc_reco_tsa: recommended tc bandwidth indexed by traffic class for TLV
44 * @reco_prio_tc: recommended tc tx bandwidth indexed by traffic class for TLV
45 *
46 * Recommended values are used to set fields in the ETS recommendation TLV
47 * with hardware offloaded LLDP.
48 *
49 * ----
50 * TSA Assignment 8 bit identifiers
51 * 0 strict priority
52 * 1 credit-based shaper
53 * 2 enhanced transmission selection
54 * 3-254 reserved
55 * 255 vendor specific
56 */
57struct ieee_ets {
58 __u8 willing;
59 __u8 ets_cap;
60 __u8 cbs;
61 __u8 tc_tx_bw[IEEE_8021QAZ_MAX_TCS];
62 __u8 tc_rx_bw[IEEE_8021QAZ_MAX_TCS];
63 __u8 tc_tsa[IEEE_8021QAZ_MAX_TCS];
64 __u8 prio_tc[IEEE_8021QAZ_MAX_TCS];
65 __u8 tc_reco_bw[IEEE_8021QAZ_MAX_TCS];
66 __u8 tc_reco_tsa[IEEE_8021QAZ_MAX_TCS];
67 __u8 reco_prio_tc[IEEE_8021QAZ_MAX_TCS];
68};
69
70/* This structure contains the IEEE 802.1Qaz PFC managed object
71 *
72 * @pfc_cap: Indicates the number of traffic classes on the local device
73 * that may simultaneously have PFC enabled.
74 * @pfc_en: bitmap indicating pfc enabled traffic classes
75 * @mbc: enable macsec bypass capability
76 * @delay: the allowance made for a round-trip propagation delay of the
77 * link in bits.
78 * @requests: count of the sent pfc frames
79 * @indications: count of the received pfc frames
80 */
81struct ieee_pfc {
82 __u8 pfc_cap;
83 __u8 pfc_en;
84 __u8 mbc;
85 __u16 delay;
86 __u64 requests[IEEE_8021QAZ_MAX_TCS];
87 __u64 indications[IEEE_8021QAZ_MAX_TCS];
88};
89
90/* CEE DCBX std supported values */
91#define CEE_DCBX_MAX_PGS 8
92#define CEE_DCBX_MAX_PRIO 8
93
94/**
95 * struct cee_pg - CEE Priority-Group managed object
96 *
97 * @willing: willing bit in the PG tlv
98 * @error: error bit in the PG tlv
99 * @pg_en: enable bit of the PG feature
100 * @tcs_supported: number of traffic classes supported
101 * @pg_bw: bandwidth percentage for each priority group
102 * @prio_pg: priority to PG mapping indexed by priority
103 */
104struct cee_pg {
105 __u8 willing;
106 __u8 error;
107 __u8 pg_en;
108 __u8 tcs_supported;
109 __u8 pg_bw[CEE_DCBX_MAX_PGS];
110 __u8 prio_pg[CEE_DCBX_MAX_PGS];
111};
112
113/**
114 * struct cee_pfc - CEE PFC managed object
115 *
116 * @willing: willing bit in the PFC tlv
117 * @error: error bit in the PFC tlv
118 * @pfc_en: bitmap indicating pfc enabled traffic classes
119 * @tcs_supported: number of traffic classes supported
120 */
121struct cee_pfc {
122 __u8 willing;
123 __u8 error;
124 __u8 pfc_en;
125 __u8 tcs_supported;
126};
127
128/* IEEE 802.1Qaz std supported values */
129#define IEEE_8021QAZ_APP_SEL_ETHERTYPE 1
130#define IEEE_8021QAZ_APP_SEL_STREAM 2
131#define IEEE_8021QAZ_APP_SEL_DGRAM 3
132#define IEEE_8021QAZ_APP_SEL_ANY 4
133
134/* This structure contains the IEEE 802.1Qaz APP managed object. This
135 * object is also used for the CEE std as well. There is no difference
136 * between the objects.
137 *
138 * @selector: protocol identifier type
139 * @protocol: protocol of type indicated
140 * @priority: 3-bit unsigned integer indicating priority
141 *
142 * ----
143 * Selector field values
144 * 0 Reserved
145 * 1 Ethertype
146 * 2 Well known port number over TCP or SCTP
147 * 3 Well known port number over UDP or DCCP
148 * 4 Well known port number over TCP, SCTP, UDP, or DCCP
149 * 5-7 Reserved
150 */
151struct dcb_app {
152 __u8 selector;
153 __u8 priority;
154 __u16 protocol;
155};
156
157/**
158 * struct dcb_peer_app_info - APP feature information sent by the peer
159 *
160 * @willing: willing bit in the peer APP tlv
161 * @error: error bit in the peer APP tlv
162 *
163 * In addition to this information the full peer APP tlv also contains
164 * a table of 'app_count' APP objects defined above.
165 */
166struct dcb_peer_app_info {
167 __u8 willing;
168 __u8 error;
169};
170
25struct dcbmsg { 171struct dcbmsg {
26 __u8 dcb_family; 172 __u8 dcb_family;
27 __u8 cmd; 173 __u8 cmd;
@@ -50,6 +196,13 @@ struct dcbmsg {
50 * @DCB_CMD_SBCN: get backward congestion notification configration. 196 * @DCB_CMD_SBCN: get backward congestion notification configration.
51 * @DCB_CMD_GAPP: get application protocol configuration 197 * @DCB_CMD_GAPP: get application protocol configuration
52 * @DCB_CMD_SAPP: set application protocol configuration 198 * @DCB_CMD_SAPP: set application protocol configuration
199 * @DCB_CMD_IEEE_SET: set IEEE 802.1Qaz configuration
200 * @DCB_CMD_IEEE_GET: get IEEE 802.1Qaz configuration
201 * @DCB_CMD_GDCBX: get DCBX engine configuration
202 * @DCB_CMD_SDCBX: set DCBX engine configuration
203 * @DCB_CMD_GFEATCFG: get DCBX features flags
204 * @DCB_CMD_SFEATCFG: set DCBX features negotiation flags
205 * @DCB_CMD_CEE_GET: get CEE aggregated configuration
53 */ 206 */
54enum dcbnl_commands { 207enum dcbnl_commands {
55 DCB_CMD_UNDEFINED, 208 DCB_CMD_UNDEFINED,
@@ -83,6 +236,17 @@ enum dcbnl_commands {
83 DCB_CMD_GAPP, 236 DCB_CMD_GAPP,
84 DCB_CMD_SAPP, 237 DCB_CMD_SAPP,
85 238
239 DCB_CMD_IEEE_SET,
240 DCB_CMD_IEEE_GET,
241
242 DCB_CMD_GDCBX,
243 DCB_CMD_SDCBX,
244
245 DCB_CMD_GFEATCFG,
246 DCB_CMD_SFEATCFG,
247
248 DCB_CMD_CEE_GET,
249
86 __DCB_CMD_ENUM_MAX, 250 __DCB_CMD_ENUM_MAX,
87 DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1, 251 DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,
88}; 252};
@@ -102,6 +266,10 @@ enum dcbnl_commands {
102 * @DCB_ATTR_CAP: DCB capabilities of the device (NLA_NESTED) 266 * @DCB_ATTR_CAP: DCB capabilities of the device (NLA_NESTED)
103 * @DCB_ATTR_NUMTCS: number of traffic classes supported (NLA_NESTED) 267 * @DCB_ATTR_NUMTCS: number of traffic classes supported (NLA_NESTED)
104 * @DCB_ATTR_BCN: backward congestion notification configuration (NLA_NESTED) 268 * @DCB_ATTR_BCN: backward congestion notification configuration (NLA_NESTED)
269 * @DCB_ATTR_IEEE: IEEE 802.1Qaz supported attributes (NLA_NESTED)
270 * @DCB_ATTR_DCBX: DCBX engine configuration in the device (NLA_U8)
271 * @DCB_ATTR_FEATCFG: DCBX features flags (NLA_NESTED)
272 * @DCB_ATTR_CEE: CEE std supported attributes (NLA_NESTED)
105 */ 273 */
106enum dcbnl_attrs { 274enum dcbnl_attrs {
107 DCB_ATTR_UNDEFINED, 275 DCB_ATTR_UNDEFINED,
@@ -119,11 +287,75 @@ enum dcbnl_attrs {
119 DCB_ATTR_BCN, 287 DCB_ATTR_BCN,
120 DCB_ATTR_APP, 288 DCB_ATTR_APP,
121 289
290 /* IEEE std attributes */
291 DCB_ATTR_IEEE,
292
293 DCB_ATTR_DCBX,
294 DCB_ATTR_FEATCFG,
295
296 /* CEE nested attributes */
297 DCB_ATTR_CEE,
298
122 __DCB_ATTR_ENUM_MAX, 299 __DCB_ATTR_ENUM_MAX,
123 DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1, 300 DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1,
124}; 301};
125 302
126/** 303/**
304 * enum ieee_attrs - IEEE 802.1Qaz get/set attributes
305 *
306 * @DCB_ATTR_IEEE_UNSPEC: unspecified
307 * @DCB_ATTR_IEEE_ETS: negotiated ETS configuration
308 * @DCB_ATTR_IEEE_PFC: negotiated PFC configuration
309 * @DCB_ATTR_IEEE_APP_TABLE: negotiated APP configuration
310 * @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only
311 * @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only
312 * @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only
313 */
314enum ieee_attrs {
315 DCB_ATTR_IEEE_UNSPEC,
316 DCB_ATTR_IEEE_ETS,
317 DCB_ATTR_IEEE_PFC,
318 DCB_ATTR_IEEE_APP_TABLE,
319 DCB_ATTR_IEEE_PEER_ETS,
320 DCB_ATTR_IEEE_PEER_PFC,
321 DCB_ATTR_IEEE_PEER_APP,
322 __DCB_ATTR_IEEE_MAX
323};
324#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
325
326enum ieee_attrs_app {
327 DCB_ATTR_IEEE_APP_UNSPEC,
328 DCB_ATTR_IEEE_APP,
329 __DCB_ATTR_IEEE_APP_MAX
330};
331#define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1)
332
333/**
334 * enum cee_attrs - CEE DCBX get attributes
335 *
336 * @DCB_ATTR_CEE_UNSPEC: unspecified
337 * @DCB_ATTR_CEE_PEER_PG: peer PG configuration - get only
338 * @DCB_ATTR_CEE_PEER_PFC: peer PFC configuration - get only
339 * @DCB_ATTR_CEE_PEER_APP: peer APP tlv - get only
340 */
341enum cee_attrs {
342 DCB_ATTR_CEE_UNSPEC,
343 DCB_ATTR_CEE_PEER_PG,
344 DCB_ATTR_CEE_PEER_PFC,
345 DCB_ATTR_CEE_PEER_APP_TABLE,
346 __DCB_ATTR_CEE_MAX
347};
348#define DCB_ATTR_CEE_MAX (__DCB_ATTR_CEE_MAX - 1)
349
350enum peer_app_attr {
351 DCB_ATTR_CEE_PEER_APP_UNSPEC,
352 DCB_ATTR_CEE_PEER_APP_INFO,
353 DCB_ATTR_CEE_PEER_APP,
354 __DCB_ATTR_CEE_PEER_APP_MAX
355};
356#define DCB_ATTR_CEE_PEER_APP_MAX (__DCB_ATTR_CEE_PEER_APP_MAX - 1)
357
358/**
127 * enum dcbnl_pfc_attrs - DCB Priority Flow Control user priority nested attrs 359 * enum dcbnl_pfc_attrs - DCB Priority Flow Control user priority nested attrs
128 * 360 *
129 * @DCB_PFC_UP_ATTR_UNDEFINED: unspecified attribute to catch errors 361 * @DCB_PFC_UP_ATTR_UNDEFINED: unspecified attribute to catch errors
@@ -262,6 +494,8 @@ enum dcbnl_tc_attrs {
262 * @DCB_CAP_ATTR_GSP: (NLA_U8) device supports group strict priority 494 * @DCB_CAP_ATTR_GSP: (NLA_U8) device supports group strict priority
263 * @DCB_CAP_ATTR_BCN: (NLA_U8) device supports Backwards Congestion 495 * @DCB_CAP_ATTR_BCN: (NLA_U8) device supports Backwards Congestion
264 * Notification 496 * Notification
497 * @DCB_CAP_ATTR_DCBX: (NLA_U8) device supports DCBX engine
498 *
265 */ 499 */
266enum dcbnl_cap_attrs { 500enum dcbnl_cap_attrs {
267 DCB_CAP_ATTR_UNDEFINED, 501 DCB_CAP_ATTR_UNDEFINED,
@@ -273,12 +507,45 @@ enum dcbnl_cap_attrs {
273 DCB_CAP_ATTR_PFC_TCS, 507 DCB_CAP_ATTR_PFC_TCS,
274 DCB_CAP_ATTR_GSP, 508 DCB_CAP_ATTR_GSP,
275 DCB_CAP_ATTR_BCN, 509 DCB_CAP_ATTR_BCN,
510 DCB_CAP_ATTR_DCBX,
276 511
277 __DCB_CAP_ATTR_ENUM_MAX, 512 __DCB_CAP_ATTR_ENUM_MAX,
278 DCB_CAP_ATTR_MAX = __DCB_CAP_ATTR_ENUM_MAX - 1, 513 DCB_CAP_ATTR_MAX = __DCB_CAP_ATTR_ENUM_MAX - 1,
279}; 514};
280 515
281/** 516/**
517 * DCBX capability flags
518 *
519 * @DCB_CAP_DCBX_HOST: DCBX negotiation is performed by the host LLDP agent.
520 * 'set' routines are used to configure the device with
521 * the negotiated parameters
522 *
523 * @DCB_CAP_DCBX_LLD_MANAGED: DCBX negotiation is not performed in the host but
524 * by another entity
525 * 'get' routines are used to retrieve the
526 * negotiated parameters
527 * 'set' routines can be used to set the initial
528 * negotiation configuration
529 *
530 * @DCB_CAP_DCBX_VER_CEE: for a non-host DCBX engine, indicates the engine
531 * supports the CEE protocol flavor
532 *
533 * @DCB_CAP_DCBX_VER_IEEE: for a non-host DCBX engine, indicates the engine
534 * supports the IEEE protocol flavor
535 *
536 * @DCB_CAP_DCBX_STATIC: for a non-host DCBX engine, indicates the engine
537 * supports static configuration (i.e no actual
538 * negotiation is performed negotiated parameters equal
539 * the initial configuration)
540 *
541 */
542#define DCB_CAP_DCBX_HOST 0x01
543#define DCB_CAP_DCBX_LLD_MANAGED 0x02
544#define DCB_CAP_DCBX_VER_CEE 0x04
545#define DCB_CAP_DCBX_VER_IEEE 0x08
546#define DCB_CAP_DCBX_STATIC 0x10
547
548/**
282 * enum dcbnl_numtcs_attrs - number of traffic classes 549 * enum dcbnl_numtcs_attrs - number of traffic classes
283 * 550 *
284 * @DCB_NUMTCS_ATTR_UNDEFINED: unspecified attribute to catch errors 551 * @DCB_NUMTCS_ATTR_UNDEFINED: unspecified attribute to catch errors
@@ -355,4 +622,30 @@ enum dcbnl_app_attrs {
355 DCB_APP_ATTR_MAX = __DCB_APP_ATTR_ENUM_MAX - 1, 622 DCB_APP_ATTR_MAX = __DCB_APP_ATTR_ENUM_MAX - 1,
356}; 623};
357 624
625/**
626 * enum dcbnl_featcfg_attrs - features conifiguration flags
627 *
628 * @DCB_FEATCFG_ATTR_UNDEFINED: unspecified attribute to catch errors
629 * @DCB_FEATCFG_ATTR_ALL: (NLA_FLAG) all features configuration attributes
630 * @DCB_FEATCFG_ATTR_PG: (NLA_U8) configuration flags for priority groups
631 * @DCB_FEATCFG_ATTR_PFC: (NLA_U8) configuration flags for priority
632 * flow control
633 * @DCB_FEATCFG_ATTR_APP: (NLA_U8) configuration flags for application TLV
634 *
635 */
636#define DCB_FEATCFG_ERROR 0x01 /* error in feature resolution */
637#define DCB_FEATCFG_ENABLE 0x02 /* enable feature */
638#define DCB_FEATCFG_WILLING 0x04 /* feature is willing */
639#define DCB_FEATCFG_ADVERTISE 0x08 /* advertise feature */
640enum dcbnl_featcfg_attrs {
641 DCB_FEATCFG_ATTR_UNDEFINED,
642 DCB_FEATCFG_ATTR_ALL,
643 DCB_FEATCFG_ATTR_PG,
644 DCB_FEATCFG_ATTR_PFC,
645 DCB_FEATCFG_ATTR_APP,
646
647 __DCB_FEATCFG_ATTR_ENUM_MAX,
648 DCB_FEATCFG_ATTR_MAX = __DCB_FEATCFG_ATTR_ENUM_MAX - 1,
649};
650
358#endif /* __LINUX_DCBNL_H__ */ 651#endif /* __LINUX_DCBNL_H__ */
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 7434a8353e23..d638e85dc501 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -165,8 +165,10 @@ enum {
165 DCCPO_TIMESTAMP_ECHO = 42, 165 DCCPO_TIMESTAMP_ECHO = 42,
166 DCCPO_ELAPSED_TIME = 43, 166 DCCPO_ELAPSED_TIME = 43,
167 DCCPO_MAX = 45, 167 DCCPO_MAX = 45,
168 DCCPO_MIN_CCID_SPECIFIC = 128, 168 DCCPO_MIN_RX_CCID_SPECIFIC = 128, /* from sender to receiver */
169 DCCPO_MAX_CCID_SPECIFIC = 255, 169 DCCPO_MAX_RX_CCID_SPECIFIC = 191,
170 DCCPO_MIN_TX_CCID_SPECIFIC = 192, /* from receiver to sender */
171 DCCPO_MAX_TX_CCID_SPECIFIC = 255,
170}; 172};
171/* maximum size of a single TLV-encoded DCCP option (sans type/len bytes) */ 173/* maximum size of a single TLV-encoded DCCP option (sans type/len bytes) */
172#define DCCP_SINGLE_OPT_MAXLEN 253 174#define DCCP_SINGLE_OPT_MAXLEN 253
@@ -195,6 +197,21 @@ enum dccp_feature_numbers {
195 DCCPF_MAX_CCID_SPECIFIC = 255, 197 DCCPF_MAX_CCID_SPECIFIC = 255,
196}; 198};
197 199
200/* DCCP socket control message types for cmsg */
201enum dccp_cmsg_type {
202 DCCP_SCM_PRIORITY = 1,
203 DCCP_SCM_QPOLICY_MAX = 0xFFFF,
204 /* ^-- Up to here reserved exclusively for qpolicy parameters */
205 DCCP_SCM_MAX
206};
207
208/* DCCP priorities for outgoing/queued packets */
209enum dccp_packet_dequeueing_policy {
210 DCCPQ_POLICY_SIMPLE,
211 DCCPQ_POLICY_PRIO,
212 DCCPQ_POLICY_MAX
213};
214
198/* DCCP socket options */ 215/* DCCP socket options */
199#define DCCP_SOCKOPT_PACKET_SIZE 1 /* XXX deprecated, without effect */ 216#define DCCP_SOCKOPT_PACKET_SIZE 1 /* XXX deprecated, without effect */
200#define DCCP_SOCKOPT_SERVICE 2 217#define DCCP_SOCKOPT_SERVICE 2
@@ -208,6 +225,8 @@ enum dccp_feature_numbers {
208#define DCCP_SOCKOPT_CCID 13 225#define DCCP_SOCKOPT_CCID 13
209#define DCCP_SOCKOPT_TX_CCID 14 226#define DCCP_SOCKOPT_TX_CCID 14
210#define DCCP_SOCKOPT_RX_CCID 15 227#define DCCP_SOCKOPT_RX_CCID 15
228#define DCCP_SOCKOPT_QPOLICY_ID 16
229#define DCCP_SOCKOPT_QPOLICY_TXQLEN 17
211#define DCCP_SOCKOPT_CCID_RX_INFO 128 230#define DCCP_SOCKOPT_CCID_RX_INFO 128
212#define DCCP_SOCKOPT_CCID_TX_INFO 192 231#define DCCP_SOCKOPT_CCID_TX_INFO 192
213 232
@@ -260,8 +279,6 @@ enum dccp_state {
260 DCCP_MAX_STATES 279 DCCP_MAX_STATES
261}; 280};
262 281
263#define DCCP_STATE_MASK 0x1f
264
265enum { 282enum {
266 DCCPF_OPEN = TCPF_ESTABLISHED, 283 DCCPF_OPEN = TCPF_ESTABLISHED,
267 DCCPF_REQUESTING = TCPF_SYN_SENT, 284 DCCPF_REQUESTING = TCPF_SYN_SENT,
@@ -456,11 +473,15 @@ struct dccp_ackvec;
456 * @dccps_hc_rx_ccid - CCID used for the receiver (or receiving half-connection) 473 * @dccps_hc_rx_ccid - CCID used for the receiver (or receiving half-connection)
457 * @dccps_hc_tx_ccid - CCID used for the sender (or sending half-connection) 474 * @dccps_hc_tx_ccid - CCID used for the sender (or sending half-connection)
458 * @dccps_options_received - parsed set of retrieved options 475 * @dccps_options_received - parsed set of retrieved options
476 * @dccps_qpolicy - TX dequeueing policy, one of %dccp_packet_dequeueing_policy
477 * @dccps_tx_qlen - maximum length of the TX queue
459 * @dccps_role - role of this sock, one of %dccp_role 478 * @dccps_role - role of this sock, one of %dccp_role
460 * @dccps_hc_rx_insert_options - receiver wants to add options when acking 479 * @dccps_hc_rx_insert_options - receiver wants to add options when acking
461 * @dccps_hc_tx_insert_options - sender wants to add options when sending 480 * @dccps_hc_tx_insert_options - sender wants to add options when sending
462 * @dccps_server_timewait - server holds timewait state on close (RFC 4340, 8.3) 481 * @dccps_server_timewait - server holds timewait state on close (RFC 4340, 8.3)
463 * @dccps_xmit_timer - timer for when CCID is not ready to send 482 * @dccps_sync_scheduled - flag which signals "send out-of-band message soon"
483 * @dccps_xmitlet - tasklet scheduled by the TX CCID to dequeue data packets
484 * @dccps_xmit_timer - used by the TX CCID to delay sending (rate-based pacing)
464 * @dccps_syn_rtt - RTT sample from Request/Response exchange (in usecs) 485 * @dccps_syn_rtt - RTT sample from Request/Response exchange (in usecs)
465 */ 486 */
466struct dccp_sock { 487struct dccp_sock {
@@ -496,10 +517,14 @@ struct dccp_sock {
496 struct ccid *dccps_hc_rx_ccid; 517 struct ccid *dccps_hc_rx_ccid;
497 struct ccid *dccps_hc_tx_ccid; 518 struct ccid *dccps_hc_tx_ccid;
498 struct dccp_options_received dccps_options_received; 519 struct dccp_options_received dccps_options_received;
520 __u8 dccps_qpolicy;
521 __u32 dccps_tx_qlen;
499 enum dccp_role dccps_role:2; 522 enum dccp_role dccps_role:2;
500 __u8 dccps_hc_rx_insert_options:1; 523 __u8 dccps_hc_rx_insert_options:1;
501 __u8 dccps_hc_tx_insert_options:1; 524 __u8 dccps_hc_tx_insert_options:1;
502 __u8 dccps_server_timewait:1; 525 __u8 dccps_server_timewait:1;
526 __u8 dccps_sync_scheduled:1;
527 struct tasklet_struct dccps_xmitlet;
503 struct timer_list dccps_xmit_timer; 528 struct timer_list dccps_xmit_timer;
504}; 529};
505 530
diff --git a/include/linux/dcookies.h b/include/linux/dcookies.h
index 24c806f12a6c..5ac3bdd5cee6 100644
--- a/include/linux/dcookies.h
+++ b/include/linux/dcookies.h
@@ -13,10 +13,10 @@
13#ifdef CONFIG_PROFILING 13#ifdef CONFIG_PROFILING
14 14
15#include <linux/dcache.h> 15#include <linux/dcache.h>
16#include <linux/path.h>
17#include <linux/types.h> 16#include <linux/types.h>
18 17
19struct dcookie_user; 18struct dcookie_user;
19struct path;
20 20
21/** 21/**
22 * dcookie_register - register a user of dcookies 22 * dcookie_register - register a user of dcookies
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h
index 29b3ce3f2a1d..2833452ea01c 100644
--- a/include/linux/debug_locks.h
+++ b/include/linux/debug_locks.h
@@ -49,7 +49,6 @@ struct task_struct;
49 49
50#ifdef CONFIG_LOCKDEP 50#ifdef CONFIG_LOCKDEP
51extern void debug_show_all_locks(void); 51extern void debug_show_all_locks(void);
52extern void __debug_show_held_locks(struct task_struct *task);
53extern void debug_show_held_locks(struct task_struct *task); 52extern void debug_show_held_locks(struct task_struct *task);
54extern void debug_check_no_locks_freed(const void *from, unsigned long len); 53extern void debug_check_no_locks_freed(const void *from, unsigned long len);
55extern void debug_check_no_locks_held(struct task_struct *task); 54extern void debug_check_no_locks_held(struct task_struct *task);
@@ -58,10 +57,6 @@ static inline void debug_show_all_locks(void)
58{ 57{
59} 58}
60 59
61static inline void __debug_show_held_locks(struct task_struct *task)
62{
63}
64
65static inline void debug_show_held_locks(struct task_struct *task) 60static inline void debug_show_held_locks(struct task_struct *task)
66{ 61{
67} 62}
diff --git a/include/linux/debugobjects.h b/include/linux/debugobjects.h
index 597692f1fc8d..65970b811e22 100644
--- a/include/linux/debugobjects.h
+++ b/include/linux/debugobjects.h
@@ -34,7 +34,10 @@ struct debug_obj {
34 34
35/** 35/**
36 * struct debug_obj_descr - object type specific debug description structure 36 * struct debug_obj_descr - object type specific debug description structure
37 *
37 * @name: name of the object typee 38 * @name: name of the object typee
39 * @debug_hint: function returning address, which have associated
40 * kernel symbol, to allow identify the object
38 * @fixup_init: fixup function, which is called when the init check 41 * @fixup_init: fixup function, which is called when the init check
39 * fails 42 * fails
40 * @fixup_activate: fixup function, which is called when the activate check 43 * @fixup_activate: fixup function, which is called when the activate check
@@ -46,7 +49,7 @@ struct debug_obj {
46 */ 49 */
47struct debug_obj_descr { 50struct debug_obj_descr {
48 const char *name; 51 const char *name;
49 52 void *(*debug_hint) (void *addr);
50 int (*fixup_init) (void *addr, enum debug_obj_state state); 53 int (*fixup_init) (void *addr, enum debug_obj_state state);
51 int (*fixup_activate) (void *addr, enum debug_obj_state state); 54 int (*fixup_activate) (void *addr, enum debug_obj_state state);
52 int (*fixup_destroy) (void *addr, enum debug_obj_state state); 55 int (*fixup_destroy) (void *addr, enum debug_obj_state state);
diff --git a/include/linux/decompress/inflate.h b/include/linux/decompress/inflate.h
index f9b06ccc3e5c..8c0aef1ba5f5 100644
--- a/include/linux/decompress/inflate.h
+++ b/include/linux/decompress/inflate.h
@@ -1,9 +1,6 @@
1#ifndef INFLATE_H 1#ifndef INFLATE_H
2#define INFLATE_H 2#define INFLATE_H
3 3
4/* Other housekeeping constants */
5#define INBUFSIZ 4096
6
7int gunzip(unsigned char *inbuf, int len, 4int gunzip(unsigned char *inbuf, int len,
8 int(*fill)(void*, unsigned int), 5 int(*fill)(void*, unsigned int),
9 int(*flush)(void*, unsigned int), 6 int(*flush)(void*, unsigned int),
diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
index ad5ec1d0475e..7925bf0ee836 100644
--- a/include/linux/decompress/mm.h
+++ b/include/linux/decompress/mm.h
@@ -16,7 +16,7 @@
16 16
17/* 17/*
18 * Some architectures want to ensure there is no local data in their 18 * Some architectures want to ensure there is no local data in their
19 * pre-boot environment, so that data can arbitarily relocated (via 19 * pre-boot environment, so that data can arbitrarily relocated (via
20 * GOT references). This is achieved by defining STATIC_RW_DATA to 20 * GOT references). This is achieved by defining STATIC_RW_DATA to
21 * be null. 21 * be null.
22 */ 22 */
@@ -61,8 +61,6 @@ static void free(void *where)
61#define large_malloc(a) malloc(a) 61#define large_malloc(a) malloc(a)
62#define large_free(a) free(a) 62#define large_free(a) free(a)
63 63
64#define set_error_fn(x)
65
66#define INIT 64#define INIT
67 65
68#else /* STATIC */ 66#else /* STATIC */
@@ -72,6 +70,7 @@ static void free(void *where)
72#include <linux/kernel.h> 70#include <linux/kernel.h>
73#include <linux/fs.h> 71#include <linux/fs.h>
74#include <linux/string.h> 72#include <linux/string.h>
73#include <linux/slab.h>
75#include <linux/vmalloc.h> 74#include <linux/vmalloc.h>
76 75
77/* Use defines rather than static inline in order to avoid spurious 76/* Use defines rather than static inline in order to avoid spurious
@@ -84,9 +83,6 @@ static void free(void *where)
84#define large_malloc(a) vmalloc(a) 83#define large_malloc(a) vmalloc(a)
85#define large_free(a) vfree(a) 84#define large_free(a) vfree(a)
86 85
87static void(*error)(char *m);
88#define set_error_fn(x) error = x;
89
90#define INIT __init 86#define INIT __init
91#define STATIC 87#define STATIC
92 88
diff --git a/include/linux/decompress/unxz.h b/include/linux/decompress/unxz.h
new file mode 100644
index 000000000000..41728fc6c8a1
--- /dev/null
+++ b/include/linux/decompress/unxz.h
@@ -0,0 +1,19 @@
1/*
2 * Wrapper for decompressing XZ-compressed kernel, initramfs, and initrd
3 *
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
5 *
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
8 */
9
10#ifndef DECOMPRESS_UNXZ_H
11#define DECOMPRESS_UNXZ_H
12
13int unxz(unsigned char *in, int in_size,
14 int (*fill)(void *dest, unsigned int size),
15 int (*flush)(void *src, unsigned int size),
16 unsigned char *out, int *in_used,
17 void (*error)(char *x));
18
19#endif
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 2970022faa63..4427e0454051 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -191,6 +191,18 @@ struct dm_target {
191 191
192 /* Used to provide an error string from the ctr */ 192 /* Used to provide an error string from the ctr */
193 char *error; 193 char *error;
194
195 /*
196 * Set if this target needs to receive discards regardless of
197 * whether or not its underlying devices have support.
198 */
199 unsigned discards_supported:1;
200};
201
202/* Each target can link one of these into the table */
203struct dm_target_callbacks {
204 struct list_head list;
205 int (*congested_fn) (struct dm_target_callbacks *, int);
194}; 206};
195 207
196int dm_register_target(struct target_type *t); 208int dm_register_target(struct target_type *t);
@@ -269,14 +281,14 @@ int dm_table_add_target(struct dm_table *t, const char *type,
269 sector_t start, sector_t len, char *params); 281 sector_t start, sector_t len, char *params);
270 282
271/* 283/*
272 * Finally call this to make the table ready for use. 284 * Target_ctr should call this if it needs to add any callbacks.
273 */ 285 */
274int dm_table_complete(struct dm_table *t); 286void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callbacks *cb);
275 287
276/* 288/*
277 * Unplug all devices in a table. 289 * Finally call this to make the table ready for use.
278 */ 290 */
279void dm_table_unplug_all(struct dm_table *t); 291int dm_table_complete(struct dm_table *t);
280 292
281/* 293/*
282 * Table reference counting. 294 * Table reference counting.
diff --git a/include/linux/device.h b/include/linux/device.h
index 516fecacf27b..e4f62d8896b7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -30,9 +30,8 @@ struct device_private;
30struct device_driver; 30struct device_driver;
31struct driver_private; 31struct driver_private;
32struct class; 32struct class;
33struct class_private; 33struct subsys_private;
34struct bus_type; 34struct bus_type;
35struct bus_type_private;
36struct device_node; 35struct device_node;
37 36
38struct bus_attribute { 37struct bus_attribute {
@@ -48,6 +47,38 @@ extern int __must_check bus_create_file(struct bus_type *,
48 struct bus_attribute *); 47 struct bus_attribute *);
49extern void bus_remove_file(struct bus_type *, struct bus_attribute *); 48extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
50 49
50/**
51 * struct bus_type - The bus type of the device
52 *
53 * @name: The name of the bus.
54 * @bus_attrs: Default attributes of the bus.
55 * @dev_attrs: Default attributes of the devices on the bus.
56 * @drv_attrs: Default attributes of the device drivers on the bus.
57 * @match: Called, perhaps multiple times, whenever a new device or driver
58 * is added for this bus. It should return a nonzero value if the
59 * given device can be handled by the given driver.
60 * @uevent: Called when a device is added, removed, or a few other things
61 * that generate uevents to add the environment variables.
62 * @probe: Called when a new device or driver add to this bus, and callback
63 * the specific driver's probe to initial the matched device.
64 * @remove: Called when a device removed from this bus.
65 * @shutdown: Called at shut-down time to quiesce the device.
66 * @suspend: Called when a device on this bus wants to go to sleep mode.
67 * @resume: Called to bring a device on this bus out of sleep mode.
68 * @pm: Power management operations of this bus, callback the specific
69 * device driver's pm-ops.
70 * @p: The private data of the driver core, only the driver core can
71 * touch this.
72 *
73 * A bus is a channel between the processor and one or more devices. For the
74 * purposes of the device model, all devices are connected via a bus, even if
75 * it is an internal, virtual, "platform" bus. Buses can plug into each other.
76 * A USB controller is usually a PCI device, for example. The device model
77 * represents the actual connections between buses and the devices they control.
78 * A bus is represented by the bus_type structure. It contains the name, the
79 * default attributes, the bus' methods, PM operations, and the driver core's
80 * private data.
81 */
51struct bus_type { 82struct bus_type {
52 const char *name; 83 const char *name;
53 struct bus_attribute *bus_attrs; 84 struct bus_attribute *bus_attrs;
@@ -65,7 +96,7 @@ struct bus_type {
65 96
66 const struct dev_pm_ops *pm; 97 const struct dev_pm_ops *pm;
67 98
68 struct bus_type_private *p; 99 struct subsys_private *p;
69}; 100};
70 101
71extern int __must_check bus_register(struct bus_type *bus); 102extern int __must_check bus_register(struct bus_type *bus);
@@ -120,6 +151,37 @@ extern int bus_unregister_notifier(struct bus_type *bus,
120extern struct kset *bus_get_kset(struct bus_type *bus); 151extern struct kset *bus_get_kset(struct bus_type *bus);
121extern struct klist *bus_get_device_klist(struct bus_type *bus); 152extern struct klist *bus_get_device_klist(struct bus_type *bus);
122 153
154/**
155 * struct device_driver - The basic device driver structure
156 * @name: Name of the device driver.
157 * @bus: The bus which the device of this driver belongs to.
158 * @owner: The module owner.
159 * @mod_name: Used for built-in modules.
160 * @suppress_bind_attrs: Disables bind/unbind via sysfs.
161 * @of_match_table: The open firmware table.
162 * @probe: Called to query the existence of a specific device,
163 * whether this driver can work with it, and bind the driver
164 * to a specific device.
165 * @remove: Called when the device is removed from the system to
166 * unbind a device from this driver.
167 * @shutdown: Called at shut-down time to quiesce the device.
168 * @suspend: Called to put the device to sleep mode. Usually to a
169 * low power state.
170 * @resume: Called to bring a device from sleep mode.
171 * @groups: Default attributes that get created by the driver core
172 * automatically.
173 * @pm: Power management operations of the device which matched
174 * this driver.
175 * @p: Driver core's private data, no one other than the driver
176 * core can touch this.
177 *
178 * The device driver-model tracks all of the drivers known to the system.
179 * The main reason for this tracking is to enable the driver core to match
180 * up drivers with new devices. Once drivers are known objects within the
181 * system, however, a number of other things become possible. Device drivers
182 * can export information and configuration variables that are independent
183 * of any specific device.
184 */
123struct device_driver { 185struct device_driver {
124 const char *name; 186 const char *name;
125 struct bus_type *bus; 187 struct bus_type *bus;
@@ -129,9 +191,7 @@ struct device_driver {
129 191
130 bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ 192 bool suppress_bind_attrs; /* disables bind/unbind via sysfs */
131 193
132#if defined(CONFIG_OF)
133 const struct of_device_id *of_match_table; 194 const struct of_device_id *of_match_table;
134#endif
135 195
136 int (*probe) (struct device *dev); 196 int (*probe) (struct device *dev);
137 int (*remove) (struct device *dev); 197 int (*remove) (struct device *dev);
@@ -188,8 +248,34 @@ struct device *driver_find_device(struct device_driver *drv,
188 struct device *start, void *data, 248 struct device *start, void *data,
189 int (*match)(struct device *dev, void *data)); 249 int (*match)(struct device *dev, void *data));
190 250
191/* 251/**
192 * device classes 252 * struct class - device classes
253 * @name: Name of the class.
254 * @owner: The module owner.
255 * @class_attrs: Default attributes of this class.
256 * @dev_attrs: Default attributes of the devices belong to the class.
257 * @dev_bin_attrs: Default binary attributes of the devices belong to the class.
258 * @dev_kobj: The kobject that represents this class and links it into the hierarchy.
259 * @dev_uevent: Called when a device is added, removed from this class, or a
260 * few other things that generate uevents to add the environment
261 * variables.
262 * @devnode: Callback to provide the devtmpfs.
263 * @class_release: Called to release this class.
264 * @dev_release: Called to release the device.
265 * @suspend: Used to put the device to sleep mode, usually to a low power
266 * state.
267 * @resume: Used to bring the device from the sleep mode.
268 * @ns_type: Callbacks so sysfs can detemine namespaces.
269 * @namespace: Namespace of the device belongs to this class.
270 * @pm: The default device power management operations of this class.
271 * @p: The private data of the driver core, no one other than the
272 * driver core can touch this.
273 *
274 * A class is a higher-level view of a device that abstracts out low-level
275 * implementation details. Drivers may see a SCSI disk or an ATA disk, but,
276 * at the class level, they are all simply disks. Classes allow user space
277 * to work with devices based on what they do, rather than how they are
278 * connected or how they work.
193 */ 279 */
194struct class { 280struct class {
195 const char *name; 281 const char *name;
@@ -197,6 +283,7 @@ struct class {
197 283
198 struct class_attribute *class_attrs; 284 struct class_attribute *class_attrs;
199 struct device_attribute *dev_attrs; 285 struct device_attribute *dev_attrs;
286 struct bin_attribute *dev_bin_attrs;
200 struct kobject *dev_kobj; 287 struct kobject *dev_kobj;
201 288
202 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); 289 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
@@ -213,7 +300,7 @@ struct class {
213 300
214 const struct dev_pm_ops *pm; 301 const struct dev_pm_ops *pm;
215 302
216 struct class_private *p; 303 struct subsys_private *p;
217}; 304};
218 305
219struct class_dev_iter { 306struct class_dev_iter {
@@ -403,6 +490,64 @@ struct device_dma_parameters {
403 unsigned long segment_boundary_mask; 490 unsigned long segment_boundary_mask;
404}; 491};
405 492
493/**
494 * struct device - The basic device structure
495 * @parent: The device's "parent" device, the device to which it is attached.
496 * In most cases, a parent device is some sort of bus or host
497 * controller. If parent is NULL, the device, is a top-level device,
498 * which is not usually what you want.
499 * @p: Holds the private data of the driver core portions of the device.
500 * See the comment of the struct device_private for detail.
501 * @kobj: A top-level, abstract class from which other classes are derived.
502 * @init_name: Initial name of the device.
503 * @type: The type of device.
504 * This identifies the device type and carries type-specific
505 * information.
506 * @mutex: Mutex to synchronize calls to its driver.
507 * @bus: Type of bus device is on.
508 * @driver: Which driver has allocated this
509 * @platform_data: Platform data specific to the device.
510 * Example: For devices on custom boards, as typical of embedded
511 * and SOC based hardware, Linux often uses platform_data to point
512 * to board-specific structures describing devices and how they
513 * are wired. That can include what ports are available, chip
514 * variants, which GPIO pins act in what additional roles, and so
515 * on. This shrinks the "Board Support Packages" (BSPs) and
516 * minimizes board-specific #ifdefs in drivers.
517 * @power: For device power management.
518 * See Documentation/power/devices.txt for details.
519 * @pwr_domain: Provide callbacks that are executed during system suspend,
520 * hibernation, system resume and during runtime PM transitions
521 * along with subsystem-level and driver-level callbacks.
522 * @numa_node: NUMA node this device is close to.
523 * @dma_mask: Dma mask (if dma'ble device).
524 * @coherent_dma_mask: Like dma_mask, but for alloc_coherent mapping as not all
525 * hardware supports 64-bit addresses for consistent allocations
526 * such descriptors.
527 * @dma_parms: A low level driver may set these to teach IOMMU code about
528 * segment limitations.
529 * @dma_pools: Dma pools (if dma'ble device).
530 * @dma_mem: Internal for coherent mem override.
531 * @archdata: For arch-specific additions.
532 * @of_node: Associated device tree node.
533 * @devt: For creating the sysfs "dev".
534 * @devres_lock: Spinlock to protect the resource of the device.
535 * @devres_head: The resources list of the device.
536 * @knode_class: The node used to add the device to the class list.
537 * @class: The class of the device.
538 * @groups: Optional attribute groups.
539 * @release: Callback to free the device after all references have
540 * gone away. This should be set by the allocator of the
541 * device (i.e. the bus driver that discovered the device).
542 *
543 * At the lowest level, every device in a Linux system is represented by an
544 * instance of struct device. The device structure contains the information
545 * that the device model core needs to model the system. Most subsystems,
546 * however, track additional information about the devices they host. As a
547 * result, it is rare for devices to be represented by bare device structures;
548 * instead, that structure, like kobject structures, is usually embedded within
549 * a higher-level representation of the device.
550 */
406struct device { 551struct device {
407 struct device *parent; 552 struct device *parent;
408 553
@@ -410,7 +555,7 @@ struct device {
410 555
411 struct kobject kobj; 556 struct kobject kobj;
412 const char *init_name; /* initial name of the device */ 557 const char *init_name; /* initial name of the device */
413 struct device_type *type; 558 const struct device_type *type;
414 559
415 struct mutex mutex; /* mutex to synchronize calls to 560 struct mutex mutex; /* mutex to synchronize calls to
416 * its driver. 561 * its driver.
@@ -422,6 +567,7 @@ struct device {
422 void *platform_data; /* Platform specific data, device 567 void *platform_data; /* Platform specific data, device
423 core doesn't touch it */ 568 core doesn't touch it */
424 struct dev_pm_info power; 569 struct dev_pm_info power;
570 struct dev_power_domain *pwr_domain;
425 571
426#ifdef CONFIG_NUMA 572#ifdef CONFIG_NUMA
427 int numa_node; /* NUMA node this device is close to */ 573 int numa_node; /* NUMA node this device is close to */
@@ -441,9 +587,8 @@ struct device {
441 override */ 587 override */
442 /* arch specific additions */ 588 /* arch specific additions */
443 struct dev_archdata archdata; 589 struct dev_archdata archdata;
444#ifdef CONFIG_OF 590
445 struct device_node *of_node; 591 struct device_node *of_node; /* associated device tree node */
446#endif
447 592
448 dev_t devt; /* dev_t, creates the sysfs "dev" */ 593 dev_t devt; /* dev_t, creates the sysfs "dev" */
449 594
@@ -508,13 +653,13 @@ static inline int device_is_registered(struct device *dev)
508 653
509static inline void device_enable_async_suspend(struct device *dev) 654static inline void device_enable_async_suspend(struct device *dev)
510{ 655{
511 if (dev->power.status == DPM_ON) 656 if (!dev->power.is_prepared)
512 dev->power.async_suspend = true; 657 dev->power.async_suspend = true;
513} 658}
514 659
515static inline void device_disable_async_suspend(struct device *dev) 660static inline void device_disable_async_suspend(struct device *dev)
516{ 661{
517 if (dev->power.status == DPM_ON) 662 if (!dev->power.is_prepared)
518 dev->power.async_suspend = false; 663 dev->power.async_suspend = false;
519} 664}
520 665
@@ -558,7 +703,7 @@ extern int device_move(struct device *dev, struct device *new_parent,
558extern const char *device_get_devnode(struct device *dev, 703extern const char *device_get_devnode(struct device *dev,
559 mode_t *mode, const char **tmp); 704 mode_t *mode, const char **tmp);
560extern void *dev_get_drvdata(const struct device *dev); 705extern void *dev_get_drvdata(const struct device *dev);
561extern void dev_set_drvdata(struct device *dev, void *data); 706extern int dev_set_drvdata(struct device *dev, void *data);
562 707
563/* 708/*
564 * Root device objects for grouping under /sys/devices 709 * Root device objects for grouping under /sys/devices
@@ -612,7 +757,7 @@ extern int (*platform_notify)(struct device *dev);
612extern int (*platform_notify_remove)(struct device *dev); 757extern int (*platform_notify_remove)(struct device *dev);
613 758
614 759
615/** 760/*
616 * get_device - atomically increment the reference count for the device. 761 * get_device - atomically increment the reference count for the device.
617 * 762 *
618 */ 763 */
@@ -634,9 +779,6 @@ static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
634/* drivers/base/power/shutdown.c */ 779/* drivers/base/power/shutdown.c */
635extern void device_shutdown(void); 780extern void device_shutdown(void);
636 781
637/* drivers/base/sys.c */
638extern void sysdev_shutdown(void);
639
640/* debugging and troubleshooting/diagnostic helpers. */ 782/* debugging and troubleshooting/diagnostic helpers. */
641extern const char *dev_driver_string(const struct device *dev); 783extern const char *dev_driver_string(const struct device *dev);
642 784
@@ -739,16 +881,27 @@ do { \
739#endif 881#endif
740 882
741/* 883/*
742 * dev_WARN() acts like dev_printk(), but with the key difference 884 * dev_WARN*() acts like dev_printk(), but with the key difference
743 * of using a WARN/WARN_ON to get the message out, including the 885 * of using a WARN/WARN_ON to get the message out, including the
744 * file/line information and a backtrace. 886 * file/line information and a backtrace.
745 */ 887 */
746#define dev_WARN(dev, format, arg...) \ 888#define dev_WARN(dev, format, arg...) \
747 WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); 889 WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg);
748 890
891#define dev_WARN_ONCE(dev, condition, format, arg...) \
892 WARN_ONCE(condition, "Device %s\n" format, \
893 dev_driver_string(dev), ## arg)
894
749/* Create alias, so I can be autoloaded. */ 895/* Create alias, so I can be autoloaded. */
750#define MODULE_ALIAS_CHARDEV(major,minor) \ 896#define MODULE_ALIAS_CHARDEV(major,minor) \
751 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 897 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
752#define MODULE_ALIAS_CHARDEV_MAJOR(major) \ 898#define MODULE_ALIAS_CHARDEV_MAJOR(major) \
753 MODULE_ALIAS("char-major-" __stringify(major) "-*") 899 MODULE_ALIAS("char-major-" __stringify(major) "-*")
900
901#ifdef CONFIG_SYSFS_DEPRECATED
902extern long sysfs_deprecated;
903#else
904#define sysfs_deprecated 0
905#endif
906
754#endif /* _DEVICE_H_ */ 907#endif /* _DEVICE_H_ */
diff --git a/include/linux/device_cgroup.h b/include/linux/device_cgroup.h
index 0b0d9c39ed67..7aad1f440867 100644
--- a/include/linux/device_cgroup.h
+++ b/include/linux/device_cgroup.h
@@ -2,8 +2,16 @@
2#include <linux/fs.h> 2#include <linux/fs.h>
3 3
4#ifdef CONFIG_CGROUP_DEVICE 4#ifdef CONFIG_CGROUP_DEVICE
5extern int devcgroup_inode_permission(struct inode *inode, int mask); 5extern int __devcgroup_inode_permission(struct inode *inode, int mask);
6extern int devcgroup_inode_mknod(int mode, dev_t dev); 6extern int devcgroup_inode_mknod(int mode, dev_t dev);
7static inline int devcgroup_inode_permission(struct inode *inode, int mask)
8{
9 if (likely(!inode->i_rdev))
10 return 0;
11 if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode))
12 return 0;
13 return __devcgroup_inode_permission(inode, mask);
14}
7#else 15#else
8static inline int devcgroup_inode_permission(struct inode *inode, int mask) 16static inline int devcgroup_inode_permission(struct inode *inode, int mask)
9{ return 0; } 17{ return 0; }
diff --git a/include/linux/dlm.h b/include/linux/dlm.h
index 0b3518c42356..d4e02f5353a0 100644
--- a/include/linux/dlm.h
+++ b/include/linux/dlm.h
@@ -48,10 +48,10 @@ typedef void dlm_lockspace_t;
48 * 48 *
49 * 0 if lock request was successful 49 * 0 if lock request was successful
50 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE 50 * -EAGAIN if request would block and is flagged DLM_LKF_NOQUEUE
51 * -ENOMEM if there is no memory to process request
52 * -EINVAL if there are invalid parameters
53 * -DLM_EUNLOCK if unlock request was successful 51 * -DLM_EUNLOCK if unlock request was successful
54 * -DLM_ECANCEL if a cancel completed successfully 52 * -DLM_ECANCEL if a cancel completed successfully
53 * -EDEADLK if a deadlock was detected
54 * -ETIMEDOUT if the lock request was canceled due to a timeout
55 */ 55 */
56 56
57#define DLM_SBF_DEMOTED 0x01 57#define DLM_SBF_DEMOTED 0x01
diff --git a/include/linux/dlm_plock.h b/include/linux/dlm_plock.h
index 2dd21243104f..3b1cc1be419f 100644
--- a/include/linux/dlm_plock.h
+++ b/include/linux/dlm_plock.h
@@ -14,7 +14,7 @@
14#define DLM_PLOCK_MISC_NAME "dlm_plock" 14#define DLM_PLOCK_MISC_NAME "dlm_plock"
15 15
16#define DLM_PLOCK_VERSION_MAJOR 1 16#define DLM_PLOCK_VERSION_MAJOR 1
17#define DLM_PLOCK_VERSION_MINOR 1 17#define DLM_PLOCK_VERSION_MINOR 2
18#define DLM_PLOCK_VERSION_PATCH 0 18#define DLM_PLOCK_VERSION_PATCH 0
19 19
20enum { 20enum {
@@ -23,12 +23,14 @@ enum {
23 DLM_PLOCK_OP_GET, 23 DLM_PLOCK_OP_GET,
24}; 24};
25 25
26#define DLM_PLOCK_FL_CLOSE 1
27
26struct dlm_plock_info { 28struct dlm_plock_info {
27 __u32 version[3]; 29 __u32 version[3];
28 __u8 optype; 30 __u8 optype;
29 __u8 ex; 31 __u8 ex;
30 __u8 wait; 32 __u8 wait;
31 __u8 pad; 33 __u8 flags;
32 __u32 pid; 34 __u32 pid;
33 __s32 nodeid; 35 __s32 nodeid;
34 __s32 rv; 36 __s32 rv;
diff --git a/include/linux/dm-io.h b/include/linux/dm-io.h
index 5c9186b93fff..f4b0aa3126f5 100644
--- a/include/linux/dm-io.h
+++ b/include/linux/dm-io.h
@@ -69,8 +69,7 @@ struct dm_io_request {
69 * 69 *
70 * Create/destroy may block. 70 * Create/destroy may block.
71 */ 71 */
72struct dm_io_client *dm_io_client_create(unsigned num_pages); 72struct dm_io_client *dm_io_client_create(void);
73int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client);
74void dm_io_client_destroy(struct dm_io_client *client); 73void dm_io_client_destroy(struct dm_io_client *client);
75 74
76/* 75/*
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h
index 49eab360d5d4..3708455ee6c3 100644
--- a/include/linux/dm-ioctl.h
+++ b/include/linux/dm-ioctl.h
@@ -44,7 +44,7 @@
44 * Remove a device, destroy any tables. 44 * Remove a device, destroy any tables.
45 * 45 *
46 * DM_DEV_RENAME: 46 * DM_DEV_RENAME:
47 * Rename a device. 47 * Rename a device or set its uuid if none was previously supplied.
48 * 48 *
49 * DM_SUSPEND: 49 * DM_SUSPEND:
50 * This performs both suspend and resume, depending which flag is 50 * This performs both suspend and resume, depending which flag is
@@ -267,9 +267,9 @@ enum {
267#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) 267#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
268 268
269#define DM_VERSION_MAJOR 4 269#define DM_VERSION_MAJOR 4
270#define DM_VERSION_MINOR 18 270#define DM_VERSION_MINOR 20
271#define DM_VERSION_PATCHLEVEL 0 271#define DM_VERSION_PATCHLEVEL 0
272#define DM_VERSION_EXTRA "-ioctl (2010-06-29)" 272#define DM_VERSION_EXTRA "-ioctl (2011-02-02)"
273 273
274/* Status bits */ 274/* Status bits */
275#define DM_READONLY_FLAG (1 << 0) /* In/Out */ 275#define DM_READONLY_FLAG (1 << 0) /* In/Out */
@@ -322,4 +322,16 @@ enum {
322 */ 322 */
323#define DM_UEVENT_GENERATED_FLAG (1 << 13) /* Out */ 323#define DM_UEVENT_GENERATED_FLAG (1 << 13) /* Out */
324 324
325/*
326 * If set, rename changes the uuid not the name. Only permitted
327 * if no uuid was previously supplied: an existing uuid cannot be changed.
328 */
329#define DM_UUID_FLAG (1 << 14) /* In */
330
331/*
332 * If set, all buffers are wiped after use. Use when sending
333 * or requesting sensitive data such as an encryption key.
334 */
335#define DM_SECURE_DATA_FLAG (1 << 15) /* In */
336
325#endif /* _LINUX_DM_IOCTL_H */ 337#endif /* _LINUX_DM_IOCTL_H */
diff --git a/include/linux/dm-kcopyd.h b/include/linux/dm-kcopyd.h
index 5db216311695..298d587e349b 100644
--- a/include/linux/dm-kcopyd.h
+++ b/include/linux/dm-kcopyd.h
@@ -25,8 +25,7 @@
25 * To use kcopyd you must first create a dm_kcopyd_client object. 25 * To use kcopyd you must first create a dm_kcopyd_client object.
26 */ 26 */
27struct dm_kcopyd_client; 27struct dm_kcopyd_client;
28int dm_kcopyd_client_create(unsigned num_pages, 28struct dm_kcopyd_client *dm_kcopyd_client_create(void);
29 struct dm_kcopyd_client **result);
30void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc); 29void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc);
31 30
32/* 31/*
diff --git a/include/linux/dm-log-userspace.h b/include/linux/dm-log-userspace.h
index 0c3c3a2110c4..eeace7d3ff15 100644
--- a/include/linux/dm-log-userspace.h
+++ b/include/linux/dm-log-userspace.h
@@ -370,6 +370,16 @@
370#define DM_ULOG_REQUEST_TYPE(request_type) \ 370#define DM_ULOG_REQUEST_TYPE(request_type) \
371 (DM_ULOG_REQUEST_MASK & (request_type)) 371 (DM_ULOG_REQUEST_MASK & (request_type))
372 372
373/*
374 * DM_ULOG_REQUEST_VERSION is incremented when there is a
375 * change to the way information is passed between kernel
376 * and userspace. This could be a structure change of
377 * dm_ulog_request or a change in the way requests are
378 * issued/handled. Changes are outlined here:
379 * version 1: Initial implementation
380 */
381#define DM_ULOG_REQUEST_VERSION 1
382
373struct dm_ulog_request { 383struct dm_ulog_request {
374 /* 384 /*
375 * The local unique identifier (luid) and the universally unique 385 * The local unique identifier (luid) and the universally unique
@@ -383,8 +393,9 @@ struct dm_ulog_request {
383 */ 393 */
384 uint64_t luid; 394 uint64_t luid;
385 char uuid[DM_UUID_LEN]; 395 char uuid[DM_UUID_LEN];
386 char padding[7]; /* Padding because DM_UUID_LEN = 129 */ 396 char padding[3]; /* Padding because DM_UUID_LEN = 129 */
387 397
398 uint32_t version; /* See DM_ULOG_REQUEST_VERSION */
388 int32_t error; /* Used to report back processing errors */ 399 int32_t error; /* Used to report back processing errors */
389 400
390 uint32_t seq; /* Sequence number for request */ 401 uint32_t seq; /* Sequence number for request */
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index 5619f8522738..bbd8661b3473 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -9,8 +9,12 @@
9#define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT) 9#define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT)
10#define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK) 10#define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK)
11 11
12#define VTD_STRIDE_SHIFT (9)
13#define VTD_STRIDE_MASK (((u64)-1) << VTD_STRIDE_SHIFT)
14
12#define DMA_PTE_READ (1) 15#define DMA_PTE_READ (1)
13#define DMA_PTE_WRITE (2) 16#define DMA_PTE_WRITE (2)
17#define DMA_PTE_LARGE_PAGE (1 << 7)
14#define DMA_PTE_SNP (1 << 11) 18#define DMA_PTE_SNP (1 << 11)
15 19
16#define CONTEXT_TT_MULTI_LEVEL 0 20#define CONTEXT_TT_MULTI_LEVEL 0
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index e2106495cc11..eee7addec282 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -64,13 +64,15 @@ enum dma_transaction_type {
64 DMA_PQ_VAL, 64 DMA_PQ_VAL,
65 DMA_MEMSET, 65 DMA_MEMSET,
66 DMA_INTERRUPT, 66 DMA_INTERRUPT,
67 DMA_SG,
67 DMA_PRIVATE, 68 DMA_PRIVATE,
68 DMA_ASYNC_TX, 69 DMA_ASYNC_TX,
69 DMA_SLAVE, 70 DMA_SLAVE,
71 DMA_CYCLIC,
70}; 72};
71 73
72/* last transaction type for creation of the capabilities mask */ 74/* last transaction type for creation of the capabilities mask */
73#define DMA_TX_TYPE_END (DMA_SLAVE + 1) 75#define DMA_TX_TYPE_END (DMA_CYCLIC + 1)
74 76
75 77
76/** 78/**
@@ -119,12 +121,15 @@ enum dma_ctrl_flags {
119 * configuration data in statically from the platform). An additional 121 * configuration data in statically from the platform). An additional
120 * argument of struct dma_slave_config must be passed in with this 122 * argument of struct dma_slave_config must be passed in with this
121 * command. 123 * command.
124 * @FSLDMA_EXTERNAL_START: this command will put the Freescale DMA controller
125 * into external start mode.
122 */ 126 */
123enum dma_ctrl_cmd { 127enum dma_ctrl_cmd {
124 DMA_TERMINATE_ALL, 128 DMA_TERMINATE_ALL,
125 DMA_PAUSE, 129 DMA_PAUSE,
126 DMA_RESUME, 130 DMA_RESUME,
127 DMA_SLAVE_CONFIG, 131 DMA_SLAVE_CONFIG,
132 FSLDMA_EXTERNAL_START,
128}; 133};
129 134
130/** 135/**
@@ -316,14 +321,14 @@ struct dma_async_tx_descriptor {
316 dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx); 321 dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx);
317 dma_async_tx_callback callback; 322 dma_async_tx_callback callback;
318 void *callback_param; 323 void *callback_param;
319#ifndef CONFIG_ASYNC_TX_DISABLE_CHANNEL_SWITCH 324#ifdef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH
320 struct dma_async_tx_descriptor *next; 325 struct dma_async_tx_descriptor *next;
321 struct dma_async_tx_descriptor *parent; 326 struct dma_async_tx_descriptor *parent;
322 spinlock_t lock; 327 spinlock_t lock;
323#endif 328#endif
324}; 329};
325 330
326#ifdef CONFIG_ASYNC_TX_DISABLE_CHANNEL_SWITCH 331#ifndef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH
327static inline void txd_lock(struct dma_async_tx_descriptor *txd) 332static inline void txd_lock(struct dma_async_tx_descriptor *txd)
328{ 333{
329} 334}
@@ -422,11 +427,14 @@ struct dma_tx_state {
422 * @device_prep_dma_memset: prepares a memset operation 427 * @device_prep_dma_memset: prepares a memset operation
423 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation 428 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation
424 * @device_prep_slave_sg: prepares a slave dma operation 429 * @device_prep_slave_sg: prepares a slave dma operation
430 * @device_prep_dma_cyclic: prepare a cyclic dma operation suitable for audio.
431 * The function takes a buffer of size buf_len. The callback function will
432 * be called after period_len bytes have been transferred.
425 * @device_control: manipulate all pending operations on a channel, returns 433 * @device_control: manipulate all pending operations on a channel, returns
426 * zero or error code 434 * zero or error code
427 * @device_tx_status: poll for transaction completion, the optional 435 * @device_tx_status: poll for transaction completion, the optional
428 * txstate parameter can be supplied with a pointer to get a 436 * txstate parameter can be supplied with a pointer to get a
429 * struct with auxilary transfer status information, otherwise the call 437 * struct with auxiliary transfer status information, otherwise the call
430 * will just return a simple status code 438 * will just return a simple status code
431 * @device_issue_pending: push pending transactions to hardware 439 * @device_issue_pending: push pending transactions to hardware
432 */ 440 */
@@ -473,11 +481,19 @@ struct dma_device {
473 unsigned long flags); 481 unsigned long flags);
474 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( 482 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)(
475 struct dma_chan *chan, unsigned long flags); 483 struct dma_chan *chan, unsigned long flags);
484 struct dma_async_tx_descriptor *(*device_prep_dma_sg)(
485 struct dma_chan *chan,
486 struct scatterlist *dst_sg, unsigned int dst_nents,
487 struct scatterlist *src_sg, unsigned int src_nents,
488 unsigned long flags);
476 489
477 struct dma_async_tx_descriptor *(*device_prep_slave_sg)( 490 struct dma_async_tx_descriptor *(*device_prep_slave_sg)(
478 struct dma_chan *chan, struct scatterlist *sgl, 491 struct dma_chan *chan, struct scatterlist *sgl,
479 unsigned int sg_len, enum dma_data_direction direction, 492 unsigned int sg_len, enum dma_data_direction direction,
480 unsigned long flags); 493 unsigned long flags);
494 struct dma_async_tx_descriptor *(*device_prep_dma_cyclic)(
495 struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
496 size_t period_len, enum dma_data_direction direction);
481 int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd, 497 int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
482 unsigned long arg); 498 unsigned long arg);
483 499
@@ -487,6 +503,40 @@ struct dma_device {
487 void (*device_issue_pending)(struct dma_chan *chan); 503 void (*device_issue_pending)(struct dma_chan *chan);
488}; 504};
489 505
506static inline int dmaengine_device_control(struct dma_chan *chan,
507 enum dma_ctrl_cmd cmd,
508 unsigned long arg)
509{
510 return chan->device->device_control(chan, cmd, arg);
511}
512
513static inline int dmaengine_slave_config(struct dma_chan *chan,
514 struct dma_slave_config *config)
515{
516 return dmaengine_device_control(chan, DMA_SLAVE_CONFIG,
517 (unsigned long)config);
518}
519
520static inline int dmaengine_terminate_all(struct dma_chan *chan)
521{
522 return dmaengine_device_control(chan, DMA_TERMINATE_ALL, 0);
523}
524
525static inline int dmaengine_pause(struct dma_chan *chan)
526{
527 return dmaengine_device_control(chan, DMA_PAUSE, 0);
528}
529
530static inline int dmaengine_resume(struct dma_chan *chan)
531{
532 return dmaengine_device_control(chan, DMA_RESUME, 0);
533}
534
535static inline dma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc)
536{
537 return desc->tx_submit(desc);
538}
539
490static inline bool dmaengine_check_align(u8 align, size_t off1, size_t off2, size_t len) 540static inline bool dmaengine_check_align(u8 align, size_t off1, size_t off2, size_t len)
491{ 541{
492 size_t mask; 542 size_t mask;
@@ -606,11 +656,11 @@ static inline void net_dmaengine_put(void)
606#ifdef CONFIG_ASYNC_TX_DMA 656#ifdef CONFIG_ASYNC_TX_DMA
607#define async_dmaengine_get() dmaengine_get() 657#define async_dmaengine_get() dmaengine_get()
608#define async_dmaengine_put() dmaengine_put() 658#define async_dmaengine_put() dmaengine_put()
609#ifdef CONFIG_ASYNC_TX_DISABLE_CHANNEL_SWITCH 659#ifndef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH
610#define async_dma_find_channel(type) dma_find_channel(DMA_ASYNC_TX) 660#define async_dma_find_channel(type) dma_find_channel(DMA_ASYNC_TX)
611#else 661#else
612#define async_dma_find_channel(type) dma_find_channel(type) 662#define async_dma_find_channel(type) dma_find_channel(type)
613#endif /* CONFIG_ASYNC_TX_DISABLE_CHANNEL_SWITCH */ 663#endif /* CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH */
614#else 664#else
615static inline void async_dmaengine_get(void) 665static inline void async_dmaengine_get(void)
616{ 666{
@@ -774,6 +824,8 @@ enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie);
774#ifdef CONFIG_DMA_ENGINE 824#ifdef CONFIG_DMA_ENGINE
775enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx); 825enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);
776void dma_issue_pending_all(void); 826void dma_issue_pending_all(void);
827struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param);
828void dma_release_channel(struct dma_chan *chan);
777#else 829#else
778static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx) 830static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
779{ 831{
@@ -781,7 +833,14 @@ static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descript
781} 833}
782static inline void dma_issue_pending_all(void) 834static inline void dma_issue_pending_all(void)
783{ 835{
784 do { } while (0); 836}
837static inline struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask,
838 dma_filter_fn fn, void *fn_param)
839{
840 return NULL;
841}
842static inline void dma_release_channel(struct dma_chan *chan)
843{
785} 844}
786#endif 845#endif
787 846
@@ -792,8 +851,6 @@ void dma_async_device_unregister(struct dma_device *device);
792void dma_run_dependencies(struct dma_async_tx_descriptor *tx); 851void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
793struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type); 852struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type);
794#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y) 853#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y)
795struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param);
796void dma_release_channel(struct dma_chan *chan);
797 854
798/* --- Helper iov-locking functions --- */ 855/* --- Helper iov-locking functions --- */
799 856
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index d7cecc90ed34..7b776d71d36d 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -57,15 +57,15 @@ extern int dmar_table_init(void);
57extern int dmar_dev_scope_init(void); 57extern int dmar_dev_scope_init(void);
58 58
59/* Intel IOMMU detection */ 59/* Intel IOMMU detection */
60extern void detect_intel_iommu(void); 60extern int detect_intel_iommu(void);
61extern int enable_drhd_fault_handling(void); 61extern int enable_drhd_fault_handling(void);
62 62
63extern int parse_ioapics_under_ir(void); 63extern int parse_ioapics_under_ir(void);
64extern int alloc_iommu(struct dmar_drhd_unit *); 64extern int alloc_iommu(struct dmar_drhd_unit *);
65#else 65#else
66static inline void detect_intel_iommu(void) 66static inline int detect_intel_iommu(void)
67{ 67{
68 return; 68 return -ENODEV;
69} 69}
70 70
71static inline int dmar_table_init(void) 71static inline int dmar_table_init(void)
@@ -106,6 +106,7 @@ struct irte {
106 __u64 high; 106 __u64 high;
107 }; 107 };
108}; 108};
109
109#ifdef CONFIG_INTR_REMAP 110#ifdef CONFIG_INTR_REMAP
110extern int intr_remapping_enabled; 111extern int intr_remapping_enabled;
111extern int intr_remapping_supported(void); 112extern int intr_remapping_supported(void);
@@ -119,11 +120,8 @@ extern int alloc_irte(struct intel_iommu *iommu, int irq, u16 count);
119extern int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index, 120extern int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index,
120 u16 sub_handle); 121 u16 sub_handle);
121extern int map_irq_to_irte_handle(int irq, u16 *sub_handle); 122extern int map_irq_to_irte_handle(int irq, u16 *sub_handle);
122extern int clear_irte_irq(int irq, struct intel_iommu *iommu, u16 index);
123extern int flush_irte(int irq);
124extern int free_irte(int irq); 123extern int free_irte(int irq);
125 124
126extern int irq_remapped(int irq);
127extern struct intel_iommu *map_dev_to_ir(struct pci_dev *dev); 125extern struct intel_iommu *map_dev_to_ir(struct pci_dev *dev);
128extern struct intel_iommu *map_ioapic_to_ir(int apic); 126extern struct intel_iommu *map_ioapic_to_ir(int apic);
129extern struct intel_iommu *map_hpet_to_ir(u8 id); 127extern struct intel_iommu *map_hpet_to_ir(u8 id);
@@ -177,18 +175,29 @@ static inline int set_msi_sid(struct irte *irte, struct pci_dev *dev)
177 return 0; 175 return 0;
178} 176}
179 177
180#define irq_remapped(irq) (0)
181#define enable_intr_remapping(mode) (-1)
182#define disable_intr_remapping() (0)
183#define reenable_intr_remapping(mode) (0)
184#define intr_remapping_enabled (0) 178#define intr_remapping_enabled (0)
179
180static inline int enable_intr_remapping(int eim)
181{
182 return -1;
183}
184
185static inline void disable_intr_remapping(void)
186{
187}
188
189static inline int reenable_intr_remapping(int eim)
190{
191 return 0;
192}
185#endif 193#endif
186 194
187/* Can't use the common MSI interrupt functions 195/* Can't use the common MSI interrupt functions
188 * since DMAR is not a pci device 196 * since DMAR is not a pci device
189 */ 197 */
190extern void dmar_msi_unmask(unsigned int irq); 198struct irq_data;
191extern void dmar_msi_mask(unsigned int irq); 199extern void dmar_msi_unmask(struct irq_data *data);
200extern void dmar_msi_mask(struct irq_data *data);
192extern void dmar_msi_read(int irq, struct msi_msg *msg); 201extern void dmar_msi_read(int irq, struct msi_msg *msg);
193extern void dmar_msi_write(int irq, struct msi_msg *msg); 202extern void dmar_msi_write(int irq, struct msi_msg *msg);
194extern int dmar_set_interrupt(struct intel_iommu *iommu); 203extern int dmar_set_interrupt(struct intel_iommu *iommu);
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 90e087f8d951..f156cca25ad0 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -23,6 +23,53 @@ enum dmi_device_type {
23 DMI_DEV_TYPE_DEV_ONBOARD = -3, 23 DMI_DEV_TYPE_DEV_ONBOARD = -3,
24}; 24};
25 25
26enum dmi_entry_type {
27 DMI_ENTRY_BIOS = 0,
28 DMI_ENTRY_SYSTEM,
29 DMI_ENTRY_BASEBOARD,
30 DMI_ENTRY_CHASSIS,
31 DMI_ENTRY_PROCESSOR,
32 DMI_ENTRY_MEM_CONTROLLER,
33 DMI_ENTRY_MEM_MODULE,
34 DMI_ENTRY_CACHE,
35 DMI_ENTRY_PORT_CONNECTOR,
36 DMI_ENTRY_SYSTEM_SLOT,
37 DMI_ENTRY_ONBOARD_DEVICE,
38 DMI_ENTRY_OEMSTRINGS,
39 DMI_ENTRY_SYSCONF,
40 DMI_ENTRY_BIOS_LANG,
41 DMI_ENTRY_GROUP_ASSOC,
42 DMI_ENTRY_SYSTEM_EVENT_LOG,
43 DMI_ENTRY_PHYS_MEM_ARRAY,
44 DMI_ENTRY_MEM_DEVICE,
45 DMI_ENTRY_32_MEM_ERROR,
46 DMI_ENTRY_MEM_ARRAY_MAPPED_ADDR,
47 DMI_ENTRY_MEM_DEV_MAPPED_ADDR,
48 DMI_ENTRY_BUILTIN_POINTING_DEV,
49 DMI_ENTRY_PORTABLE_BATTERY,
50 DMI_ENTRY_SYSTEM_RESET,
51 DMI_ENTRY_HW_SECURITY,
52 DMI_ENTRY_SYSTEM_POWER_CONTROLS,
53 DMI_ENTRY_VOLTAGE_PROBE,
54 DMI_ENTRY_COOLING_DEV,
55 DMI_ENTRY_TEMP_PROBE,
56 DMI_ENTRY_ELECTRICAL_CURRENT_PROBE,
57 DMI_ENTRY_OOB_REMOTE_ACCESS,
58 DMI_ENTRY_BIS_ENTRY,
59 DMI_ENTRY_SYSTEM_BOOT,
60 DMI_ENTRY_MGMT_DEV,
61 DMI_ENTRY_MGMT_DEV_COMPONENT,
62 DMI_ENTRY_MGMT_DEV_THRES,
63 DMI_ENTRY_MEM_CHANNEL,
64 DMI_ENTRY_IPMI_DEV,
65 DMI_ENTRY_SYS_POWER_SUPPLY,
66 DMI_ENTRY_ADDITIONAL,
67 DMI_ENTRY_ONBOARD_DEV_EXT,
68 DMI_ENTRY_MGMT_CONTROLLER_HOST,
69 DMI_ENTRY_INACTIVE = 126,
70 DMI_ENTRY_END_OF_TABLE = 127,
71};
72
26struct dmi_header { 73struct dmi_header {
27 u8 type; 74 u8 type;
28 u8 length; 75 u8 length;
diff --git a/include/linux/drbd.h b/include/linux/drbd.h
index 479ee3a1d901..9e5f5607eba3 100644
--- a/include/linux/drbd.h
+++ b/include/linux/drbd.h
@@ -36,9 +36,9 @@
36#include <sys/wait.h> 36#include <sys/wait.h>
37#include <limits.h> 37#include <limits.h>
38 38
39/* Altough the Linux source code makes a difference between 39/* Although the Linux source code makes a difference between
40 generic endianness and the bitfields' endianness, there is no 40 generic endianness and the bitfields' endianness, there is no
41 architecture as of Linux-2.6.24-rc4 where the bitfileds' endianness 41 architecture as of Linux-2.6.24-rc4 where the bitfields' endianness
42 does not match the generic endianness. */ 42 does not match the generic endianness. */
43 43
44#if __BYTE_ORDER == __LITTLE_ENDIAN 44#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -53,10 +53,10 @@
53 53
54 54
55extern const char *drbd_buildtag(void); 55extern const char *drbd_buildtag(void);
56#define REL_VERSION "8.3.8.1" 56#define REL_VERSION "8.3.11"
57#define API_VERSION 88 57#define API_VERSION 88
58#define PRO_VERSION_MIN 86 58#define PRO_VERSION_MIN 86
59#define PRO_VERSION_MAX 94 59#define PRO_VERSION_MAX 96
60 60
61 61
62enum drbd_io_error_p { 62enum drbd_io_error_p {
@@ -91,8 +91,19 @@ enum drbd_after_sb_p {
91 ASB_VIOLENTLY 91 ASB_VIOLENTLY
92}; 92};
93 93
94enum drbd_on_no_data {
95 OND_IO_ERROR,
96 OND_SUSPEND_IO
97};
98
99enum drbd_on_congestion {
100 OC_BLOCK,
101 OC_PULL_AHEAD,
102 OC_DISCONNECT,
103};
104
94/* KEEP the order, do not delete or insert. Only append. */ 105/* KEEP the order, do not delete or insert. Only append. */
95enum drbd_ret_codes { 106enum drbd_ret_code {
96 ERR_CODE_BASE = 100, 107 ERR_CODE_BASE = 100,
97 NO_ERROR = 101, 108 NO_ERROR = 101,
98 ERR_LOCAL_ADDR = 102, 109 ERR_LOCAL_ADDR = 102,
@@ -140,6 +151,10 @@ enum drbd_ret_codes {
140 ERR_CONNECTED = 151, /* DRBD 8.3 only */ 151 ERR_CONNECTED = 151, /* DRBD 8.3 only */
141 ERR_PERM = 152, 152 ERR_PERM = 152,
142 ERR_NEED_APV_93 = 153, 153 ERR_NEED_APV_93 = 153,
154 ERR_STONITH_AND_PROT_A = 154,
155 ERR_CONG_NOT_PROTO_A = 155,
156 ERR_PIC_AFTER_DEP = 156,
157 ERR_PIC_PEER_DEP = 157,
143 158
144 /* insert new ones above this line */ 159 /* insert new ones above this line */
145 AFTER_LAST_ERR_CODE 160 AFTER_LAST_ERR_CODE
@@ -169,7 +184,7 @@ enum drbd_conns {
169 /* These temporal states are all used on the way 184 /* These temporal states are all used on the way
170 * from >= C_CONNECTED to Unconnected. 185 * from >= C_CONNECTED to Unconnected.
171 * The 'disconnect reason' states 186 * The 'disconnect reason' states
172 * I do not allow to change beween them. */ 187 * I do not allow to change between them. */
173 C_TIMEOUT, 188 C_TIMEOUT,
174 C_BROKEN_PIPE, 189 C_BROKEN_PIPE,
175 C_NETWORK_FAILURE, 190 C_NETWORK_FAILURE,
@@ -180,7 +195,7 @@ enum drbd_conns {
180 C_WF_REPORT_PARAMS, /* we have a socket */ 195 C_WF_REPORT_PARAMS, /* we have a socket */
181 C_CONNECTED, /* we have introduced each other */ 196 C_CONNECTED, /* we have introduced each other */
182 C_STARTING_SYNC_S, /* starting full sync by admin request. */ 197 C_STARTING_SYNC_S, /* starting full sync by admin request. */
183 C_STARTING_SYNC_T, /* stariing full sync by admin request. */ 198 C_STARTING_SYNC_T, /* starting full sync by admin request. */
184 C_WF_BITMAP_S, 199 C_WF_BITMAP_S,
185 C_WF_BITMAP_T, 200 C_WF_BITMAP_T,
186 C_WF_SYNC_UUID, 201 C_WF_SYNC_UUID,
@@ -193,6 +208,10 @@ enum drbd_conns {
193 C_VERIFY_T, 208 C_VERIFY_T,
194 C_PAUSED_SYNC_S, 209 C_PAUSED_SYNC_S,
195 C_PAUSED_SYNC_T, 210 C_PAUSED_SYNC_T,
211
212 C_AHEAD,
213 C_BEHIND,
214
196 C_MASK = 31 215 C_MASK = 31
197}; 216};
198 217
@@ -217,7 +236,7 @@ union drbd_state {
217 * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com> 236 * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
218 * even though we transmit as "cpu_to_be32(state)", 237 * even though we transmit as "cpu_to_be32(state)",
219 * the offsets of the bitfields still need to be swapped 238 * the offsets of the bitfields still need to be swapped
220 * on different endianess. 239 * on different endianness.
221 */ 240 */
222 struct { 241 struct {
223#if defined(__LITTLE_ENDIAN_BITFIELD) 242#if defined(__LITTLE_ENDIAN_BITFIELD)
@@ -226,13 +245,17 @@ union drbd_state {
226 unsigned conn:5 ; /* 17/32 cstates */ 245 unsigned conn:5 ; /* 17/32 cstates */
227 unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */ 246 unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
228 unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */ 247 unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
229 unsigned susp:1 ; /* 2/2 IO suspended no/yes */ 248 unsigned susp:1 ; /* 2/2 IO suspended no/yes (by user) */
230 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */ 249 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
231 unsigned peer_isp:1 ; 250 unsigned peer_isp:1 ;
232 unsigned user_isp:1 ; 251 unsigned user_isp:1 ;
233 unsigned _pad:11; /* 0 unused */ 252 unsigned susp_nod:1 ; /* IO suspended because no data */
253 unsigned susp_fen:1 ; /* IO suspended because fence peer handler runs*/
254 unsigned _pad:9; /* 0 unused */
234#elif defined(__BIG_ENDIAN_BITFIELD) 255#elif defined(__BIG_ENDIAN_BITFIELD)
235 unsigned _pad:11; /* 0 unused */ 256 unsigned _pad:9;
257 unsigned susp_fen:1 ;
258 unsigned susp_nod:1 ;
236 unsigned user_isp:1 ; 259 unsigned user_isp:1 ;
237 unsigned peer_isp:1 ; 260 unsigned peer_isp:1 ;
238 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */ 261 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
@@ -243,13 +266,13 @@ union drbd_state {
243 unsigned peer:2 ; /* 3/4 primary/secondary/unknown */ 266 unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
244 unsigned role:2 ; /* 3/4 primary/secondary/unknown */ 267 unsigned role:2 ; /* 3/4 primary/secondary/unknown */
245#else 268#else
246# error "this endianess is not supported" 269# error "this endianness is not supported"
247#endif 270#endif
248 }; 271 };
249 unsigned int i; 272 unsigned int i;
250}; 273};
251 274
252enum drbd_state_ret_codes { 275enum drbd_state_rv {
253 SS_CW_NO_NEED = 4, 276 SS_CW_NO_NEED = 4,
254 SS_CW_SUCCESS = 3, 277 SS_CW_SUCCESS = 3,
255 SS_NOTHING_TO_DO = 2, 278 SS_NOTHING_TO_DO = 2,
@@ -280,7 +303,7 @@ enum drbd_state_ret_codes {
280extern const char *drbd_conn_str(enum drbd_conns); 303extern const char *drbd_conn_str(enum drbd_conns);
281extern const char *drbd_role_str(enum drbd_role); 304extern const char *drbd_role_str(enum drbd_role);
282extern const char *drbd_disk_str(enum drbd_disk_state); 305extern const char *drbd_disk_str(enum drbd_disk_state);
283extern const char *drbd_set_st_err_str(enum drbd_state_ret_codes); 306extern const char *drbd_set_st_err_str(enum drbd_state_rv);
284 307
285#define SHARED_SECRET_MAX 64 308#define SHARED_SECRET_MAX 64
286 309
@@ -312,6 +335,8 @@ enum drbd_timeout_flag {
312 335
313#define DRBD_MAGIC 0x83740267 336#define DRBD_MAGIC 0x83740267
314#define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC) 337#define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC)
338#define DRBD_MAGIC_BIG 0x835a
339#define BE_DRBD_MAGIC_BIG __constant_cpu_to_be16(DRBD_MAGIC_BIG)
315 340
316/* these are of type "int" */ 341/* these are of type "int" */
317#define DRBD_MD_INDEX_INTERNAL -1 342#define DRBD_MD_INDEX_INTERNAL -1
diff --git a/include/linux/drbd_limits.h b/include/linux/drbd_limits.h
index 440b42e38e89..447c36752385 100644
--- a/include/linux/drbd_limits.h
+++ b/include/linux/drbd_limits.h
@@ -16,7 +16,8 @@
16#define DEBUG_RANGE_CHECK 0 16#define DEBUG_RANGE_CHECK 0
17 17
18#define DRBD_MINOR_COUNT_MIN 1 18#define DRBD_MINOR_COUNT_MIN 1
19#define DRBD_MINOR_COUNT_MAX 255 19#define DRBD_MINOR_COUNT_MAX 256
20#define DRBD_MINOR_COUNT_DEF 32
20 21
21#define DRBD_DIALOG_REFRESH_MIN 0 22#define DRBD_DIALOG_REFRESH_MIN 0
22#define DRBD_DIALOG_REFRESH_MAX 600 23#define DRBD_DIALOG_REFRESH_MAX 600
@@ -42,7 +43,7 @@
42 43
43/* net { */ 44/* net { */
44 /* timeout, unit centi seconds 45 /* timeout, unit centi seconds
45 * more than one minute timeout is not usefull */ 46 * more than one minute timeout is not useful */
46#define DRBD_TIMEOUT_MIN 1 47#define DRBD_TIMEOUT_MIN 1
47#define DRBD_TIMEOUT_MAX 600 48#define DRBD_TIMEOUT_MAX 600
48#define DRBD_TIMEOUT_DEF 60 /* 6 seconds */ 49#define DRBD_TIMEOUT_DEF 60 /* 6 seconds */
@@ -67,7 +68,7 @@
67#define DRBD_MAX_EPOCH_SIZE_MAX 20000 68#define DRBD_MAX_EPOCH_SIZE_MAX 20000
68#define DRBD_MAX_EPOCH_SIZE_DEF 2048 69#define DRBD_MAX_EPOCH_SIZE_DEF 2048
69 70
70 /* I don't think that a tcp send buffer of more than 10M is usefull */ 71 /* I don't think that a tcp send buffer of more than 10M is useful */
71#define DRBD_SNDBUF_SIZE_MIN 0 72#define DRBD_SNDBUF_SIZE_MIN 0
72#define DRBD_SNDBUF_SIZE_MAX (10<<20) 73#define DRBD_SNDBUF_SIZE_MAX (10<<20)
73#define DRBD_SNDBUF_SIZE_DEF 0 74#define DRBD_SNDBUF_SIZE_DEF 0
@@ -100,7 +101,7 @@
100#define DRBD_RATE_MAX (4 << 20) 101#define DRBD_RATE_MAX (4 << 20)
101#define DRBD_RATE_DEF 250 /* kb/second */ 102#define DRBD_RATE_DEF 250 /* kb/second */
102 103
103 /* less than 7 would hit performance unneccessarily. 104 /* less than 7 would hit performance unnecessarily.
104 * 3833 is the largest prime that still does fit 105 * 3833 is the largest prime that still does fit
105 * into 64 sectors of activity log */ 106 * into 64 sectors of activity log */
106#define DRBD_AL_EXTENTS_MIN 7 107#define DRBD_AL_EXTENTS_MIN 7
@@ -116,10 +117,10 @@
116/* drbdsetup XY resize -d Z 117/* drbdsetup XY resize -d Z
117 * you are free to reduce the device size to nothing, if you want to. 118 * you are free to reduce the device size to nothing, if you want to.
118 * the upper limit with 64bit kernel, enough ram and flexible meta data 119 * the upper limit with 64bit kernel, enough ram and flexible meta data
119 * is 16 TB, currently. */ 120 * is 1 PiB, currently. */
120/* DRBD_MAX_SECTORS */ 121/* DRBD_MAX_SECTORS */
121#define DRBD_DISK_SIZE_SECT_MIN 0 122#define DRBD_DISK_SIZE_SECT_MIN 0
122#define DRBD_DISK_SIZE_SECT_MAX (16 * (2LLU << 30)) 123#define DRBD_DISK_SIZE_SECT_MAX (1 * (2LLU << 40))
123#define DRBD_DISK_SIZE_SECT_DEF 0 /* = disabled = no user size... */ 124#define DRBD_DISK_SIZE_SECT_DEF 0 /* = disabled = no user size... */
124 125
125#define DRBD_ON_IO_ERROR_DEF EP_PASS_ON 126#define DRBD_ON_IO_ERROR_DEF EP_PASS_ON
@@ -128,26 +129,40 @@
128#define DRBD_AFTER_SB_1P_DEF ASB_DISCONNECT 129#define DRBD_AFTER_SB_1P_DEF ASB_DISCONNECT
129#define DRBD_AFTER_SB_2P_DEF ASB_DISCONNECT 130#define DRBD_AFTER_SB_2P_DEF ASB_DISCONNECT
130#define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT 131#define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT
132#define DRBD_ON_NO_DATA_DEF OND_IO_ERROR
133#define DRBD_ON_CONGESTION_DEF OC_BLOCK
131 134
132#define DRBD_MAX_BIO_BVECS_MIN 0 135#define DRBD_MAX_BIO_BVECS_MIN 0
133#define DRBD_MAX_BIO_BVECS_MAX 128 136#define DRBD_MAX_BIO_BVECS_MAX 128
134#define DRBD_MAX_BIO_BVECS_DEF 0 137#define DRBD_MAX_BIO_BVECS_DEF 0
135 138
136#define DRBD_DP_VOLUME_MIN 4 139#define DRBD_C_PLAN_AHEAD_MIN 0
137#define DRBD_DP_VOLUME_MAX 1048576 140#define DRBD_C_PLAN_AHEAD_MAX 300
138#define DRBD_DP_VOLUME_DEF 16384 141#define DRBD_C_PLAN_AHEAD_DEF 0 /* RS rate controller disabled by default */
139 142
140#define DRBD_DP_INTERVAL_MIN 1 143#define DRBD_C_DELAY_TARGET_MIN 1
141#define DRBD_DP_INTERVAL_MAX 600 144#define DRBD_C_DELAY_TARGET_MAX 100
142#define DRBD_DP_INTERVAL_DEF 5 145#define DRBD_C_DELAY_TARGET_DEF 10
143 146
144#define DRBD_RS_THROTTLE_TH_MIN 1 147#define DRBD_C_FILL_TARGET_MIN 0
145#define DRBD_RS_THROTTLE_TH_MAX 600 148#define DRBD_C_FILL_TARGET_MAX (1<<20) /* 500MByte in sec */
146#define DRBD_RS_THROTTLE_TH_DEF 20 149#define DRBD_C_FILL_TARGET_DEF 0 /* By default disabled -> controlled by delay_target */
147 150
148#define DRBD_RS_HOLD_OFF_TH_MIN 1 151#define DRBD_C_MAX_RATE_MIN 250 /* kByte/sec */
149#define DRBD_RS_HOLD_OFF_TH_MAX 6000 152#define DRBD_C_MAX_RATE_MAX (4 << 20)
150#define DRBD_RS_HOLD_OFF_TH_DEF 100 153#define DRBD_C_MAX_RATE_DEF 102400
154
155#define DRBD_C_MIN_RATE_MIN 0 /* kByte/sec */
156#define DRBD_C_MIN_RATE_MAX (4 << 20)
157#define DRBD_C_MIN_RATE_DEF 4096
158
159#define DRBD_CONG_FILL_MIN 0
160#define DRBD_CONG_FILL_MAX (10<<21) /* 10GByte in sectors */
161#define DRBD_CONG_FILL_DEF 0
162
163#define DRBD_CONG_EXTENTS_MIN DRBD_AL_EXTENTS_MIN
164#define DRBD_CONG_EXTENTS_MAX DRBD_AL_EXTENTS_MAX
165#define DRBD_CONG_EXTENTS_DEF DRBD_AL_EXTENTS_DEF
151 166
152#undef RANGE 167#undef RANGE
153#endif 168#endif
diff --git a/include/linux/drbd_nl.h b/include/linux/drbd_nl.h
index 5f042810a56c..ab6159e4fcf0 100644
--- a/include/linux/drbd_nl.h
+++ b/include/linux/drbd_nl.h
@@ -56,6 +56,9 @@ NL_PACKET(net_conf, 5,
56 NL_INTEGER( 39, T_MAY_IGNORE, rr_conflict) 56 NL_INTEGER( 39, T_MAY_IGNORE, rr_conflict)
57 NL_INTEGER( 40, T_MAY_IGNORE, ping_timeo) 57 NL_INTEGER( 40, T_MAY_IGNORE, ping_timeo)
58 NL_INTEGER( 67, T_MAY_IGNORE, rcvbuf_size) 58 NL_INTEGER( 67, T_MAY_IGNORE, rcvbuf_size)
59 NL_INTEGER( 81, T_MAY_IGNORE, on_congestion)
60 NL_INTEGER( 82, T_MAY_IGNORE, cong_fill)
61 NL_INTEGER( 83, T_MAY_IGNORE, cong_extents)
59 /* 59 addr_family was available in GIT, never released */ 62 /* 59 addr_family was available in GIT, never released */
60 NL_BIT( 60, T_MANDATORY, mind_af) 63 NL_BIT( 60, T_MANDATORY, mind_af)
61 NL_BIT( 27, T_MAY_IGNORE, want_lose) 64 NL_BIT( 27, T_MAY_IGNORE, want_lose)
@@ -66,7 +69,9 @@ NL_PACKET(net_conf, 5,
66 NL_BIT( 70, T_MANDATORY, dry_run) 69 NL_BIT( 70, T_MANDATORY, dry_run)
67) 70)
68 71
69NL_PACKET(disconnect, 6, ) 72NL_PACKET(disconnect, 6,
73 NL_BIT( 84, T_MAY_IGNORE, force)
74)
70 75
71NL_PACKET(resize, 7, 76NL_PACKET(resize, 7,
72 NL_INT64( 29, T_MAY_IGNORE, resize_size) 77 NL_INT64( 29, T_MAY_IGNORE, resize_size)
@@ -87,6 +92,12 @@ NL_PACKET(syncer_conf, 8,
87 NL_STRING( 51, T_MAY_IGNORE, cpu_mask, 32) 92 NL_STRING( 51, T_MAY_IGNORE, cpu_mask, 32)
88 NL_STRING( 64, T_MAY_IGNORE, csums_alg, SHARED_SECRET_MAX) 93 NL_STRING( 64, T_MAY_IGNORE, csums_alg, SHARED_SECRET_MAX)
89 NL_BIT( 65, T_MAY_IGNORE, use_rle) 94 NL_BIT( 65, T_MAY_IGNORE, use_rle)
95 NL_INTEGER( 75, T_MAY_IGNORE, on_no_data)
96 NL_INTEGER( 76, T_MAY_IGNORE, c_plan_ahead)
97 NL_INTEGER( 77, T_MAY_IGNORE, c_delay_target)
98 NL_INTEGER( 78, T_MAY_IGNORE, c_fill_target)
99 NL_INTEGER( 79, T_MAY_IGNORE, c_max_rate)
100 NL_INTEGER( 80, T_MAY_IGNORE, c_min_rate)
90) 101)
91 102
92NL_PACKET(invalidate, 9, ) 103NL_PACKET(invalidate, 9, )
@@ -137,9 +148,13 @@ NL_PACKET(new_c_uuid, 26,
137 NL_BIT( 63, T_MANDATORY, clear_bm) 148 NL_BIT( 63, T_MANDATORY, clear_bm)
138) 149)
139 150
151#ifdef NL_RESPONSE
152NL_RESPONSE(return_code_only, 27)
153#endif
154
140#undef NL_PACKET 155#undef NL_PACKET
141#undef NL_INTEGER 156#undef NL_INTEGER
142#undef NL_INT64 157#undef NL_INT64
143#undef NL_BIT 158#undef NL_BIT
144#undef NL_STRING 159#undef NL_STRING
145 160#undef NL_RESPONSE
diff --git a/include/linux/drbd_tag_magic.h b/include/linux/drbd_tag_magic.h
index fcdff8410e99..069543190516 100644
--- a/include/linux/drbd_tag_magic.h
+++ b/include/linux/drbd_tag_magic.h
@@ -7,6 +7,7 @@
7/* declare packet_type enums */ 7/* declare packet_type enums */
8enum packet_types { 8enum packet_types {
9#define NL_PACKET(name, number, fields) P_ ## name = number, 9#define NL_PACKET(name, number, fields) P_ ## name = number,
10#define NL_RESPONSE(name, number) P_ ## name = number,
10#define NL_INTEGER(pn, pr, member) 11#define NL_INTEGER(pn, pr, member)
11#define NL_INT64(pn, pr, member) 12#define NL_INT64(pn, pr, member)
12#define NL_BIT(pn, pr, member) 13#define NL_BIT(pn, pr, member)
@@ -29,7 +30,7 @@ enum packet_types {
29 int tag_and_len ## member; 30 int tag_and_len ## member;
30#include "linux/drbd_nl.h" 31#include "linux/drbd_nl.h"
31 32
32/* declate tag-list-sizes */ 33/* declare tag-list-sizes */
33static const int tag_list_sizes[] = { 34static const int tag_list_sizes[] = {
34#define NL_PACKET(name, number, fields) 2 fields , 35#define NL_PACKET(name, number, fields) 2 fields ,
35#define NL_INTEGER(pn, pr, member) + 4 + 4 36#define NL_INTEGER(pn, pr, member) + 4 + 4
diff --git a/include/linux/dvb/frontend.h b/include/linux/dvb/frontend.h
index 493a2bf85f62..36a3ed63f571 100644
--- a/include/linux/dvb/frontend.h
+++ b/include/linux/dvb/frontend.h
@@ -175,14 +175,20 @@ typedef enum fe_transmit_mode {
175 TRANSMISSION_MODE_2K, 175 TRANSMISSION_MODE_2K,
176 TRANSMISSION_MODE_8K, 176 TRANSMISSION_MODE_8K,
177 TRANSMISSION_MODE_AUTO, 177 TRANSMISSION_MODE_AUTO,
178 TRANSMISSION_MODE_4K 178 TRANSMISSION_MODE_4K,
179 TRANSMISSION_MODE_1K,
180 TRANSMISSION_MODE_16K,
181 TRANSMISSION_MODE_32K,
179} fe_transmit_mode_t; 182} fe_transmit_mode_t;
180 183
181typedef enum fe_bandwidth { 184typedef enum fe_bandwidth {
182 BANDWIDTH_8_MHZ, 185 BANDWIDTH_8_MHZ,
183 BANDWIDTH_7_MHZ, 186 BANDWIDTH_7_MHZ,
184 BANDWIDTH_6_MHZ, 187 BANDWIDTH_6_MHZ,
185 BANDWIDTH_AUTO 188 BANDWIDTH_AUTO,
189 BANDWIDTH_5_MHZ,
190 BANDWIDTH_10_MHZ,
191 BANDWIDTH_1_712_MHZ,
186} fe_bandwidth_t; 192} fe_bandwidth_t;
187 193
188 194
@@ -191,7 +197,10 @@ typedef enum fe_guard_interval {
191 GUARD_INTERVAL_1_16, 197 GUARD_INTERVAL_1_16,
192 GUARD_INTERVAL_1_8, 198 GUARD_INTERVAL_1_8,
193 GUARD_INTERVAL_1_4, 199 GUARD_INTERVAL_1_4,
194 GUARD_INTERVAL_AUTO 200 GUARD_INTERVAL_AUTO,
201 GUARD_INTERVAL_1_128,
202 GUARD_INTERVAL_19_128,
203 GUARD_INTERVAL_19_256,
195} fe_guard_interval_t; 204} fe_guard_interval_t;
196 205
197 206
@@ -305,7 +314,9 @@ struct dvb_frontend_event {
305 314
306#define DTV_ISDBS_TS_ID 42 315#define DTV_ISDBS_TS_ID 42
307 316
308#define DTV_MAX_COMMAND DTV_ISDBS_TS_ID 317#define DTV_DVBT2_PLP_ID 43
318
319#define DTV_MAX_COMMAND DTV_DVBT2_PLP_ID
309 320
310typedef enum fe_pilot { 321typedef enum fe_pilot {
311 PILOT_ON, 322 PILOT_ON,
@@ -337,6 +348,7 @@ typedef enum fe_delivery_system {
337 SYS_DMBTH, 348 SYS_DMBTH,
338 SYS_CMMB, 349 SYS_CMMB,
339 SYS_DAB, 350 SYS_DAB,
351 SYS_DVBT2,
340} fe_delivery_system_t; 352} fe_delivery_system_t;
341 353
342struct dtv_cmds_h { 354struct dtv_cmds_h {
diff --git a/include/linux/dvb/version.h b/include/linux/dvb/version.h
index 5a7546c12688..1421cc84afaa 100644
--- a/include/linux/dvb/version.h
+++ b/include/linux/dvb/version.h
@@ -24,6 +24,6 @@
24#define _DVBVERSION_H_ 24#define _DVBVERSION_H_
25 25
26#define DVB_API_VERSION 5 26#define DVB_API_VERSION 5
27#define DVB_API_VERSION_MINOR 2 27#define DVB_API_VERSION_MINOR 3
28 28
29#endif /*_DVBVERSION_H_*/ 29#endif /*_DVBVERSION_H_*/
diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
index c8aad713a046..4bfe0a2f7d50 100644
--- a/include/linux/dw_dmac.h
+++ b/include/linux/dw_dmac.h
@@ -3,6 +3,7 @@
3 * AVR32 systems.) 3 * AVR32 systems.)
4 * 4 *
5 * Copyright (C) 2007 Atmel Corporation 5 * Copyright (C) 2007 Atmel Corporation
6 * Copyright (C) 2010-2011 ST Microelectronics
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -16,9 +17,18 @@
16/** 17/**
17 * struct dw_dma_platform_data - Controller configuration parameters 18 * struct dw_dma_platform_data - Controller configuration parameters
18 * @nr_channels: Number of channels supported by hardware (max 8) 19 * @nr_channels: Number of channels supported by hardware (max 8)
20 * @is_private: The device channels should be marked as private and not for
21 * by the general purpose DMA channel allocator.
19 */ 22 */
20struct dw_dma_platform_data { 23struct dw_dma_platform_data {
21 unsigned int nr_channels; 24 unsigned int nr_channels;
25 bool is_private;
26#define CHAN_ALLOCATION_ASCENDING 0 /* zero to seven */
27#define CHAN_ALLOCATION_DESCENDING 1 /* seven to zero */
28 unsigned char chan_allocation_order;
29#define CHAN_PRIORITY_ASCENDING 0 /* chan0 highest */
30#define CHAN_PRIORITY_DESCENDING 1 /* chan7 highest */
31 unsigned char chan_priority;
22}; 32};
23 33
24/** 34/**
@@ -33,6 +43,30 @@ enum dw_dma_slave_width {
33 DW_DMA_SLAVE_WIDTH_32BIT, 43 DW_DMA_SLAVE_WIDTH_32BIT,
34}; 44};
35 45
46/* bursts size */
47enum dw_dma_msize {
48 DW_DMA_MSIZE_1,
49 DW_DMA_MSIZE_4,
50 DW_DMA_MSIZE_8,
51 DW_DMA_MSIZE_16,
52 DW_DMA_MSIZE_32,
53 DW_DMA_MSIZE_64,
54 DW_DMA_MSIZE_128,
55 DW_DMA_MSIZE_256,
56};
57
58/* flow controller */
59enum dw_dma_fc {
60 DW_DMA_FC_D_M2M,
61 DW_DMA_FC_D_M2P,
62 DW_DMA_FC_D_P2M,
63 DW_DMA_FC_D_P2P,
64 DW_DMA_FC_P_P2M,
65 DW_DMA_FC_SP_P2P,
66 DW_DMA_FC_P_M2P,
67 DW_DMA_FC_DP_P2P,
68};
69
36/** 70/**
37 * struct dw_dma_slave - Controller-specific information about a slave 71 * struct dw_dma_slave - Controller-specific information about a slave
38 * 72 *
@@ -44,6 +78,11 @@ enum dw_dma_slave_width {
44 * @reg_width: peripheral register width 78 * @reg_width: peripheral register width
45 * @cfg_hi: Platform-specific initializer for the CFG_HI register 79 * @cfg_hi: Platform-specific initializer for the CFG_HI register
46 * @cfg_lo: Platform-specific initializer for the CFG_LO register 80 * @cfg_lo: Platform-specific initializer for the CFG_LO register
81 * @src_master: src master for transfers on allocated channel.
82 * @dst_master: dest master for transfers on allocated channel.
83 * @src_msize: src burst size.
84 * @dst_msize: dest burst size.
85 * @fc: flow controller for DMA transfer
47 */ 86 */
48struct dw_dma_slave { 87struct dw_dma_slave {
49 struct device *dma_dev; 88 struct device *dma_dev;
@@ -52,6 +91,11 @@ struct dw_dma_slave {
52 enum dw_dma_slave_width reg_width; 91 enum dw_dma_slave_width reg_width;
53 u32 cfg_hi; 92 u32 cfg_hi;
54 u32 cfg_lo; 93 u32 cfg_lo;
94 u8 src_master;
95 u8 dst_master;
96 u8 src_msize;
97 u8 dst_msize;
98 u8 fc;
55}; 99};
56 100
57/* Platform-configurable bits in CFG_HI */ 101/* Platform-configurable bits in CFG_HI */
@@ -62,7 +106,6 @@ struct dw_dma_slave {
62#define DWC_CFGH_DST_PER(x) ((x) << 11) 106#define DWC_CFGH_DST_PER(x) ((x) << 11)
63 107
64/* Platform-configurable bits in CFG_LO */ 108/* Platform-configurable bits in CFG_LO */
65#define DWC_CFGL_PRIO(x) ((x) << 5) /* priority */
66#define DWC_CFGL_LOCK_CH_XFER (0 << 12) /* scope of LOCK_CH */ 109#define DWC_CFGL_LOCK_CH_XFER (0 << 12) /* scope of LOCK_CH */
67#define DWC_CFGL_LOCK_CH_BLOCK (1 << 12) 110#define DWC_CFGL_LOCK_CH_BLOCK (1 << 12)
68#define DWC_CFGL_LOCK_CH_XACT (2 << 12) 111#define DWC_CFGL_LOCK_CH_XACT (2 << 12)
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 52c0da4bdd18..e747ecd48e1c 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -22,8 +22,6 @@ struct _ddebug {
22 const char *function; 22 const char *function;
23 const char *filename; 23 const char *filename;
24 const char *format; 24 const char *format;
25 char primary_hash;
26 char secondary_hash;
27 unsigned int lineno:24; 25 unsigned int lineno:24;
28 /* 26 /*
29 * The flags field controls the behaviour at the callsite. 27 * The flags field controls the behaviour at the callsite.
@@ -31,8 +29,13 @@ struct _ddebug {
31 * writes commands to <debugfs>/dynamic_debug/control 29 * writes commands to <debugfs>/dynamic_debug/control
32 */ 30 */
33#define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */ 31#define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */
32#define _DPRINTK_FLAGS_INCL_MODNAME (1<<1)
33#define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2)
34#define _DPRINTK_FLAGS_INCL_LINENO (1<<3)
35#define _DPRINTK_FLAGS_INCL_TID (1<<4)
34#define _DPRINTK_FLAGS_DEFAULT 0 36#define _DPRINTK_FLAGS_DEFAULT 0
35 unsigned int flags:8; 37 unsigned int flags:8;
38 char enabled;
36} __attribute__((aligned(8))); 39} __attribute__((aligned(8)));
37 40
38 41
@@ -41,23 +44,17 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
41 44
42#if defined(CONFIG_DYNAMIC_DEBUG) 45#if defined(CONFIG_DYNAMIC_DEBUG)
43extern int ddebug_remove_module(const char *mod_name); 46extern int ddebug_remove_module(const char *mod_name);
44 47extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
45#define __dynamic_dbg_enabled(dd) ({ \ 48 __attribute__ ((format (printf, 2, 3)));
46 int __ret = 0; \
47 if (unlikely((dynamic_debug_enabled & (1LL << DEBUG_HASH)) && \
48 (dynamic_debug_enabled2 & (1LL << DEBUG_HASH2)))) \
49 if (unlikely(dd.flags)) \
50 __ret = 1; \
51 __ret; })
52 49
53#define dynamic_pr_debug(fmt, ...) do { \ 50#define dynamic_pr_debug(fmt, ...) do { \
54 static struct _ddebug descriptor \ 51 static struct _ddebug descriptor \
55 __used \ 52 __used \
56 __attribute__((section("__verbose"), aligned(8))) = \ 53 __attribute__((section("__verbose"), aligned(8))) = \
57 { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ 54 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \
58 DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ 55 _DPRINTK_FLAGS_DEFAULT }; \
59 if (__dynamic_dbg_enabled(descriptor)) \ 56 if (unlikely(descriptor.enabled)) \
60 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ 57 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \
61 } while (0) 58 } while (0)
62 59
63 60
@@ -65,9 +62,9 @@ extern int ddebug_remove_module(const char *mod_name);
65 static struct _ddebug descriptor \ 62 static struct _ddebug descriptor \
66 __used \ 63 __used \
67 __attribute__((section("__verbose"), aligned(8))) = \ 64 __attribute__((section("__verbose"), aligned(8))) = \
68 { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ 65 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \
69 DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ 66 _DPRINTK_FLAGS_DEFAULT }; \
70 if (__dynamic_dbg_enabled(descriptor)) \ 67 if (unlikely(descriptor.enabled)) \
71 dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ 68 dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
72 } while (0) 69 } while (0)
73 70
@@ -80,7 +77,7 @@ static inline int ddebug_remove_module(const char *mod)
80 77
81#define dynamic_pr_debug(fmt, ...) \ 78#define dynamic_pr_debug(fmt, ...) \
82 do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) 79 do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
83#define dynamic_dev_dbg(dev, format, ...) \ 80#define dynamic_dev_dbg(dev, fmt, ...) \
84 do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) 81 do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0)
85#endif 82#endif
86 83
diff --git a/include/linux/early_res.h b/include/linux/early_res.h
deleted file mode 100644
index 29c09f57a13c..000000000000
--- a/include/linux/early_res.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#ifndef _LINUX_EARLY_RES_H
2#define _LINUX_EARLY_RES_H
3#ifdef __KERNEL__
4
5extern void reserve_early(u64 start, u64 end, char *name);
6extern void reserve_early_overlap_ok(u64 start, u64 end, char *name);
7extern void free_early(u64 start, u64 end);
8void free_early_partial(u64 start, u64 end);
9extern void early_res_to_bootmem(u64 start, u64 end);
10
11void reserve_early_without_check(u64 start, u64 end, char *name);
12u64 find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end,
13 u64 size, u64 align);
14u64 find_early_area_size(u64 ei_start, u64 ei_last, u64 start,
15 u64 *sizep, u64 align);
16u64 find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align);
17u64 get_max_mapped(void);
18#include <linux/range.h>
19int get_free_all_memory_range(struct range **rangep, int nodeid);
20
21#endif /* __KERNEL__ */
22
23#endif /* _LINUX_EARLY_RES_H */
diff --git a/include/linux/edac.h b/include/linux/edac.h
index 7cf92e8a4196..36c66443bdfd 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -13,6 +13,7 @@
13#define _LINUX_EDAC_H_ 13#define _LINUX_EDAC_H_
14 14
15#include <asm/atomic.h> 15#include <asm/atomic.h>
16#include <linux/sysdev.h>
16 17
17#define EDAC_OPSTATE_INVAL -1 18#define EDAC_OPSTATE_INVAL -1
18#define EDAC_OPSTATE_POLL 0 19#define EDAC_OPSTATE_POLL 0
@@ -22,9 +23,12 @@
22extern int edac_op_state; 23extern int edac_op_state;
23extern int edac_err_assert; 24extern int edac_err_assert;
24extern atomic_t edac_handlers; 25extern atomic_t edac_handlers;
26extern struct sysdev_class edac_class;
25 27
26extern int edac_handler_set(void); 28extern int edac_handler_set(void);
27extern void edac_atomic_assert_error(void); 29extern void edac_atomic_assert_error(void);
30extern struct sysdev_class *edac_get_sysfs_class(void);
31extern void edac_put_sysfs_class(void);
28 32
29static inline void opstate_init(void) 33static inline void opstate_init(void)
30{ 34{
diff --git a/include/linux/efi.h b/include/linux/efi.h
index fb737bc19a8c..e376270cd26e 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -299,6 +299,7 @@ extern void efi_initialize_iomem_resources(struct resource *code_resource,
299 struct resource *data_resource, struct resource *bss_resource); 299 struct resource *data_resource, struct resource *bss_resource);
300extern unsigned long efi_get_time(void); 300extern unsigned long efi_get_time(void);
301extern int efi_set_rtc_mmss(unsigned long nowtime); 301extern int efi_set_rtc_mmss(unsigned long nowtime);
302extern void efi_reserve_boot_services(void);
302extern struct efi_memory_map memmap; 303extern struct efi_memory_map memmap;
303 304
304/** 305/**
@@ -397,4 +398,41 @@ static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
397 *addr &= PAGE_MASK; 398 *addr &= PAGE_MASK;
398} 399}
399 400
401#if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE)
402/*
403 * EFI Variable support.
404 *
405 * Different firmware drivers can expose their EFI-like variables using
406 * the following.
407 */
408
409struct efivar_operations {
410 efi_get_variable_t *get_variable;
411 efi_get_next_variable_t *get_next_variable;
412 efi_set_variable_t *set_variable;
413};
414
415struct efivars {
416 /*
417 * ->lock protects two things:
418 * 1) ->list - adds, removals, reads, writes
419 * 2) ops.[gs]et_variable() calls.
420 * It must not be held when creating sysfs entries or calling kmalloc.
421 * ops.get_next_variable() is only called from register_efivars(),
422 * which is protected by the BKL, so that path is safe.
423 */
424 spinlock_t lock;
425 struct list_head list;
426 struct kset *kset;
427 struct bin_attribute *new_var, *del_var;
428 const struct efivar_operations *ops;
429};
430
431int register_efivars(struct efivars *efivars,
432 const struct efivar_operations *ops,
433 struct kobject *parent_kobj);
434void unregister_efivars(struct efivars *efivars);
435
436#endif /* CONFIG_EFI_VARS */
437
400#endif /* _LINUX_EFI_H */ 438#endif /* _LINUX_EFI_H */
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 4fd978e7eb83..21a8ebf2dc3a 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -20,7 +20,6 @@ typedef void (elevator_bio_merged_fn) (struct request_queue *,
20typedef int (elevator_dispatch_fn) (struct request_queue *, int); 20typedef int (elevator_dispatch_fn) (struct request_queue *, int);
21 21
22typedef void (elevator_add_req_fn) (struct request_queue *, struct request *); 22typedef void (elevator_add_req_fn) (struct request_queue *, struct request *);
23typedef int (elevator_queue_empty_fn) (struct request_queue *);
24typedef struct request *(elevator_request_list_fn) (struct request_queue *, struct request *); 23typedef struct request *(elevator_request_list_fn) (struct request_queue *, struct request *);
25typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *); 24typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *);
26typedef int (elevator_may_queue_fn) (struct request_queue *, int); 25typedef int (elevator_may_queue_fn) (struct request_queue *, int);
@@ -46,7 +45,6 @@ struct elevator_ops
46 elevator_activate_req_fn *elevator_activate_req_fn; 45 elevator_activate_req_fn *elevator_activate_req_fn;
47 elevator_deactivate_req_fn *elevator_deactivate_req_fn; 46 elevator_deactivate_req_fn *elevator_deactivate_req_fn;
48 47
49 elevator_queue_empty_fn *elevator_queue_empty_fn;
50 elevator_completed_req_fn *elevator_completed_req_fn; 48 elevator_completed_req_fn *elevator_completed_req_fn;
51 49
52 elevator_request_list_fn *elevator_former_req_fn; 50 elevator_request_list_fn *elevator_former_req_fn;
@@ -101,17 +99,16 @@ struct elevator_queue
101 */ 99 */
102extern void elv_dispatch_sort(struct request_queue *, struct request *); 100extern void elv_dispatch_sort(struct request_queue *, struct request *);
103extern void elv_dispatch_add_tail(struct request_queue *, struct request *); 101extern void elv_dispatch_add_tail(struct request_queue *, struct request *);
104extern void elv_add_request(struct request_queue *, struct request *, int, int); 102extern void elv_add_request(struct request_queue *, struct request *, int);
105extern void __elv_add_request(struct request_queue *, struct request *, int, int); 103extern void __elv_add_request(struct request_queue *, struct request *, int);
106extern void elv_insert(struct request_queue *, struct request *, int);
107extern int elv_merge(struct request_queue *, struct request **, struct bio *); 104extern int elv_merge(struct request_queue *, struct request **, struct bio *);
105extern int elv_try_merge(struct request *, struct bio *);
108extern void elv_merge_requests(struct request_queue *, struct request *, 106extern void elv_merge_requests(struct request_queue *, struct request *,
109 struct request *); 107 struct request *);
110extern void elv_merged_request(struct request_queue *, struct request *, int); 108extern void elv_merged_request(struct request_queue *, struct request *, int);
111extern void elv_bio_merged(struct request_queue *q, struct request *, 109extern void elv_bio_merged(struct request_queue *q, struct request *,
112 struct bio *); 110 struct bio *);
113extern void elv_requeue_request(struct request_queue *, struct request *); 111extern void elv_requeue_request(struct request_queue *, struct request *);
114extern int elv_queue_empty(struct request_queue *);
115extern struct request *elv_former_request(struct request_queue *, struct request *); 112extern struct request *elv_former_request(struct request_queue *, struct request *);
116extern struct request *elv_latter_request(struct request_queue *, struct request *); 113extern struct request *elv_latter_request(struct request_queue *, struct request *);
117extern int elv_register_queue(struct request_queue *q); 114extern int elv_register_queue(struct request_queue *q);
@@ -167,6 +164,8 @@ extern struct request *elv_rb_find(struct rb_root *, sector_t);
167#define ELEVATOR_INSERT_BACK 2 164#define ELEVATOR_INSERT_BACK 2
168#define ELEVATOR_INSERT_SORT 3 165#define ELEVATOR_INSERT_SORT 3
169#define ELEVATOR_INSERT_REQUEUE 4 166#define ELEVATOR_INSERT_REQUEUE 4
167#define ELEVATOR_INSERT_FLUSH 5
168#define ELEVATOR_INSERT_SORT_MERGE 6
170 169
171/* 170/*
172 * return values from elevator_may_queue_fn 171 * return values from elevator_may_queue_fn
@@ -195,15 +194,9 @@ enum {
195/* 194/*
196 * io context count accounting 195 * io context count accounting
197 */ 196 */
198#define elv_ioc_count_mod(name, __val) \ 197#define elv_ioc_count_mod(name, __val) this_cpu_add(name, __val)
199 do { \ 198#define elv_ioc_count_inc(name) this_cpu_inc(name)
200 preempt_disable(); \ 199#define elv_ioc_count_dec(name) this_cpu_dec(name)
201 __get_cpu_var(name) += (__val); \
202 preempt_enable(); \
203 } while (0)
204
205#define elv_ioc_count_inc(name) elv_ioc_count_mod(name, 1)
206#define elv_ioc_count_dec(name) elv_ioc_count_mod(name, -1)
207 200
208#define elv_ioc_count_read(name) \ 201#define elv_ioc_count_read(name) \
209({ \ 202({ \
diff --git a/include/linux/elf.h b/include/linux/elf.h
index 4d608014753a..110821cb6ea5 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -395,6 +395,7 @@ typedef struct elf64_shdr {
395#define NT_S390_CTRS 0x304 /* s390 control registers */ 395#define NT_S390_CTRS 0x304 /* s390 control registers */
396#define NT_S390_PREFIX 0x305 /* s390 prefix register */ 396#define NT_S390_PREFIX 0x305 /* s390 prefix register */
397#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */ 397#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */
398#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
398 399
399 400
400/* Note header in a PT_NOTE section */ 401/* Note header in a PT_NOTE section */
diff --git a/include/linux/err.h b/include/linux/err.h
index 448afc12c78a..f2edce25a76b 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -52,6 +52,14 @@ static inline void * __must_check ERR_CAST(const void *ptr)
52 return (void *) ptr; 52 return (void *) ptr;
53} 53}
54 54
55static inline int __must_check PTR_RET(const void *ptr)
56{
57 if (IS_ERR(ptr))
58 return PTR_ERR(ptr);
59 else
60 return 0;
61}
62
55#endif 63#endif
56 64
57#endif /* _LINUX_ERR_H */ 65#endif /* _LINUX_ERR_H */
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 2308fbb4523a..ab68f785fd19 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -48,8 +48,10 @@ extern int eth_validate_addr(struct net_device *dev);
48 48
49 49
50 50
51extern struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count); 51extern struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
52 unsigned int rxqs);
52#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1) 53#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
54#define alloc_etherdev_mq(sizeof_priv, count) alloc_etherdev_mqs(sizeof_priv, count, count)
53 55
54/** 56/**
55 * is_zero_ether_addr - Determine if give Ethernet address is all zeros. 57 * is_zero_ether_addr - Determine if give Ethernet address is all zeros.
@@ -71,7 +73,7 @@ static inline int is_zero_ether_addr(const u8 *addr)
71 */ 73 */
72static inline int is_multicast_ether_addr(const u8 *addr) 74static inline int is_multicast_ether_addr(const u8 *addr)
73{ 75{
74 return (0x01 & addr[0]); 76 return 0x01 & addr[0];
75} 77}
76 78
77/** 79/**
@@ -82,7 +84,7 @@ static inline int is_multicast_ether_addr(const u8 *addr)
82 */ 84 */
83static inline int is_local_ether_addr(const u8 *addr) 85static inline int is_local_ether_addr(const u8 *addr)
84{ 86{
85 return (0x02 & addr[0]); 87 return 0x02 & addr[0];
86} 88}
87 89
88/** 90/**
@@ -97,6 +99,17 @@ static inline int is_broadcast_ether_addr(const u8 *addr)
97} 99}
98 100
99/** 101/**
102 * is_unicast_ether_addr - Determine if the Ethernet address is unicast
103 * @addr: Pointer to a six-byte array containing the Ethernet address
104 *
105 * Return true if the address is a unicast address.
106 */
107static inline int is_unicast_ether_addr(const u8 *addr)
108{
109 return !is_multicast_ether_addr(addr);
110}
111
112/**
100 * is_valid_ether_addr - Determine if the given Ethernet address is valid 113 * is_valid_ether_addr - Determine if the given Ethernet address is valid
101 * @addr: Pointer to a six-byte array containing the Ethernet address 114 * @addr: Pointer to a six-byte array containing the Ethernet address
102 * 115 *
@@ -237,13 +250,29 @@ static inline bool is_etherdev_addr(const struct net_device *dev,
237 * entry points. 250 * entry points.
238 */ 251 */
239 252
240static inline int compare_ether_header(const void *a, const void *b) 253static inline unsigned long compare_ether_header(const void *a, const void *b)
241{ 254{
255#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
256 unsigned long fold;
257
258 /*
259 * We want to compare 14 bytes:
260 * [a0 ... a13] ^ [b0 ... b13]
261 * Use two long XOR, ORed together, with an overlap of two bytes.
262 * [a0 a1 a2 a3 a4 a5 a6 a7 ] ^ [b0 b1 b2 b3 b4 b5 b6 b7 ] |
263 * [a6 a7 a8 a9 a10 a11 a12 a13] ^ [b6 b7 b8 b9 b10 b11 b12 b13]
264 * This means the [a6 a7] ^ [b6 b7] part is done two times.
265 */
266 fold = *(unsigned long *)a ^ *(unsigned long *)b;
267 fold |= *(unsigned long *)(a + 6) ^ *(unsigned long *)(b + 6);
268 return fold;
269#else
242 u32 *a32 = (u32 *)((u8 *)a + 2); 270 u32 *a32 = (u32 *)((u8 *)a + 2);
243 u32 *b32 = (u32 *)((u8 *)b + 2); 271 u32 *b32 = (u32 *)((u8 *)b + 2);
244 272
245 return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) | 273 return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) |
246 (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]); 274 (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]);
275#endif
247} 276}
248 277
249#endif /* _LINUX_ETHERDEVICE_H */ 278#endif /* _LINUX_ETHERDEVICE_H */
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 991269e5b152..439b173c5882 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -13,14 +13,21 @@
13#ifndef _LINUX_ETHTOOL_H 13#ifndef _LINUX_ETHTOOL_H
14#define _LINUX_ETHTOOL_H 14#define _LINUX_ETHTOOL_H
15 15
16#ifdef __KERNEL__
17#include <linux/compat.h>
18#endif
16#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/if_ether.h>
17 21
18/* This should work for both 32 and 64 bit userland. */ 22/* This should work for both 32 and 64 bit userland. */
19struct ethtool_cmd { 23struct ethtool_cmd {
20 __u32 cmd; 24 __u32 cmd;
21 __u32 supported; /* Features this interface supports */ 25 __u32 supported; /* Features this interface supports */
22 __u32 advertising; /* Features this interface advertises */ 26 __u32 advertising; /* Features this interface advertises */
23 __u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */ 27 __u16 speed; /* The forced speed (lower bits) in
28 * Mbps. Please use
29 * ethtool_cmd_speed()/_set() to
30 * access it */
24 __u8 duplex; /* Duplex, half or full */ 31 __u8 duplex; /* Duplex, half or full */
25 __u8 port; /* Which connector port */ 32 __u8 port; /* Which connector port */
26 __u8 phy_address; 33 __u8 phy_address;
@@ -29,7 +36,10 @@ struct ethtool_cmd {
29 __u8 mdio_support; 36 __u8 mdio_support;
30 __u32 maxtxpkt; /* Tx pkts before generating tx int */ 37 __u32 maxtxpkt; /* Tx pkts before generating tx int */
31 __u32 maxrxpkt; /* Rx pkts before generating rx int */ 38 __u32 maxrxpkt; /* Rx pkts before generating rx int */
32 __u16 speed_hi; 39 __u16 speed_hi; /* The forced speed (upper
40 * bits) in Mbps. Please use
41 * ethtool_cmd_speed()/_set() to
42 * access it */
33 __u8 eth_tp_mdix; 43 __u8 eth_tp_mdix;
34 __u8 reserved2; 44 __u8 reserved2;
35 __u32 lp_advertising; /* Features the link partner advertises */ 45 __u32 lp_advertising; /* Features the link partner advertises */
@@ -37,14 +47,14 @@ struct ethtool_cmd {
37}; 47};
38 48
39static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, 49static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
40 __u32 speed) 50 __u32 speed)
41{ 51{
42 52
43 ep->speed = (__u16)speed; 53 ep->speed = (__u16)speed;
44 ep->speed_hi = (__u16)(speed >> 16); 54 ep->speed_hi = (__u16)(speed >> 16);
45} 55}
46 56
47static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep) 57static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
48{ 58{
49 return (ep->speed_hi << 16) | ep->speed; 59 return (ep->speed_hi << 16) | ep->speed;
50} 60}
@@ -225,12 +235,40 @@ struct ethtool_ringparam {
225 __u32 tx_pending; 235 __u32 tx_pending;
226}; 236};
227 237
238/**
239 * struct ethtool_channels - configuring number of network channel
240 * @cmd: ETHTOOL_{G,S}CHANNELS
241 * @max_rx: Read only. Maximum number of receive channel the driver support.
242 * @max_tx: Read only. Maximum number of transmit channel the driver support.
243 * @max_other: Read only. Maximum number of other channel the driver support.
244 * @max_combined: Read only. Maximum number of combined channel the driver
245 * support. Set of queues RX, TX or other.
246 * @rx_count: Valid values are in the range 1 to the max_rx.
247 * @tx_count: Valid values are in the range 1 to the max_tx.
248 * @other_count: Valid values are in the range 1 to the max_other.
249 * @combined_count: Valid values are in the range 1 to the max_combined.
250 *
251 * This can be used to configure RX, TX and other channels.
252 */
253
254struct ethtool_channels {
255 __u32 cmd;
256 __u32 max_rx;
257 __u32 max_tx;
258 __u32 max_other;
259 __u32 max_combined;
260 __u32 rx_count;
261 __u32 tx_count;
262 __u32 other_count;
263 __u32 combined_count;
264};
265
228/* for configuring link flow control parameters */ 266/* for configuring link flow control parameters */
229struct ethtool_pauseparam { 267struct ethtool_pauseparam {
230 __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ 268 __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
231 269
232 /* If the link is being auto-negotiated (via ethtool_cmd.autoneg 270 /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
233 * being true) the user may set 'autonet' here non-zero to have the 271 * being true) the user may set 'autoneg' here non-zero to have the
234 * pause parameters be auto-negotiated too. In such a case, the 272 * pause parameters be auto-negotiated too. In such a case, the
235 * {rx,tx}_pause values below determine what capabilities are 273 * {rx,tx}_pause values below determine what capabilities are
236 * advertised. 274 * advertised.
@@ -250,6 +288,7 @@ enum ethtool_stringset {
250 ETH_SS_STATS, 288 ETH_SS_STATS,
251 ETH_SS_PRIV_FLAGS, 289 ETH_SS_PRIV_FLAGS,
252 ETH_SS_NTUPLE_FILTERS, 290 ETH_SS_NTUPLE_FILTERS,
291 ETH_SS_FEATURES,
253}; 292};
254 293
255/* for passing string sets for data tagging */ 294/* for passing string sets for data tagging */
@@ -308,15 +347,28 @@ struct ethtool_perm_addr {
308 * flag differs from the read-only value. 347 * flag differs from the read-only value.
309 */ 348 */
310enum ethtool_flags { 349enum ethtool_flags {
350 ETH_FLAG_TXVLAN = (1 << 7), /* TX VLAN offload enabled */
351 ETH_FLAG_RXVLAN = (1 << 8), /* RX VLAN offload enabled */
311 ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */ 352 ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */
312 ETH_FLAG_NTUPLE = (1 << 27), /* N-tuple filters enabled */ 353 ETH_FLAG_NTUPLE = (1 << 27), /* N-tuple filters enabled */
313 ETH_FLAG_RXHASH = (1 << 28), 354 ETH_FLAG_RXHASH = (1 << 28),
314}; 355};
315 356
316/* The following structures are for supporting RX network flow 357/* The following structures are for supporting RX network flow
317 * classification configuration. Note, all multibyte fields, e.g., 358 * classification and RX n-tuple configuration. Note, all multibyte
318 * ip4src, ip4dst, psrc, pdst, spi, etc. are expected to be in network 359 * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to
319 * byte order. 360 * be in network byte order.
361 */
362
363/**
364 * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc.
365 * @ip4src: Source host
366 * @ip4dst: Destination host
367 * @psrc: Source port
368 * @pdst: Destination port
369 * @tos: Type-of-service
370 *
371 * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow.
320 */ 372 */
321struct ethtool_tcpip4_spec { 373struct ethtool_tcpip4_spec {
322 __be32 ip4src; 374 __be32 ip4src;
@@ -326,6 +378,15 @@ struct ethtool_tcpip4_spec {
326 __u8 tos; 378 __u8 tos;
327}; 379};
328 380
381/**
382 * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4
383 * @ip4src: Source host
384 * @ip4dst: Destination host
385 * @spi: Security parameters index
386 * @tos: Type-of-service
387 *
388 * This can be used to specify an IPsec transport or tunnel over IPv4.
389 */
329struct ethtool_ah_espip4_spec { 390struct ethtool_ah_espip4_spec {
330 __be32 ip4src; 391 __be32 ip4src;
331 __be32 ip4dst; 392 __be32 ip4dst;
@@ -333,21 +394,17 @@ struct ethtool_ah_espip4_spec {
333 __u8 tos; 394 __u8 tos;
334}; 395};
335 396
336struct ethtool_rawip4_spec {
337 __be32 ip4src;
338 __be32 ip4dst;
339 __u8 hdata[64];
340};
341
342struct ethtool_ether_spec {
343 __be16 ether_type;
344 __u8 frame_size;
345 __u8 eframe[16];
346};
347
348#define ETH_RX_NFC_IP4 1 397#define ETH_RX_NFC_IP4 1
349#define ETH_RX_NFC_IP6 2
350 398
399/**
400 * struct ethtool_usrip4_spec - general flow specification for IPv4
401 * @ip4src: Source host
402 * @ip4dst: Destination host
403 * @l4_4_bytes: First 4 bytes of transport (layer 4) header
404 * @tos: Type-of-service
405 * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
406 * @proto: Transport protocol number; mask must be 0
407 */
351struct ethtool_usrip4_spec { 408struct ethtool_usrip4_spec {
352 __be32 ip4src; 409 __be32 ip4src;
353 __be32 ip4dst; 410 __be32 ip4dst;
@@ -357,44 +414,148 @@ struct ethtool_usrip4_spec {
357 __u8 proto; 414 __u8 proto;
358}; 415};
359 416
417union ethtool_flow_union {
418 struct ethtool_tcpip4_spec tcp_ip4_spec;
419 struct ethtool_tcpip4_spec udp_ip4_spec;
420 struct ethtool_tcpip4_spec sctp_ip4_spec;
421 struct ethtool_ah_espip4_spec ah_ip4_spec;
422 struct ethtool_ah_espip4_spec esp_ip4_spec;
423 struct ethtool_usrip4_spec usr_ip4_spec;
424 struct ethhdr ether_spec;
425 __u8 hdata[60];
426};
427
428struct ethtool_flow_ext {
429 __be16 vlan_etype;
430 __be16 vlan_tci;
431 __be32 data[2];
432};
433
434/**
435 * struct ethtool_rx_flow_spec - specification for RX flow filter
436 * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
437 * @h_u: Flow fields to match (dependent on @flow_type)
438 * @h_ext: Additional fields to match
439 * @m_u: Masks for flow field bits to be matched
440 * @m_ext: Masks for additional field bits to be matched
441 * Note, all additional fields must be ignored unless @flow_type
442 * includes the %FLOW_EXT flag.
443 * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
444 * if packets should be discarded
445 * @location: Index of filter in hardware table
446 */
360struct ethtool_rx_flow_spec { 447struct ethtool_rx_flow_spec {
361 __u32 flow_type; 448 __u32 flow_type;
362 union { 449 union ethtool_flow_union h_u;
363 struct ethtool_tcpip4_spec tcp_ip4_spec; 450 struct ethtool_flow_ext h_ext;
364 struct ethtool_tcpip4_spec udp_ip4_spec; 451 union ethtool_flow_union m_u;
365 struct ethtool_tcpip4_spec sctp_ip4_spec; 452 struct ethtool_flow_ext m_ext;
366 struct ethtool_ah_espip4_spec ah_ip4_spec;
367 struct ethtool_ah_espip4_spec esp_ip4_spec;
368 struct ethtool_rawip4_spec raw_ip4_spec;
369 struct ethtool_ether_spec ether_spec;
370 struct ethtool_usrip4_spec usr_ip4_spec;
371 __u8 hdata[64];
372 } h_u, m_u; /* entry, mask */
373 __u64 ring_cookie; 453 __u64 ring_cookie;
374 __u32 location; 454 __u32 location;
375}; 455};
376 456
457/**
458 * struct ethtool_rxnfc - command to get or set RX flow classification rules
459 * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
460 * %ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE,
461 * %ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS
462 * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW
463 * @data: Command-dependent value
464 * @fs: Flow filter specification
465 * @rule_cnt: Number of rules to be affected
466 * @rule_locs: Array of valid rule indices
467 *
468 * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating
469 * the fields included in the flow hash, e.g. %RXH_IP_SRC. The following
470 * structure fields must not be used.
471 *
472 * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues
473 * on return.
474 *
475 * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined
476 * rules on return.
477 *
478 * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the index of an
479 * existing filter rule on entry and @fs contains the rule on return.
480 *
481 * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
482 * user buffer for @rule_locs on entry. On return, @data is the size
483 * of the filter table and @rule_locs contains the indices of the
484 * defined rules.
485 *
486 * For %ETHTOOL_SRXCLSRLINS, @fs specifies the filter rule to add or
487 * update. @fs.@location specifies the index to use and must not be
488 * ignored.
489 *
490 * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the index of an
491 * existing filter rule on entry.
492 *
493 * Implementation of indexed classification rules generally requires a
494 * TCAM.
495 */
377struct ethtool_rxnfc { 496struct ethtool_rxnfc {
378 __u32 cmd; 497 __u32 cmd;
379 __u32 flow_type; 498 __u32 flow_type;
380 /* The rx flow hash value or the rule DB size */
381 __u64 data; 499 __u64 data;
382 /* The following fields are not valid and must not be used for
383 * the ETHTOOL_{G,X}RXFH commands. */
384 struct ethtool_rx_flow_spec fs; 500 struct ethtool_rx_flow_spec fs;
385 __u32 rule_cnt; 501 __u32 rule_cnt;
386 __u32 rule_locs[0]; 502 __u32 rule_locs[0];
387}; 503};
388 504
505#ifdef __KERNEL__
506#ifdef CONFIG_COMPAT
507
508struct compat_ethtool_rx_flow_spec {
509 u32 flow_type;
510 union ethtool_flow_union h_u;
511 struct ethtool_flow_ext h_ext;
512 union ethtool_flow_union m_u;
513 struct ethtool_flow_ext m_ext;
514 compat_u64 ring_cookie;
515 u32 location;
516};
517
518struct compat_ethtool_rxnfc {
519 u32 cmd;
520 u32 flow_type;
521 compat_u64 data;
522 struct compat_ethtool_rx_flow_spec fs;
523 u32 rule_cnt;
524 u32 rule_locs[0];
525};
526
527#endif /* CONFIG_COMPAT */
528#endif /* __KERNEL__ */
529
530/**
531 * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
532 * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
533 * @size: On entry, the array size of the user buffer. On return from
534 * %ETHTOOL_GRXFHINDIR, the array size of the hardware indirection table.
535 * @ring_index: RX ring/queue index for each hash value
536 */
389struct ethtool_rxfh_indir { 537struct ethtool_rxfh_indir {
390 __u32 cmd; 538 __u32 cmd;
391 /* On entry, this is the array size of the user buffer. On
392 * return from ETHTOOL_GRXFHINDIR, this is the array size of
393 * the hardware indirection table. */
394 __u32 size; 539 __u32 size;
395 __u32 ring_index[0]; /* ring/queue index for each hash value */ 540 __u32 ring_index[0];
396}; 541};
397 542
543/**
544 * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
545 * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
546 * @h_u: Flow field values to match (dependent on @flow_type)
547 * @m_u: Masks for flow field value bits to be ignored
548 * @vlan_tag: VLAN tag to match
549 * @vlan_tag_mask: Mask for VLAN tag bits to be ignored
550 * @data: Driver-dependent data to match
551 * @data_mask: Mask for driver-dependent data bits to be ignored
552 * @action: RX ring/queue index to deliver to (non-negative) or other action
553 * (negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP)
554 *
555 * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where
556 * a field value and mask are both zero this is treated as if all mask
557 * bits are set i.e. the field is ignored.
558 */
398struct ethtool_rx_ntuple_flow_spec { 559struct ethtool_rx_ntuple_flow_spec {
399 __u32 flow_type; 560 __u32 flow_type;
400 union { 561 union {
@@ -403,22 +564,26 @@ struct ethtool_rx_ntuple_flow_spec {
403 struct ethtool_tcpip4_spec sctp_ip4_spec; 564 struct ethtool_tcpip4_spec sctp_ip4_spec;
404 struct ethtool_ah_espip4_spec ah_ip4_spec; 565 struct ethtool_ah_espip4_spec ah_ip4_spec;
405 struct ethtool_ah_espip4_spec esp_ip4_spec; 566 struct ethtool_ah_espip4_spec esp_ip4_spec;
406 struct ethtool_rawip4_spec raw_ip4_spec;
407 struct ethtool_ether_spec ether_spec;
408 struct ethtool_usrip4_spec usr_ip4_spec; 567 struct ethtool_usrip4_spec usr_ip4_spec;
409 __u8 hdata[64]; 568 struct ethhdr ether_spec;
410 } h_u, m_u; /* entry, mask */ 569 __u8 hdata[72];
570 } h_u, m_u;
411 571
412 __u16 vlan_tag; 572 __u16 vlan_tag;
413 __u16 vlan_tag_mask; 573 __u16 vlan_tag_mask;
414 __u64 data; /* user-defined flow spec data */ 574 __u64 data;
415 __u64 data_mask; /* user-defined flow spec mask */ 575 __u64 data_mask;
416 576
417 /* signed to distinguish between queue and actions (DROP) */
418 __s32 action; 577 __s32 action;
419#define ETHTOOL_RXNTUPLE_ACTION_DROP -1 578#define ETHTOOL_RXNTUPLE_ACTION_DROP (-1) /* drop packet */
579#define ETHTOOL_RXNTUPLE_ACTION_CLEAR (-2) /* clear filter */
420}; 580};
421 581
582/**
583 * struct ethtool_rx_ntuple - command to set or clear RX flow filter
584 * @cmd: Command number - %ETHTOOL_SRXNTUPLE
585 * @fs: Flow filter specification
586 */
422struct ethtool_rx_ntuple { 587struct ethtool_rx_ntuple {
423 __u32 cmd; 588 __u32 cmd;
424 struct ethtool_rx_ntuple_flow_spec fs; 589 struct ethtool_rx_ntuple_flow_spec fs;
@@ -436,10 +601,119 @@ struct ethtool_flash {
436 char data[ETHTOOL_FLASH_MAX_FILENAME]; 601 char data[ETHTOOL_FLASH_MAX_FILENAME];
437}; 602};
438 603
604/**
605 * struct ethtool_dump - used for retrieving, setting device dump
606 * @cmd: Command number - %ETHTOOL_GET_DUMP_FLAG, %ETHTOOL_GET_DUMP_DATA, or
607 * %ETHTOOL_SET_DUMP
608 * @version: FW version of the dump, filled in by driver
609 * @flag: driver dependent flag for dump setting, filled in by driver during
610 * get and filled in by ethtool for set operation
611 * @len: length of dump data, used as the length of the user buffer on entry to
612 * %ETHTOOL_GET_DUMP_DATA and this is returned as dump length by driver
613 * for %ETHTOOL_GET_DUMP_FLAG command
614 * @data: data collected for get dump data operation
615 */
616struct ethtool_dump {
617 __u32 cmd;
618 __u32 version;
619 __u32 flag;
620 __u32 len;
621 __u8 data[0];
622};
623
624/* for returning and changing feature sets */
625
626/**
627 * struct ethtool_get_features_block - block with state of 32 features
628 * @available: mask of changeable features
629 * @requested: mask of features requested to be enabled if possible
630 * @active: mask of currently enabled features
631 * @never_changed: mask of features not changeable for any device
632 */
633struct ethtool_get_features_block {
634 __u32 available;
635 __u32 requested;
636 __u32 active;
637 __u32 never_changed;
638};
639
640/**
641 * struct ethtool_gfeatures - command to get state of device's features
642 * @cmd: command number = %ETHTOOL_GFEATURES
643 * @size: in: number of elements in the features[] array;
644 * out: number of elements in features[] needed to hold all features
645 * @features: state of features
646 */
647struct ethtool_gfeatures {
648 __u32 cmd;
649 __u32 size;
650 struct ethtool_get_features_block features[0];
651};
652
653/**
654 * struct ethtool_set_features_block - block with request for 32 features
655 * @valid: mask of features to be changed
656 * @requested: values of features to be changed
657 */
658struct ethtool_set_features_block {
659 __u32 valid;
660 __u32 requested;
661};
662
663/**
664 * struct ethtool_sfeatures - command to request change in device's features
665 * @cmd: command number = %ETHTOOL_SFEATURES
666 * @size: array size of the features[] array
667 * @features: feature change masks
668 */
669struct ethtool_sfeatures {
670 __u32 cmd;
671 __u32 size;
672 struct ethtool_set_features_block features[0];
673};
674
675/*
676 * %ETHTOOL_SFEATURES changes features present in features[].valid to the
677 * values of corresponding bits in features[].requested. Bits in .requested
678 * not set in .valid or not changeable are ignored.
679 *
680 * Returns %EINVAL when .valid contains undefined or never-changeable bits
681 * or size is not equal to required number of features words (32-bit blocks).
682 * Returns >= 0 if request was completed; bits set in the value mean:
683 * %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not
684 * changeable (not present in %ETHTOOL_GFEATURES' features[].available)
685 * those bits were ignored.
686 * %ETHTOOL_F_WISH - some or all changes requested were recorded but the
687 * resulting state of bits masked by .valid is not equal to .requested.
688 * Probably there are other device-specific constraints on some features
689 * in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered
690 * here as though ignored bits were cleared.
691 * %ETHTOOL_F_COMPAT - some or all changes requested were made by calling
692 * compatibility functions. Requested offload state cannot be properly
693 * managed by kernel.
694 *
695 * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of
696 * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands
697 * for ETH_SS_FEATURES string set. First entry in the table corresponds to least
698 * significant bit in features[0] fields. Empty strings mark undefined features.
699 */
700enum ethtool_sfeatures_retval_bits {
701 ETHTOOL_F_UNSUPPORTED__BIT,
702 ETHTOOL_F_WISH__BIT,
703 ETHTOOL_F_COMPAT__BIT,
704};
705
706#define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT)
707#define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT)
708#define ETHTOOL_F_COMPAT (1 << ETHTOOL_F_COMPAT__BIT)
709
439#ifdef __KERNEL__ 710#ifdef __KERNEL__
440 711
441#include <linux/rculist.h> 712#include <linux/rculist.h>
442 713
714/* needed by dev_disable_lro() */
715extern int __ethtool_set_flags(struct net_device *dev, u32 flags);
716
443struct ethtool_rx_ntuple_flow_spec_container { 717struct ethtool_rx_ntuple_flow_spec_container {
444 struct ethtool_rx_ntuple_flow_spec fs; 718 struct ethtool_rx_ntuple_flow_spec fs;
445 struct list_head list; 719 struct list_head list;
@@ -452,11 +726,26 @@ struct ethtool_rx_ntuple_list {
452 unsigned int count; 726 unsigned int count;
453}; 727};
454 728
729/**
730 * enum ethtool_phys_id_state - indicator state for physical identification
731 * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
732 * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
733 * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
734 * is not supported)
735 * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
736 * is not supported)
737 */
738enum ethtool_phys_id_state {
739 ETHTOOL_ID_INACTIVE,
740 ETHTOOL_ID_ACTIVE,
741 ETHTOOL_ID_ON,
742 ETHTOOL_ID_OFF
743};
744
455struct net_device; 745struct net_device;
456 746
457/* Some generic methods drivers may use in their ethtool_ops */ 747/* Some generic methods drivers may use in their ethtool_ops */
458u32 ethtool_op_get_link(struct net_device *dev); 748u32 ethtool_op_get_link(struct net_device *dev);
459u32 ethtool_op_get_rx_csum(struct net_device *dev);
460u32 ethtool_op_get_tx_csum(struct net_device *dev); 749u32 ethtool_op_get_tx_csum(struct net_device *dev);
461int ethtool_op_set_tx_csum(struct net_device *dev, u32 data); 750int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
462int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data); 751int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data);
@@ -470,65 +759,134 @@ int ethtool_op_set_ufo(struct net_device *dev, u32 data);
470u32 ethtool_op_get_flags(struct net_device *dev); 759u32 ethtool_op_get_flags(struct net_device *dev);
471int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported); 760int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported);
472void ethtool_ntuple_flush(struct net_device *dev); 761void ethtool_ntuple_flush(struct net_device *dev);
762bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported);
473 763
474/** 764/**
475 * &ethtool_ops - Alter and report network device settings 765 * struct ethtool_ops - optional netdev operations
476 * get_settings: Get device-specific settings 766 * @get_settings: Get various device settings including Ethernet link
477 * set_settings: Set device-specific settings 767 * settings. The @cmd parameter is expected to have been cleared
478 * get_drvinfo: Report driver information 768 * before get_settings is called. Returns a negative error code or
479 * get_regs: Get device registers 769 * zero.
480 * get_wol: Report whether Wake-on-Lan is enabled 770 * @set_settings: Set various device settings including Ethernet link
481 * set_wol: Turn Wake-on-Lan on or off 771 * settings. Returns a negative error code or zero.
482 * get_msglevel: Report driver message level 772 * @get_drvinfo: Report driver/device information. Should only set the
483 * set_msglevel: Set driver message level 773 * @driver, @version, @fw_version and @bus_info fields. If not
484 * nway_reset: Restart autonegotiation 774 * implemented, the @driver and @bus_info fields will be filled in
485 * get_link: Get link status 775 * according to the netdev's parent device.
486 * get_eeprom: Read data from the device EEPROM 776 * @get_regs_len: Get buffer length required for @get_regs
487 * set_eeprom: Write data to the device EEPROM 777 * @get_regs: Get device registers
488 * get_coalesce: Get interrupt coalescing parameters 778 * @get_wol: Report whether Wake-on-Lan is enabled
489 * set_coalesce: Set interrupt coalescing parameters 779 * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
490 * get_ringparam: Report ring sizes 780 * or zero.
491 * set_ringparam: Set ring sizes 781 * @get_msglevel: Report driver message level. This should be the value
492 * get_pauseparam: Report pause parameters 782 * of the @msg_enable field used by netif logging functions.
493 * set_pauseparam: Set pause parameters 783 * @set_msglevel: Set driver message level
494 * get_rx_csum: Report whether receive checksums are turned on or off 784 * @nway_reset: Restart autonegotiation. Returns a negative error code
495 * set_rx_csum: Turn receive checksum on or off 785 * or zero.
496 * get_tx_csum: Report whether transmit checksums are turned on or off 786 * @get_link: Report whether physical link is up. Will only be called if
497 * set_tx_csum: Turn transmit checksums on or off 787 * the netdev is up. Should usually be set to ethtool_op_get_link(),
498 * get_sg: Report whether scatter-gather is enabled 788 * which uses netif_carrier_ok().
499 * set_sg: Turn scatter-gather on or off 789 * @get_eeprom: Read data from the device EEPROM.
500 * get_tso: Report whether TCP segmentation offload is enabled
501 * set_tso: Turn TCP segmentation offload on or off
502 * get_ufo: Report whether UDP fragmentation offload is enabled
503 * set_ufo: Turn UDP fragmentation offload on or off
504 * self_test: Run specified self-tests
505 * get_strings: Return a set of strings that describe the requested objects
506 * phys_id: Identify the device
507 * get_stats: Return statistics about the device
508 * get_flags: get 32-bit flags bitmap
509 * set_flags: set 32-bit flags bitmap
510 *
511 * Description:
512 *
513 * get_settings:
514 * @get_settings is passed an &ethtool_cmd to fill in. It returns
515 * an negative errno or zero.
516 *
517 * set_settings:
518 * @set_settings is passed an &ethtool_cmd and should attempt to set
519 * all the settings this device supports. It may return an error value
520 * if something goes wrong (otherwise 0).
521 *
522 * get_eeprom:
523 * Should fill in the magic field. Don't need to check len for zero 790 * Should fill in the magic field. Don't need to check len for zero
524 * or wraparound. Fill in the data argument with the eeprom values 791 * or wraparound. Fill in the data argument with the eeprom values
525 * from offset to offset + len. Update len to the amount read. 792 * from offset to offset + len. Update len to the amount read.
526 * Returns an error or zero. 793 * Returns an error or zero.
527 * 794 * @set_eeprom: Write data to the device EEPROM.
528 * set_eeprom:
529 * Should validate the magic field. Don't need to check len for zero 795 * Should validate the magic field. Don't need to check len for zero
530 * or wraparound. Update len to the amount written. Returns an error 796 * or wraparound. Update len to the amount written. Returns an error
531 * or zero. 797 * or zero.
798 * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
799 * error code or zero.
800 * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
801 * error code or zero.
802 * @get_ringparam: Report ring sizes
803 * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
804 * @get_pauseparam: Report pause parameters
805 * @set_pauseparam: Set pause parameters. Returns a negative error code
806 * or zero.
807 * @get_rx_csum: Deprecated in favour of the netdev feature %NETIF_F_RXCSUM.
808 * Report whether receive checksums are turned on or off.
809 * @set_rx_csum: Deprecated in favour of generic netdev features. Turn
810 * receive checksum on or off. Returns a negative error code or zero.
811 * @get_tx_csum: Deprecated as redundant. Report whether transmit checksums
812 * are turned on or off.
813 * @set_tx_csum: Deprecated in favour of generic netdev features. Turn
814 * transmit checksums on or off. Returns a negative error code or zero.
815 * @get_sg: Deprecated as redundant. Report whether scatter-gather is
816 * enabled.
817 * @set_sg: Deprecated in favour of generic netdev features. Turn
818 * scatter-gather on or off. Returns a negative error code or zero.
819 * @get_tso: Deprecated as redundant. Report whether TCP segmentation
820 * offload is enabled.
821 * @set_tso: Deprecated in favour of generic netdev features. Turn TCP
822 * segmentation offload on or off. Returns a negative error code or zero.
823 * @self_test: Run specified self-tests
824 * @get_strings: Return a set of strings that describe the requested objects
825 * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
826 * attached to it. The implementation may update the indicator
827 * asynchronously or synchronously, but in either case it must return
828 * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
829 * and must either activate asynchronous updates and return zero, return
830 * a negative error or return a positive frequency for synchronous
831 * indication (e.g. 1 for one on/off cycle per second). If it returns
832 * a frequency then it will be called again at intervals with the
833 * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
834 * the indicator accordingly. Finally, it is called with the argument
835 * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
836 * negative error code or zero.
837 * @get_ethtool_stats: Return extended statistics about the device.
838 * This is only useful if the device maintains statistics not
839 * included in &struct rtnl_link_stats64.
840 * @begin: Function to be called before any other operation. Returns a
841 * negative error code or zero.
842 * @complete: Function to be called after any other operation except
843 * @begin. Will be called even if the other operation failed.
844 * @get_ufo: Deprecated as redundant. Report whether UDP fragmentation
845 * offload is enabled.
846 * @set_ufo: Deprecated in favour of generic netdev features. Turn UDP
847 * fragmentation offload on or off. Returns a negative error code or zero.
848 * @get_flags: Deprecated as redundant. Report features included in
849 * &enum ethtool_flags that are enabled.
850 * @set_flags: Deprecated in favour of generic netdev features. Turn
851 * features included in &enum ethtool_flags on or off. Returns a
852 * negative error code or zero.
853 * @get_priv_flags: Report driver-specific feature flags.
854 * @set_priv_flags: Set driver-specific feature flags. Returns a negative
855 * error code or zero.
856 * @get_sset_count: Get number of strings that @get_strings will write.
857 * @get_rxnfc: Get RX flow classification rules. Returns a negative
858 * error code or zero.
859 * @set_rxnfc: Set RX flow classification rules. Returns a negative
860 * error code or zero.
861 * @flash_device: Write a firmware image to device's flash memory.
862 * Returns a negative error code or zero.
863 * @reset: Reset (part of) the device, as specified by a bitmask of
864 * flags from &enum ethtool_reset_flags. Returns a negative
865 * error code or zero.
866 * @set_rx_ntuple: Set an RX n-tuple rule. Returns a negative error code
867 * or zero.
868 * @get_rx_ntuple: Deprecated.
869 * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
870 * Returns a negative error code or zero.
871 * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
872 * Returns a negative error code or zero.
873 * @get_channels: Get number of channels.
874 * @set_channels: Set number of channels. Returns a negative error code or
875 * zero.
876 * @get_dump_flag: Get dump flag indicating current dump length, version,
877 * and flag of the device.
878 * @get_dump_data: Get dump data.
879 * @set_dump: Set dump specific flags to the device.
880 *
881 * All operations are optional (i.e. the function pointer may be set
882 * to %NULL) and callers must take this into account. Callers must
883 * hold the RTNL, except that for @get_drvinfo the caller may or may
884 * not hold the RTNL.
885 *
886 * See the structures used by these operations for further documentation.
887 *
888 * See &struct net_device and &struct net_device_ops for documentation
889 * of the generic netdev features interface.
532 */ 890 */
533struct ethtool_ops { 891struct ethtool_ops {
534 int (*get_settings)(struct net_device *, struct ethtool_cmd *); 892 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
@@ -567,7 +925,7 @@ struct ethtool_ops {
567 int (*set_tso)(struct net_device *, u32); 925 int (*set_tso)(struct net_device *, u32);
568 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); 926 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
569 void (*get_strings)(struct net_device *, u32 stringset, u8 *); 927 void (*get_strings)(struct net_device *, u32 stringset, u8 *);
570 int (*phys_id)(struct net_device *, u32); 928 int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
571 void (*get_ethtool_stats)(struct net_device *, 929 void (*get_ethtool_stats)(struct net_device *,
572 struct ethtool_stats *, u64 *); 930 struct ethtool_stats *, u64 *);
573 int (*begin)(struct net_device *); 931 int (*begin)(struct net_device *);
@@ -591,6 +949,13 @@ struct ethtool_ops {
591 struct ethtool_rxfh_indir *); 949 struct ethtool_rxfh_indir *);
592 int (*set_rxfh_indir)(struct net_device *, 950 int (*set_rxfh_indir)(struct net_device *,
593 const struct ethtool_rxfh_indir *); 951 const struct ethtool_rxfh_indir *);
952 void (*get_channels)(struct net_device *, struct ethtool_channels *);
953 int (*set_channels)(struct net_device *, struct ethtool_channels *);
954 int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
955 int (*get_dump_data)(struct net_device *,
956 struct ethtool_dump *, void *);
957 int (*set_dump)(struct net_device *, struct ethtool_dump *);
958
594}; 959};
595#endif /* __KERNEL__ */ 960#endif /* __KERNEL__ */
596 961
@@ -604,7 +969,9 @@ struct ethtool_ops {
604#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */ 969#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
605#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */ 970#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
606#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */ 971#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */
607#define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */ 972/* Get link status for host, i.e. whether the interface *and* the
973 * physical port (if there is one) are up (ethtool_value). */
974#define ETHTOOL_GLINK 0x0000000a
608#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */ 975#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
609#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */ 976#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */
610#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */ 977#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
@@ -655,6 +1022,14 @@ struct ethtool_ops {
655#define ETHTOOL_GRXFHINDIR 0x00000038 /* Get RX flow hash indir'n table */ 1022#define ETHTOOL_GRXFHINDIR 0x00000038 /* Get RX flow hash indir'n table */
656#define ETHTOOL_SRXFHINDIR 0x00000039 /* Set RX flow hash indir'n table */ 1023#define ETHTOOL_SRXFHINDIR 0x00000039 /* Set RX flow hash indir'n table */
657 1024
1025#define ETHTOOL_GFEATURES 0x0000003a /* Get device offload settings */
1026#define ETHTOOL_SFEATURES 0x0000003b /* Change device offload settings */
1027#define ETHTOOL_GCHANNELS 0x0000003c /* Get no of channels */
1028#define ETHTOOL_SCHANNELS 0x0000003d /* Set no of channels */
1029#define ETHTOOL_SET_DUMP 0x0000003e /* Set dump settings */
1030#define ETHTOOL_GET_DUMP_FLAG 0x0000003f /* Get dump settings */
1031#define ETHTOOL_GET_DUMP_DATA 0x00000040 /* Get dump data */
1032
658/* compatibility with older code */ 1033/* compatibility with older code */
659#define SPARC_ETH_GSET ETHTOOL_GSET 1034#define SPARC_ETH_GSET ETHTOOL_GSET
660#define SPARC_ETH_SSET ETHTOOL_SSET 1035#define SPARC_ETH_SSET ETHTOOL_SSET
@@ -681,6 +1056,8 @@ struct ethtool_ops {
681#define SUPPORTED_10000baseKX4_Full (1 << 18) 1056#define SUPPORTED_10000baseKX4_Full (1 << 18)
682#define SUPPORTED_10000baseKR_Full (1 << 19) 1057#define SUPPORTED_10000baseKR_Full (1 << 19)
683#define SUPPORTED_10000baseR_FEC (1 << 20) 1058#define SUPPORTED_10000baseR_FEC (1 << 20)
1059#define SUPPORTED_20000baseMLD2_Full (1 << 21)
1060#define SUPPORTED_20000baseKR2_Full (1 << 22)
684 1061
685/* Indicates what features are advertised by the interface. */ 1062/* Indicates what features are advertised by the interface. */
686#define ADVERTISED_10baseT_Half (1 << 0) 1063#define ADVERTISED_10baseT_Half (1 << 0)
@@ -704,11 +1081,13 @@ struct ethtool_ops {
704#define ADVERTISED_10000baseKX4_Full (1 << 18) 1081#define ADVERTISED_10000baseKX4_Full (1 << 18)
705#define ADVERTISED_10000baseKR_Full (1 << 19) 1082#define ADVERTISED_10000baseKR_Full (1 << 19)
706#define ADVERTISED_10000baseR_FEC (1 << 20) 1083#define ADVERTISED_10000baseR_FEC (1 << 20)
1084#define ADVERTISED_20000baseMLD2_Full (1 << 21)
1085#define ADVERTISED_20000baseKR2_Full (1 << 22)
707 1086
708/* The following are all involved in forcing a particular link 1087/* The following are all involved in forcing a particular link
709 * mode for the device for setting things. When getting the 1088 * mode for the device for setting things. When getting the
710 * devices settings, these indicate the current mode and whether 1089 * devices settings, these indicate the current mode and whether
711 * it was foced up into this mode or autonegotiated. 1090 * it was forced up into this mode or autonegotiated.
712 */ 1091 */
713 1092
714/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */ 1093/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */
@@ -759,22 +1138,25 @@ struct ethtool_ops {
759#define WAKE_MAGIC (1 << 5) 1138#define WAKE_MAGIC (1 << 5)
760#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */ 1139#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
761 1140
762/* L3-L4 network traffic flow types */ 1141/* L2-L4 network traffic flow types */
763#define TCP_V4_FLOW 0x01 1142#define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */
764#define UDP_V4_FLOW 0x02 1143#define UDP_V4_FLOW 0x02 /* hash or spec (udp_ip4_spec) */
765#define SCTP_V4_FLOW 0x03 1144#define SCTP_V4_FLOW 0x03 /* hash or spec (sctp_ip4_spec) */
766#define AH_ESP_V4_FLOW 0x04 1145#define AH_ESP_V4_FLOW 0x04 /* hash only */
767#define TCP_V6_FLOW 0x05 1146#define TCP_V6_FLOW 0x05 /* hash only */
768#define UDP_V6_FLOW 0x06 1147#define UDP_V6_FLOW 0x06 /* hash only */
769#define SCTP_V6_FLOW 0x07 1148#define SCTP_V6_FLOW 0x07 /* hash only */
770#define AH_ESP_V6_FLOW 0x08 1149#define AH_ESP_V6_FLOW 0x08 /* hash only */
771#define AH_V4_FLOW 0x09 1150#define AH_V4_FLOW 0x09 /* hash or spec (ah_ip4_spec) */
772#define ESP_V4_FLOW 0x0a 1151#define ESP_V4_FLOW 0x0a /* hash or spec (esp_ip4_spec) */
773#define AH_V6_FLOW 0x0b 1152#define AH_V6_FLOW 0x0b /* hash only */
774#define ESP_V6_FLOW 0x0c 1153#define ESP_V6_FLOW 0x0c /* hash only */
775#define IP_USER_FLOW 0x0d 1154#define IP_USER_FLOW 0x0d /* spec only (usr_ip4_spec) */
776#define IPV4_FLOW 0x10 1155#define IPV4_FLOW 0x10 /* hash only */
777#define IPV6_FLOW 0x11 1156#define IPV6_FLOW 0x11 /* hash only */
1157#define ETHER_FLOW 0x12 /* spec only (ether_spec) */
1158/* Flag to enable additional fields in struct ethtool_rx_flow_spec */
1159#define FLOW_EXT 0x80000000
778 1160
779/* L3-L4 network traffic flow hash options */ 1161/* L3-L4 network traffic flow hash options */
780#define RXH_L2DA (1 << 1) 1162#define RXH_L2DA (1 << 1)
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index f6856a5a1d4b..f362733186a5 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/linux/eventpoll.h ( Efficent event polling implementation ) 2 * include/linux/eventpoll.h ( Efficient event polling implementation )
3 * Copyright (C) 2001,...,2006 Davide Libenzi 3 * Copyright (C) 2001,...,2006 Davide Libenzi
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index a9cd507f8cd2..3a4cef5322dc 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -8,6 +8,9 @@ struct inode;
8struct super_block; 8struct super_block;
9struct vfsmount; 9struct vfsmount;
10 10
11/* limit the handle size to NFSv4 handle size now */
12#define MAX_HANDLE_SZ 128
13
11/* 14/*
12 * The fileid_type identifies how the file within the filesystem is encoded. 15 * The fileid_type identifies how the file within the filesystem is encoded.
13 * In theory this is freely set and parsed by the filesystem, but we try to 16 * In theory this is freely set and parsed by the filesystem, but we try to
@@ -67,6 +70,19 @@ enum fid_type {
67 * 32 bit parent block number, 32 bit parent generation number 70 * 32 bit parent block number, 32 bit parent generation number
68 */ 71 */
69 FILEID_UDF_WITH_PARENT = 0x52, 72 FILEID_UDF_WITH_PARENT = 0x52,
73
74 /*
75 * 64 bit checkpoint number, 64 bit inode number,
76 * 32 bit generation number.
77 */
78 FILEID_NILFS_WITHOUT_PARENT = 0x61,
79
80 /*
81 * 64 bit checkpoint number, 64 bit inode number,
82 * 32 bit generation number, 32 bit parent generation.
83 * 64 bit parent inode number.
84 */
85 FILEID_NILFS_WITH_PARENT = 0x62,
70}; 86};
71 87
72struct fid { 88struct fid {
@@ -104,12 +120,14 @@ struct fid {
104 * encode_fh: 120 * encode_fh:
105 * @encode_fh should store in the file handle fragment @fh (using at most 121 * @encode_fh should store in the file handle fragment @fh (using at most
106 * @max_len bytes) information that can be used by @decode_fh to recover the 122 * @max_len bytes) information that can be used by @decode_fh to recover the
107 * file refered to by the &struct dentry @de. If the @connectable flag is 123 * file referred to by the &struct dentry @de. If the @connectable flag is
108 * set, the encode_fh() should store sufficient information so that a good 124 * set, the encode_fh() should store sufficient information so that a good
109 * attempt can be made to find not only the file but also it's place in the 125 * attempt can be made to find not only the file but also it's place in the
110 * filesystem. This typically means storing a reference to de->d_parent in 126 * filesystem. This typically means storing a reference to de->d_parent in
111 * the filehandle fragment. encode_fh() should return the number of bytes 127 * the filehandle fragment. encode_fh() should return the fileid_type on
112 * stored or a negative error code such as %-ENOSPC 128 * success and on error returns 255 (if the space needed to encode fh is
129 * greater than @max_len*4 bytes). On error @max_len contains the minimum
130 * size(in 4 byte unit) needed to encode the file handle.
113 * 131 *
114 * fh_to_dentry: 132 * fh_to_dentry:
115 * @fh_to_dentry is given a &struct super_block (@sb) and a file handle 133 * @fh_to_dentry is given a &struct super_block (@sb) and a file handle
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 6ce1bca01724..5e06acf95d0f 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -418,13 +418,13 @@ struct ext3_inode {
418#define EXT2_MOUNT_DATA_FLAGS EXT3_MOUNT_DATA_FLAGS 418#define EXT2_MOUNT_DATA_FLAGS EXT3_MOUNT_DATA_FLAGS
419#endif 419#endif
420 420
421#define ext3_set_bit ext2_set_bit 421#define ext3_set_bit __test_and_set_bit_le
422#define ext3_set_bit_atomic ext2_set_bit_atomic 422#define ext3_set_bit_atomic ext2_set_bit_atomic
423#define ext3_clear_bit ext2_clear_bit 423#define ext3_clear_bit __test_and_clear_bit_le
424#define ext3_clear_bit_atomic ext2_clear_bit_atomic 424#define ext3_clear_bit_atomic ext2_clear_bit_atomic
425#define ext3_test_bit ext2_test_bit 425#define ext3_test_bit test_bit_le
426#define ext3_find_first_zero_bit ext2_find_first_zero_bit 426#define ext3_find_first_zero_bit find_first_zero_bit_le
427#define ext3_find_next_zero_bit ext2_find_next_zero_bit 427#define ext3_find_next_zero_bit find_next_zero_bit_le
428 428
429/* 429/*
430 * Maximal mount counts between two filesystem checks 430 * Maximal mount counts between two filesystem checks
@@ -724,21 +724,30 @@ struct ext3_dir_entry_2 {
724 ~EXT3_DIR_ROUND) 724 ~EXT3_DIR_ROUND)
725#define EXT3_MAX_REC_LEN ((1<<16)-1) 725#define EXT3_MAX_REC_LEN ((1<<16)-1)
726 726
727/*
728 * Tests against MAX_REC_LEN etc were put in place for 64k block
729 * sizes; if that is not possible on this arch, we can skip
730 * those tests and speed things up.
731 */
727static inline unsigned ext3_rec_len_from_disk(__le16 dlen) 732static inline unsigned ext3_rec_len_from_disk(__le16 dlen)
728{ 733{
729 unsigned len = le16_to_cpu(dlen); 734 unsigned len = le16_to_cpu(dlen);
730 735
736#if (PAGE_CACHE_SIZE >= 65536)
731 if (len == EXT3_MAX_REC_LEN) 737 if (len == EXT3_MAX_REC_LEN)
732 return 1 << 16; 738 return 1 << 16;
739#endif
733 return len; 740 return len;
734} 741}
735 742
736static inline __le16 ext3_rec_len_to_disk(unsigned len) 743static inline __le16 ext3_rec_len_to_disk(unsigned len)
737{ 744{
745#if (PAGE_CACHE_SIZE >= 65536)
738 if (len == (1 << 16)) 746 if (len == (1 << 16))
739 return cpu_to_le16(EXT3_MAX_REC_LEN); 747 return cpu_to_le16(EXT3_MAX_REC_LEN);
740 else if (len > (1 << 16)) 748 else if (len > (1 << 16))
741 BUG(); 749 BUG();
750#endif
742 return cpu_to_le16(len); 751 return cpu_to_le16(len);
743} 752}
744 753
@@ -856,6 +865,7 @@ extern struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
856extern int ext3_should_retry_alloc(struct super_block *sb, int *retries); 865extern int ext3_should_retry_alloc(struct super_block *sb, int *retries);
857extern void ext3_init_block_alloc_info(struct inode *); 866extern void ext3_init_block_alloc_info(struct inode *);
858extern void ext3_rsv_window_add(struct super_block *sb, struct ext3_reserve_window_node *rsv); 867extern void ext3_rsv_window_add(struct super_block *sb, struct ext3_reserve_window_node *rsv);
868extern int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range);
859 869
860/* dir.c */ 870/* dir.c */
861extern int ext3_check_dir_entry(const char *, struct inode *, 871extern int ext3_check_dir_entry(const char *, struct inode *,
@@ -874,7 +884,8 @@ extern int ext3fs_dirhash(const char *name, int len, struct
874 dx_hash_info *hinfo); 884 dx_hash_info *hinfo);
875 885
876/* ialloc.c */ 886/* ialloc.c */
877extern struct inode * ext3_new_inode (handle_t *, struct inode *, int); 887extern struct inode * ext3_new_inode (handle_t *, struct inode *,
888 const struct qstr *, int);
878extern void ext3_free_inode (handle_t *, struct inode *); 889extern void ext3_free_inode (handle_t *, struct inode *);
879extern struct inode * ext3_orphan_get (struct super_block *, unsigned long); 890extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
880extern unsigned long ext3_count_free_inodes (struct super_block *); 891extern unsigned long ext3_count_free_inodes (struct super_block *);
@@ -898,7 +909,7 @@ extern int ext3_setattr (struct dentry *, struct iattr *);
898extern void ext3_evict_inode (struct inode *); 909extern void ext3_evict_inode (struct inode *);
899extern int ext3_sync_inode (handle_t *, struct inode *); 910extern int ext3_sync_inode (handle_t *, struct inode *);
900extern void ext3_discard_reservation (struct inode *); 911extern void ext3_discard_reservation (struct inode *);
901extern void ext3_dirty_inode(struct inode *); 912extern void ext3_dirty_inode(struct inode *, int);
902extern int ext3_change_inode_journal_flag(struct inode *, int); 913extern int ext3_change_inode_journal_flag(struct inode *, int);
903extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *); 914extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *);
904extern int ext3_can_truncate(struct inode *inode); 915extern int ext3_can_truncate(struct inode *inode);
diff --git a/include/linux/falloc.h b/include/linux/falloc.h
index 3c155107d61f..73e0b628e058 100644
--- a/include/linux/falloc.h
+++ b/include/linux/falloc.h
@@ -2,6 +2,7 @@
2#define _FALLOC_H_ 2#define _FALLOC_H_
3 3
4#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ 4#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
5#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
5 6
6#ifdef __KERNEL__ 7#ifdef __KERNEL__
7 8
diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h
index 63531a6b4d2a..6c6133f76e16 100644
--- a/include/linux/fanotify.h
+++ b/include/linux/fanotify.h
@@ -6,18 +6,19 @@
6/* the following events that user-space can register for */ 6/* the following events that user-space can register for */
7#define FAN_ACCESS 0x00000001 /* File was accessed */ 7#define FAN_ACCESS 0x00000001 /* File was accessed */
8#define FAN_MODIFY 0x00000002 /* File was modified */ 8#define FAN_MODIFY 0x00000002 /* File was modified */
9#define FAN_CLOSE_WRITE 0x00000008 /* Unwrittable file closed */ 9#define FAN_CLOSE_WRITE 0x00000008 /* Writtable file closed */
10#define FAN_CLOSE_NOWRITE 0x00000010 /* Writtable file closed */ 10#define FAN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
11#define FAN_OPEN 0x00000020 /* File was opened */ 11#define FAN_OPEN 0x00000020 /* File was opened */
12 12
13#define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */
14
15/* FIXME currently Q's have no limit.... */
16#define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ 13#define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
17 14
18#define FAN_OPEN_PERM 0x00010000 /* File open in perm check */ 15#define FAN_OPEN_PERM 0x00010000 /* File open in perm check */
19#define FAN_ACCESS_PERM 0x00020000 /* File accessed in perm check */ 16#define FAN_ACCESS_PERM 0x00020000 /* File accessed in perm check */
20 17
18#define FAN_ONDIR 0x40000000 /* event occurred against dir */
19
20#define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */
21
21/* helper events */ 22/* helper events */
22#define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */ 23#define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */
23 24
@@ -25,7 +26,19 @@
25#define FAN_CLOEXEC 0x00000001 26#define FAN_CLOEXEC 0x00000001
26#define FAN_NONBLOCK 0x00000002 27#define FAN_NONBLOCK 0x00000002
27 28
28#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK) 29/* These are NOT bitwise flags. Both bits are used togther. */
30#define FAN_CLASS_NOTIF 0x00000000
31#define FAN_CLASS_CONTENT 0x00000004
32#define FAN_CLASS_PRE_CONTENT 0x00000008
33#define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
34 FAN_CLASS_PRE_CONTENT)
35
36#define FAN_UNLIMITED_QUEUE 0x00000010
37#define FAN_UNLIMITED_MARKS 0x00000020
38
39#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \
40 FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\
41 FAN_UNLIMITED_MARKS)
29 42
30/* flags used for fanotify_modify_mark() */ 43/* flags used for fanotify_modify_mark() */
31#define FAN_MARK_ADD 0x00000001 44#define FAN_MARK_ADD 0x00000001
@@ -36,6 +49,10 @@
36#define FAN_MARK_IGNORED_MASK 0x00000020 49#define FAN_MARK_IGNORED_MASK 0x00000020
37#define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040 50#define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040
38#define FAN_MARK_FLUSH 0x00000080 51#define FAN_MARK_FLUSH 0x00000080
52#ifdef __KERNEL__
53/* not valid from userspace, only kernel internal */
54#define FAN_MARK_ONDIR 0x00000100
55#endif
39 56
40#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\ 57#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\
41 FAN_MARK_REMOVE |\ 58 FAN_MARK_REMOVE |\
@@ -43,7 +60,8 @@
43 FAN_MARK_ONLYDIR |\ 60 FAN_MARK_ONLYDIR |\
44 FAN_MARK_MOUNT |\ 61 FAN_MARK_MOUNT |\
45 FAN_MARK_IGNORED_MASK |\ 62 FAN_MARK_IGNORED_MASK |\
46 FAN_MARK_IGNORED_SURV_MODIFY) 63 FAN_MARK_IGNORED_SURV_MODIFY |\
64 FAN_MARK_FLUSH)
47 65
48/* 66/*
49 * All of the events - we build the list by hand so that we can add flags in 67 * All of the events - we build the list by hand so that we can add flags in
@@ -65,24 +83,28 @@
65 FAN_ALL_PERM_EVENTS |\ 83 FAN_ALL_PERM_EVENTS |\
66 FAN_Q_OVERFLOW) 84 FAN_Q_OVERFLOW)
67 85
68#define FANOTIFY_METADATA_VERSION 2 86#define FANOTIFY_METADATA_VERSION 3
69 87
70struct fanotify_event_metadata { 88struct fanotify_event_metadata {
71 __u32 event_len; 89 __u32 event_len;
72 __u32 vers; 90 __u8 vers;
73 __u64 mask; 91 __u8 reserved;
92 __u16 metadata_len;
93 __aligned_u64 mask;
74 __s32 fd; 94 __s32 fd;
75 __s32 pid; 95 __s32 pid;
76} __attribute__ ((packed)); 96};
77 97
78struct fanotify_response { 98struct fanotify_response {
79 __s32 fd; 99 __s32 fd;
80 __u32 response; 100 __u32 response;
81} __attribute__ ((packed)); 101};
82 102
83/* Legit userspace responses to a _PERM event */ 103/* Legit userspace responses to a _PERM event */
84#define FAN_ALLOW 0x01 104#define FAN_ALLOW 0x01
85#define FAN_DENY 0x02 105#define FAN_DENY 0x02
106/* No fd set in event */
107#define FAN_NOFD -1
86 108
87/* Helper functions to deal with fanotify_event_metadata buffers */ 109/* Helper functions to deal with fanotify_event_metadata buffers */
88#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) 110#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
diff --git a/include/linux/fb.h b/include/linux/fb.h
index f0268deca658..6a8274877171 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -152,6 +152,8 @@
152#define FB_ACCEL_PROSAVAGE_DDR 0x8d /* S3 ProSavage DDR */ 152#define FB_ACCEL_PROSAVAGE_DDR 0x8d /* S3 ProSavage DDR */
153#define FB_ACCEL_PROSAVAGE_DDRK 0x8e /* S3 ProSavage DDR-K */ 153#define FB_ACCEL_PROSAVAGE_DDRK 0x8e /* S3 ProSavage DDR-K */
154 154
155#define FB_ACCEL_PUV3_UNIGFX 0xa0 /* PKUnity-v3 Unigfx */
156
155struct fb_fix_screeninfo { 157struct fb_fix_screeninfo {
156 char id[16]; /* identification string eg "TT Builtin" */ 158 char id[16]; /* identification string eg "TT Builtin" */
157 unsigned long smem_start; /* Start of frame buffer mem */ 159 unsigned long smem_start; /* Start of frame buffer mem */
@@ -532,14 +534,14 @@ struct fb_cursor_user {
532#define FB_EVENT_GET_CONSOLE_MAP 0x07 534#define FB_EVENT_GET_CONSOLE_MAP 0x07
533/* CONSOLE-SPECIFIC: set console to framebuffer mapping */ 535/* CONSOLE-SPECIFIC: set console to framebuffer mapping */
534#define FB_EVENT_SET_CONSOLE_MAP 0x08 536#define FB_EVENT_SET_CONSOLE_MAP 0x08
535/* A hardware display blank change occured */ 537/* A hardware display blank change occurred */
536#define FB_EVENT_BLANK 0x09 538#define FB_EVENT_BLANK 0x09
537/* Private modelist is to be replaced */ 539/* Private modelist is to be replaced */
538#define FB_EVENT_NEW_MODELIST 0x0A 540#define FB_EVENT_NEW_MODELIST 0x0A
539/* The resolution of the passed in fb_info about to change and 541/* The resolution of the passed in fb_info about to change and
540 all vc's should be changed */ 542 all vc's should be changed */
541#define FB_EVENT_MODE_CHANGE_ALL 0x0B 543#define FB_EVENT_MODE_CHANGE_ALL 0x0B
542/* A software display blank change occured */ 544/* A software display blank change occurred */
543#define FB_EVENT_CONBLANK 0x0C 545#define FB_EVENT_CONBLANK 0x0C
544/* Get drawing requirements */ 546/* Get drawing requirements */
545#define FB_EVENT_GET_REQ 0x0D 547#define FB_EVENT_GET_REQ 0x0D
@@ -803,7 +805,7 @@ struct fb_tile_ops {
803/* A driver may set this flag to indicate that it does want a set_par to be 805/* A driver may set this flag to indicate that it does want a set_par to be
804 * called every time when fbcon_switch is executed. The advantage is that with 806 * called every time when fbcon_switch is executed. The advantage is that with
805 * this flag set you can really be sure that set_par is always called before 807 * this flag set you can really be sure that set_par is always called before
806 * any of the functions dependant on the correct hardware state or altering 808 * any of the functions dependent on the correct hardware state or altering
807 * that state, even if you are using some broken X releases. The disadvantage 809 * that state, even if you are using some broken X releases. The disadvantage
808 * is that it introduces unwanted delays to every console switch if set_par 810 * is that it introduces unwanted delays to every console switch if set_par
809 * is slow. It is a good idea to try this flag in the drivers initialization 811 * is slow. It is a good idea to try this flag in the drivers initialization
@@ -830,6 +832,7 @@ struct fb_tile_ops {
830#define FBINFO_CAN_FORCE_OUTPUT 0x200000 832#define FBINFO_CAN_FORCE_OUTPUT 0x200000
831 833
832struct fb_info { 834struct fb_info {
835 atomic_t count;
833 int node; 836 int node;
834 int flags; 837 int flags;
835 struct mutex lock; /* Lock for open/release/ioctl funcs */ 838 struct mutex lock; /* Lock for open/release/ioctl funcs */
@@ -875,7 +878,7 @@ struct fb_info {
875 void *fbcon_par; /* fbcon use-only private area */ 878 void *fbcon_par; /* fbcon use-only private area */
876 /* From here on everything is device dependent */ 879 /* From here on everything is device dependent */
877 void *par; 880 void *par;
878 /* we need the PCI or similiar aperture base/size not 881 /* we need the PCI or similar aperture base/size not
879 smem_start/size as smem_start may just be an object 882 smem_start/size as smem_start may just be an object
880 allocated inside the aperture so may not actually overlap */ 883 allocated inside the aperture so may not actually overlap */
881 struct apertures_struct { 884 struct apertures_struct {
@@ -931,6 +934,8 @@ static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
931#define fb_writel sbus_writel 934#define fb_writel sbus_writel
932#define fb_writeq sbus_writeq 935#define fb_writeq sbus_writeq
933#define fb_memset sbus_memset_io 936#define fb_memset sbus_memset_io
937#define fb_memcpy_fromfb sbus_memcpy_fromio
938#define fb_memcpy_tofb sbus_memcpy_toio
934 939
935#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || defined(__avr32__) || defined(__bfin__) 940#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || defined(__avr32__) || defined(__bfin__)
936 941
@@ -943,6 +948,8 @@ static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
943#define fb_writel __raw_writel 948#define fb_writel __raw_writel
944#define fb_writeq __raw_writeq 949#define fb_writeq __raw_writeq
945#define fb_memset memset_io 950#define fb_memset memset_io
951#define fb_memcpy_fromfb memcpy_fromio
952#define fb_memcpy_tofb memcpy_toio
946 953
947#else 954#else
948 955
@@ -955,6 +962,8 @@ static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
955#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b)) 962#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
956#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b)) 963#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
957#define fb_memset memset 964#define fb_memset memset
965#define fb_memcpy_fromfb memcpy
966#define fb_memcpy_tofb memcpy
958 967
959#endif 968#endif
960 969
@@ -1086,6 +1095,8 @@ extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var);
1086extern const unsigned char *fb_firmware_edid(struct device *device); 1095extern const unsigned char *fb_firmware_edid(struct device *device);
1087extern void fb_edid_to_monspecs(unsigned char *edid, 1096extern void fb_edid_to_monspecs(unsigned char *edid,
1088 struct fb_monspecs *specs); 1097 struct fb_monspecs *specs);
1098extern void fb_edid_add_monspecs(unsigned char *edid,
1099 struct fb_monspecs *specs);
1089extern void fb_destroy_modedb(struct fb_videomode *modedb); 1100extern void fb_destroy_modedb(struct fb_videomode *modedb);
1090extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb); 1101extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb);
1091extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter); 1102extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter);
@@ -1116,6 +1127,7 @@ extern const struct fb_videomode *fb_find_best_display(const struct fb_monspecs
1116 1127
1117/* drivers/video/fbcmap.c */ 1128/* drivers/video/fbcmap.c */
1118extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp); 1129extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
1130extern int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags);
1119extern void fb_dealloc_cmap(struct fb_cmap *cmap); 1131extern void fb_dealloc_cmap(struct fb_cmap *cmap);
1120extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to); 1132extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
1121extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to); 1133extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
@@ -1143,6 +1155,7 @@ struct fb_videomode {
1143 1155
1144extern const char *fb_mode_option; 1156extern const char *fb_mode_option;
1145extern const struct fb_videomode vesa_modes[]; 1157extern const struct fb_videomode vesa_modes[];
1158extern const struct fb_videomode cea_modes[64];
1146 1159
1147struct fb_modelist { 1160struct fb_modelist {
1148 struct list_head list; 1161 struct list_head list;
diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h
index afc00af3229b..f550f894ba15 100644
--- a/include/linux/fcntl.h
+++ b/include/linux/fcntl.h
@@ -45,6 +45,8 @@
45#define AT_REMOVEDIR 0x200 /* Remove directory instead of 45#define AT_REMOVEDIR 0x200 /* Remove directory instead of
46 unlinking file. */ 46 unlinking file. */
47#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ 47#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
48#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */
49#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
48 50
49#ifdef __KERNEL__ 51#ifdef __KERNEL__
50 52
diff --git a/include/linux/fdreg.h b/include/linux/fdreg.h
index c2eeb63b72db..61ce64169004 100644
--- a/include/linux/fdreg.h
+++ b/include/linux/fdreg.h
@@ -89,7 +89,7 @@
89/* the following commands are new in the 82078. They are not used in the 89/* the following commands are new in the 82078. They are not used in the
90 * floppy driver, except the first three. These commands may be useful for apps 90 * floppy driver, except the first three. These commands may be useful for apps
91 * which use the FDRAWCMD interface. For doc, get the 82078 spec sheets at 91 * which use the FDRAWCMD interface. For doc, get the 82078 spec sheets at
92 * http://www-techdoc.intel.com/docs/periph/fd_contr/datasheets/ */ 92 * http://www.intel.com/design/archives/periphrl/docs/29046803.htm */
93 93
94#define FD_PARTID 0x18 /* part id ("extended" version cmd) */ 94#define FD_PARTID 0x18 /* part id ("extended" version cmd) */
95#define FD_SAVE 0x2e /* save fdc regs for later restore */ 95#define FD_SAVE 0x2e /* save fdc regs for later restore */
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index f59ed297b661..133c0ba25e30 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -31,7 +31,7 @@ struct embedded_fd_set {
31 31
32struct fdtable { 32struct fdtable {
33 unsigned int max_fds; 33 unsigned int max_fds;
34 struct file ** fd; /* current fd array */ 34 struct file __rcu **fd; /* current fd array */
35 fd_set *close_on_exec; 35 fd_set *close_on_exec;
36 fd_set *open_fds; 36 fd_set *open_fds;
37 struct rcu_head rcu; 37 struct rcu_head rcu;
@@ -46,7 +46,7 @@ struct files_struct {
46 * read mostly part 46 * read mostly part
47 */ 47 */
48 atomic_t count; 48 atomic_t count;
49 struct fdtable *fdt; 49 struct fdtable __rcu *fdt;
50 struct fdtable fdtab; 50 struct fdtable fdtab;
51 /* 51 /*
52 * written part on a separate cache line in SMP 52 * written part on a separate cache line in SMP
@@ -55,7 +55,7 @@ struct files_struct {
55 int next_fd; 55 int next_fd;
56 struct embedded_fd_set close_on_exec_init; 56 struct embedded_fd_set close_on_exec_init;
57 struct embedded_fd_set open_fds_init; 57 struct embedded_fd_set open_fds_init;
58 struct file * fd_array[NR_OPEN_DEFAULT]; 58 struct file __rcu * fd_array[NR_OPEN_DEFAULT];
59}; 59};
60 60
61#define rcu_dereference_check_fdtable(files, fdtfd) \ 61#define rcu_dereference_check_fdtable(files, fdtfd) \
diff --git a/include/linux/fec.h b/include/linux/fec.h
index 5d3523d8dd0c..bcff455d1d53 100644
--- a/include/linux/fec.h
+++ b/include/linux/fec.h
@@ -3,6 +3,8 @@
3 * Copyright (c) 2009 Orex Computed Radiography 3 * Copyright (c) 2009 Orex Computed Radiography
4 * Baruch Siach <baruch@tkos.co.il> 4 * Baruch Siach <baruch@tkos.co.il>
5 * 5 *
6 * Copyright (C) 2010 Freescale Semiconductor, Inc.
7 *
6 * Header file for the FEC platform data 8 * Header file for the FEC platform data
7 * 9 *
8 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
@@ -16,6 +18,7 @@
16 18
17struct fec_platform_data { 19struct fec_platform_data {
18 phy_interface_t phy; 20 phy_interface_t phy;
21 unsigned char mac[ETH_ALEN];
19}; 22};
20 23
21#endif 24#endif
diff --git a/include/linux/file.h b/include/linux/file.h
index b1e12970f617..21a79958541c 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -23,12 +23,14 @@ extern struct file *alloc_file(struct path *, fmode_t mode,
23 23
24static inline void fput_light(struct file *file, int fput_needed) 24static inline void fput_light(struct file *file, int fput_needed)
25{ 25{
26 if (unlikely(fput_needed)) 26 if (fput_needed)
27 fput(file); 27 fput(file);
28} 28}
29 29
30extern struct file *fget(unsigned int fd); 30extern struct file *fget(unsigned int fd);
31extern struct file *fget_light(unsigned int fd, int *fput_needed); 31extern struct file *fget_light(unsigned int fd, int *fput_needed);
32extern struct file *fget_raw(unsigned int fd);
33extern struct file *fget_raw_light(unsigned int fd, int *fput_needed);
32extern void set_close_on_exec(unsigned int fd, int flag); 34extern void set_close_on_exec(unsigned int fd, int flag);
33extern void put_filp(struct file *); 35extern void put_filp(struct file *);
34extern int alloc_fd(unsigned start, unsigned flags); 36extern int alloc_fd(unsigned start, unsigned flags);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 69b43dbea6c6..9ee3f9fb0b4a 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -91,54 +91,6 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
91#define BPF_TAX 0x00 91#define BPF_TAX 0x00
92#define BPF_TXA 0x80 92#define BPF_TXA 0x80
93 93
94enum {
95 BPF_S_RET_K = 0,
96 BPF_S_RET_A,
97 BPF_S_ALU_ADD_K,
98 BPF_S_ALU_ADD_X,
99 BPF_S_ALU_SUB_K,
100 BPF_S_ALU_SUB_X,
101 BPF_S_ALU_MUL_K,
102 BPF_S_ALU_MUL_X,
103 BPF_S_ALU_DIV_X,
104 BPF_S_ALU_AND_K,
105 BPF_S_ALU_AND_X,
106 BPF_S_ALU_OR_K,
107 BPF_S_ALU_OR_X,
108 BPF_S_ALU_LSH_K,
109 BPF_S_ALU_LSH_X,
110 BPF_S_ALU_RSH_K,
111 BPF_S_ALU_RSH_X,
112 BPF_S_ALU_NEG,
113 BPF_S_LD_W_ABS,
114 BPF_S_LD_H_ABS,
115 BPF_S_LD_B_ABS,
116 BPF_S_LD_W_LEN,
117 BPF_S_LD_W_IND,
118 BPF_S_LD_H_IND,
119 BPF_S_LD_B_IND,
120 BPF_S_LD_IMM,
121 BPF_S_LDX_W_LEN,
122 BPF_S_LDX_B_MSH,
123 BPF_S_LDX_IMM,
124 BPF_S_MISC_TAX,
125 BPF_S_MISC_TXA,
126 BPF_S_ALU_DIV_K,
127 BPF_S_LD_MEM,
128 BPF_S_LDX_MEM,
129 BPF_S_ST,
130 BPF_S_STX,
131 BPF_S_JMP_JA,
132 BPF_S_JMP_JEQ_K,
133 BPF_S_JMP_JEQ_X,
134 BPF_S_JMP_JGE_K,
135 BPF_S_JMP_JGE_X,
136 BPF_S_JMP_JGT_K,
137 BPF_S_JMP_JGT_X,
138 BPF_S_JMP_JSET_K,
139 BPF_S_JMP_JSET_X,
140};
141
142#ifndef BPF_MAXINSNS 94#ifndef BPF_MAXINSNS
143#define BPF_MAXINSNS 4096 95#define BPF_MAXINSNS 4096
144#endif 96#endif
@@ -172,15 +124,23 @@ enum {
172#define SKF_AD_MARK 20 124#define SKF_AD_MARK 20
173#define SKF_AD_QUEUE 24 125#define SKF_AD_QUEUE 24
174#define SKF_AD_HATYPE 28 126#define SKF_AD_HATYPE 28
175#define SKF_AD_MAX 32 127#define SKF_AD_RXHASH 32
128#define SKF_AD_CPU 36
129#define SKF_AD_MAX 40
176#define SKF_NET_OFF (-0x100000) 130#define SKF_NET_OFF (-0x100000)
177#define SKF_LL_OFF (-0x200000) 131#define SKF_LL_OFF (-0x200000)
178 132
179#ifdef __KERNEL__ 133#ifdef __KERNEL__
134
135struct sk_buff;
136struct sock;
137
180struct sk_filter 138struct sk_filter
181{ 139{
182 atomic_t refcnt; 140 atomic_t refcnt;
183 unsigned int len; /* Number of filter blocks */ 141 unsigned int len; /* Number of filter blocks */
142 unsigned int (*bpf_func)(const struct sk_buff *skb,
143 const struct sock_filter *filter);
184 struct rcu_head rcu; 144 struct rcu_head rcu;
185 struct sock_filter insns[0]; 145 struct sock_filter insns[0];
186}; 146};
@@ -190,15 +150,86 @@ static inline unsigned int sk_filter_len(const struct sk_filter *fp)
190 return fp->len * sizeof(struct sock_filter) + sizeof(*fp); 150 return fp->len * sizeof(struct sock_filter) + sizeof(*fp);
191} 151}
192 152
193struct sk_buff;
194struct sock;
195
196extern int sk_filter(struct sock *sk, struct sk_buff *skb); 153extern int sk_filter(struct sock *sk, struct sk_buff *skb);
197extern unsigned int sk_run_filter(struct sk_buff *skb, 154extern unsigned int sk_run_filter(const struct sk_buff *skb,
198 struct sock_filter *filter, int flen); 155 const struct sock_filter *filter);
199extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); 156extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
200extern int sk_detach_filter(struct sock *sk); 157extern int sk_detach_filter(struct sock *sk);
201extern int sk_chk_filter(struct sock_filter *filter, int flen); 158extern int sk_chk_filter(struct sock_filter *filter, int flen);
159
160#ifdef CONFIG_BPF_JIT
161extern void bpf_jit_compile(struct sk_filter *fp);
162extern void bpf_jit_free(struct sk_filter *fp);
163#define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns)
164#else
165static inline void bpf_jit_compile(struct sk_filter *fp)
166{
167}
168static inline void bpf_jit_free(struct sk_filter *fp)
169{
170}
171#define SK_RUN_FILTER(FILTER, SKB) sk_run_filter(SKB, FILTER->insns)
172#endif
173
174enum {
175 BPF_S_RET_K = 1,
176 BPF_S_RET_A,
177 BPF_S_ALU_ADD_K,
178 BPF_S_ALU_ADD_X,
179 BPF_S_ALU_SUB_K,
180 BPF_S_ALU_SUB_X,
181 BPF_S_ALU_MUL_K,
182 BPF_S_ALU_MUL_X,
183 BPF_S_ALU_DIV_X,
184 BPF_S_ALU_AND_K,
185 BPF_S_ALU_AND_X,
186 BPF_S_ALU_OR_K,
187 BPF_S_ALU_OR_X,
188 BPF_S_ALU_LSH_K,
189 BPF_S_ALU_LSH_X,
190 BPF_S_ALU_RSH_K,
191 BPF_S_ALU_RSH_X,
192 BPF_S_ALU_NEG,
193 BPF_S_LD_W_ABS,
194 BPF_S_LD_H_ABS,
195 BPF_S_LD_B_ABS,
196 BPF_S_LD_W_LEN,
197 BPF_S_LD_W_IND,
198 BPF_S_LD_H_IND,
199 BPF_S_LD_B_IND,
200 BPF_S_LD_IMM,
201 BPF_S_LDX_W_LEN,
202 BPF_S_LDX_B_MSH,
203 BPF_S_LDX_IMM,
204 BPF_S_MISC_TAX,
205 BPF_S_MISC_TXA,
206 BPF_S_ALU_DIV_K,
207 BPF_S_LD_MEM,
208 BPF_S_LDX_MEM,
209 BPF_S_ST,
210 BPF_S_STX,
211 BPF_S_JMP_JA,
212 BPF_S_JMP_JEQ_K,
213 BPF_S_JMP_JEQ_X,
214 BPF_S_JMP_JGE_K,
215 BPF_S_JMP_JGE_X,
216 BPF_S_JMP_JGT_K,
217 BPF_S_JMP_JGT_X,
218 BPF_S_JMP_JSET_K,
219 BPF_S_JMP_JSET_X,
220 /* Ancillary data */
221 BPF_S_ANC_PROTOCOL,
222 BPF_S_ANC_PKTTYPE,
223 BPF_S_ANC_IFINDEX,
224 BPF_S_ANC_NLATTR,
225 BPF_S_ANC_NLATTR_NEST,
226 BPF_S_ANC_MARK,
227 BPF_S_ANC_QUEUE,
228 BPF_S_ANC_HATYPE,
229 BPF_S_ANC_RXHASH,
230 BPF_S_ANC_CPU,
231};
232
202#endif /* __KERNEL__ */ 233#endif /* __KERNEL__ */
203 234
204#endif /* __LINUX_FILTER_H__ */ 235#endif /* __LINUX_FILTER_H__ */
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
index 68c642d8843d..4ff09889c5c0 100644
--- a/include/linux/firewire-cdev.h
+++ b/include/linux/firewire-cdev.h
@@ -273,7 +273,7 @@ struct fw_cdev_event_iso_interrupt {
273 * @closure: See &fw_cdev_event_common; 273 * @closure: See &fw_cdev_event_common;
274 * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl 274 * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
275 * @type: %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL 275 * @type: %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
276 * @completed: Offset into the receive buffer; data before this offest is valid 276 * @completed: Offset into the receive buffer; data before this offset is valid
277 * 277 *
278 * This event is sent in multichannel contexts (context type 278 * This event is sent in multichannel contexts (context type
279 * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer 279 * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer
@@ -900,7 +900,7 @@ struct fw_cdev_get_cycle_timer2 {
900 900
901/** 901/**
902 * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth 902 * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth
903 * @closure: Passed back to userspace in correponding iso resource events 903 * @closure: Passed back to userspace in corresponding iso resource events
904 * @channels: Isochronous channels of which one is to be (de)allocated 904 * @channels: Isochronous channels of which one is to be (de)allocated
905 * @bandwidth: Isochronous bandwidth units to be (de)allocated 905 * @bandwidth: Isochronous bandwidth units to be (de)allocated
906 * @handle: Handle to the allocation, written by the kernel (only valid in 906 * @handle: Handle to the allocation, written by the kernel (only valid in
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index 1cd637ef62d2..5e6f42789afe 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -42,6 +42,10 @@
42#define CSR_BROADCAST_CHANNEL 0x234 42#define CSR_BROADCAST_CHANNEL 0x234
43#define CSR_CONFIG_ROM 0x400 43#define CSR_CONFIG_ROM 0x400
44#define CSR_CONFIG_ROM_END 0x800 44#define CSR_CONFIG_ROM_END 0x800
45#define CSR_OMPR 0x900
46#define CSR_OPCR(i) (0x904 + (i) * 4)
47#define CSR_IMPR 0x980
48#define CSR_IPCR(i) (0x984 + (i) * 4)
45#define CSR_FCP_COMMAND 0xB00 49#define CSR_FCP_COMMAND 0xB00
46#define CSR_FCP_RESPONSE 0xD00 50#define CSR_FCP_RESPONSE 0xD00
47#define CSR_FCP_END 0xF00 51#define CSR_FCP_END 0xF00
@@ -89,7 +93,7 @@ struct fw_card {
89 int current_tlabel; 93 int current_tlabel;
90 u64 tlabel_mask; 94 u64 tlabel_mask;
91 struct list_head transaction_list; 95 struct list_head transaction_list;
92 unsigned long reset_jiffies; 96 u64 reset_jiffies;
93 97
94 u32 split_timeout_hi; 98 u32 split_timeout_hi;
95 u32 split_timeout_lo; 99 u32 split_timeout_lo;
@@ -121,7 +125,6 @@ struct fw_card {
121 struct delayed_work bm_work; /* bus manager job */ 125 struct delayed_work bm_work; /* bus manager job */
122 int bm_retries; 126 int bm_retries;
123 int bm_generation; 127 int bm_generation;
124 __be32 bm_transaction_data[2];
125 int bm_node_id; 128 int bm_node_id;
126 bool bm_abdicate; 129 bool bm_abdicate;
127 130
@@ -302,9 +305,9 @@ struct fw_packet {
302struct fw_transaction { 305struct fw_transaction {
303 int node_id; /* The generation is implied; it is always the current. */ 306 int node_id; /* The generation is implied; it is always the current. */
304 int tlabel; 307 int tlabel;
305 int timestamp;
306 struct list_head link; 308 struct list_head link;
307 struct fw_card *card; 309 struct fw_card *card;
310 bool is_split_transaction;
308 struct timer_list split_timeout_timer; 311 struct timer_list split_timeout_timer;
309 312
310 struct fw_packet packet; 313 struct fw_packet packet;
@@ -437,9 +440,15 @@ int fw_iso_context_queue(struct fw_iso_context *ctx,
437 struct fw_iso_packet *packet, 440 struct fw_iso_packet *packet,
438 struct fw_iso_buffer *buffer, 441 struct fw_iso_buffer *buffer,
439 unsigned long payload); 442 unsigned long payload);
443void fw_iso_context_queue_flush(struct fw_iso_context *ctx);
440int fw_iso_context_start(struct fw_iso_context *ctx, 444int fw_iso_context_start(struct fw_iso_context *ctx,
441 int cycle, int sync, int tags); 445 int cycle, int sync, int tags);
442int fw_iso_context_stop(struct fw_iso_context *ctx); 446int fw_iso_context_stop(struct fw_iso_context *ctx);
443void fw_iso_context_destroy(struct fw_iso_context *ctx); 447void fw_iso_context_destroy(struct fw_iso_context *ctx);
448void fw_iso_resource_manage(struct fw_card *card, int generation,
449 u64 channels_mask, int *channel, int *bandwidth,
450 bool allocate);
451
452extern struct workqueue_struct *fw_workqueue;
444 453
445#endif /* _LINUX_FIREWIRE_H */ 454#endif /* _LINUX_FIREWIRE_H */
diff --git a/include/linux/firmware-map.h b/include/linux/firmware-map.h
index c6dcc1dfe781..43fe52fcef0f 100644
--- a/include/linux/firmware-map.h
+++ b/include/linux/firmware-map.h
@@ -17,7 +17,6 @@
17#define _LINUX_FIRMWARE_MAP_H 17#define _LINUX_FIRMWARE_MAP_H
18 18
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/kobject.h>
21 20
22/* 21/*
23 * provide a dummy interface if CONFIG_FIRMWARE_MEMMAP is disabled 22 * provide a dummy interface if CONFIG_FIRMWARE_MEMMAP is disabled
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index 53d1e6c4f848..21b3e7588abd 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -39,7 +39,7 @@ struct builtin_fw {
39int request_firmware(const struct firmware **fw, const char *name, 39int request_firmware(const struct firmware **fw, const char *name,
40 struct device *device); 40 struct device *device);
41int request_firmware_nowait( 41int request_firmware_nowait(
42 struct module *module, int uevent, 42 struct module *module, bool uevent,
43 const char *name, struct device *device, gfp_t gfp, void *context, 43 const char *name, struct device *device, gfp_t gfp, void *context,
44 void (*cont)(const struct firmware *fw, void *context)); 44 void (*cont)(const struct firmware *fw, void *context));
45 45
@@ -52,7 +52,7 @@ static inline int request_firmware(const struct firmware **fw,
52 return -EINVAL; 52 return -EINVAL;
53} 53}
54static inline int request_firmware_nowait( 54static inline int request_firmware_nowait(
55 struct module *module, int uevent, 55 struct module *module, bool uevent,
56 const char *name, struct device *device, gfp_t gfp, void *context, 56 const char *name, struct device *device, gfp_t gfp, void *context,
57 void (*cont)(const struct firmware *fw, void *context)) 57 void (*cont)(const struct firmware *fw, void *context))
58{ 58{
diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h
index 631b77f2ac70..6843cf193a44 100644
--- a/include/linux/flex_array.h
+++ b/include/linux/flex_array.h
@@ -21,6 +21,8 @@ struct flex_array {
21 struct { 21 struct {
22 int element_size; 22 int element_size;
23 int total_nr_elements; 23 int total_nr_elements;
24 int elems_per_part;
25 u32 reciprocal_elems;
24 struct flex_array_part *parts[]; 26 struct flex_array_part *parts[];
25 }; 27 };
26 /* 28 /*
@@ -61,7 +63,7 @@ struct flex_array {
61struct flex_array *flex_array_alloc(int element_size, unsigned int total, 63struct flex_array *flex_array_alloc(int element_size, unsigned int total,
62 gfp_t flags); 64 gfp_t flags);
63int flex_array_prealloc(struct flex_array *fa, unsigned int start, 65int flex_array_prealloc(struct flex_array *fa, unsigned int start,
64 unsigned int end, gfp_t flags); 66 unsigned int nr_elements, gfp_t flags);
65void flex_array_free(struct flex_array *fa); 67void flex_array_free(struct flex_array *fa);
66void flex_array_free_parts(struct flex_array *fa); 68void flex_array_free_parts(struct flex_array *fa);
67int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, 69int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
@@ -71,7 +73,7 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr);
71int flex_array_shrink(struct flex_array *fa); 73int flex_array_shrink(struct flex_array *fa);
72 74
73#define flex_array_put_ptr(fa, nr, src, gfp) \ 75#define flex_array_put_ptr(fa, nr, src, gfp) \
74 flex_array_put(fa, nr, &(void *)(src), gfp) 76 flex_array_put(fa, nr, (void *)&(src), gfp)
75 77
76void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr); 78void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr);
77 79
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index da7e52b099f3..1effc8b56b4e 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -109,7 +109,7 @@ static inline void freezer_count(void)
109} 109}
110 110
111/* 111/*
112 * Check if the task should be counted as freezeable by the freezer 112 * Check if the task should be counted as freezable by the freezer
113 */ 113 */
114static inline int freezer_should_skip(struct task_struct *p) 114static inline int freezer_should_skip(struct task_struct *p)
115{ 115{
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 29a672458d27..8d5834bcb891 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -9,6 +9,7 @@
9#include <linux/limits.h> 9#include <linux/limits.h>
10#include <linux/ioctl.h> 10#include <linux/ioctl.h>
11#include <linux/blk_types.h> 11#include <linux/blk_types.h>
12#include <linux/types.h>
12 13
13/* 14/*
14 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change 15 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
@@ -22,7 +23,8 @@
22 23
23/* Fixed constants first: */ 24/* Fixed constants first: */
24#undef NR_OPEN 25#undef NR_OPEN
25#define INR_OPEN 1024 /* Initial setting for nfile rlimits */ 26#define INR_OPEN_CUR 1024 /* Initial setting for nfile rlimits */
27#define INR_OPEN_MAX 4096 /* Hard limit for nfile rlimits */
26 28
27#define BLOCK_SIZE_BITS 10 29#define BLOCK_SIZE_BITS 10
28#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS) 30#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
@@ -32,11 +34,17 @@
32#define SEEK_END 2 /* seek relative to end of file */ 34#define SEEK_END 2 /* seek relative to end of file */
33#define SEEK_MAX SEEK_END 35#define SEEK_MAX SEEK_END
34 36
37struct fstrim_range {
38 __u64 start;
39 __u64 len;
40 __u64 minlen;
41};
42
35/* And dynamically-tunable limits and defaults: */ 43/* And dynamically-tunable limits and defaults: */
36struct files_stat_struct { 44struct files_stat_struct {
37 int nr_files; /* read only */ 45 unsigned long nr_files; /* read only */
38 int nr_free_files; /* read only */ 46 unsigned long nr_free_files; /* read only */
39 int max_files; /* tunable */ 47 unsigned long max_files; /* tunable */
40}; 48};
41 49
42struct inodes_stat_t { 50struct inodes_stat_t {
@@ -92,6 +100,12 @@ struct inodes_stat_t {
92/* Expect random access pattern */ 100/* Expect random access pattern */
93#define FMODE_RANDOM ((__force fmode_t)0x1000) 101#define FMODE_RANDOM ((__force fmode_t)0x1000)
94 102
103/* File is huge (eg. /dev/kmem): treat loff_t as unsigned */
104#define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000)
105
106/* File is opened with O_PATH; almost nothing can be done with it */
107#define FMODE_PATH ((__force fmode_t)0x4000)
108
95/* File was opened by fanotify and shouldn't generate fanotify events */ 109/* File was opened by fanotify and shouldn't generate fanotify events */
96#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) 110#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)
97 111
@@ -125,22 +139,16 @@ struct inodes_stat_t {
125 * block layer could (in theory) choose to ignore this 139 * block layer could (in theory) choose to ignore this
126 * request if it runs into resource problems. 140 * request if it runs into resource problems.
127 * WRITE A normal async write. Device will be plugged. 141 * WRITE A normal async write. Device will be plugged.
128 * WRITE_SYNC_PLUG Synchronous write. Identical to WRITE, but passes down 142 * WRITE_SYNC Synchronous write. Identical to WRITE, but passes down
129 * the hint that someone will be waiting on this IO 143 * the hint that someone will be waiting on this IO
130 * shortly. The device must still be unplugged explicitly, 144 * shortly. The write equivalent of READ_SYNC.
131 * WRITE_SYNC_PLUG does not do this as we could be 145 * WRITE_ODIRECT Special case write for O_DIRECT only.
132 * submitting more writes before we actually wait on any 146 * WRITE_FLUSH Like WRITE_SYNC but with preceding cache flush.
133 * of them. 147 * WRITE_FUA Like WRITE_SYNC but data is guaranteed to be on
134 * WRITE_SYNC Like WRITE_SYNC_PLUG, but also unplugs the device 148 * non-volatile media on completion.
135 * immediately after submission. The write equivalent 149 * WRITE_FLUSH_FUA Combination of WRITE_FLUSH and FUA. The IO is preceded
136 * of READ_SYNC. 150 * by a cache flush and data is guaranteed to be on
137 * WRITE_ODIRECT_PLUG Special case write for O_DIRECT only. 151 * non-volatile media on completion.
138 * WRITE_BARRIER Like WRITE_SYNC, but tells the block layer that all
139 * previously submitted writes must be safely on storage
140 * before this one is started. Also guarantees that when
141 * this write is complete, it itself is also safely on
142 * storage. Prevents reordering of writes on both sides
143 * of this IO.
144 * 152 *
145 */ 153 */
146#define RW_MASK REQ_WRITE 154#define RW_MASK REQ_WRITE
@@ -150,22 +158,14 @@ struct inodes_stat_t {
150#define WRITE RW_MASK 158#define WRITE RW_MASK
151#define READA RWA_MASK 159#define READA RWA_MASK
152 160
153#define READ_SYNC (READ | REQ_SYNC | REQ_UNPLUG) 161#define READ_SYNC (READ | REQ_SYNC)
154#define READ_META (READ | REQ_META) 162#define READ_META (READ | REQ_META)
155#define WRITE_SYNC_PLUG (WRITE | REQ_SYNC | REQ_NOIDLE) 163#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE)
156#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG) 164#define WRITE_ODIRECT (WRITE | REQ_SYNC)
157#define WRITE_ODIRECT_PLUG (WRITE | REQ_SYNC)
158#define WRITE_META (WRITE | REQ_META) 165#define WRITE_META (WRITE | REQ_META)
159#define WRITE_BARRIER (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG | \ 166#define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH)
160 REQ_HARDBARRIER) 167#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
161 168#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
162/*
163 * These aren't really reads or writes, they pass down information about
164 * parts of device that are now unused by the file system.
165 */
166#define DISCARD_NOBARRIER (WRITE | REQ_DISCARD)
167#define DISCARD_BARRIER (WRITE | REQ_DISCARD | REQ_HARDBARRIER)
168#define DISCARD_SECURE (DISCARD_NOBARRIER | REQ_SECURE)
169 169
170#define SEL_IN 1 170#define SEL_IN 1
171#define SEL_OUT 2 171#define SEL_OUT 2
@@ -208,6 +208,7 @@ struct inodes_stat_t {
208#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ 208#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
209#define MS_I_VERSION (1<<23) /* Update inode I_version field */ 209#define MS_I_VERSION (1<<23) /* Update inode I_version field */
210#define MS_STRICTATIME (1<<24) /* Always perform atime updates */ 210#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
211#define MS_NOSEC (1<<28)
211#define MS_BORN (1<<29) 212#define MS_BORN (1<<29)
212#define MS_ACTIVE (1<<30) 213#define MS_ACTIVE (1<<30)
213#define MS_NOUSER (1<<31) 214#define MS_NOUSER (1<<31)
@@ -235,6 +236,9 @@ struct inodes_stat_t {
235#define S_NOCMTIME 128 /* Do not update file c/mtime */ 236#define S_NOCMTIME 128 /* Do not update file c/mtime */
236#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ 237#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
237#define S_PRIVATE 512 /* Inode is fs-internal */ 238#define S_PRIVATE 512 /* Inode is fs-internal */
239#define S_IMA 1024 /* Inode has an associated IMA struct */
240#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
241#define S_NOSEC 4096 /* no suid or xattr security attributes */
238 242
239/* 243/*
240 * Note that nosuid etc flags are inode-specific: setting some file-system 244 * Note that nosuid etc flags are inode-specific: setting some file-system
@@ -269,6 +273,9 @@ struct inodes_stat_t {
269#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) 273#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
270#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE) 274#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
271#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE) 275#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
276#define IS_IMA(inode) ((inode)->i_flags & S_IMA)
277#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
278#define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
272 279
273/* the read-only stuff doesn't really belong here, but any other place is 280/* the read-only stuff doesn't really belong here, but any other place is
274 probably as bad and I don't want to create yet another include file. */ 281 probably as bad and I don't want to create yet another include file. */
@@ -316,6 +323,7 @@ struct inodes_stat_t {
316#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */ 323#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
317#define FIFREEZE _IOWR('X', 119, int) /* Freeze */ 324#define FIFREEZE _IOWR('X', 119, int) /* Freeze */
318#define FITHAW _IOWR('X', 120, int) /* Thaw */ 325#define FITHAW _IOWR('X', 120, int) /* Thaw */
326#define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */
319 327
320#define FS_IOC_GETFLAGS _IOR('f', 1, long) 328#define FS_IOC_GETFLAGS _IOR('f', 1, long)
321#define FS_IOC_SETFLAGS _IOW('f', 2, long) 329#define FS_IOC_SETFLAGS _IOW('f', 2, long)
@@ -353,6 +361,7 @@ struct inodes_stat_t {
353#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ 361#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
354#define FS_EXTENT_FL 0x00080000 /* Extents */ 362#define FS_EXTENT_FL 0x00080000 /* Extents */
355#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */ 363#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
364#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
356#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ 365#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
357 366
358#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ 367#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
@@ -373,7 +382,6 @@ struct inodes_stat_t {
373#include <linux/path.h> 382#include <linux/path.h>
374#include <linux/stat.h> 383#include <linux/stat.h>
375#include <linux/cache.h> 384#include <linux/cache.h>
376#include <linux/kobject.h>
377#include <linux/list.h> 385#include <linux/list.h>
378#include <linux/radix-tree.h> 386#include <linux/radix-tree.h>
379#include <linux/prio_tree.h> 387#include <linux/prio_tree.h>
@@ -383,6 +391,7 @@ struct inodes_stat_t {
383#include <linux/capability.h> 391#include <linux/capability.h>
384#include <linux/semaphore.h> 392#include <linux/semaphore.h>
385#include <linux/fiemap.h> 393#include <linux/fiemap.h>
394#include <linux/rculist_bl.h>
386 395
387#include <asm/atomic.h> 396#include <asm/atomic.h>
388#include <asm/byteorder.h> 397#include <asm/byteorder.h>
@@ -392,6 +401,7 @@ struct hd_geometry;
392struct iovec; 401struct iovec;
393struct nameidata; 402struct nameidata;
394struct kiocb; 403struct kiocb;
404struct kobject;
395struct pipe_inode_info; 405struct pipe_inode_info;
396struct poll_table_struct; 406struct poll_table_struct;
397struct kstatfs; 407struct kstatfs;
@@ -404,7 +414,7 @@ extern void __init inode_init_early(void);
404extern void __init files_init(unsigned long); 414extern void __init files_init(unsigned long);
405 415
406extern struct files_stat_struct files_stat; 416extern struct files_stat_struct files_stat;
407extern int get_max_files(void); 417extern unsigned long get_max_files(void);
408extern int sysctl_nr_open; 418extern int sysctl_nr_open;
409extern struct inodes_stat_t inodes_stat; 419extern struct inodes_stat_t inodes_stat;
410extern int leases_enable, lease_break_time; 420extern int leases_enable, lease_break_time;
@@ -458,7 +468,7 @@ struct iattr {
458 struct timespec ia_ctime; 468 struct timespec ia_ctime;
459 469
460 /* 470 /*
461 * Not an attribute, but an auxilary info for filesystems wanting to 471 * Not an attribute, but an auxiliary info for filesystems wanting to
462 * implement an ftruncate() like method. NOTE: filesystem should 472 * implement an ftruncate() like method. NOTE: filesystem should
463 * check for (ia_valid & ATTR_FILE), and not for (ia_file != NULL). 473 * check for (ia_valid & ATTR_FILE), and not for (ia_file != NULL).
464 */ 474 */
@@ -571,7 +581,6 @@ typedef int (*read_actor_t)(read_descriptor_t *, struct page *,
571struct address_space_operations { 581struct address_space_operations {
572 int (*writepage)(struct page *page, struct writeback_control *wbc); 582 int (*writepage)(struct page *page, struct writeback_control *wbc);
573 int (*readpage)(struct file *, struct page *); 583 int (*readpage)(struct file *, struct page *);
574 void (*sync_page)(struct page *);
575 584
576 /* Write back some dirty pages from this mapping. */ 585 /* Write back some dirty pages from this mapping. */
577 int (*writepages)(struct address_space *, struct writeback_control *); 586 int (*writepages)(struct address_space *, struct writeback_control *);
@@ -593,6 +602,7 @@ struct address_space_operations {
593 sector_t (*bmap)(struct address_space *, sector_t); 602 sector_t (*bmap)(struct address_space *, sector_t);
594 void (*invalidatepage) (struct page *, unsigned long); 603 void (*invalidatepage) (struct page *, unsigned long);
595 int (*releasepage) (struct page *, gfp_t); 604 int (*releasepage) (struct page *, gfp_t);
605 void (*freepage)(struct page *);
596 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, 606 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
597 loff_t offset, unsigned long nr_segs); 607 loff_t offset, unsigned long nr_segs);
598 int (*get_xip_mem)(struct address_space *, pgoff_t, int, 608 int (*get_xip_mem)(struct address_space *, pgoff_t, int,
@@ -606,6 +616,8 @@ struct address_space_operations {
606 int (*error_remove_page)(struct address_space *, struct page *); 616 int (*error_remove_page)(struct address_space *, struct page *);
607}; 617};
608 618
619extern const struct address_space_operations empty_aops;
620
609/* 621/*
610 * pagecache_write_begin/pagecache_write_end must be used by general code 622 * pagecache_write_begin/pagecache_write_end must be used by general code
611 * to write into the pagecache. 623 * to write into the pagecache.
@@ -626,8 +638,8 @@ struct address_space {
626 unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 638 unsigned int i_mmap_writable;/* count VM_SHARED mappings */
627 struct prio_tree_root i_mmap; /* tree of private and shared mappings */ 639 struct prio_tree_root i_mmap; /* tree of private and shared mappings */
628 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 640 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
629 spinlock_t i_mmap_lock; /* protect tree, count, list */ 641 struct mutex i_mmap_mutex; /* protect tree, count, list */
630 unsigned int truncate_count; /* Cover race condition with truncate */ 642 /* Protected by tree_lock together with the radix tree */
631 unsigned long nrpages; /* number of total pages */ 643 unsigned long nrpages; /* number of total pages */
632 pgoff_t writeback_index;/* writeback starts here */ 644 pgoff_t writeback_index;/* writeback starts here */
633 const struct address_space_operations *a_ops; /* methods */ 645 const struct address_space_operations *a_ops; /* methods */
@@ -639,22 +651,23 @@ struct address_space {
639} __attribute__((aligned(sizeof(long)))); 651} __attribute__((aligned(sizeof(long))));
640 /* 652 /*
641 * On most architectures that alignment is already the case; but 653 * On most architectures that alignment is already the case; but
642 * must be enforced here for CRIS, to let the least signficant bit 654 * must be enforced here for CRIS, to let the least significant bit
643 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. 655 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON.
644 */ 656 */
645 657
646struct block_device { 658struct block_device {
647 dev_t bd_dev; /* not a kdev_t - it's a search key */ 659 dev_t bd_dev; /* not a kdev_t - it's a search key */
660 int bd_openers;
648 struct inode * bd_inode; /* will die */ 661 struct inode * bd_inode; /* will die */
649 struct super_block * bd_super; 662 struct super_block * bd_super;
650 int bd_openers;
651 struct mutex bd_mutex; /* open/close mutex */ 663 struct mutex bd_mutex; /* open/close mutex */
652 struct list_head bd_inodes; 664 struct list_head bd_inodes;
653 void * bd_claiming; 665 void * bd_claiming;
654 void * bd_holder; 666 void * bd_holder;
655 int bd_holders; 667 int bd_holders;
668 bool bd_write_holder;
656#ifdef CONFIG_SYSFS 669#ifdef CONFIG_SYSFS
657 struct list_head bd_holder_list; 670 struct list_head bd_holder_disks;
658#endif 671#endif
659 struct block_device * bd_contains; 672 struct block_device * bd_contains;
660 unsigned bd_block_size; 673 unsigned bd_block_size;
@@ -724,15 +737,35 @@ struct posix_acl;
724struct inode_obj_id_table; 737struct inode_obj_id_table;
725 738
726struct inode { 739struct inode {
740 /* RCU path lookup touches following: */
741 umode_t i_mode;
742 uid_t i_uid;
743 gid_t i_gid;
744 const struct inode_operations *i_op;
745 struct super_block *i_sb;
746
747 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
748 unsigned int i_flags;
749 unsigned long i_state;
750#ifdef CONFIG_SECURITY
751 void *i_security;
752#endif
753 struct mutex i_mutex;
754
755
756 unsigned long dirtied_when; /* jiffies of first dirtying */
757
727 struct hlist_node i_hash; 758 struct hlist_node i_hash;
728 struct list_head i_list; /* backing dev IO list */ 759 struct list_head i_wb_list; /* backing dev IO list */
760 struct list_head i_lru; /* inode LRU list */
729 struct list_head i_sb_list; 761 struct list_head i_sb_list;
730 struct list_head i_dentry; 762 union {
763 struct list_head i_dentry;
764 struct rcu_head i_rcu;
765 };
731 unsigned long i_ino; 766 unsigned long i_ino;
732 atomic_t i_count; 767 atomic_t i_count;
733 unsigned int i_nlink; 768 unsigned int i_nlink;
734 uid_t i_uid;
735 gid_t i_gid;
736 dev_t i_rdev; 769 dev_t i_rdev;
737 unsigned int i_blkbits; 770 unsigned int i_blkbits;
738 u64 i_version; 771 u64 i_version;
@@ -745,13 +778,8 @@ struct inode {
745 struct timespec i_ctime; 778 struct timespec i_ctime;
746 blkcnt_t i_blocks; 779 blkcnt_t i_blocks;
747 unsigned short i_bytes; 780 unsigned short i_bytes;
748 umode_t i_mode;
749 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
750 struct mutex i_mutex;
751 struct rw_semaphore i_alloc_sem; 781 struct rw_semaphore i_alloc_sem;
752 const struct inode_operations *i_op;
753 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 782 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
754 struct super_block *i_sb;
755 struct file_lock *i_flock; 783 struct file_lock *i_flock;
756 struct address_space *i_mapping; 784 struct address_space *i_mapping;
757 struct address_space i_data; 785 struct address_space i_data;
@@ -772,15 +800,10 @@ struct inode {
772 struct hlist_head i_fsnotify_marks; 800 struct hlist_head i_fsnotify_marks;
773#endif 801#endif
774 802
775 unsigned long i_state; 803#ifdef CONFIG_IMA
776 unsigned long dirtied_when; /* jiffies of first dirtying */ 804 atomic_t i_readcount; /* struct files open RO */
777
778 unsigned int i_flags;
779
780 atomic_t i_writecount;
781#ifdef CONFIG_SECURITY
782 void *i_security;
783#endif 805#endif
806 atomic_t i_writecount;
784#ifdef CONFIG_FS_POSIX_ACL 807#ifdef CONFIG_FS_POSIX_ACL
785 struct posix_acl *i_acl; 808 struct posix_acl *i_acl;
786 struct posix_acl *i_default_acl; 809 struct posix_acl *i_default_acl;
@@ -790,6 +813,11 @@ struct inode {
790 void *i_private; /* fs or device private pointer */ 813 void *i_private; /* fs or device private pointer */
791}; 814};
792 815
816static inline int inode_unhashed(struct inode *inode)
817{
818 return hlist_unhashed(&inode->i_hash);
819}
820
793/* 821/*
794 * inode->i_mutex nesting subclasses for the lock validator: 822 * inode->i_mutex nesting subclasses for the lock validator:
795 * 823 *
@@ -951,6 +979,13 @@ struct file {
951#endif 979#endif
952}; 980};
953 981
982struct file_handle {
983 __u32 handle_bytes;
984 int handle_type;
985 /* file identifier */
986 unsigned char f_handle[0];
987};
988
954#define get_file(x) atomic_long_inc(&(x)->f_count) 989#define get_file(x) atomic_long_inc(&(x)->f_count)
955#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) 990#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1)
956#define file_count(x) atomic_long_read(&(x)->f_count) 991#define file_count(x) atomic_long_read(&(x)->f_count)
@@ -1040,10 +1075,8 @@ struct lock_manager_operations {
1040 int (*fl_compare_owner)(struct file_lock *, struct file_lock *); 1075 int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
1041 void (*fl_notify)(struct file_lock *); /* unblock callback */ 1076 void (*fl_notify)(struct file_lock *); /* unblock callback */
1042 int (*fl_grant)(struct file_lock *, struct file_lock *, int); 1077 int (*fl_grant)(struct file_lock *, struct file_lock *, int);
1043 void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
1044 void (*fl_release_private)(struct file_lock *); 1078 void (*fl_release_private)(struct file_lock *);
1045 void (*fl_break)(struct file_lock *); 1079 void (*fl_break)(struct file_lock *);
1046 int (*fl_mylease)(struct file_lock *, struct file_lock *);
1047 int (*fl_change)(struct file_lock **, int); 1080 int (*fl_change)(struct file_lock **, int);
1048}; 1081};
1049 1082
@@ -1096,10 +1129,6 @@ struct file_lock {
1096 1129
1097#include <linux/fcntl.h> 1130#include <linux/fcntl.h>
1098 1131
1099/* temporary stubs for BKL removal */
1100#define lock_flocks() lock_kernel()
1101#define unlock_flocks() unlock_kernel()
1102
1103extern void send_sigio(struct fown_struct *fown, int fd, int band); 1132extern void send_sigio(struct fown_struct *fown, int fd, int band);
1104 1133
1105#ifdef CONFIG_FILE_LOCKING 1134#ifdef CONFIG_FILE_LOCKING
@@ -1117,7 +1146,9 @@ extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
1117extern int fcntl_getlease(struct file *filp); 1146extern int fcntl_getlease(struct file *filp);
1118 1147
1119/* fs/locks.c */ 1148/* fs/locks.c */
1149void locks_free_lock(struct file_lock *fl);
1120extern void locks_init_lock(struct file_lock *); 1150extern void locks_init_lock(struct file_lock *);
1151extern struct file_lock * locks_alloc_lock(void);
1121extern void locks_copy_lock(struct file_lock *, struct file_lock *); 1152extern void locks_copy_lock(struct file_lock *, struct file_lock *);
1122extern void __locks_copy_lock(struct file_lock *, const struct file_lock *); 1153extern void __locks_copy_lock(struct file_lock *, const struct file_lock *);
1123extern void locks_remove_posix(struct file *, fl_owner_t); 1154extern void locks_remove_posix(struct file *, fl_owner_t);
@@ -1138,6 +1169,8 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
1138extern int lease_modify(struct file_lock **, int); 1169extern int lease_modify(struct file_lock **, int);
1139extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1170extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
1140extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 1171extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
1172extern void lock_flocks(void);
1173extern void unlock_flocks(void);
1141#else /* !CONFIG_FILE_LOCKING */ 1174#else /* !CONFIG_FILE_LOCKING */
1142static inline int fcntl_getlk(struct file *file, struct flock __user *user) 1175static inline int fcntl_getlk(struct file *file, struct flock __user *user)
1143{ 1176{
@@ -1280,6 +1313,14 @@ static inline int lock_may_write(struct inode *inode, loff_t start,
1280 return 1; 1313 return 1;
1281} 1314}
1282 1315
1316static inline void lock_flocks(void)
1317{
1318}
1319
1320static inline void unlock_flocks(void)
1321{
1322}
1323
1283#endif /* !CONFIG_FILE_LOCKING */ 1324#endif /* !CONFIG_FILE_LOCKING */
1284 1325
1285 1326
@@ -1296,6 +1337,11 @@ struct fasync_struct {
1296 1337
1297/* SMP safe fasync helpers: */ 1338/* SMP safe fasync helpers: */
1298extern int fasync_helper(int, struct file *, int, struct fasync_struct **); 1339extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
1340extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *);
1341extern int fasync_remove_entry(struct file *, struct fasync_struct **);
1342extern struct fasync_struct *fasync_alloc(void);
1343extern void fasync_free(struct fasync_struct *);
1344
1299/* can be called from interrupts */ 1345/* can be called from interrupts */
1300extern void kill_fasync(struct fasync_struct **, int, int); 1346extern void kill_fasync(struct fasync_struct **, int, int);
1301 1347
@@ -1343,13 +1389,13 @@ struct super_block {
1343 const struct xattr_handler **s_xattr; 1389 const struct xattr_handler **s_xattr;
1344 1390
1345 struct list_head s_inodes; /* all inodes */ 1391 struct list_head s_inodes; /* all inodes */
1346 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */ 1392 struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */
1347#ifdef CONFIG_SMP 1393#ifdef CONFIG_SMP
1348 struct list_head __percpu *s_files; 1394 struct list_head __percpu *s_files;
1349#else 1395#else
1350 struct list_head s_files; 1396 struct list_head s_files;
1351#endif 1397#endif
1352 /* s_dentry_lru and s_nr_dentry_unused are protected by dcache_lock */ 1398 /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */
1353 struct list_head s_dentry_lru; /* unused dentry lru */ 1399 struct list_head s_dentry_lru; /* unused dentry lru */
1354 int s_nr_dentry_unused; /* # of dentry on lru */ 1400 int s_nr_dentry_unused; /* # of dentry on lru */
1355 1401
@@ -1363,6 +1409,7 @@ struct super_block {
1363 wait_queue_head_t s_wait_unfrozen; 1409 wait_queue_head_t s_wait_unfrozen;
1364 1410
1365 char s_id[32]; /* Informational name */ 1411 char s_id[32]; /* Informational name */
1412 u8 s_uuid[16]; /* UUID */
1366 1413
1367 void *s_fs_info; /* Filesystem private info */ 1414 void *s_fs_info; /* Filesystem private info */
1368 fmode_t s_mode; 1415 fmode_t s_mode;
@@ -1387,7 +1434,13 @@ struct super_block {
1387 * Saved mount options for lazy filesystems using 1434 * Saved mount options for lazy filesystems using
1388 * generic_show_options() 1435 * generic_show_options()
1389 */ 1436 */
1390 char *s_options; 1437 char __rcu *s_options;
1438 const struct dentry_operations *s_d_op; /* default d_op for dentries */
1439
1440 /*
1441 * Saved pool identifier for cleancache (-1 means none)
1442 */
1443 int cleancache_poolid;
1391}; 1444};
1392 1445
1393extern struct timespec current_fs_time(struct super_block *sb); 1446extern struct timespec current_fs_time(struct super_block *sb);
@@ -1408,8 +1461,13 @@ enum {
1408#define put_fs_excl() atomic_dec(&current->fs_excl) 1461#define put_fs_excl() atomic_dec(&current->fs_excl)
1409#define has_fs_excl() atomic_read(&current->fs_excl) 1462#define has_fs_excl() atomic_read(&current->fs_excl)
1410 1463
1411#define is_owner_or_cap(inode) \ 1464/*
1412 ((current_fsuid() == (inode)->i_uid) || capable(CAP_FOWNER)) 1465 * until VFS tracks user namespaces for inodes, just make all files
1466 * belong to init_user_ns
1467 */
1468extern struct user_namespace init_user_ns;
1469#define inode_userns(inode) (&init_user_ns)
1470extern bool inode_owner_or_capable(const struct inode *inode);
1413 1471
1414/* not quite ready to be deprecated, but... */ 1472/* not quite ready to be deprecated, but... */
1415extern void lock_super(struct super_block *); 1473extern void lock_super(struct super_block *);
@@ -1445,8 +1503,8 @@ struct fiemap_extent_info {
1445 unsigned int fi_flags; /* Flags as passed from user */ 1503 unsigned int fi_flags; /* Flags as passed from user */
1446 unsigned int fi_extents_mapped; /* Number of mapped extents */ 1504 unsigned int fi_extents_mapped; /* Number of mapped extents */
1447 unsigned int fi_extents_max; /* Size of fiemap_extent array */ 1505 unsigned int fi_extents_max; /* Size of fiemap_extent array */
1448 struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent 1506 struct fiemap_extent __user *fi_extents_start; /* Start of
1449 * array */ 1507 fiemap_extent array */
1450}; 1508};
1451int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, 1509int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
1452 u64 phys, u64 len, u32 flags); 1510 u64 phys, u64 len, u32 flags);
@@ -1514,11 +1572,22 @@ struct file_operations {
1514 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1572 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
1515 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); 1573 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
1516 int (*setlease)(struct file *, long, struct file_lock **); 1574 int (*setlease)(struct file *, long, struct file_lock **);
1575 long (*fallocate)(struct file *file, int mode, loff_t offset,
1576 loff_t len);
1517}; 1577};
1518 1578
1579#define IPERM_FLAG_RCU 0x0001
1580
1519struct inode_operations { 1581struct inode_operations {
1520 int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
1521 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *); 1582 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
1583 void * (*follow_link) (struct dentry *, struct nameidata *);
1584 int (*permission) (struct inode *, int, unsigned int);
1585 int (*check_acl)(struct inode *, int, unsigned int);
1586
1587 int (*readlink) (struct dentry *, char __user *,int);
1588 void (*put_link) (struct dentry *, struct nameidata *, void *);
1589
1590 int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
1522 int (*link) (struct dentry *,struct inode *,struct dentry *); 1591 int (*link) (struct dentry *,struct inode *,struct dentry *);
1523 int (*unlink) (struct inode *,struct dentry *); 1592 int (*unlink) (struct inode *,struct dentry *);
1524 int (*symlink) (struct inode *,struct dentry *,const char *); 1593 int (*symlink) (struct inode *,struct dentry *,const char *);
@@ -1527,12 +1596,7 @@ struct inode_operations {
1527 int (*mknod) (struct inode *,struct dentry *,int,dev_t); 1596 int (*mknod) (struct inode *,struct dentry *,int,dev_t);
1528 int (*rename) (struct inode *, struct dentry *, 1597 int (*rename) (struct inode *, struct dentry *,
1529 struct inode *, struct dentry *); 1598 struct inode *, struct dentry *);
1530 int (*readlink) (struct dentry *, char __user *,int);
1531 void * (*follow_link) (struct dentry *, struct nameidata *);
1532 void (*put_link) (struct dentry *, struct nameidata *, void *);
1533 void (*truncate) (struct inode *); 1599 void (*truncate) (struct inode *);
1534 int (*permission) (struct inode *, int);
1535 int (*check_acl)(struct inode *, int);
1536 int (*setattr) (struct dentry *, struct iattr *); 1600 int (*setattr) (struct dentry *, struct iattr *);
1537 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 1601 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1538 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); 1602 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -1540,11 +1604,9 @@ struct inode_operations {
1540 ssize_t (*listxattr) (struct dentry *, char *, size_t); 1604 ssize_t (*listxattr) (struct dentry *, char *, size_t);
1541 int (*removexattr) (struct dentry *, const char *); 1605 int (*removexattr) (struct dentry *, const char *);
1542 void (*truncate_range)(struct inode *, loff_t, loff_t); 1606 void (*truncate_range)(struct inode *, loff_t, loff_t);
1543 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
1544 loff_t len);
1545 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, 1607 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
1546 u64 len); 1608 u64 len);
1547}; 1609} ____cacheline_aligned;
1548 1610
1549struct seq_file; 1611struct seq_file;
1550 1612
@@ -1564,7 +1626,7 @@ struct super_operations {
1564 struct inode *(*alloc_inode)(struct super_block *sb); 1626 struct inode *(*alloc_inode)(struct super_block *sb);
1565 void (*destroy_inode)(struct inode *); 1627 void (*destroy_inode)(struct inode *);
1566 1628
1567 void (*dirty_inode) (struct inode *); 1629 void (*dirty_inode) (struct inode *, int flags);
1568 int (*write_inode) (struct inode *, struct writeback_control *wbc); 1630 int (*write_inode) (struct inode *, struct writeback_control *wbc);
1569 int (*drop_inode) (struct inode *); 1631 int (*drop_inode) (struct inode *);
1570 void (*evict_inode) (struct inode *); 1632 void (*evict_inode) (struct inode *);
@@ -1578,6 +1640,8 @@ struct super_operations {
1578 void (*umount_begin) (struct super_block *); 1640 void (*umount_begin) (struct super_block *);
1579 1641
1580 int (*show_options)(struct seq_file *, struct vfsmount *); 1642 int (*show_options)(struct seq_file *, struct vfsmount *);
1643 int (*show_devname)(struct seq_file *, struct vfsmount *);
1644 int (*show_path)(struct seq_file *, struct vfsmount *);
1581 int (*show_stats)(struct seq_file *, struct vfsmount *); 1645 int (*show_stats)(struct seq_file *, struct vfsmount *);
1582#ifdef CONFIG_QUOTA 1646#ifdef CONFIG_QUOTA
1583 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); 1647 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
@@ -1587,7 +1651,7 @@ struct super_operations {
1587}; 1651};
1588 1652
1589/* 1653/*
1590 * Inode state bits. Protected by inode_lock. 1654 * Inode state bits. Protected by inode->i_lock
1591 * 1655 *
1592 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC, 1656 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC,
1593 * I_DIRTY_DATASYNC and I_DIRTY_PAGES. 1657 * I_DIRTY_DATASYNC and I_DIRTY_PAGES.
@@ -1634,16 +1698,17 @@ struct super_operations {
1634 * 1698 *
1635 * Q: What is the difference between I_WILL_FREE and I_FREEING? 1699 * Q: What is the difference between I_WILL_FREE and I_FREEING?
1636 */ 1700 */
1637#define I_DIRTY_SYNC 1 1701#define I_DIRTY_SYNC (1 << 0)
1638#define I_DIRTY_DATASYNC 2 1702#define I_DIRTY_DATASYNC (1 << 1)
1639#define I_DIRTY_PAGES 4 1703#define I_DIRTY_PAGES (1 << 2)
1640#define __I_NEW 3 1704#define __I_NEW 3
1641#define I_NEW (1 << __I_NEW) 1705#define I_NEW (1 << __I_NEW)
1642#define I_WILL_FREE 16 1706#define I_WILL_FREE (1 << 4)
1643#define I_FREEING 32 1707#define I_FREEING (1 << 5)
1644#define I_CLEAR 64 1708#define I_CLEAR (1 << 6)
1645#define __I_SYNC 7 1709#define __I_SYNC 7
1646#define I_SYNC (1 << __I_SYNC) 1710#define I_SYNC (1 << __I_SYNC)
1711#define I_REFERENCED (1 << 8)
1647 1712
1648#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) 1713#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
1649 1714
@@ -1735,12 +1800,13 @@ static inline void file_accessed(struct file *file)
1735} 1800}
1736 1801
1737int sync_inode(struct inode *inode, struct writeback_control *wbc); 1802int sync_inode(struct inode *inode, struct writeback_control *wbc);
1803int sync_inode_metadata(struct inode *inode, int wait);
1738 1804
1739struct file_system_type { 1805struct file_system_type {
1740 const char *name; 1806 const char *name;
1741 int fs_flags; 1807 int fs_flags;
1742 int (*get_sb) (struct file_system_type *, int, 1808 struct dentry *(*mount) (struct file_system_type *, int,
1743 const char *, void *, struct vfsmount *); 1809 const char *, void *);
1744 void (*kill_sb) (struct super_block *); 1810 void (*kill_sb) (struct super_block *);
1745 struct module *owner; 1811 struct module *owner;
1746 struct file_system_type * next; 1812 struct file_system_type * next;
@@ -1756,21 +1822,17 @@ struct file_system_type {
1756 struct lock_class_key i_alloc_sem_key; 1822 struct lock_class_key i_alloc_sem_key;
1757}; 1823};
1758 1824
1759extern int get_sb_ns(struct file_system_type *fs_type, int flags, void *data, 1825extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags,
1760 int (*fill_super)(struct super_block *, void *, int), 1826 void *data, int (*fill_super)(struct super_block *, void *, int));
1761 struct vfsmount *mnt); 1827extern struct dentry *mount_bdev(struct file_system_type *fs_type,
1762extern int get_sb_bdev(struct file_system_type *fs_type,
1763 int flags, const char *dev_name, void *data, 1828 int flags, const char *dev_name, void *data,
1764 int (*fill_super)(struct super_block *, void *, int), 1829 int (*fill_super)(struct super_block *, void *, int));
1765 struct vfsmount *mnt); 1830extern struct dentry *mount_single(struct file_system_type *fs_type,
1766extern int get_sb_single(struct file_system_type *fs_type,
1767 int flags, void *data, 1831 int flags, void *data,
1768 int (*fill_super)(struct super_block *, void *, int), 1832 int (*fill_super)(struct super_block *, void *, int));
1769 struct vfsmount *mnt); 1833extern struct dentry *mount_nodev(struct file_system_type *fs_type,
1770extern int get_sb_nodev(struct file_system_type *fs_type,
1771 int flags, void *data, 1834 int flags, void *data,
1772 int (*fill_super)(struct super_block *, void *, int), 1835 int (*fill_super)(struct super_block *, void *, int));
1773 struct vfsmount *mnt);
1774void generic_shutdown_super(struct super_block *sb); 1836void generic_shutdown_super(struct super_block *sb);
1775void kill_block_super(struct super_block *sb); 1837void kill_block_super(struct super_block *sb);
1776void kill_anon_super(struct super_block *sb); 1838void kill_anon_super(struct super_block *sb);
@@ -1782,10 +1844,10 @@ struct super_block *sget(struct file_system_type *type,
1782 int (*test)(struct super_block *,void *), 1844 int (*test)(struct super_block *,void *),
1783 int (*set)(struct super_block *,void *), 1845 int (*set)(struct super_block *,void *),
1784 void *data); 1846 void *data);
1785extern int get_sb_pseudo(struct file_system_type *, char *, 1847extern struct dentry *mount_pseudo(struct file_system_type *, char *,
1786 const struct super_operations *ops, unsigned long, 1848 const struct super_operations *ops,
1787 struct vfsmount *mnt); 1849 const struct dentry_operations *dops,
1788extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1850 unsigned long);
1789 1851
1790static inline void sb_mark_dirty(struct super_block *sb) 1852static inline void sb_mark_dirty(struct super_block *sb)
1791{ 1853{
@@ -1818,6 +1880,8 @@ extern void drop_collected_mounts(struct vfsmount *);
1818extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, 1880extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
1819 struct vfsmount *); 1881 struct vfsmount *);
1820extern int vfs_statfs(struct path *, struct kstatfs *); 1882extern int vfs_statfs(struct path *, struct kstatfs *);
1883extern int user_statfs(const char __user *, struct kstatfs *);
1884extern int fd_statfs(int, struct kstatfs *);
1821extern int statfs_by_dentry(struct dentry *, struct kstatfs *); 1885extern int statfs_by_dentry(struct dentry *, struct kstatfs *);
1822extern int freeze_super(struct super_block *super); 1886extern int freeze_super(struct super_block *super);
1823extern int thaw_super(struct super_block *super); 1887extern int thaw_super(struct super_block *super);
@@ -1827,6 +1891,7 @@ extern int current_umask(void);
1827/* /sys/fs */ 1891/* /sys/fs */
1828extern struct kobject *fs_kobj; 1892extern struct kobject *fs_kobj;
1829 1893
1894#define MAX_RW_COUNT (INT_MAX & PAGE_CACHE_MASK)
1830extern int rw_verify_area(int, struct file *, loff_t *, size_t); 1895extern int rw_verify_area(int, struct file *, loff_t *, size_t);
1831 1896
1832#define FLOCK_VERIFY_READ 1 1897#define FLOCK_VERIFY_READ 1
@@ -1933,6 +1998,8 @@ extern int do_fallocate(struct file *file, int mode, loff_t offset,
1933extern long do_sys_open(int dfd, const char __user *filename, int flags, 1998extern long do_sys_open(int dfd, const char __user *filename, int flags,
1934 int mode); 1999 int mode);
1935extern struct file *filp_open(const char *, int, int); 2000extern struct file *filp_open(const char *, int, int);
2001extern struct file *file_open_root(struct dentry *, struct vfsmount *,
2002 const char *, int);
1936extern struct file * dentry_open(struct dentry *, struct vfsmount *, int, 2003extern struct file * dentry_open(struct dentry *, struct vfsmount *, int,
1937 const struct cred *); 2004 const struct cred *);
1938extern int filp_close(struct file *, fl_owner_t id); 2005extern int filp_close(struct file *, fl_owner_t id);
@@ -1965,7 +2032,6 @@ extern struct block_device *bdgrab(struct block_device *bdev);
1965extern void bd_set_size(struct block_device *, loff_t size); 2032extern void bd_set_size(struct block_device *, loff_t size);
1966extern void bd_forget(struct inode *inode); 2033extern void bd_forget(struct inode *inode);
1967extern void bdput(struct block_device *); 2034extern void bdput(struct block_device *);
1968extern struct block_device *open_by_devnum(dev_t, fmode_t);
1969extern void invalidate_bdev(struct block_device *); 2035extern void invalidate_bdev(struct block_device *);
1970extern int sync_blockdev(struct block_device *bdev); 2036extern int sync_blockdev(struct block_device *bdev);
1971extern struct super_block *freeze_bdev(struct block_device *); 2037extern struct super_block *freeze_bdev(struct block_device *);
@@ -1996,16 +2062,26 @@ extern const struct file_operations def_fifo_fops;
1996extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 2062extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1997extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); 2063extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
1998extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 2064extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1999extern int blkdev_get(struct block_device *, fmode_t); 2065extern int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder);
2000extern int blkdev_put(struct block_device *, fmode_t); 2066extern struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
2001extern int bd_claim(struct block_device *, void *); 2067 void *holder);
2002extern void bd_release(struct block_device *); 2068extern struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode,
2069 void *holder);
2070extern int blkdev_put(struct block_device *bdev, fmode_t mode);
2003#ifdef CONFIG_SYSFS 2071#ifdef CONFIG_SYSFS
2004extern int bd_claim_by_disk(struct block_device *, void *, struct gendisk *); 2072extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk);
2005extern void bd_release_from_disk(struct block_device *, struct gendisk *); 2073extern void bd_unlink_disk_holder(struct block_device *bdev,
2074 struct gendisk *disk);
2006#else 2075#else
2007#define bd_claim_by_disk(bdev, holder, disk) bd_claim(bdev, holder) 2076static inline int bd_link_disk_holder(struct block_device *bdev,
2008#define bd_release_from_disk(bdev, disk) bd_release(bdev) 2077 struct gendisk *disk)
2078{
2079 return 0;
2080}
2081static inline void bd_unlink_disk_holder(struct block_device *bdev,
2082 struct gendisk *disk)
2083{
2084}
2009#endif 2085#endif
2010#endif 2086#endif
2011 2087
@@ -2041,8 +2117,6 @@ static inline void unregister_chrdev(unsigned int major, const char *name)
2041extern const char *__bdevname(dev_t, char *buffer); 2117extern const char *__bdevname(dev_t, char *buffer);
2042extern const char *bdevname(struct block_device *bdev, char *buffer); 2118extern const char *bdevname(struct block_device *bdev, char *buffer);
2043extern struct block_device *lookup_bdev(const char *); 2119extern struct block_device *lookup_bdev(const char *);
2044extern struct block_device *open_bdev_exclusive(const char *, fmode_t, void *);
2045extern void close_bdev_exclusive(struct block_device *, fmode_t);
2046extern void blkdev_show(struct seq_file *,off_t); 2120extern void blkdev_show(struct seq_file *,off_t);
2047 2121
2048#else 2122#else
@@ -2076,10 +2150,9 @@ extern void check_disk_size_change(struct gendisk *disk,
2076 struct block_device *bdev); 2150 struct block_device *bdev);
2077extern int revalidate_disk(struct gendisk *); 2151extern int revalidate_disk(struct gendisk *);
2078extern int check_disk_change(struct block_device *); 2152extern int check_disk_change(struct block_device *);
2079extern int __invalidate_device(struct block_device *); 2153extern int __invalidate_device(struct block_device *, bool);
2080extern int invalidate_partition(struct gendisk *, int); 2154extern int invalidate_partition(struct gendisk *, int);
2081#endif 2155#endif
2082extern int invalidate_inodes(struct super_block *);
2083unsigned long invalidate_mapping_pages(struct address_space *mapping, 2156unsigned long invalidate_mapping_pages(struct address_space *mapping,
2084 pgoff_t start, pgoff_t end); 2157 pgoff_t start, pgoff_t end);
2085 2158
@@ -2118,8 +2191,8 @@ extern sector_t bmap(struct inode *, sector_t);
2118#endif 2191#endif
2119extern int notify_change(struct dentry *, struct iattr *); 2192extern int notify_change(struct dentry *, struct iattr *);
2120extern int inode_permission(struct inode *, int); 2193extern int inode_permission(struct inode *, int);
2121extern int generic_permission(struct inode *, int, 2194extern int generic_permission(struct inode *, int, unsigned int,
2122 int (*check_acl)(struct inode *, int)); 2195 int (*check_acl)(struct inode *, int, unsigned int));
2123 2196
2124static inline bool execute_ok(struct inode *inode) 2197static inline bool execute_ok(struct inode *inode)
2125{ 2198{
@@ -2137,15 +2210,31 @@ static inline void allow_write_access(struct file *file)
2137 if (file) 2210 if (file)
2138 atomic_inc(&file->f_path.dentry->d_inode->i_writecount); 2211 atomic_inc(&file->f_path.dentry->d_inode->i_writecount);
2139} 2212}
2213#ifdef CONFIG_IMA
2214static inline void i_readcount_dec(struct inode *inode)
2215{
2216 BUG_ON(!atomic_read(&inode->i_readcount));
2217 atomic_dec(&inode->i_readcount);
2218}
2219static inline void i_readcount_inc(struct inode *inode)
2220{
2221 atomic_inc(&inode->i_readcount);
2222}
2223#else
2224static inline void i_readcount_dec(struct inode *inode)
2225{
2226 return;
2227}
2228static inline void i_readcount_inc(struct inode *inode)
2229{
2230 return;
2231}
2232#endif
2140extern int do_pipe_flags(int *, int); 2233extern int do_pipe_flags(int *, int);
2141extern struct file *create_read_pipe(struct file *f, int flags); 2234extern struct file *create_read_pipe(struct file *f, int flags);
2142extern struct file *create_write_pipe(int flags); 2235extern struct file *create_write_pipe(int flags);
2143extern void free_write_pipe(struct file *); 2236extern void free_write_pipe(struct file *);
2144 2237
2145extern struct file *do_filp_open(int dfd, const char *pathname,
2146 int open_flag, int mode, int acc_mode);
2147extern int may_open(struct path *, int, int);
2148
2149extern int kernel_read(struct file *, loff_t, char *, unsigned long); 2238extern int kernel_read(struct file *, loff_t, char *, unsigned long);
2150extern struct file * open_exec(const char *); 2239extern struct file * open_exec(const char *);
2151 2240
@@ -2163,7 +2252,8 @@ extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin);
2163 2252
2164extern int inode_init_always(struct super_block *, struct inode *); 2253extern int inode_init_always(struct super_block *, struct inode *);
2165extern void inode_init_once(struct inode *); 2254extern void inode_init_once(struct inode *);
2166extern void inode_add_to_lists(struct super_block *, struct inode *); 2255extern void address_space_init_once(struct address_space *mapping);
2256extern void ihold(struct inode * inode);
2167extern void iput(struct inode *); 2257extern void iput(struct inode *);
2168extern struct inode * igrab(struct inode *); 2258extern struct inode * igrab(struct inode *);
2169extern ino_t iunique(struct super_block *, ino_t); 2259extern ino_t iunique(struct super_block *, ino_t);
@@ -2183,21 +2273,24 @@ extern struct inode * iget_locked(struct super_block *, unsigned long);
2183extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); 2273extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *);
2184extern int insert_inode_locked(struct inode *); 2274extern int insert_inode_locked(struct inode *);
2185extern void unlock_new_inode(struct inode *); 2275extern void unlock_new_inode(struct inode *);
2276extern unsigned int get_next_ino(void);
2186 2277
2187extern void __iget(struct inode * inode); 2278extern void __iget(struct inode * inode);
2188extern void iget_failed(struct inode *); 2279extern void iget_failed(struct inode *);
2189extern void end_writeback(struct inode *); 2280extern void end_writeback(struct inode *);
2190extern void destroy_inode(struct inode *);
2191extern void __destroy_inode(struct inode *); 2281extern void __destroy_inode(struct inode *);
2192extern struct inode *new_inode(struct super_block *); 2282extern struct inode *new_inode(struct super_block *);
2283extern void free_inode_nonrcu(struct inode *inode);
2193extern int should_remove_suid(struct dentry *); 2284extern int should_remove_suid(struct dentry *);
2194extern int file_remove_suid(struct file *); 2285extern int file_remove_suid(struct file *);
2195 2286
2196extern void __insert_inode_hash(struct inode *, unsigned long hashval); 2287extern void __insert_inode_hash(struct inode *, unsigned long hashval);
2197extern void remove_inode_hash(struct inode *); 2288extern void remove_inode_hash(struct inode *);
2198static inline void insert_inode_hash(struct inode *inode) { 2289static inline void insert_inode_hash(struct inode *inode)
2290{
2199 __insert_inode_hash(inode, inode->i_ino); 2291 __insert_inode_hash(inode, inode->i_ino);
2200} 2292}
2293extern void inode_sb_list_add(struct inode *inode);
2201 2294
2202#ifdef CONFIG_BLOCK 2295#ifdef CONFIG_BLOCK
2203extern void submit_bio(int, struct bio *); 2296extern void submit_bio(int, struct bio *);
@@ -2381,6 +2474,8 @@ extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
2381 2474
2382extern int generic_file_fsync(struct file *, int); 2475extern int generic_file_fsync(struct file *, int);
2383 2476
2477extern int generic_check_addressable(unsigned, u64);
2478
2384#ifdef CONFIG_MIGRATION 2479#ifdef CONFIG_MIGRATION
2385extern int buffer_migrate_page(struct address_space *, 2480extern int buffer_migrate_page(struct address_space *,
2386 struct page *, struct page *); 2481 struct page *, struct page *);
@@ -2402,6 +2497,10 @@ static inline ino_t parent_ino(struct dentry *dentry)
2402{ 2497{
2403 ino_t res; 2498 ino_t res;
2404 2499
2500 /*
2501 * Don't strictly need d_lock here? If the parent ino could change
2502 * then surely we'd have a deeper race in the caller?
2503 */
2405 spin_lock(&dentry->d_lock); 2504 spin_lock(&dentry->d_lock);
2406 res = dentry->d_parent->d_inode->i_ino; 2505 res = dentry->d_parent->d_inode->i_ino;
2407 spin_unlock(&dentry->d_lock); 2506 spin_unlock(&dentry->d_lock);
@@ -2457,6 +2556,7 @@ static const struct file_operations __fops = { \
2457 .release = simple_attr_release, \ 2556 .release = simple_attr_release, \
2458 .read = simple_attr_read, \ 2557 .read = simple_attr_read, \
2459 .write = simple_attr_write, \ 2558 .write = simple_attr_write, \
2559 .llseek = generic_file_llseek, \
2460}; 2560};
2461 2561
2462static inline void __attribute__((format(printf, 1, 2))) 2562static inline void __attribute__((format(printf, 1, 2)))
@@ -2477,12 +2577,29 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
2477struct ctl_table; 2577struct ctl_table;
2478int proc_nr_files(struct ctl_table *table, int write, 2578int proc_nr_files(struct ctl_table *table, int write,
2479 void __user *buffer, size_t *lenp, loff_t *ppos); 2579 void __user *buffer, size_t *lenp, loff_t *ppos);
2480 2580int proc_nr_dentry(struct ctl_table *table, int write,
2581 void __user *buffer, size_t *lenp, loff_t *ppos);
2582int proc_nr_inodes(struct ctl_table *table, int write,
2583 void __user *buffer, size_t *lenp, loff_t *ppos);
2481int __init get_filesystem_list(char *buf); 2584int __init get_filesystem_list(char *buf);
2482 2585
2586#define __FMODE_EXEC ((__force int) FMODE_EXEC)
2587#define __FMODE_NONOTIFY ((__force int) FMODE_NONOTIFY)
2588
2483#define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE]) 2589#define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE])
2484#define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \ 2590#define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \
2485 (flag & FMODE_NONOTIFY))) 2591 (flag & __FMODE_NONOTIFY)))
2592
2593static inline int is_sxid(mode_t mode)
2594{
2595 return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP));
2596}
2597
2598static inline void inode_has_no_xattr(struct inode *inode)
2599{
2600 if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC))
2601 inode->i_flags |= S_NOSEC;
2602}
2486 2603
2487#endif /* __KERNEL__ */ 2604#endif /* __KERNEL__ */
2488#endif /* _LINUX_FS_H */ 2605#endif /* _LINUX_FS_H */
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index a42b5bf02f8b..003dc0fd7347 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -2,10 +2,13 @@
2#define _LINUX_FS_STRUCT_H 2#define _LINUX_FS_STRUCT_H
3 3
4#include <linux/path.h> 4#include <linux/path.h>
5#include <linux/spinlock.h>
6#include <linux/seqlock.h>
5 7
6struct fs_struct { 8struct fs_struct {
7 int users; 9 int users;
8 spinlock_t lock; 10 spinlock_t lock;
11 seqcount_t seq;
9 int umask; 12 int umask;
10 int in_exec; 13 int in_exec;
11 struct path root, pwd; 14 struct path root, pwd;
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index b8581c09d19f..af095b54502e 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -100,17 +100,6 @@ struct fscache_operation {
100 100
101 /* operation releaser */ 101 /* operation releaser */
102 fscache_operation_release_t release; 102 fscache_operation_release_t release;
103
104#ifdef CONFIG_WORKQUEUE_DEBUGFS
105 struct work_struct put_work; /* work to delay operation put */
106 const char *name; /* operation name */
107 const char *state; /* operation state */
108#define fscache_set_op_name(OP, N) do { (OP)->name = (N); } while(0)
109#define fscache_set_op_state(OP, S) do { (OP)->state = (S); } while(0)
110#else
111#define fscache_set_op_name(OP, N) do { } while(0)
112#define fscache_set_op_state(OP, S) do { } while(0)
113#endif
114}; 103};
115 104
116extern atomic_t fscache_op_debug_id; 105extern atomic_t fscache_op_debug_id;
@@ -137,7 +126,6 @@ static inline void fscache_operation_init(struct fscache_operation *op,
137 op->processor = processor; 126 op->processor = processor;
138 op->release = release; 127 op->release = release;
139 INIT_LIST_HEAD(&op->pend_link); 128 INIT_LIST_HEAD(&op->pend_link);
140 fscache_set_op_state(op, "Init");
141} 129}
142 130
143/* 131/*
@@ -236,7 +224,7 @@ struct fscache_cache_ops {
236 /* unpin an object in the cache */ 224 /* unpin an object in the cache */
237 void (*unpin_object)(struct fscache_object *object); 225 void (*unpin_object)(struct fscache_object *object);
238 226
239 /* store the updated auxilliary data on an object */ 227 /* store the updated auxiliary data on an object */
240 void (*update_object)(struct fscache_object *object); 228 void (*update_object)(struct fscache_object *object);
241 229
242 /* discard the resources pinned by an object and effect retirement if 230 /* discard the resources pinned by an object and effect retirement if
diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index ec0dad5ab90f..9ec20dec3353 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -102,9 +102,9 @@ struct fscache_cookie_def {
102 */ 102 */
103 void (*get_attr)(const void *cookie_netfs_data, uint64_t *size); 103 void (*get_attr)(const void *cookie_netfs_data, uint64_t *size);
104 104
105 /* get the auxilliary data from netfs data 105 /* get the auxiliary data from netfs data
106 * - this function can be absent if the index carries no state data 106 * - this function can be absent if the index carries no state data
107 * - should store the auxilliary data in the buffer 107 * - should store the auxiliary data in the buffer
108 * - should return the amount of amount stored 108 * - should return the amount of amount stored
109 * - not permitted to return an error 109 * - not permitted to return an error
110 * - the netfs data from the cookie being used as the source is 110 * - the netfs data from the cookie being used as the source is
@@ -117,7 +117,7 @@ struct fscache_cookie_def {
117 /* consult the netfs about the state of an object 117 /* consult the netfs about the state of an object
118 * - this function can be absent if the index carries no state data 118 * - this function can be absent if the index carries no state data
119 * - the netfs data from the cookie being used as the target is 119 * - the netfs data from the cookie being used as the target is
120 * presented, as is the auxilliary data 120 * presented, as is the auxiliary data
121 */ 121 */
122 enum fscache_checkaux (*check_aux)(void *cookie_netfs_data, 122 enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
123 const void *data, 123 const void *data,
@@ -204,6 +204,8 @@ extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *);
204extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *); 204extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *);
205extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *, 205extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *,
206 gfp_t); 206 gfp_t);
207extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *,
208 struct inode *);
207 209
208/** 210/**
209 * fscache_register_netfs - Register a filesystem as desiring caching services 211 * fscache_register_netfs - Register a filesystem as desiring caching services
@@ -643,4 +645,23 @@ bool fscache_maybe_release_page(struct fscache_cookie *cookie,
643 return false; 645 return false;
644} 646}
645 647
648/**
649 * fscache_uncache_all_inode_pages - Uncache all an inode's pages
650 * @cookie: The cookie representing the inode's cache object.
651 * @inode: The inode to uncache pages from.
652 *
653 * Uncache all the pages in an inode that are marked PG_fscache, assuming them
654 * to be associated with the given cookie.
655 *
656 * This function may sleep. It will wait for pages that are being written out
657 * and will wait whilst the PG_fscache mark is removed by the cache.
658 */
659static inline
660void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie,
661 struct inode *inode)
662{
663 if (fscache_cookie_valid(cookie))
664 __fscache_uncache_all_inode_pages(cookie, inode);
665}
666
646#endif /* _LINUX_FSCACHE_H */ 667#endif /* _LINUX_FSCACHE_H */
diff --git a/include/linux/fsl-diu-fb.h b/include/linux/fsl-diu-fb.h
index fc295d7ea463..daa9952d2174 100644
--- a/include/linux/fsl-diu-fb.h
+++ b/include/linux/fsl-diu-fb.h
@@ -24,12 +24,6 @@
24 * See mpc8610fb_set_par(), map_video_memory(), and unmap_video_memory() 24 * See mpc8610fb_set_par(), map_video_memory(), and unmap_video_memory()
25 */ 25 */
26#define MEM_ALLOC_THRESHOLD (1024*768*4+32) 26#define MEM_ALLOC_THRESHOLD (1024*768*4+32)
27/* Minimum value that the pixel clock can be set to in pico seconds
28 * This is determined by platform clock/3 where the minimum platform
29 * clock is 533MHz. This gives 5629 pico seconds.
30 */
31#define MIN_PIX_CLK 5629
32#define MAX_PIX_CLK 96096
33 27
34#include <linux/types.h> 28#include <linux/types.h>
35 29
@@ -54,7 +48,6 @@ struct aoi_display_offset {
54}; 48};
55 49
56#define MFB_SET_CHROMA_KEY _IOW('M', 1, struct mfb_chroma_key) 50#define MFB_SET_CHROMA_KEY _IOW('M', 1, struct mfb_chroma_key)
57#define MFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t)
58#define MFB_SET_BRIGHTNESS _IOW('M', 3, __u8) 51#define MFB_SET_BRIGHTNESS _IOW('M', 3, __u8)
59 52
60#define MFB_SET_ALPHA 0x80014d00 53#define MFB_SET_ALPHA 0x80014d00
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 28e33fea5107..fffdf00f87b9 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -58,17 +58,51 @@ enum fsl_usb2_phy_modes {
58 FSL_USB2_PHY_SERIAL, 58 FSL_USB2_PHY_SERIAL,
59}; 59};
60 60
61struct clk;
62struct platform_device;
63
61struct fsl_usb2_platform_data { 64struct fsl_usb2_platform_data {
62 /* board specific information */ 65 /* board specific information */
63 enum fsl_usb2_operating_modes operating_mode; 66 enum fsl_usb2_operating_modes operating_mode;
64 enum fsl_usb2_phy_modes phy_mode; 67 enum fsl_usb2_phy_modes phy_mode;
65 unsigned int port_enables; 68 unsigned int port_enables;
69 unsigned int workaround;
70
71 int (*init)(struct platform_device *);
72 void (*exit)(struct platform_device *);
73 void __iomem *regs; /* ioremap'd register base */
74 struct clk *clk;
75 unsigned power_budget; /* hcd->power_budget */
76 unsigned big_endian_mmio:1;
77 unsigned big_endian_desc:1;
78 unsigned es:1; /* need USBMODE:ES */
79 unsigned le_setup_buf:1;
80 unsigned have_sysif_regs:1;
81 unsigned invert_drvvbus:1;
82 unsigned invert_pwr_fault:1;
83
84 unsigned suspended:1;
85 unsigned already_suspended:1;
86
87 /* register save area for suspend/resume */
88 u32 pm_command;
89 u32 pm_status;
90 u32 pm_intr_enable;
91 u32 pm_frame_index;
92 u32 pm_segment;
93 u32 pm_frame_list;
94 u32 pm_async_next;
95 u32 pm_configured_flag;
96 u32 pm_portsc;
97 u32 pm_usbgenctrl;
66}; 98};
67 99
68/* Flags in fsl_usb2_mph_platform_data */ 100/* Flags in fsl_usb2_mph_platform_data */
69#define FSL_USB2_PORT0_ENABLED 0x00000001 101#define FSL_USB2_PORT0_ENABLED 0x00000001
70#define FSL_USB2_PORT1_ENABLED 0x00000002 102#define FSL_USB2_PORT1_ENABLED 0x00000002
71 103
104#define FLS_USB2_WORKAROUND_ENGCM09152 (1 << 0)
105
72struct spi_device; 106struct spi_device;
73 107
74struct fsl_spi_platform_data { 108struct fsl_spi_platform_data {
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 59d0df43ff9d..2a53f10712b3 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -17,7 +17,6 @@
17 17
18/* 18/*
19 * fsnotify_d_instantiate - instantiate a dentry for inode 19 * fsnotify_d_instantiate - instantiate a dentry for inode
20 * Called with dcache_lock held.
21 */ 20 */
22static inline void fsnotify_d_instantiate(struct dentry *dentry, 21static inline void fsnotify_d_instantiate(struct dentry *dentry,
23 struct inode *inode) 22 struct inode *inode)
@@ -26,12 +25,12 @@ static inline void fsnotify_d_instantiate(struct dentry *dentry,
26} 25}
27 26
28/* Notify this dentry's parent about a child's events. */ 27/* Notify this dentry's parent about a child's events. */
29static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) 28static inline int fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
30{ 29{
31 if (!dentry) 30 if (!dentry)
32 dentry = path->dentry; 31 dentry = path->dentry;
33 32
34 __fsnotify_parent(path, dentry, mask); 33 return __fsnotify_parent(path, dentry, mask);
35} 34}
36 35
37/* simple call site for access decisions */ 36/* simple call site for access decisions */
@@ -40,6 +39,7 @@ static inline int fsnotify_perm(struct file *file, int mask)
40 struct path *path = &file->f_path; 39 struct path *path = &file->f_path;
41 struct inode *inode = path->dentry->d_inode; 40 struct inode *inode = path->dentry->d_inode;
42 __u32 fsnotify_mask = 0; 41 __u32 fsnotify_mask = 0;
42 int ret;
43 43
44 if (file->f_mode & FMODE_NONOTIFY) 44 if (file->f_mode & FMODE_NONOTIFY)
45 return 0; 45 return 0;
@@ -52,12 +52,15 @@ static inline int fsnotify_perm(struct file *file, int mask)
52 else 52 else
53 BUG(); 53 BUG();
54 54
55 ret = fsnotify_parent(path, NULL, fsnotify_mask);
56 if (ret)
57 return ret;
58
55 return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 59 return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
56} 60}
57 61
58/* 62/*
59 * fsnotify_d_move - dentry has been moved 63 * fsnotify_d_move - dentry has been moved
60 * Called with dcache_lock and dentry->d_lock held.
61 */ 64 */
62static inline void fsnotify_d_move(struct dentry *dentry) 65static inline void fsnotify_d_move(struct dentry *dentry)
63{ 66{
@@ -93,8 +96,8 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
93 old_dir_mask |= FS_DN_RENAME; 96 old_dir_mask |= FS_DN_RENAME;
94 97
95 if (isdir) { 98 if (isdir) {
96 old_dir_mask |= FS_IN_ISDIR; 99 old_dir_mask |= FS_ISDIR;
97 new_dir_mask |= FS_IN_ISDIR; 100 new_dir_mask |= FS_ISDIR;
98 } 101 }
99 102
100 fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie); 103 fsnotify(old_dir, old_dir_mask, old_dir, FSNOTIFY_EVENT_INODE, old_name, fs_cookie);
@@ -132,7 +135,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
132 __u32 mask = FS_DELETE; 135 __u32 mask = FS_DELETE;
133 136
134 if (isdir) 137 if (isdir)
135 mask |= FS_IN_ISDIR; 138 mask |= FS_ISDIR;
136 139
137 fsnotify_parent(NULL, dentry, mask); 140 fsnotify_parent(NULL, dentry, mask);
138} 141}
@@ -174,7 +177,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct
174 */ 177 */
175static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) 178static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
176{ 179{
177 __u32 mask = (FS_CREATE | FS_IN_ISDIR); 180 __u32 mask = (FS_CREATE | FS_ISDIR);
178 struct inode *d_inode = dentry->d_inode; 181 struct inode *d_inode = dentry->d_inode;
179 182
180 audit_inode_child(dentry, inode); 183 audit_inode_child(dentry, inode);
@@ -192,7 +195,7 @@ static inline void fsnotify_access(struct file *file)
192 __u32 mask = FS_ACCESS; 195 __u32 mask = FS_ACCESS;
193 196
194 if (S_ISDIR(inode->i_mode)) 197 if (S_ISDIR(inode->i_mode))
195 mask |= FS_IN_ISDIR; 198 mask |= FS_ISDIR;
196 199
197 if (!(file->f_mode & FMODE_NONOTIFY)) { 200 if (!(file->f_mode & FMODE_NONOTIFY)) {
198 fsnotify_parent(path, NULL, mask); 201 fsnotify_parent(path, NULL, mask);
@@ -210,7 +213,7 @@ static inline void fsnotify_modify(struct file *file)
210 __u32 mask = FS_MODIFY; 213 __u32 mask = FS_MODIFY;
211 214
212 if (S_ISDIR(inode->i_mode)) 215 if (S_ISDIR(inode->i_mode))
213 mask |= FS_IN_ISDIR; 216 mask |= FS_ISDIR;
214 217
215 if (!(file->f_mode & FMODE_NONOTIFY)) { 218 if (!(file->f_mode & FMODE_NONOTIFY)) {
216 fsnotify_parent(path, NULL, mask); 219 fsnotify_parent(path, NULL, mask);
@@ -228,12 +231,10 @@ static inline void fsnotify_open(struct file *file)
228 __u32 mask = FS_OPEN; 231 __u32 mask = FS_OPEN;
229 232
230 if (S_ISDIR(inode->i_mode)) 233 if (S_ISDIR(inode->i_mode))
231 mask |= FS_IN_ISDIR; 234 mask |= FS_ISDIR;
232 235
233 if (!(file->f_mode & FMODE_NONOTIFY)) { 236 fsnotify_parent(path, NULL, mask);
234 fsnotify_parent(path, NULL, mask); 237 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
235 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
236 }
237} 238}
238 239
239/* 240/*
@@ -247,7 +248,7 @@ static inline void fsnotify_close(struct file *file)
247 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; 248 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
248 249
249 if (S_ISDIR(inode->i_mode)) 250 if (S_ISDIR(inode->i_mode))
250 mask |= FS_IN_ISDIR; 251 mask |= FS_ISDIR;
251 252
252 if (!(file->f_mode & FMODE_NONOTIFY)) { 253 if (!(file->f_mode & FMODE_NONOTIFY)) {
253 fsnotify_parent(path, NULL, mask); 254 fsnotify_parent(path, NULL, mask);
@@ -264,7 +265,7 @@ static inline void fsnotify_xattr(struct dentry *dentry)
264 __u32 mask = FS_ATTRIB; 265 __u32 mask = FS_ATTRIB;
265 266
266 if (S_ISDIR(inode->i_mode)) 267 if (S_ISDIR(inode->i_mode))
267 mask |= FS_IN_ISDIR; 268 mask |= FS_ISDIR;
268 269
269 fsnotify_parent(NULL, dentry, mask); 270 fsnotify_parent(NULL, dentry, mask);
270 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 271 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
@@ -299,7 +300,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
299 300
300 if (mask) { 301 if (mask) {
301 if (S_ISDIR(inode->i_mode)) 302 if (S_ISDIR(inode->i_mode))
302 mask |= FS_IN_ISDIR; 303 mask |= FS_ISDIR;
303 304
304 fsnotify_parent(NULL, dentry, mask); 305 fsnotify_parent(NULL, dentry, mask);
305 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 306 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index e40190d16878..69ad89b50489 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -45,7 +45,7 @@
45#define FS_ACCESS_PERM 0x00020000 /* access event in a permissions hook */ 45#define FS_ACCESS_PERM 0x00020000 /* access event in a permissions hook */
46 46
47#define FS_EXCL_UNLINK 0x04000000 /* do not send events if object is unlinked */ 47#define FS_EXCL_UNLINK 0x04000000 /* do not send events if object is unlinked */
48#define FS_IN_ISDIR 0x40000000 /* event occurred against dir */ 48#define FS_ISDIR 0x40000000 /* event occurred against dir */
49#define FS_IN_ONESHOT 0x80000000 /* only send event once */ 49#define FS_IN_ONESHOT 0x80000000 /* only send event once */
50 50
51#define FS_DN_RENAME 0x10000000 /* file renamed */ 51#define FS_DN_RENAME 0x10000000 /* file renamed */
@@ -64,13 +64,15 @@
64 64
65#define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO) 65#define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO)
66 66
67#define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM)
68
67#define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ 69#define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \
68 FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \ 70 FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \
69 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \ 71 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \
70 FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \ 72 FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \
71 FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ 73 FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \
72 FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \ 74 FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \
73 FS_IN_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \ 75 FS_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \
74 FS_DN_MULTISHOT | FS_EVENT_ON_CHILD) 76 FS_DN_MULTISHOT | FS_EVENT_ON_CHILD)
75 77
76struct fsnotify_group; 78struct fsnotify_group;
@@ -129,6 +131,14 @@ struct fsnotify_group {
129 wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */ 131 wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */
130 unsigned int q_len; /* events on the queue */ 132 unsigned int q_len; /* events on the queue */
131 unsigned int max_events; /* maximum events allowed on the list */ 133 unsigned int max_events; /* maximum events allowed on the list */
134 /*
135 * Valid fsnotify group priorities. Events are send in order from highest
136 * priority to lowest priority. We default to the lowest priority.
137 */
138 #define FS_PRIO_0 0 /* normal notifiers, no permissions */
139 #define FS_PRIO_1 1 /* fanotify content based access control */
140 #define FS_PRIO_2 2 /* fanotify pre-content access */
141 unsigned int priority;
132 142
133 /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */ 143 /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */
134 spinlock_t mark_lock; /* protect marks_list */ 144 spinlock_t mark_lock; /* protect marks_list */
@@ -156,9 +166,11 @@ struct fsnotify_group {
156 struct mutex access_mutex; 166 struct mutex access_mutex;
157 struct list_head access_list; 167 struct list_head access_list;
158 wait_queue_head_t access_waitq; 168 wait_queue_head_t access_waitq;
159 bool bypass_perm; /* protected by access_mutex */ 169 atomic_t bypass_perm;
160#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */ 170#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */
161 int f_flags; 171 int f_flags;
172 unsigned int max_marks;
173 struct user_struct *user;
162 } fanotify_data; 174 } fanotify_data;
163#endif /* CONFIG_FANOTIFY */ 175#endif /* CONFIG_FANOTIFY */
164 }; 176 };
@@ -275,8 +287,8 @@ struct fsnotify_mark {
275 struct fsnotify_inode_mark i; 287 struct fsnotify_inode_mark i;
276 struct fsnotify_vfsmount_mark m; 288 struct fsnotify_vfsmount_mark m;
277 }; 289 };
278 __u32 ignored_mask; /* events types to ignore */
279 struct list_head free_g_list; /* tmp list used when freeing this mark */ 290 struct list_head free_g_list; /* tmp list used when freeing this mark */
291 __u32 ignored_mask; /* events types to ignore */
280#define FSNOTIFY_MARK_FLAG_INODE 0x01 292#define FSNOTIFY_MARK_FLAG_INODE 0x01
281#define FSNOTIFY_MARK_FLAG_VFSMOUNT 0x02 293#define FSNOTIFY_MARK_FLAG_VFSMOUNT 0x02
282#define FSNOTIFY_MARK_FLAG_OBJECT_PINNED 0x04 294#define FSNOTIFY_MARK_FLAG_OBJECT_PINNED 0x04
@@ -294,7 +306,7 @@ struct fsnotify_mark {
294/* main fsnotify call to send events */ 306/* main fsnotify call to send events */
295extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, 307extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
296 const unsigned char *name, u32 cookie); 308 const unsigned char *name, u32 cookie);
297extern void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask); 309extern int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask);
298extern void __fsnotify_inode_delete(struct inode *inode); 310extern void __fsnotify_inode_delete(struct inode *inode);
299extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); 311extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
300extern u32 fsnotify_get_cookie(void); 312extern u32 fsnotify_get_cookie(void);
@@ -317,9 +329,15 @@ static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
317{ 329{
318 struct dentry *parent; 330 struct dentry *parent;
319 331
320 assert_spin_locked(&dcache_lock);
321 assert_spin_locked(&dentry->d_lock); 332 assert_spin_locked(&dentry->d_lock);
322 333
334 /*
335 * Serialisation of setting PARENT_WATCHED on the dentries is provided
336 * by d_lock. If inotify_inode_watched changes after we have taken
337 * d_lock, the following __fsnotify_update_child_dentry_flags call will
338 * find our entry, so it will spin until we complete here, and update
339 * us with the new state.
340 */
323 parent = dentry->d_parent; 341 parent = dentry->d_parent;
324 if (parent->d_inode && fsnotify_inode_watches_children(parent->d_inode)) 342 if (parent->d_inode && fsnotify_inode_watches_children(parent->d_inode))
325 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED; 343 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
@@ -329,15 +347,12 @@ static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
329 347
330/* 348/*
331 * fsnotify_d_instantiate - instantiate a dentry for inode 349 * fsnotify_d_instantiate - instantiate a dentry for inode
332 * Called with dcache_lock held.
333 */ 350 */
334static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode *inode) 351static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode *inode)
335{ 352{
336 if (!inode) 353 if (!inode)
337 return; 354 return;
338 355
339 assert_spin_locked(&dcache_lock);
340
341 spin_lock(&dentry->d_lock); 356 spin_lock(&dentry->d_lock);
342 __fsnotify_update_dcache_flags(dentry); 357 __fsnotify_update_dcache_flags(dentry);
343 spin_unlock(&dentry->d_lock); 358 spin_unlock(&dentry->d_lock);
@@ -423,8 +438,10 @@ static inline int fsnotify(struct inode *to_tell, __u32 mask, void *data, int da
423 return 0; 438 return 0;
424} 439}
425 440
426static inline void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) 441static inline int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
427{} 442{
443 return 0;
444}
428 445
429static inline void __fsnotify_inode_delete(struct inode *inode) 446static inline void __fsnotify_inode_delete(struct inode *inode)
430{} 447{}
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index dcd6a7c3a435..9d88e1cb5dbb 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -29,9 +29,22 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
29 29
30typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip); 30typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
31 31
32struct ftrace_hash;
33
34enum {
35 FTRACE_OPS_FL_ENABLED = 1 << 0,
36 FTRACE_OPS_FL_GLOBAL = 1 << 1,
37 FTRACE_OPS_FL_DYNAMIC = 1 << 2,
38};
39
32struct ftrace_ops { 40struct ftrace_ops {
33 ftrace_func_t func; 41 ftrace_func_t func;
34 struct ftrace_ops *next; 42 struct ftrace_ops *next;
43 unsigned long flags;
44#ifdef CONFIG_DYNAMIC_FTRACE
45 struct ftrace_hash *notrace_hash;
46 struct ftrace_hash *filter_hash;
47#endif
35}; 48};
36 49
37extern int function_trace_stop; 50extern int function_trace_stop;
@@ -146,14 +159,13 @@ extern void unregister_ftrace_function_probe_all(char *glob);
146extern int ftrace_text_reserved(void *start, void *end); 159extern int ftrace_text_reserved(void *start, void *end);
147 160
148enum { 161enum {
149 FTRACE_FL_FREE = (1 << 0), 162 FTRACE_FL_ENABLED = (1 << 30),
150 FTRACE_FL_FAILED = (1 << 1), 163 FTRACE_FL_FREE = (1 << 31),
151 FTRACE_FL_FILTER = (1 << 2),
152 FTRACE_FL_ENABLED = (1 << 3),
153 FTRACE_FL_NOTRACE = (1 << 4),
154 FTRACE_FL_CONVERTED = (1 << 5),
155}; 164};
156 165
166#define FTRACE_FL_MASK (0x3UL << 30)
167#define FTRACE_REF_MAX ((1 << 30) - 1)
168
157struct dyn_ftrace { 169struct dyn_ftrace {
158 union { 170 union {
159 unsigned long ip; /* address of mcount call-site */ 171 unsigned long ip; /* address of mcount call-site */
@@ -167,7 +179,12 @@ struct dyn_ftrace {
167}; 179};
168 180
169int ftrace_force_update(void); 181int ftrace_force_update(void);
170void ftrace_set_filter(unsigned char *buf, int len, int reset); 182void ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
183 int len, int reset);
184void ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
185 int len, int reset);
186void ftrace_set_global_filter(unsigned char *buf, int len, int reset);
187void ftrace_set_global_notrace(unsigned char *buf, int len, int reset);
171 188
172int register_ftrace_command(struct ftrace_func_command *cmd); 189int register_ftrace_command(struct ftrace_func_command *cmd);
173int unregister_ftrace_command(struct ftrace_func_command *cmd); 190int unregister_ftrace_command(struct ftrace_func_command *cmd);
@@ -428,6 +445,7 @@ extern void unregister_ftrace_graph(void);
428 445
429extern void ftrace_graph_init_task(struct task_struct *t); 446extern void ftrace_graph_init_task(struct task_struct *t);
430extern void ftrace_graph_exit_task(struct task_struct *t); 447extern void ftrace_graph_exit_task(struct task_struct *t);
448extern void ftrace_graph_init_idle_task(struct task_struct *t, int cpu);
431 449
432static inline int task_curr_ret_stack(struct task_struct *t) 450static inline int task_curr_ret_stack(struct task_struct *t)
433{ 451{
@@ -451,6 +469,7 @@ static inline void unpause_graph_tracing(void)
451 469
452static inline void ftrace_graph_init_task(struct task_struct *t) { } 470static inline void ftrace_graph_init_task(struct task_struct *t) { }
453static inline void ftrace_graph_exit_task(struct task_struct *t) { } 471static inline void ftrace_graph_exit_task(struct task_struct *t) { }
472static inline void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) { }
454 473
455static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc, 474static inline int register_ftrace_graph(trace_func_graph_ret_t retfunc,
456 trace_func_graph_ent_t entryfunc) 475 trace_func_graph_ent_t entryfunc)
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 02b8b24f8f51..59d3ef100eb9 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -16,6 +16,11 @@ struct trace_print_flags {
16 const char *name; 16 const char *name;
17}; 17};
18 18
19struct trace_print_flags_u64 {
20 unsigned long long mask;
21 const char *name;
22};
23
19const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim, 24const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
20 unsigned long flags, 25 unsigned long flags,
21 const struct trace_print_flags *flag_array); 26 const struct trace_print_flags *flag_array);
@@ -23,6 +28,13 @@ const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
23const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val, 28const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
24 const struct trace_print_flags *symbol_array); 29 const struct trace_print_flags *symbol_array);
25 30
31#if BITS_PER_LONG == 32
32const char *ftrace_print_symbols_seq_u64(struct trace_seq *p,
33 unsigned long long val,
34 const struct trace_print_flags_u64
35 *symbol_array);
36#endif
37
26const char *ftrace_print_hex_seq(struct trace_seq *p, 38const char *ftrace_print_hex_seq(struct trace_seq *p,
27 const unsigned char *buf, int len); 39 const unsigned char *buf, int len);
28 40
@@ -37,7 +49,7 @@ struct trace_entry {
37 unsigned char flags; 49 unsigned char flags;
38 unsigned char preempt_count; 50 unsigned char preempt_count;
39 int pid; 51 int pid;
40 int lock_depth; 52 int padding;
41}; 53};
42 54
43#define FTRACE_MAX_EVENT \ 55#define FTRACE_MAX_EVENT \
@@ -154,12 +166,14 @@ enum {
154 TRACE_EVENT_FL_ENABLED_BIT, 166 TRACE_EVENT_FL_ENABLED_BIT,
155 TRACE_EVENT_FL_FILTERED_BIT, 167 TRACE_EVENT_FL_FILTERED_BIT,
156 TRACE_EVENT_FL_RECORDED_CMD_BIT, 168 TRACE_EVENT_FL_RECORDED_CMD_BIT,
169 TRACE_EVENT_FL_CAP_ANY_BIT,
157}; 170};
158 171
159enum { 172enum {
160 TRACE_EVENT_FL_ENABLED = (1 << TRACE_EVENT_FL_ENABLED_BIT), 173 TRACE_EVENT_FL_ENABLED = (1 << TRACE_EVENT_FL_ENABLED_BIT),
161 TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT), 174 TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
162 TRACE_EVENT_FL_RECORDED_CMD = (1 << TRACE_EVENT_FL_RECORDED_CMD_BIT), 175 TRACE_EVENT_FL_RECORDED_CMD = (1 << TRACE_EVENT_FL_RECORDED_CMD_BIT),
176 TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT),
163}; 177};
164 178
165struct ftrace_event_call { 179struct ftrace_event_call {
@@ -191,14 +205,21 @@ struct ftrace_event_call {
191 unsigned int flags; 205 unsigned int flags;
192 206
193#ifdef CONFIG_PERF_EVENTS 207#ifdef CONFIG_PERF_EVENTS
194 int perf_refcount; 208 int perf_refcount;
195 struct hlist_head *perf_events; 209 struct hlist_head __percpu *perf_events;
196#endif 210#endif
197}; 211};
198 212
213#define __TRACE_EVENT_FLAGS(name, value) \
214 static int __init trace_init_flags_##name(void) \
215 { \
216 event_##name.flags = value; \
217 return 0; \
218 } \
219 early_initcall(trace_init_flags_##name);
220
199#define PERF_MAX_TRACE_SIZE 2048 221#define PERF_MAX_TRACE_SIZE 2048
200 222
201#define MAX_FILTER_PRED 32
202#define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */ 223#define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */
203 224
204extern void destroy_preds(struct ftrace_event_call *call); 225extern void destroy_preds(struct ftrace_event_call *call);
@@ -215,6 +236,10 @@ enum {
215 FILTER_PTR_STRING, 236 FILTER_PTR_STRING,
216}; 237};
217 238
239#define EVENT_STORAGE_SIZE 128
240extern struct mutex event_storage_mutex;
241extern char event_storage[EVENT_STORAGE_SIZE];
242
218extern int trace_event_raw_init(struct ftrace_event_call *call); 243extern int trace_event_raw_init(struct ftrace_event_call *call);
219extern int trace_define_field(struct ftrace_event_call *call, const char *type, 244extern int trace_define_field(struct ftrace_event_call *call, const char *type,
220 const char *name, int offset, int size, 245 const char *name, int offset, int size,
@@ -252,8 +277,8 @@ DECLARE_PER_CPU(struct pt_regs, perf_trace_regs);
252 277
253extern int perf_trace_init(struct perf_event *event); 278extern int perf_trace_init(struct perf_event *event);
254extern void perf_trace_destroy(struct perf_event *event); 279extern void perf_trace_destroy(struct perf_event *event);
255extern int perf_trace_enable(struct perf_event *event); 280extern int perf_trace_add(struct perf_event *event, int flags);
256extern void perf_trace_disable(struct perf_event *event); 281extern void perf_trace_del(struct perf_event *event, int flags);
257extern int ftrace_profile_set_filter(struct perf_event *event, int event_id, 282extern int ftrace_profile_set_filter(struct perf_event *event, int event_id,
258 char *filter_str); 283 char *filter_str);
259extern void ftrace_profile_free_filter(struct perf_event *event); 284extern void ftrace_profile_free_filter(struct perf_event *event);
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index c3c578e09833..d464de53db43 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -41,6 +41,12 @@
41 * 7.15 41 * 7.15
42 * - add store notify 42 * - add store notify
43 * - add retrieve notify 43 * - add retrieve notify
44 *
45 * 7.16
46 * - add BATCH_FORGET request
47 * - FUSE_IOCTL_UNRESTRICTED shall now return with array of 'struct
48 * fuse_ioctl_iovec' instead of ambiguous 'struct iovec'
49 * - add FUSE_IOCTL_32BIT flag
44 */ 50 */
45 51
46#ifndef _LINUX_FUSE_H 52#ifndef _LINUX_FUSE_H
@@ -72,7 +78,7 @@
72#define FUSE_KERNEL_VERSION 7 78#define FUSE_KERNEL_VERSION 7
73 79
74/** Minor version number of this interface */ 80/** Minor version number of this interface */
75#define FUSE_KERNEL_MINOR_VERSION 15 81#define FUSE_KERNEL_MINOR_VERSION 16
76 82
77/** The node ID of the root inode */ 83/** The node ID of the root inode */
78#define FUSE_ROOT_ID 1 84#define FUSE_ROOT_ID 1
@@ -200,12 +206,14 @@ struct fuse_file_lock {
200 * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine 206 * FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
201 * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed 207 * FUSE_IOCTL_UNRESTRICTED: not restricted to well-formed ioctls, retry allowed
202 * FUSE_IOCTL_RETRY: retry with new iovecs 208 * FUSE_IOCTL_RETRY: retry with new iovecs
209 * FUSE_IOCTL_32BIT: 32bit ioctl
203 * 210 *
204 * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs 211 * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
205 */ 212 */
206#define FUSE_IOCTL_COMPAT (1 << 0) 213#define FUSE_IOCTL_COMPAT (1 << 0)
207#define FUSE_IOCTL_UNRESTRICTED (1 << 1) 214#define FUSE_IOCTL_UNRESTRICTED (1 << 1)
208#define FUSE_IOCTL_RETRY (1 << 2) 215#define FUSE_IOCTL_RETRY (1 << 2)
216#define FUSE_IOCTL_32BIT (1 << 3)
209 217
210#define FUSE_IOCTL_MAX_IOV 256 218#define FUSE_IOCTL_MAX_IOV 256
211 219
@@ -256,6 +264,7 @@ enum fuse_opcode {
256 FUSE_IOCTL = 39, 264 FUSE_IOCTL = 39,
257 FUSE_POLL = 40, 265 FUSE_POLL = 40,
258 FUSE_NOTIFY_REPLY = 41, 266 FUSE_NOTIFY_REPLY = 41,
267 FUSE_BATCH_FORGET = 42,
259 268
260 /* CUSE specific operations */ 269 /* CUSE specific operations */
261 CUSE_INIT = 4096, 270 CUSE_INIT = 4096,
@@ -290,6 +299,16 @@ struct fuse_forget_in {
290 __u64 nlookup; 299 __u64 nlookup;
291}; 300};
292 301
302struct fuse_forget_one {
303 __u64 nodeid;
304 __u64 nlookup;
305};
306
307struct fuse_batch_forget_in {
308 __u32 count;
309 __u32 dummy;
310};
311
293struct fuse_getattr_in { 312struct fuse_getattr_in {
294 __u32 getattr_flags; 313 __u32 getattr_flags;
295 __u32 dummy; 314 __u32 dummy;
@@ -510,6 +529,11 @@ struct fuse_ioctl_in {
510 __u32 out_size; 529 __u32 out_size;
511}; 530};
512 531
532struct fuse_ioctl_iovec {
533 __u64 base;
534 __u64 len;
535};
536
513struct fuse_ioctl_out { 537struct fuse_ioctl_out {
514 __s32 result; 538 __s32 result;
515 __u32 flags; 539 __u32 flags;
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
index 361d1cc288d0..b65a6f472775 100644
--- a/include/linux/gameport.h
+++ b/include/linux/gameport.h
@@ -53,9 +53,7 @@ struct gameport {
53#define to_gameport_port(d) container_of(d, struct gameport, dev) 53#define to_gameport_port(d) container_of(d, struct gameport, dev)
54 54
55struct gameport_driver { 55struct gameport_driver {
56 56 const char *description;
57 void *private;
58 char *description;
59 57
60 int (*connect)(struct gameport *, struct gameport_driver *drv); 58 int (*connect)(struct gameport *, struct gameport_driver *drv);
61 int (*reconnect)(struct gameport *); 59 int (*reconnect)(struct gameport *);
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index 9869ef3674ac..5bbebda78b02 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -9,6 +9,8 @@
9 */ 9 */
10 10
11 11
12#ifndef __GENALLOC_H__
13#define __GENALLOC_H__
12/* 14/*
13 * General purpose special memory pool descriptor. 15 * General purpose special memory pool descriptor.
14 */ 16 */
@@ -24,13 +26,34 @@ struct gen_pool {
24struct gen_pool_chunk { 26struct gen_pool_chunk {
25 spinlock_t lock; 27 spinlock_t lock;
26 struct list_head next_chunk; /* next chunk in pool */ 28 struct list_head next_chunk; /* next chunk in pool */
29 phys_addr_t phys_addr; /* physical starting address of memory chunk */
27 unsigned long start_addr; /* starting address of memory chunk */ 30 unsigned long start_addr; /* starting address of memory chunk */
28 unsigned long end_addr; /* ending address of memory chunk */ 31 unsigned long end_addr; /* ending address of memory chunk */
29 unsigned long bits[0]; /* bitmap for allocating memory chunk */ 32 unsigned long bits[0]; /* bitmap for allocating memory chunk */
30}; 33};
31 34
32extern struct gen_pool *gen_pool_create(int, int); 35extern struct gen_pool *gen_pool_create(int, int);
33extern int gen_pool_add(struct gen_pool *, unsigned long, size_t, int); 36extern phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long);
37extern int gen_pool_add_virt(struct gen_pool *, unsigned long, phys_addr_t,
38 size_t, int);
39/**
40 * gen_pool_add - add a new chunk of special memory to the pool
41 * @pool: pool to add new memory chunk to
42 * @addr: starting address of memory chunk to add to pool
43 * @size: size in bytes of the memory chunk to add to pool
44 * @nid: node id of the node the chunk structure and bitmap should be
45 * allocated on, or -1
46 *
47 * Add a new chunk of special memory to the specified pool.
48 *
49 * Returns 0 on success or a -ve errno on failure.
50 */
51static inline int gen_pool_add(struct gen_pool *pool, unsigned long addr,
52 size_t size, int nid)
53{
54 return gen_pool_add_virt(pool, addr, -1, size, nid);
55}
34extern void gen_pool_destroy(struct gen_pool *); 56extern void gen_pool_destroy(struct gen_pool *);
35extern unsigned long gen_pool_alloc(struct gen_pool *, size_t); 57extern unsigned long gen_pool_alloc(struct gen_pool *, size_t);
36extern void gen_pool_free(struct gen_pool *, unsigned long, size_t); 58extern void gen_pool_free(struct gen_pool *, unsigned long, size_t);
59#endif /* __GENALLOC_H__ */
diff --git a/include/linux/generic_acl.h b/include/linux/generic_acl.h
index 574bea4013b6..0437e377b555 100644
--- a/include/linux/generic_acl.h
+++ b/include/linux/generic_acl.h
@@ -10,6 +10,6 @@ extern const struct xattr_handler generic_acl_default_handler;
10 10
11int generic_acl_init(struct inode *, struct inode *); 11int generic_acl_init(struct inode *, struct inode *);
12int generic_acl_chmod(struct inode *); 12int generic_acl_chmod(struct inode *);
13int generic_check_acl(struct inode *inode, int mask); 13int generic_check_acl(struct inode *inode, int mask, unsigned int flags);
14 14
15#endif /* LINUX_GENERIC_ACL_H */ 15#endif /* LINUX_GENERIC_ACL_H */
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 5f2f4c4d8fb0..300d7582006e 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -12,6 +12,7 @@
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/kdev_t.h> 13#include <linux/kdev_t.h>
14#include <linux/rcupdate.h> 14#include <linux/rcupdate.h>
15#include <linux/slab.h>
15 16
16#ifdef CONFIG_BLOCK 17#ifdef CONFIG_BLOCK
17 18
@@ -86,7 +87,15 @@ struct disk_stats {
86 unsigned long io_ticks; 87 unsigned long io_ticks;
87 unsigned long time_in_queue; 88 unsigned long time_in_queue;
88}; 89};
89 90
91#define PARTITION_META_INFO_VOLNAMELTH 64
92#define PARTITION_META_INFO_UUIDLTH 16
93
94struct partition_meta_info {
95 u8 uuid[PARTITION_META_INFO_UUIDLTH]; /* always big endian */
96 u8 volname[PARTITION_META_INFO_VOLNAMELTH];
97};
98
90struct hd_struct { 99struct hd_struct {
91 sector_t start_sect; 100 sector_t start_sect;
92 sector_t nr_sects; 101 sector_t nr_sects;
@@ -95,16 +104,18 @@ struct hd_struct {
95 struct device __dev; 104 struct device __dev;
96 struct kobject *holder_dir; 105 struct kobject *holder_dir;
97 int policy, partno; 106 int policy, partno;
107 struct partition_meta_info *info;
98#ifdef CONFIG_FAIL_MAKE_REQUEST 108#ifdef CONFIG_FAIL_MAKE_REQUEST
99 int make_it_fail; 109 int make_it_fail;
100#endif 110#endif
101 unsigned long stamp; 111 unsigned long stamp;
102 int in_flight[2]; 112 atomic_t in_flight[2];
103#ifdef CONFIG_SMP 113#ifdef CONFIG_SMP
104 struct disk_stats __percpu *dkstats; 114 struct disk_stats __percpu *dkstats;
105#else 115#else
106 struct disk_stats dkstats; 116 struct disk_stats dkstats;
107#endif 117#endif
118 atomic_t ref;
108 struct rcu_head rcu_head; 119 struct rcu_head rcu_head;
109}; 120};
110 121
@@ -116,6 +127,12 @@ struct hd_struct {
116#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 127#define GENHD_FL_SUPPRESS_PARTITION_INFO 32
117#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ 128#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */
118#define GENHD_FL_NATIVE_CAPACITY 128 129#define GENHD_FL_NATIVE_CAPACITY 128
130#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256
131
132enum {
133 DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */
134 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
135};
119 136
120#define BLK_SCSI_MAX_CMDS (256) 137#define BLK_SCSI_MAX_CMDS (256)
121#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) 138#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
@@ -129,10 +146,12 @@ struct blk_scsi_cmd_filter {
129struct disk_part_tbl { 146struct disk_part_tbl {
130 struct rcu_head rcu_head; 147 struct rcu_head rcu_head;
131 int len; 148 int len;
132 struct hd_struct *last_lookup; 149 struct hd_struct __rcu *last_lookup;
133 struct hd_struct *part[]; 150 struct hd_struct __rcu *part[];
134}; 151};
135 152
153struct disk_events;
154
136struct gendisk { 155struct gendisk {
137 /* major, first_minor and minors are input parameters only, 156 /* major, first_minor and minors are input parameters only,
138 * don't use directly. Use disk_devt() and disk_max_parts(). 157 * don't use directly. Use disk_devt() and disk_max_parts().
@@ -144,12 +163,16 @@ struct gendisk {
144 163
145 char disk_name[DISK_NAME_LEN]; /* name of major driver */ 164 char disk_name[DISK_NAME_LEN]; /* name of major driver */
146 char *(*devnode)(struct gendisk *gd, mode_t *mode); 165 char *(*devnode)(struct gendisk *gd, mode_t *mode);
166
167 unsigned int events; /* supported events */
168 unsigned int async_events; /* async events, subset of all */
169
147 /* Array of pointers to partitions indexed by partno. 170 /* Array of pointers to partitions indexed by partno.
148 * Protected with matching bdev lock but stat and other 171 * Protected with matching bdev lock but stat and other
149 * non-critical accesses use RCU. Always access through 172 * non-critical accesses use RCU. Always access through
150 * helpers. 173 * helpers.
151 */ 174 */
152 struct disk_part_tbl *part_tbl; 175 struct disk_part_tbl __rcu *part_tbl;
153 struct hd_struct part0; 176 struct hd_struct part0;
154 177
155 const struct block_device_operations *fops; 178 const struct block_device_operations *fops;
@@ -161,9 +184,8 @@ struct gendisk {
161 struct kobject *slave_dir; 184 struct kobject *slave_dir;
162 185
163 struct timer_rand_state *random; 186 struct timer_rand_state *random;
164
165 atomic_t sync_io; /* RAID */ 187 atomic_t sync_io; /* RAID */
166 struct work_struct async_notify; 188 struct disk_events *ev;
167#ifdef CONFIG_BLK_DEV_INTEGRITY 189#ifdef CONFIG_BLK_DEV_INTEGRITY
168 struct blk_integrity *integrity; 190 struct blk_integrity *integrity;
169#endif 191#endif
@@ -181,6 +203,30 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part)
181 return NULL; 203 return NULL;
182} 204}
183 205
206static inline void part_pack_uuid(const u8 *uuid_str, u8 *to)
207{
208 int i;
209 for (i = 0; i < 16; ++i) {
210 *to++ = (hex_to_bin(*uuid_str) << 4) |
211 (hex_to_bin(*(uuid_str + 1)));
212 uuid_str += 2;
213 switch (i) {
214 case 3:
215 case 5:
216 case 7:
217 case 9:
218 uuid_str++;
219 continue;
220 }
221 }
222}
223
224static inline char *part_unpack_uuid(const u8 *uuid, char *out)
225{
226 sprintf(out, "%pU", uuid);
227 return out;
228}
229
184static inline int disk_max_parts(struct gendisk *disk) 230static inline int disk_max_parts(struct gendisk *disk)
185{ 231{
186 if (disk->flags & GENHD_FL_EXT_DEVT) 232 if (disk->flags & GENHD_FL_EXT_DEVT)
@@ -325,21 +371,34 @@ static inline void free_part_stats(struct hd_struct *part)
325 371
326static inline void part_inc_in_flight(struct hd_struct *part, int rw) 372static inline void part_inc_in_flight(struct hd_struct *part, int rw)
327{ 373{
328 part->in_flight[rw]++; 374 atomic_inc(&part->in_flight[rw]);
329 if (part->partno) 375 if (part->partno)
330 part_to_disk(part)->part0.in_flight[rw]++; 376 atomic_inc(&part_to_disk(part)->part0.in_flight[rw]);
331} 377}
332 378
333static inline void part_dec_in_flight(struct hd_struct *part, int rw) 379static inline void part_dec_in_flight(struct hd_struct *part, int rw)
334{ 380{
335 part->in_flight[rw]--; 381 atomic_dec(&part->in_flight[rw]);
336 if (part->partno) 382 if (part->partno)
337 part_to_disk(part)->part0.in_flight[rw]--; 383 atomic_dec(&part_to_disk(part)->part0.in_flight[rw]);
338} 384}
339 385
340static inline int part_in_flight(struct hd_struct *part) 386static inline int part_in_flight(struct hd_struct *part)
341{ 387{
342 return part->in_flight[0] + part->in_flight[1]; 388 return atomic_read(&part->in_flight[0]) + atomic_read(&part->in_flight[1]);
389}
390
391static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk)
392{
393 if (disk)
394 return kzalloc_node(sizeof(struct partition_meta_info),
395 GFP_KERNEL, disk->node_id);
396 return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL);
397}
398
399static inline void free_part_info(struct hd_struct *part)
400{
401 kfree(part->info);
343} 402}
344 403
345/* block/blk-core.c */ 404/* block/blk-core.c */
@@ -348,7 +407,6 @@ extern void part_round_stats(int cpu, struct hd_struct *part);
348/* block/genhd.c */ 407/* block/genhd.c */
349extern void add_disk(struct gendisk *disk); 408extern void add_disk(struct gendisk *disk);
350extern void del_gendisk(struct gendisk *gp); 409extern void del_gendisk(struct gendisk *gp);
351extern void unlink_gendisk(struct gendisk *gp);
352extern struct gendisk *get_gendisk(dev_t dev, int *partno); 410extern struct gendisk *get_gendisk(dev_t dev, int *partno);
353extern struct block_device *bdget_disk(struct gendisk *disk, int partno); 411extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
354 412
@@ -360,6 +418,11 @@ static inline int get_disk_ro(struct gendisk *disk)
360 return disk->part0.policy; 418 return disk->part0.policy;
361} 419}
362 420
421extern void disk_block_events(struct gendisk *disk);
422extern void disk_unblock_events(struct gendisk *disk);
423extern void disk_check_events(struct gendisk *disk);
424extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
425
363/* drivers/char/random.c */ 426/* drivers/char/random.c */
364extern void add_disk_randomness(struct gendisk *disk); 427extern void add_disk_randomness(struct gendisk *disk);
365extern void rand_initialize_disk(struct gendisk *disk); 428extern void rand_initialize_disk(struct gendisk *disk);
@@ -533,7 +596,10 @@ extern int disk_expand_part_tbl(struct gendisk *disk, int target);
533extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 596extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
534extern struct hd_struct * __must_check add_partition(struct gendisk *disk, 597extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
535 int partno, sector_t start, 598 int partno, sector_t start,
536 sector_t len, int flags); 599 sector_t len, int flags,
600 struct partition_meta_info
601 *info);
602extern void __delete_partition(struct hd_struct *);
537extern void delete_partition(struct gendisk *, int); 603extern void delete_partition(struct gendisk *, int);
538extern void printk_all_partitions(void); 604extern void printk_all_partitions(void);
539 605
@@ -562,6 +628,29 @@ extern ssize_t part_fail_store(struct device *dev,
562 const char *buf, size_t count); 628 const char *buf, size_t count);
563#endif /* CONFIG_FAIL_MAKE_REQUEST */ 629#endif /* CONFIG_FAIL_MAKE_REQUEST */
564 630
631static inline void hd_ref_init(struct hd_struct *part)
632{
633 atomic_set(&part->ref, 1);
634 smp_mb();
635}
636
637static inline void hd_struct_get(struct hd_struct *part)
638{
639 atomic_inc(&part->ref);
640 smp_mb__after_atomic_inc();
641}
642
643static inline int hd_struct_try_get(struct hd_struct *part)
644{
645 return atomic_inc_not_zero(&part->ref);
646}
647
648static inline void hd_struct_put(struct hd_struct *part)
649{
650 if (atomic_dec_and_test(&part->ref))
651 __delete_partition(part);
652}
653
565#else /* CONFIG_BLOCK */ 654#else /* CONFIG_BLOCK */
566 655
567static inline void printk_all_partitions(void) { } 656static inline void printk_all_partitions(void) { }
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 975609cb8548..cb4089254f01 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -9,6 +9,34 @@
9 9
10struct vm_area_struct; 10struct vm_area_struct;
11 11
12/* Plain integer GFP bitmasks. Do not use this directly. */
13#define ___GFP_DMA 0x01u
14#define ___GFP_HIGHMEM 0x02u
15#define ___GFP_DMA32 0x04u
16#define ___GFP_MOVABLE 0x08u
17#define ___GFP_WAIT 0x10u
18#define ___GFP_HIGH 0x20u
19#define ___GFP_IO 0x40u
20#define ___GFP_FS 0x80u
21#define ___GFP_COLD 0x100u
22#define ___GFP_NOWARN 0x200u
23#define ___GFP_REPEAT 0x400u
24#define ___GFP_NOFAIL 0x800u
25#define ___GFP_NORETRY 0x1000u
26#define ___GFP_COMP 0x4000u
27#define ___GFP_ZERO 0x8000u
28#define ___GFP_NOMEMALLOC 0x10000u
29#define ___GFP_HARDWALL 0x20000u
30#define ___GFP_THISNODE 0x40000u
31#define ___GFP_RECLAIMABLE 0x80000u
32#ifdef CONFIG_KMEMCHECK
33#define ___GFP_NOTRACK 0x200000u
34#else
35#define ___GFP_NOTRACK 0
36#endif
37#define ___GFP_NO_KSWAPD 0x400000u
38#define ___GFP_OTHER_NODE 0x800000u
39
12/* 40/*
13 * GFP bitmasks.. 41 * GFP bitmasks..
14 * 42 *
@@ -18,10 +46,10 @@ struct vm_area_struct;
18 * without the underscores and use them consistently. The definitions here may 46 * without the underscores and use them consistently. The definitions here may
19 * be used in bit comparisons. 47 * be used in bit comparisons.
20 */ 48 */
21#define __GFP_DMA ((__force gfp_t)0x01u) 49#define __GFP_DMA ((__force gfp_t)___GFP_DMA)
22#define __GFP_HIGHMEM ((__force gfp_t)0x02u) 50#define __GFP_HIGHMEM ((__force gfp_t)___GFP_HIGHMEM)
23#define __GFP_DMA32 ((__force gfp_t)0x04u) 51#define __GFP_DMA32 ((__force gfp_t)___GFP_DMA32)
24#define __GFP_MOVABLE ((__force gfp_t)0x08u) /* Page is movable */ 52#define __GFP_MOVABLE ((__force gfp_t)___GFP_MOVABLE) /* Page is movable */
25#define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE) 53#define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)
26/* 54/*
27 * Action modifiers - doesn't change the zoning 55 * Action modifiers - doesn't change the zoning
@@ -38,27 +66,25 @@ struct vm_area_struct;
38 * __GFP_MOVABLE: Flag that this page will be movable by the page migration 66 * __GFP_MOVABLE: Flag that this page will be movable by the page migration
39 * mechanism or reclaimed 67 * mechanism or reclaimed
40 */ 68 */
41#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */ 69#define __GFP_WAIT ((__force gfp_t)___GFP_WAIT) /* Can wait and reschedule? */
42#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */ 70#define __GFP_HIGH ((__force gfp_t)___GFP_HIGH) /* Should access emergency pools? */
43#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */ 71#define __GFP_IO ((__force gfp_t)___GFP_IO) /* Can start physical IO? */
44#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ 72#define __GFP_FS ((__force gfp_t)___GFP_FS) /* Can call down to low-level FS? */
45#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ 73#define __GFP_COLD ((__force gfp_t)___GFP_COLD) /* Cache-cold page required */
46#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ 74#define __GFP_NOWARN ((__force gfp_t)___GFP_NOWARN) /* Suppress page allocation failure warning */
47#define __GFP_REPEAT ((__force gfp_t)0x400u) /* See above */ 75#define __GFP_REPEAT ((__force gfp_t)___GFP_REPEAT) /* See above */
48#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* See above */ 76#define __GFP_NOFAIL ((__force gfp_t)___GFP_NOFAIL) /* See above */
49#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* See above */ 77#define __GFP_NORETRY ((__force gfp_t)___GFP_NORETRY) /* See above */
50#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ 78#define __GFP_COMP ((__force gfp_t)___GFP_COMP) /* Add compound page metadata */
51#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ 79#define __GFP_ZERO ((__force gfp_t)___GFP_ZERO) /* Return zeroed page on success */
52#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ 80#define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) /* Don't use emergency reserves */
53#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */ 81#define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) /* Enforce hardwall cpuset memory allocs */
54#define __GFP_THISNODE ((__force gfp_t)0x40000u)/* No fallback, no policies */ 82#define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)/* No fallback, no policies */
55#define __GFP_RECLAIMABLE ((__force gfp_t)0x80000u) /* Page is reclaimable */ 83#define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */
56 84#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */
57#ifdef CONFIG_KMEMCHECK 85
58#define __GFP_NOTRACK ((__force gfp_t)0x200000u) /* Don't track with kmemcheck */ 86#define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD)
59#else 87#define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
60#define __GFP_NOTRACK ((__force gfp_t)0)
61#endif
62 88
63/* 89/*
64 * This may seem redundant, but it's a way of annotating false positives vs. 90 * This may seem redundant, but it's a way of annotating false positives vs.
@@ -66,7 +92,7 @@ struct vm_area_struct;
66 */ 92 */
67#define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK) 93#define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68 94
69#define __GFP_BITS_SHIFT 22 /* Room for 22 __GFP_FOO bits */ 95#define __GFP_BITS_SHIFT 23 /* Room for 23 __GFP_FOO bits */
70#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) 96#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
71 97
72/* This equals 0, but use constants in case they ever change */ 98/* This equals 0, but use constants in case they ever change */
@@ -85,6 +111,9 @@ struct vm_area_struct;
85 __GFP_HARDWALL | __GFP_HIGHMEM | \ 111 __GFP_HARDWALL | __GFP_HIGHMEM | \
86 __GFP_MOVABLE) 112 __GFP_MOVABLE)
87#define GFP_IOFS (__GFP_IO | __GFP_FS) 113#define GFP_IOFS (__GFP_IO | __GFP_FS)
114#define GFP_TRANSHUGE (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
115 __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \
116 __GFP_NO_KSWAPD)
88 117
89#ifdef CONFIG_NUMA 118#ifdef CONFIG_NUMA
90#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY) 119#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
@@ -186,14 +215,14 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags)
186#endif 215#endif
187 216
188#define GFP_ZONE_TABLE ( \ 217#define GFP_ZONE_TABLE ( \
189 (ZONE_NORMAL << 0 * ZONES_SHIFT) \ 218 (ZONE_NORMAL << 0 * ZONES_SHIFT) \
190 | (OPT_ZONE_DMA << __GFP_DMA * ZONES_SHIFT) \ 219 | (OPT_ZONE_DMA << ___GFP_DMA * ZONES_SHIFT) \
191 | (OPT_ZONE_HIGHMEM << __GFP_HIGHMEM * ZONES_SHIFT) \ 220 | (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * ZONES_SHIFT) \
192 | (OPT_ZONE_DMA32 << __GFP_DMA32 * ZONES_SHIFT) \ 221 | (OPT_ZONE_DMA32 << ___GFP_DMA32 * ZONES_SHIFT) \
193 | (ZONE_NORMAL << __GFP_MOVABLE * ZONES_SHIFT) \ 222 | (ZONE_NORMAL << ___GFP_MOVABLE * ZONES_SHIFT) \
194 | (OPT_ZONE_DMA << (__GFP_MOVABLE | __GFP_DMA) * ZONES_SHIFT) \ 223 | (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * ZONES_SHIFT) \
195 | (ZONE_MOVABLE << (__GFP_MOVABLE | __GFP_HIGHMEM) * ZONES_SHIFT)\ 224 | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * ZONES_SHIFT) \
196 | (OPT_ZONE_DMA32 << (__GFP_MOVABLE | __GFP_DMA32) * ZONES_SHIFT)\ 225 | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * ZONES_SHIFT) \
197) 226)
198 227
199/* 228/*
@@ -203,31 +232,24 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags)
203 * allowed. 232 * allowed.
204 */ 233 */
205#define GFP_ZONE_BAD ( \ 234#define GFP_ZONE_BAD ( \
206 1 << (__GFP_DMA | __GFP_HIGHMEM) \ 235 1 << (___GFP_DMA | ___GFP_HIGHMEM) \
207 | 1 << (__GFP_DMA | __GFP_DMA32) \ 236 | 1 << (___GFP_DMA | ___GFP_DMA32) \
208 | 1 << (__GFP_DMA32 | __GFP_HIGHMEM) \ 237 | 1 << (___GFP_DMA32 | ___GFP_HIGHMEM) \
209 | 1 << (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM) \ 238 | 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM) \
210 | 1 << (__GFP_MOVABLE | __GFP_HIGHMEM | __GFP_DMA) \ 239 | 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA) \
211 | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA) \ 240 | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA) \
212 | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_HIGHMEM) \ 241 | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM) \
213 | 1 << (__GFP_MOVABLE | __GFP_DMA32 | __GFP_DMA | __GFP_HIGHMEM)\ 242 | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \
214) 243)
215 244
216static inline enum zone_type gfp_zone(gfp_t flags) 245static inline enum zone_type gfp_zone(gfp_t flags)
217{ 246{
218 enum zone_type z; 247 enum zone_type z;
219 int bit = flags & GFP_ZONEMASK; 248 int bit = (__force int) (flags & GFP_ZONEMASK);
220 249
221 z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) & 250 z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) &
222 ((1 << ZONES_SHIFT) - 1); 251 ((1 << ZONES_SHIFT) - 1);
223 252 VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
224 if (__builtin_constant_p(bit))
225 MAYBE_BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
226 else {
227#ifdef CONFIG_DEBUG_VM
228 BUG_ON((GFP_ZONE_BAD >> bit) & 1);
229#endif
230 }
231 return z; 253 return z;
232} 254}
233 255
@@ -304,20 +326,28 @@ alloc_pages(gfp_t gfp_mask, unsigned int order)
304{ 326{
305 return alloc_pages_current(gfp_mask, order); 327 return alloc_pages_current(gfp_mask, order);
306} 328}
307extern struct page *alloc_page_vma(gfp_t gfp_mask, 329extern struct page *alloc_pages_vma(gfp_t gfp_mask, int order,
308 struct vm_area_struct *vma, unsigned long addr); 330 struct vm_area_struct *vma, unsigned long addr,
331 int node);
309#else 332#else
310#define alloc_pages(gfp_mask, order) \ 333#define alloc_pages(gfp_mask, order) \
311 alloc_pages_node(numa_node_id(), gfp_mask, order) 334 alloc_pages_node(numa_node_id(), gfp_mask, order)
312#define alloc_page_vma(gfp_mask, vma, addr) alloc_pages(gfp_mask, 0) 335#define alloc_pages_vma(gfp_mask, order, vma, addr, node) \
336 alloc_pages(gfp_mask, order)
313#endif 337#endif
314#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) 338#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
339#define alloc_page_vma(gfp_mask, vma, addr) \
340 alloc_pages_vma(gfp_mask, 0, vma, addr, numa_node_id())
341#define alloc_page_vma_node(gfp_mask, vma, addr, node) \
342 alloc_pages_vma(gfp_mask, 0, vma, addr, node)
315 343
316extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); 344extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order);
317extern unsigned long get_zeroed_page(gfp_t gfp_mask); 345extern unsigned long get_zeroed_page(gfp_t gfp_mask);
318 346
319void *alloc_pages_exact(size_t size, gfp_t gfp_mask); 347void *alloc_pages_exact(size_t size, gfp_t gfp_mask);
320void free_pages_exact(void *virt, size_t size); 348void free_pages_exact(void *virt, size_t size);
349/* This is different from alloc_pages_exact_node !!! */
350void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask);
321 351
322#define __get_free_page(gfp_mask) \ 352#define __get_free_page(gfp_mask) \
323 __get_free_pages((gfp_mask), 0) 353 __get_free_pages((gfp_mask), 0)
@@ -339,7 +369,7 @@ void drain_local_pages(void *dummy);
339 369
340extern gfp_t gfp_allowed_mask; 370extern gfp_t gfp_allowed_mask;
341 371
342extern void set_gfp_allowed_mask(gfp_t mask); 372extern void pm_restrict_gfp_mask(void);
343extern gfp_t clear_gfp_allowed_mask(gfp_t mask); 373extern void pm_restore_gfp_mask(void);
344 374
345#endif /* __LINUX_GFP_H */ 375#endif /* __LINUX_GFP_H */
diff --git a/include/linux/gpio-fan.h b/include/linux/gpio-fan.h
new file mode 100644
index 000000000000..096659169215
--- /dev/null
+++ b/include/linux/gpio-fan.h
@@ -0,0 +1,36 @@
1/*
2 * include/linux/gpio-fan.h
3 *
4 * Platform data structure for GPIO fan driver
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#ifndef __LINUX_GPIO_FAN_H
12#define __LINUX_GPIO_FAN_H
13
14struct gpio_fan_alarm {
15 unsigned gpio;
16 unsigned active_low;
17};
18
19struct gpio_fan_speed {
20 int rpm;
21 int ctrl_val;
22};
23
24struct gpio_fan_platform_data {
25 int num_ctrl;
26 unsigned *ctrl; /* fan control GPIOs. */
27 struct gpio_fan_alarm *alarm; /* fan alarm GPIO. */
28 /*
29 * Speed conversion array: rpm from/to GPIO bit field.
30 * This array _must_ be sorted in ascending rpm order.
31 */
32 int num_speed;
33 struct gpio_fan_speed *speed;
34};
35
36#endif /* __LINUX_GPIO_FAN_H */
diff --git a/include/linux/gpio-i2cmux.h b/include/linux/gpio-i2cmux.h
new file mode 100644
index 000000000000..4a333bb0bd0d
--- /dev/null
+++ b/include/linux/gpio-i2cmux.h
@@ -0,0 +1,38 @@
1/*
2 * gpio-i2cmux interface to platform code
3 *
4 * Peter Korsgaard <peter.korsgaard@barco.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _LINUX_GPIO_I2CMUX_H
12#define _LINUX_GPIO_I2CMUX_H
13
14/* MUX has no specific idle mode */
15#define GPIO_I2CMUX_NO_IDLE ((unsigned)-1)
16
17/**
18 * struct gpio_i2cmux_platform_data - Platform-dependent data for gpio-i2cmux
19 * @parent: Parent I2C bus adapter number
20 * @base_nr: Base I2C bus number to number adapters from or zero for dynamic
21 * @values: Array of bitmasks of GPIO settings (low/high) for each
22 * position
23 * @n_values: Number of multiplexer positions (busses to instantiate)
24 * @gpios: Array of GPIO numbers used to control MUX
25 * @n_gpios: Number of GPIOs used to control MUX
26 * @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used
27 */
28struct gpio_i2cmux_platform_data {
29 int parent;
30 int base_nr;
31 const unsigned *values;
32 int n_values;
33 const unsigned *gpios;
34 int n_gpios;
35 unsigned idle;
36};
37
38#endif /* _LINUX_GPIO_I2CMUX_H */
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index e41f7dd1ae67..17b5a0d80e42 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -3,6 +3,17 @@
3 3
4/* see Documentation/gpio.txt */ 4/* see Documentation/gpio.txt */
5 5
6/* make these flag values available regardless of GPIO kconfig options */
7#define GPIOF_DIR_OUT (0 << 0)
8#define GPIOF_DIR_IN (1 << 0)
9
10#define GPIOF_INIT_LOW (0 << 1)
11#define GPIOF_INIT_HIGH (1 << 1)
12
13#define GPIOF_IN (GPIOF_DIR_IN)
14#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
15#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
16
6#ifdef CONFIG_GENERIC_GPIO 17#ifdef CONFIG_GENERIC_GPIO
7#include <asm/gpio.h> 18#include <asm/gpio.h>
8 19
@@ -13,6 +24,7 @@
13#include <linux/errno.h> 24#include <linux/errno.h>
14 25
15struct device; 26struct device;
27struct gpio;
16struct gpio_chip; 28struct gpio_chip;
17 29
18/* 30/*
@@ -24,9 +36,9 @@ struct gpio_chip;
24 * warning when something is wrongly called. 36 * warning when something is wrongly called.
25 */ 37 */
26 38
27static inline int gpio_is_valid(int number) 39static inline bool gpio_is_valid(int number)
28{ 40{
29 return 0; 41 return false;
30} 42}
31 43
32static inline int gpio_request(unsigned gpio, const char *label) 44static inline int gpio_request(unsigned gpio, const char *label)
@@ -34,6 +46,17 @@ static inline int gpio_request(unsigned gpio, const char *label)
34 return -ENOSYS; 46 return -ENOSYS;
35} 47}
36 48
49static inline int gpio_request_one(unsigned gpio,
50 unsigned long flags, const char *label)
51{
52 return -ENOSYS;
53}
54
55static inline int gpio_request_array(const struct gpio *array, size_t num)
56{
57 return -ENOSYS;
58}
59
37static inline void gpio_free(unsigned gpio) 60static inline void gpio_free(unsigned gpio)
38{ 61{
39 might_sleep(); 62 might_sleep();
@@ -42,6 +65,14 @@ static inline void gpio_free(unsigned gpio)
42 WARN_ON(1); 65 WARN_ON(1);
43} 66}
44 67
68static inline void gpio_free_array(const struct gpio *array, size_t num)
69{
70 might_sleep();
71
72 /* GPIO can never have been requested */
73 WARN_ON(1);
74}
75
45static inline int gpio_direction_input(unsigned gpio) 76static inline int gpio_direction_input(unsigned gpio)
46{ 77{
47 return -ENOSYS; 78 return -ENOSYS;
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index ce73a30113b4..b5ca4b2c08ec 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -3,22 +3,26 @@
3 3
4struct gpio_keys_button { 4struct gpio_keys_button {
5 /* Configuration parameters */ 5 /* Configuration parameters */
6 int code; /* input event code (KEY_*, SW_*) */ 6 unsigned int code; /* input event code (KEY_*, SW_*) */
7 int gpio; 7 int gpio;
8 int active_low; 8 int active_low;
9 char *desc; 9 const char *desc;
10 int type; /* input event type (EV_KEY, EV_SW) */ 10 unsigned int type; /* input event type (EV_KEY, EV_SW, EV_ABS) */
11 int wakeup; /* configure the button as a wake-up source */ 11 int wakeup; /* configure the button as a wake-up source */
12 int debounce_interval; /* debounce ticks interval in msecs */ 12 int debounce_interval; /* debounce ticks interval in msecs */
13 bool can_disable; 13 bool can_disable;
14 int value; /* axis value for EV_ABS */
14}; 15};
15 16
16struct gpio_keys_platform_data { 17struct gpio_keys_platform_data {
17 struct gpio_keys_button *buttons; 18 struct gpio_keys_button *buttons;
18 int nbuttons; 19 int nbuttons;
20 unsigned int poll_interval; /* polling interval in msecs -
21 for polling driver only */
19 unsigned int rep:1; /* enable input subsystem auto repeat */ 22 unsigned int rep:1; /* enable input subsystem auto repeat */
20 int (*enable)(struct device *dev); 23 int (*enable)(struct device *dev);
21 void (*disable)(struct device *dev); 24 void (*disable)(struct device *dev);
25 const char *name; /* input device name */
22}; 26};
23 27
24#endif 28#endif
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index d5b387669dab..ba362171e8ae 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -2,13 +2,9 @@
2#define LINUX_HARDIRQ_H 2#define LINUX_HARDIRQ_H
3 3
4#include <linux/preempt.h> 4#include <linux/preempt.h>
5#ifdef CONFIG_PREEMPT
6#include <linux/smp_lock.h>
7#endif
8#include <linux/lockdep.h> 5#include <linux/lockdep.h>
9#include <linux/ftrace_irq.h> 6#include <linux/ftrace_irq.h>
10#include <asm/hardirq.h> 7#include <asm/hardirq.h>
11#include <asm/system.h>
12 8
13/* 9/*
14 * We put the hardirq and softirq counter into the preemption 10 * We put the hardirq and softirq counter into the preemption
@@ -64,6 +60,8 @@
64#define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT) 60#define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT)
65#define NMI_OFFSET (1UL << NMI_SHIFT) 61#define NMI_OFFSET (1UL << NMI_SHIFT)
66 62
63#define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET)
64
67#ifndef PREEMPT_ACTIVE 65#ifndef PREEMPT_ACTIVE
68#define PREEMPT_ACTIVE_BITS 1 66#define PREEMPT_ACTIVE_BITS 1
69#define PREEMPT_ACTIVE_SHIFT (NMI_SHIFT + NMI_BITS) 67#define PREEMPT_ACTIVE_SHIFT (NMI_SHIFT + NMI_BITS)
@@ -82,10 +80,13 @@
82/* 80/*
83 * Are we doing bottom half or hardware interrupt processing? 81 * Are we doing bottom half or hardware interrupt processing?
84 * Are we in a softirq context? Interrupt context? 82 * Are we in a softirq context? Interrupt context?
83 * in_softirq - Are we currently processing softirq or have bh disabled?
84 * in_serving_softirq - Are we currently processing softirq?
85 */ 85 */
86#define in_irq() (hardirq_count()) 86#define in_irq() (hardirq_count())
87#define in_softirq() (softirq_count()) 87#define in_softirq() (softirq_count())
88#define in_interrupt() (irq_count()) 88#define in_interrupt() (irq_count())
89#define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET)
89 90
90/* 91/*
91 * Are we in NMI context? 92 * Are we in NMI context?
@@ -93,10 +94,8 @@
93#define in_nmi() (preempt_count() & NMI_MASK) 94#define in_nmi() (preempt_count() & NMI_MASK)
94 95
95#if defined(CONFIG_PREEMPT) 96#if defined(CONFIG_PREEMPT)
96# define PREEMPT_INATOMIC_BASE kernel_locked()
97# define PREEMPT_CHECK_OFFSET 1 97# define PREEMPT_CHECK_OFFSET 1
98#else 98#else
99# define PREEMPT_INATOMIC_BASE 0
100# define PREEMPT_CHECK_OFFSET 0 99# define PREEMPT_CHECK_OFFSET 0
101#endif 100#endif
102 101
@@ -107,7 +106,7 @@
107 * used in the general case to determine whether sleeping is possible. 106 * used in the general case to determine whether sleeping is possible.
108 * Do not use in_atomic() in driver code. 107 * Do not use in_atomic() in driver code.
109 */ 108 */
110#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_INATOMIC_BASE) 109#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)
111 110
112/* 111/*
113 * Check whether we were atomic before we did preempt_disable(): 112 * Check whether we were atomic before we did preempt_disable():
@@ -132,14 +131,16 @@ extern void synchronize_irq(unsigned int irq);
132 131
133struct task_struct; 132struct task_struct;
134 133
135#ifndef CONFIG_VIRT_CPU_ACCOUNTING 134#if !defined(CONFIG_VIRT_CPU_ACCOUNTING) && !defined(CONFIG_IRQ_TIME_ACCOUNTING)
136static inline void account_system_vtime(struct task_struct *tsk) 135static inline void account_system_vtime(struct task_struct *tsk)
137{ 136{
138} 137}
138#else
139extern void account_system_vtime(struct task_struct *tsk);
139#endif 140#endif
140 141
141#if defined(CONFIG_NO_HZ) 142#if defined(CONFIG_NO_HZ)
142#if defined(CONFIG_TINY_RCU) 143#if defined(CONFIG_TINY_RCU) || defined(CONFIG_TINY_PREEMPT_RCU)
143extern void rcu_enter_nohz(void); 144extern void rcu_enter_nohz(void);
144extern void rcu_exit_nohz(void); 145extern void rcu_exit_nohz(void);
145 146
diff --git a/include/linux/hid-roccat.h b/include/linux/hid-roccat.h
new file mode 100644
index 000000000000..24e1ca01f9a0
--- /dev/null
+++ b/include/linux/hid-roccat.h
@@ -0,0 +1,29 @@
1#ifndef __HID_ROCCAT_H
2#define __HID_ROCCAT_H
3
4/*
5 * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/hid.h>
16#include <linux/types.h>
17
18#define ROCCATIOCGREPSIZE _IOR('H', 0xf1, int)
19
20#ifdef __KERNEL__
21
22int roccat_connect(struct class *klass, struct hid_device *hid,
23 int report_size);
24void roccat_disconnect(int minor);
25int roccat_report_event(int minor, u8 const *data);
26
27#endif
28
29#endif
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 42a0f1d11365..42f7e2fb501f 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -316,6 +316,7 @@ struct hid_item {
316#define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 316#define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000
317#define HID_QUIRK_NO_INIT_REPORTS 0x20000000 317#define HID_QUIRK_NO_INIT_REPORTS 0x20000000
318#define HID_QUIRK_NO_IGNORE 0x40000000 318#define HID_QUIRK_NO_IGNORE 0x40000000
319#define HID_QUIRK_NO_INPUT_SYNC 0x80000000
319 320
320/* 321/*
321 * This is the global environment of the parser. This information is 322 * This is the global environment of the parser. This information is
@@ -401,7 +402,7 @@ struct hid_field {
401 __u16 dpad; /* dpad input code */ 402 __u16 dpad; /* dpad input code */
402}; 403};
403 404
404#define HID_MAX_FIELDS 64 405#define HID_MAX_FIELDS 128
405 406
406struct hid_report { 407struct hid_report {
407 struct list_head list; 408 struct list_head list;
@@ -503,6 +504,9 @@ struct hid_device { /* device report descriptor */
503 struct hid_usage *, __s32); 504 struct hid_usage *, __s32);
504 void (*hiddev_report_event) (struct hid_device *, struct hid_report *); 505 void (*hiddev_report_event) (struct hid_device *, struct hid_report *);
505 506
507 /* handler for raw input (Get_Report) data, used by hidraw */
508 int (*hid_get_raw_report) (struct hid_device *, unsigned char, __u8 *, size_t, unsigned char);
509
506 /* handler for raw output data, used by hidraw */ 510 /* handler for raw output data, used by hidraw */
507 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t, unsigned char); 511 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t, unsigned char);
508 512
@@ -592,6 +596,7 @@ struct hid_usage_id {
592 * @report_fixup: called before report descriptor parsing (NULL means nop) 596 * @report_fixup: called before report descriptor parsing (NULL means nop)
593 * @input_mapping: invoked on input registering before mapping an usage 597 * @input_mapping: invoked on input registering before mapping an usage
594 * @input_mapped: invoked on input registering after mapping an usage 598 * @input_mapped: invoked on input registering after mapping an usage
599 * @feature_mapping: invoked on feature registering
595 * @suspend: invoked on suspend (NULL means nop) 600 * @suspend: invoked on suspend (NULL means nop)
596 * @resume: invoked on resume if device was not reset (NULL means nop) 601 * @resume: invoked on resume if device was not reset (NULL means nop)
597 * @reset_resume: invoked on resume if device was reset (NULL means nop) 602 * @reset_resume: invoked on resume if device was reset (NULL means nop)
@@ -626,8 +631,8 @@ struct hid_driver {
626 int (*event)(struct hid_device *hdev, struct hid_field *field, 631 int (*event)(struct hid_device *hdev, struct hid_field *field,
627 struct hid_usage *usage, __s32 value); 632 struct hid_usage *usage, __s32 value);
628 633
629 void (*report_fixup)(struct hid_device *hdev, __u8 *buf, 634 __u8 *(*report_fixup)(struct hid_device *hdev, __u8 *buf,
630 unsigned int size); 635 unsigned int *size);
631 636
632 int (*input_mapping)(struct hid_device *hdev, 637 int (*input_mapping)(struct hid_device *hdev,
633 struct hid_input *hidinput, struct hid_field *field, 638 struct hid_input *hidinput, struct hid_field *field,
@@ -635,6 +640,9 @@ struct hid_driver {
635 int (*input_mapped)(struct hid_device *hdev, 640 int (*input_mapped)(struct hid_device *hdev,
636 struct hid_input *hidinput, struct hid_field *field, 641 struct hid_input *hidinput, struct hid_field *field,
637 struct hid_usage *usage, unsigned long **bit, int *max); 642 struct hid_usage *usage, unsigned long **bit, int *max);
643 void (*feature_mapping)(struct hid_device *hdev,
644 struct hid_field *field,
645 struct hid_usage *usage);
638#ifdef CONFIG_PM 646#ifdef CONFIG_PM
639 int (*suspend)(struct hid_device *hdev, pm_message_t message); 647 int (*suspend)(struct hid_device *hdev, pm_message_t message);
640 int (*resume)(struct hid_device *hdev); 648 int (*resume)(struct hid_device *hdev);
@@ -791,7 +799,7 @@ static inline int __must_check hid_parse(struct hid_device *hdev)
791 * 799 *
792 * Call this in probe function *after* hid_parse. This will setup HW buffers 800 * Call this in probe function *after* hid_parse. This will setup HW buffers
793 * and start the device (if not deffered to device open). hid_hw_stop must be 801 * and start the device (if not deffered to device open). hid_hw_stop must be
794 * called if this was successfull. 802 * called if this was successful.
795 */ 803 */
796static inline int __must_check hid_hw_start(struct hid_device *hdev, 804static inline int __must_check hid_hw_start(struct hid_device *hdev,
797 unsigned int connect_mask) 805 unsigned int connect_mask)
@@ -819,6 +827,49 @@ static inline void hid_hw_stop(struct hid_device *hdev)
819 hdev->ll_driver->stop(hdev); 827 hdev->ll_driver->stop(hdev);
820} 828}
821 829
830/**
831 * hid_hw_open - signal underlaying HW to start delivering events
832 *
833 * @hdev: hid device
834 *
835 * Tell underlying HW to start delivering events from the device.
836 * This function should be called sometime after successful call
837 * to hid_hiw_start().
838 */
839static inline int __must_check hid_hw_open(struct hid_device *hdev)
840{
841 return hdev->ll_driver->open(hdev);
842}
843
844/**
845 * hid_hw_close - signal underlaying HW to stop delivering events
846 *
847 * @hdev: hid device
848 *
849 * This function indicates that we are not interested in the events
850 * from this device anymore. Delivery of events may or may not stop,
851 * depending on the number of users still outstanding.
852 */
853static inline void hid_hw_close(struct hid_device *hdev)
854{
855 hdev->ll_driver->close(hdev);
856}
857
858/**
859 * hid_hw_power - requests underlying HW to go into given power mode
860 *
861 * @hdev: hid device
862 * @level: requested power level (one of %PM_HINT_* defines)
863 *
864 * This function requests underlying hardware to enter requested power
865 * mode.
866 */
867
868static inline int hid_hw_power(struct hid_device *hdev, int level)
869{
870 return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0;
871}
872
822void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, 873void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
823 int interrupt); 874 int interrupt);
824 875
@@ -837,12 +888,32 @@ int hid_pidff_init(struct hid_device *hid);
837#define hid_pidff_init NULL 888#define hid_pidff_init NULL
838#endif 889#endif
839 890
840#define dbg_hid(format, arg...) if (hid_debug) \ 891#define dbg_hid(format, arg...) \
841 printk(KERN_DEBUG "%s: " format ,\ 892do { \
842 __FILE__ , ## arg) 893 if (hid_debug) \
843#define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ 894 printk(KERN_DEBUG "%s: " format, __FILE__, ##arg); \
844 __FILE__ , ## arg) 895} while (0)
845#endif /* HID_FF */ 896
897#define hid_printk(level, hid, fmt, arg...) \
898 dev_printk(level, &(hid)->dev, fmt, ##arg)
899#define hid_emerg(hid, fmt, arg...) \
900 dev_emerg(&(hid)->dev, fmt, ##arg)
901#define hid_crit(hid, fmt, arg...) \
902 dev_crit(&(hid)->dev, fmt, ##arg)
903#define hid_alert(hid, fmt, arg...) \
904 dev_alert(&(hid)->dev, fmt, ##arg)
905#define hid_err(hid, fmt, arg...) \
906 dev_err(&(hid)->dev, fmt, ##arg)
907#define hid_notice(hid, fmt, arg...) \
908 dev_notice(&(hid)->dev, fmt, ##arg)
909#define hid_warn(hid, fmt, arg...) \
910 dev_warn(&(hid)->dev, fmt, ##arg)
911#define hid_info(hid, fmt, arg...) \
912 dev_info(&(hid)->dev, fmt, ##arg)
913#define hid_dbg(hid, fmt, arg...) \
914 dev_dbg(&(hid)->dev, fmt, ##arg)
915
916#endif /* __KERNEL__ */
846 917
847#endif 918#endif
848 919
diff --git a/include/linux/hiddev.h b/include/linux/hiddev.h
index bb6f58baf319..a3f481a3063b 100644
--- a/include/linux/hiddev.h
+++ b/include/linux/hiddev.h
@@ -226,8 +226,6 @@ void hiddev_disconnect(struct hid_device *);
226void hiddev_hid_event(struct hid_device *hid, struct hid_field *field, 226void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
227 struct hid_usage *usage, __s32 value); 227 struct hid_usage *usage, __s32 value);
228void hiddev_report_event(struct hid_device *hid, struct hid_report *report); 228void hiddev_report_event(struct hid_device *hid, struct hid_report *report);
229int __init hiddev_init(void);
230void hiddev_exit(void);
231#else 229#else
232static inline int hiddev_connect(struct hid_device *hid, 230static inline int hiddev_connect(struct hid_device *hid,
233 unsigned int force) 231 unsigned int force)
@@ -236,8 +234,6 @@ static inline void hiddev_disconnect(struct hid_device *hid) { }
236static inline void hiddev_hid_event(struct hid_device *hid, struct hid_field *field, 234static inline void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
237 struct hid_usage *usage, __s32 value) { } 235 struct hid_usage *usage, __s32 value) { }
238static inline void hiddev_report_event(struct hid_device *hid, struct hid_report *report) { } 236static inline void hiddev_report_event(struct hid_device *hid, struct hid_report *report) { }
239static inline int hiddev_init(void) { return 0; }
240static inline void hiddev_exit(void) { }
241#endif 237#endif
242 238
243#endif 239#endif
diff --git a/include/linux/hidraw.h b/include/linux/hidraw.h
index dd8d69269176..4b88e697c4e9 100644
--- a/include/linux/hidraw.h
+++ b/include/linux/hidraw.h
@@ -35,6 +35,9 @@ struct hidraw_devinfo {
35#define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo) 35#define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo)
36#define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len) 36#define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len)
37#define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len) 37#define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len)
38/* The first byte of SFEATURE and GFEATURE is the report number */
39#define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
40#define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
38 41
39#define HIDRAW_FIRST_MINOR 0 42#define HIDRAW_FIRST_MINOR 0
40#define HIDRAW_MAX_DEVICES 64 43#define HIDRAW_MAX_DEVICES 64
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index e3060ef85b6d..3a93f73a8acc 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -5,6 +5,7 @@
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/mm.h> 6#include <linux/mm.h>
7#include <linux/uaccess.h> 7#include <linux/uaccess.h>
8#include <linux/hardirq.h>
8 9
9#include <asm/cacheflush.h> 10#include <asm/cacheflush.h>
10 11
@@ -28,18 +29,6 @@ static inline void invalidate_kernel_vmap_range(void *vaddr, int size)
28 29
29#include <asm/kmap_types.h> 30#include <asm/kmap_types.h>
30 31
31#ifdef CONFIG_DEBUG_HIGHMEM
32
33void debug_kmap_atomic(enum km_type type);
34
35#else
36
37static inline void debug_kmap_atomic(enum km_type type)
38{
39}
40
41#endif
42
43#ifdef CONFIG_HIGHMEM 32#ifdef CONFIG_HIGHMEM
44#include <asm/highmem.h> 33#include <asm/highmem.h>
45 34
@@ -66,19 +55,19 @@ static inline void kunmap(struct page *page)
66{ 55{
67} 56}
68 57
69static inline void *kmap_atomic(struct page *page, enum km_type idx) 58static inline void *__kmap_atomic(struct page *page)
70{ 59{
71 pagefault_disable(); 60 pagefault_disable();
72 return page_address(page); 61 return page_address(page);
73} 62}
74#define kmap_atomic_prot(page, idx, prot) kmap_atomic(page, idx) 63#define kmap_atomic_prot(page, prot) __kmap_atomic(page)
75 64
76static inline void kunmap_atomic_notypecheck(void *addr, enum km_type idx) 65static inline void __kunmap_atomic(void *addr)
77{ 66{
78 pagefault_enable(); 67 pagefault_enable();
79} 68}
80 69
81#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx)) 70#define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
82#define kmap_atomic_to_page(ptr) virt_to_page(ptr) 71#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
83 72
84#define kmap_flush_unused() do {} while(0) 73#define kmap_flush_unused() do {} while(0)
@@ -86,12 +75,53 @@ static inline void kunmap_atomic_notypecheck(void *addr, enum km_type idx)
86 75
87#endif /* CONFIG_HIGHMEM */ 76#endif /* CONFIG_HIGHMEM */
88 77
89/* Prevent people trying to call kunmap_atomic() as if it were kunmap() */ 78#if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32)
90/* kunmap_atomic() should get the return value of kmap_atomic, not the page. */ 79
91#define kunmap_atomic(addr, idx) do { \ 80DECLARE_PER_CPU(int, __kmap_atomic_idx);
92 BUILD_BUG_ON(__same_type((addr), struct page *)); \ 81
93 kunmap_atomic_notypecheck((addr), (idx)); \ 82static inline int kmap_atomic_idx_push(void)
94 } while (0) 83{
84 int idx = __this_cpu_inc_return(__kmap_atomic_idx) - 1;
85
86#ifdef CONFIG_DEBUG_HIGHMEM
87 WARN_ON_ONCE(in_irq() && !irqs_disabled());
88 BUG_ON(idx > KM_TYPE_NR);
89#endif
90 return idx;
91}
92
93static inline int kmap_atomic_idx(void)
94{
95 return __this_cpu_read(__kmap_atomic_idx) - 1;
96}
97
98static inline void kmap_atomic_idx_pop(void)
99{
100#ifdef CONFIG_DEBUG_HIGHMEM
101 int idx = __this_cpu_dec_return(__kmap_atomic_idx);
102
103 BUG_ON(idx < 0);
104#else
105 __this_cpu_dec(__kmap_atomic_idx);
106#endif
107}
108
109#endif
110
111/*
112 * Make both: kmap_atomic(page, idx) and kmap_atomic(page) work.
113 */
114#define kmap_atomic(page, args...) __kmap_atomic(page)
115
116/*
117 * Prevent people trying to call kunmap_atomic() as if it were kunmap()
118 * kunmap_atomic() should get the return value of kmap_atomic, not the page.
119 */
120#define kunmap_atomic(addr, args...) \
121do { \
122 BUILD_BUG_ON(__same_type((addr), struct page *)); \
123 __kunmap_atomic(addr); \
124} while (0)
95 125
96/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */ 126/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
97#ifndef clear_user_highpage 127#ifndef clear_user_highpage
@@ -201,8 +231,8 @@ static inline void copy_user_highpage(struct page *to, struct page *from,
201 vfrom = kmap_atomic(from, KM_USER0); 231 vfrom = kmap_atomic(from, KM_USER0);
202 vto = kmap_atomic(to, KM_USER1); 232 vto = kmap_atomic(to, KM_USER1);
203 copy_user_page(vto, vfrom, vaddr, to); 233 copy_user_page(vto, vfrom, vaddr, to);
204 kunmap_atomic(vfrom, KM_USER0);
205 kunmap_atomic(vto, KM_USER1); 234 kunmap_atomic(vto, KM_USER1);
235 kunmap_atomic(vfrom, KM_USER0);
206} 236}
207 237
208#endif 238#endif
@@ -214,8 +244,8 @@ static inline void copy_highpage(struct page *to, struct page *from)
214 vfrom = kmap_atomic(from, KM_USER0); 244 vfrom = kmap_atomic(from, KM_USER0);
215 vto = kmap_atomic(to, KM_USER1); 245 vto = kmap_atomic(to, KM_USER1);
216 copy_page(vto, vfrom); 246 copy_page(vto, vfrom);
217 kunmap_atomic(vfrom, KM_USER0);
218 kunmap_atomic(vto, KM_USER1); 247 kunmap_atomic(vto, KM_USER1);
248 kunmap_atomic(vfrom, KM_USER0);
219} 249}
220 250
221#endif /* _LINUX_HIGHMEM_H */ 251#endif /* _LINUX_HIGHMEM_H */
diff --git a/include/linux/hp_sdc.h b/include/linux/hp_sdc.h
index 9db3d454887f..d392975d8887 100644
--- a/include/linux/hp_sdc.h
+++ b/include/linux/hp_sdc.h
@@ -101,7 +101,7 @@ int hp_sdc_dequeue_transaction(hp_sdc_transaction *this);
101#define HP_SDC_STATUS_REG 0x40 /* Data from an i8042 register */ 101#define HP_SDC_STATUS_REG 0x40 /* Data from an i8042 register */
102#define HP_SDC_STATUS_HILCMD 0x50 /* Command from HIL MLC */ 102#define HP_SDC_STATUS_HILCMD 0x50 /* Command from HIL MLC */
103#define HP_SDC_STATUS_HILDATA 0x60 /* Data from HIL MLC */ 103#define HP_SDC_STATUS_HILDATA 0x60 /* Data from HIL MLC */
104#define HP_SDC_STATUS_PUP 0x70 /* Sucessful power-up self test */ 104#define HP_SDC_STATUS_PUP 0x70 /* Successful power-up self test */
105#define HP_SDC_STATUS_KCOOKED 0x80 /* Key from cooked kbd */ 105#define HP_SDC_STATUS_KCOOKED 0x80 /* Key from cooked kbd */
106#define HP_SDC_STATUS_KRPG 0xc0 /* Key from Repeat Gen */ 106#define HP_SDC_STATUS_KRPG 0xc0 /* Key from Repeat Gen */
107#define HP_SDC_STATUS_KMOD_SUP 0x10 /* Shift key is up */ 107#define HP_SDC_STATUS_KMOD_SUP 0x10 /* Shift key is up */
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 76da541c1f66..d91bba539ca8 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -22,7 +22,7 @@
22#include <linux/wait.h> 22#include <linux/wait.h>
23#include <linux/percpu.h> 23#include <linux/percpu.h>
24#include <linux/timer.h> 24#include <linux/timer.h>
25 25#include <linux/timerqueue.h>
26 26
27struct hrtimer_clock_base; 27struct hrtimer_clock_base;
28struct hrtimer_cpu_base; 28struct hrtimer_cpu_base;
@@ -54,11 +54,13 @@ enum hrtimer_restart {
54 * 0x00 inactive 54 * 0x00 inactive
55 * 0x01 enqueued into rbtree 55 * 0x01 enqueued into rbtree
56 * 0x02 callback function running 56 * 0x02 callback function running
57 * 0x04 timer is migrated to another cpu
57 * 58 *
58 * Special cases: 59 * Special cases:
59 * 0x03 callback function running and enqueued 60 * 0x03 callback function running and enqueued
60 * (was requeued on another CPU) 61 * (was requeued on another CPU)
61 * 0x09 timer was migrated on CPU hotunplug 62 * 0x05 timer was migrated on CPU hotunplug
63 *
62 * The "callback function running and enqueued" status is only possible on 64 * The "callback function running and enqueued" status is only possible on
63 * SMP. It happens for example when a posix timer expired and the callback 65 * SMP. It happens for example when a posix timer expired and the callback
64 * queued a signal. Between dropping the lock which protects the posix timer 66 * queued a signal. Between dropping the lock which protects the posix timer
@@ -67,8 +69,11 @@ enum hrtimer_restart {
67 * as otherwise the timer could be removed before the softirq code finishes the 69 * as otherwise the timer could be removed before the softirq code finishes the
68 * the handling of the timer. 70 * the handling of the timer.
69 * 71 *
70 * The HRTIMER_STATE_ENQUEUED bit is always or'ed to the current state to 72 * The HRTIMER_STATE_ENQUEUED bit is always or'ed to the current state
71 * preserve the HRTIMER_STATE_CALLBACK bit in the above scenario. 73 * to preserve the HRTIMER_STATE_CALLBACK in the above scenario. This
74 * also affects HRTIMER_STATE_MIGRATE where the preservation is not
75 * necessary. HRTIMER_STATE_MIGRATE is cleared after the timer is
76 * enqueued on the new cpu.
72 * 77 *
73 * All state transitions are protected by cpu_base->lock. 78 * All state transitions are protected by cpu_base->lock.
74 */ 79 */
@@ -79,8 +84,8 @@ enum hrtimer_restart {
79 84
80/** 85/**
81 * struct hrtimer - the basic hrtimer structure 86 * struct hrtimer - the basic hrtimer structure
82 * @node: red black tree node for time ordered insertion 87 * @node: timerqueue node, which also manages node.expires,
83 * @_expires: the absolute expiry time in the hrtimers internal 88 * the absolute expiry time in the hrtimers internal
84 * representation. The time is related to the clock on 89 * representation. The time is related to the clock on
85 * which the timer is based. Is setup by adding 90 * which the timer is based. Is setup by adding
86 * slack to the _softexpires value. For non range timers 91 * slack to the _softexpires value. For non range timers
@@ -101,8 +106,7 @@ enum hrtimer_restart {
101 * The hrtimer structure must be initialized by hrtimer_init() 106 * The hrtimer structure must be initialized by hrtimer_init()
102 */ 107 */
103struct hrtimer { 108struct hrtimer {
104 struct rb_node node; 109 struct timerqueue_node node;
105 ktime_t _expires;
106 ktime_t _softexpires; 110 ktime_t _softexpires;
107 enum hrtimer_restart (*function)(struct hrtimer *); 111 enum hrtimer_restart (*function)(struct hrtimer *);
108 struct hrtimer_clock_base *base; 112 struct hrtimer_clock_base *base;
@@ -131,8 +135,8 @@ struct hrtimer_sleeper {
131 * @cpu_base: per cpu clock base 135 * @cpu_base: per cpu clock base
132 * @index: clock type index for per_cpu support when moving a 136 * @index: clock type index for per_cpu support when moving a
133 * timer to a base on another cpu. 137 * timer to a base on another cpu.
138 * @clockid: clock id for per_cpu support
134 * @active: red black tree root node for the active timers 139 * @active: red black tree root node for the active timers
135 * @first: pointer to the timer node which expires first
136 * @resolution: the resolution of the clock, in nanoseconds 140 * @resolution: the resolution of the clock, in nanoseconds
137 * @get_time: function to retrieve the current time of the clock 141 * @get_time: function to retrieve the current time of the clock
138 * @softirq_time: the time when running the hrtimer queue in the softirq 142 * @softirq_time: the time when running the hrtimer queue in the softirq
@@ -140,25 +144,27 @@ struct hrtimer_sleeper {
140 */ 144 */
141struct hrtimer_clock_base { 145struct hrtimer_clock_base {
142 struct hrtimer_cpu_base *cpu_base; 146 struct hrtimer_cpu_base *cpu_base;
143 clockid_t index; 147 int index;
144 struct rb_root active; 148 clockid_t clockid;
145 struct rb_node *first; 149 struct timerqueue_head active;
146 ktime_t resolution; 150 ktime_t resolution;
147 ktime_t (*get_time)(void); 151 ktime_t (*get_time)(void);
148 ktime_t softirq_time; 152 ktime_t softirq_time;
149#ifdef CONFIG_HIGH_RES_TIMERS
150 ktime_t offset; 153 ktime_t offset;
151#endif
152}; 154};
153 155
154#define HRTIMER_MAX_CLOCK_BASES 2 156enum hrtimer_base_type {
157 HRTIMER_BASE_MONOTONIC,
158 HRTIMER_BASE_REALTIME,
159 HRTIMER_BASE_BOOTTIME,
160 HRTIMER_MAX_CLOCK_BASES,
161};
155 162
156/* 163/*
157 * struct hrtimer_cpu_base - the per cpu clock bases 164 * struct hrtimer_cpu_base - the per cpu clock bases
158 * @lock: lock protecting the base and associated clock bases 165 * @lock: lock protecting the base and associated clock bases
159 * and timers 166 * and timers
160 * @clock_base: array of clock bases for this cpu 167 * @active_bases: Bitfield to mark bases with active timers
161 * @curr_timer: the timer which is executing a callback right now
162 * @expires_next: absolute time of the next event which was scheduled 168 * @expires_next: absolute time of the next event which was scheduled
163 * via clock_set_next_event() 169 * via clock_set_next_event()
164 * @hres_active: State of high resolution mode 170 * @hres_active: State of high resolution mode
@@ -167,11 +173,12 @@ struct hrtimer_clock_base {
167 * @nr_retries: Total number of hrtimer interrupt retries 173 * @nr_retries: Total number of hrtimer interrupt retries
168 * @nr_hangs: Total number of hrtimer interrupt hangs 174 * @nr_hangs: Total number of hrtimer interrupt hangs
169 * @max_hang_time: Maximum time spent in hrtimer_interrupt 175 * @max_hang_time: Maximum time spent in hrtimer_interrupt
176 * @clock_base: array of clock bases for this cpu
170 * @to_pull: LITMUS^RT list of timers to be pulled on this cpu 177 * @to_pull: LITMUS^RT list of timers to be pulled on this cpu
171 */ 178 */
172struct hrtimer_cpu_base { 179struct hrtimer_cpu_base {
173 raw_spinlock_t lock; 180 raw_spinlock_t lock;
174 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; 181 unsigned long active_bases;
175#ifdef CONFIG_HIGH_RES_TIMERS 182#ifdef CONFIG_HIGH_RES_TIMERS
176 ktime_t expires_next; 183 ktime_t expires_next;
177 int hres_active; 184 int hres_active;
@@ -181,6 +188,7 @@ struct hrtimer_cpu_base {
181 unsigned long nr_hangs; 188 unsigned long nr_hangs;
182 ktime_t max_hang_time; 189 ktime_t max_hang_time;
183#endif 190#endif
191 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
184 struct list_head to_pull; 192 struct list_head to_pull;
185}; 193};
186 194
@@ -209,43 +217,43 @@ struct hrtimer_start_on_info {
209 217
210static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) 218static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
211{ 219{
212 timer->_expires = time; 220 timer->node.expires = time;
213 timer->_softexpires = time; 221 timer->_softexpires = time;
214} 222}
215 223
216static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta) 224static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
217{ 225{
218 timer->_softexpires = time; 226 timer->_softexpires = time;
219 timer->_expires = ktime_add_safe(time, delta); 227 timer->node.expires = ktime_add_safe(time, delta);
220} 228}
221 229
222static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, unsigned long delta) 230static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, unsigned long delta)
223{ 231{
224 timer->_softexpires = time; 232 timer->_softexpires = time;
225 timer->_expires = ktime_add_safe(time, ns_to_ktime(delta)); 233 timer->node.expires = ktime_add_safe(time, ns_to_ktime(delta));
226} 234}
227 235
228static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64) 236static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
229{ 237{
230 timer->_expires.tv64 = tv64; 238 timer->node.expires.tv64 = tv64;
231 timer->_softexpires.tv64 = tv64; 239 timer->_softexpires.tv64 = tv64;
232} 240}
233 241
234static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time) 242static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
235{ 243{
236 timer->_expires = ktime_add_safe(timer->_expires, time); 244 timer->node.expires = ktime_add_safe(timer->node.expires, time);
237 timer->_softexpires = ktime_add_safe(timer->_softexpires, time); 245 timer->_softexpires = ktime_add_safe(timer->_softexpires, time);
238} 246}
239 247
240static inline void hrtimer_add_expires_ns(struct hrtimer *timer, u64 ns) 248static inline void hrtimer_add_expires_ns(struct hrtimer *timer, u64 ns)
241{ 249{
242 timer->_expires = ktime_add_ns(timer->_expires, ns); 250 timer->node.expires = ktime_add_ns(timer->node.expires, ns);
243 timer->_softexpires = ktime_add_ns(timer->_softexpires, ns); 251 timer->_softexpires = ktime_add_ns(timer->_softexpires, ns);
244} 252}
245 253
246static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer) 254static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
247{ 255{
248 return timer->_expires; 256 return timer->node.expires;
249} 257}
250 258
251static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer) 259static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
@@ -255,7 +263,7 @@ static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
255 263
256static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer) 264static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
257{ 265{
258 return timer->_expires.tv64; 266 return timer->node.expires.tv64;
259} 267}
260static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer) 268static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
261{ 269{
@@ -264,19 +272,17 @@ static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
264 272
265static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer) 273static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
266{ 274{
267 return ktime_to_ns(timer->_expires); 275 return ktime_to_ns(timer->node.expires);
268} 276}
269 277
270static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) 278static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
271{ 279{
272 return ktime_sub(timer->_expires, timer->base->get_time()); 280 return ktime_sub(timer->node.expires, timer->base->get_time());
273} 281}
274 282
275#ifdef CONFIG_HIGH_RES_TIMERS 283#ifdef CONFIG_HIGH_RES_TIMERS
276struct clock_event_device; 284struct clock_event_device;
277 285
278extern void clock_was_set(void);
279extern void hres_timers_resume(void);
280extern void hrtimer_interrupt(struct clock_event_device *dev); 286extern void hrtimer_interrupt(struct clock_event_device *dev);
281 287
282/* 288/*
@@ -310,16 +316,8 @@ extern void hrtimer_peek_ahead_timers(void);
310# define MONOTONIC_RES_NSEC LOW_RES_NSEC 316# define MONOTONIC_RES_NSEC LOW_RES_NSEC
311# define KTIME_MONOTONIC_RES KTIME_LOW_RES 317# define KTIME_MONOTONIC_RES KTIME_LOW_RES
312 318
313/*
314 * clock_was_set() is a NOP for non- high-resolution systems. The
315 * time-sorted order guarantees that a timer does not expire early and
316 * is expired in the next softirq when the clock was advanced.
317 */
318static inline void clock_was_set(void) { }
319static inline void hrtimer_peek_ahead_timers(void) { } 319static inline void hrtimer_peek_ahead_timers(void) { }
320 320
321static inline void hres_timers_resume(void) { }
322
323/* 321/*
324 * In non high resolution mode the time reference is taken from 322 * In non high resolution mode the time reference is taken from
325 * the base softirq time variable. 323 * the base softirq time variable.
@@ -335,9 +333,18 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
335} 333}
336#endif 334#endif
337 335
336extern void clock_was_set(void);
337#ifdef CONFIG_TIMERFD
338extern void timerfd_clock_was_set(void);
339#else
340static inline void timerfd_clock_was_set(void) { }
341#endif
342extern void hrtimers_resume(void);
343
338extern ktime_t ktime_get(void); 344extern ktime_t ktime_get(void);
339extern ktime_t ktime_get_real(void); 345extern ktime_t ktime_get_real(void);
340 346extern ktime_t ktime_get_boottime(void);
347extern ktime_t ktime_get_monotonic_offset(void);
341 348
342DECLARE_PER_CPU(struct tick_device, tick_cpu_device); 349DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
343 350
@@ -406,8 +413,9 @@ extern int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp);
406extern ktime_t hrtimer_get_next_event(void); 413extern ktime_t hrtimer_get_next_event(void);
407 414
408/* 415/*
409 * A timer is active, when it is enqueued into the rbtree or the callback 416 * A timer is active, when it is enqueued into the rbtree or the
410 * function is running. 417 * callback function is running or it's in the state of being migrated
418 * to another cpu.
411 */ 419 */
412static inline int hrtimer_active(const struct hrtimer *timer) 420static inline int hrtimer_active(const struct hrtimer *timer)
413{ 421{
diff --git a/include/linux/htirq.h b/include/linux/htirq.h
index c96ea46737d0..70a1dbbf2093 100644
--- a/include/linux/htirq.h
+++ b/include/linux/htirq.h
@@ -9,8 +9,9 @@ struct ht_irq_msg {
9/* Helper functions.. */ 9/* Helper functions.. */
10void fetch_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg); 10void fetch_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg);
11void write_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg); 11void write_ht_irq_msg(unsigned int irq, struct ht_irq_msg *msg);
12void mask_ht_irq(unsigned int irq); 12struct irq_data;
13void unmask_ht_irq(unsigned int irq); 13void mask_ht_irq(struct irq_data *data);
14void unmask_ht_irq(struct irq_data *data);
14 15
15/* The arch hook for getting things started */ 16/* The arch hook for getting things started */
16int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev); 17int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev);
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
new file mode 100644
index 000000000000..48c32ebf65a7
--- /dev/null
+++ b/include/linux/huge_mm.h
@@ -0,0 +1,176 @@
1#ifndef _LINUX_HUGE_MM_H
2#define _LINUX_HUGE_MM_H
3
4extern int do_huge_pmd_anonymous_page(struct mm_struct *mm,
5 struct vm_area_struct *vma,
6 unsigned long address, pmd_t *pmd,
7 unsigned int flags);
8extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
9 pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr,
10 struct vm_area_struct *vma);
11extern int do_huge_pmd_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
12 unsigned long address, pmd_t *pmd,
13 pmd_t orig_pmd);
14extern pgtable_t get_pmd_huge_pte(struct mm_struct *mm);
15extern struct page *follow_trans_huge_pmd(struct mm_struct *mm,
16 unsigned long addr,
17 pmd_t *pmd,
18 unsigned int flags);
19extern int zap_huge_pmd(struct mmu_gather *tlb,
20 struct vm_area_struct *vma,
21 pmd_t *pmd);
22extern int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
23 unsigned long addr, unsigned long end,
24 unsigned char *vec);
25extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
26 unsigned long addr, pgprot_t newprot);
27
28enum transparent_hugepage_flag {
29 TRANSPARENT_HUGEPAGE_FLAG,
30 TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG,
31 TRANSPARENT_HUGEPAGE_DEFRAG_FLAG,
32 TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG,
33 TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG,
34#ifdef CONFIG_DEBUG_VM
35 TRANSPARENT_HUGEPAGE_DEBUG_COW_FLAG,
36#endif
37};
38
39enum page_check_address_pmd_flag {
40 PAGE_CHECK_ADDRESS_PMD_FLAG,
41 PAGE_CHECK_ADDRESS_PMD_NOTSPLITTING_FLAG,
42 PAGE_CHECK_ADDRESS_PMD_SPLITTING_FLAG,
43};
44extern pmd_t *page_check_address_pmd(struct page *page,
45 struct mm_struct *mm,
46 unsigned long address,
47 enum page_check_address_pmd_flag flag);
48
49#ifdef CONFIG_TRANSPARENT_HUGEPAGE
50#define HPAGE_PMD_SHIFT HPAGE_SHIFT
51#define HPAGE_PMD_MASK HPAGE_MASK
52#define HPAGE_PMD_SIZE HPAGE_SIZE
53
54#define transparent_hugepage_enabled(__vma) \
55 ((transparent_hugepage_flags & \
56 (1<<TRANSPARENT_HUGEPAGE_FLAG) || \
57 (transparent_hugepage_flags & \
58 (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG) && \
59 ((__vma)->vm_flags & VM_HUGEPAGE))) && \
60 !((__vma)->vm_flags & VM_NOHUGEPAGE) && \
61 !is_vma_temporary_stack(__vma))
62#define transparent_hugepage_defrag(__vma) \
63 ((transparent_hugepage_flags & \
64 (1<<TRANSPARENT_HUGEPAGE_DEFRAG_FLAG)) || \
65 (transparent_hugepage_flags & \
66 (1<<TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG) && \
67 (__vma)->vm_flags & VM_HUGEPAGE))
68#ifdef CONFIG_DEBUG_VM
69#define transparent_hugepage_debug_cow() \
70 (transparent_hugepage_flags & \
71 (1<<TRANSPARENT_HUGEPAGE_DEBUG_COW_FLAG))
72#else /* CONFIG_DEBUG_VM */
73#define transparent_hugepage_debug_cow() 0
74#endif /* CONFIG_DEBUG_VM */
75
76extern unsigned long transparent_hugepage_flags;
77extern int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
78 pmd_t *dst_pmd, pmd_t *src_pmd,
79 struct vm_area_struct *vma,
80 unsigned long addr, unsigned long end);
81extern int handle_pte_fault(struct mm_struct *mm,
82 struct vm_area_struct *vma, unsigned long address,
83 pte_t *pte, pmd_t *pmd, unsigned int flags);
84extern int split_huge_page(struct page *page);
85extern void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd);
86#define split_huge_page_pmd(__mm, __pmd) \
87 do { \
88 pmd_t *____pmd = (__pmd); \
89 if (unlikely(pmd_trans_huge(*____pmd))) \
90 __split_huge_page_pmd(__mm, ____pmd); \
91 } while (0)
92#define wait_split_huge_page(__anon_vma, __pmd) \
93 do { \
94 pmd_t *____pmd = (__pmd); \
95 anon_vma_lock(__anon_vma); \
96 anon_vma_unlock(__anon_vma); \
97 BUG_ON(pmd_trans_splitting(*____pmd) || \
98 pmd_trans_huge(*____pmd)); \
99 } while (0)
100#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
101#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
102#if HPAGE_PMD_ORDER > MAX_ORDER
103#error "hugepages can't be allocated by the buddy allocator"
104#endif
105extern int hugepage_madvise(struct vm_area_struct *vma,
106 unsigned long *vm_flags, int advice);
107extern void __vma_adjust_trans_huge(struct vm_area_struct *vma,
108 unsigned long start,
109 unsigned long end,
110 long adjust_next);
111static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,
112 unsigned long start,
113 unsigned long end,
114 long adjust_next)
115{
116 if (!vma->anon_vma || vma->vm_ops)
117 return;
118 __vma_adjust_trans_huge(vma, start, end, adjust_next);
119}
120static inline int hpage_nr_pages(struct page *page)
121{
122 if (unlikely(PageTransHuge(page)))
123 return HPAGE_PMD_NR;
124 return 1;
125}
126static inline struct page *compound_trans_head(struct page *page)
127{
128 if (PageTail(page)) {
129 struct page *head;
130 head = page->first_page;
131 smp_rmb();
132 /*
133 * head may be a dangling pointer.
134 * __split_huge_page_refcount clears PageTail before
135 * overwriting first_page, so if PageTail is still
136 * there it means the head pointer isn't dangling.
137 */
138 if (PageTail(page))
139 return head;
140 }
141 return page;
142}
143#else /* CONFIG_TRANSPARENT_HUGEPAGE */
144#define HPAGE_PMD_SHIFT ({ BUG(); 0; })
145#define HPAGE_PMD_MASK ({ BUG(); 0; })
146#define HPAGE_PMD_SIZE ({ BUG(); 0; })
147
148#define hpage_nr_pages(x) 1
149
150#define transparent_hugepage_enabled(__vma) 0
151
152#define transparent_hugepage_flags 0UL
153static inline int split_huge_page(struct page *page)
154{
155 return 0;
156}
157#define split_huge_page_pmd(__mm, __pmd) \
158 do { } while (0)
159#define wait_split_huge_page(__anon_vma, __pmd) \
160 do { } while (0)
161#define compound_trans_head(page) compound_head(page)
162static inline int hugepage_madvise(struct vm_area_struct *vma,
163 unsigned long *vm_flags, int advice)
164{
165 BUG();
166 return 0;
167}
168static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,
169 unsigned long start,
170 unsigned long end,
171 long adjust_next)
172{
173}
174#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
175
176#endif /* _LINUX_HUGE_MM_H */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index f479700df61b..59225ef27d15 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -1,6 +1,7 @@
1#ifndef _LINUX_HUGETLB_H 1#ifndef _LINUX_HUGETLB_H
2#define _LINUX_HUGETLB_H 2#define _LINUX_HUGETLB_H
3 3
4#include <linux/mm_types.h>
4#include <linux/fs.h> 5#include <linux/fs.h>
5#include <linux/hugetlb_inline.h> 6#include <linux/hugetlb_inline.h>
6 7
@@ -41,9 +42,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
41 unsigned long address, unsigned int flags); 42 unsigned long address, unsigned int flags);
42int hugetlb_reserve_pages(struct inode *inode, long from, long to, 43int hugetlb_reserve_pages(struct inode *inode, long from, long to,
43 struct vm_area_struct *vma, 44 struct vm_area_struct *vma,
44 int acctflags); 45 vm_flags_t vm_flags);
45void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); 46void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
46void __isolate_hwpoisoned_huge_page(struct page *page); 47int dequeue_hwpoisoned_huge_page(struct page *page);
48void copy_huge_page(struct page *dst, struct page *src);
47 49
48extern unsigned long hugepages_treat_as_movable; 50extern unsigned long hugepages_treat_as_movable;
49extern const unsigned long hugetlb_zero, hugetlb_infinity; 51extern const unsigned long hugetlb_zero, hugetlb_infinity;
@@ -101,7 +103,10 @@ static inline void hugetlb_report_meminfo(struct seq_file *m)
101#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) 103#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
102#define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) 104#define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; })
103#define huge_pte_offset(mm, address) 0 105#define huge_pte_offset(mm, address) 0
104#define __isolate_hwpoisoned_huge_page(page) 0 106#define dequeue_hwpoisoned_huge_page(page) 0
107static inline void copy_huge_page(struct page *dst, struct page *src)
108{
109}
105 110
106#define hugetlb_change_protection(vma, address, end, newprot) 111#define hugetlb_change_protection(vma, address, end, newprot)
107 112
@@ -164,7 +169,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
164 169
165extern const struct file_operations hugetlbfs_file_operations; 170extern const struct file_operations hugetlbfs_file_operations;
166extern const struct vm_operations_struct hugetlb_vm_ops; 171extern const struct vm_operations_struct hugetlb_vm_ops;
167struct file *hugetlb_file_setup(const char *name, size_t size, int acct, 172struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
168 struct user_struct **user, int creat_flags); 173 struct user_struct **user, int creat_flags);
169int hugetlb_get_quota(struct address_space *mapping, long delta); 174int hugetlb_get_quota(struct address_space *mapping, long delta);
170void hugetlb_put_quota(struct address_space *mapping, long delta); 175void hugetlb_put_quota(struct address_space *mapping, long delta);
@@ -188,7 +193,7 @@ static inline void set_file_hugepages(struct file *file)
188#define is_file_hugepages(file) 0 193#define is_file_hugepages(file) 0
189#define set_file_hugepages(file) BUG() 194#define set_file_hugepages(file) BUG()
190static inline struct file *hugetlb_file_setup(const char *name, size_t size, 195static inline struct file *hugetlb_file_setup(const char *name, size_t size,
191 int acctflag, struct user_struct **user, int creat_flags) 196 vm_flags_t acctflag, struct user_struct **user, int creat_flags)
192{ 197{
193 return ERR_PTR(-ENOSYS); 198 return ERR_PTR(-ENOSYS);
194} 199}
@@ -228,6 +233,8 @@ struct huge_bootmem_page {
228 struct hstate *hstate; 233 struct hstate *hstate;
229}; 234};
230 235
236struct page *alloc_huge_page_node(struct hstate *h, int nid);
237
231/* arch callback */ 238/* arch callback */
232int __init alloc_bootmem_huge_page(struct hstate *h); 239int __init alloc_bootmem_huge_page(struct hstate *h);
233 240
@@ -301,8 +308,14 @@ static inline struct hstate *page_hstate(struct page *page)
301 return size_to_hstate(PAGE_SIZE << compound_order(page)); 308 return size_to_hstate(PAGE_SIZE << compound_order(page));
302} 309}
303 310
311static inline unsigned hstate_index_to_shift(unsigned index)
312{
313 return hstates[index].order + PAGE_SHIFT;
314}
315
304#else 316#else
305struct hstate {}; 317struct hstate {};
318#define alloc_huge_page_node(h, nid) NULL
306#define alloc_bootmem_huge_page(h) NULL 319#define alloc_bootmem_huge_page(h) NULL
307#define hstate_file(f) NULL 320#define hstate_file(f) NULL
308#define hstate_vma(v) NULL 321#define hstate_vma(v) NULL
@@ -317,6 +330,7 @@ static inline unsigned int pages_per_huge_page(struct hstate *h)
317{ 330{
318 return 1; 331 return 1;
319} 332}
333#define hstate_index_to_shift(index) 0
320#endif 334#endif
321 335
322#endif /* _LINUX_HUGETLB_H */ 336#endif /* _LINUX_HUGETLB_H */
diff --git a/include/linux/hugetlb_inline.h b/include/linux/hugetlb_inline.h
index 6931489a5c14..2bb681fbeb35 100644
--- a/include/linux/hugetlb_inline.h
+++ b/include/linux/hugetlb_inline.h
@@ -7,7 +7,7 @@
7 7
8static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) 8static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
9{ 9{
10 return vma->vm_flags & VM_HUGETLB; 10 return !!(vma->vm_flags & VM_HUGETLB);
11} 11}
12 12
13#else 13#else
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index a2d6ea49ec56..d1e55fed2c7d 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -33,6 +33,8 @@ enum bp_type_idx {
33 33
34#ifdef CONFIG_HAVE_HW_BREAKPOINT 34#ifdef CONFIG_HAVE_HW_BREAKPOINT
35 35
36extern int __init init_hw_breakpoint(void);
37
36static inline void hw_breakpoint_init(struct perf_event_attr *attr) 38static inline void hw_breakpoint_init(struct perf_event_attr *attr)
37{ 39{
38 memset(attr, 0, sizeof(*attr)); 40 memset(attr, 0, sizeof(*attr));
@@ -108,6 +110,8 @@ static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
108 110
109#else /* !CONFIG_HAVE_HW_BREAKPOINT */ 111#else /* !CONFIG_HAVE_HW_BREAKPOINT */
110 112
113static inline int __init init_hw_breakpoint(void) { return 0; }
114
111static inline struct perf_event * 115static inline struct perf_event *
112register_user_hw_breakpoint(struct perf_event_attr *attr, 116register_user_hw_breakpoint(struct perf_event_attr *attr,
113 perf_overflow_handler_t triggered, 117 perf_overflow_handler_t triggered,
diff --git a/include/linux/hwspinlock.h b/include/linux/hwspinlock.h
new file mode 100644
index 000000000000..8390efc457eb
--- /dev/null
+++ b/include/linux/hwspinlock.h
@@ -0,0 +1,292 @@
1/*
2 * Hardware spinlock public header
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Contact: Ohad Ben-Cohen <ohad@wizery.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#ifndef __LINUX_HWSPINLOCK_H
19#define __LINUX_HWSPINLOCK_H
20
21#include <linux/err.h>
22#include <linux/sched.h>
23
24/* hwspinlock mode argument */
25#define HWLOCK_IRQSTATE 0x01 /* Disable interrupts, save state */
26#define HWLOCK_IRQ 0x02 /* Disable interrupts, don't save state */
27
28struct hwspinlock;
29
30#if defined(CONFIG_HWSPINLOCK) || defined(CONFIG_HWSPINLOCK_MODULE)
31
32int hwspin_lock_register(struct hwspinlock *lock);
33struct hwspinlock *hwspin_lock_unregister(unsigned int id);
34struct hwspinlock *hwspin_lock_request(void);
35struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
36int hwspin_lock_free(struct hwspinlock *hwlock);
37int hwspin_lock_get_id(struct hwspinlock *hwlock);
38int __hwspin_lock_timeout(struct hwspinlock *, unsigned int, int,
39 unsigned long *);
40int __hwspin_trylock(struct hwspinlock *, int, unsigned long *);
41void __hwspin_unlock(struct hwspinlock *, int, unsigned long *);
42
43#else /* !CONFIG_HWSPINLOCK */
44
45/*
46 * We don't want these functions to fail if CONFIG_HWSPINLOCK is not
47 * enabled. We prefer to silently succeed in this case, and let the
48 * code path get compiled away. This way, if CONFIG_HWSPINLOCK is not
49 * required on a given setup, users will still work.
50 *
51 * The only exception is hwspin_lock_register/hwspin_lock_unregister, with which
52 * we _do_ want users to fail (no point in registering hwspinlock instances if
53 * the framework is not available).
54 *
55 * Note: ERR_PTR(-ENODEV) will still be considered a success for NULL-checking
56 * users. Others, which care, can still check this with IS_ERR.
57 */
58static inline struct hwspinlock *hwspin_lock_request(void)
59{
60 return ERR_PTR(-ENODEV);
61}
62
63static inline struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
64{
65 return ERR_PTR(-ENODEV);
66}
67
68static inline int hwspin_lock_free(struct hwspinlock *hwlock)
69{
70 return 0;
71}
72
73static inline
74int __hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int to,
75 int mode, unsigned long *flags)
76{
77 return 0;
78}
79
80static inline
81int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
82{
83 return 0;
84}
85
86static inline
87void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
88{
89 return 0;
90}
91
92static inline int hwspin_lock_get_id(struct hwspinlock *hwlock)
93{
94 return 0;
95}
96
97static inline int hwspin_lock_register(struct hwspinlock *hwlock)
98{
99 return -ENODEV;
100}
101
102static inline struct hwspinlock *hwspin_lock_unregister(unsigned int id)
103{
104 return NULL;
105}
106
107#endif /* !CONFIG_HWSPINLOCK */
108
109/**
110 * hwspin_trylock_irqsave() - try to lock an hwspinlock, disable interrupts
111 * @hwlock: an hwspinlock which we want to trylock
112 * @flags: a pointer to where the caller's interrupt state will be saved at
113 *
114 * This function attempts to lock the underlying hwspinlock, and will
115 * immediately fail if the hwspinlock is already locked.
116 *
117 * Upon a successful return from this function, preemption and local
118 * interrupts are disabled (previous interrupts state is saved at @flags),
119 * so the caller must not sleep, and is advised to release the hwspinlock
120 * as soon as possible.
121 *
122 * Returns 0 if we successfully locked the hwspinlock, -EBUSY if
123 * the hwspinlock was already taken, and -EINVAL if @hwlock is invalid.
124 */
125static inline
126int hwspin_trylock_irqsave(struct hwspinlock *hwlock, unsigned long *flags)
127{
128 return __hwspin_trylock(hwlock, HWLOCK_IRQSTATE, flags);
129}
130
131/**
132 * hwspin_trylock_irq() - try to lock an hwspinlock, disable interrupts
133 * @hwlock: an hwspinlock which we want to trylock
134 *
135 * This function attempts to lock the underlying hwspinlock, and will
136 * immediately fail if the hwspinlock is already locked.
137 *
138 * Upon a successful return from this function, preemption and local
139 * interrupts are disabled, so the caller must not sleep, and is advised
140 * to release the hwspinlock as soon as possible.
141 *
142 * Returns 0 if we successfully locked the hwspinlock, -EBUSY if
143 * the hwspinlock was already taken, and -EINVAL if @hwlock is invalid.
144 */
145static inline int hwspin_trylock_irq(struct hwspinlock *hwlock)
146{
147 return __hwspin_trylock(hwlock, HWLOCK_IRQ, NULL);
148}
149
150/**
151 * hwspin_trylock() - attempt to lock a specific hwspinlock
152 * @hwlock: an hwspinlock which we want to trylock
153 *
154 * This function attempts to lock an hwspinlock, and will immediately fail
155 * if the hwspinlock is already taken.
156 *
157 * Upon a successful return from this function, preemption is disabled,
158 * so the caller must not sleep, and is advised to release the hwspinlock
159 * as soon as possible. This is required in order to minimize remote cores
160 * polling on the hardware interconnect.
161 *
162 * Returns 0 if we successfully locked the hwspinlock, -EBUSY if
163 * the hwspinlock was already taken, and -EINVAL if @hwlock is invalid.
164 */
165static inline int hwspin_trylock(struct hwspinlock *hwlock)
166{
167 return __hwspin_trylock(hwlock, 0, NULL);
168}
169
170/**
171 * hwspin_lock_timeout_irqsave() - lock hwspinlock, with timeout, disable irqs
172 * @hwlock: the hwspinlock to be locked
173 * @to: timeout value in msecs
174 * @flags: a pointer to where the caller's interrupt state will be saved at
175 *
176 * This function locks the underlying @hwlock. If the @hwlock
177 * is already taken, the function will busy loop waiting for it to
178 * be released, but give up when @timeout msecs have elapsed.
179 *
180 * Upon a successful return from this function, preemption and local interrupts
181 * are disabled (plus previous interrupt state is saved), so the caller must
182 * not sleep, and is advised to release the hwspinlock as soon as possible.
183 *
184 * Returns 0 when the @hwlock was successfully taken, and an appropriate
185 * error code otherwise (most notably an -ETIMEDOUT if the @hwlock is still
186 * busy after @timeout msecs). The function will never sleep.
187 */
188static inline int hwspin_lock_timeout_irqsave(struct hwspinlock *hwlock,
189 unsigned int to, unsigned long *flags)
190{
191 return __hwspin_lock_timeout(hwlock, to, HWLOCK_IRQSTATE, flags);
192}
193
194/**
195 * hwspin_lock_timeout_irq() - lock hwspinlock, with timeout, disable irqs
196 * @hwlock: the hwspinlock to be locked
197 * @to: timeout value in msecs
198 *
199 * This function locks the underlying @hwlock. If the @hwlock
200 * is already taken, the function will busy loop waiting for it to
201 * be released, but give up when @timeout msecs have elapsed.
202 *
203 * Upon a successful return from this function, preemption and local interrupts
204 * are disabled so the caller must not sleep, and is advised to release the
205 * hwspinlock as soon as possible.
206 *
207 * Returns 0 when the @hwlock was successfully taken, and an appropriate
208 * error code otherwise (most notably an -ETIMEDOUT if the @hwlock is still
209 * busy after @timeout msecs). The function will never sleep.
210 */
211static inline
212int hwspin_lock_timeout_irq(struct hwspinlock *hwlock, unsigned int to)
213{
214 return __hwspin_lock_timeout(hwlock, to, HWLOCK_IRQ, NULL);
215}
216
217/**
218 * hwspin_lock_timeout() - lock an hwspinlock with timeout limit
219 * @hwlock: the hwspinlock to be locked
220 * @to: timeout value in msecs
221 *
222 * This function locks the underlying @hwlock. If the @hwlock
223 * is already taken, the function will busy loop waiting for it to
224 * be released, but give up when @timeout msecs have elapsed.
225 *
226 * Upon a successful return from this function, preemption is disabled
227 * so the caller must not sleep, and is advised to release the hwspinlock
228 * as soon as possible.
229 * This is required in order to minimize remote cores polling on the
230 * hardware interconnect.
231 *
232 * Returns 0 when the @hwlock was successfully taken, and an appropriate
233 * error code otherwise (most notably an -ETIMEDOUT if the @hwlock is still
234 * busy after @timeout msecs). The function will never sleep.
235 */
236static inline
237int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int to)
238{
239 return __hwspin_lock_timeout(hwlock, to, 0, NULL);
240}
241
242/**
243 * hwspin_unlock_irqrestore() - unlock hwspinlock, restore irq state
244 * @hwlock: a previously-acquired hwspinlock which we want to unlock
245 * @flags: previous caller's interrupt state to restore
246 *
247 * This function will unlock a specific hwspinlock, enable preemption and
248 * restore the previous state of the local interrupts. It should be used
249 * to undo, e.g., hwspin_trylock_irqsave().
250 *
251 * @hwlock must be already locked before calling this function: it is a bug
252 * to call unlock on a @hwlock that is already unlocked.
253 */
254static inline void hwspin_unlock_irqrestore(struct hwspinlock *hwlock,
255 unsigned long *flags)
256{
257 __hwspin_unlock(hwlock, HWLOCK_IRQSTATE, flags);
258}
259
260/**
261 * hwspin_unlock_irq() - unlock hwspinlock, enable interrupts
262 * @hwlock: a previously-acquired hwspinlock which we want to unlock
263 *
264 * This function will unlock a specific hwspinlock, enable preemption and
265 * enable local interrupts. Should be used to undo hwspin_lock_irq().
266 *
267 * @hwlock must be already locked (e.g. by hwspin_trylock_irq()) before
268 * calling this function: it is a bug to call unlock on a @hwlock that is
269 * already unlocked.
270 */
271static inline void hwspin_unlock_irq(struct hwspinlock *hwlock)
272{
273 __hwspin_unlock(hwlock, HWLOCK_IRQ, NULL);
274}
275
276/**
277 * hwspin_unlock() - unlock hwspinlock
278 * @hwlock: a previously-acquired hwspinlock which we want to unlock
279 *
280 * This function will unlock a specific hwspinlock and enable preemption
281 * back.
282 *
283 * @hwlock must be already locked (e.g. by hwspin_trylock()) before calling
284 * this function: it is a bug to call unlock on a @hwlock that is already
285 * unlocked.
286 */
287static inline void hwspin_unlock(struct hwspinlock *hwlock)
288{
289 __hwspin_unlock(hwlock, 0, NULL);
290}
291
292#endif /* __LINUX_HWSPINLOCK_H */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
deleted file mode 100644
index e844a0b18695..000000000000
--- a/include/linux/i2c-id.h
+++ /dev/null
@@ -1,59 +0,0 @@
1/* ------------------------------------------------------------------------- */
2/* */
3/* i2c-id.h - identifier values for i2c drivers and adapters */
4/* */
5/* ------------------------------------------------------------------------- */
6/* Copyright (C) 1995-1999 Simon G. Vogl
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21/* ------------------------------------------------------------------------- */
22
23#ifndef LINUX_I2C_ID_H
24#define LINUX_I2C_ID_H
25
26/* Please note that I2C driver IDs are optional. They are only needed if a
27 legacy chip driver needs to identify a bus or a bus driver needs to
28 identify a legacy client. If you don't need them, just don't set them. */
29
30/*
31 * ---- Adapter types ----------------------------------------------------
32 */
33
34/* --- Bit algorithm adapters */
35#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
36#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */
37#define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */
38#define I2C_HW_B_CX2388x 0x01001b /* connexant 2388x based tv cards */
39#define I2C_HW_B_EM28XX 0x01001f /* em28xx video capture cards */
40#define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */
41#define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */
42#define I2C_HW_B_AU0828 0x010023 /* auvitek au0828 usb bridge */
43#define I2C_HW_B_CX231XX 0x010024 /* Conexant CX231XX USB based cards */
44#define I2C_HW_B_HDPVR 0x010025 /* Hauppauge HD PVR */
45
46/* --- SGI adapters */
47#define I2C_HW_SGI_VINO 0x160000
48
49/* --- SMBus only adapters */
50#define I2C_HW_SMBUS_W9968CF 0x04000d
51#define I2C_HW_SMBUS_OV511 0x04000e /* OV511(+) USB 1.1 webcam ICs */
52#define I2C_HW_SMBUS_OV518 0x04000f /* OV518(+) USB 1.1 webcam ICs */
53#define I2C_HW_SMBUS_CAFE 0x040012 /* Marvell 88ALP01 "CAFE" cam */
54
55/* --- Miscellaneous adapters */
56#define I2C_HW_SAA7146 0x060000 /* SAA7146 video decoder bus */
57#define I2C_HW_SAA7134 0x090000 /* SAA7134 video decoder bus */
58
59#endif /* LINUX_I2C_ID_H */
diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h
index 78ebf507ce56..7472449cbb74 100644
--- a/include/linux/i2c-omap.h
+++ b/include/linux/i2c-omap.h
@@ -1,9 +1,14 @@
1#ifndef __I2C_OMAP_H__ 1#ifndef __I2C_OMAP_H__
2#define __I2C_OMAP_H__ 2#define __I2C_OMAP_H__
3 3
4#include <linux/platform_device.h>
5
4struct omap_i2c_bus_platform_data { 6struct omap_i2c_bus_platform_data {
5 u32 clkrate; 7 u32 clkrate;
6 void (*set_mpu_wkup_lat)(struct device *dev, long set); 8 void (*set_mpu_wkup_lat)(struct device *dev, long set);
9 int (*device_enable) (struct platform_device *pdev);
10 int (*device_shutdown) (struct platform_device *pdev);
11 int (*device_idle) (struct platform_device *pdev);
7}; 12};
8 13
9#endif 14#endif
diff --git a/include/linux/i2c-tegra.h b/include/linux/i2c-tegra.h
new file mode 100644
index 000000000000..9c85da49857a
--- /dev/null
+++ b/include/linux/i2c-tegra.h
@@ -0,0 +1,25 @@
1/*
2 * drivers/i2c/busses/i2c-tegra.c
3 *
4 * Copyright (C) 2010 Google, Inc.
5 * Author: Colin Cross <ccross@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef _LINUX_I2C_TEGRA_H
19#define _LINUX_I2C_TEGRA_H
20
21struct tegra_i2c_platform_data {
22 unsigned long bus_clk_rate;
23};
24
25#endif /* _LINUX_I2C_TEGRA_H */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 4bae0b72ed3c..a6c652ef516d 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -29,7 +29,6 @@
29#include <linux/types.h> 29#include <linux/types.h>
30#ifdef __KERNEL__ 30#ifdef __KERNEL__
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/i2c-id.h>
33#include <linux/mod_devicetable.h> 32#include <linux/mod_devicetable.h>
34#include <linux/device.h> /* for struct device */ 33#include <linux/device.h> /* for struct device */
35#include <linux/sched.h> /* for completion */ 34#include <linux/sched.h> /* for completion */
@@ -57,9 +56,10 @@ struct i2c_board_info;
57 * transmit an arbitrary number of messages without interruption. 56 * transmit an arbitrary number of messages without interruption.
58 * @count must be be less than 64k since msg.len is u16. 57 * @count must be be less than 64k since msg.len is u16.
59 */ 58 */
60extern int i2c_master_send(struct i2c_client *client, const char *buf, 59extern int i2c_master_send(const struct i2c_client *client, const char *buf,
60 int count);
61extern int i2c_master_recv(const struct i2c_client *client, char *buf,
61 int count); 62 int count);
62extern int i2c_master_recv(struct i2c_client *client, char *buf, int count);
63 63
64/* Transfer num messages. 64/* Transfer num messages.
65 */ 65 */
@@ -78,23 +78,25 @@ extern s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
78/* Now follow the 'nice' access routines. These also document the calling 78/* Now follow the 'nice' access routines. These also document the calling
79 conventions of i2c_smbus_xfer. */ 79 conventions of i2c_smbus_xfer. */
80 80
81extern s32 i2c_smbus_read_byte(struct i2c_client *client); 81extern s32 i2c_smbus_read_byte(const struct i2c_client *client);
82extern s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value); 82extern s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value);
83extern s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command); 83extern s32 i2c_smbus_read_byte_data(const struct i2c_client *client,
84extern s32 i2c_smbus_write_byte_data(struct i2c_client *client, 84 u8 command);
85extern s32 i2c_smbus_write_byte_data(const struct i2c_client *client,
85 u8 command, u8 value); 86 u8 command, u8 value);
86extern s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command); 87extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
87extern s32 i2c_smbus_write_word_data(struct i2c_client *client, 88 u8 command);
89extern s32 i2c_smbus_write_word_data(const struct i2c_client *client,
88 u8 command, u16 value); 90 u8 command, u16 value);
89/* Returns the number of read bytes */ 91/* Returns the number of read bytes */
90extern s32 i2c_smbus_read_block_data(struct i2c_client *client, 92extern s32 i2c_smbus_read_block_data(const struct i2c_client *client,
91 u8 command, u8 *values); 93 u8 command, u8 *values);
92extern s32 i2c_smbus_write_block_data(struct i2c_client *client, 94extern s32 i2c_smbus_write_block_data(const struct i2c_client *client,
93 u8 command, u8 length, const u8 *values); 95 u8 command, u8 length, const u8 *values);
94/* Returns the number of read bytes */ 96/* Returns the number of read bytes */
95extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, 97extern s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client,
96 u8 command, u8 length, u8 *values); 98 u8 command, u8 length, u8 *values);
97extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, 99extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
98 u8 command, u8 length, 100 u8 command, u8 length,
99 const u8 *values); 101 const u8 *values);
100#endif /* I2C */ 102#endif /* I2C */
@@ -102,8 +104,8 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client,
102/** 104/**
103 * struct i2c_driver - represent an I2C device driver 105 * struct i2c_driver - represent an I2C device driver
104 * @class: What kind of i2c device we instantiate (for detect) 106 * @class: What kind of i2c device we instantiate (for detect)
105 * @attach_adapter: Callback for bus addition (for legacy drivers) 107 * @attach_adapter: Callback for bus addition (deprecated)
106 * @detach_adapter: Callback for bus removal (for legacy drivers) 108 * @detach_adapter: Callback for bus removal (deprecated)
107 * @probe: Callback for device binding 109 * @probe: Callback for device binding
108 * @remove: Callback for device unbinding 110 * @remove: Callback for device unbinding
109 * @shutdown: Callback for device shutdown 111 * @shutdown: Callback for device shutdown
@@ -141,11 +143,11 @@ struct i2c_driver {
141 unsigned int class; 143 unsigned int class;
142 144
143 /* Notifies the driver that a new bus has appeared or is about to be 145 /* Notifies the driver that a new bus has appeared or is about to be
144 * removed. You should avoid using this if you can, it will probably 146 * removed. You should avoid using this, it will be removed in a
145 * be removed in a near future. 147 * near future.
146 */ 148 */
147 int (*attach_adapter)(struct i2c_adapter *); 149 int (*attach_adapter)(struct i2c_adapter *) __deprecated;
148 int (*detach_adapter)(struct i2c_adapter *); 150 int (*detach_adapter)(struct i2c_adapter *) __deprecated;
149 151
150 /* Standard driver model interfaces */ 152 /* Standard driver model interfaces */
151 int (*probe)(struct i2c_client *, const struct i2c_device_id *); 153 int (*probe)(struct i2c_client *, const struct i2c_device_id *);
@@ -255,9 +257,7 @@ struct i2c_board_info {
255 unsigned short addr; 257 unsigned short addr;
256 void *platform_data; 258 void *platform_data;
257 struct dev_archdata *archdata; 259 struct dev_archdata *archdata;
258#ifdef CONFIG_OF
259 struct device_node *of_node; 260 struct device_node *of_node;
260#endif
261 int irq; 261 int irq;
262}; 262};
263 263
@@ -353,7 +353,6 @@ struct i2c_algorithm {
353 */ 353 */
354struct i2c_adapter { 354struct i2c_adapter {
355 struct module *owner; 355 struct module *owner;
356 unsigned int id;
357 unsigned int class; /* classes to allow probing for */ 356 unsigned int class; /* classes to allow probing for */
358 const struct i2c_algorithm *algo; /* the algorithm to access the bus */ 357 const struct i2c_algorithm *algo; /* the algorithm to access the bus */
359 void *algo_data; 358 void *algo_data;
@@ -384,13 +383,19 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
384 dev_set_drvdata(&dev->dev, data); 383 dev_set_drvdata(&dev->dev, data);
385} 384}
386 385
387static inline int i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter) 386static inline struct i2c_adapter *
387i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter)
388{ 388{
389 return adapter->dev.parent != NULL 389 struct device *parent = adapter->dev.parent;
390 && adapter->dev.parent->bus == &i2c_bus_type 390
391 && adapter->dev.parent->type == &i2c_adapter_type; 391 if (parent != NULL && parent->type == &i2c_adapter_type)
392 return to_i2c_adapter(parent);
393 else
394 return NULL;
392} 395}
393 396
397int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *));
398
394/* Adapter locking functions, exported for shared pin cases */ 399/* Adapter locking functions, exported for shared pin cases */
395void i2c_lock_adapter(struct i2c_adapter *); 400void i2c_lock_adapter(struct i2c_adapter *);
396void i2c_unlock_adapter(struct i2c_adapter *); 401void i2c_unlock_adapter(struct i2c_adapter *);
@@ -403,10 +408,8 @@ void i2c_unlock_adapter(struct i2c_adapter *);
403 408
404/* i2c adapter classes (bitmask) */ 409/* i2c adapter classes (bitmask) */
405#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ 410#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */
406#define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
407#define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */
408#define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */ 411#define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */
409#define I2C_CLASS_SPD (1<<7) /* SPD EEPROMs and similar */ 412#define I2C_CLASS_SPD (1<<7) /* Memory modules */
410 413
411/* Internal numbers to terminate lists */ 414/* Internal numbers to terminate lists */
412#define I2C_CLIENT_END 0xfffeU 415#define I2C_CLIENT_END 0xfffeU
@@ -444,7 +447,7 @@ extern void i2c_release_client(struct i2c_client *client);
444extern void i2c_clients_command(struct i2c_adapter *adap, 447extern void i2c_clients_command(struct i2c_adapter *adap,
445 unsigned int cmd, void *arg); 448 unsigned int cmd, void *arg);
446 449
447extern struct i2c_adapter *i2c_get_adapter(int id); 450extern struct i2c_adapter *i2c_get_adapter(int nr);
448extern void i2c_put_adapter(struct i2c_adapter *adap); 451extern void i2c_put_adapter(struct i2c_adapter *adap);
449 452
450 453
diff --git a/include/linux/i2c/adp5588.h b/include/linux/i2c/adp5588.h
index 269181b8f623..cec17cf6cac2 100644
--- a/include/linux/i2c/adp5588.h
+++ b/include/linux/i2c/adp5588.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Analog Devices ADP5588 I/O Expander and QWERTY Keypad Controller 2 * Analog Devices ADP5588 I/O Expander and QWERTY Keypad Controller
3 * 3 *
4 * Copyright 2009 Analog Devices Inc. 4 * Copyright 2009-2010 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -74,6 +74,33 @@
74 74
75#define ADP5588_DEVICE_ID_MASK 0xF 75#define ADP5588_DEVICE_ID_MASK 0xF
76 76
77 /* Configuration Register1 */
78#define ADP5588_AUTO_INC (1 << 7)
79#define ADP5588_GPIEM_CFG (1 << 6)
80#define ADP5588_OVR_FLOW_M (1 << 5)
81#define ADP5588_INT_CFG (1 << 4)
82#define ADP5588_OVR_FLOW_IEN (1 << 3)
83#define ADP5588_K_LCK_IM (1 << 2)
84#define ADP5588_GPI_IEN (1 << 1)
85#define ADP5588_KE_IEN (1 << 0)
86
87/* Interrupt Status Register */
88#define ADP5588_CMP2_INT (1 << 5)
89#define ADP5588_CMP1_INT (1 << 4)
90#define ADP5588_OVR_FLOW_INT (1 << 3)
91#define ADP5588_K_LCK_INT (1 << 2)
92#define ADP5588_GPI_INT (1 << 1)
93#define ADP5588_KE_INT (1 << 0)
94
95/* Key Lock and Event Counter Register */
96#define ADP5588_K_LCK_EN (1 << 6)
97#define ADP5588_LCK21 0x30
98#define ADP5588_KEC 0xF
99
100#define ADP5588_MAXGPIO 18
101#define ADP5588_BANK(offs) ((offs) >> 3)
102#define ADP5588_BIT(offs) (1u << ((offs) & 0x7))
103
77/* Put one of these structures in i2c_board_info platform_data */ 104/* Put one of these structures in i2c_board_info platform_data */
78 105
79#define ADP5588_KEYMAPSIZE 80 106#define ADP5588_KEYMAPSIZE 80
@@ -126,9 +153,12 @@ struct adp5588_kpad_platform_data {
126 const struct adp5588_gpio_platform_data *gpio_data; 153 const struct adp5588_gpio_platform_data *gpio_data;
127}; 154};
128 155
156struct i2c_client; /* forward declaration */
157
129struct adp5588_gpio_platform_data { 158struct adp5588_gpio_platform_data {
130 unsigned gpio_start; /* GPIO Chip base # */ 159 int gpio_start; /* GPIO Chip base # */
131 unsigned pullup_dis_mask; /* Pull-Up Disable Mask */ 160 unsigned irq_base; /* interrupt base # */
161 unsigned pullup_dis_mask; /* Pull-Up Disable Mask */
132 int (*setup)(struct i2c_client *client, 162 int (*setup)(struct i2c_client *client,
133 int gpio, unsigned ngpio, 163 int gpio, unsigned ngpio,
134 void *context); 164 void *context);
diff --git a/include/linux/i2c/adp8870.h b/include/linux/i2c/adp8870.h
new file mode 100644
index 000000000000..624dceccbd5b
--- /dev/null
+++ b/include/linux/i2c/adp8870.h
@@ -0,0 +1,153 @@
1/*
2 * Definitions and platform data for Analog Devices
3 * Backlight drivers ADP8870
4 *
5 * Copyright 2009-2010 Analog Devices Inc.
6 *
7 * Licensed under the GPL-2 or later.
8 */
9
10#ifndef __LINUX_I2C_ADP8870_H
11#define __LINUX_I2C_ADP8870_H
12
13#define ID_ADP8870 8870
14
15#define ADP8870_MAX_BRIGHTNESS 0x7F
16#define FLAG_OFFT_SHIFT 8
17
18/*
19 * LEDs subdevice platform data
20 */
21
22#define ADP8870_LED_DIS_BLINK (0 << FLAG_OFFT_SHIFT)
23#define ADP8870_LED_OFFT_600ms (1 << FLAG_OFFT_SHIFT)
24#define ADP8870_LED_OFFT_1200ms (2 << FLAG_OFFT_SHIFT)
25#define ADP8870_LED_OFFT_1800ms (3 << FLAG_OFFT_SHIFT)
26
27#define ADP8870_LED_ONT_200ms 0
28#define ADP8870_LED_ONT_600ms 1
29#define ADP8870_LED_ONT_800ms 2
30#define ADP8870_LED_ONT_1200ms 3
31
32#define ADP8870_LED_D7 (7)
33#define ADP8870_LED_D6 (6)
34#define ADP8870_LED_D5 (5)
35#define ADP8870_LED_D4 (4)
36#define ADP8870_LED_D3 (3)
37#define ADP8870_LED_D2 (2)
38#define ADP8870_LED_D1 (1)
39
40/*
41 * Backlight subdevice platform data
42 */
43
44#define ADP8870_BL_D7 (1 << 6)
45#define ADP8870_BL_D6 (1 << 5)
46#define ADP8870_BL_D5 (1 << 4)
47#define ADP8870_BL_D4 (1 << 3)
48#define ADP8870_BL_D3 (1 << 2)
49#define ADP8870_BL_D2 (1 << 1)
50#define ADP8870_BL_D1 (1 << 0)
51
52#define ADP8870_FADE_T_DIS 0 /* Fade Timer Disabled */
53#define ADP8870_FADE_T_300ms 1 /* 0.3 Sec */
54#define ADP8870_FADE_T_600ms 2
55#define ADP8870_FADE_T_900ms 3
56#define ADP8870_FADE_T_1200ms 4
57#define ADP8870_FADE_T_1500ms 5
58#define ADP8870_FADE_T_1800ms 6
59#define ADP8870_FADE_T_2100ms 7
60#define ADP8870_FADE_T_2400ms 8
61#define ADP8870_FADE_T_2700ms 9
62#define ADP8870_FADE_T_3000ms 10
63#define ADP8870_FADE_T_3500ms 11
64#define ADP8870_FADE_T_4000ms 12
65#define ADP8870_FADE_T_4500ms 13
66#define ADP8870_FADE_T_5000ms 14
67#define ADP8870_FADE_T_5500ms 15 /* 5.5 Sec */
68
69#define ADP8870_FADE_LAW_LINEAR 0
70#define ADP8870_FADE_LAW_SQUARE 1
71#define ADP8870_FADE_LAW_CUBIC1 2
72#define ADP8870_FADE_LAW_CUBIC2 3
73
74#define ADP8870_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */
75#define ADP8870_BL_AMBL_FILT_160ms 1
76#define ADP8870_BL_AMBL_FILT_320ms 2
77#define ADP8870_BL_AMBL_FILT_640ms 3
78#define ADP8870_BL_AMBL_FILT_1280ms 4
79#define ADP8870_BL_AMBL_FILT_2560ms 5
80#define ADP8870_BL_AMBL_FILT_5120ms 6
81#define ADP8870_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */
82
83/*
84 * Blacklight current 0..30mA
85 */
86#define ADP8870_BL_CUR_mA(I) ((I * 127) / 30)
87
88/*
89 * L2 comparator current 0..1106uA
90 */
91#define ADP8870_L2_COMP_CURR_uA(I) ((I * 255) / 1106)
92
93/*
94 * L3 comparator current 0..551uA
95 */
96#define ADP8870_L3_COMP_CURR_uA(I) ((I * 255) / 551)
97
98/*
99 * L4 comparator current 0..275uA
100 */
101#define ADP8870_L4_COMP_CURR_uA(I) ((I * 255) / 275)
102
103/*
104 * L5 comparator current 0..138uA
105 */
106#define ADP8870_L5_COMP_CURR_uA(I) ((I * 255) / 138)
107
108struct adp8870_backlight_platform_data {
109 u8 bl_led_assign; /* 1 = Backlight 0 = Individual LED */
110 u8 pwm_assign; /* 1 = Enables PWM mode */
111
112 u8 bl_fade_in; /* Backlight Fade-In Timer */
113 u8 bl_fade_out; /* Backlight Fade-Out Timer */
114 u8 bl_fade_law; /* fade-on/fade-off transfer characteristic */
115
116 u8 en_ambl_sens; /* 1 = enable ambient light sensor */
117 u8 abml_filt; /* Light sensor filter time */
118
119 u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
120 u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
121 u8 l2_bright_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
122 u8 l2_bright_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
123 u8 l3_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
124 u8 l3_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
125 u8 l4_indoor_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
126 u8 l4_indor_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
127 u8 l5_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
128 u8 l5_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
129
130 u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
131 u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
132 u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */
133 u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */
134 u8 l4_trip; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */
135 u8 l4_hyst; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */
136 u8 l5_trip; /* use L5_COMP_CURR_uA(I) 0 <= I <= 138 uA */
137 u8 l5_hyst; /* use L6_COMP_CURR_uA(I) 0 <= I <= 138 uA */
138
139 /**
140 * Independent Current Sinks / LEDS
141 * Sinks not assigned to the Backlight can be exposed to
142 * user space using the LEDS CLASS interface
143 */
144
145 int num_leds;
146 struct led_info *leds;
147 u8 led_fade_in; /* LED Fade-In Timer */
148 u8 led_fade_out; /* LED Fade-Out Timer */
149 u8 led_fade_law; /* fade-on/fade-off transfer characteristic */
150 u8 led_on_time;
151};
152
153#endif /* __LINUX_I2C_ADP8870_H */
diff --git a/include/linux/i2c/ads1015.h b/include/linux/i2c/ads1015.h
new file mode 100644
index 000000000000..d5aa2a045669
--- /dev/null
+++ b/include/linux/i2c/ads1015.h
@@ -0,0 +1,36 @@
1/*
2 * Platform Data for ADS1015 12-bit 4-input ADC
3 * (C) Copyright 2010
4 * Dirk Eibach, Guntermann & Drunck GmbH <eibach@gdsys.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef LINUX_ADS1015_H
22#define LINUX_ADS1015_H
23
24#define ADS1015_CHANNELS 8
25
26struct ads1015_channel_data {
27 bool enabled;
28 unsigned int pga;
29 unsigned int data_rate;
30};
31
32struct ads1015_platform_data {
33 struct ads1015_channel_data channel_data[ADS1015_CHANNELS];
34};
35
36#endif /* LINUX_ADS1015_H */
diff --git a/include/linux/i2c/apds990x.h b/include/linux/i2c/apds990x.h
new file mode 100644
index 000000000000..d186fcc5d257
--- /dev/null
+++ b/include/linux/i2c/apds990x.h
@@ -0,0 +1,79 @@
1/*
2 * This file is part of the APDS990x sensor driver.
3 * Chip is combined proximity and ambient light sensor.
4 *
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 *
7 * Contact: Samu Onkalo <samu.p.onkalo@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __APDS990X_H__
26#define __APDS990X_H__
27
28
29#define APDS_IRLED_CURR_12mA 0x3
30#define APDS_IRLED_CURR_25mA 0x2
31#define APDS_IRLED_CURR_50mA 0x1
32#define APDS_IRLED_CURR_100mA 0x0
33
34/**
35 * struct apds990x_chip_factors - defines effect of the cover window
36 * @ga: Total glass attenuation
37 * @cf1: clear channel factor 1 for raw to lux conversion
38 * @irf1: IR channel factor 1 for raw to lux conversion
39 * @cf2: clear channel factor 2 for raw to lux conversion
40 * @irf2: IR channel factor 2 for raw to lux conversion
41 * @df: device factor for conversion formulas
42 *
43 * Structure for tuning ALS calculation to match with environment.
44 * Values depend on the material above the sensor and the sensor
45 * itself. If the GA is zero, driver will use uncovered sensor default values
46 * format: decimal value * APDS_PARAM_SCALE except df which is plain integer.
47 */
48#define APDS_PARAM_SCALE 4096
49struct apds990x_chip_factors {
50 int ga;
51 int cf1;
52 int irf1;
53 int cf2;
54 int irf2;
55 int df;
56};
57
58/**
59 * struct apds990x_platform_data - platform data for apsd990x.c driver
60 * @cf: chip factor data
61 * @pddrive: IR-led driving current
62 * @ppcount: number of IR pulses used for proximity estimation
63 * @setup_resources: interrupt line setup call back function
64 * @release_resources: interrupt line release call back function
65 *
66 * Proximity detection result depends heavily on correct ppcount, pdrive
67 * and cover window.
68 *
69 */
70
71struct apds990x_platform_data {
72 struct apds990x_chip_factors cf;
73 u8 pdrive;
74 u8 ppcount;
75 int (*setup_resources)(void);
76 int (*release_resources)(void);
77};
78
79#endif
diff --git a/include/linux/i2c/qt602240_ts.h b/include/linux/i2c/atmel_mxt_ts.h
index c5033e101094..f027f7a63511 100644
--- a/include/linux/i2c/qt602240_ts.h
+++ b/include/linux/i2c/atmel_mxt_ts.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * AT42QT602240/ATMXT224 Touchscreen driver 2 * Atmel maXTouch Touchscreen driver
3 * 3 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd 4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: Joonyoung Shim <jy0922.shim@samsung.com> 5 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
@@ -10,21 +10,26 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13#ifndef __LINUX_QT602240_TS_H 13#ifndef __LINUX_ATMEL_MXT_TS_H
14#define __LINUX_QT602240_TS_H 14#define __LINUX_ATMEL_MXT_TS_H
15
16#include <linux/types.h>
15 17
16/* Orient */ 18/* Orient */
17#define QT602240_NORMAL 0x0 19#define MXT_NORMAL 0x0
18#define QT602240_DIAGONAL 0x1 20#define MXT_DIAGONAL 0x1
19#define QT602240_HORIZONTAL_FLIP 0x2 21#define MXT_HORIZONTAL_FLIP 0x2
20#define QT602240_ROTATED_90_COUNTER 0x3 22#define MXT_ROTATED_90_COUNTER 0x3
21#define QT602240_VERTICAL_FLIP 0x4 23#define MXT_VERTICAL_FLIP 0x4
22#define QT602240_ROTATED_90 0x5 24#define MXT_ROTATED_90 0x5
23#define QT602240_ROTATED_180 0x6 25#define MXT_ROTATED_180 0x6
24#define QT602240_DIAGONAL_COUNTER 0x7 26#define MXT_DIAGONAL_COUNTER 0x7
27
28/* The platform data for the Atmel maXTouch touchscreen driver */
29struct mxt_platform_data {
30 const u8 *config;
31 size_t config_length;
25 32
26/* The platform data for the AT42QT602240/ATMXT224 touchscreen driver */
27struct qt602240_platform_data {
28 unsigned int x_line; 33 unsigned int x_line;
29 unsigned int y_line; 34 unsigned int y_line;
30 unsigned int x_size; 35 unsigned int x_size;
@@ -33,6 +38,7 @@ struct qt602240_platform_data {
33 unsigned int threshold; 38 unsigned int threshold;
34 unsigned int voltage; 39 unsigned int voltage;
35 unsigned char orient; 40 unsigned char orient;
41 unsigned long irqflags;
36}; 42};
37 43
38#endif /* __LINUX_QT602240_TS_H */ 44#endif /* __LINUX_ATMEL_MXT_TS_H */
diff --git a/include/linux/i2c/bh1770glc.h b/include/linux/i2c/bh1770glc.h
new file mode 100644
index 000000000000..8b5e2df36c72
--- /dev/null
+++ b/include/linux/i2c/bh1770glc.h
@@ -0,0 +1,53 @@
1/*
2 * This file is part of the ROHM BH1770GLC / OSRAM SFH7770 sensor driver.
3 * Chip is combined proximity and ambient light sensor.
4 *
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 *
7 * Contact: Samu Onkalo <samu.p.onkalo@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __BH1770_H__
26#define __BH1770_H__
27
28/**
29 * struct bh1770_platform_data - platform data for bh1770glc driver
30 * @led_def_curr: IR led driving current.
31 * @glass_attenuation: Attenuation factor for covering window.
32 * @setup_resources: Call back for interrupt line setup function
33 * @release_resources: Call back for interrupte line release function
34 *
35 * Example of glass attenuation: 16384 * 385 / 100 means attenuation factor
36 * of 3.85. i.e. light_above_sensor = light_above_cover_window / 3.85
37 */
38
39struct bh1770_platform_data {
40#define BH1770_LED_5mA 0
41#define BH1770_LED_10mA 1
42#define BH1770_LED_20mA 2
43#define BH1770_LED_50mA 3
44#define BH1770_LED_100mA 4
45#define BH1770_LED_150mA 5
46#define BH1770_LED_200mA 6
47 __u8 led_def_curr;
48#define BH1770_NEUTRAL_GA 16384 /* 16384 / 16384 = 1 */
49 __u32 glass_attenuation;
50 int (*setup_resources)(void);
51 int (*release_resources)(void);
52};
53#endif
diff --git a/include/linux/i2c/ds620.h b/include/linux/i2c/ds620.h
new file mode 100644
index 000000000000..736bb87ac0fc
--- /dev/null
+++ b/include/linux/i2c/ds620.h
@@ -0,0 +1,21 @@
1#ifndef _LINUX_DS620_H
2#define _LINUX_DS620_H
3
4#include <linux/types.h>
5#include <linux/i2c.h>
6
7/* platform data for the DS620 temperature sensor and thermostat */
8
9struct ds620_platform_data {
10 /*
11 * Thermostat output pin PO mode:
12 * 0 = always low (default)
13 * 1 = PO_LOW
14 * 2 = PO_HIGH
15 *
16 * (see Documentation/hwmon/ds620)
17 */
18 int pomode;
19};
20
21#endif /* _LINUX_DS620_H */
diff --git a/include/linux/i2c/i2c-sh_mobile.h b/include/linux/i2c/i2c-sh_mobile.h
new file mode 100644
index 000000000000..beda7081aead
--- /dev/null
+++ b/include/linux/i2c/i2c-sh_mobile.h
@@ -0,0 +1,10 @@
1#ifndef __I2C_SH_MOBILE_H__
2#define __I2C_SH_MOBILE_H__
3
4#include <linux/platform_device.h>
5
6struct i2c_sh_mobile_platform_data {
7 unsigned long bus_speed;
8};
9
10#endif /* __I2C_SH_MOBILE_H__ */
diff --git a/include/linux/i2c/max6639.h b/include/linux/i2c/max6639.h
new file mode 100644
index 000000000000..6011c42034da
--- /dev/null
+++ b/include/linux/i2c/max6639.h
@@ -0,0 +1,14 @@
1#ifndef _LINUX_MAX6639_H
2#define _LINUX_MAX6639_H
3
4#include <linux/types.h>
5
6/* platform data for the MAX6639 temperature sensor and fan control */
7
8struct max6639_platform_data {
9 bool pwm_polarity; /* Polarity low (0) or high (1, default) */
10 int ppr; /* Pulses per rotation 1..4 (default == 2) */
11 int rpm_range; /* 2000, 4000 (default), 8000 or 16000 */
12};
13
14#endif /* _LINUX_MAX6639_H */
diff --git a/include/linux/i2c/mcs.h b/include/linux/i2c/mcs.h
index 725ae7c313ff..61bb18a4fd3c 100644
--- a/include/linux/i2c/mcs.h
+++ b/include/linux/i2c/mcs.h
@@ -18,6 +18,7 @@
18#define MCS_KEY_CODE(v) ((v) & 0xffff) 18#define MCS_KEY_CODE(v) ((v) & 0xffff)
19 19
20struct mcs_platform_data { 20struct mcs_platform_data {
21 void (*poweron)(bool);
21 void (*cfg_pin)(void); 22 void (*cfg_pin)(void);
22 23
23 /* touchscreen */ 24 /* touchscreen */
diff --git a/include/linux/i2c/mpr121_touchkey.h b/include/linux/i2c/mpr121_touchkey.h
new file mode 100644
index 000000000000..f0bcc38bbb97
--- /dev/null
+++ b/include/linux/i2c/mpr121_touchkey.h
@@ -0,0 +1,20 @@
1/* Header file for Freescale MPR121 Capacitive Touch Sensor */
2
3#ifndef _MPR121_TOUCHKEY_H
4#define _MPR121_TOUCHKEY_H
5
6/**
7 * struct mpr121_platform_data - platform data for mpr121 sensor
8 * @keymap: pointer to array of KEY_* values representing keymap
9 * @keymap_size: size of the keymap
10 * @wakeup: configure the button as a wake-up source
11 * @vdd_uv: VDD voltage in uV
12 */
13struct mpr121_platform_data {
14 const unsigned short *keymap;
15 unsigned int keymap_size;
16 bool wakeup;
17 int vdd_uv;
18};
19
20#endif /* _MPR121_TOUCHKEY_H */
diff --git a/include/linux/i2c/pmbus.h b/include/linux/i2c/pmbus.h
new file mode 100644
index 000000000000..69280db02c41
--- /dev/null
+++ b/include/linux/i2c/pmbus.h
@@ -0,0 +1,45 @@
1/*
2 * Hardware monitoring driver for PMBus devices
3 *
4 * Copyright (c) 2010, 2011 Ericsson AB.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef _PMBUS_H_
22#define _PMBUS_H_
23
24/* flags */
25
26/*
27 * PMBUS_SKIP_STATUS_CHECK
28 *
29 * During register detection, skip checking the status register for
30 * communication or command errors.
31 *
32 * Some PMBus chips respond with valid data when trying to read an unsupported
33 * register. For such chips, checking the status register is mandatory when
34 * trying to determine if a chip register exists or not.
35 * Other PMBus chips don't support the STATUS_CML register, or report
36 * communication errors for no explicable reason. For such chips, checking
37 * the status register must be disabled.
38 */
39#define PMBUS_SKIP_STATUS_CHECK (1 << 0)
40
41struct pmbus_platform_data {
42 u32 flags; /* Device specific flags */
43};
44
45#endif /* _PMBUS_H_ */
diff --git a/include/linux/i2c/pxa-i2c.h b/include/linux/i2c/pxa-i2c.h
new file mode 100644
index 000000000000..1a9f65e6ec0f
--- /dev/null
+++ b/include/linux/i2c/pxa-i2c.h
@@ -0,0 +1,82 @@
1/*
2 * i2c_pxa.h
3 *
4 * Copyright (C) 2002 Intrinsyc Software Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11#ifndef _I2C_PXA_H_
12#define _I2C_PXA_H_
13
14#if 0
15#define DEF_TIMEOUT 3
16#else
17/* need a longer timeout if we're dealing with the fact we may well be
18 * looking at a multi-master environment
19*/
20#define DEF_TIMEOUT 32
21#endif
22
23#define BUS_ERROR (-EREMOTEIO)
24#define XFER_NAKED (-ECONNREFUSED)
25#define I2C_RETRY (-2000) /* an error has occurred retry transmit */
26
27/* ICR initialize bit values
28*
29* 15. FM 0 (100 Khz operation)
30* 14. UR 0 (No unit reset)
31* 13. SADIE 0 (Disables the unit from interrupting on slave addresses
32* matching its slave address)
33* 12. ALDIE 0 (Disables the unit from interrupt when it loses arbitration
34* in master mode)
35* 11. SSDIE 0 (Disables interrupts from a slave stop detected, in slave mode)
36* 10. BEIE 1 (Enable interrupts from detected bus errors, no ACK sent)
37* 9. IRFIE 1 (Enable interrupts from full buffer received)
38* 8. ITEIE 1 (Enables the I2C unit to interrupt when transmit buffer empty)
39* 7. GCD 1 (Disables i2c unit response to general call messages as a slave)
40* 6. IUE 0 (Disable unit until we change settings)
41* 5. SCLE 1 (Enables the i2c clock output for master mode (drives SCL)
42* 4. MA 0 (Only send stop with the ICR stop bit)
43* 3. TB 0 (We are not transmitting a byte initially)
44* 2. ACKNAK 0 (Send an ACK after the unit receives a byte)
45* 1. STOP 0 (Do not send a STOP)
46* 0. START 0 (Do not send a START)
47*
48*/
49#define I2C_ICR_INIT (ICR_BEIE | ICR_IRFIE | ICR_ITEIE | ICR_GCD | ICR_SCLE)
50
51/* I2C status register init values
52 *
53 * 10. BED 1 (Clear bus error detected)
54 * 9. SAD 1 (Clear slave address detected)
55 * 7. IRF 1 (Clear IDBR Receive Full)
56 * 6. ITE 1 (Clear IDBR Transmit Empty)
57 * 5. ALD 1 (Clear Arbitration Loss Detected)
58 * 4. SSD 1 (Clear Slave Stop Detected)
59 */
60#define I2C_ISR_INIT 0x7FF /* status register init */
61
62struct i2c_slave_client;
63
64struct i2c_pxa_platform_data {
65 unsigned int slave_addr;
66 struct i2c_slave_client *slave;
67 unsigned int class;
68 unsigned int use_pio :1;
69 unsigned int fast_mode :1;
70};
71
72extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
73
74#ifdef CONFIG_PXA27x
75extern void pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info);
76#endif
77
78#ifdef CONFIG_PXA3xx
79extern void pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info);
80#endif
81
82#endif
diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
index c6361fbb7bf9..591427a63b06 100644
--- a/include/linux/i2c/tsc2007.h
+++ b/include/linux/i2c/tsc2007.h
@@ -6,6 +6,13 @@
6struct tsc2007_platform_data { 6struct tsc2007_platform_data {
7 u16 model; /* 2007. */ 7 u16 model; /* 2007. */
8 u16 x_plate_ohms; 8 u16 x_plate_ohms;
9 u16 max_rt; /* max. resistance above which samples are ignored */
10 unsigned long poll_delay; /* delay (in ms) after pen-down event
11 before polling starts */
12 unsigned long poll_period; /* time (in ms) between samples */
13 int fuzzx; /* fuzz factor for X, Y and pressure axes */
14 int fuzzy;
15 int fuzzz;
9 16
10 int (*get_pendown_state)(void); 17 int (*get_pendown_state)(void);
11 void (*clear_penirq)(void); /* If needed, clear 2nd level 18 void (*clear_penirq)(void); /* If needed, clear 2nd level
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 6de90bfc6acd..ba4f88624fcd 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -91,6 +91,7 @@
91#define BCI_INTR_OFFSET 2 91#define BCI_INTR_OFFSET 2
92#define MADC_INTR_OFFSET 3 92#define MADC_INTR_OFFSET 3
93#define USB_INTR_OFFSET 4 93#define USB_INTR_OFFSET 4
94#define CHARGERFAULT_INTR_OFFSET 5
94#define BCI_PRES_INTR_OFFSET 9 95#define BCI_PRES_INTR_OFFSET 9
95#define USB_PRES_INTR_OFFSET 10 96#define USB_PRES_INTR_OFFSET 10
96#define RTC_INTR_OFFSET 11 97#define RTC_INTR_OFFSET 11
@@ -141,6 +142,21 @@
141#define TWL6030_CHARGER_CTRL_INT_MASK 0x10 142#define TWL6030_CHARGER_CTRL_INT_MASK 0x10
142#define TWL6030_CHARGER_FAULT_INT_MASK 0x60 143#define TWL6030_CHARGER_FAULT_INT_MASK 0x60
143 144
145#define TWL6030_MMCCTRL 0xEE
146#define VMMC_AUTO_OFF (0x1 << 3)
147#define SW_FC (0x1 << 2)
148#define STS_MMC 0x1
149
150#define TWL6030_CFG_INPUT_PUPD3 0xF2
151#define MMC_PU (0x1 << 3)
152#define MMC_PD (0x1 << 2)
153
154#define TWL_SIL_TYPE(rev) ((rev) & 0x00FFFFFF)
155#define TWL_SIL_REV(rev) ((rev) >> 24)
156#define TWL_SIL_5030 0x09002F
157#define TWL5030_REV_1_0 0x00
158#define TWL5030_REV_1_1 0x10
159#define TWL5030_REV_1_2 0x30
144 160
145#define TWL4030_CLASS_ID 0x4030 161#define TWL4030_CLASS_ID 0x4030
146#define TWL6030_CLASS_ID 0x6030 162#define TWL6030_CLASS_ID 0x6030
@@ -155,6 +171,8 @@ static inline int twl_class_is_ ##class(void) \
155TWL_CLASS_IS(4030, TWL4030_CLASS_ID) 171TWL_CLASS_IS(4030, TWL4030_CLASS_ID)
156TWL_CLASS_IS(6030, TWL6030_CLASS_ID) 172TWL_CLASS_IS(6030, TWL6030_CLASS_ID)
157 173
174#define TWL6025_SUBCLASS BIT(4) /* TWL6025 has changed registers */
175
158/* 176/*
159 * Read and write single 8-bit registers 177 * Read and write single 8-bit registers
160 */ 178 */
@@ -170,9 +188,33 @@ int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
170int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 188int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
171int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 189int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
172 190
191int twl_get_type(void);
192int twl_get_version(void);
193
173int twl6030_interrupt_unmask(u8 bit_mask, u8 offset); 194int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
174int twl6030_interrupt_mask(u8 bit_mask, u8 offset); 195int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
175 196
197/* Card detect Configuration for MMC1 Controller on OMAP4 */
198#ifdef CONFIG_TWL4030_CORE
199int twl6030_mmc_card_detect_config(void);
200#else
201static inline int twl6030_mmc_card_detect_config(void)
202{
203 pr_debug("twl6030_mmc_card_detect_config not supported\n");
204 return 0;
205}
206#endif
207
208/* MMC1 Controller on OMAP4 uses Phoenix irq for Card detect */
209#ifdef CONFIG_TWL4030_CORE
210int twl6030_mmc_card_detect(struct device *dev, int slot);
211#else
212static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
213{
214 pr_debug("Call back twl6030_mmc_card_detect not supported\n");
215 return -EIO;
216}
217#endif
176/*----------------------------------------------------------------------*/ 218/*----------------------------------------------------------------------*/
177 219
178/* 220/*
@@ -248,7 +290,12 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
248 *(Use TWL_4030_MODULE_INTBR) 290 *(Use TWL_4030_MODULE_INTBR)
249 */ 291 */
250 292
293#define REG_IDCODE_7_0 0x00
294#define REG_IDCODE_15_8 0x01
295#define REG_IDCODE_16_23 0x02
296#define REG_IDCODE_31_24 0x03
251#define REG_GPPUPDCTR1 0x0F 297#define REG_GPPUPDCTR1 0x0F
298#define REG_UNLOCK_TEST_REG 0x12
252 299
253/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */ 300/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
254 301
@@ -257,6 +304,8 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
257#define SR_I2C_SCL_CTRL_PU BIT(4) 304#define SR_I2C_SCL_CTRL_PU BIT(4)
258#define SR_I2C_SDA_CTRL_PU BIT(6) 305#define SR_I2C_SDA_CTRL_PU BIT(6)
259 306
307#define TWL_EEPROM_R_UNLOCK 0x49
308
260/*----------------------------------------------------------------------*/ 309/*----------------------------------------------------------------------*/
261 310
262/* 311/*
@@ -357,6 +406,52 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
357 406
358/*----------------------------------------------------------------------*/ 407/*----------------------------------------------------------------------*/
359 408
409/*
410 * PM Master module register offsets (use TWL4030_MODULE_PM_MASTER)
411 */
412
413#define TWL4030_PM_MASTER_CFG_P1_TRANSITION 0x00
414#define TWL4030_PM_MASTER_CFG_P2_TRANSITION 0x01
415#define TWL4030_PM_MASTER_CFG_P3_TRANSITION 0x02
416#define TWL4030_PM_MASTER_CFG_P123_TRANSITION 0x03
417#define TWL4030_PM_MASTER_STS_BOOT 0x04
418#define TWL4030_PM_MASTER_CFG_BOOT 0x05
419#define TWL4030_PM_MASTER_SHUNDAN 0x06
420#define TWL4030_PM_MASTER_BOOT_BCI 0x07
421#define TWL4030_PM_MASTER_CFG_PWRANA1 0x08
422#define TWL4030_PM_MASTER_CFG_PWRANA2 0x09
423#define TWL4030_PM_MASTER_BACKUP_MISC_STS 0x0b
424#define TWL4030_PM_MASTER_BACKUP_MISC_CFG 0x0c
425#define TWL4030_PM_MASTER_BACKUP_MISC_TST 0x0d
426#define TWL4030_PM_MASTER_PROTECT_KEY 0x0e
427#define TWL4030_PM_MASTER_STS_HW_CONDITIONS 0x0f
428#define TWL4030_PM_MASTER_P1_SW_EVENTS 0x10
429#define TWL4030_PM_MASTER_P2_SW_EVENTS 0x11
430#define TWL4030_PM_MASTER_P3_SW_EVENTS 0x12
431#define TWL4030_PM_MASTER_STS_P123_STATE 0x13
432#define TWL4030_PM_MASTER_PB_CFG 0x14
433#define TWL4030_PM_MASTER_PB_WORD_MSB 0x15
434#define TWL4030_PM_MASTER_PB_WORD_LSB 0x16
435#define TWL4030_PM_MASTER_SEQ_ADD_W2P 0x1c
436#define TWL4030_PM_MASTER_SEQ_ADD_P2A 0x1d
437#define TWL4030_PM_MASTER_SEQ_ADD_A2W 0x1e
438#define TWL4030_PM_MASTER_SEQ_ADD_A2S 0x1f
439#define TWL4030_PM_MASTER_SEQ_ADD_S2A12 0x20
440#define TWL4030_PM_MASTER_SEQ_ADD_S2A3 0x21
441#define TWL4030_PM_MASTER_SEQ_ADD_WARM 0x22
442#define TWL4030_PM_MASTER_MEMORY_ADDRESS 0x23
443#define TWL4030_PM_MASTER_MEMORY_DATA 0x24
444
445#define TWL4030_PM_MASTER_KEY_CFG1 0xc0
446#define TWL4030_PM_MASTER_KEY_CFG2 0x0c
447
448#define TWL4030_PM_MASTER_KEY_TST1 0xe0
449#define TWL4030_PM_MASTER_KEY_TST2 0x0e
450
451#define TWL4030_PM_MASTER_GLOBAL_TST 0xb6
452
453/*----------------------------------------------------------------------*/
454
360/* Power bus message definitions */ 455/* Power bus message definitions */
361 456
362/* The TWL4030/5030 splits its power-management resources (the various 457/* The TWL4030/5030 splits its power-management resources (the various
@@ -424,7 +519,7 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
424#define RES_32KCLKOUT 26 519#define RES_32KCLKOUT 26
425#define RES_RESET 27 520#define RES_RESET 27
426/* Power Reference */ 521/* Power Reference */
427#define RES_Main_Ref 28 522#define RES_MAIN_REF 28
428 523
429#define TOTAL_RESOURCES 28 524#define TOTAL_RESOURCES 28
430/* 525/*
@@ -516,6 +611,16 @@ enum twl4030_usb_mode {
516 611
517struct twl4030_usb_data { 612struct twl4030_usb_data {
518 enum twl4030_usb_mode usb_mode; 613 enum twl4030_usb_mode usb_mode;
614 unsigned long features;
615
616 int (*phy_init)(struct device *dev);
617 int (*phy_exit)(struct device *dev);
618 /* Power on/off the PHY */
619 int (*phy_power)(struct device *dev, int iD, int on);
620 /* enable/disable phy clocks */
621 int (*phy_set_clock)(struct device *dev, int on);
622 /* suspend/resume of phy */
623 int (*phy_suspend)(struct device *dev, int suspend);
519}; 624};
520 625
521struct twl4030_ins { 626struct twl4030_ins {
@@ -553,14 +658,16 @@ extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
553extern int twl4030_remove_script(u8 flags); 658extern int twl4030_remove_script(u8 flags);
554 659
555struct twl4030_codec_audio_data { 660struct twl4030_codec_audio_data {
556 unsigned int audio_mclk; 661 unsigned int digimic_delay; /* in ms */
557 unsigned int ramp_delay_value; 662 unsigned int ramp_delay_value;
663 unsigned int offset_cncl_path;
664 unsigned int check_defaults:1;
665 unsigned int reset_registers:1;
558 unsigned int hs_extmute:1; 666 unsigned int hs_extmute:1;
559 void (*set_hs_extmute)(int mute); 667 void (*set_hs_extmute)(int mute);
560}; 668};
561 669
562struct twl4030_codec_vibra_data { 670struct twl4030_codec_vibra_data {
563 unsigned int audio_mclk;
564 unsigned int coexist; 671 unsigned int coexist;
565}; 672};
566 673
@@ -610,6 +717,21 @@ struct twl4030_platform_data {
610 struct regulator_init_data *vana; 717 struct regulator_init_data *vana;
611 struct regulator_init_data *vcxio; 718 struct regulator_init_data *vcxio;
612 struct regulator_init_data *vusb; 719 struct regulator_init_data *vusb;
720 struct regulator_init_data *clk32kg;
721 /* TWL6025 LDO regulators */
722 struct regulator_init_data *ldo1;
723 struct regulator_init_data *ldo2;
724 struct regulator_init_data *ldo3;
725 struct regulator_init_data *ldo4;
726 struct regulator_init_data *ldo5;
727 struct regulator_init_data *ldo6;
728 struct regulator_init_data *ldo7;
729 struct regulator_init_data *ldoln;
730 struct regulator_init_data *ldousb;
731 /* TWL6025 DCDC regulators */
732 struct regulator_init_data *smps3;
733 struct regulator_init_data *smps4;
734 struct regulator_init_data *vio6025;
613}; 735};
614 736
615/*----------------------------------------------------------------------*/ 737/*----------------------------------------------------------------------*/
@@ -689,5 +811,23 @@ static inline int twl4030charger_usb_en(int enable) { return 0; }
689 811
690/* INTERNAL LDOs */ 812/* INTERNAL LDOs */
691#define TWL6030_REG_VRTC 47 813#define TWL6030_REG_VRTC 47
814#define TWL6030_REG_CLK32KG 48
815
816/* LDOs on 6025 have different names */
817#define TWL6025_REG_LDO2 49
818#define TWL6025_REG_LDO4 50
819#define TWL6025_REG_LDO3 51
820#define TWL6025_REG_LDO5 52
821#define TWL6025_REG_LDO1 53
822#define TWL6025_REG_LDO7 54
823#define TWL6025_REG_LDO6 55
824#define TWL6025_REG_LDOLN 56
825#define TWL6025_REG_LDOUSB 57
826
827/* 6025 DCDC supplies */
828#define TWL6025_REG_SMPS3 58
829#define TWL6025_REG_SMPS4 59
830#define TWL6025_REG_VIO 60
831
692 832
693#endif /* End of __TWL4030_H */ 833#endif /* End of __TWL4030_H */
diff --git a/include/linux/i2c/twl4030-madc.h b/include/linux/i2c/twl4030-madc.h
new file mode 100644
index 000000000000..6427d298fbfc
--- /dev/null
+++ b/include/linux/i2c/twl4030-madc.h
@@ -0,0 +1,141 @@
1/*
2 * twl4030_madc.h - Header for TWL4030 MADC
3 *
4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 * J Keerthy <j-keerthy@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 */
22
23#ifndef _TWL4030_MADC_H
24#define _TWL4030_MADC_H
25
26struct twl4030_madc_conversion_method {
27 u8 sel;
28 u8 avg;
29 u8 rbase;
30 u8 ctrl;
31};
32
33#define TWL4030_MADC_MAX_CHANNELS 16
34
35
36/*
37 * twl4030_madc_request- madc request packet for channel conversion
38 * @channels: 16 bit bitmap for individual channels
39 * @do_avgP: sample the input channel for 4 consecutive cycles
40 * @method: RT, SW1, SW2
41 * @type: Polling or interrupt based method
42 */
43
44struct twl4030_madc_request {
45 unsigned long channels;
46 u16 do_avg;
47 u16 method;
48 u16 type;
49 bool active;
50 bool result_pending;
51 int rbuf[TWL4030_MADC_MAX_CHANNELS];
52 void (*func_cb)(int len, int channels, int *buf);
53};
54
55enum conversion_methods {
56 TWL4030_MADC_RT,
57 TWL4030_MADC_SW1,
58 TWL4030_MADC_SW2,
59 TWL4030_MADC_NUM_METHODS
60};
61
62enum sample_type {
63 TWL4030_MADC_WAIT,
64 TWL4030_MADC_IRQ_ONESHOT,
65 TWL4030_MADC_IRQ_REARM
66};
67
68#define TWL4030_MADC_CTRL1 0x00
69#define TWL4030_MADC_CTRL2 0x01
70
71#define TWL4030_MADC_RTSELECT_LSB 0x02
72#define TWL4030_MADC_SW1SELECT_LSB 0x06
73#define TWL4030_MADC_SW2SELECT_LSB 0x0A
74
75#define TWL4030_MADC_RTAVERAGE_LSB 0x04
76#define TWL4030_MADC_SW1AVERAGE_LSB 0x08
77#define TWL4030_MADC_SW2AVERAGE_LSB 0x0C
78
79#define TWL4030_MADC_CTRL_SW1 0x12
80#define TWL4030_MADC_CTRL_SW2 0x13
81
82#define TWL4030_MADC_RTCH0_LSB 0x17
83#define TWL4030_MADC_GPCH0_LSB 0x37
84
85#define TWL4030_MADC_MADCON (1 << 0) /* MADC power on */
86#define TWL4030_MADC_BUSY (1 << 0) /* MADC busy */
87/* MADC conversion completion */
88#define TWL4030_MADC_EOC_SW (1 << 1)
89/* MADC SWx start conversion */
90#define TWL4030_MADC_SW_START (1 << 5)
91#define TWL4030_MADC_ADCIN0 (1 << 0)
92#define TWL4030_MADC_ADCIN1 (1 << 1)
93#define TWL4030_MADC_ADCIN2 (1 << 2)
94#define TWL4030_MADC_ADCIN3 (1 << 3)
95#define TWL4030_MADC_ADCIN4 (1 << 4)
96#define TWL4030_MADC_ADCIN5 (1 << 5)
97#define TWL4030_MADC_ADCIN6 (1 << 6)
98#define TWL4030_MADC_ADCIN7 (1 << 7)
99#define TWL4030_MADC_ADCIN8 (1 << 8)
100#define TWL4030_MADC_ADCIN9 (1 << 9)
101#define TWL4030_MADC_ADCIN10 (1 << 10)
102#define TWL4030_MADC_ADCIN11 (1 << 11)
103#define TWL4030_MADC_ADCIN12 (1 << 12)
104#define TWL4030_MADC_ADCIN13 (1 << 13)
105#define TWL4030_MADC_ADCIN14 (1 << 14)
106#define TWL4030_MADC_ADCIN15 (1 << 15)
107
108/* Fixed channels */
109#define TWL4030_MADC_BTEMP TWL4030_MADC_ADCIN1
110#define TWL4030_MADC_VBUS TWL4030_MADC_ADCIN8
111#define TWL4030_MADC_VBKB TWL4030_MADC_ADCIN9
112#define TWL4030_MADC_ICHG TWL4030_MADC_ADCIN10
113#define TWL4030_MADC_VCHG TWL4030_MADC_ADCIN11
114#define TWL4030_MADC_VBAT TWL4030_MADC_ADCIN12
115
116/* Step size and prescaler ratio */
117#define TEMP_STEP_SIZE 147
118#define TEMP_PSR_R 100
119#define CURR_STEP_SIZE 147
120#define CURR_PSR_R1 44
121#define CURR_PSR_R2 88
122
123#define TWL4030_BCI_BCICTL1 0x23
124#define TWL4030_BCI_CGAIN 0x020
125#define TWL4030_BCI_MESBAT (1 << 1)
126#define TWL4030_BCI_TYPEN (1 << 4)
127#define TWL4030_BCI_ITHEN (1 << 3)
128
129#define REG_BCICTL2 0x024
130#define TWL4030_BCI_ITHSENS 0x007
131
132struct twl4030_madc_user_parms {
133 int channel;
134 int average;
135 int status;
136 u16 result;
137};
138
139int twl4030_madc_conversion(struct twl4030_madc_request *conv);
140int twl4030_get_madc_conversion(int channel_no);
141#endif
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 9e7a12d6385d..a6deef4f4f67 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -826,7 +826,7 @@ static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct
826 * @c: I2O controller 826 * @c: I2O controller
827 * 827 *
828 * This function tries to get a message frame. If no message frame is 828 * This function tries to get a message frame. If no message frame is
829 * available do not wait until one is availabe (see also i2o_msg_get_wait). 829 * available do not wait until one is available (see also i2o_msg_get_wait).
830 * The returned pointer to the message frame is not in I/O memory, it is 830 * The returned pointer to the message frame is not in I/O memory, it is
831 * allocated from a mempool. But because a MFA is allocated from the 831 * allocated from a mempool. But because a MFA is allocated from the
832 * controller too it is guaranteed that i2o_msg_post() will never fail. 832 * controller too it is guaranteed that i2o_msg_post() will never fail.
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index 4c4c74ec5987..ba45e6bc0764 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -183,10 +183,10 @@ extern void icmpv6_cleanup(void);
183extern void icmpv6_param_prob(struct sk_buff *skb, 183extern void icmpv6_param_prob(struct sk_buff *skb,
184 u8 code, int pos); 184 u8 code, int pos);
185 185
186struct flowi; 186struct flowi6;
187struct in6_addr; 187struct in6_addr;
188extern void icmpv6_flow_init(struct sock *sk, 188extern void icmpv6_flow_init(struct sock *sk,
189 struct flowi *fl, 189 struct flowi6 *fl6,
190 u8 type, 190 u8 type,
191 const struct in6_addr *saddr, 191 const struct in6_addr *saddr,
192 const struct in6_addr *daddr, 192 const struct in6_addr *daddr,
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 072fe8c93e6f..42557851b12e 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -18,13 +18,13 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/completion.h> 19#include <linux/completion.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/mutex.h>
21#ifdef CONFIG_BLK_DEV_IDEACPI 22#ifdef CONFIG_BLK_DEV_IDEACPI
22#include <acpi/acpi.h> 23#include <acpi/acpi.h>
23#endif 24#endif
24#include <asm/byteorder.h> 25#include <asm/byteorder.h>
25#include <asm/system.h> 26#include <asm/system.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <asm/mutex.h>
28 28
29/* for request_sense */ 29/* for request_sense */
30#include <linux/cdrom.h> 30#include <linux/cdrom.h>
diff --git a/include/linux/idr.h b/include/linux/idr.h
index e968db71e33a..13a801f3d028 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -50,14 +50,14 @@
50 50
51struct idr_layer { 51struct idr_layer {
52 unsigned long bitmap; /* A zero bit means "space here" */ 52 unsigned long bitmap; /* A zero bit means "space here" */
53 struct idr_layer *ary[1<<IDR_BITS]; 53 struct idr_layer __rcu *ary[1<<IDR_BITS];
54 int count; /* When zero, we can release it */ 54 int count; /* When zero, we can release it */
55 int layer; /* distance from leaf */ 55 int layer; /* distance from leaf */
56 struct rcu_head rcu_head; 56 struct rcu_head rcu_head;
57}; 57};
58 58
59struct idr { 59struct idr {
60 struct idr_layer *top; 60 struct idr_layer __rcu *top;
61 struct idr_layer *id_free; 61 struct idr_layer *id_free;
62 int layers; /* only valid without concurrent changes */ 62 int layers; /* only valid without concurrent changes */
63 int id_free_cnt; 63 int id_free_cnt;
@@ -81,6 +81,7 @@ struct idr {
81#define _idr_rc_to_errno(rc) ((rc) == -1 ? -EAGAIN : -ENOSPC) 81#define _idr_rc_to_errno(rc) ((rc) == -1 ? -EAGAIN : -ENOSPC)
82 82
83/** 83/**
84 * DOC: idr sync
84 * idr synchronization (stolen from radix-tree.h) 85 * idr synchronization (stolen from radix-tree.h)
85 * 86 *
86 * idr_find() is able to be called locklessly, using RCU. The caller must 87 * idr_find() is able to be called locklessly, using RCU. The caller must
@@ -117,10 +118,13 @@ void idr_init(struct idr *idp);
117/* 118/*
118 * IDA - IDR based id allocator, use when translation from id to 119 * IDA - IDR based id allocator, use when translation from id to
119 * pointer isn't necessary. 120 * pointer isn't necessary.
121 *
122 * IDA_BITMAP_LONGS is calculated to be one less to accommodate
123 * ida_bitmap->nr_busy so that the whole struct fits in 128 bytes.
120 */ 124 */
121#define IDA_CHUNK_SIZE 128 /* 128 bytes per chunk */ 125#define IDA_CHUNK_SIZE 128 /* 128 bytes per chunk */
122#define IDA_BITMAP_LONGS (128 / sizeof(long) - 1) 126#define IDA_BITMAP_LONGS (IDA_CHUNK_SIZE / sizeof(long) - 1)
123#define IDA_BITMAP_BITS (IDA_BITMAP_LONGS * sizeof(long) * 8) 127#define IDA_BITMAP_BITS (IDA_BITMAP_LONGS * sizeof(long) * 8)
124 128
125struct ida_bitmap { 129struct ida_bitmap {
126 long nr_busy; 130 long nr_busy;
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 97b2eae6a22c..bf56b6f78270 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -122,6 +122,7 @@
122 122
123/* U-APSD queue for WMM IEs sent by AP */ 123/* U-APSD queue for WMM IEs sent by AP */
124#define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7) 124#define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7)
125#define IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK 0x0f
125 126
126/* U-APSD queues for WMM IEs sent by STA */ 127/* U-APSD queues for WMM IEs sent by STA */
127#define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0) 128#define IEEE80211_WMM_IE_STA_QOSINFO_AC_VO (1<<0)
@@ -535,7 +536,6 @@ struct ieee80211s_hdr {
535 __le32 seqnum; 536 __le32 seqnum;
536 u8 eaddr1[6]; 537 u8 eaddr1[6];
537 u8 eaddr2[6]; 538 u8 eaddr2[6];
538 u8 eaddr3[6];
539} __attribute__ ((packed)); 539} __attribute__ ((packed));
540 540
541/* Mesh flags */ 541/* Mesh flags */
@@ -884,6 +884,15 @@ struct ieee80211_ht_cap {
884#define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000 884#define IEEE80211_HT_CAP_40MHZ_INTOLERANT 0x4000
885#define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000 885#define IEEE80211_HT_CAP_LSIG_TXOP_PROT 0x8000
886 886
887/* 802.11n HT extended capabilities masks (for extended_ht_cap_info) */
888#define IEEE80211_HT_EXT_CAP_PCO 0x0001
889#define IEEE80211_HT_EXT_CAP_PCO_TIME 0x0006
890#define IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT 1
891#define IEEE80211_HT_EXT_CAP_MCS_FB 0x0300
892#define IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT 8
893#define IEEE80211_HT_EXT_CAP_HTC_SUP 0x0400
894#define IEEE80211_HT_EXT_CAP_RD_RESPONDER 0x0800
895
887/* 802.11n HT capability AMPDU settings (for ampdu_params_info) */ 896/* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
888#define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03 897#define IEEE80211_HT_AMPDU_PARM_FACTOR 0x03
889#define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C 898#define IEEE80211_HT_AMPDU_PARM_DENSITY 0x1C
@@ -959,7 +968,7 @@ struct ieee80211_ht_info {
959/* block-ack parameters */ 968/* block-ack parameters */
960#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 969#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
961#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C 970#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
962#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0 971#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
963#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 972#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
964#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 973#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
965 974
@@ -986,12 +995,22 @@ struct ieee80211_ht_info {
986#define WLAN_AUTH_OPEN 0 995#define WLAN_AUTH_OPEN 0
987#define WLAN_AUTH_SHARED_KEY 1 996#define WLAN_AUTH_SHARED_KEY 1
988#define WLAN_AUTH_FT 2 997#define WLAN_AUTH_FT 2
998#define WLAN_AUTH_SAE 3
989#define WLAN_AUTH_LEAP 128 999#define WLAN_AUTH_LEAP 128
990 1000
991#define WLAN_AUTH_CHALLENGE_LEN 128 1001#define WLAN_AUTH_CHALLENGE_LEN 128
992 1002
993#define WLAN_CAPABILITY_ESS (1<<0) 1003#define WLAN_CAPABILITY_ESS (1<<0)
994#define WLAN_CAPABILITY_IBSS (1<<1) 1004#define WLAN_CAPABILITY_IBSS (1<<1)
1005
1006/*
1007 * A mesh STA sets the ESS and IBSS capability bits to zero.
1008 * however, this holds true for p2p probe responses (in the p2p_find
1009 * phase) as well.
1010 */
1011#define WLAN_CAPABILITY_IS_STA_BSS(cap) \
1012 (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
1013
995#define WLAN_CAPABILITY_CF_POLLABLE (1<<2) 1014#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
996#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) 1015#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
997#define WLAN_CAPABILITY_PRIVACY (1<<4) 1016#define WLAN_CAPABILITY_PRIVACY (1<<4)
@@ -1072,6 +1091,10 @@ enum ieee80211_statuscode {
1072 WLAN_STATUS_NO_DIRECT_LINK = 48, 1091 WLAN_STATUS_NO_DIRECT_LINK = 48,
1073 WLAN_STATUS_STA_NOT_PRESENT = 49, 1092 WLAN_STATUS_STA_NOT_PRESENT = 49,
1074 WLAN_STATUS_STA_NOT_QSTA = 50, 1093 WLAN_STATUS_STA_NOT_QSTA = 50,
1094 /* 802.11s */
1095 WLAN_STATUS_ANTI_CLOG_REQUIRED = 76,
1096 WLAN_STATUS_FCG_NOT_SUPP = 78,
1097 WLAN_STATUS_STA_NO_TBTT = 78,
1075}; 1098};
1076 1099
1077 1100
@@ -1112,6 +1135,22 @@ enum ieee80211_reasoncode {
1112 WLAN_REASON_QSTA_REQUIRE_SETUP = 38, 1135 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
1113 WLAN_REASON_QSTA_TIMEOUT = 39, 1136 WLAN_REASON_QSTA_TIMEOUT = 39,
1114 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45, 1137 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
1138 /* 802.11s */
1139 WLAN_REASON_MESH_PEER_CANCELED = 52,
1140 WLAN_REASON_MESH_MAX_PEERS = 53,
1141 WLAN_REASON_MESH_CONFIG = 54,
1142 WLAN_REASON_MESH_CLOSE = 55,
1143 WLAN_REASON_MESH_MAX_RETRIES = 56,
1144 WLAN_REASON_MESH_CONFIRM_TIMEOUT = 57,
1145 WLAN_REASON_MESH_INVALID_GTK = 58,
1146 WLAN_REASON_MESH_INCONSISTENT_PARAM = 59,
1147 WLAN_REASON_MESH_INVALID_SECURITY = 60,
1148 WLAN_REASON_MESH_PATH_ERROR = 61,
1149 WLAN_REASON_MESH_PATH_NOFORWARD = 62,
1150 WLAN_REASON_MESH_PATH_DEST_UNREACHABLE = 63,
1151 WLAN_REASON_MAC_EXISTS_IN_MBSS = 64,
1152 WLAN_REASON_MESH_CHAN_REGULATORY = 65,
1153 WLAN_REASON_MESH_CHAN = 66,
1115}; 1154};
1116 1155
1117 1156
@@ -1139,20 +1178,33 @@ enum ieee80211_eid {
1139 WLAN_EID_TS_DELAY = 43, 1178 WLAN_EID_TS_DELAY = 43,
1140 WLAN_EID_TCLAS_PROCESSING = 44, 1179 WLAN_EID_TCLAS_PROCESSING = 44,
1141 WLAN_EID_QOS_CAPA = 46, 1180 WLAN_EID_QOS_CAPA = 46,
1142 /* 802.11s 1181 /* 802.11s */
1143 * 1182 WLAN_EID_MESH_CONFIG = 113,
1144 * All mesh EID numbers are pending IEEE 802.11 ANA approval. 1183 WLAN_EID_MESH_ID = 114,
1145 * The numbers have been incremented from those suggested in 1184 WLAN_EID_LINK_METRIC_REPORT = 115,
1146 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with 1185 WLAN_EID_CONGESTION_NOTIFICATION = 116,
1147 * EXT_SUPP_RATES. 1186 /* Note that the Peer Link IE has been replaced with the similar
1187 * Peer Management IE. We will keep the former definition until mesh
1188 * code is changed to comply with latest 802.11s drafts.
1148 */ 1189 */
1149 WLAN_EID_MESH_CONFIG = 51, 1190 WLAN_EID_PEER_LINK = 55, /* no longer in 802.11s drafts */
1150 WLAN_EID_MESH_ID = 52, 1191 WLAN_EID_PEER_MGMT = 117,
1151 WLAN_EID_PEER_LINK = 55, 1192 WLAN_EID_CHAN_SWITCH_PARAM = 118,
1152 WLAN_EID_PREQ = 68, 1193 WLAN_EID_MESH_AWAKE_WINDOW = 119,
1153 WLAN_EID_PREP = 69, 1194 WLAN_EID_BEACON_TIMING = 120,
1154 WLAN_EID_PERR = 70, 1195 WLAN_EID_MCCAOP_SETUP_REQ = 121,
1155 WLAN_EID_RANN = 49, /* compatible with FreeBSD */ 1196 WLAN_EID_MCCAOP_SETUP_RESP = 122,
1197 WLAN_EID_MCCAOP_ADVERT = 123,
1198 WLAN_EID_MCCAOP_TEARDOWN = 124,
1199 WLAN_EID_GANN = 125,
1200 WLAN_EID_RANN = 126,
1201 WLAN_EID_PREQ = 130,
1202 WLAN_EID_PREP = 131,
1203 WLAN_EID_PERR = 132,
1204 WLAN_EID_PXU = 137,
1205 WLAN_EID_PXUC = 138,
1206 WLAN_EID_AUTH_MESH_PEER_EXCH = 139,
1207 WLAN_EID_MIC = 140,
1156 1208
1157 WLAN_EID_PWR_CONSTRAINT = 32, 1209 WLAN_EID_PWR_CONSTRAINT = 32,
1158 WLAN_EID_PWR_CAPABILITY = 33, 1210 WLAN_EID_PWR_CAPABILITY = 33,
@@ -1189,6 +1241,9 @@ enum ieee80211_eid {
1189 WLAN_EID_BSS_AC_ACCESS_DELAY = 68, 1241 WLAN_EID_BSS_AC_ACCESS_DELAY = 68,
1190 WLAN_EID_RRM_ENABLED_CAPABILITIES = 70, 1242 WLAN_EID_RRM_ENABLED_CAPABILITIES = 70,
1191 WLAN_EID_MULTIPLE_BSSID = 71, 1243 WLAN_EID_MULTIPLE_BSSID = 71,
1244 WLAN_EID_BSS_COEX_2040 = 72,
1245 WLAN_EID_OVERLAP_BSS_SCAN_PARAM = 74,
1246 WLAN_EID_EXT_CAPABILITY = 127,
1192 1247
1193 WLAN_EID_MOBILITY_DOMAIN = 54, 1248 WLAN_EID_MOBILITY_DOMAIN = 54,
1194 WLAN_EID_FAST_BSS_TRANSITION = 55, 1249 WLAN_EID_FAST_BSS_TRANSITION = 55,
@@ -1211,9 +1266,13 @@ enum ieee80211_category {
1211 WLAN_CATEGORY_HT = 7, 1266 WLAN_CATEGORY_HT = 7,
1212 WLAN_CATEGORY_SA_QUERY = 8, 1267 WLAN_CATEGORY_SA_QUERY = 8,
1213 WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9, 1268 WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
1269 WLAN_CATEGORY_MESH_ACTION = 13,
1270 WLAN_CATEGORY_MULTIHOP_ACTION = 14,
1271 WLAN_CATEGORY_SELF_PROTECTED = 15,
1214 WLAN_CATEGORY_WMM = 17, 1272 WLAN_CATEGORY_WMM = 17,
1215 WLAN_CATEGORY_MESH_PLINK = 30, /* Pending ANA approval */ 1273 /* TODO: remove MESH_PATH_SEL after mesh is updated
1216 WLAN_CATEGORY_MESH_PATH_SEL = 32, /* Pending ANA approval */ 1274 * to current 802.11s draft */
1275 WLAN_CATEGORY_MESH_PATH_SEL = 32,
1217 WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126, 1276 WLAN_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
1218 WLAN_CATEGORY_VENDOR_SPECIFIC = 127, 1277 WLAN_CATEGORY_VENDOR_SPECIFIC = 127,
1219}; 1278};
@@ -1248,6 +1307,31 @@ enum ieee80211_key_len {
1248 WLAN_KEY_LEN_AES_CMAC = 16, 1307 WLAN_KEY_LEN_AES_CMAC = 16,
1249}; 1308};
1250 1309
1310/**
1311 * enum - mesh path selection protocol identifier
1312 *
1313 * @IEEE80211_PATH_PROTOCOL_HWMP: the default path selection protocol
1314 * @IEEE80211_PATH_PROTOCOL_VENDOR: a vendor specific protocol that will
1315 * be specified in a vendor specific information element
1316 */
1317enum {
1318 IEEE80211_PATH_PROTOCOL_HWMP = 0,
1319 IEEE80211_PATH_PROTOCOL_VENDOR = 255,
1320};
1321
1322/**
1323 * enum - mesh path selection metric identifier
1324 *
1325 * @IEEE80211_PATH_METRIC_AIRTIME: the default path selection metric
1326 * @IEEE80211_PATH_METRIC_VENDOR: a vendor specific metric that will be
1327 * specified in a vendor specific information element
1328 */
1329enum {
1330 IEEE80211_PATH_METRIC_AIRTIME = 0,
1331 IEEE80211_PATH_METRIC_VENDOR = 255,
1332};
1333
1334
1251/* 1335/*
1252 * IEEE 802.11-2007 7.3.2.9 Country information element 1336 * IEEE 802.11-2007 7.3.2.9 Country information element
1253 * 1337 *
@@ -1258,6 +1342,9 @@ enum ieee80211_key_len {
1258/* Although the spec says 8 I'm seeing 6 in practice */ 1342/* Although the spec says 8 I'm seeing 6 in practice */
1259#define IEEE80211_COUNTRY_IE_MIN_LEN 6 1343#define IEEE80211_COUNTRY_IE_MIN_LEN 6
1260 1344
1345/* The Country String field of the element shall be 3 octets in length */
1346#define IEEE80211_COUNTRY_STRING_LEN 3
1347
1261/* 1348/*
1262 * For regulatory extension stuff see IEEE 802.11-2007 1349 * For regulatory extension stuff see IEEE 802.11-2007
1263 * Annex I (page 1141) and Annex J (page 1147). Also 1350 * Annex I (page 1141) and Annex J (page 1147). Also
@@ -1351,6 +1438,8 @@ enum ieee80211_sa_query_action {
1351/* AKM suite selectors */ 1438/* AKM suite selectors */
1352#define WLAN_AKM_SUITE_8021X 0x000FAC01 1439#define WLAN_AKM_SUITE_8021X 0x000FAC01
1353#define WLAN_AKM_SUITE_PSK 0x000FAC02 1440#define WLAN_AKM_SUITE_PSK 0x000FAC02
1441#define WLAN_AKM_SUITE_SAE 0x000FAC08
1442#define WLAN_AKM_SUITE_FT_OVER_SAE 0x000FAC09
1354 1443
1355#define WLAN_MAX_KEY_LEN 32 1444#define WLAN_MAX_KEY_LEN 32
1356 1445
@@ -1435,6 +1524,7 @@ static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1435 category = ((u8 *) hdr) + 24; 1524 category = ((u8 *) hdr) + 24;
1436 return *category != WLAN_CATEGORY_PUBLIC && 1525 return *category != WLAN_CATEGORY_PUBLIC &&
1437 *category != WLAN_CATEGORY_HT && 1526 *category != WLAN_CATEGORY_HT &&
1527 *category != WLAN_CATEGORY_SELF_PROTECTED &&
1438 *category != WLAN_CATEGORY_VENDOR_SPECIFIC; 1528 *category != WLAN_CATEGORY_VENDOR_SPECIFIC;
1439 } 1529 }
1440 1530
diff --git a/include/linux/if.h b/include/linux/if.h
index 53558ec59e1b..3bc63e6a02f7 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -71,10 +71,11 @@
71 * release skb->dst 71 * release skb->dst
72 */ 72 */
73#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ 73#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */
74#define IFF_IN_NETPOLL 0x1000 /* whether we are processing netpoll */ 74#define IFF_DISABLE_NETPOLL 0x1000 /* disable netpoll at run-time */
75#define IFF_DISABLE_NETPOLL 0x2000 /* disable netpoll at run-time */ 75#define IFF_MACVLAN_PORT 0x2000 /* device used as macvlan port */
76#define IFF_MACVLAN_PORT 0x4000 /* device used as macvlan port */ 76#define IFF_BRIDGE_PORT 0x4000 /* device used as bridge port */
77#define IFF_BRIDGE_PORT 0x8000 /* device used as bridge port */ 77#define IFF_OVS_DATAPATH 0x8000 /* device used as Open vSwitch
78 * datapath port */
78 79
79#define IF_GET_IFACE 0x0001 /* for querying only */ 80#define IF_GET_IFACE 0x0001 /* for querying only */
80#define IF_GET_PROTO 0x0002 81#define IF_GET_PROTO 0x0002
diff --git a/include/linux/if_alg.h b/include/linux/if_alg.h
new file mode 100644
index 000000000000..0f9acce5b1ff
--- /dev/null
+++ b/include/linux/if_alg.h
@@ -0,0 +1,40 @@
1/*
2 * if_alg: User-space algorithm interface
3 *
4 * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _LINUX_IF_ALG_H
14#define _LINUX_IF_ALG_H
15
16#include <linux/types.h>
17
18struct sockaddr_alg {
19 __u16 salg_family;
20 __u8 salg_type[14];
21 __u32 salg_feat;
22 __u32 salg_mask;
23 __u8 salg_name[64];
24};
25
26struct af_alg_iv {
27 __u32 ivlen;
28 __u8 iv[0];
29};
30
31/* Socket options */
32#define ALG_SET_KEY 1
33#define ALG_SET_IV 2
34#define ALG_SET_OP 3
35
36/* Operations */
37#define ALG_OP_DECRYPT 0
38#define ALG_OP_ENCRYPT 1
39
40#endif /* _LINUX_IF_ALG_H */
diff --git a/include/linux/if_bonding.h b/include/linux/if_bonding.h
index 2c7994372bde..a17edda8a781 100644
--- a/include/linux/if_bonding.h
+++ b/include/linux/if_bonding.h
@@ -84,6 +84,9 @@
84#define BOND_DEFAULT_MAX_BONDS 1 /* Default maximum number of devices to support */ 84#define BOND_DEFAULT_MAX_BONDS 1 /* Default maximum number of devices to support */
85 85
86#define BOND_DEFAULT_TX_QUEUES 16 /* Default number of tx queues per device */ 86#define BOND_DEFAULT_TX_QUEUES 16 /* Default number of tx queues per device */
87
88#define BOND_DEFAULT_RESEND_IGMP 1 /* Default number of IGMP membership reports */
89
87/* hashing types */ 90/* hashing types */
88#define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */ 91#define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */
89#define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ (TCP || UDP)) */ 92#define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ (TCP || UDP)) */
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index 0d241a5c4909..dd3f20139640 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -102,7 +102,9 @@ struct __fdb_entry {
102#include <linux/netdevice.h> 102#include <linux/netdevice.h>
103 103
104extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *)); 104extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
105extern int (*br_should_route_hook)(struct sk_buff *skb); 105
106typedef int br_should_route_hook_t(struct sk_buff *skb);
107extern br_should_route_hook_t __rcu *br_should_route_hook;
106 108
107#endif 109#endif
108 110
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index bed7a4682b90..0065ffd3226b 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -72,6 +72,7 @@
72#define ETH_P_MPLS_UC 0x8847 /* MPLS Unicast traffic */ 72#define ETH_P_MPLS_UC 0x8847 /* MPLS Unicast traffic */
73#define ETH_P_MPLS_MC 0x8848 /* MPLS Multicast traffic */ 73#define ETH_P_MPLS_MC 0x8848 /* MPLS Multicast traffic */
74#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ 74#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
75#define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */
75#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport 76#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
76 * over Ethernet 77 * over Ethernet
77 */ 78 */
@@ -131,14 +132,9 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
131 132
132int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); 133int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
133 134
134#ifdef CONFIG_SYSCTL 135int mac_pton(const char *s, u8 *mac);
135extern struct ctl_table ether_table[];
136#endif
137
138extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); 136extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
139 137
140#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
141
142#endif 138#endif
143 139
144#endif /* _LINUX_IF_ETHER_H */ 140#endif /* _LINUX_IF_ETHER_H */
diff --git a/include/linux/if_infiniband.h b/include/linux/if_infiniband.h
index 3e659ec7dfdd..7d958475d4ac 100644
--- a/include/linux/if_infiniband.h
+++ b/include/linux/if_infiniband.h
@@ -5,7 +5,7 @@
5 * <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD 5 * <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
6 * license, available in the LICENSE.TXT file accompanying this 6 * license, available in the LICENSE.TXT file accompanying this
7 * software. These details are also available at 7 * software. These details are also available at
8 * <http://openib.org/license.html>. 8 * <http://www.openfabrics.org/software_license.htm>.
9 * 9 *
10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 11 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 2fc66dd783ee..0ee969a5593d 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -80,6 +80,24 @@ struct rtnl_link_ifmap {
80 __u8 port; 80 __u8 port;
81}; 81};
82 82
83/*
84 * IFLA_AF_SPEC
85 * Contains nested attributes for address family specific attributes.
86 * Each address family may create a attribute with the address family
87 * number as type and create its own attribute structure in it.
88 *
89 * Example:
90 * [IFLA_AF_SPEC] = {
91 * [AF_INET] = {
92 * [IFLA_INET_CONF] = ...,
93 * },
94 * [AF_INET6] = {
95 * [IFLA_INET6_FLAGS] = ...,
96 * [IFLA_INET6_CONF] = ...,
97 * }
98 * }
99 */
100
83enum { 101enum {
84 IFLA_UNSPEC, 102 IFLA_UNSPEC,
85 IFLA_ADDRESS, 103 IFLA_ADDRESS,
@@ -116,6 +134,9 @@ enum {
116 IFLA_STATS64, 134 IFLA_STATS64,
117 IFLA_VF_PORTS, 135 IFLA_VF_PORTS,
118 IFLA_PORT_SELF, 136 IFLA_PORT_SELF,
137 IFLA_AF_SPEC,
138 IFLA_GROUP, /* Group the device belongs to */
139 IFLA_NET_NS_FD,
119 __IFLA_MAX 140 __IFLA_MAX
120}; 141};
121 142
@@ -128,6 +149,14 @@ enum {
128#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) 149#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
129#endif 150#endif
130 151
152enum {
153 IFLA_INET_UNSPEC,
154 IFLA_INET_CONF,
155 __IFLA_INET_MAX,
156};
157
158#define IFLA_INET_MAX (__IFLA_INET_MAX - 1)
159
131/* ifi_flags. 160/* ifi_flags.
132 161
133 IFF_* flags. 162 IFF_* flags.
@@ -232,6 +261,7 @@ enum macvlan_mode {
232 MACVLAN_MODE_PRIVATE = 1, /* don't talk to other macvlans */ 261 MACVLAN_MODE_PRIVATE = 1, /* don't talk to other macvlans */
233 MACVLAN_MODE_VEPA = 2, /* talk to other ports through ext bridge */ 262 MACVLAN_MODE_VEPA = 2, /* talk to other ports through ext bridge */
234 MACVLAN_MODE_BRIDGE = 4, /* talk to bridge ports directly */ 263 MACVLAN_MODE_BRIDGE = 4, /* talk to bridge ports directly */
264 MACVLAN_MODE_PASSTHRU = 8,/* take over the underlying device */
235}; 265};
236 266
237/* SR-IOV virtual function management section */ 267/* SR-IOV virtual function management section */
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
index 35280b302290..e28b2e4959d4 100644
--- a/include/linux/if_macvlan.h
+++ b/include/linux/if_macvlan.h
@@ -25,50 +25,63 @@ struct macvlan_port;
25struct macvtap_queue; 25struct macvtap_queue;
26 26
27/** 27/**
28 * struct macvlan_rx_stats - MACVLAN percpu rx stats 28 * struct macvlan_pcpu_stats - MACVLAN percpu stats
29 * @rx_packets: number of received packets 29 * @rx_packets: number of received packets
30 * @rx_bytes: number of received bytes 30 * @rx_bytes: number of received bytes
31 * @rx_multicast: number of received multicast packets 31 * @rx_multicast: number of received multicast packets
32 * @tx_packets: number of transmitted packets
33 * @tx_bytes: number of transmitted bytes
32 * @syncp: synchronization point for 64bit counters 34 * @syncp: synchronization point for 64bit counters
33 * @rx_errors: number of errors 35 * @rx_errors: number of rx errors
36 * @tx_dropped: number of tx dropped packets
34 */ 37 */
35struct macvlan_rx_stats { 38struct macvlan_pcpu_stats {
36 u64 rx_packets; 39 u64 rx_packets;
37 u64 rx_bytes; 40 u64 rx_bytes;
38 u64 rx_multicast; 41 u64 rx_multicast;
42 u64 tx_packets;
43 u64 tx_bytes;
39 struct u64_stats_sync syncp; 44 struct u64_stats_sync syncp;
40 unsigned long rx_errors; 45 u32 rx_errors;
46 u32 tx_dropped;
41}; 47};
42 48
49/*
50 * Maximum times a macvtap device can be opened. This can be used to
51 * configure the number of receive queue, e.g. for multiqueue virtio.
52 */
53#define MAX_MACVTAP_QUEUES (NR_CPUS < 16 ? NR_CPUS : 16)
54
43struct macvlan_dev { 55struct macvlan_dev {
44 struct net_device *dev; 56 struct net_device *dev;
45 struct list_head list; 57 struct list_head list;
46 struct hlist_node hlist; 58 struct hlist_node hlist;
47 struct macvlan_port *port; 59 struct macvlan_port *port;
48 struct net_device *lowerdev; 60 struct net_device *lowerdev;
49 struct macvlan_rx_stats __percpu *rx_stats; 61 struct macvlan_pcpu_stats __percpu *pcpu_stats;
50 enum macvlan_mode mode; 62 enum macvlan_mode mode;
51 int (*receive)(struct sk_buff *skb); 63 int (*receive)(struct sk_buff *skb);
52 int (*forward)(struct net_device *dev, struct sk_buff *skb); 64 int (*forward)(struct net_device *dev, struct sk_buff *skb);
53 struct macvtap_queue *tap; 65 struct macvtap_queue *taps[MAX_MACVTAP_QUEUES];
66 int numvtaps;
54}; 67};
55 68
56static inline void macvlan_count_rx(const struct macvlan_dev *vlan, 69static inline void macvlan_count_rx(const struct macvlan_dev *vlan,
57 unsigned int len, bool success, 70 unsigned int len, bool success,
58 bool multicast) 71 bool multicast)
59{ 72{
60 struct macvlan_rx_stats *rx_stats;
61
62 rx_stats = this_cpu_ptr(vlan->rx_stats);
63 if (likely(success)) { 73 if (likely(success)) {
64 u64_stats_update_begin(&rx_stats->syncp); 74 struct macvlan_pcpu_stats *pcpu_stats;
65 rx_stats->rx_packets++;; 75
66 rx_stats->rx_bytes += len; 76 pcpu_stats = this_cpu_ptr(vlan->pcpu_stats);
77 u64_stats_update_begin(&pcpu_stats->syncp);
78 pcpu_stats->rx_packets++;
79 pcpu_stats->rx_bytes += len;
67 if (multicast) 80 if (multicast)
68 rx_stats->rx_multicast++; 81 pcpu_stats->rx_multicast++;
69 u64_stats_update_end(&rx_stats->syncp); 82 u64_stats_update_end(&pcpu_stats->syncp);
70 } else { 83 } else {
71 rx_stats->rx_errors++; 84 this_cpu_inc(vlan->pcpu_stats->rx_errors);
72 } 85 }
73} 86}
74 87
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
index 72bfa5a034dd..7b318630139f 100644
--- a/include/linux/if_packet.h
+++ b/include/linux/if_packet.h
@@ -62,6 +62,7 @@ struct tpacket_auxdata {
62 __u16 tp_mac; 62 __u16 tp_mac;
63 __u16 tp_net; 63 __u16 tp_net;
64 __u16 tp_vlan_tci; 64 __u16 tp_vlan_tci;
65 __u16 tp_padding;
65}; 66};
66 67
67/* Rx ring - header status */ 68/* Rx ring - header status */
@@ -70,6 +71,7 @@ struct tpacket_auxdata {
70#define TP_STATUS_COPY 0x2 71#define TP_STATUS_COPY 0x2
71#define TP_STATUS_LOSING 0x4 72#define TP_STATUS_LOSING 0x4
72#define TP_STATUS_CSUMNOTREADY 0x8 73#define TP_STATUS_CSUMNOTREADY 0x8
74#define TP_STATUS_VLAN_VALID 0x10 /* auxdata has valid tp_vlan_tci */
73 75
74/* Tx ring - header status */ 76/* Tx ring - header status */
75#define TP_STATUS_AVAILABLE 0x0 77#define TP_STATUS_AVAILABLE 0x0
@@ -100,6 +102,7 @@ struct tpacket2_hdr {
100 __u32 tp_sec; 102 __u32 tp_sec;
101 __u32 tp_nsec; 103 __u32 tp_nsec;
102 __u16 tp_vlan_tci; 104 __u16 tp_vlan_tci;
105 __u16 tp_padding;
103}; 106};
104 107
105#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll)) 108#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
diff --git a/include/linux/if_ppp.h b/include/linux/if_ppp.h
index fcef103aa3f6..c9ad38322576 100644
--- a/include/linux/if_ppp.h
+++ b/include/linux/if_ppp.h
@@ -114,14 +114,14 @@ struct pppol2tp_ioc_stats {
114 __u16 tunnel_id; /* redundant */ 114 __u16 tunnel_id; /* redundant */
115 __u16 session_id; /* if zero, get tunnel stats */ 115 __u16 session_id; /* if zero, get tunnel stats */
116 __u32 using_ipsec:1; /* valid only for session_id == 0 */ 116 __u32 using_ipsec:1; /* valid only for session_id == 0 */
117 aligned_u64 tx_packets; 117 __aligned_u64 tx_packets;
118 aligned_u64 tx_bytes; 118 __aligned_u64 tx_bytes;
119 aligned_u64 tx_errors; 119 __aligned_u64 tx_errors;
120 aligned_u64 rx_packets; 120 __aligned_u64 rx_packets;
121 aligned_u64 rx_bytes; 121 __aligned_u64 rx_bytes;
122 aligned_u64 rx_seq_discards; 122 __aligned_u64 rx_seq_discards;
123 aligned_u64 rx_oos_packets; 123 __aligned_u64 rx_oos_packets;
124 aligned_u64 rx_errors; 124 __aligned_u64 rx_errors;
125}; 125};
126 126
127#define ifr__name b.ifr_ifrn.ifrn_name 127#define ifr__name b.ifr_ifrn.ifrn_name
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index 27741e05446f..397921b09ef9 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -40,25 +40,35 @@
40 * PPPoE addressing definition 40 * PPPoE addressing definition
41 */ 41 */
42typedef __be16 sid_t; 42typedef __be16 sid_t;
43struct pppoe_addr{ 43struct pppoe_addr {
44 sid_t sid; /* Session identifier */ 44 sid_t sid; /* Session identifier */
45 unsigned char remote[ETH_ALEN]; /* Remote address */ 45 unsigned char remote[ETH_ALEN]; /* Remote address */
46 char dev[IFNAMSIZ]; /* Local device to use */ 46 char dev[IFNAMSIZ]; /* Local device to use */
47}; 47};
48 48
49/************************************************************************ 49/************************************************************************
50 * Protocols supported by AF_PPPOX 50 * PPTP addressing definition
51 */ 51 */
52struct pptp_addr {
53 __be16 call_id;
54 struct in_addr sin_addr;
55};
56
57/************************************************************************
58 * Protocols supported by AF_PPPOX
59 */
52#define PX_PROTO_OE 0 /* Currently just PPPoE */ 60#define PX_PROTO_OE 0 /* Currently just PPPoE */
53#define PX_PROTO_OL2TP 1 /* Now L2TP also */ 61#define PX_PROTO_OL2TP 1 /* Now L2TP also */
54#define PX_MAX_PROTO 2 62#define PX_PROTO_PPTP 2
55 63#define PX_MAX_PROTO 3
56struct sockaddr_pppox { 64
57 sa_family_t sa_family; /* address family, AF_PPPOX */ 65struct sockaddr_pppox {
58 unsigned int sa_protocol; /* protocol identifier */ 66 sa_family_t sa_family; /* address family, AF_PPPOX */
59 union{ 67 unsigned int sa_protocol; /* protocol identifier */
60 struct pppoe_addr pppoe; 68 union {
61 }sa_addr; 69 struct pppoe_addr pppoe;
70 struct pptp_addr pptp;
71 } sa_addr;
62} __attribute__((packed)); 72} __attribute__((packed));
63 73
64/* The use of the above union isn't viable because the size of this 74/* The use of the above union isn't viable because the size of this
@@ -150,15 +160,23 @@ struct pppoe_opt {
150 relayed to (PPPoE relaying) */ 160 relayed to (PPPoE relaying) */
151}; 161};
152 162
163struct pptp_opt {
164 struct pptp_addr src_addr;
165 struct pptp_addr dst_addr;
166 u32 ack_sent, ack_recv;
167 u32 seq_sent, seq_recv;
168 int ppp_flags;
169};
153#include <net/sock.h> 170#include <net/sock.h>
154 171
155struct pppox_sock { 172struct pppox_sock {
156 /* struct sock must be the first member of pppox_sock */ 173 /* struct sock must be the first member of pppox_sock */
157 struct sock sk; 174 struct sock sk;
158 struct ppp_channel chan; 175 struct ppp_channel chan;
159 struct pppox_sock *next; /* for hash table */ 176 struct pppox_sock *next; /* for hash table */
160 union { 177 union {
161 struct pppoe_opt pppoe; 178 struct pppoe_opt pppoe;
179 struct pptp_opt pptp;
162 } proto; 180 } proto;
163 __be16 num; 181 __be16 num;
164}; 182};
@@ -186,7 +204,7 @@ struct pppox_proto {
186 struct module *owner; 204 struct module *owner;
187}; 205};
188 206
189extern int register_pppox_proto(int proto_num, struct pppox_proto *pp); 207extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
190extern void unregister_pppox_proto(int proto_num); 208extern void unregister_pppox_proto(int proto_num);
191extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */ 209extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
192extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 210extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 3d870fda8c4f..affa27380b72 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -16,6 +16,7 @@
16#ifdef __KERNEL__ 16#ifdef __KERNEL__
17#include <linux/netdevice.h> 17#include <linux/netdevice.h>
18#include <linux/etherdevice.h> 18#include <linux/etherdevice.h>
19#include <linux/rtnetlink.h>
19 20
20#define VLAN_HLEN 4 /* The additional bytes (on top of the Ethernet header) 21#define VLAN_HLEN 4 /* The additional bytes (on top of the Ethernet header)
21 * that VLAN requires. 22 * that VLAN requires.
@@ -68,6 +69,7 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
68#define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator */ 69#define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator */
69#define VLAN_TAG_PRESENT VLAN_CFI_MASK 70#define VLAN_TAG_PRESENT VLAN_CFI_MASK
70#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ 71#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */
72#define VLAN_N_VID 4096
71 73
72/* found in socket.c */ 74/* found in socket.c */
73extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); 75extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
@@ -76,16 +78,14 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
76 * depends on completely exhausting the VLAN identifier space. Thus 78 * depends on completely exhausting the VLAN identifier space. Thus
77 * it gives constant time look-up, but in many cases it wastes memory. 79 * it gives constant time look-up, but in many cases it wastes memory.
78 */ 80 */
79#define VLAN_GROUP_ARRAY_LEN 4096
80#define VLAN_GROUP_ARRAY_SPLIT_PARTS 8 81#define VLAN_GROUP_ARRAY_SPLIT_PARTS 8
81#define VLAN_GROUP_ARRAY_PART_LEN (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS) 82#define VLAN_GROUP_ARRAY_PART_LEN (VLAN_N_VID/VLAN_GROUP_ARRAY_SPLIT_PARTS)
82 83
83struct vlan_group { 84struct vlan_group {
84 struct net_device *real_dev; /* The ethernet(like) device 85 struct net_device *real_dev; /* The ethernet(like) device
85 * the vlan is attached to. 86 * the vlan is attached to.
86 */ 87 */
87 unsigned int nr_vlans; 88 unsigned int nr_vlans;
88 int killall;
89 struct hlist_node hlist; /* linked list */ 89 struct hlist_node hlist; /* linked list */
90 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS]; 90 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS];
91 struct rcu_head rcu; 91 struct rcu_head rcu;
@@ -110,16 +110,34 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
110 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; 110 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
111} 111}
112 112
113static inline int is_vlan_dev(struct net_device *dev)
114{
115 return dev->priv_flags & IFF_802_1Q_VLAN;
116}
117
113#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT) 118#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT)
114#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT) 119#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
115 120
116#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 121#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
122/* Must be invoked with rcu_read_lock or with RTNL. */
123static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
124 u16 vlan_id)
125{
126 struct vlan_group *grp = rcu_dereference_rtnl(real_dev->vlgrp);
127
128 if (grp)
129 return vlan_group_get_device(grp, vlan_id);
130
131 return NULL;
132}
133
117extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); 134extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
118extern u16 vlan_dev_vlan_id(const struct net_device *dev); 135extern u16 vlan_dev_vlan_id(const struct net_device *dev);
119 136
120extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, 137extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
121 u16 vlan_tci, int polling); 138 u16 vlan_tci, int polling);
122extern int vlan_hwaccel_do_receive(struct sk_buff *skb); 139extern bool vlan_do_receive(struct sk_buff **skb);
140extern struct sk_buff *vlan_untag(struct sk_buff *skb);
123extern gro_result_t 141extern gro_result_t
124vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp, 142vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
125 unsigned int vlan_tci, struct sk_buff *skb); 143 unsigned int vlan_tci, struct sk_buff *skb);
@@ -128,6 +146,12 @@ vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
128 unsigned int vlan_tci); 146 unsigned int vlan_tci);
129 147
130#else 148#else
149static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
150 u16 vlan_id)
151{
152 return NULL;
153}
154
131static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev) 155static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
132{ 156{
133 BUG(); 157 BUG();
@@ -147,9 +171,16 @@ static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
147 return NET_XMIT_SUCCESS; 171 return NET_XMIT_SUCCESS;
148} 172}
149 173
150static inline int vlan_hwaccel_do_receive(struct sk_buff *skb) 174static inline bool vlan_do_receive(struct sk_buff **skb)
151{ 175{
152 return 0; 176 if ((*skb)->vlan_tci & VLAN_VID_MASK)
177 (*skb)->pkt_type = PACKET_OTHERHOST;
178 return false;
179}
180
181static inline struct sk_buff *vlan_untag(struct sk_buff *skb)
182{
183 return skb;
153} 184}
154 185
155static inline gro_result_t 186static inline gro_result_t
@@ -194,7 +225,7 @@ static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
194} 225}
195 226
196/** 227/**
197 * __vlan_put_tag - regular VLAN tag inserting 228 * vlan_insert_tag - regular VLAN tag inserting
198 * @skb: skbuff to tag 229 * @skb: skbuff to tag
199 * @vlan_tci: VLAN TCI to insert 230 * @vlan_tci: VLAN TCI to insert
200 * 231 *
@@ -203,8 +234,10 @@ static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
203 * 234 *
204 * Following the skb_unshare() example, in case of error, the calling function 235 * Following the skb_unshare() example, in case of error, the calling function
205 * doesn't have to worry about freeing the original skb. 236 * doesn't have to worry about freeing the original skb.
237 *
238 * Does not change skb->protocol so this function can be used during receive.
206 */ 239 */
207static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 240static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci)
208{ 241{
209 struct vlan_ethhdr *veth; 242 struct vlan_ethhdr *veth;
210 243
@@ -224,8 +257,25 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
224 /* now, the TCI */ 257 /* now, the TCI */
225 veth->h_vlan_TCI = htons(vlan_tci); 258 veth->h_vlan_TCI = htons(vlan_tci);
226 259
227 skb->protocol = htons(ETH_P_8021Q); 260 return skb;
261}
228 262
263/**
264 * __vlan_put_tag - regular VLAN tag inserting
265 * @skb: skbuff to tag
266 * @vlan_tci: VLAN TCI to insert
267 *
268 * Inserts the VLAN tag into @skb as part of the payload
269 * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
270 *
271 * Following the skb_unshare() example, in case of error, the calling function
272 * doesn't have to worry about freeing the original skb.
273 */
274static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
275{
276 skb = vlan_insert_tag(skb, vlan_tci);
277 if (skb)
278 skb->protocol = htons(ETH_P_8021Q);
229 return skb; 279 return skb;
230} 280}
231 281
@@ -318,6 +368,31 @@ static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
318 } 368 }
319} 369}
320 370
371/**
372 * vlan_get_protocol - get protocol EtherType.
373 * @skb: skbuff to query
374 *
375 * Returns the EtherType of the packet, regardless of whether it is
376 * vlan encapsulated (normal or hardware accelerated) or not.
377 */
378static inline __be16 vlan_get_protocol(const struct sk_buff *skb)
379{
380 __be16 protocol = 0;
381
382 if (vlan_tx_tag_present(skb) ||
383 skb->protocol != cpu_to_be16(ETH_P_8021Q))
384 protocol = skb->protocol;
385 else {
386 __be16 proto, *protop;
387 protop = skb_header_pointer(skb, offsetof(struct vlan_ethhdr,
388 h_vlan_encapsulated_proto),
389 sizeof(proto), &proto);
390 if (likely(protop))
391 protocol = *protop;
392 }
393
394 return protocol;
395}
321#endif /* __KERNEL__ */ 396#endif /* __KERNEL__ */
322 397
323/* VLAN IOCTLs are found in sockios.h */ 398/* VLAN IOCTLs are found in sockios.h */
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 93fc2449af10..82de336b8155 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -85,9 +85,9 @@ struct igmpv3_query {
85#define IGMP_DVMRP 0x13 /* DVMRP routing */ 85#define IGMP_DVMRP 0x13 /* DVMRP routing */
86#define IGMP_PIM 0x14 /* PIM routing */ 86#define IGMP_PIM 0x14 /* PIM routing */
87#define IGMP_TRACE 0x15 87#define IGMP_TRACE 0x15
88#define IGMPV2_HOST_MEMBERSHIP_REPORT 0x16 /* V2 version of 0x11 */ 88#define IGMPV2_HOST_MEMBERSHIP_REPORT 0x16 /* V2 version of 0x12 */
89#define IGMP_HOST_LEAVE_MESSAGE 0x17 89#define IGMP_HOST_LEAVE_MESSAGE 0x17
90#define IGMPV3_HOST_MEMBERSHIP_REPORT 0x22 /* V3 version of 0x11 */ 90#define IGMPV3_HOST_MEMBERSHIP_REPORT 0x22 /* V3 version of 0x12 */
91 91
92#define IGMP_MTRACE_RESP 0x1e 92#define IGMP_MTRACE_RESP 0x1e
93#define IGMP_MTRACE 0x1f 93#define IGMP_MTRACE 0x1f
@@ -167,10 +167,10 @@ struct ip_sf_socklist {
167 */ 167 */
168 168
169struct ip_mc_socklist { 169struct ip_mc_socklist {
170 struct ip_mc_socklist *next; 170 struct ip_mc_socklist __rcu *next_rcu;
171 struct ip_mreqn multi; 171 struct ip_mreqn multi;
172 unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */ 172 unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */
173 struct ip_sf_socklist *sflist; 173 struct ip_sf_socklist __rcu *sflist;
174 struct rcu_head rcu; 174 struct rcu_head rcu;
175}; 175};
176 176
@@ -186,11 +186,14 @@ struct ip_sf_list {
186struct ip_mc_list { 186struct ip_mc_list {
187 struct in_device *interface; 187 struct in_device *interface;
188 __be32 multiaddr; 188 __be32 multiaddr;
189 unsigned int sfmode;
189 struct ip_sf_list *sources; 190 struct ip_sf_list *sources;
190 struct ip_sf_list *tomb; 191 struct ip_sf_list *tomb;
191 unsigned int sfmode;
192 unsigned long sfcount[2]; 192 unsigned long sfcount[2];
193 struct ip_mc_list *next; 193 union {
194 struct ip_mc_list *next;
195 struct ip_mc_list __rcu *next_rcu;
196 };
194 struct timer_list timer; 197 struct timer_list timer;
195 int users; 198 int users;
196 atomic_t refcnt; 199 atomic_t refcnt;
@@ -201,6 +204,7 @@ struct ip_mc_list {
201 char loaded; 204 char loaded;
202 unsigned char gsquery; /* check source marks? */ 205 unsigned char gsquery; /* check source marks? */
203 unsigned char crcount; 206 unsigned char crcount;
207 struct rcu_head rcu;
204}; 208};
205 209
206/* V3 exponential field decoding */ 210/* V3 exponential field decoding */
@@ -213,7 +217,7 @@ struct ip_mc_list {
213#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value) 217#define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value)
214#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value) 218#define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value)
215 219
216extern int ip_check_mc(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u16 proto); 220extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u16 proto);
217extern int igmp_rcv(struct sk_buff *); 221extern int igmp_rcv(struct sk_buff *);
218extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr); 222extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
219extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr); 223extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
@@ -234,7 +238,7 @@ extern void ip_mc_unmap(struct in_device *);
234extern void ip_mc_remap(struct in_device *); 238extern void ip_mc_remap(struct in_device *);
235extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr); 239extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr);
236extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr); 240extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
237extern void ip_mc_rejoin_group(struct ip_mc_list *im); 241extern void ip_mc_rejoin_groups(struct in_device *in_dev);
238 242
239#endif 243#endif
240#endif 244#endif
diff --git a/include/linux/ima.h b/include/linux/ima.h
index 975837e7d6c0..09e6e62f9953 100644
--- a/include/linux/ima.h
+++ b/include/linux/ima.h
@@ -20,7 +20,6 @@ extern void ima_inode_free(struct inode *inode);
20extern int ima_file_check(struct file *file, int mask); 20extern int ima_file_check(struct file *file, int mask);
21extern void ima_file_free(struct file *file); 21extern void ima_file_free(struct file *file);
22extern int ima_file_mmap(struct file *file, unsigned long prot); 22extern int ima_file_mmap(struct file *file, unsigned long prot);
23extern void ima_counts_get(struct file *file);
24 23
25#else 24#else
26static inline int ima_bprm_check(struct linux_binprm *bprm) 25static inline int ima_bprm_check(struct linux_binprm *bprm)
@@ -53,10 +52,5 @@ static inline int ima_file_mmap(struct file *file, unsigned long prot)
53 return 0; 52 return 0;
54} 53}
55 54
56static inline void ima_counts_get(struct file *file)
57{
58 return;
59}
60
61#endif /* CONFIG_IMA_H */ 55#endif /* CONFIG_IMA_H */
62#endif /* _LINUX_IMA_H */ 56#endif /* _LINUX_IMA_H */
diff --git a/include/linux/in.h b/include/linux/in.h
index 41d88a4689af..beeb6dee2b49 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -250,6 +250,25 @@ struct sockaddr_in {
250 250
251#ifdef __KERNEL__ 251#ifdef __KERNEL__
252 252
253#include <linux/errno.h>
254
255static inline int proto_ports_offset(int proto)
256{
257 switch (proto) {
258 case IPPROTO_TCP:
259 case IPPROTO_UDP:
260 case IPPROTO_DCCP:
261 case IPPROTO_ESP: /* SPI */
262 case IPPROTO_SCTP:
263 case IPPROTO_UDPLITE:
264 return 0;
265 case IPPROTO_AH: /* SPI */
266 return 4;
267 default:
268 return -EINVAL;
269 }
270}
271
253static inline bool ipv4_is_loopback(__be32 addr) 272static inline bool ipv4_is_loopback(__be32 addr)
254{ 273{
255 return (addr & htonl(0xff000000)) == htonl(0x7f000000); 274 return (addr & htonl(0xff000000)) == htonl(0x7f000000);
diff --git a/include/linux/in6.h b/include/linux/in6.h
index c4bf46f764bf..097a34b55560 100644
--- a/include/linux/in6.h
+++ b/include/linux/in6.h
@@ -268,6 +268,10 @@ struct in6_flowlabel_req {
268/* RFC5082: Generalized Ttl Security Mechanism */ 268/* RFC5082: Generalized Ttl Security Mechanism */
269#define IPV6_MINHOPCOUNT 73 269#define IPV6_MINHOPCOUNT 73
270 270
271#define IPV6_ORIGDSTADDR 74
272#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
273#define IPV6_TRANSPARENT 75
274
271/* 275/*
272 * Multicast Routing: 276 * Multicast Routing:
273 * see include/linux/mroute6.h. 277 * see include/linux/mroute6.h.
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 2be1a1a2beb9..5f8146695b7f 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -9,6 +9,7 @@
9#include <linux/rcupdate.h> 9#include <linux/rcupdate.h>
10#include <linux/timer.h> 10#include <linux/timer.h>
11#include <linux/sysctl.h> 11#include <linux/sysctl.h>
12#include <linux/rtnetlink.h>
12 13
13enum 14enum
14{ 15{
@@ -40,10 +41,12 @@ enum
40 __IPV4_DEVCONF_MAX 41 __IPV4_DEVCONF_MAX
41}; 42};
42 43
44#define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
45
43struct ipv4_devconf { 46struct ipv4_devconf {
44 void *sysctl; 47 void *sysctl;
45 int data[__IPV4_DEVCONF_MAX - 1]; 48 int data[IPV4_DEVCONF_MAX];
46 DECLARE_BITMAP(state, __IPV4_DEVCONF_MAX - 1); 49 DECLARE_BITMAP(state, IPV4_DEVCONF_MAX);
47}; 50};
48 51
49struct in_device { 52struct in_device {
@@ -51,9 +54,8 @@ struct in_device {
51 atomic_t refcnt; 54 atomic_t refcnt;
52 int dead; 55 int dead;
53 struct in_ifaddr *ifa_list; /* IP ifaddr chain */ 56 struct in_ifaddr *ifa_list; /* IP ifaddr chain */
54 rwlock_t mc_list_lock; 57 struct ip_mc_list __rcu *mc_list; /* IP multicast filter chain */
55 struct ip_mc_list *mc_list; /* IP multicast filter chain */ 58 int mc_count; /* Number of installed mcasts */
56 int mc_count; /* Number of installed mcasts */
57 spinlock_t mc_tomb_lock; 59 spinlock_t mc_tomb_lock;
58 struct ip_mc_list *mc_tomb; 60 struct ip_mc_list *mc_tomb;
59 unsigned long mr_v1_seen; 61 unsigned long mr_v1_seen;
@@ -90,7 +92,7 @@ static inline void ipv4_devconf_set(struct in_device *in_dev, int index,
90 92
91static inline void ipv4_devconf_setall(struct in_device *in_dev) 93static inline void ipv4_devconf_setall(struct in_device *in_dev)
92{ 94{
93 bitmap_fill(in_dev->cnf.state, __IPV4_DEVCONF_MAX - 1); 95 bitmap_fill(in_dev->cnf.state, IPV4_DEVCONF_MAX);
94} 96}
95 97
96#define IN_DEV_CONF_GET(in_dev, attr) \ 98#define IN_DEV_CONF_GET(in_dev, attr) \
@@ -142,6 +144,7 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev)
142#define IN_DEV_ARP_NOTIFY(in_dev) IN_DEV_MAXCONF((in_dev), ARP_NOTIFY) 144#define IN_DEV_ARP_NOTIFY(in_dev) IN_DEV_MAXCONF((in_dev), ARP_NOTIFY)
143 145
144struct in_ifaddr { 146struct in_ifaddr {
147 struct hlist_node hash;
145 struct in_ifaddr *ifa_next; 148 struct in_ifaddr *ifa_next;
146 struct in_device *ifa_dev; 149 struct in_device *ifa_dev;
147 struct rcu_head rcu_head; 150 struct rcu_head rcu_head;
@@ -158,7 +161,12 @@ struct in_ifaddr {
158extern int register_inetaddr_notifier(struct notifier_block *nb); 161extern int register_inetaddr_notifier(struct notifier_block *nb);
159extern int unregister_inetaddr_notifier(struct notifier_block *nb); 162extern int unregister_inetaddr_notifier(struct notifier_block *nb);
160 163
161extern struct net_device *ip_dev_find(struct net *net, __be32 addr); 164extern struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref);
165static inline struct net_device *ip_dev_find(struct net *net, __be32 addr)
166{
167 return __ip_dev_find(net, addr, true);
168}
169
162extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b); 170extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
163extern int devinet_ioctl(struct net *net, unsigned int cmd, void __user *); 171extern int devinet_ioctl(struct net *net, unsigned int cmd, void __user *);
164extern void devinet_init(void); 172extern void devinet_init(void);
@@ -198,14 +206,10 @@ static __inline__ int bad_mask(__be32 mask, __be32 addr)
198 206
199static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev) 207static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev)
200{ 208{
201 struct in_device *in_dev = dev->ip_ptr; 209 return rcu_dereference(dev->ip_ptr);
202 if (in_dev)
203 in_dev = rcu_dereference(in_dev);
204 return in_dev;
205} 210}
206 211
207static __inline__ struct in_device * 212static inline struct in_device *in_dev_get(const struct net_device *dev)
208in_dev_get(const struct net_device *dev)
209{ 213{
210 struct in_device *in_dev; 214 struct in_device *in_dev;
211 215
@@ -217,10 +221,9 @@ in_dev_get(const struct net_device *dev)
217 return in_dev; 221 return in_dev;
218} 222}
219 223
220static __inline__ struct in_device * 224static inline struct in_device *__in_dev_get_rtnl(const struct net_device *dev)
221__in_dev_get_rtnl(const struct net_device *dev)
222{ 225{
223 return (struct in_device*)dev->ip_ptr; 226 return rtnl_dereference(dev->ip_ptr);
224} 227}
225 228
226extern void in_dev_finish_destroy(struct in_device *idev); 229extern void in_dev_finish_destroy(struct in_device *idev);
diff --git a/include/linux/init.h b/include/linux/init.h
index de994304e0bb..9146f39cdddf 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -46,16 +46,23 @@
46#define __exitdata __section(.exit.data) 46#define __exitdata __section(.exit.data)
47#define __exit_call __used __section(.exitcall.exit) 47#define __exit_call __used __section(.exitcall.exit)
48 48
49/* modpost check for section mismatches during the kernel build. 49/*
50 * modpost check for section mismatches during the kernel build.
50 * A section mismatch happens when there are references from a 51 * A section mismatch happens when there are references from a
51 * code or data section to an init section (both code or data). 52 * code or data section to an init section (both code or data).
52 * The init sections are (for most archs) discarded by the kernel 53 * The init sections are (for most archs) discarded by the kernel
53 * when early init has completed so all such references are potential bugs. 54 * when early init has completed so all such references are potential bugs.
54 * For exit sections the same issue exists. 55 * For exit sections the same issue exists.
56 *
55 * The following markers are used for the cases where the reference to 57 * The following markers are used for the cases where the reference to
56 * the *init / *exit section (code or data) is valid and will teach 58 * the *init / *exit section (code or data) is valid and will teach
57 * modpost not to issue a warning. 59 * modpost not to issue a warning. Intended semantics is that a code or
58 * The markers follow same syntax rules as __init / __initdata. */ 60 * data tagged __ref* can reference code or data from init section without
61 * producing a warning (of course, no warning does not mean code is
62 * correct, so optimally document why the __ref is needed and why it's OK).
63 *
64 * The markers follow same syntax rules as __init / __initdata.
65 */
59#define __ref __section(.ref.text) noinline 66#define __ref __section(.ref.text) noinline
60#define __refdata __section(.ref.data) 67#define __refdata __section(.ref.data)
61#define __refconst __section(.ref.rodata) 68#define __refconst __section(.ref.rodata)
@@ -72,29 +79,29 @@
72#define __exitused __used 79#define __exitused __used
73#endif 80#endif
74 81
75#define __exit __section(.exit.text) __exitused __cold 82#define __exit __section(.exit.text) __exitused __cold notrace
76 83
77/* Used for HOTPLUG */ 84/* Used for HOTPLUG */
78#define __devinit __section(.devinit.text) __cold 85#define __devinit __section(.devinit.text) __cold notrace
79#define __devinitdata __section(.devinit.data) 86#define __devinitdata __section(.devinit.data)
80#define __devinitconst __section(.devinit.rodata) 87#define __devinitconst __section(.devinit.rodata)
81#define __devexit __section(.devexit.text) __exitused __cold 88#define __devexit __section(.devexit.text) __exitused __cold notrace
82#define __devexitdata __section(.devexit.data) 89#define __devexitdata __section(.devexit.data)
83#define __devexitconst __section(.devexit.rodata) 90#define __devexitconst __section(.devexit.rodata)
84 91
85/* Used for HOTPLUG_CPU */ 92/* Used for HOTPLUG_CPU */
86#define __cpuinit __section(.cpuinit.text) __cold 93#define __cpuinit __section(.cpuinit.text) __cold notrace
87#define __cpuinitdata __section(.cpuinit.data) 94#define __cpuinitdata __section(.cpuinit.data)
88#define __cpuinitconst __section(.cpuinit.rodata) 95#define __cpuinitconst __section(.cpuinit.rodata)
89#define __cpuexit __section(.cpuexit.text) __exitused __cold 96#define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
90#define __cpuexitdata __section(.cpuexit.data) 97#define __cpuexitdata __section(.cpuexit.data)
91#define __cpuexitconst __section(.cpuexit.rodata) 98#define __cpuexitconst __section(.cpuexit.rodata)
92 99
93/* Used for MEMORY_HOTPLUG */ 100/* Used for MEMORY_HOTPLUG */
94#define __meminit __section(.meminit.text) __cold 101#define __meminit __section(.meminit.text) __cold notrace
95#define __meminitdata __section(.meminit.data) 102#define __meminitdata __section(.meminit.data)
96#define __meminitconst __section(.meminit.rodata) 103#define __meminitconst __section(.meminit.rodata)
97#define __memexit __section(.memexit.text) __exitused __cold 104#define __memexit __section(.memexit.text) __exitused __cold notrace
98#define __memexitdata __section(.memexit.data) 105#define __memexitdata __section(.memexit.data)
99#define __memexitconst __section(.memexit.rodata) 106#define __memexitconst __section(.memexit.rodata)
100 107
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 1f43fa56f600..580f70c02391 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -12,9 +12,24 @@
12#include <linux/securebits.h> 12#include <linux/securebits.h>
13#include <net/net_namespace.h> 13#include <net/net_namespace.h>
14 14
15#ifdef CONFIG_SMP
16# define INIT_PUSHABLE_TASKS(tsk) \
17 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO),
18#else
19# define INIT_PUSHABLE_TASKS(tsk)
20#endif
21
15extern struct files_struct init_files; 22extern struct files_struct init_files;
16extern struct fs_struct init_fs; 23extern struct fs_struct init_fs;
17 24
25#ifdef CONFIG_CGROUPS
26#define INIT_THREADGROUP_FORK_LOCK(sig) \
27 .threadgroup_fork_lock = \
28 __RWSEM_INITIALIZER(sig.threadgroup_fork_lock),
29#else
30#define INIT_THREADGROUP_FORK_LOCK(sig)
31#endif
32
18#define INIT_SIGNALS(sig) { \ 33#define INIT_SIGNALS(sig) { \
19 .nr_threads = 1, \ 34 .nr_threads = 1, \
20 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\ 35 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
@@ -29,6 +44,9 @@ extern struct fs_struct init_fs;
29 .running = 0, \ 44 .running = 0, \
30 .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \ 45 .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \
31 }, \ 46 }, \
47 .cred_guard_mutex = \
48 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
49 INIT_THREADGROUP_FORK_LOCK(sig) \
32} 50}
33 51
34extern struct nsproxy init_nsproxy; 52extern struct nsproxy init_nsproxy;
@@ -74,19 +92,25 @@ extern struct group_info init_groups;
74#define INIT_IDS 92#define INIT_IDS
75#endif 93#endif
76 94
77/* 95#ifdef CONFIG_RCU_BOOST
78 * Because of the reduced scope of CAP_SETPCAP when filesystem 96#define INIT_TASK_RCU_BOOST() \
79 * capabilities are in effect, it is safe to allow CAP_SETPCAP to 97 .rcu_boost_mutex = NULL,
80 * be available in the default configuration. 98#else
81 */ 99#define INIT_TASK_RCU_BOOST()
82# define CAP_INIT_BSET CAP_FULL_SET 100#endif
83
84#ifdef CONFIG_TREE_PREEMPT_RCU 101#ifdef CONFIG_TREE_PREEMPT_RCU
102#define INIT_TASK_RCU_TREE_PREEMPT() \
103 .rcu_blocked_node = NULL,
104#else
105#define INIT_TASK_RCU_TREE_PREEMPT(tsk)
106#endif
107#ifdef CONFIG_PREEMPT_RCU
85#define INIT_TASK_RCU_PREEMPT(tsk) \ 108#define INIT_TASK_RCU_PREEMPT(tsk) \
86 .rcu_read_lock_nesting = 0, \ 109 .rcu_read_lock_nesting = 0, \
87 .rcu_read_unlock_special = 0, \ 110 .rcu_read_unlock_special = 0, \
88 .rcu_blocked_node = NULL, \ 111 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), \
89 .rcu_node_entry = LIST_HEAD_INIT(tsk.rcu_node_entry), 112 INIT_TASK_RCU_TREE_PREEMPT() \
113 INIT_TASK_RCU_BOOST()
90#else 114#else
91#define INIT_TASK_RCU_PREEMPT(tsk) 115#define INIT_TASK_RCU_PREEMPT(tsk)
92#endif 116#endif
@@ -112,7 +136,6 @@ extern struct cred init_cred;
112 .stack = &init_thread_info, \ 136 .stack = &init_thread_info, \
113 .usage = ATOMIC_INIT(2), \ 137 .usage = ATOMIC_INIT(2), \
114 .flags = PF_KTHREAD, \ 138 .flags = PF_KTHREAD, \
115 .lock_depth = -1, \
116 .prio = MAX_PRIO-20, \ 139 .prio = MAX_PRIO-20, \
117 .static_prio = MAX_PRIO-20, \ 140 .static_prio = MAX_PRIO-20, \
118 .normal_prio = MAX_PRIO-20, \ 141 .normal_prio = MAX_PRIO-20, \
@@ -129,7 +152,7 @@ extern struct cred init_cred;
129 .nr_cpus_allowed = NR_CPUS, \ 152 .nr_cpus_allowed = NR_CPUS, \
130 }, \ 153 }, \
131 .tasks = LIST_HEAD_INIT(tsk.tasks), \ 154 .tasks = LIST_HEAD_INIT(tsk.tasks), \
132 .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO), \ 155 INIT_PUSHABLE_TASKS(tsk) \
133 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \ 156 .ptraced = LIST_HEAD_INIT(tsk.ptraced), \
134 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \ 157 .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \
135 .real_parent = &tsk, \ 158 .real_parent = &tsk, \
@@ -137,10 +160,8 @@ extern struct cred init_cred;
137 .children = LIST_HEAD_INIT(tsk.children), \ 160 .children = LIST_HEAD_INIT(tsk.children), \
138 .sibling = LIST_HEAD_INIT(tsk.sibling), \ 161 .sibling = LIST_HEAD_INIT(tsk.sibling), \
139 .group_leader = &tsk, \ 162 .group_leader = &tsk, \
140 .real_cred = &init_cred, \ 163 RCU_INIT_POINTER(.real_cred, &init_cred), \
141 .cred = &init_cred, \ 164 RCU_INIT_POINTER(.cred, &init_cred), \
142 .cred_guard_mutex = \
143 __MUTEX_INITIALIZER(tsk.cred_guard_mutex), \
144 .comm = "swapper", \ 165 .comm = "swapper", \
145 .thread = INIT_THREAD, \ 166 .thread = INIT_THREAD, \
146 .fs = &init_fs, \ 167 .fs = &init_fs, \
diff --git a/include/linux/input-polldev.h b/include/linux/input-polldev.h
index 5e3dddf8f562..ce0b72464eb8 100644
--- a/include/linux/input-polldev.h
+++ b/include/linux/input-polldev.h
@@ -22,12 +22,12 @@
22 * @poll: driver-supplied method that polls the device and posts 22 * @poll: driver-supplied method that polls the device and posts
23 * input events (mandatory). 23 * input events (mandatory).
24 * @poll_interval: specifies how often the poll() method should be called. 24 * @poll_interval: specifies how often the poll() method should be called.
25 * Defaults to 500 msec unless overriden when registering the device. 25 * Defaults to 500 msec unless overridden when registering the device.
26 * @poll_interval_max: specifies upper bound for the poll interval. 26 * @poll_interval_max: specifies upper bound for the poll interval.
27 * Defaults to the initial value of @poll_interval. 27 * Defaults to the initial value of @poll_interval.
28 * @poll_interval_min: specifies lower bound for the poll interval. 28 * @poll_interval_min: specifies lower bound for the poll interval.
29 * Defaults to 0. 29 * Defaults to 0.
30 * @input: input device structire associated with the polled device. 30 * @input: input device structure associated with the polled device.
31 * Must be properly initialized by the driver (id, name, phys, bits). 31 * Must be properly initialized by the driver (id, name, phys, bits).
32 * 32 *
33 * Polled input device provides a skeleton for supporting simple input 33 * Polled input device provides a skeleton for supporting simple input
diff --git a/include/linux/input.h b/include/linux/input.h
index 896a92227bc4..771d6d85667d 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -34,7 +34,7 @@ struct input_event {
34 * Protocol version. 34 * Protocol version.
35 */ 35 */
36 36
37#define EV_VERSION 0x010000 37#define EV_VERSION 0x010001
38 38
39/* 39/*
40 * IOCTLs (0x00 - 0x7f) 40 * IOCTLs (0x00 - 0x7f)
@@ -47,6 +47,25 @@ struct input_id {
47 __u16 version; 47 __u16 version;
48}; 48};
49 49
50/**
51 * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls
52 * @value: latest reported value for the axis.
53 * @minimum: specifies minimum value for the axis.
54 * @maximum: specifies maximum value for the axis.
55 * @fuzz: specifies fuzz value that is used to filter noise from
56 * the event stream.
57 * @flat: values that are within this value will be discarded by
58 * joydev interface and reported as 0 instead.
59 * @resolution: specifies resolution for the values reported for
60 * the axis.
61 *
62 * Note that input core does not clamp reported values to the
63 * [minimum, maximum] limits, such task is left to userspace.
64 *
65 * Resolution for main axes (ABS_X, ABS_Y, ABS_Z) is reported in
66 * units per millimeter (units/mm), resolution for rotational axes
67 * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.
68 */
50struct input_absinfo { 69struct input_absinfo {
51 __s32 value; 70 __s32 value;
52 __s32 minimum; 71 __s32 minimum;
@@ -56,25 +75,53 @@ struct input_absinfo {
56 __s32 resolution; 75 __s32 resolution;
57}; 76};
58 77
78/**
79 * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
80 * @scancode: scancode represented in machine-endian form.
81 * @len: length of the scancode that resides in @scancode buffer.
82 * @index: index in the keymap, may be used instead of scancode
83 * @flags: allows to specify how kernel should handle the request. For
84 * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
85 * should perform lookup in keymap by @index instead of @scancode
86 * @keycode: key code assigned to this scancode
87 *
88 * The structure is used to retrieve and modify keymap data. Users have
89 * option of performing lookup either by @scancode itself or by @index
90 * in keymap entry. EVIOCGKEYCODE will also return scancode or index
91 * (depending on which element was used to perform lookup).
92 */
93struct input_keymap_entry {
94#define INPUT_KEYMAP_BY_INDEX (1 << 0)
95 __u8 flags;
96 __u8 len;
97 __u16 index;
98 __u32 keycode;
99 __u8 scancode[32];
100};
101
59#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 102#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
60#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ 103#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */
61#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ 104#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */
62#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ 105#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */
63#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */ 106
64#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */ 107#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */
108#define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry)
109#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */
110#define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry)
65 111
66#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 112#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
67#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 113#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
68#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ 114#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
115#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */
69 116
70#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */ 117#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */
71#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ 118#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
72#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ 119#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
73#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ 120#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
74 121
75#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ 122#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */
76#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ 123#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */
77#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */ 124#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */
78 125
79#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */ 126#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */
80#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 127#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
@@ -83,6 +130,18 @@ struct input_absinfo {
83#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ 130#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
84 131
85/* 132/*
133 * Device properties and quirks
134 */
135
136#define INPUT_PROP_POINTER 0x00 /* needs a pointer */
137#define INPUT_PROP_DIRECT 0x01 /* direct input devices */
138#define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */
139#define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */
140
141#define INPUT_PROP_MAX 0x1f
142#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
143
144/*
86 * Event types 145 * Event types
87 */ 146 */
88 147
@@ -108,6 +167,7 @@ struct input_absinfo {
108#define SYN_REPORT 0 167#define SYN_REPORT 0
109#define SYN_CONFIG 1 168#define SYN_CONFIG 1
110#define SYN_MT_REPORT 2 169#define SYN_MT_REPORT 2
170#define SYN_DROPPED 3
111 171
112/* 172/*
113 * Keys and buttons 173 * Keys and buttons
@@ -494,8 +554,8 @@ struct input_absinfo {
494#define KEY_DVD 0x185 /* Media Select DVD */ 554#define KEY_DVD 0x185 /* Media Select DVD */
495#define KEY_AUX 0x186 555#define KEY_AUX 0x186
496#define KEY_MP3 0x187 556#define KEY_MP3 0x187
497#define KEY_AUDIO 0x188 557#define KEY_AUDIO 0x188 /* AL Audio Browser */
498#define KEY_VIDEO 0x189 558#define KEY_VIDEO 0x189 /* AL Movie Browser */
499#define KEY_DIRECTORY 0x18a 559#define KEY_DIRECTORY 0x18a
500#define KEY_LIST 0x18b 560#define KEY_LIST 0x18b
501#define KEY_MEMO 0x18c /* Media Select Messages */ 561#define KEY_MEMO 0x18c /* Media Select Messages */
@@ -544,6 +604,9 @@ struct input_absinfo {
544#define KEY_FRAMEFORWARD 0x1b5 604#define KEY_FRAMEFORWARD 0x1b5
545#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ 605#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */
546#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ 606#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */
607#define KEY_10CHANNELSUP 0x1b8 /* 10 channels up (10+) */
608#define KEY_10CHANNELSDOWN 0x1b9 /* 10 channels down (10-) */
609#define KEY_IMAGES 0x1ba /* AL Image Browser */
547 610
548#define KEY_DEL_EOL 0x1c0 611#define KEY_DEL_EOL 0x1c0
549#define KEY_DEL_EOS 0x1c1 612#define KEY_DEL_EOS 0x1c1
@@ -599,6 +662,17 @@ struct input_absinfo {
599#define KEY_CAMERA_FOCUS 0x210 662#define KEY_CAMERA_FOCUS 0x210
600#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ 663#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */
601 664
665#define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */
666#define KEY_TOUCHPAD_ON 0x213
667#define KEY_TOUCHPAD_OFF 0x214
668
669#define KEY_CAMERA_ZOOMIN 0x215
670#define KEY_CAMERA_ZOOMOUT 0x216
671#define KEY_CAMERA_UP 0x217
672#define KEY_CAMERA_DOWN 0x218
673#define KEY_CAMERA_LEFT 0x219
674#define KEY_CAMERA_RIGHT 0x21a
675
602#define BTN_TRIGGER_HAPPY 0x2c0 676#define BTN_TRIGGER_HAPPY 0x2c0
603#define BTN_TRIGGER_HAPPY1 0x2c0 677#define BTN_TRIGGER_HAPPY1 0x2c0
604#define BTN_TRIGGER_HAPPY2 0x2c1 678#define BTN_TRIGGER_HAPPY2 0x2c1
@@ -708,11 +782,12 @@ struct input_absinfo {
708#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ 782#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
709#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 783#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
710#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 784#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
785#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */
711 786
712#ifdef __KERNEL__ 787#ifdef __KERNEL__
713/* Implementation details, userspace should not care about these */ 788/* Implementation details, userspace should not care about these */
714#define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR 789#define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR
715#define ABS_MT_LAST ABS_MT_PRESSURE 790#define ABS_MT_LAST ABS_MT_DISTANCE
716#endif 791#endif
717 792
718#define ABS_MAX 0x3f 793#define ABS_MAX 0x3f
@@ -736,6 +811,7 @@ struct input_absinfo {
736#define SW_CAMERA_LENS_COVER 0x09 /* set = lens covered */ 811#define SW_CAMERA_LENS_COVER 0x09 /* set = lens covered */
737#define SW_KEYPAD_SLIDE 0x0a /* set = keypad slide out */ 812#define SW_KEYPAD_SLIDE 0x0a /* set = keypad slide out */
738#define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */ 813#define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */
814#define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */
739#define SW_MAX 0x0f 815#define SW_MAX 0x0f
740#define SW_CNT (SW_MAX+1) 816#define SW_CNT (SW_MAX+1)
741 817
@@ -823,6 +899,7 @@ struct input_absinfo {
823 */ 899 */
824#define MT_TOOL_FINGER 0 900#define MT_TOOL_FINGER 0
825#define MT_TOOL_PEN 1 901#define MT_TOOL_PEN 1
902#define MT_TOOL_MAX 1
826 903
827/* 904/*
828 * Values describing the status of a force-feedback effect 905 * Values describing the status of a force-feedback effect
@@ -1058,19 +1135,12 @@ struct ff_effect {
1058#include <linux/mod_devicetable.h> 1135#include <linux/mod_devicetable.h>
1059 1136
1060/** 1137/**
1061 * struct input_mt_slot - represents the state of an input MT slot
1062 * @abs: holds current values of ABS_MT axes for this slot
1063 */
1064struct input_mt_slot {
1065 int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
1066};
1067
1068/**
1069 * struct input_dev - represents an input device 1138 * struct input_dev - represents an input device
1070 * @name: name of the device 1139 * @name: name of the device
1071 * @phys: physical path to the device in the system hierarchy 1140 * @phys: physical path to the device in the system hierarchy
1072 * @uniq: unique identification code for the device (if device has it) 1141 * @uniq: unique identification code for the device (if device has it)
1073 * @id: id of the device (struct input_id) 1142 * @id: id of the device (struct input_id)
1143 * @propbit: bitmap of device properties and quirks
1074 * @evbit: bitmap of types of events supported by the device (EV_KEY, 1144 * @evbit: bitmap of types of events supported by the device (EV_KEY,
1075 * EV_REL, etc.) 1145 * EV_REL, etc.)
1076 * @keybit: bitmap of keys/buttons this device has 1146 * @keybit: bitmap of keys/buttons this device has
@@ -1088,13 +1158,11 @@ struct input_mt_slot {
1088 * @keycodemax: size of keycode table 1158 * @keycodemax: size of keycode table
1089 * @keycodesize: size of elements in keycode table 1159 * @keycodesize: size of elements in keycode table
1090 * @keycode: map of scancodes to keycodes for this device 1160 * @keycode: map of scancodes to keycodes for this device
1161 * @getkeycode: optional legacy method to retrieve current keymap.
1091 * @setkeycode: optional method to alter current keymap, used to implement 1162 * @setkeycode: optional method to alter current keymap, used to implement
1092 * sparse keymaps. If not supplied default mechanism will be used. 1163 * sparse keymaps. If not supplied default mechanism will be used.
1093 * The method is being called while holding event_lock and thus must 1164 * The method is being called while holding event_lock and thus must
1094 * not sleep 1165 * not sleep
1095 * @getkeycode: optional method to retrieve current keymap. If not supplied
1096 * default mechanism will be used. The method is being called while
1097 * holding event_lock and thus must not sleep
1098 * @ff: force feedback structure associated with the device if device 1166 * @ff: force feedback structure associated with the device if device
1099 * supports force feedback effects 1167 * supports force feedback effects
1100 * @repeat_key: stores key code of the last key pressed; used to implement 1168 * @repeat_key: stores key code of the last key pressed; used to implement
@@ -1105,7 +1173,8 @@ struct input_mt_slot {
1105 * of tracked contacts 1173 * of tracked contacts
1106 * @mtsize: number of MT slots the device uses 1174 * @mtsize: number of MT slots the device uses
1107 * @slot: MT slot currently being transmitted 1175 * @slot: MT slot currently being transmitted
1108 * @absinfo: array of &struct absinfo elements holding information 1176 * @trkid: stores MT tracking ID for the current contact
1177 * @absinfo: array of &struct input_absinfo elements holding information
1109 * about absolute axes (current value, min, max, flat, fuzz, 1178 * about absolute axes (current value, min, max, flat, fuzz,
1110 * resolution) 1179 * resolution)
1111 * @key: reflects current state of device's keys/buttons 1180 * @key: reflects current state of device's keys/buttons
@@ -1153,6 +1222,8 @@ struct input_dev {
1153 const char *uniq; 1222 const char *uniq;
1154 struct input_id id; 1223 struct input_id id;
1155 1224
1225 unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];
1226
1156 unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; 1227 unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
1157 unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; 1228 unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
1158 unsigned long relbit[BITS_TO_LONGS(REL_CNT)]; 1229 unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
@@ -1168,10 +1239,12 @@ struct input_dev {
1168 unsigned int keycodemax; 1239 unsigned int keycodemax;
1169 unsigned int keycodesize; 1240 unsigned int keycodesize;
1170 void *keycode; 1241 void *keycode;
1242
1171 int (*setkeycode)(struct input_dev *dev, 1243 int (*setkeycode)(struct input_dev *dev,
1172 unsigned int scancode, unsigned int keycode); 1244 const struct input_keymap_entry *ke,
1245 unsigned int *old_keycode);
1173 int (*getkeycode)(struct input_dev *dev, 1246 int (*getkeycode)(struct input_dev *dev,
1174 unsigned int scancode, unsigned int *keycode); 1247 struct input_keymap_entry *ke);
1175 1248
1176 struct ff_device *ff; 1249 struct ff_device *ff;
1177 1250
@@ -1183,6 +1256,7 @@ struct input_dev {
1183 struct input_mt_slot *mt; 1256 struct input_mt_slot *mt;
1184 int mtsize; 1257 int mtsize;
1185 int slot; 1258 int slot;
1259 int trkid;
1186 1260
1187 struct input_absinfo *absinfo; 1261 struct input_absinfo *absinfo;
1188 1262
@@ -1196,7 +1270,7 @@ struct input_dev {
1196 int (*flush)(struct input_dev *dev, struct file *file); 1270 int (*flush)(struct input_dev *dev, struct file *file);
1197 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); 1271 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
1198 1272
1199 struct input_handle *grab; 1273 struct input_handle __rcu *grab;
1200 1274
1201 spinlock_t event_lock; 1275 spinlock_t event_lock;
1202 struct mutex mutex; 1276 struct mutex mutex;
@@ -1375,6 +1449,8 @@ static inline void input_set_drvdata(struct input_dev *dev, void *data)
1375int __must_check input_register_device(struct input_dev *); 1449int __must_check input_register_device(struct input_dev *);
1376void input_unregister_device(struct input_dev *); 1450void input_unregister_device(struct input_dev *);
1377 1451
1452void input_reset_device(struct input_dev *);
1453
1378int __must_check input_register_handler(struct input_handler *); 1454int __must_check input_register_handler(struct input_handler *);
1379void input_unregister_handler(struct input_handler *); 1455void input_unregister_handler(struct input_handler *);
1380 1456
@@ -1390,7 +1466,7 @@ void input_release_device(struct input_handle *);
1390int input_open_device(struct input_handle *); 1466int input_open_device(struct input_handle *);
1391void input_close_device(struct input_handle *); 1467void input_close_device(struct input_handle *);
1392 1468
1393int input_flush_device(struct input_handle* handle, struct file* file); 1469int input_flush_device(struct input_handle *handle, struct file *file);
1394 1470
1395void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); 1471void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
1396void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value); 1472void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
@@ -1430,11 +1506,6 @@ static inline void input_mt_sync(struct input_dev *dev)
1430 input_event(dev, EV_SYN, SYN_MT_REPORT, 0); 1506 input_event(dev, EV_SYN, SYN_MT_REPORT, 0);
1431} 1507}
1432 1508
1433static inline void input_mt_slot(struct input_dev *dev, int slot)
1434{
1435 input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
1436}
1437
1438void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); 1509void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
1439 1510
1440/** 1511/**
@@ -1478,10 +1549,12 @@ INPUT_GENERATE_ABS_ACCESSORS(fuzz, fuzz)
1478INPUT_GENERATE_ABS_ACCESSORS(flat, flat) 1549INPUT_GENERATE_ABS_ACCESSORS(flat, flat)
1479INPUT_GENERATE_ABS_ACCESSORS(res, resolution) 1550INPUT_GENERATE_ABS_ACCESSORS(res, resolution)
1480 1551
1481int input_get_keycode(struct input_dev *dev, 1552int input_scancode_to_scalar(const struct input_keymap_entry *ke,
1482 unsigned int scancode, unsigned int *keycode); 1553 unsigned int *scancode);
1554
1555int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);
1483int input_set_keycode(struct input_dev *dev, 1556int input_set_keycode(struct input_dev *dev,
1484 unsigned int scancode, unsigned int keycode); 1557 const struct input_keymap_entry *ke);
1485 1558
1486extern struct class input_class; 1559extern struct class input_class;
1487 1560
@@ -1545,8 +1618,5 @@ int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
1545int input_ff_create_memless(struct input_dev *dev, void *data, 1618int input_ff_create_memless(struct input_dev *dev, void *data,
1546 int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); 1619 int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
1547 1620
1548int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots);
1549void input_mt_destroy_slots(struct input_dev *dev);
1550
1551#endif 1621#endif
1552#endif 1622#endif
diff --git a/include/linux/input/ad714x.h b/include/linux/input/ad714x.h
index 0cbe5e81482e..d388d857bf14 100644
--- a/include/linux/input/ad714x.h
+++ b/include/linux/input/ad714x.h
@@ -6,7 +6,7 @@
6 * The platform_data for the device's "struct device" holds this 6 * The platform_data for the device's "struct device" holds this
7 * information. 7 * information.
8 * 8 *
9 * Copyright 2009 Analog Devices Inc. 9 * Copyright 2009-2011 Analog Devices Inc.
10 * 10 *
11 * Licensed under the GPL-2 or later. 11 * Licensed under the GPL-2 or later.
12 */ 12 */
@@ -58,6 +58,7 @@ struct ad714x_platform_data {
58 struct ad714x_button_plat *button; 58 struct ad714x_button_plat *button;
59 unsigned short stage_cfg_reg[STAGE_NUM][STAGE_CFGREG_NUM]; 59 unsigned short stage_cfg_reg[STAGE_NUM][STAGE_CFGREG_NUM];
60 unsigned short sys_cfg_reg[SYS_CFGREG_NUM]; 60 unsigned short sys_cfg_reg[SYS_CFGREG_NUM];
61 unsigned long irqflags;
61}; 62};
62 63
63#endif 64#endif
diff --git a/include/linux/input/adp5589.h b/include/linux/input/adp5589.h
new file mode 100644
index 000000000000..ef792ecfaabf
--- /dev/null
+++ b/include/linux/input/adp5589.h
@@ -0,0 +1,213 @@
1/*
2 * Analog Devices ADP5589 I/O Expander and QWERTY Keypad Controller
3 *
4 * Copyright 2010-2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#ifndef _ADP5589_H
10#define _ADP5589_H
11
12#define ADP5589_ID 0x00
13#define ADP5589_INT_STATUS 0x01
14#define ADP5589_STATUS 0x02
15#define ADP5589_FIFO_1 0x03
16#define ADP5589_FIFO_2 0x04
17#define ADP5589_FIFO_3 0x05
18#define ADP5589_FIFO_4 0x06
19#define ADP5589_FIFO_5 0x07
20#define ADP5589_FIFO_6 0x08
21#define ADP5589_FIFO_7 0x09
22#define ADP5589_FIFO_8 0x0A
23#define ADP5589_FIFO_9 0x0B
24#define ADP5589_FIFO_10 0x0C
25#define ADP5589_FIFO_11 0x0D
26#define ADP5589_FIFO_12 0x0E
27#define ADP5589_FIFO_13 0x0F
28#define ADP5589_FIFO_14 0x10
29#define ADP5589_FIFO_15 0x11
30#define ADP5589_FIFO_16 0x12
31#define ADP5589_GPI_INT_STAT_A 0x13
32#define ADP5589_GPI_INT_STAT_B 0x14
33#define ADP5589_GPI_INT_STAT_C 0x15
34#define ADP5589_GPI_STATUS_A 0x16
35#define ADP5589_GPI_STATUS_B 0x17
36#define ADP5589_GPI_STATUS_C 0x18
37#define ADP5589_RPULL_CONFIG_A 0x19
38#define ADP5589_RPULL_CONFIG_B 0x1A
39#define ADP5589_RPULL_CONFIG_C 0x1B
40#define ADP5589_RPULL_CONFIG_D 0x1C
41#define ADP5589_RPULL_CONFIG_E 0x1D
42#define ADP5589_GPI_INT_LEVEL_A 0x1E
43#define ADP5589_GPI_INT_LEVEL_B 0x1F
44#define ADP5589_GPI_INT_LEVEL_C 0x20
45#define ADP5589_GPI_EVENT_EN_A 0x21
46#define ADP5589_GPI_EVENT_EN_B 0x22
47#define ADP5589_GPI_EVENT_EN_C 0x23
48#define ADP5589_GPI_INTERRUPT_EN_A 0x24
49#define ADP5589_GPI_INTERRUPT_EN_B 0x25
50#define ADP5589_GPI_INTERRUPT_EN_C 0x26
51#define ADP5589_DEBOUNCE_DIS_A 0x27
52#define ADP5589_DEBOUNCE_DIS_B 0x28
53#define ADP5589_DEBOUNCE_DIS_C 0x29
54#define ADP5589_GPO_DATA_OUT_A 0x2A
55#define ADP5589_GPO_DATA_OUT_B 0x2B
56#define ADP5589_GPO_DATA_OUT_C 0x2C
57#define ADP5589_GPO_OUT_MODE_A 0x2D
58#define ADP5589_GPO_OUT_MODE_B 0x2E
59#define ADP5589_GPO_OUT_MODE_C 0x2F
60#define ADP5589_GPIO_DIRECTION_A 0x30
61#define ADP5589_GPIO_DIRECTION_B 0x31
62#define ADP5589_GPIO_DIRECTION_C 0x32
63#define ADP5589_UNLOCK1 0x33
64#define ADP5589_UNLOCK2 0x34
65#define ADP5589_EXT_LOCK_EVENT 0x35
66#define ADP5589_UNLOCK_TIMERS 0x36
67#define ADP5589_LOCK_CFG 0x37
68#define ADP5589_RESET1_EVENT_A 0x38
69#define ADP5589_RESET1_EVENT_B 0x39
70#define ADP5589_RESET1_EVENT_C 0x3A
71#define ADP5589_RESET2_EVENT_A 0x3B
72#define ADP5589_RESET2_EVENT_B 0x3C
73#define ADP5589_RESET_CFG 0x3D
74#define ADP5589_PWM_OFFT_LOW 0x3E
75#define ADP5589_PWM_OFFT_HIGH 0x3F
76#define ADP5589_PWM_ONT_LOW 0x40
77#define ADP5589_PWM_ONT_HIGH 0x41
78#define ADP5589_PWM_CFG 0x42
79#define ADP5589_CLOCK_DIV_CFG 0x43
80#define ADP5589_LOGIC_1_CFG 0x44
81#define ADP5589_LOGIC_2_CFG 0x45
82#define ADP5589_LOGIC_FF_CFG 0x46
83#define ADP5589_LOGIC_INT_EVENT_EN 0x47
84#define ADP5589_POLL_PTIME_CFG 0x48
85#define ADP5589_PIN_CONFIG_A 0x49
86#define ADP5589_PIN_CONFIG_B 0x4A
87#define ADP5589_PIN_CONFIG_C 0x4B
88#define ADP5589_PIN_CONFIG_D 0x4C
89#define ADP5589_GENERAL_CFG 0x4D
90#define ADP5589_INT_EN 0x4E
91
92#define ADP5589_DEVICE_ID_MASK 0xF
93
94/* Put one of these structures in i2c_board_info platform_data */
95
96#define ADP5589_KEYMAPSIZE 88
97
98#define ADP5589_GPI_PIN_ROW0 97
99#define ADP5589_GPI_PIN_ROW1 98
100#define ADP5589_GPI_PIN_ROW2 99
101#define ADP5589_GPI_PIN_ROW3 100
102#define ADP5589_GPI_PIN_ROW4 101
103#define ADP5589_GPI_PIN_ROW5 102
104#define ADP5589_GPI_PIN_ROW6 103
105#define ADP5589_GPI_PIN_ROW7 104
106#define ADP5589_GPI_PIN_COL0 105
107#define ADP5589_GPI_PIN_COL1 106
108#define ADP5589_GPI_PIN_COL2 107
109#define ADP5589_GPI_PIN_COL3 108
110#define ADP5589_GPI_PIN_COL4 109
111#define ADP5589_GPI_PIN_COL5 110
112#define ADP5589_GPI_PIN_COL6 111
113#define ADP5589_GPI_PIN_COL7 112
114#define ADP5589_GPI_PIN_COL8 113
115#define ADP5589_GPI_PIN_COL9 114
116#define ADP5589_GPI_PIN_COL10 115
117#define GPI_LOGIC1 116
118#define GPI_LOGIC2 117
119
120#define ADP5589_GPI_PIN_ROW_BASE ADP5589_GPI_PIN_ROW0
121#define ADP5589_GPI_PIN_ROW_END ADP5589_GPI_PIN_ROW7
122#define ADP5589_GPI_PIN_COL_BASE ADP5589_GPI_PIN_COL0
123#define ADP5589_GPI_PIN_COL_END ADP5589_GPI_PIN_COL10
124
125#define ADP5589_GPI_PIN_BASE ADP5589_GPI_PIN_ROW_BASE
126#define ADP5589_GPI_PIN_END ADP5589_GPI_PIN_COL_END
127
128#define ADP5589_GPIMAPSIZE_MAX (ADP5589_GPI_PIN_END - ADP5589_GPI_PIN_BASE + 1)
129
130struct adp5589_gpi_map {
131 unsigned short pin;
132 unsigned short sw_evt;
133};
134
135/* scan_cycle_time */
136#define ADP5589_SCAN_CYCLE_10ms 0
137#define ADP5589_SCAN_CYCLE_20ms 1
138#define ADP5589_SCAN_CYCLE_30ms 2
139#define ADP5589_SCAN_CYCLE_40ms 3
140
141/* RESET_CFG */
142#define RESET_PULSE_WIDTH_500us 0
143#define RESET_PULSE_WIDTH_1ms 1
144#define RESET_PULSE_WIDTH_2ms 2
145#define RESET_PULSE_WIDTH_10ms 3
146
147#define RESET_TRIG_TIME_0ms (0 << 2)
148#define RESET_TRIG_TIME_1000ms (1 << 2)
149#define RESET_TRIG_TIME_1500ms (2 << 2)
150#define RESET_TRIG_TIME_2000ms (3 << 2)
151#define RESET_TRIG_TIME_2500ms (4 << 2)
152#define RESET_TRIG_TIME_3000ms (5 << 2)
153#define RESET_TRIG_TIME_3500ms (6 << 2)
154#define RESET_TRIG_TIME_4000ms (7 << 2)
155
156#define RESET_PASSTHRU_EN (1 << 5)
157#define RESET1_POL_HIGH (1 << 6)
158#define RESET1_POL_LOW (0 << 6)
159#define RESET2_POL_HIGH (1 << 7)
160#define RESET2_POL_LOW (0 << 7)
161
162/* Mask Bits:
163 * C C C C C C C C C C C | R R R R R R R R
164 * 1 9 8 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
165 * 0
166 * ---------------- BIT ------------------
167 * 1 1 1 1 1 1 1 1 1 0 0 | 0 0 0 0 0 0 0 0
168 * 8 7 6 5 4 3 2 1 0 9 8 | 7 6 5 4 3 2 1 0
169 */
170
171#define ADP_ROW(x) (1 << (x))
172#define ADP_COL(x) (1 << (x + 8))
173
174struct adp5589_kpad_platform_data {
175 unsigned keypad_en_mask; /* Keypad (Rows/Columns) enable mask */
176 const unsigned short *keymap; /* Pointer to keymap */
177 unsigned short keymapsize; /* Keymap size */
178 bool repeat; /* Enable key repeat */
179 bool en_keylock; /* Enable key lock feature */
180 unsigned char unlock_key1; /* Unlock Key 1 */
181 unsigned char unlock_key2; /* Unlock Key 2 */
182 unsigned char unlock_timer; /* Time in seconds [0..7] between the two unlock keys 0=disable */
183 unsigned char scan_cycle_time; /* Time between consecutive scan cycles */
184 unsigned char reset_cfg; /* Reset config */
185 unsigned short reset1_key_1; /* Reset Key 1 */
186 unsigned short reset1_key_2; /* Reset Key 2 */
187 unsigned short reset1_key_3; /* Reset Key 3 */
188 unsigned short reset2_key_1; /* Reset Key 1 */
189 unsigned short reset2_key_2; /* Reset Key 2 */
190 unsigned debounce_dis_mask; /* Disable debounce mask */
191 unsigned pull_dis_mask; /* Disable all pull resistors mask */
192 unsigned pullup_en_100k; /* Pull-Up 100k Enable Mask */
193 unsigned pullup_en_300k; /* Pull-Up 300k Enable Mask */
194 unsigned pulldown_en_300k; /* Pull-Down 300k Enable Mask */
195 const struct adp5589_gpi_map *gpimap;
196 unsigned short gpimapsize;
197 const struct adp5589_gpio_platform_data *gpio_data;
198};
199
200struct i2c_client; /* forward declaration */
201
202struct adp5589_gpio_platform_data {
203 int gpio_start; /* GPIO Chip base # */
204 int (*setup)(struct i2c_client *client,
205 int gpio, unsigned ngpio,
206 void *context);
207 int (*teardown)(struct i2c_client *client,
208 int gpio, unsigned ngpio,
209 void *context);
210 void *context;
211};
212
213#endif
diff --git a/include/linux/input/as5011.h b/include/linux/input/as5011.h
new file mode 100644
index 000000000000..1affd0ddfa9d
--- /dev/null
+++ b/include/linux/input/as5011.h
@@ -0,0 +1,20 @@
1#ifndef _AS5011_H
2#define _AS5011_H
3
4/*
5 * Copyright (c) 2010, 2011 Fabien Marteau <fabien.marteau@armadeus.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11
12struct as5011_platform_data {
13 unsigned int button_gpio;
14 unsigned int axis_irq; /* irq number */
15 unsigned long axis_irqflags;
16 char xp, xn; /* threshold for x axis */
17 char yp, yn; /* threshold for y axis */
18};
19
20#endif /* _AS5011_H */
diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
new file mode 100644
index 000000000000..05e03284b92a
--- /dev/null
+++ b/include/linux/input/bu21013.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson
4 * License terms:GNU General Public License (GPL) version 2
5 */
6
7#ifndef _BU21013_H
8#define _BU21013_H
9
10/**
11 * struct bu21013_platform_device - Handle the platform data
12 * @cs_en: pointer to the cs enable function
13 * @cs_dis: pointer to the cs disable function
14 * @irq_read_val: pointer to read the pen irq value function
15 * @touch_x_max: touch x max
16 * @touch_y_max: touch y max
17 * @cs_pin: chip select pin
18 * @irq: irq pin
19 * @ext_clk: external clock flag
20 * @x_flip: x flip flag
21 * @y_flip: y flip flag
22 * @wakeup: wakeup flag
23 *
24 * This is used to handle the platform data
25 */
26struct bu21013_platform_device {
27 int (*cs_en)(int reset_pin);
28 int (*cs_dis)(int reset_pin);
29 int (*irq_read_val)(void);
30 int touch_x_max;
31 int touch_y_max;
32 unsigned int cs_pin;
33 unsigned int irq;
34 bool ext_clk;
35 bool x_flip;
36 bool y_flip;
37 bool wakeup;
38};
39
40#endif
diff --git a/include/linux/input/cma3000.h b/include/linux/input/cma3000.h
new file mode 100644
index 000000000000..cbbaac27d311
--- /dev/null
+++ b/include/linux/input/cma3000.h
@@ -0,0 +1,59 @@
1/*
2 * VTI CMA3000_Dxx Accelerometer driver
3 *
4 * Copyright (C) 2010 Texas Instruments
5 * Author: Hemanth V <hemanthv@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef _LINUX_CMA3000_H
21#define _LINUX_CMA3000_H
22
23#define CMAMODE_DEFAULT 0
24#define CMAMODE_MEAS100 1
25#define CMAMODE_MEAS400 2
26#define CMAMODE_MEAS40 3
27#define CMAMODE_MOTDET 4
28#define CMAMODE_FF100 5
29#define CMAMODE_FF400 6
30#define CMAMODE_POFF 7
31
32#define CMARANGE_2G 2000
33#define CMARANGE_8G 8000
34
35/**
36 * struct cma3000_i2c_platform_data - CMA3000 Platform data
37 * @fuzz_x: Noise on X Axis
38 * @fuzz_y: Noise on Y Axis
39 * @fuzz_z: Noise on Z Axis
40 * @g_range: G range in milli g i.e 2000 or 8000
41 * @mode: Operating mode
42 * @mdthr: Motion detect threshold value
43 * @mdfftmr: Motion detect and free fall time value
44 * @ffthr: Free fall threshold value
45 */
46
47struct cma3000_platform_data {
48 int fuzz_x;
49 int fuzz_y;
50 int fuzz_z;
51 int g_range;
52 uint8_t mode;
53 uint8_t mdthr;
54 uint8_t mdfftmr;
55 uint8_t ffthr;
56 unsigned long irqflags;
57};
58
59#endif
diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
index 80352ad6581a..fe7c4b9ae270 100644
--- a/include/linux/input/matrix_keypad.h
+++ b/include/linux/input/matrix_keypad.h
@@ -4,12 +4,12 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/input.h> 5#include <linux/input.h>
6 6
7#define MATRIX_MAX_ROWS 16 7#define MATRIX_MAX_ROWS 32
8#define MATRIX_MAX_COLS 16 8#define MATRIX_MAX_COLS 32
9 9
10#define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\ 10#define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
11 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\ 11 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
12 (val & 0xffff)) 12 ((val) & 0xffff))
13 13
14#define KEY_ROW(k) (((k) >> 24) & 0xff) 14#define KEY_ROW(k) (((k) >> 24) & 0xff)
15#define KEY_COL(k) (((k) >> 16) & 0xff) 15#define KEY_COL(k) (((k) >> 16) & 0xff)
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
new file mode 100644
index 000000000000..318bb82325a6
--- /dev/null
+++ b/include/linux/input/mt.h
@@ -0,0 +1,63 @@
1#ifndef _INPUT_MT_H
2#define _INPUT_MT_H
3
4/*
5 * Input Multitouch Library
6 *
7 * Copyright (c) 2010 Henrik Rydberg
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published by
11 * the Free Software Foundation.
12 */
13
14#include <linux/input.h>
15
16#define TRKID_MAX 0xffff
17
18/**
19 * struct input_mt_slot - represents the state of an input MT slot
20 * @abs: holds current values of ABS_MT axes for this slot
21 */
22struct input_mt_slot {
23 int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
24};
25
26static inline void input_mt_set_value(struct input_mt_slot *slot,
27 unsigned code, int value)
28{
29 slot->abs[code - ABS_MT_FIRST] = value;
30}
31
32static inline int input_mt_get_value(const struct input_mt_slot *slot,
33 unsigned code)
34{
35 return slot->abs[code - ABS_MT_FIRST];
36}
37
38int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots);
39void input_mt_destroy_slots(struct input_dev *dev);
40
41static inline int input_mt_new_trkid(struct input_dev *dev)
42{
43 return dev->trkid++ & TRKID_MAX;
44}
45
46static inline void input_mt_slot(struct input_dev *dev, int slot)
47{
48 input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
49}
50
51static inline bool input_is_mt_axis(int axis)
52{
53 return axis == ABS_MT_SLOT ||
54 (axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST);
55}
56
57void input_mt_report_slot_state(struct input_dev *dev,
58 unsigned int tool_type, bool active);
59
60void input_mt_report_finger_count(struct input_dev *dev, int count);
61void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count);
62
63#endif
diff --git a/include/linux/input/pmic8xxx-keypad.h b/include/linux/input/pmic8xxx-keypad.h
new file mode 100644
index 000000000000..5f1e2f9ad959
--- /dev/null
+++ b/include/linux/input/pmic8xxx-keypad.h
@@ -0,0 +1,52 @@
1/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __PMIC8XXX_KEYPAD_H__
14#define __PMIC8XXX_KEYPAD_H__
15
16#include <linux/input/matrix_keypad.h>
17
18#define PM8XXX_KEYPAD_DEV_NAME "pm8xxx-keypad"
19
20/**
21 * struct pm8xxx_keypad_platform_data - platform data for keypad
22 * @keymap_data - matrix keymap data
23 * @input_name - input device name
24 * @input_phys_device - input device name
25 * @num_cols - number of columns of keypad
26 * @num_rows - number of row of keypad
27 * @debounce_ms - debounce period in milliseconds
28 * @scan_delay_ms - scan delay in milliseconds
29 * @row_hold_ns - row hold period in nanoseconds
30 * @wakeup - configure keypad as wakeup
31 * @rep - enable or disable key repeat bit
32 */
33struct pm8xxx_keypad_platform_data {
34 const struct matrix_keymap_data *keymap_data;
35
36 const char *input_name;
37 const char *input_phys_device;
38
39 unsigned int num_cols;
40 unsigned int num_rows;
41 unsigned int rows_gpio_start;
42 unsigned int cols_gpio_start;
43
44 unsigned int debounce_ms;
45 unsigned int scan_delay_ms;
46 unsigned int row_hold_ns;
47
48 bool wakeup;
49 bool rep;
50};
51
52#endif /*__PMIC8XXX_KEYPAD_H__ */
diff --git a/include/linux/input/pmic8xxx-pwrkey.h b/include/linux/input/pmic8xxx-pwrkey.h
new file mode 100644
index 000000000000..6d2974e57109
--- /dev/null
+++ b/include/linux/input/pmic8xxx-pwrkey.h
@@ -0,0 +1,31 @@
1/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __PMIC8XXX_PWRKEY_H__
14#define __PMIC8XXX_PWRKEY_H__
15
16#define PM8XXX_PWRKEY_DEV_NAME "pm8xxx-pwrkey"
17
18/**
19 * struct pm8xxx_pwrkey_platform_data - platform data for pwrkey driver
20 * @pull up: power on register control for pull up/down configuration
21 * @kpd_trigger_delay_us: time delay for power key state change interrupt
22 * trigger.
23 * @wakeup: configure power key as wakeup source
24 */
25struct pm8xxx_pwrkey_platform_data {
26 bool pull_up;
27 u32 kpd_trigger_delay_us;
28 u32 wakeup;
29};
30
31#endif /* __PMIC8XXX_PWRKEY_H__ */
diff --git a/include/linux/input/sh_keysc.h b/include/linux/input/sh_keysc.h
index 649dc7f12925..5d253cd93691 100644
--- a/include/linux/input/sh_keysc.h
+++ b/include/linux/input/sh_keysc.h
@@ -1,7 +1,7 @@
1#ifndef __SH_KEYSC_H__ 1#ifndef __SH_KEYSC_H__
2#define __SH_KEYSC_H__ 2#define __SH_KEYSC_H__
3 3
4#define SH_KEYSC_MAXKEYS 49 4#define SH_KEYSC_MAXKEYS 64
5 5
6struct sh_keysc_info { 6struct sh_keysc_info {
7 enum { SH_KEYSC_MODE_1, SH_KEYSC_MODE_2, SH_KEYSC_MODE_3, 7 enum { SH_KEYSC_MODE_1, SH_KEYSC_MODE_2, SH_KEYSC_MODE_3,
diff --git a/include/linux/intel-gtt.h b/include/linux/intel-gtt.h
deleted file mode 100644
index 1d19ab2afa39..000000000000
--- a/include/linux/intel-gtt.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * Common Intel AGPGART and GTT definitions.
3 */
4#ifndef _INTEL_GTT_H
5#define _INTEL_GTT_H
6
7#include <linux/agp_backend.h>
8
9/* This is for Intel only GTT controls.
10 *
11 * Sandybridge: AGP_USER_CACHED_MEMORY default to LLC only
12 */
13
14#define AGP_USER_CACHED_MEMORY_LLC_MLC (AGP_USER_TYPES + 2)
15#define AGP_USER_UNCACHED_MEMORY (AGP_USER_TYPES + 4)
16
17/* flag for GFDT type */
18#define AGP_USER_CACHED_MEMORY_GFDT (1 << 3)
19
20#endif
diff --git a/include/linux/intel_mid_dma.h b/include/linux/intel_mid_dma.h
index d9d08b6269b6..10496bd24c5c 100644
--- a/include/linux/intel_mid_dma.h
+++ b/include/linux/intel_mid_dma.h
@@ -27,14 +27,7 @@
27 27
28#include <linux/dmaengine.h> 28#include <linux/dmaengine.h>
29 29
30/*DMA transaction width, src and dstn width would be same 30#define DMA_PREP_CIRCULAR_LIST (1 << 10)
31The DMA length must be width aligned,
32for 32 bit width the length must be 32 bit (4bytes) aligned only*/
33enum intel_mid_dma_width {
34 LNW_DMA_WIDTH_8BIT = 0x0,
35 LNW_DMA_WIDTH_16BIT = 0x1,
36 LNW_DMA_WIDTH_32BIT = 0x2,
37};
38 31
39/*DMA mode configurations*/ 32/*DMA mode configurations*/
40enum intel_mid_dma_mode { 33enum intel_mid_dma_mode {
@@ -69,18 +62,15 @@ enum intel_mid_dma_msize {
69 * @cfg_mode: DMA data transfer mode (per-per/mem-per/mem-mem) 62 * @cfg_mode: DMA data transfer mode (per-per/mem-per/mem-mem)
70 * @src_msize: Source DMA burst size 63 * @src_msize: Source DMA burst size
71 * @dst_msize: Dst DMA burst size 64 * @dst_msize: Dst DMA burst size
65 * @per_addr: Periphral address
72 * @device_instance: DMA peripheral device instance, we can have multiple 66 * @device_instance: DMA peripheral device instance, we can have multiple
73 * peripheral device connected to single DMAC 67 * peripheral device connected to single DMAC
74 */ 68 */
75struct intel_mid_dma_slave { 69struct intel_mid_dma_slave {
76 enum dma_data_direction dirn;
77 enum intel_mid_dma_width src_width; /*width of DMA src txn*/
78 enum intel_mid_dma_width dst_width; /*width of DMA dst txn*/
79 enum intel_mid_dma_hs_mode hs_mode; /*handshaking*/ 70 enum intel_mid_dma_hs_mode hs_mode; /*handshaking*/
80 enum intel_mid_dma_mode cfg_mode; /*mode configuration*/ 71 enum intel_mid_dma_mode cfg_mode; /*mode configuration*/
81 enum intel_mid_dma_msize src_msize; /*size if src burst*/
82 enum intel_mid_dma_msize dst_msize; /*size of dst burst*/
83 unsigned int device_instance; /*0, 1 for periphral instance*/ 72 unsigned int device_instance; /*0, 1 for periphral instance*/
73 struct dma_slave_config dma_slave;
84}; 74};
85 75
86#endif /*__INTEL_MID_DMA_H__*/ 76#endif /*__INTEL_MID_DMA_H__*/
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a0384a4d1e6f..f6efed0039ed 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -14,10 +14,13 @@
14#include <linux/smp.h> 14#include <linux/smp.h>
15#include <linux/percpu.h> 15#include <linux/percpu.h>
16#include <linux/hrtimer.h> 16#include <linux/hrtimer.h>
17#include <linux/kref.h>
18#include <linux/workqueue.h>
17 19
18#include <asm/atomic.h> 20#include <asm/atomic.h>
19#include <asm/ptrace.h> 21#include <asm/ptrace.h>
20#include <asm/system.h> 22#include <asm/system.h>
23#include <trace/events/irq.h>
21 24
22/* 25/*
23 * These correspond to the IORESOURCE_IRQ_* defines in 26 * These correspond to the IORESOURCE_IRQ_* defines in
@@ -54,7 +57,8 @@
54 * Used by threaded interrupts which need to keep the 57 * Used by threaded interrupts which need to keep the
55 * irq line disabled until the threaded handler has been run. 58 * irq line disabled until the threaded handler has been run.
56 * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend 59 * IRQF_NO_SUSPEND - Do not disable this IRQ during suspend
57 * 60 * IRQF_FORCE_RESUME - Force enable it on resume even if IRQF_NO_SUSPEND is set
61 * IRQF_NO_THREAD - Interrupt cannot be threaded
58 */ 62 */
59#define IRQF_DISABLED 0x00000020 63#define IRQF_DISABLED 0x00000020
60#define IRQF_SAMPLE_RANDOM 0x00000040 64#define IRQF_SAMPLE_RANDOM 0x00000040
@@ -66,22 +70,10 @@
66#define IRQF_IRQPOLL 0x00001000 70#define IRQF_IRQPOLL 0x00001000
67#define IRQF_ONESHOT 0x00002000 71#define IRQF_ONESHOT 0x00002000
68#define IRQF_NO_SUSPEND 0x00004000 72#define IRQF_NO_SUSPEND 0x00004000
73#define IRQF_FORCE_RESUME 0x00008000
74#define IRQF_NO_THREAD 0x00010000
69 75
70#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND) 76#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
71
72/*
73 * Bits used by threaded handlers:
74 * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
75 * IRQTF_DIED - handler thread died
76 * IRQTF_WARNED - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
77 * IRQTF_AFFINITY - irq thread is requested to adjust affinity
78 */
79enum {
80 IRQTF_RUNTHREAD,
81 IRQTF_DIED,
82 IRQTF_WARNED,
83 IRQTF_AFFINITY,
84};
85 77
86/* 78/*
87 * These values can be returned by request_any_context_irq() and 79 * These values can be returned by request_any_context_irq() and
@@ -106,22 +98,24 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
106 * @next: pointer to the next irqaction for shared interrupts 98 * @next: pointer to the next irqaction for shared interrupts
107 * @irq: interrupt number 99 * @irq: interrupt number
108 * @dir: pointer to the proc/irq/NN/name entry 100 * @dir: pointer to the proc/irq/NN/name entry
109 * @thread_fn: interupt handler function for threaded interrupts 101 * @thread_fn: interrupt handler function for threaded interrupts
110 * @thread: thread pointer for threaded interrupts 102 * @thread: thread pointer for threaded interrupts
111 * @thread_flags: flags related to @thread 103 * @thread_flags: flags related to @thread
104 * @thread_mask: bitmask for keeping track of @thread activity
112 */ 105 */
113struct irqaction { 106struct irqaction {
114 irq_handler_t handler; 107 irq_handler_t handler;
115 unsigned long flags; 108 unsigned long flags;
116 const char *name;
117 void *dev_id; 109 void *dev_id;
118 struct irqaction *next; 110 struct irqaction *next;
119 int irq; 111 int irq;
120 struct proc_dir_entry *dir;
121 irq_handler_t thread_fn; 112 irq_handler_t thread_fn;
122 struct task_struct *thread; 113 struct task_struct *thread;
123 unsigned long thread_flags; 114 unsigned long thread_flags;
124}; 115 unsigned long thread_mask;
116 const char *name;
117 struct proc_dir_entry *dir;
118} ____cacheline_internodealigned_in_smp;
125 119
126extern irqreturn_t no_action(int cpl, void *dev_id); 120extern irqreturn_t no_action(int cpl, void *dev_id);
127 121
@@ -239,6 +233,35 @@ extern int irq_can_set_affinity(unsigned int irq);
239extern int irq_select_affinity(unsigned int irq); 233extern int irq_select_affinity(unsigned int irq);
240 234
241extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m); 235extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
236
237/**
238 * struct irq_affinity_notify - context for notification of IRQ affinity changes
239 * @irq: Interrupt to which notification applies
240 * @kref: Reference count, for internal use
241 * @work: Work item, for internal use
242 * @notify: Function to be called on change. This will be
243 * called in process context.
244 * @release: Function to be called on release. This will be
245 * called in process context. Once registered, the
246 * structure must only be freed when this function is
247 * called or later.
248 */
249struct irq_affinity_notify {
250 unsigned int irq;
251 struct kref kref;
252 struct work_struct work;
253 void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
254 void (*release)(struct kref *ref);
255};
256
257extern int
258irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
259
260static inline void irq_run_affinity_notifiers(void)
261{
262 flush_scheduled_work();
263}
264
242#else /* CONFIG_SMP */ 265#else /* CONFIG_SMP */
243 266
244static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m) 267static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
@@ -254,7 +277,7 @@ static inline int irq_can_set_affinity(unsigned int irq)
254static inline int irq_select_affinity(unsigned int irq) { return 0; } 277static inline int irq_select_affinity(unsigned int irq) { return 0; }
255 278
256static inline int irq_set_affinity_hint(unsigned int irq, 279static inline int irq_set_affinity_hint(unsigned int irq,
257 const struct cpumask *m) 280 const struct cpumask *m)
258{ 281{
259 return -EINVAL; 282 return -EINVAL;
260} 283}
@@ -313,16 +336,16 @@ static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long
313} 336}
314 337
315/* IRQ wakeup (PM) control: */ 338/* IRQ wakeup (PM) control: */
316extern int set_irq_wake(unsigned int irq, unsigned int on); 339extern int irq_set_irq_wake(unsigned int irq, unsigned int on);
317 340
318static inline int enable_irq_wake(unsigned int irq) 341static inline int enable_irq_wake(unsigned int irq)
319{ 342{
320 return set_irq_wake(irq, 1); 343 return irq_set_irq_wake(irq, 1);
321} 344}
322 345
323static inline int disable_irq_wake(unsigned int irq) 346static inline int disable_irq_wake(unsigned int irq)
324{ 347{
325 return set_irq_wake(irq, 0); 348 return irq_set_irq_wake(irq, 0);
326} 349}
327 350
328#else /* !CONFIG_GENERIC_HARDIRQS */ 351#else /* !CONFIG_GENERIC_HARDIRQS */
@@ -352,6 +375,13 @@ static inline int disable_irq_wake(unsigned int irq)
352} 375}
353#endif /* CONFIG_GENERIC_HARDIRQS */ 376#endif /* CONFIG_GENERIC_HARDIRQS */
354 377
378
379#ifdef CONFIG_IRQ_FORCED_THREADING
380extern bool force_irqthreads;
381#else
382#define force_irqthreads (0)
383#endif
384
355#ifndef __ARCH_SET_SOFTIRQ_PENDING 385#ifndef __ARCH_SET_SOFTIRQ_PENDING
356#define set_softirq_pending(x) (local_softirq_pending() = (x)) 386#define set_softirq_pending(x) (local_softirq_pending() = (x))
357#define or_softirq_pending(x) (local_softirq_pending() |= (x)) 387#define or_softirq_pending(x) (local_softirq_pending() |= (x))
@@ -384,7 +414,7 @@ enum
384 TASKLET_SOFTIRQ, 414 TASKLET_SOFTIRQ,
385 SCHED_SOFTIRQ, 415 SCHED_SOFTIRQ,
386 HRTIMER_SOFTIRQ, 416 HRTIMER_SOFTIRQ,
387 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */ 417 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
388 418
389 NR_SOFTIRQS 419 NR_SOFTIRQS
390}; 420};
@@ -407,10 +437,14 @@ asmlinkage void do_softirq(void);
407asmlinkage void __do_softirq(void); 437asmlinkage void __do_softirq(void);
408extern void open_softirq(int nr, void (*action)(struct softirq_action *)); 438extern void open_softirq(int nr, void (*action)(struct softirq_action *));
409extern void softirq_init(void); 439extern void softirq_init(void);
410#define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0) 440static inline void __raise_softirq_irqoff(unsigned int nr)
441{
442 trace_softirq_raise(nr);
443 or_softirq_pending(1UL << nr);
444}
445
411extern void raise_softirq_irqoff(unsigned int nr); 446extern void raise_softirq_irqoff(unsigned int nr);
412extern void raise_softirq(unsigned int nr); 447extern void raise_softirq(unsigned int nr);
413extern void wakeup_softirqd(void);
414 448
415/* This is the worklist that queues up per-cpu softirq work. 449/* This is the worklist that queues up per-cpu softirq work.
416 * 450 *
@@ -421,6 +455,13 @@ extern void wakeup_softirqd(void);
421 */ 455 */
422DECLARE_PER_CPU(struct list_head [NR_SOFTIRQS], softirq_work_list); 456DECLARE_PER_CPU(struct list_head [NR_SOFTIRQS], softirq_work_list);
423 457
458DECLARE_PER_CPU(struct task_struct *, ksoftirqd);
459
460static inline struct task_struct *this_cpu_ksoftirqd(void)
461{
462 return this_cpu_read(ksoftirqd);
463}
464
424/* Try to send a softirq to a remote cpu. If this cannot be done, the 465/* Try to send a softirq to a remote cpu. If this cannot be done, the
425 * work will be queued to the local cpu. 466 * work will be queued to the local cpu.
426 */ 467 */
@@ -443,7 +484,7 @@ extern void __send_remote_softirq(struct call_single_data *cp, int cpu,
443 Properties: 484 Properties:
444 * If tasklet_schedule() is called, then tasklet is guaranteed 485 * If tasklet_schedule() is called, then tasklet is guaranteed
445 to be executed on some cpu at least once after this. 486 to be executed on some cpu at least once after this.
446 * If the tasklet is already scheduled, but its excecution is still not 487 * If the tasklet is already scheduled, but its execution is still not
447 started, it will be executed only once. 488 started, it will be executed only once.
448 * If this tasklet is already running on another CPU (or schedule is called 489 * If this tasklet is already running on another CPU (or schedule is called
449 from tasklet itself), it is rescheduled for later. 490 from tasklet itself), it is rescheduled for later.
@@ -640,12 +681,10 @@ static inline void init_irq_proc(void)
640 681
641struct seq_file; 682struct seq_file;
642int show_interrupts(struct seq_file *p, void *v); 683int show_interrupts(struct seq_file *p, void *v);
643 684int arch_show_interrupts(struct seq_file *p, int prec);
644struct irq_desc;
645 685
646extern int early_irq_init(void); 686extern int early_irq_init(void);
647extern int arch_probe_nr_irqs(void); 687extern int arch_probe_nr_irqs(void);
648extern int arch_early_irq_init(void); 688extern int arch_early_irq_init(void);
649extern int arch_init_chip_data(struct irq_desc *desc, int node);
650 689
651#endif 690#endif
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
index 7fb592793738..8cdcc2a199ad 100644
--- a/include/linux/io-mapping.h
+++ b/include/linux/io-mapping.h
@@ -81,8 +81,7 @@ io_mapping_free(struct io_mapping *mapping)
81/* Atomic map/unmap */ 81/* Atomic map/unmap */
82static inline void __iomem * 82static inline void __iomem *
83io_mapping_map_atomic_wc(struct io_mapping *mapping, 83io_mapping_map_atomic_wc(struct io_mapping *mapping,
84 unsigned long offset, 84 unsigned long offset)
85 int slot)
86{ 85{
87 resource_size_t phys_addr; 86 resource_size_t phys_addr;
88 unsigned long pfn; 87 unsigned long pfn;
@@ -90,13 +89,13 @@ io_mapping_map_atomic_wc(struct io_mapping *mapping,
90 BUG_ON(offset >= mapping->size); 89 BUG_ON(offset >= mapping->size);
91 phys_addr = mapping->base + offset; 90 phys_addr = mapping->base + offset;
92 pfn = (unsigned long) (phys_addr >> PAGE_SHIFT); 91 pfn = (unsigned long) (phys_addr >> PAGE_SHIFT);
93 return iomap_atomic_prot_pfn(pfn, slot, mapping->prot); 92 return iomap_atomic_prot_pfn(pfn, mapping->prot);
94} 93}
95 94
96static inline void 95static inline void
97io_mapping_unmap_atomic(void __iomem *vaddr, int slot) 96io_mapping_unmap_atomic(void __iomem *vaddr)
98{ 97{
99 iounmap_atomic(vaddr, slot); 98 iounmap_atomic(vaddr);
100} 99}
101 100
102static inline void __iomem * 101static inline void __iomem *
@@ -137,14 +136,13 @@ io_mapping_free(struct io_mapping *mapping)
137/* Atomic map/unmap */ 136/* Atomic map/unmap */
138static inline void __iomem * 137static inline void __iomem *
139io_mapping_map_atomic_wc(struct io_mapping *mapping, 138io_mapping_map_atomic_wc(struct io_mapping *mapping,
140 unsigned long offset, 139 unsigned long offset)
141 int slot)
142{ 140{
143 return ((char __force __iomem *) mapping) + offset; 141 return ((char __force __iomem *) mapping) + offset;
144} 142}
145 143
146static inline void 144static inline void
147io_mapping_unmap_atomic(void __iomem *vaddr, int slot) 145io_mapping_unmap_atomic(void __iomem *vaddr)
148{ 146{
149} 147}
150 148
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h
index 64d529133031..b2eee896dcbc 100644
--- a/include/linux/iocontext.h
+++ b/include/linux/iocontext.h
@@ -53,7 +53,7 @@ struct io_context {
53 53
54 struct radix_tree_root radix_root; 54 struct radix_tree_root radix_root;
55 struct hlist_head cic_list; 55 struct hlist_head cic_list;
56 void *ioc_data; 56 void __rcu *ioc_data;
57}; 57};
58 58
59static inline struct io_context *ioc_task_link(struct io_context *ioc) 59static inline struct io_context *ioc_task_link(struct io_context *ioc)
@@ -76,7 +76,6 @@ int put_io_context(struct io_context *ioc);
76void exit_io_context(struct task_struct *task); 76void exit_io_context(struct task_struct *task);
77struct io_context *get_io_context(gfp_t gfp_flags, int node); 77struct io_context *get_io_context(gfp_t gfp_flags, int node);
78struct io_context *alloc_io_context(gfp_t gfp_flags, int node); 78struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
79void copy_io_context(struct io_context **pdst, struct io_context **psrc);
80#else 79#else
81static inline void exit_io_context(struct task_struct *task) 80static inline void exit_io_context(struct task_struct *task)
82{ 81{
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index b22790268b64..e9bb22cba764 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -123,6 +123,7 @@ extern void reserve_region_with_split(struct resource *root,
123extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new); 123extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);
124extern int insert_resource(struct resource *parent, struct resource *new); 124extern int insert_resource(struct resource *parent, struct resource *new);
125extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new); 125extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
126extern void arch_remove_reservations(struct resource *avail);
126extern int allocate_resource(struct resource *root, struct resource *new, 127extern int allocate_resource(struct resource *root, struct resource *new,
127 resource_size_t size, resource_size_t min, 128 resource_size_t size, resource_size_t min,
128 resource_size_t max, resource_size_t align, 129 resource_size_t max, resource_size_t align,
diff --git a/include/linux/ip_vs.h b/include/linux/ip_vs.h
index 9708de265bb1..4deb3834d62c 100644
--- a/include/linux/ip_vs.h
+++ b/include/linux/ip_vs.h
@@ -70,6 +70,7 @@
70 70
71/* 71/*
72 * IPVS Connection Flags 72 * IPVS Connection Flags
73 * Only flags 0..15 are sent to backup server
73 */ 74 */
74#define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */ 75#define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */
75#define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */ 76#define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */
@@ -88,9 +89,28 @@
88#define IP_VS_CONN_F_TEMPLATE 0x1000 /* template, not connection */ 89#define IP_VS_CONN_F_TEMPLATE 0x1000 /* template, not connection */
89#define IP_VS_CONN_F_ONE_PACKET 0x2000 /* forward only one packet */ 90#define IP_VS_CONN_F_ONE_PACKET 0x2000 /* forward only one packet */
90 91
92#define IP_VS_CONN_F_BACKUP_MASK (IP_VS_CONN_F_FWD_MASK | \
93 IP_VS_CONN_F_NOOUTPUT | \
94 IP_VS_CONN_F_INACTIVE | \
95 IP_VS_CONN_F_SEQ_MASK | \
96 IP_VS_CONN_F_NO_CPORT | \
97 IP_VS_CONN_F_TEMPLATE \
98 )
99
100/* Flags that are not sent to backup server start from bit 16 */
101#define IP_VS_CONN_F_NFCT (1 << 16) /* use netfilter conntrack */
102
103/* Connection flags from destination that can be changed by user space */
104#define IP_VS_CONN_F_DEST_MASK (IP_VS_CONN_F_FWD_MASK | \
105 IP_VS_CONN_F_ONE_PACKET | \
106 IP_VS_CONN_F_NFCT | \
107 0)
108
91#define IP_VS_SCHEDNAME_MAXLEN 16 109#define IP_VS_SCHEDNAME_MAXLEN 16
110#define IP_VS_PENAME_MAXLEN 16
92#define IP_VS_IFNAME_MAXLEN 16 111#define IP_VS_IFNAME_MAXLEN 16
93 112
113#define IP_VS_PEDATA_MAXLEN 255
94 114
95/* 115/*
96 * The struct ip_vs_service_user and struct ip_vs_dest_user are 116 * The struct ip_vs_service_user and struct ip_vs_dest_user are
@@ -324,6 +344,9 @@ enum {
324 IPVS_SVC_ATTR_NETMASK, /* persistent netmask */ 344 IPVS_SVC_ATTR_NETMASK, /* persistent netmask */
325 345
326 IPVS_SVC_ATTR_STATS, /* nested attribute for service stats */ 346 IPVS_SVC_ATTR_STATS, /* nested attribute for service stats */
347
348 IPVS_SVC_ATTR_PE_NAME, /* name of ct retriever */
349
327 __IPVS_SVC_ATTR_MAX, 350 __IPVS_SVC_ATTR_MAX,
328}; 351};
329 352
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 51952989ad42..a6d1655f9607 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -5,6 +5,7 @@
5#include <linux/idr.h> 5#include <linux/idr.h>
6#include <linux/rwsem.h> 6#include <linux/rwsem.h>
7#include <linux/notifier.h> 7#include <linux/notifier.h>
8#include <linux/nsproxy.h>
8 9
9/* 10/*
10 * ipc namespace events 11 * ipc namespace events
@@ -15,6 +16,7 @@
15 16
16#define IPCNS_CALLBACK_PRI 0 17#define IPCNS_CALLBACK_PRI 0
17 18
19struct user_namespace;
18 20
19struct ipc_ids { 21struct ipc_ids {
20 int in_use; 22 int in_use;
@@ -56,6 +58,8 @@ struct ipc_namespace {
56 unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */ 58 unsigned int mq_msg_max; /* initialized to DFLT_MSGMAX */
57 unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */ 59 unsigned int mq_msgsize_max; /* initialized to DFLT_MSGSIZEMAX */
58 60
61 /* user_ns which owns the ipc ns */
62 struct user_namespace *user_ns;
59}; 63};
60 64
61extern struct ipc_namespace init_ipc_ns; 65extern struct ipc_namespace init_ipc_ns;
@@ -90,7 +94,7 @@ static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; }
90 94
91#if defined(CONFIG_IPC_NS) 95#if defined(CONFIG_IPC_NS)
92extern struct ipc_namespace *copy_ipcs(unsigned long flags, 96extern struct ipc_namespace *copy_ipcs(unsigned long flags,
93 struct ipc_namespace *ns); 97 struct task_struct *tsk);
94static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) 98static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
95{ 99{
96 if (ns) 100 if (ns)
@@ -101,12 +105,12 @@ static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
101extern void put_ipc_ns(struct ipc_namespace *ns); 105extern void put_ipc_ns(struct ipc_namespace *ns);
102#else 106#else
103static inline struct ipc_namespace *copy_ipcs(unsigned long flags, 107static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
104 struct ipc_namespace *ns) 108 struct task_struct *tsk)
105{ 109{
106 if (flags & CLONE_NEWIPC) 110 if (flags & CLONE_NEWIPC)
107 return ERR_PTR(-EINVAL); 111 return ERR_PTR(-EINVAL);
108 112
109 return ns; 113 return tsk->nsproxy->ipc_ns;
110} 114}
111 115
112static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) 116static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
index 65aae34759de..ca85cf894e33 100644
--- a/include/linux/ipmi.h
+++ b/include/linux/ipmi.h
@@ -111,7 +111,7 @@ struct ipmi_ipmb_addr {
111 * A LAN Address. This is an address to/from a LAN interface bridged 111 * A LAN Address. This is an address to/from a LAN interface bridged
112 * by the BMC, not an address actually out on the LAN. 112 * by the BMC, not an address actually out on the LAN.
113 * 113 *
114 * A concious decision was made here to deviate slightly from the IPMI 114 * A conscious decision was made here to deviate slightly from the IPMI
115 * spec. We do not use rqSWID and rsSWID like it shows in the 115 * spec. We do not use rqSWID and rsSWID like it shows in the
116 * message. Instead, we use remote_SWID and local_SWID. This means 116 * message. Instead, we use remote_SWID and local_SWID. This means
117 * that any message (a request or response) from another device will 117 * that any message (a request or response) from another device will
@@ -259,7 +259,7 @@ struct ipmi_recv_msg {
259 void (*done)(struct ipmi_recv_msg *msg); 259 void (*done)(struct ipmi_recv_msg *msg);
260 260
261 /* Place-holder for the data, don't make any assumptions about 261 /* Place-holder for the data, don't make any assumptions about
262 the size or existance of this, since it may change. */ 262 the size or existence of this, since it may change. */
263 unsigned char msg_data[IPMI_MAX_MSG_LENGTH]; 263 unsigned char msg_data[IPMI_MAX_MSG_LENGTH];
264}; 264};
265 265
@@ -454,6 +454,44 @@ unsigned int ipmi_addr_length(int addr_type);
454/* Validate that the given IPMI address is valid. */ 454/* Validate that the given IPMI address is valid. */
455int ipmi_validate_addr(struct ipmi_addr *addr, int len); 455int ipmi_validate_addr(struct ipmi_addr *addr, int len);
456 456
457/*
458 * How did the IPMI driver find out about the device?
459 */
460enum ipmi_addr_src {
461 SI_INVALID = 0, SI_HOTMOD, SI_HARDCODED, SI_SPMI, SI_ACPI, SI_SMBIOS,
462 SI_PCI, SI_DEVICETREE, SI_DEFAULT
463};
464
465union ipmi_smi_info_union {
466 /*
467 * the acpi_info element is defined for the SI_ACPI
468 * address type
469 */
470 struct {
471 void *acpi_handle;
472 } acpi_info;
473};
474
475struct ipmi_smi_info {
476 enum ipmi_addr_src addr_src;
477
478 /*
479 * Base device for the interface. Don't forget to put this when
480 * you are done.
481 */
482 struct device *dev;
483
484 /*
485 * The addr_info provides more detailed info for some IPMI
486 * devices, depending on the addr_src. Currently only SI_ACPI
487 * info is provided.
488 */
489 union ipmi_smi_info_union addr_info;
490};
491
492/* This is to get the private info of ipmi_smi_t */
493extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data);
494
457#endif /* __KERNEL__ */ 495#endif /* __KERNEL__ */
458 496
459 497
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
index 4b48318ac542..204f9cd26c16 100644
--- a/include/linux/ipmi_smi.h
+++ b/include/linux/ipmi_smi.h
@@ -39,6 +39,7 @@
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/device.h> 40#include <linux/device.h>
41#include <linux/platform_device.h> 41#include <linux/platform_device.h>
42#include <linux/ipmi.h>
42 43
43/* This files describes the interface for IPMI system management interface 44/* This files describes the interface for IPMI system management interface
44 drivers to bind into the IPMI message handler. */ 45 drivers to bind into the IPMI message handler. */
@@ -86,6 +87,13 @@ struct ipmi_smi_handlers {
86 int (*start_processing)(void *send_info, 87 int (*start_processing)(void *send_info,
87 ipmi_smi_t new_intf); 88 ipmi_smi_t new_intf);
88 89
90 /*
91 * Get the detailed private info of the low level interface and store
92 * it into the structure of ipmi_smi_data. For example: the
93 * ACPI device handle will be returned for the pnp_acpi IPMI device.
94 */
95 int (*get_smi_info)(void *send_info, struct ipmi_smi_info *data);
96
89 /* Called to enqueue an SMI message to be sent. This 97 /* Called to enqueue an SMI message to be sent. This
90 operation is not allowed to fail. If an error occurs, it 98 operation is not allowed to fail. If an error occurs, it
91 should report back the error in a received message. It may 99 should report back the error in a received message. It may
@@ -228,7 +236,7 @@ static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
228 directory for this interface. Note that the entry will 236 directory for this interface. Note that the entry will
229 automatically be dstroyed when the interface is destroyed. */ 237 automatically be dstroyed when the interface is destroyed. */
230int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 238int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
231 read_proc_t *read_proc, 239 const struct file_operations *proc_ops,
232 void *data); 240 void *data);
233 241
234#endif /* __LINUX_IPMI_SMI_H */ 242#endif /* __LINUX_IPMI_SMI_H */
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index e62683ba88e6..0c997767429a 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -341,7 +341,9 @@ struct ipv6_pinfo {
341 odstopts:1, 341 odstopts:1,
342 rxflow:1, 342 rxflow:1,
343 rxtclass:1, 343 rxtclass:1,
344 rxpmtu:1; 344 rxpmtu:1,
345 rxorigdstaddr:1;
346 /* 2 bits hole */
345 } bits; 347 } bits;
346 __u16 all; 348 __u16 all;
347 } rxopt; 349 } rxopt;
@@ -362,7 +364,7 @@ struct ipv6_pinfo {
362 364
363 __u32 dst_cookie; 365 __u32 dst_cookie;
364 366
365 struct ipv6_mc_socklist *ipv6_mc_list; 367 struct ipv6_mc_socklist __rcu *ipv6_mc_list;
366 struct ipv6_ac_socklist *ipv6_ac_list; 368 struct ipv6_ac_socklist *ipv6_ac_list;
367 struct ipv6_fl_socklist *ipv6_fl_list; 369 struct ipv6_fl_socklist *ipv6_fl_list;
368 370
diff --git a/include/linux/irq.h b/include/linux/irq.h
index c03243ad84b4..baa397eb9c33 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -28,258 +28,357 @@
28#include <asm/ptrace.h> 28#include <asm/ptrace.h>
29#include <asm/irq_regs.h> 29#include <asm/irq_regs.h>
30 30
31struct seq_file;
31struct irq_desc; 32struct irq_desc;
33struct irq_data;
32typedef void (*irq_flow_handler_t)(unsigned int irq, 34typedef void (*irq_flow_handler_t)(unsigned int irq,
33 struct irq_desc *desc); 35 struct irq_desc *desc);
34 36typedef void (*irq_preflow_handler_t)(struct irq_data *data);
35 37
36/* 38/*
37 * IRQ line status. 39 * IRQ line status.
38 * 40 *
39 * Bits 0-7 are reserved for the IRQF_* bits in linux/interrupt.h 41 * Bits 0-7 are the same as the IRQF_* bits in linux/interrupt.h
42 *
43 * IRQ_TYPE_NONE - default, unspecified type
44 * IRQ_TYPE_EDGE_RISING - rising edge triggered
45 * IRQ_TYPE_EDGE_FALLING - falling edge triggered
46 * IRQ_TYPE_EDGE_BOTH - rising and falling edge triggered
47 * IRQ_TYPE_LEVEL_HIGH - high level triggered
48 * IRQ_TYPE_LEVEL_LOW - low level triggered
49 * IRQ_TYPE_LEVEL_MASK - Mask to filter out the level bits
50 * IRQ_TYPE_SENSE_MASK - Mask for all the above bits
51 * IRQ_TYPE_PROBE - Special flag for probing in progress
40 * 52 *
41 * IRQ types 53 * Bits which can be modified via irq_set/clear/modify_status_flags()
54 * IRQ_LEVEL - Interrupt is level type. Will be also
55 * updated in the code when the above trigger
56 * bits are modified via irq_set_irq_type()
57 * IRQ_PER_CPU - Mark an interrupt PER_CPU. Will protect
58 * it from affinity setting
59 * IRQ_NOPROBE - Interrupt cannot be probed by autoprobing
60 * IRQ_NOREQUEST - Interrupt cannot be requested via
61 * request_irq()
62 * IRQ_NOTHREAD - Interrupt cannot be threaded
63 * IRQ_NOAUTOEN - Interrupt is not automatically enabled in
64 * request/setup_irq()
65 * IRQ_NO_BALANCING - Interrupt cannot be balanced (affinity set)
66 * IRQ_MOVE_PCNTXT - Interrupt can be migrated from process context
67 * IRQ_NESTED_TRHEAD - Interrupt nests into another thread
42 */ 68 */
43#define IRQ_TYPE_NONE 0x00000000 /* Default, unspecified type */ 69enum {
44#define IRQ_TYPE_EDGE_RISING 0x00000001 /* Edge rising type */ 70 IRQ_TYPE_NONE = 0x00000000,
45#define IRQ_TYPE_EDGE_FALLING 0x00000002 /* Edge falling type */ 71 IRQ_TYPE_EDGE_RISING = 0x00000001,
46#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) 72 IRQ_TYPE_EDGE_FALLING = 0x00000002,
47#define IRQ_TYPE_LEVEL_HIGH 0x00000004 /* Level high type */ 73 IRQ_TYPE_EDGE_BOTH = (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING),
48#define IRQ_TYPE_LEVEL_LOW 0x00000008 /* Level low type */ 74 IRQ_TYPE_LEVEL_HIGH = 0x00000004,
49#define IRQ_TYPE_SENSE_MASK 0x0000000f /* Mask of the above */ 75 IRQ_TYPE_LEVEL_LOW = 0x00000008,
50#define IRQ_TYPE_PROBE 0x00000010 /* Probing in progress */ 76 IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
51 77 IRQ_TYPE_SENSE_MASK = 0x0000000f,
52/* Internal flags */ 78
53#define IRQ_INPROGRESS 0x00000100 /* IRQ handler active - do not enter! */ 79 IRQ_TYPE_PROBE = 0x00000010,
54#define IRQ_DISABLED 0x00000200 /* IRQ disabled - do not enter! */ 80
55#define IRQ_PENDING 0x00000400 /* IRQ pending - replay on enable */ 81 IRQ_LEVEL = (1 << 8),
56#define IRQ_REPLAY 0x00000800 /* IRQ has been replayed but not acked yet */ 82 IRQ_PER_CPU = (1 << 9),
57#define IRQ_AUTODETECT 0x00001000 /* IRQ is being autodetected */ 83 IRQ_NOPROBE = (1 << 10),
58#define IRQ_WAITING 0x00002000 /* IRQ not yet seen - for autodetection */ 84 IRQ_NOREQUEST = (1 << 11),
59#define IRQ_LEVEL 0x00004000 /* IRQ level triggered */ 85 IRQ_NOAUTOEN = (1 << 12),
60#define IRQ_MASKED 0x00008000 /* IRQ masked - shouldn't be seen again */ 86 IRQ_NO_BALANCING = (1 << 13),
61#define IRQ_PER_CPU 0x00010000 /* IRQ is per CPU */ 87 IRQ_MOVE_PCNTXT = (1 << 14),
62#define IRQ_NOPROBE 0x00020000 /* IRQ is not valid for probing */ 88 IRQ_NESTED_THREAD = (1 << 15),
63#define IRQ_NOREQUEST 0x00040000 /* IRQ cannot be requested */ 89 IRQ_NOTHREAD = (1 << 16),
64#define IRQ_NOAUTOEN 0x00080000 /* IRQ will not be enabled on request irq */ 90};
65#define IRQ_WAKEUP 0x00100000 /* IRQ triggers system wakeup */
66#define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */
67#define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */
68#define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */
69#define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */
70#define IRQ_AFFINITY_SET 0x02000000 /* IRQ affinity was set from userspace*/
71#define IRQ_SUSPENDED 0x04000000 /* IRQ has gone through suspend sequence */
72#define IRQ_ONESHOT 0x08000000 /* IRQ is not unmasked after hardirq */
73#define IRQ_NESTED_THREAD 0x10000000 /* IRQ is nested into another, no own handler thread */
74
75#ifdef CONFIG_IRQ_PER_CPU
76# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
77# define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)
78#else
79# define CHECK_IRQ_PER_CPU(var) 0
80# define IRQ_NO_BALANCING_MASK IRQ_NO_BALANCING
81#endif
82 91
83struct proc_dir_entry; 92#define IRQF_MODIFY_MASK \
84struct msi_desc; 93 (IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \
94 IRQ_NOAUTOEN | IRQ_MOVE_PCNTXT | IRQ_LEVEL | IRQ_NO_BALANCING | \
95 IRQ_PER_CPU | IRQ_NESTED_THREAD)
85 96
86/** 97#define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)
87 * struct irq_chip - hardware interrupt chip descriptor 98
88 * 99static inline __deprecated bool CHECK_IRQ_PER_CPU(unsigned int status)
89 * @name: name for /proc/interrupts 100{
90 * @startup: start up the interrupt (defaults to ->enable if NULL) 101 return status & IRQ_PER_CPU;
91 * @shutdown: shut down the interrupt (defaults to ->disable if NULL) 102}
92 * @enable: enable the interrupt (defaults to chip->unmask if NULL) 103
93 * @disable: disable the interrupt 104/*
94 * @ack: start of a new interrupt 105 * Return value for chip->irq_set_affinity()
95 * @mask: mask an interrupt source
96 * @mask_ack: ack and mask an interrupt source
97 * @unmask: unmask an interrupt source
98 * @eoi: end of interrupt - chip level
99 * @end: end of interrupt - flow level
100 * @set_affinity: set the CPU affinity on SMP machines
101 * @retrigger: resend an IRQ to the CPU
102 * @set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
103 * @set_wake: enable/disable power-management wake-on of an IRQ
104 *
105 * @bus_lock: function to lock access to slow bus (i2c) chips
106 * @bus_sync_unlock: function to sync and unlock slow bus (i2c) chips
107 * 106 *
108 * @release: release function solely used by UML 107 * IRQ_SET_MASK_OK - OK, core updates irq_data.affinity
109 * @typename: obsoleted by name, kept as migration helper 108 * IRQ_SET_MASK_NOCPY - OK, chip did update irq_data.affinity
110 */ 109 */
111struct irq_chip { 110enum {
112 const char *name; 111 IRQ_SET_MASK_OK = 0,
113 unsigned int (*startup)(unsigned int irq); 112 IRQ_SET_MASK_OK_NOCOPY,
114 void (*shutdown)(unsigned int irq);
115 void (*enable)(unsigned int irq);
116 void (*disable)(unsigned int irq);
117
118 void (*ack)(unsigned int irq);
119 void (*mask)(unsigned int irq);
120 void (*mask_ack)(unsigned int irq);
121 void (*unmask)(unsigned int irq);
122 void (*eoi)(unsigned int irq);
123
124 void (*end)(unsigned int irq);
125 int (*set_affinity)(unsigned int irq,
126 const struct cpumask *dest);
127 int (*retrigger)(unsigned int irq);
128 int (*set_type)(unsigned int irq, unsigned int flow_type);
129 int (*set_wake)(unsigned int irq, unsigned int on);
130
131 void (*bus_lock)(unsigned int irq);
132 void (*bus_sync_unlock)(unsigned int irq);
133
134 /* Currently used only by UML, might disappear one day.*/
135#ifdef CONFIG_IRQ_RELEASE_METHOD
136 void (*release)(unsigned int irq, void *dev_id);
137#endif
138 /*
139 * For compatibility, ->typename is copied into ->name.
140 * Will disappear.
141 */
142 const char *typename;
143}; 113};
144 114
145struct timer_rand_state; 115struct msi_desc;
146struct irq_2_iommu; 116
147/** 117/**
148 * struct irq_desc - interrupt descriptor 118 * struct irq_data - per irq and irq chip data passed down to chip functions
149 * @irq: interrupt number for this descriptor 119 * @irq: interrupt number
150 * @timer_rand_state: pointer to timer rand state struct 120 * @node: node index useful for balancing
151 * @kstat_irqs: irq stats per cpu 121 * @state_use_accessors: status information for irq chip functions.
152 * @irq_2_iommu: iommu with this irq 122 * Use accessor functions to deal with it
153 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
154 * @chip: low level interrupt hardware access 123 * @chip: low level interrupt hardware access
155 * @msi_desc: MSI descriptor
156 * @handler_data: per-IRQ data for the irq_chip methods 124 * @handler_data: per-IRQ data for the irq_chip methods
157 * @chip_data: platform-specific per-chip private data for the chip 125 * @chip_data: platform-specific per-chip private data for the chip
158 * methods, to allow shared chip implementations 126 * methods, to allow shared chip implementations
159 * @action: the irq action chain 127 * @msi_desc: MSI descriptor
160 * @status: status information
161 * @depth: disable-depth, for nested irq_disable() calls
162 * @wake_depth: enable depth, for multiple set_irq_wake() callers
163 * @irq_count: stats field to detect stalled irqs
164 * @last_unhandled: aging timer for unhandled count
165 * @irqs_unhandled: stats field for spurious unhandled interrupts
166 * @lock: locking for SMP
167 * @affinity: IRQ affinity on SMP 128 * @affinity: IRQ affinity on SMP
168 * @node: node index useful for balancing 129 *
169 * @pending_mask: pending rebalanced interrupts 130 * The fields here need to overlay the ones in irq_desc until we
170 * @threads_active: number of irqaction threads currently running 131 * cleaned up the direct references and switched everything over to
171 * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers 132 * irq_data.
172 * @dir: /proc/irq/ procfs entry
173 * @name: flow handler name for /proc/interrupts output
174 */ 133 */
175struct irq_desc { 134struct irq_data {
176 unsigned int irq; 135 unsigned int irq;
177 struct timer_rand_state *timer_rand_state; 136 unsigned int node;
178 unsigned int *kstat_irqs; 137 unsigned int state_use_accessors;
179#ifdef CONFIG_INTR_REMAP
180 struct irq_2_iommu *irq_2_iommu;
181#endif
182 irq_flow_handler_t handle_irq;
183 struct irq_chip *chip; 138 struct irq_chip *chip;
184 struct msi_desc *msi_desc;
185 void *handler_data; 139 void *handler_data;
186 void *chip_data; 140 void *chip_data;
187 struct irqaction *action; /* IRQ action list */ 141 struct msi_desc *msi_desc;
188 unsigned int status; /* IRQ status */
189
190 unsigned int depth; /* nested irq disables */
191 unsigned int wake_depth; /* nested wake enables */
192 unsigned int irq_count; /* For detecting broken IRQs */
193 unsigned long last_unhandled; /* Aging timer for unhandled count */
194 unsigned int irqs_unhandled;
195 raw_spinlock_t lock;
196#ifdef CONFIG_SMP 142#ifdef CONFIG_SMP
197 cpumask_var_t affinity; 143 cpumask_var_t affinity;
198 const struct cpumask *affinity_hint;
199 unsigned int node;
200#ifdef CONFIG_GENERIC_PENDING_IRQ
201 cpumask_var_t pending_mask;
202#endif
203#endif 144#endif
204 atomic_t threads_active; 145};
205 wait_queue_head_t wait_for_threads;
206#ifdef CONFIG_PROC_FS
207 struct proc_dir_entry *dir;
208#endif
209 const char *name;
210} ____cacheline_internodealigned_in_smp;
211 146
212extern void arch_init_copy_chip_data(struct irq_desc *old_desc, 147/*
213 struct irq_desc *desc, int node); 148 * Bit masks for irq_data.state
214extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc); 149 *
150 * IRQD_TRIGGER_MASK - Mask for the trigger type bits
151 * IRQD_SETAFFINITY_PENDING - Affinity setting is pending
152 * IRQD_NO_BALANCING - Balancing disabled for this IRQ
153 * IRQD_PER_CPU - Interrupt is per cpu
154 * IRQD_AFFINITY_SET - Interrupt affinity was set
155 * IRQD_LEVEL - Interrupt is level triggered
156 * IRQD_WAKEUP_STATE - Interrupt is configured for wakeup
157 * from suspend
158 * IRDQ_MOVE_PCNTXT - Interrupt can be moved in process
159 * context
160 * IRQD_IRQ_DISABLED - Disabled state of the interrupt
161 * IRQD_IRQ_MASKED - Masked state of the interrupt
162 * IRQD_IRQ_INPROGRESS - In progress state of the interrupt
163 */
164enum {
165 IRQD_TRIGGER_MASK = 0xf,
166 IRQD_SETAFFINITY_PENDING = (1 << 8),
167 IRQD_NO_BALANCING = (1 << 10),
168 IRQD_PER_CPU = (1 << 11),
169 IRQD_AFFINITY_SET = (1 << 12),
170 IRQD_LEVEL = (1 << 13),
171 IRQD_WAKEUP_STATE = (1 << 14),
172 IRQD_MOVE_PCNTXT = (1 << 15),
173 IRQD_IRQ_DISABLED = (1 << 16),
174 IRQD_IRQ_MASKED = (1 << 17),
175 IRQD_IRQ_INPROGRESS = (1 << 18),
176};
215 177
216#ifndef CONFIG_SPARSE_IRQ 178static inline bool irqd_is_setaffinity_pending(struct irq_data *d)
217extern struct irq_desc irq_desc[NR_IRQS]; 179{
218#endif 180 return d->state_use_accessors & IRQD_SETAFFINITY_PENDING;
181}
219 182
220#ifdef CONFIG_NUMA_IRQ_DESC 183static inline bool irqd_is_per_cpu(struct irq_data *d)
221extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int node);
222#else
223static inline struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
224{ 184{
225 return desc; 185 return d->state_use_accessors & IRQD_PER_CPU;
226} 186}
227#endif
228 187
229extern struct irq_desc *irq_to_desc_alloc_node(unsigned int irq, int node); 188static inline bool irqd_can_balance(struct irq_data *d)
189{
190 return !(d->state_use_accessors & (IRQD_PER_CPU | IRQD_NO_BALANCING));
191}
192
193static inline bool irqd_affinity_was_set(struct irq_data *d)
194{
195 return d->state_use_accessors & IRQD_AFFINITY_SET;
196}
197
198static inline void irqd_mark_affinity_was_set(struct irq_data *d)
199{
200 d->state_use_accessors |= IRQD_AFFINITY_SET;
201}
202
203static inline u32 irqd_get_trigger_type(struct irq_data *d)
204{
205 return d->state_use_accessors & IRQD_TRIGGER_MASK;
206}
230 207
231/* 208/*
232 * Pick up the arch-dependent methods: 209 * Must only be called inside irq_chip.irq_set_type() functions.
233 */ 210 */
234#include <asm/hw_irq.h> 211static inline void irqd_set_trigger_type(struct irq_data *d, u32 type)
235 212{
236extern int setup_irq(unsigned int irq, struct irqaction *new); 213 d->state_use_accessors &= ~IRQD_TRIGGER_MASK;
237extern void remove_irq(unsigned int irq, struct irqaction *act); 214 d->state_use_accessors |= type & IRQD_TRIGGER_MASK;
215}
238 216
239#ifdef CONFIG_GENERIC_HARDIRQS 217static inline bool irqd_is_level_type(struct irq_data *d)
218{
219 return d->state_use_accessors & IRQD_LEVEL;
220}
240 221
241#ifdef CONFIG_SMP 222static inline bool irqd_is_wakeup_set(struct irq_data *d)
223{
224 return d->state_use_accessors & IRQD_WAKEUP_STATE;
225}
242 226
243#ifdef CONFIG_GENERIC_PENDING_IRQ 227static inline bool irqd_can_move_in_process_context(struct irq_data *d)
228{
229 return d->state_use_accessors & IRQD_MOVE_PCNTXT;
230}
244 231
245void move_native_irq(int irq); 232static inline bool irqd_irq_disabled(struct irq_data *d)
246void move_masked_irq(int irq); 233{
234 return d->state_use_accessors & IRQD_IRQ_DISABLED;
235}
247 236
248#else /* CONFIG_GENERIC_PENDING_IRQ */ 237static inline bool irqd_irq_masked(struct irq_data *d)
238{
239 return d->state_use_accessors & IRQD_IRQ_MASKED;
240}
249 241
250static inline void move_irq(int irq) 242static inline bool irqd_irq_inprogress(struct irq_data *d)
251{ 243{
244 return d->state_use_accessors & IRQD_IRQ_INPROGRESS;
252} 245}
253 246
254static inline void move_native_irq(int irq) 247/*
248 * Functions for chained handlers which can be enabled/disabled by the
249 * standard disable_irq/enable_irq calls. Must be called with
250 * irq_desc->lock held.
251 */
252static inline void irqd_set_chained_irq_inprogress(struct irq_data *d)
255{ 253{
254 d->state_use_accessors |= IRQD_IRQ_INPROGRESS;
256} 255}
257 256
258static inline void move_masked_irq(int irq) 257static inline void irqd_clr_chained_irq_inprogress(struct irq_data *d)
259{ 258{
259 d->state_use_accessors &= ~IRQD_IRQ_INPROGRESS;
260} 260}
261 261
262#endif /* CONFIG_GENERIC_PENDING_IRQ */ 262/**
263 * struct irq_chip - hardware interrupt chip descriptor
264 *
265 * @name: name for /proc/interrupts
266 * @irq_startup: start up the interrupt (defaults to ->enable if NULL)
267 * @irq_shutdown: shut down the interrupt (defaults to ->disable if NULL)
268 * @irq_enable: enable the interrupt (defaults to chip->unmask if NULL)
269 * @irq_disable: disable the interrupt
270 * @irq_ack: start of a new interrupt
271 * @irq_mask: mask an interrupt source
272 * @irq_mask_ack: ack and mask an interrupt source
273 * @irq_unmask: unmask an interrupt source
274 * @irq_eoi: end of interrupt
275 * @irq_set_affinity: set the CPU affinity on SMP machines
276 * @irq_retrigger: resend an IRQ to the CPU
277 * @irq_set_type: set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
278 * @irq_set_wake: enable/disable power-management wake-on of an IRQ
279 * @irq_bus_lock: function to lock access to slow bus (i2c) chips
280 * @irq_bus_sync_unlock:function to sync and unlock slow bus (i2c) chips
281 * @irq_cpu_online: configure an interrupt source for a secondary CPU
282 * @irq_cpu_offline: un-configure an interrupt source for a secondary CPU
283 * @irq_suspend: function called from core code on suspend once per chip
284 * @irq_resume: function called from core code on resume once per chip
285 * @irq_pm_shutdown: function called from core code on shutdown once per chip
286 * @irq_print_chip: optional to print special chip info in show_interrupts
287 * @flags: chip specific flags
288 *
289 * @release: release function solely used by UML
290 */
291struct irq_chip {
292 const char *name;
293 unsigned int (*irq_startup)(struct irq_data *data);
294 void (*irq_shutdown)(struct irq_data *data);
295 void (*irq_enable)(struct irq_data *data);
296 void (*irq_disable)(struct irq_data *data);
297
298 void (*irq_ack)(struct irq_data *data);
299 void (*irq_mask)(struct irq_data *data);
300 void (*irq_mask_ack)(struct irq_data *data);
301 void (*irq_unmask)(struct irq_data *data);
302 void (*irq_eoi)(struct irq_data *data);
263 303
264#else /* CONFIG_SMP */ 304 int (*irq_set_affinity)(struct irq_data *data, const struct cpumask *dest, bool force);
305 int (*irq_retrigger)(struct irq_data *data);
306 int (*irq_set_type)(struct irq_data *data, unsigned int flow_type);
307 int (*irq_set_wake)(struct irq_data *data, unsigned int on);
265 308
266#define move_native_irq(x) 309 void (*irq_bus_lock)(struct irq_data *data);
267#define move_masked_irq(x) 310 void (*irq_bus_sync_unlock)(struct irq_data *data);
268 311
269#endif /* CONFIG_SMP */ 312 void (*irq_cpu_online)(struct irq_data *data);
313 void (*irq_cpu_offline)(struct irq_data *data);
270 314
271extern int no_irq_affinity; 315 void (*irq_suspend)(struct irq_data *data);
316 void (*irq_resume)(struct irq_data *data);
317 void (*irq_pm_shutdown)(struct irq_data *data);
272 318
273static inline int irq_balancing_disabled(unsigned int irq) 319 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
274{
275 struct irq_desc *desc;
276 320
277 desc = irq_to_desc(irq); 321 unsigned long flags;
278 return desc->status & IRQ_NO_BALANCING_MASK; 322
279} 323 /* Currently used only by UML, might disappear one day.*/
324#ifdef CONFIG_IRQ_RELEASE_METHOD
325 void (*release)(unsigned int irq, void *dev_id);
326#endif
327};
328
329/*
330 * irq_chip specific flags
331 *
332 * IRQCHIP_SET_TYPE_MASKED: Mask before calling chip.irq_set_type()
333 * IRQCHIP_EOI_IF_HANDLED: Only issue irq_eoi() when irq was handled
334 * IRQCHIP_MASK_ON_SUSPEND: Mask non wake irqs in the suspend path
335 * IRQCHIP_ONOFFLINE_ENABLED: Only call irq_on/off_line callbacks
336 * when irq enabled
337 */
338enum {
339 IRQCHIP_SET_TYPE_MASKED = (1 << 0),
340 IRQCHIP_EOI_IF_HANDLED = (1 << 1),
341 IRQCHIP_MASK_ON_SUSPEND = (1 << 2),
342 IRQCHIP_ONOFFLINE_ENABLED = (1 << 3),
343};
280 344
281/* Handle irq action chains: */ 345/* This include will go away once we isolated irq_desc usage to core code */
282extern irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action); 346#include <linux/irqdesc.h>
347
348/*
349 * Pick up the arch-dependent methods:
350 */
351#include <asm/hw_irq.h>
352
353#ifndef NR_IRQS_LEGACY
354# define NR_IRQS_LEGACY 0
355#endif
356
357#ifndef ARCH_IRQ_INIT_FLAGS
358# define ARCH_IRQ_INIT_FLAGS 0
359#endif
360
361#define IRQ_DEFAULT_INIT_FLAGS ARCH_IRQ_INIT_FLAGS
362
363struct irqaction;
364extern int setup_irq(unsigned int irq, struct irqaction *new);
365extern void remove_irq(unsigned int irq, struct irqaction *act);
366
367extern void irq_cpu_online(void);
368extern void irq_cpu_offline(void);
369extern int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *cpumask);
370
371#ifdef CONFIG_GENERIC_HARDIRQS
372
373#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ)
374void irq_move_irq(struct irq_data *data);
375void irq_move_masked_irq(struct irq_data *data);
376#else
377static inline void irq_move_irq(struct irq_data *data) { }
378static inline void irq_move_masked_irq(struct irq_data *data) { }
379#endif
380
381extern int no_irq_affinity;
283 382
284/* 383/*
285 * Built-in IRQ handlers for various IRQ types, 384 * Built-in IRQ handlers for various IRQ types,
@@ -288,47 +387,16 @@ extern irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action);
288extern void handle_level_irq(unsigned int irq, struct irq_desc *desc); 387extern void handle_level_irq(unsigned int irq, struct irq_desc *desc);
289extern void handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc); 388extern void handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc);
290extern void handle_edge_irq(unsigned int irq, struct irq_desc *desc); 389extern void handle_edge_irq(unsigned int irq, struct irq_desc *desc);
390extern void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc);
291extern void handle_simple_irq(unsigned int irq, struct irq_desc *desc); 391extern void handle_simple_irq(unsigned int irq, struct irq_desc *desc);
292extern void handle_percpu_irq(unsigned int irq, struct irq_desc *desc); 392extern void handle_percpu_irq(unsigned int irq, struct irq_desc *desc);
293extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc); 393extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
294extern void handle_nested_irq(unsigned int irq); 394extern void handle_nested_irq(unsigned int irq);
295 395
296/*
297 * Monolithic do_IRQ implementation.
298 */
299#ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
300extern unsigned int __do_IRQ(unsigned int irq);
301#endif
302
303/*
304 * Architectures call this to let the generic IRQ layer
305 * handle an interrupt. If the descriptor is attached to an
306 * irqchip-style controller then we call the ->handle_irq() handler,
307 * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
308 */
309static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
310{
311#ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
312 desc->handle_irq(irq, desc);
313#else
314 if (likely(desc->handle_irq))
315 desc->handle_irq(irq, desc);
316 else
317 __do_IRQ(irq);
318#endif
319}
320
321static inline void generic_handle_irq(unsigned int irq)
322{
323 generic_handle_irq_desc(irq, irq_to_desc(irq));
324}
325
326/* Handling of unhandled and spurious interrupts: */ 396/* Handling of unhandled and spurious interrupts: */
327extern void note_interrupt(unsigned int irq, struct irq_desc *desc, 397extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
328 irqreturn_t action_ret); 398 irqreturn_t action_ret);
329 399
330/* Resending of interrupts :*/
331void check_irq_resend(struct irq_desc *desc, unsigned int irq);
332 400
333/* Enable/disable irq debugging output: */ 401/* Enable/disable irq debugging output: */
334extern int noirqdebug_setup(char *str); 402extern int noirqdebug_setup(char *str);
@@ -341,184 +409,314 @@ extern struct irq_chip no_irq_chip;
341extern struct irq_chip dummy_irq_chip; 409extern struct irq_chip dummy_irq_chip;
342 410
343extern void 411extern void
344set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip, 412irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
345 irq_flow_handler_t handle);
346extern void
347set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
348 irq_flow_handler_t handle, const char *name); 413 irq_flow_handler_t handle, const char *name);
349 414
350extern void 415static inline void irq_set_chip_and_handler(unsigned int irq, struct irq_chip *chip,
351__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, 416 irq_flow_handler_t handle)
352 const char *name);
353
354/* caller has locked the irq_desc and both params are valid */
355static inline void __set_irq_handler_unlocked(int irq,
356 irq_flow_handler_t handler)
357{ 417{
358 struct irq_desc *desc; 418 irq_set_chip_and_handler_name(irq, chip, handle, NULL);
359
360 desc = irq_to_desc(irq);
361 desc->handle_irq = handler;
362} 419}
363 420
364/* 421extern void
365 * Set a highlevel flow handler for a given IRQ: 422__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
366 */ 423 const char *name);
424
367static inline void 425static inline void
368set_irq_handler(unsigned int irq, irq_flow_handler_t handle) 426irq_set_handler(unsigned int irq, irq_flow_handler_t handle)
369{ 427{
370 __set_irq_handler(irq, handle, 0, NULL); 428 __irq_set_handler(irq, handle, 0, NULL);
371} 429}
372 430
373/* 431/*
374 * Set a highlevel chained flow handler for a given IRQ. 432 * Set a highlevel chained flow handler for a given IRQ.
375 * (a chained handler is automatically enabled and set to 433 * (a chained handler is automatically enabled and set to
376 * IRQ_NOREQUEST and IRQ_NOPROBE) 434 * IRQ_NOREQUEST, IRQ_NOPROBE, and IRQ_NOTHREAD)
377 */ 435 */
378static inline void 436static inline void
379set_irq_chained_handler(unsigned int irq, 437irq_set_chained_handler(unsigned int irq, irq_flow_handler_t handle)
380 irq_flow_handler_t handle) 438{
439 __irq_set_handler(irq, handle, 1, NULL);
440}
441
442void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set);
443
444static inline void irq_set_status_flags(unsigned int irq, unsigned long set)
445{
446 irq_modify_status(irq, 0, set);
447}
448
449static inline void irq_clear_status_flags(unsigned int irq, unsigned long clr)
450{
451 irq_modify_status(irq, clr, 0);
452}
453
454static inline void irq_set_noprobe(unsigned int irq)
455{
456 irq_modify_status(irq, 0, IRQ_NOPROBE);
457}
458
459static inline void irq_set_probe(unsigned int irq)
460{
461 irq_modify_status(irq, IRQ_NOPROBE, 0);
462}
463
464static inline void irq_set_nothread(unsigned int irq)
381{ 465{
382 __set_irq_handler(irq, handle, 1, NULL); 466 irq_modify_status(irq, 0, IRQ_NOTHREAD);
383} 467}
384 468
385extern void set_irq_nested_thread(unsigned int irq, int nest); 469static inline void irq_set_thread(unsigned int irq)
470{
471 irq_modify_status(irq, IRQ_NOTHREAD, 0);
472}
386 473
387extern void set_irq_noprobe(unsigned int irq); 474static inline void irq_set_nested_thread(unsigned int irq, bool nest)
388extern void set_irq_probe(unsigned int irq); 475{
476 if (nest)
477 irq_set_status_flags(irq, IRQ_NESTED_THREAD);
478 else
479 irq_clear_status_flags(irq, IRQ_NESTED_THREAD);
480}
389 481
390/* Handle dynamic irq creation and destruction */ 482/* Handle dynamic irq creation and destruction */
391extern unsigned int create_irq_nr(unsigned int irq_want, int node); 483extern unsigned int create_irq_nr(unsigned int irq_want, int node);
392extern int create_irq(void); 484extern int create_irq(void);
393extern void destroy_irq(unsigned int irq); 485extern void destroy_irq(unsigned int irq);
394 486
395/* Test to see if a driver has successfully requested an irq */ 487/*
396static inline int irq_has_action(unsigned int irq) 488 * Dynamic irq helper functions. Obsolete. Use irq_alloc_desc* and
489 * irq_free_desc instead.
490 */
491extern void dynamic_irq_cleanup(unsigned int irq);
492static inline void dynamic_irq_init(unsigned int irq)
397{ 493{
398 struct irq_desc *desc = irq_to_desc(irq); 494 dynamic_irq_cleanup(irq);
399 return desc->action != NULL;
400} 495}
401 496
402/* Dynamic irq helper functions */
403extern void dynamic_irq_init(unsigned int irq);
404void dynamic_irq_init_keep_chip_data(unsigned int irq);
405extern void dynamic_irq_cleanup(unsigned int irq);
406void dynamic_irq_cleanup_keep_chip_data(unsigned int irq);
407
408/* Set/get chip/data for an IRQ: */ 497/* Set/get chip/data for an IRQ: */
409extern int set_irq_chip(unsigned int irq, struct irq_chip *chip); 498extern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
410extern int set_irq_data(unsigned int irq, void *data); 499extern int irq_set_handler_data(unsigned int irq, void *data);
411extern int set_irq_chip_data(unsigned int irq, void *data); 500extern int irq_set_chip_data(unsigned int irq, void *data);
412extern int set_irq_type(unsigned int irq, unsigned int type); 501extern int irq_set_irq_type(unsigned int irq, unsigned int type);
413extern int set_irq_msi(unsigned int irq, struct msi_desc *entry); 502extern int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry);
414 503extern struct irq_data *irq_get_irq_data(unsigned int irq);
415#define get_irq_chip(irq) (irq_to_desc(irq)->chip) 504
416#define get_irq_chip_data(irq) (irq_to_desc(irq)->chip_data) 505static inline struct irq_chip *irq_get_chip(unsigned int irq)
417#define get_irq_data(irq) (irq_to_desc(irq)->handler_data) 506{
418#define get_irq_msi(irq) (irq_to_desc(irq)->msi_desc) 507 struct irq_data *d = irq_get_irq_data(irq);
419 508 return d ? d->chip : NULL;
420#define get_irq_desc_chip(desc) ((desc)->chip) 509}
421#define get_irq_desc_chip_data(desc) ((desc)->chip_data)
422#define get_irq_desc_data(desc) ((desc)->handler_data)
423#define get_irq_desc_msi(desc) ((desc)->msi_desc)
424 510
425#endif /* CONFIG_GENERIC_HARDIRQS */ 511static inline struct irq_chip *irq_data_get_irq_chip(struct irq_data *d)
512{
513 return d->chip;
514}
426 515
427#endif /* !CONFIG_S390 */ 516static inline void *irq_get_chip_data(unsigned int irq)
517{
518 struct irq_data *d = irq_get_irq_data(irq);
519 return d ? d->chip_data : NULL;
520}
428 521
429#ifdef CONFIG_SMP 522static inline void *irq_data_get_irq_chip_data(struct irq_data *d)
430/**
431 * alloc_desc_masks - allocate cpumasks for irq_desc
432 * @desc: pointer to irq_desc struct
433 * @node: node which will be handling the cpumasks
434 * @boot: true if need bootmem
435 *
436 * Allocates affinity and pending_mask cpumask if required.
437 * Returns true if successful (or not required).
438 */
439static inline bool alloc_desc_masks(struct irq_desc *desc, int node,
440 bool boot)
441{ 523{
442 gfp_t gfp = GFP_ATOMIC; 524 return d->chip_data;
525}
443 526
444 if (boot) 527static inline void *irq_get_handler_data(unsigned int irq)
445 gfp = GFP_NOWAIT; 528{
529 struct irq_data *d = irq_get_irq_data(irq);
530 return d ? d->handler_data : NULL;
531}
446 532
447#ifdef CONFIG_CPUMASK_OFFSTACK 533static inline void *irq_data_get_irq_handler_data(struct irq_data *d)
448 if (!alloc_cpumask_var_node(&desc->affinity, gfp, node)) 534{
449 return false; 535 return d->handler_data;
536}
450 537
451#ifdef CONFIG_GENERIC_PENDING_IRQ 538static inline struct msi_desc *irq_get_msi_desc(unsigned int irq)
452 if (!alloc_cpumask_var_node(&desc->pending_mask, gfp, node)) { 539{
453 free_cpumask_var(desc->affinity); 540 struct irq_data *d = irq_get_irq_data(irq);
454 return false; 541 return d ? d->msi_desc : NULL;
455 }
456#endif
457#endif
458 return true;
459} 542}
460 543
461static inline void init_desc_masks(struct irq_desc *desc) 544static inline struct msi_desc *irq_data_get_msi(struct irq_data *d)
462{ 545{
463 cpumask_setall(desc->affinity); 546 return d->msi_desc;
464#ifdef CONFIG_GENERIC_PENDING_IRQ
465 cpumask_clear(desc->pending_mask);
466#endif
467} 547}
468 548
469/** 549int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node);
470 * init_copy_desc_masks - copy cpumasks for irq_desc 550void irq_free_descs(unsigned int irq, unsigned int cnt);
471 * @old_desc: pointer to old irq_desc struct 551int irq_reserve_irqs(unsigned int from, unsigned int cnt);
472 * @new_desc: pointer to new irq_desc struct
473 *
474 * Insures affinity and pending_masks are copied to new irq_desc.
475 * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the
476 * irq_desc struct so the copy is redundant.
477 */
478 552
479static inline void init_copy_desc_masks(struct irq_desc *old_desc, 553static inline int irq_alloc_desc(int node)
480 struct irq_desc *new_desc)
481{ 554{
482#ifdef CONFIG_CPUMASK_OFFSTACK 555 return irq_alloc_descs(-1, 0, 1, node);
483 cpumask_copy(new_desc->affinity, old_desc->affinity);
484
485#ifdef CONFIG_GENERIC_PENDING_IRQ
486 cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);
487#endif
488#endif
489} 556}
490 557
491static inline void free_desc_masks(struct irq_desc *old_desc, 558static inline int irq_alloc_desc_at(unsigned int at, int node)
492 struct irq_desc *new_desc)
493{ 559{
494 free_cpumask_var(old_desc->affinity); 560 return irq_alloc_descs(at, at, 1, node);
561}
495 562
496#ifdef CONFIG_GENERIC_PENDING_IRQ 563static inline int irq_alloc_desc_from(unsigned int from, int node)
497 free_cpumask_var(old_desc->pending_mask); 564{
498#endif 565 return irq_alloc_descs(-1, from, 1, node);
499} 566}
500 567
501#else /* !CONFIG_SMP */ 568static inline void irq_free_desc(unsigned int irq)
569{
570 irq_free_descs(irq, 1);
571}
502 572
503static inline bool alloc_desc_masks(struct irq_desc *desc, int node, 573static inline int irq_reserve_irq(unsigned int irq)
504 bool boot)
505{ 574{
506 return true; 575 return irq_reserve_irqs(irq, 1);
507} 576}
508 577
509static inline void init_desc_masks(struct irq_desc *desc) 578#ifndef irq_reg_writel
579# define irq_reg_writel(val, addr) writel(val, addr)
580#endif
581#ifndef irq_reg_readl
582# define irq_reg_readl(addr) readl(addr)
583#endif
584
585/**
586 * struct irq_chip_regs - register offsets for struct irq_gci
587 * @enable: Enable register offset to reg_base
588 * @disable: Disable register offset to reg_base
589 * @mask: Mask register offset to reg_base
590 * @ack: Ack register offset to reg_base
591 * @eoi: Eoi register offset to reg_base
592 * @type: Type configuration register offset to reg_base
593 * @polarity: Polarity configuration register offset to reg_base
594 */
595struct irq_chip_regs {
596 unsigned long enable;
597 unsigned long disable;
598 unsigned long mask;
599 unsigned long ack;
600 unsigned long eoi;
601 unsigned long type;
602 unsigned long polarity;
603};
604
605/**
606 * struct irq_chip_type - Generic interrupt chip instance for a flow type
607 * @chip: The real interrupt chip which provides the callbacks
608 * @regs: Register offsets for this chip
609 * @handler: Flow handler associated with this chip
610 * @type: Chip can handle these flow types
611 *
612 * A irq_generic_chip can have several instances of irq_chip_type when
613 * it requires different functions and register offsets for different
614 * flow types.
615 */
616struct irq_chip_type {
617 struct irq_chip chip;
618 struct irq_chip_regs regs;
619 irq_flow_handler_t handler;
620 u32 type;
621};
622
623/**
624 * struct irq_chip_generic - Generic irq chip data structure
625 * @lock: Lock to protect register and cache data access
626 * @reg_base: Register base address (virtual)
627 * @irq_base: Interrupt base nr for this chip
628 * @irq_cnt: Number of interrupts handled by this chip
629 * @mask_cache: Cached mask register
630 * @type_cache: Cached type register
631 * @polarity_cache: Cached polarity register
632 * @wake_enabled: Interrupt can wakeup from suspend
633 * @wake_active: Interrupt is marked as an wakeup from suspend source
634 * @num_ct: Number of available irq_chip_type instances (usually 1)
635 * @private: Private data for non generic chip callbacks
636 * @list: List head for keeping track of instances
637 * @chip_types: Array of interrupt irq_chip_types
638 *
639 * Note, that irq_chip_generic can have multiple irq_chip_type
640 * implementations which can be associated to a particular irq line of
641 * an irq_chip_generic instance. That allows to share and protect
642 * state in an irq_chip_generic instance when we need to implement
643 * different flow mechanisms (level/edge) for it.
644 */
645struct irq_chip_generic {
646 raw_spinlock_t lock;
647 void __iomem *reg_base;
648 unsigned int irq_base;
649 unsigned int irq_cnt;
650 u32 mask_cache;
651 u32 type_cache;
652 u32 polarity_cache;
653 u32 wake_enabled;
654 u32 wake_active;
655 unsigned int num_ct;
656 void *private;
657 struct list_head list;
658 struct irq_chip_type chip_types[0];
659};
660
661/**
662 * enum irq_gc_flags - Initialization flags for generic irq chips
663 * @IRQ_GC_INIT_MASK_CACHE: Initialize the mask_cache by reading mask reg
664 * @IRQ_GC_INIT_NESTED_LOCK: Set the lock class of the irqs to nested for
665 * irq chips which need to call irq_set_wake() on
666 * the parent irq. Usually GPIO implementations
667 */
668enum irq_gc_flags {
669 IRQ_GC_INIT_MASK_CACHE = 1 << 0,
670 IRQ_GC_INIT_NESTED_LOCK = 1 << 1,
671};
672
673/* Generic chip callback functions */
674void irq_gc_noop(struct irq_data *d);
675void irq_gc_mask_disable_reg(struct irq_data *d);
676void irq_gc_mask_set_bit(struct irq_data *d);
677void irq_gc_mask_clr_bit(struct irq_data *d);
678void irq_gc_unmask_enable_reg(struct irq_data *d);
679void irq_gc_ack_set_bit(struct irq_data *d);
680void irq_gc_ack_clr_bit(struct irq_data *d);
681void irq_gc_mask_disable_reg_and_ack(struct irq_data *d);
682void irq_gc_eoi(struct irq_data *d);
683int irq_gc_set_wake(struct irq_data *d, unsigned int on);
684
685/* Setup functions for irq_chip_generic */
686struct irq_chip_generic *
687irq_alloc_generic_chip(const char *name, int nr_ct, unsigned int irq_base,
688 void __iomem *reg_base, irq_flow_handler_t handler);
689void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
690 enum irq_gc_flags flags, unsigned int clr,
691 unsigned int set);
692int irq_setup_alt_chip(struct irq_data *d, unsigned int type);
693void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
694 unsigned int clr, unsigned int set);
695
696static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
510{ 697{
698 return container_of(d->chip, struct irq_chip_type, chip);
511} 699}
512 700
513static inline void init_copy_desc_masks(struct irq_desc *old_desc, 701#define IRQ_MSK(n) (u32)((n) < 32 ? ((1 << (n)) - 1) : UINT_MAX)
514 struct irq_desc *new_desc) 702
703#ifdef CONFIG_SMP
704static inline void irq_gc_lock(struct irq_chip_generic *gc)
515{ 705{
706 raw_spin_lock(&gc->lock);
516} 707}
517 708
518static inline void free_desc_masks(struct irq_desc *old_desc, 709static inline void irq_gc_unlock(struct irq_chip_generic *gc)
519 struct irq_desc *new_desc)
520{ 710{
711 raw_spin_unlock(&gc->lock);
521} 712}
522#endif /* CONFIG_SMP */ 713#else
714static inline void irq_gc_lock(struct irq_chip_generic *gc) { }
715static inline void irq_gc_unlock(struct irq_chip_generic *gc) { }
716#endif
717
718#endif /* CONFIG_GENERIC_HARDIRQS */
719
720#endif /* !CONFIG_S390 */
523 721
524#endif /* _LINUX_IRQ_H */ 722#endif /* _LINUX_IRQ_H */
diff --git a/include/linux/irq_work.h b/include/linux/irq_work.h
new file mode 100644
index 000000000000..4fa09d4d0b71
--- /dev/null
+++ b/include/linux/irq_work.h
@@ -0,0 +1,20 @@
1#ifndef _LINUX_IRQ_WORK_H
2#define _LINUX_IRQ_WORK_H
3
4struct irq_work {
5 struct irq_work *next;
6 void (*func)(struct irq_work *);
7};
8
9static inline
10void init_irq_work(struct irq_work *entry, void (*func)(struct irq_work *))
11{
12 entry->next = NULL;
13 entry->func = func;
14}
15
16bool irq_work_queue(struct irq_work *entry);
17void irq_work_run(void);
18void irq_work_sync(struct irq_work *entry);
19
20#endif /* _LINUX_IRQ_WORK_H */
diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
new file mode 100644
index 000000000000..2d921b35212c
--- /dev/null
+++ b/include/linux/irqdesc.h
@@ -0,0 +1,175 @@
1#ifndef _LINUX_IRQDESC_H
2#define _LINUX_IRQDESC_H
3
4/*
5 * Core internal functions to deal with irq descriptors
6 *
7 * This include will move to kernel/irq once we cleaned up the tree.
8 * For now it's included from <linux/irq.h>
9 */
10
11struct irq_affinity_notify;
12struct proc_dir_entry;
13struct timer_rand_state;
14/**
15 * struct irq_desc - interrupt descriptor
16 * @irq_data: per irq and chip data passed down to chip functions
17 * @timer_rand_state: pointer to timer rand state struct
18 * @kstat_irqs: irq stats per cpu
19 * @handle_irq: highlevel irq-events handler
20 * @preflow_handler: handler called before the flow handler (currently used by sparc)
21 * @action: the irq action chain
22 * @status: status information
23 * @core_internal_state__do_not_mess_with_it: core internal status information
24 * @depth: disable-depth, for nested irq_disable() calls
25 * @wake_depth: enable depth, for multiple irq_set_irq_wake() callers
26 * @irq_count: stats field to detect stalled irqs
27 * @last_unhandled: aging timer for unhandled count
28 * @irqs_unhandled: stats field for spurious unhandled interrupts
29 * @lock: locking for SMP
30 * @affinity_hint: hint to user space for preferred irq affinity
31 * @affinity_notify: context for notification of affinity changes
32 * @pending_mask: pending rebalanced interrupts
33 * @threads_oneshot: bitfield to handle shared oneshot threads
34 * @threads_active: number of irqaction threads currently running
35 * @wait_for_threads: wait queue for sync_irq to wait for threaded handlers
36 * @dir: /proc/irq/ procfs entry
37 * @name: flow handler name for /proc/interrupts output
38 */
39struct irq_desc {
40 struct irq_data irq_data;
41 struct timer_rand_state *timer_rand_state;
42 unsigned int __percpu *kstat_irqs;
43 irq_flow_handler_t handle_irq;
44#ifdef CONFIG_IRQ_PREFLOW_FASTEOI
45 irq_preflow_handler_t preflow_handler;
46#endif
47 struct irqaction *action; /* IRQ action list */
48 unsigned int status_use_accessors;
49 unsigned int core_internal_state__do_not_mess_with_it;
50 unsigned int depth; /* nested irq disables */
51 unsigned int wake_depth; /* nested wake enables */
52 unsigned int irq_count; /* For detecting broken IRQs */
53 unsigned long last_unhandled; /* Aging timer for unhandled count */
54 unsigned int irqs_unhandled;
55 raw_spinlock_t lock;
56#ifdef CONFIG_SMP
57 const struct cpumask *affinity_hint;
58 struct irq_affinity_notify *affinity_notify;
59#ifdef CONFIG_GENERIC_PENDING_IRQ
60 cpumask_var_t pending_mask;
61#endif
62#endif
63 unsigned long threads_oneshot;
64 atomic_t threads_active;
65 wait_queue_head_t wait_for_threads;
66#ifdef CONFIG_PROC_FS
67 struct proc_dir_entry *dir;
68#endif
69 const char *name;
70} ____cacheline_internodealigned_in_smp;
71
72#ifndef CONFIG_SPARSE_IRQ
73extern struct irq_desc irq_desc[NR_IRQS];
74#endif
75
76#ifdef CONFIG_GENERIC_HARDIRQS
77
78static inline struct irq_data *irq_desc_get_irq_data(struct irq_desc *desc)
79{
80 return &desc->irq_data;
81}
82
83static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
84{
85 return desc->irq_data.chip;
86}
87
88static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
89{
90 return desc->irq_data.chip_data;
91}
92
93static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
94{
95 return desc->irq_data.handler_data;
96}
97
98static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
99{
100 return desc->irq_data.msi_desc;
101}
102
103/*
104 * Architectures call this to let the generic IRQ layer
105 * handle an interrupt. If the descriptor is attached to an
106 * irqchip-style controller then we call the ->handle_irq() handler,
107 * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
108 */
109static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
110{
111 desc->handle_irq(irq, desc);
112}
113
114int generic_handle_irq(unsigned int irq);
115
116/* Test to see if a driver has successfully requested an irq */
117static inline int irq_has_action(unsigned int irq)
118{
119 struct irq_desc *desc = irq_to_desc(irq);
120 return desc->action != NULL;
121}
122
123/* caller has locked the irq_desc and both params are valid */
124static inline void __irq_set_handler_locked(unsigned int irq,
125 irq_flow_handler_t handler)
126{
127 struct irq_desc *desc;
128
129 desc = irq_to_desc(irq);
130 desc->handle_irq = handler;
131}
132
133/* caller has locked the irq_desc and both params are valid */
134static inline void
135__irq_set_chip_handler_name_locked(unsigned int irq, struct irq_chip *chip,
136 irq_flow_handler_t handler, const char *name)
137{
138 struct irq_desc *desc;
139
140 desc = irq_to_desc(irq);
141 irq_desc_get_irq_data(desc)->chip = chip;
142 desc->handle_irq = handler;
143 desc->name = name;
144}
145
146static inline int irq_balancing_disabled(unsigned int irq)
147{
148 struct irq_desc *desc;
149
150 desc = irq_to_desc(irq);
151 return desc->status_use_accessors & IRQ_NO_BALANCING_MASK;
152}
153
154static inline void
155irq_set_lockdep_class(unsigned int irq, struct lock_class_key *class)
156{
157 struct irq_desc *desc = irq_to_desc(irq);
158
159 if (desc)
160 lockdep_set_class(&desc->lock, class);
161}
162
163#ifdef CONFIG_IRQ_PREFLOW_FASTEOI
164static inline void
165__irq_set_preflow_handler(unsigned int irq, irq_preflow_handler_t handler)
166{
167 struct irq_desc *desc;
168
169 desc = irq_to_desc(irq);
170 desc->preflow_handler = handler;
171}
172#endif
173#endif
174
175#endif
diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
index 006bf45eae30..d176d658fe25 100644
--- a/include/linux/irqflags.h
+++ b/include/linux/irqflags.h
@@ -12,6 +12,7 @@
12#define _LINUX_TRACE_IRQFLAGS_H 12#define _LINUX_TRACE_IRQFLAGS_H
13 13
14#include <linux/typecheck.h> 14#include <linux/typecheck.h>
15#include <asm/irqflags.h>
15 16
16#ifdef CONFIG_TRACE_IRQFLAGS 17#ifdef CONFIG_TRACE_IRQFLAGS
17 extern void trace_softirqs_on(unsigned long ip); 18 extern void trace_softirqs_on(unsigned long ip);
@@ -52,17 +53,45 @@
52# define start_critical_timings() do { } while (0) 53# define start_critical_timings() do { } while (0)
53#endif 54#endif
54 55
55#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT 56/*
56 57 * Wrap the arch provided IRQ routines to provide appropriate checks.
57#include <asm/irqflags.h> 58 */
59#define raw_local_irq_disable() arch_local_irq_disable()
60#define raw_local_irq_enable() arch_local_irq_enable()
61#define raw_local_irq_save(flags) \
62 do { \
63 typecheck(unsigned long, flags); \
64 flags = arch_local_irq_save(); \
65 } while (0)
66#define raw_local_irq_restore(flags) \
67 do { \
68 typecheck(unsigned long, flags); \
69 arch_local_irq_restore(flags); \
70 } while (0)
71#define raw_local_save_flags(flags) \
72 do { \
73 typecheck(unsigned long, flags); \
74 flags = arch_local_save_flags(); \
75 } while (0)
76#define raw_irqs_disabled_flags(flags) \
77 ({ \
78 typecheck(unsigned long, flags); \
79 arch_irqs_disabled_flags(flags); \
80 })
81#define raw_irqs_disabled() (arch_irqs_disabled())
82#define raw_safe_halt() arch_safe_halt()
58 83
84/*
85 * The local_irq_*() APIs are equal to the raw_local_irq*()
86 * if !TRACE_IRQFLAGS.
87 */
88#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
59#define local_irq_enable() \ 89#define local_irq_enable() \
60 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0) 90 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
61#define local_irq_disable() \ 91#define local_irq_disable() \
62 do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0) 92 do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
63#define local_irq_save(flags) \ 93#define local_irq_save(flags) \
64 do { \ 94 do { \
65 typecheck(unsigned long, flags); \
66 raw_local_irq_save(flags); \ 95 raw_local_irq_save(flags); \
67 trace_hardirqs_off(); \ 96 trace_hardirqs_off(); \
68 } while (0) 97 } while (0)
@@ -70,7 +99,6 @@
70 99
71#define local_irq_restore(flags) \ 100#define local_irq_restore(flags) \
72 do { \ 101 do { \
73 typecheck(unsigned long, flags); \
74 if (raw_irqs_disabled_flags(flags)) { \ 102 if (raw_irqs_disabled_flags(flags)) { \
75 raw_local_irq_restore(flags); \ 103 raw_local_irq_restore(flags); \
76 trace_hardirqs_off(); \ 104 trace_hardirqs_off(); \
@@ -79,51 +107,44 @@
79 raw_local_irq_restore(flags); \ 107 raw_local_irq_restore(flags); \
80 } \ 108 } \
81 } while (0) 109 } while (0)
82#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ 110#define local_save_flags(flags) \
83/*
84 * The local_irq_*() APIs are equal to the raw_local_irq*()
85 * if !TRACE_IRQFLAGS.
86 */
87# define raw_local_irq_disable() local_irq_disable()
88# define raw_local_irq_enable() local_irq_enable()
89# define raw_local_irq_save(flags) \
90 do { \
91 typecheck(unsigned long, flags); \
92 local_irq_save(flags); \
93 } while (0)
94# define raw_local_irq_restore(flags) \
95 do { \ 111 do { \
96 typecheck(unsigned long, flags); \ 112 raw_local_save_flags(flags); \
97 local_irq_restore(flags); \
98 } while (0) 113 } while (0)
99#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
100 114
101#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT 115#define irqs_disabled_flags(flags) \
102#define safe_halt() \ 116 ({ \
103 do { \ 117 raw_irqs_disabled_flags(flags); \
104 trace_hardirqs_on(); \ 118 })
105 raw_safe_halt(); \
106 } while (0)
107 119
108#define local_save_flags(flags) \ 120#define irqs_disabled() \
109 do { \ 121 ({ \
110 typecheck(unsigned long, flags); \ 122 unsigned long _flags; \
111 raw_local_save_flags(flags); \ 123 raw_local_save_flags(_flags); \
124 raw_irqs_disabled_flags(_flags); \
125 })
126
127#define safe_halt() \
128 do { \
129 trace_hardirqs_on(); \
130 raw_safe_halt(); \
112 } while (0) 131 } while (0)
113 132
114#define irqs_disabled() \
115({ \
116 unsigned long _flags; \
117 \
118 raw_local_save_flags(_flags); \
119 raw_irqs_disabled_flags(_flags); \
120})
121 133
122#define irqs_disabled_flags(flags) \ 134#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
123({ \ 135
124 typecheck(unsigned long, flags); \ 136#define local_irq_enable() do { raw_local_irq_enable(); } while (0)
125 raw_irqs_disabled_flags(flags); \ 137#define local_irq_disable() do { raw_local_irq_disable(); } while (0)
126}) 138#define local_irq_save(flags) \
139 do { \
140 raw_local_irq_save(flags); \
141 } while (0)
142#define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
143#define local_save_flags(flags) do { raw_local_save_flags(flags); } while (0)
144#define irqs_disabled() (raw_irqs_disabled())
145#define irqs_disabled_flags(flags) (raw_irqs_disabled_flags(flags))
146#define safe_halt() do { raw_safe_halt(); } while (0)
147
127#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ 148#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
128 149
129#endif 150#endif
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 7bf89bc8cbca..3bc4dcab6e82 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -25,6 +25,7 @@
25 25
26extern int nr_irqs; 26extern int nr_irqs;
27extern struct irq_desc *irq_to_desc(unsigned int irq); 27extern struct irq_desc *irq_to_desc(unsigned int irq);
28unsigned int irq_get_next_irq(unsigned int offset);
28 29
29# define for_each_irq_desc(irq, desc) \ 30# define for_each_irq_desc(irq, desc) \
30 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \ 31 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
@@ -42,11 +43,15 @@ extern struct irq_desc *irq_to_desc(unsigned int irq);
42 else 43 else
43 44
44#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
45#define irq_node(irq) (irq_to_desc(irq)->node) 46#define irq_node(irq) (irq_get_irq_data(irq)->node)
46#else 47#else
47#define irq_node(irq) 0 48#define irq_node(irq) 0
48#endif 49#endif
49 50
51# define for_each_active_irq(irq) \
52 for (irq = irq_get_next_irq(0); irq < nr_irqs; \
53 irq = irq_get_next_irq(irq + 1))
54
50#endif /* CONFIG_GENERIC_HARDIRQS */ 55#endif /* CONFIG_GENERIC_HARDIRQS */
51 56
52#define for_each_irq_nr(irq) \ 57#define for_each_irq_nr(irq) \
diff --git a/include/linux/irqreturn.h b/include/linux/irqreturn.h
index 819acaaac3f5..714ba08dc092 100644
--- a/include/linux/irqreturn.h
+++ b/include/linux/irqreturn.h
@@ -8,9 +8,9 @@
8 * @IRQ_WAKE_THREAD handler requests to wake the handler thread 8 * @IRQ_WAKE_THREAD handler requests to wake the handler thread
9 */ 9 */
10enum irqreturn { 10enum irqreturn {
11 IRQ_NONE, 11 IRQ_NONE = (0 << 0),
12 IRQ_HANDLED, 12 IRQ_HANDLED = (1 << 0),
13 IRQ_WAKE_THREAD, 13 IRQ_WAKE_THREAD = (1 << 1),
14}; 14};
15 15
16typedef enum irqreturn irqreturn_t; 16typedef enum irqreturn irqreturn_t;
diff --git a/include/linux/isdn/hdlc.h b/include/linux/isdn/hdlc.h
index 4b3ecc40889a..96521370c782 100644
--- a/include/linux/isdn/hdlc.h
+++ b/include/linux/isdn/hdlc.h
@@ -2,7 +2,7 @@
2 * hdlc.h -- General purpose ISDN HDLC decoder. 2 * hdlc.h -- General purpose ISDN HDLC decoder.
3 * 3 *
4 * Implementation of a HDLC decoder/encoder in software. 4 * Implementation of a HDLC decoder/encoder in software.
5 * Neccessary because some ISDN devices don't have HDLC 5 * Necessary because some ISDN devices don't have HDLC
6 * controllers. 6 * controllers.
7 * 7 *
8 * Copyright (C) 8 * Copyright (C)
diff --git a/include/linux/ixjuser.h b/include/linux/ixjuser.h
index 88b45895746d..94ab5e942e53 100644
--- a/include/linux/ixjuser.h
+++ b/include/linux/ixjuser.h
@@ -50,7 +50,7 @@
50* IOCTL's used for the Quicknet Telephony Cards 50* IOCTL's used for the Quicknet Telephony Cards
51* 51*
52* If you use the IXJCTL_TESTRAM command, the card must be power cycled to 52* If you use the IXJCTL_TESTRAM command, the card must be power cycled to
53* reset the SRAM values before futher use. 53* reset the SRAM values before further use.
54* 54*
55******************************************************************************/ 55******************************************************************************/
56 56
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 0b52924a0cb6..d087c2e7b2aa 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -94,7 +94,7 @@ extern void jbd2_free(void *ptr, size_t size);
94 * 94 *
95 * This is an opaque datatype. 95 * This is an opaque datatype.
96 **/ 96 **/
97typedef struct handle_s handle_t; /* Atomic operation type */ 97typedef struct jbd2_journal_handle handle_t; /* Atomic operation type */
98 98
99 99
100/** 100/**
@@ -395,7 +395,7 @@ struct jbd2_inode {
395 struct inode *i_vfs_inode; 395 struct inode *i_vfs_inode;
396 396
397 /* Flags of inode [j_list_lock] */ 397 /* Flags of inode [j_list_lock] */
398 unsigned int i_flags; 398 unsigned long i_flags;
399}; 399};
400 400
401struct jbd2_revoke_table_s; 401struct jbd2_revoke_table_s;
@@ -416,7 +416,7 @@ struct jbd2_revoke_table_s;
416 * in so it can be fixed later. 416 * in so it can be fixed later.
417 */ 417 */
418 418
419struct handle_s 419struct jbd2_journal_handle
420{ 420{
421 /* Which compound transaction is this update a part of? */ 421 /* Which compound transaction is this update a part of? */
422 transaction_t *h_transaction; 422 transaction_t *h_transaction;
@@ -432,13 +432,35 @@ struct handle_s
432 int h_err; 432 int h_err;
433 433
434 /* Flags [no locking] */ 434 /* Flags [no locking] */
435 unsigned int h_sync: 1; /* sync-on-close */ 435 unsigned int h_sync:1; /* sync-on-close */
436 unsigned int h_jdata: 1; /* force data journaling */ 436 unsigned int h_jdata:1; /* force data journaling */
437 unsigned int h_aborted: 1; /* fatal error on handle */ 437 unsigned int h_aborted:1; /* fatal error on handle */
438 unsigned int h_cowing:1; /* COWing block to snapshot */
439
440 /* Number of buffers requested by user:
441 * (before adding the COW credits factor) */
442 unsigned int h_base_credits:14;
443
444 /* Number of buffers the user is allowed to dirty:
445 * (counts only buffers dirtied when !h_cowing) */
446 unsigned int h_user_credits:14;
447
438 448
439#ifdef CONFIG_DEBUG_LOCK_ALLOC 449#ifdef CONFIG_DEBUG_LOCK_ALLOC
440 struct lockdep_map h_lockdep_map; 450 struct lockdep_map h_lockdep_map;
441#endif 451#endif
452
453#ifdef CONFIG_JBD2_DEBUG
454 /* COW debugging counters: */
455 unsigned int h_cow_moved; /* blocks moved to snapshot */
456 unsigned int h_cow_copied; /* blocks copied to snapshot */
457 unsigned int h_cow_ok_jh; /* blocks already COWed during current
458 transaction */
459 unsigned int h_cow_ok_bitmap; /* blocks not set in COW bitmap */
460 unsigned int h_cow_ok_mapped;/* blocks already mapped in snapshot */
461 unsigned int h_cow_bitmaps; /* COW bitmaps created */
462 unsigned int h_cow_excluded; /* blocks set in exclude bitmap */
463#endif
442}; 464};
443 465
444 466
@@ -507,9 +529,10 @@ struct transaction_s
507 enum { 529 enum {
508 T_RUNNING, 530 T_RUNNING,
509 T_LOCKED, 531 T_LOCKED,
510 T_RUNDOWN,
511 T_FLUSH, 532 T_FLUSH,
512 T_COMMIT, 533 T_COMMIT,
534 T_COMMIT_DFLUSH,
535 T_COMMIT_JFLUSH,
513 T_FINISHED 536 T_FINISHED
514 } t_state; 537 } t_state;
515 538
@@ -636,7 +659,9 @@ struct transaction_s
636 * waiting for it to finish. 659 * waiting for it to finish.
637 */ 660 */
638 unsigned int t_synchronous_commit:1; 661 unsigned int t_synchronous_commit:1;
639 unsigned int t_flushed_data_blocks:1; 662
663 /* Disk flush needs to be sent to fs partition [no locking] */
664 int t_need_data_flush;
640 665
641 /* 666 /*
642 * For use by the filesystem to store fs-specific data 667 * For use by the filesystem to store fs-specific data
@@ -999,7 +1024,6 @@ struct journal_s
999 1024
1000/* Filing buffers */ 1025/* Filing buffers */
1001extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *); 1026extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
1002extern void __jbd2_journal_unfile_buffer(struct journal_head *);
1003extern void __jbd2_journal_refile_buffer(struct journal_head *); 1027extern void __jbd2_journal_refile_buffer(struct journal_head *);
1004extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *); 1028extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
1005extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int); 1029extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
@@ -1140,7 +1164,6 @@ extern void jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_in
1140 */ 1164 */
1141struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh); 1165struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh);
1142struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh); 1166struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh);
1143void jbd2_journal_remove_journal_head(struct buffer_head *bh);
1144void jbd2_journal_put_journal_head(struct journal_head *jh); 1167void jbd2_journal_put_journal_head(struct journal_head *jh);
1145 1168
1146/* 1169/*
@@ -1158,6 +1181,22 @@ static inline void jbd2_free_handle(handle_t *handle)
1158 kmem_cache_free(jbd2_handle_cache, handle); 1181 kmem_cache_free(jbd2_handle_cache, handle);
1159} 1182}
1160 1183
1184/*
1185 * jbd2_inode management (optional, for those file systems that want to use
1186 * dynamically allocated jbd2_inode structures)
1187 */
1188extern struct kmem_cache *jbd2_inode_cache;
1189
1190static inline struct jbd2_inode *jbd2_alloc_inode(gfp_t gfp_flags)
1191{
1192 return kmem_cache_alloc(jbd2_inode_cache, gfp_flags);
1193}
1194
1195static inline void jbd2_free_inode(struct jbd2_inode *jinode)
1196{
1197 kmem_cache_free(jbd2_inode_cache, jinode);
1198}
1199
1161/* Primary revoke support */ 1200/* Primary revoke support */
1162#define JOURNAL_REVOKE_DEFAULT_HASH 256 1201#define JOURNAL_REVOKE_DEFAULT_HASH 256
1163extern int jbd2_journal_init_revoke(journal_t *, int); 1202extern int jbd2_journal_init_revoke(journal_t *, int);
@@ -1190,6 +1229,7 @@ int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
1190int jbd2_journal_force_commit_nested(journal_t *journal); 1229int jbd2_journal_force_commit_nested(journal_t *journal);
1191int jbd2_log_wait_commit(journal_t *journal, tid_t tid); 1230int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
1192int jbd2_log_do_checkpoint(journal_t *journal); 1231int jbd2_log_do_checkpoint(journal_t *journal);
1232int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid);
1193 1233
1194void __jbd2_log_wait_for_space(journal_t *journal); 1234void __jbd2_log_wait_for_space(journal_t *journal);
1195extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *); 1235extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
diff --git a/include/linux/jhash.h b/include/linux/jhash.h
index 2a2f99fbcb16..47cb09edec1a 100644
--- a/include/linux/jhash.h
+++ b/include/linux/jhash.h
@@ -3,129 +3,156 @@
3 3
4/* jhash.h: Jenkins hash support. 4/* jhash.h: Jenkins hash support.
5 * 5 *
6 * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net) 6 * Copyright (C) 2006. Bob Jenkins (bob_jenkins@burtleburtle.net)
7 * 7 *
8 * http://burtleburtle.net/bob/hash/ 8 * http://burtleburtle.net/bob/hash/
9 * 9 *
10 * These are the credits from Bob's sources: 10 * These are the credits from Bob's sources:
11 * 11 *
12 * lookup2.c, by Bob Jenkins, December 1996, Public Domain. 12 * lookup3.c, by Bob Jenkins, May 2006, Public Domain.
13 * hash(), hash2(), hash3, and mix() are externally useful functions.
14 * Routines to test the hash are included if SELF_TEST is defined.
15 * You can use this free for any purpose. It has no warranty.
16 * 13 *
17 * Copyright (C) 2003 David S. Miller (davem@redhat.com) 14 * These are functions for producing 32-bit hashes for hash table lookup.
15 * hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
16 * are externally useful functions. Routines to test the hash are included
17 * if SELF_TEST is defined. You can use this free for any purpose. It's in
18 * the public domain. It has no warranty.
19 *
20 * Copyright (C) 2009-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
18 * 21 *
19 * I've modified Bob's hash to be useful in the Linux kernel, and 22 * I've modified Bob's hash to be useful in the Linux kernel, and
20 * any bugs present are surely my fault. -DaveM 23 * any bugs present are my fault.
24 * Jozsef
21 */ 25 */
26#include <linux/bitops.h>
27#include <linux/unaligned/packed_struct.h>
28
29/* Best hash sizes are of power of two */
30#define jhash_size(n) ((u32)1<<(n))
31/* Mask the hash value, i.e (value & jhash_mask(n)) instead of (value % n) */
32#define jhash_mask(n) (jhash_size(n)-1)
33
34/* __jhash_mix -- mix 3 32-bit values reversibly. */
35#define __jhash_mix(a, b, c) \
36{ \
37 a -= c; a ^= rol32(c, 4); c += b; \
38 b -= a; b ^= rol32(a, 6); a += c; \
39 c -= b; c ^= rol32(b, 8); b += a; \
40 a -= c; a ^= rol32(c, 16); c += b; \
41 b -= a; b ^= rol32(a, 19); a += c; \
42 c -= b; c ^= rol32(b, 4); b += a; \
43}
22 44
23/* NOTE: Arguments are modified. */ 45/* __jhash_final - final mixing of 3 32-bit values (a,b,c) into c */
24#define __jhash_mix(a, b, c) \ 46#define __jhash_final(a, b, c) \
25{ \ 47{ \
26 a -= b; a -= c; a ^= (c>>13); \ 48 c ^= b; c -= rol32(b, 14); \
27 b -= c; b -= a; b ^= (a<<8); \ 49 a ^= c; a -= rol32(c, 11); \
28 c -= a; c -= b; c ^= (b>>13); \ 50 b ^= a; b -= rol32(a, 25); \
29 a -= b; a -= c; a ^= (c>>12); \ 51 c ^= b; c -= rol32(b, 16); \
30 b -= c; b -= a; b ^= (a<<16); \ 52 a ^= c; a -= rol32(c, 4); \
31 c -= a; c -= b; c ^= (b>>5); \ 53 b ^= a; b -= rol32(a, 14); \
32 a -= b; a -= c; a ^= (c>>3); \ 54 c ^= b; c -= rol32(b, 24); \
33 b -= c; b -= a; b ^= (a<<10); \
34 c -= a; c -= b; c ^= (b>>15); \
35} 55}
36 56
37/* The golden ration: an arbitrary value */ 57/* An arbitrary initial parameter */
38#define JHASH_GOLDEN_RATIO 0x9e3779b9 58#define JHASH_INITVAL 0xdeadbeef
39 59
40/* The most generic version, hashes an arbitrary sequence 60/* jhash - hash an arbitrary key
41 * of bytes. No alignment or length assumptions are made about 61 * @k: sequence of bytes as key
42 * the input key. 62 * @length: the length of the key
63 * @initval: the previous hash, or an arbitray value
64 *
65 * The generic version, hashes an arbitrary sequence of bytes.
66 * No alignment or length assumptions are made about the input key.
67 *
68 * Returns the hash value of the key. The result depends on endianness.
43 */ 69 */
44static inline u32 jhash(const void *key, u32 length, u32 initval) 70static inline u32 jhash(const void *key, u32 length, u32 initval)
45{ 71{
46 u32 a, b, c, len; 72 u32 a, b, c;
47 const u8 *k = key; 73 const u8 *k = key;
48 74
49 len = length; 75 /* Set up the internal state */
50 a = b = JHASH_GOLDEN_RATIO; 76 a = b = c = JHASH_INITVAL + length + initval;
51 c = initval;
52
53 while (len >= 12) {
54 a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24));
55 b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24));
56 c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24));
57
58 __jhash_mix(a,b,c);
59 77
78 /* All but the last block: affect some 32 bits of (a,b,c) */
79 while (length > 12) {
80 a += __get_unaligned_cpu32(k);
81 b += __get_unaligned_cpu32(k + 4);
82 c += __get_unaligned_cpu32(k + 8);
83 __jhash_mix(a, b, c);
84 length -= 12;
60 k += 12; 85 k += 12;
61 len -= 12;
62 } 86 }
63 87 /* Last block: affect all 32 bits of (c) */
64 c += length; 88 /* All the case statements fall through */
65 switch (len) { 89 switch (length) {
66 case 11: c += ((u32)k[10]<<24); 90 case 12: c += (u32)k[11]<<24;
67 case 10: c += ((u32)k[9]<<16); 91 case 11: c += (u32)k[10]<<16;
68 case 9 : c += ((u32)k[8]<<8); 92 case 10: c += (u32)k[9]<<8;
69 case 8 : b += ((u32)k[7]<<24); 93 case 9: c += k[8];
70 case 7 : b += ((u32)k[6]<<16); 94 case 8: b += (u32)k[7]<<24;
71 case 6 : b += ((u32)k[5]<<8); 95 case 7: b += (u32)k[6]<<16;
72 case 5 : b += k[4]; 96 case 6: b += (u32)k[5]<<8;
73 case 4 : a += ((u32)k[3]<<24); 97 case 5: b += k[4];
74 case 3 : a += ((u32)k[2]<<16); 98 case 4: a += (u32)k[3]<<24;
75 case 2 : a += ((u32)k[1]<<8); 99 case 3: a += (u32)k[2]<<16;
76 case 1 : a += k[0]; 100 case 2: a += (u32)k[1]<<8;
77 }; 101 case 1: a += k[0];
78 102 __jhash_final(a, b, c);
79 __jhash_mix(a,b,c); 103 case 0: /* Nothing left to add */
104 break;
105 }
80 106
81 return c; 107 return c;
82} 108}
83 109
84/* A special optimized version that handles 1 or more of u32s. 110/* jhash2 - hash an array of u32's
85 * The length parameter here is the number of u32s in the key. 111 * @k: the key which must be an array of u32's
112 * @length: the number of u32's in the key
113 * @initval: the previous hash, or an arbitray value
114 *
115 * Returns the hash value of the key.
86 */ 116 */
87static inline u32 jhash2(const u32 *k, u32 length, u32 initval) 117static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
88{ 118{
89 u32 a, b, c, len; 119 u32 a, b, c;
90 120
91 a = b = JHASH_GOLDEN_RATIO; 121 /* Set up the internal state */
92 c = initval; 122 a = b = c = JHASH_INITVAL + (length<<2) + initval;
93 len = length;
94 123
95 while (len >= 3) { 124 /* Handle most of the key */
125 while (length > 3) {
96 a += k[0]; 126 a += k[0];
97 b += k[1]; 127 b += k[1];
98 c += k[2]; 128 c += k[2];
99 __jhash_mix(a, b, c); 129 __jhash_mix(a, b, c);
100 k += 3; len -= 3; 130 length -= 3;
131 k += 3;
101 } 132 }
102 133
103 c += length * 4; 134 /* Handle the last 3 u32's: all the case statements fall through */
104 135 switch (length) {
105 switch (len) { 136 case 3: c += k[2];
106 case 2 : b += k[1]; 137 case 2: b += k[1];
107 case 1 : a += k[0]; 138 case 1: a += k[0];
108 }; 139 __jhash_final(a, b, c);
109 140 case 0: /* Nothing left to add */
110 __jhash_mix(a,b,c); 141 break;
142 }
111 143
112 return c; 144 return c;
113} 145}
114 146
115 147
116/* A special ultra-optimized versions that knows they are hashing exactly 148/* jhash_3words - hash exactly 3, 2 or 1 word(s) */
117 * 3, 2 or 1 word(s).
118 *
119 * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
120 * done at the end is not done here.
121 */
122static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval) 149static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
123{ 150{
124 a += JHASH_GOLDEN_RATIO; 151 a += JHASH_INITVAL;
125 b += JHASH_GOLDEN_RATIO; 152 b += JHASH_INITVAL;
126 c += initval; 153 c += initval;
127 154
128 __jhash_mix(a, b, c); 155 __jhash_final(a, b, c);
129 156
130 return c; 157 return c;
131} 158}
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 6811f4bfc6e7..f97672a36fa8 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -42,7 +42,7 @@
42/* LATCH is used in the interval timer and ftape setup. */ 42/* LATCH is used in the interval timer and ftape setup. */
43#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ 43#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
44 44
45/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, then we can 45/* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can
46 * improve accuracy by shifting LSH bits, hence calculating: 46 * improve accuracy by shifting LSH bits, hence calculating:
47 * (NOM << LSH) / DEN 47 * (NOM << LSH) / DEN
48 * This however means trouble for large NOM, because (NOM << LSH) may no 48 * This however means trouble for large NOM, because (NOM << LSH) may no
@@ -307,6 +307,7 @@ extern clock_t jiffies_to_clock_t(long x);
307extern unsigned long clock_t_to_jiffies(unsigned long x); 307extern unsigned long clock_t_to_jiffies(unsigned long x);
308extern u64 jiffies_64_to_clock_t(u64 x); 308extern u64 jiffies_64_to_clock_t(u64 x);
309extern u64 nsec_to_clock_t(u64 x); 309extern u64 nsec_to_clock_t(u64 x);
310extern u64 nsecs_to_jiffies64(u64 n);
310extern unsigned long nsecs_to_jiffies(u64 n); 311extern unsigned long nsecs_to_jiffies(u64 n);
311 312
312#define TIMESTAMP_SIZE 30 313#define TIMESTAMP_SIZE 30
diff --git a/include/linux/journal-head.h b/include/linux/journal-head.h
index 525aac3c97df..44e95d0a721f 100644
--- a/include/linux/journal-head.h
+++ b/include/linux/journal-head.h
@@ -41,6 +41,13 @@ struct journal_head {
41 unsigned b_modified; 41 unsigned b_modified;
42 42
43 /* 43 /*
44 * This feild tracks the last transaction id in which this buffer
45 * has been cowed
46 * [jbd_lock_bh_state()]
47 */
48 unsigned b_cow_tid;
49
50 /*
44 * Copy of the buffer data frozen for writing to the log. 51 * Copy of the buffer data frozen for writing to the log.
45 * [jbd_lock_bh_state()] 52 * [jbd_lock_bh_state()]
46 */ 53 */
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
new file mode 100644
index 000000000000..83e745f3ead7
--- /dev/null
+++ b/include/linux/jump_label.h
@@ -0,0 +1,102 @@
1#ifndef _LINUX_JUMP_LABEL_H
2#define _LINUX_JUMP_LABEL_H
3
4#include <linux/types.h>
5#include <linux/compiler.h>
6
7#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
8
9struct jump_label_key {
10 atomic_t enabled;
11 struct jump_entry *entries;
12#ifdef CONFIG_MODULES
13 struct jump_label_mod *next;
14#endif
15};
16
17# include <asm/jump_label.h>
18# define HAVE_JUMP_LABEL
19#endif
20
21enum jump_label_type {
22 JUMP_LABEL_DISABLE = 0,
23 JUMP_LABEL_ENABLE,
24};
25
26struct module;
27
28#ifdef HAVE_JUMP_LABEL
29
30#ifdef CONFIG_MODULES
31#define JUMP_LABEL_INIT {{ 0 }, NULL, NULL}
32#else
33#define JUMP_LABEL_INIT {{ 0 }, NULL}
34#endif
35
36static __always_inline bool static_branch(struct jump_label_key *key)
37{
38 return arch_static_branch(key);
39}
40
41extern struct jump_entry __start___jump_table[];
42extern struct jump_entry __stop___jump_table[];
43
44extern void jump_label_lock(void);
45extern void jump_label_unlock(void);
46extern void arch_jump_label_transform(struct jump_entry *entry,
47 enum jump_label_type type);
48extern void arch_jump_label_text_poke_early(jump_label_t addr);
49extern int jump_label_text_reserved(void *start, void *end);
50extern void jump_label_inc(struct jump_label_key *key);
51extern void jump_label_dec(struct jump_label_key *key);
52extern bool jump_label_enabled(struct jump_label_key *key);
53extern void jump_label_apply_nops(struct module *mod);
54
55#else
56
57#include <asm/atomic.h>
58
59#define JUMP_LABEL_INIT {ATOMIC_INIT(0)}
60
61struct jump_label_key {
62 atomic_t enabled;
63};
64
65static __always_inline bool static_branch(struct jump_label_key *key)
66{
67 if (unlikely(atomic_read(&key->enabled)))
68 return true;
69 return false;
70}
71
72static inline void jump_label_inc(struct jump_label_key *key)
73{
74 atomic_inc(&key->enabled);
75}
76
77static inline void jump_label_dec(struct jump_label_key *key)
78{
79 atomic_dec(&key->enabled);
80}
81
82static inline int jump_label_text_reserved(void *start, void *end)
83{
84 return 0;
85}
86
87static inline void jump_label_lock(void) {}
88static inline void jump_label_unlock(void) {}
89
90static inline bool jump_label_enabled(struct jump_label_key *key)
91{
92 return !!atomic_read(&key->enabled);
93}
94
95static inline int jump_label_apply_nops(struct module *mod)
96{
97 return 0;
98}
99
100#endif
101
102#endif
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index d8e9b3d1c23c..0df513b7a9f8 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -36,6 +36,7 @@ const char *kallsyms_lookup(unsigned long addr,
36 36
37/* Look up a kernel symbol and return it in a text buffer. */ 37/* Look up a kernel symbol and return it in a text buffer. */
38extern int sprint_symbol(char *buffer, unsigned long address); 38extern int sprint_symbol(char *buffer, unsigned long address);
39extern int sprint_backtrace(char *buffer, unsigned long address);
39 40
40/* Look up a kernel symbol and print it to the kernel messages. */ 41/* Look up a kernel symbol and print it to the kernel messages. */
41extern void __print_symbol(const char *fmt, unsigned long address); 42extern void __print_symbol(const char *fmt, unsigned long address);
@@ -79,6 +80,12 @@ static inline int sprint_symbol(char *buffer, unsigned long addr)
79 return 0; 80 return 0;
80} 81}
81 82
83static inline int sprint_backtrace(char *buffer, unsigned long addr)
84{
85 *buffer = '\0';
86 return 0;
87}
88
82static inline int lookup_symbol_name(unsigned long addr, char *symname) 89static inline int lookup_symbol_name(unsigned long addr, char *symname)
83{ 90{
84 return -ERANGE; 91 return -ERANGE;
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
index 506ad20c18f8..ec2d17bc1f1e 100644
--- a/include/linux/kbd_kern.h
+++ b/include/linux/kbd_kern.h
@@ -50,11 +50,12 @@ struct kbd_struct {
50#define VC_CAPSLOCK 2 /* capslock mode */ 50#define VC_CAPSLOCK 2 /* capslock mode */
51#define VC_KANALOCK 3 /* kanalock mode */ 51#define VC_KANALOCK 3 /* kanalock mode */
52 52
53 unsigned char kbdmode:2; /* one 2-bit value */ 53 unsigned char kbdmode:3; /* one 3-bit value */
54#define VC_XLATE 0 /* translate keycodes using keymap */ 54#define VC_XLATE 0 /* translate keycodes using keymap */
55#define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */ 55#define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */
56#define VC_RAW 2 /* raw (scancode) mode */ 56#define VC_RAW 2 /* raw (scancode) mode */
57#define VC_UNICODE 3 /* Unicode mode */ 57#define VC_UNICODE 3 /* Unicode mode */
58#define VC_OFF 4 /* disabled mode */
58 59
59 unsigned char modeflags:5; 60 unsigned char modeflags:5;
60#define VC_APPLIC 0 /* application key mode */ 61#define VC_APPLIC 0 /* application key mode */
@@ -158,7 +159,7 @@ static inline void con_schedule_flip(struct tty_struct *t)
158 if (t->buf.tail != NULL) 159 if (t->buf.tail != NULL)
159 t->buf.tail->commit = t->buf.tail->used; 160 t->buf.tail->commit = t->buf.tail->used;
160 spin_unlock_irqrestore(&t->buf.lock, flags); 161 spin_unlock_irqrestore(&t->buf.lock, flags);
161 schedule_delayed_work(&t->buf.work, 0); 162 schedule_work(&t->buf.work);
162} 163}
163 164
164#endif 165#endif
diff --git a/include/linux/kd.h b/include/linux/kd.h
index 15f2853ea58f..c36d8476db55 100644
--- a/include/linux/kd.h
+++ b/include/linux/kd.h
@@ -81,6 +81,7 @@ struct unimapinit {
81#define K_XLATE 0x01 81#define K_XLATE 0x01
82#define K_MEDIUMRAW 0x02 82#define K_MEDIUMRAW 0x02
83#define K_UNICODE 0x03 83#define K_UNICODE 0x03
84#define K_OFF 0x04
84#define KDGKBMODE 0x4B44 /* gets current keyboard mode */ 85#define KDGKBMODE 0x4B44 /* gets current keyboard mode */
85#define KDSKBMODE 0x4B45 /* sets current keyboard mode */ 86#define KDSKBMODE 0x4B45 /* sets current keyboard mode */
86 87
diff --git a/include/linux/kdb.h b/include/linux/kdb.h
index ea6e5244ed3f..aadff7cc2b84 100644
--- a/include/linux/kdb.h
+++ b/include/linux/kdb.h
@@ -28,6 +28,41 @@ extern int kdb_poll_idx;
28extern int kdb_initial_cpu; 28extern int kdb_initial_cpu;
29extern atomic_t kdb_event; 29extern atomic_t kdb_event;
30 30
31/* Types and messages used for dynamically added kdb shell commands */
32
33#define KDB_MAXARGS 16 /* Maximum number of arguments to a function */
34
35typedef enum {
36 KDB_REPEAT_NONE = 0, /* Do not repeat this command */
37 KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */
38 KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */
39} kdb_repeat_t;
40
41typedef int (*kdb_func_t)(int, const char **);
42
43/* KDB return codes from a command or internal kdb function */
44#define KDB_NOTFOUND (-1)
45#define KDB_ARGCOUNT (-2)
46#define KDB_BADWIDTH (-3)
47#define KDB_BADRADIX (-4)
48#define KDB_NOTENV (-5)
49#define KDB_NOENVVALUE (-6)
50#define KDB_NOTIMP (-7)
51#define KDB_ENVFULL (-8)
52#define KDB_ENVBUFFULL (-9)
53#define KDB_TOOMANYBPT (-10)
54#define KDB_TOOMANYDBREGS (-11)
55#define KDB_DUPBPT (-12)
56#define KDB_BPTNOTFOUND (-13)
57#define KDB_BADMODE (-14)
58#define KDB_BADINT (-15)
59#define KDB_INVADDRFMT (-16)
60#define KDB_BADREG (-17)
61#define KDB_BADCPUNUM (-18)
62#define KDB_BADLENGTH (-19)
63#define KDB_NOBP (-20)
64#define KDB_BADADDR (-21)
65
31/* 66/*
32 * kdb_diemsg 67 * kdb_diemsg
33 * 68 *
@@ -104,10 +139,26 @@ int kdb_process_cpu(const struct task_struct *p)
104 139
105/* kdb access to register set for stack dumping */ 140/* kdb access to register set for stack dumping */
106extern struct pt_regs *kdb_current_regs; 141extern struct pt_regs *kdb_current_regs;
142#ifdef CONFIG_KALLSYMS
143extern const char *kdb_walk_kallsyms(loff_t *pos);
144#else /* ! CONFIG_KALLSYMS */
145static inline const char *kdb_walk_kallsyms(loff_t *pos)
146{
147 return NULL;
148}
149#endif /* ! CONFIG_KALLSYMS */
107 150
151/* Dynamic kdb shell command registration */
152extern int kdb_register(char *, kdb_func_t, char *, char *, short);
153extern int kdb_register_repeat(char *, kdb_func_t, char *, char *,
154 short, kdb_repeat_t);
155extern int kdb_unregister(char *);
108#else /* ! CONFIG_KGDB_KDB */ 156#else /* ! CONFIG_KGDB_KDB */
109#define kdb_printf(...) 157#define kdb_printf(...)
110#define kdb_init(x) 158#define kdb_init(x)
159#define kdb_register(...)
160#define kdb_register_repeat(...)
161#define kdb_uregister(x)
111#endif /* CONFIG_KGDB_KDB */ 162#endif /* CONFIG_KGDB_KDB */
112enum { 163enum {
113 KDB_NOT_INITIALIZED, 164 KDB_NOT_INITIALIZED,
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2b0a35e6bc69..953352a88336 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -17,13 +17,11 @@
17#include <linux/bitops.h> 17#include <linux/bitops.h>
18#include <linux/log2.h> 18#include <linux/log2.h>
19#include <linux/typecheck.h> 19#include <linux/typecheck.h>
20#include <linux/printk.h>
20#include <linux/dynamic_debug.h> 21#include <linux/dynamic_debug.h>
21#include <asm/byteorder.h> 22#include <asm/byteorder.h>
22#include <asm/bug.h> 23#include <asm/bug.h>
23 24
24extern const char linux_banner[];
25extern const char linux_proc_banner[];
26
27#define USHRT_MAX ((u16)(~0U)) 25#define USHRT_MAX ((u16)(~0U))
28#define SHRT_MAX ((s16)(USHRT_MAX>>1)) 26#define SHRT_MAX ((s16)(USHRT_MAX>>1))
29#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) 27#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
@@ -58,7 +56,20 @@ extern const char linux_proc_banner[];
58 56
59#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 57#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
60#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 58#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
61#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) 59
60/* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
61#define roundup(x, y) ( \
62{ \
63 const typeof(y) __y = y; \
64 (((x) + (__y - 1)) / __y) * __y; \
65} \
66)
67#define rounddown(x, y) ( \
68{ \
69 typeof(x) __x = (x); \
70 __x - (__x % (y)); \
71} \
72)
62#define DIV_ROUND_CLOSEST(x, divisor)( \ 73#define DIV_ROUND_CLOSEST(x, divisor)( \
63{ \ 74{ \
64 typeof(divisor) __divisor = divisor; \ 75 typeof(divisor) __divisor = divisor; \
@@ -99,31 +110,6 @@ extern const char linux_proc_banner[];
99 */ 110 */
100#define lower_32_bits(n) ((u32)(n)) 111#define lower_32_bits(n) ((u32)(n))
101 112
102#define KERN_EMERG "<0>" /* system is unusable */
103#define KERN_ALERT "<1>" /* action must be taken immediately */
104#define KERN_CRIT "<2>" /* critical conditions */
105#define KERN_ERR "<3>" /* error conditions */
106#define KERN_WARNING "<4>" /* warning conditions */
107#define KERN_NOTICE "<5>" /* normal but significant condition */
108#define KERN_INFO "<6>" /* informational */
109#define KERN_DEBUG "<7>" /* debug-level messages */
110
111/* Use the default kernel loglevel */
112#define KERN_DEFAULT "<d>"
113/*
114 * Annotation for a "continued" line of log printout (only done after a
115 * line that had no enclosing \n). Only to be used by core/arch code
116 * during early bootup (a continued line is not SMP-safe otherwise).
117 */
118#define KERN_CONT "<c>"
119
120extern int console_printk[];
121
122#define console_loglevel (console_printk[0])
123#define default_message_loglevel (console_printk[1])
124#define minimum_console_loglevel (console_printk[2])
125#define default_console_loglevel (console_printk[3])
126
127struct completion; 113struct completion;
128struct pt_regs; 114struct pt_regs;
129struct user; 115struct user;
@@ -157,8 +143,26 @@ extern int _cond_resched(void);
157 143
158#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) 144#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
159 145
160#define abs(x) ({ \ 146/*
161 long __x = (x); \ 147 * abs() handles unsigned and signed longs, ints, shorts and chars. For all
148 * input types abs() returns a signed long.
149 * abs() should not be used for 64-bit types (s64, u64, long long) - use abs64()
150 * for those.
151 */
152#define abs(x) ({ \
153 long ret; \
154 if (sizeof(x) == sizeof(long)) { \
155 long __x = (x); \
156 ret = (__x < 0) ? -__x : __x; \
157 } else { \
158 int __x = (x); \
159 ret = (__x < 0) ? -__x : __x; \
160 } \
161 ret; \
162 })
163
164#define abs64(x) ({ \
165 s64 __x = (x); \
162 (__x < 0) ? -__x : __x; \ 166 (__x < 0) ? -__x : __x; \
163 }) 167 })
164 168
@@ -171,11 +175,6 @@ static inline void might_fault(void)
171} 175}
172#endif 176#endif
173 177
174struct va_format {
175 const char *fmt;
176 va_list *va;
177};
178
179extern struct atomic_notifier_head panic_notifier_list; 178extern struct atomic_notifier_head panic_notifier_list;
180extern long (*panic_blink)(int state); 179extern long (*panic_blink)(int state);
181NORET_TYPE void panic(const char * fmt, ...) 180NORET_TYPE void panic(const char * fmt, ...)
@@ -188,14 +187,107 @@ NORET_TYPE void do_exit(long error_code)
188 ATTRIB_NORET; 187 ATTRIB_NORET;
189NORET_TYPE void complete_and_exit(struct completion *, long) 188NORET_TYPE void complete_and_exit(struct completion *, long)
190 ATTRIB_NORET; 189 ATTRIB_NORET;
190
191/* Internal, do not use. */
192int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
193int __must_check _kstrtol(const char *s, unsigned int base, long *res);
194
195int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res);
196int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
197static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
198{
199 /*
200 * We want to shortcut function call, but
201 * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
202 */
203 if (sizeof(unsigned long) == sizeof(unsigned long long) &&
204 __alignof__(unsigned long) == __alignof__(unsigned long long))
205 return kstrtoull(s, base, (unsigned long long *)res);
206 else
207 return _kstrtoul(s, base, res);
208}
209
210static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
211{
212 /*
213 * We want to shortcut function call, but
214 * __builtin_types_compatible_p(long, long long) = 0.
215 */
216 if (sizeof(long) == sizeof(long long) &&
217 __alignof__(long) == __alignof__(long long))
218 return kstrtoll(s, base, (long long *)res);
219 else
220 return _kstrtol(s, base, res);
221}
222
223int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res);
224int __must_check kstrtoint(const char *s, unsigned int base, int *res);
225
226static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res)
227{
228 return kstrtoull(s, base, res);
229}
230
231static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res)
232{
233 return kstrtoll(s, base, res);
234}
235
236static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res)
237{
238 return kstrtouint(s, base, res);
239}
240
241static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res)
242{
243 return kstrtoint(s, base, res);
244}
245
246int __must_check kstrtou16(const char *s, unsigned int base, u16 *res);
247int __must_check kstrtos16(const char *s, unsigned int base, s16 *res);
248int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);
249int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
250
251int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
252int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
253int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res);
254int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res);
255int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res);
256int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res);
257int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res);
258int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
259int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
260int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
261
262static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
263{
264 return kstrtoull_from_user(s, count, base, res);
265}
266
267static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
268{
269 return kstrtoll_from_user(s, count, base, res);
270}
271
272static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res)
273{
274 return kstrtouint_from_user(s, count, base, res);
275}
276
277static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
278{
279 return kstrtoint_from_user(s, count, base, res);
280}
281
191extern unsigned long simple_strtoul(const char *,char **,unsigned int); 282extern unsigned long simple_strtoul(const char *,char **,unsigned int);
192extern long simple_strtol(const char *,char **,unsigned int); 283extern long simple_strtol(const char *,char **,unsigned int);
193extern unsigned long long simple_strtoull(const char *,char **,unsigned int); 284extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
194extern long long simple_strtoll(const char *,char **,unsigned int); 285extern long long simple_strtoll(const char *,char **,unsigned int);
195extern int strict_strtoul(const char *, unsigned int, unsigned long *); 286#define strict_strtoul kstrtoul
196extern int strict_strtol(const char *, unsigned int, long *); 287#define strict_strtol kstrtol
197extern int strict_strtoull(const char *, unsigned int, unsigned long long *); 288#define strict_strtoull kstrtoull
198extern int strict_strtoll(const char *, unsigned int, long long *); 289#define strict_strtoll kstrtoll
290
199extern int sprintf(char * buf, const char * fmt, ...) 291extern int sprintf(char * buf, const char * fmt, ...)
200 __attribute__ ((format (printf, 2, 3))); 292 __attribute__ ((format (printf, 2, 3)));
201extern int vsprintf(char *buf, const char *, va_list) 293extern int vsprintf(char *buf, const char *, va_list)
@@ -222,6 +314,7 @@ extern char *get_options(const char *str, int nints, int *ints);
222extern unsigned long long memparse(const char *ptr, char **retptr); 314extern unsigned long long memparse(const char *ptr, char **retptr);
223 315
224extern int core_kernel_text(unsigned long addr); 316extern int core_kernel_text(unsigned long addr);
317extern int core_kernel_data(unsigned long addr);
225extern int __kernel_text_address(unsigned long addr); 318extern int __kernel_text_address(unsigned long addr);
226extern int kernel_text_address(unsigned long addr); 319extern int kernel_text_address(unsigned long addr);
227extern int func_ptr_is_kernel_text(void *ptr); 320extern int func_ptr_is_kernel_text(void *ptr);
@@ -229,109 +322,8 @@ extern int func_ptr_is_kernel_text(void *ptr);
229struct pid; 322struct pid;
230extern struct pid *session_of_pgrp(struct pid *pgrp); 323extern struct pid *session_of_pgrp(struct pid *pgrp);
231 324
232/*
233 * FW_BUG
234 * Add this to a message where you are sure the firmware is buggy or behaves
235 * really stupid or out of spec. Be aware that the responsible BIOS developer
236 * should be able to fix this issue or at least get a concrete idea of the
237 * problem by reading your message without the need of looking at the kernel
238 * code.
239 *
240 * Use it for definite and high priority BIOS bugs.
241 *
242 * FW_WARN
243 * Use it for not that clear (e.g. could the kernel messed up things already?)
244 * and medium priority BIOS bugs.
245 *
246 * FW_INFO
247 * Use this one if you want to tell the user or vendor about something
248 * suspicious, but generally harmless related to the firmware.
249 *
250 * Use it for information or very low priority BIOS bugs.
251 */
252#define FW_BUG "[Firmware Bug]: "
253#define FW_WARN "[Firmware Warn]: "
254#define FW_INFO "[Firmware Info]: "
255
256/*
257 * HW_ERR
258 * Add this to a message for hardware errors, so that user can report
259 * it to hardware vendor instead of LKML or software vendor.
260 */
261#define HW_ERR "[Hardware Error]: "
262
263#ifdef CONFIG_PRINTK
264asmlinkage int vprintk(const char *fmt, va_list args)
265 __attribute__ ((format (printf, 1, 0)));
266asmlinkage int printk(const char * fmt, ...)
267 __attribute__ ((format (printf, 1, 2))) __cold;
268
269extern int __printk_ratelimit(const char *func);
270#define printk_ratelimit() __printk_ratelimit(__func__)
271extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
272 unsigned int interval_msec);
273
274extern int printk_delay_msec;
275
276/*
277 * Print a one-time message (analogous to WARN_ONCE() et al):
278 */
279#define printk_once(x...) ({ \
280 static bool __print_once; \
281 \
282 if (!__print_once) { \
283 __print_once = true; \
284 printk(x); \
285 } \
286})
287
288void log_buf_kexec_setup(void);
289#else
290static inline int vprintk(const char *s, va_list args)
291 __attribute__ ((format (printf, 1, 0)));
292static inline int vprintk(const char *s, va_list args) { return 0; }
293static inline int printk(const char *s, ...)
294 __attribute__ ((format (printf, 1, 2)));
295static inline int __cold printk(const char *s, ...) { return 0; }
296static inline int printk_ratelimit(void) { return 0; }
297static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
298 unsigned int interval_msec) \
299 { return false; }
300
301/* No effect, but we still get type checking even in the !PRINTK case: */
302#define printk_once(x...) printk(x)
303
304static inline void log_buf_kexec_setup(void)
305{
306}
307#endif
308
309/*
310 * Dummy printk for disabled debugging statements to use whilst maintaining
311 * gcc's format and side-effect checking.
312 */
313static inline __attribute__ ((format (printf, 1, 2)))
314int no_printk(const char *s, ...) { return 0; }
315
316extern int printk_needs_cpu(int cpu);
317extern void printk_tick(void);
318
319extern void asmlinkage __attribute__((format(printf, 1, 2)))
320 early_printk(const char *fmt, ...);
321
322unsigned long int_sqrt(unsigned long); 325unsigned long int_sqrt(unsigned long);
323 326
324static inline void console_silent(void)
325{
326 console_loglevel = 0;
327}
328
329static inline void console_verbose(void)
330{
331 if (console_loglevel)
332 console_loglevel = 15;
333}
334
335extern void bust_spinlocks(int yes); 327extern void bust_spinlocks(int yes);
336extern void wake_up_klogd(void); 328extern void wake_up_klogd(void);
337extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ 329extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
@@ -345,6 +337,8 @@ extern int test_taint(unsigned flag);
345extern unsigned long get_taint(void); 337extern unsigned long get_taint(void);
346extern int root_mountflags; 338extern int root_mountflags;
347 339
340extern bool early_boot_irqs_disabled;
341
348/* Values used for system_state */ 342/* Values used for system_state */
349extern enum system_states { 343extern enum system_states {
350 SYSTEM_BOOTING, 344 SYSTEM_BOOTING,
@@ -368,22 +362,6 @@ extern enum system_states {
368#define TAINT_CRAP 10 362#define TAINT_CRAP 10
369#define TAINT_FIRMWARE_WORKAROUND 11 363#define TAINT_FIRMWARE_WORKAROUND 11
370 364
371extern void dump_stack(void) __cold;
372
373enum {
374 DUMP_PREFIX_NONE,
375 DUMP_PREFIX_ADDRESS,
376 DUMP_PREFIX_OFFSET
377};
378extern void hex_dump_to_buffer(const void *buf, size_t len,
379 int rowsize, int groupsize,
380 char *linebuf, size_t linebuflen, bool ascii);
381extern void print_hex_dump(const char *level, const char *prefix_str,
382 int prefix_type, int rowsize, int groupsize,
383 const void *buf, size_t len, bool ascii);
384extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
385 const void *buf, size_t len);
386
387extern const char hex_asc[]; 365extern const char hex_asc[];
388#define hex_asc_lo(x) hex_asc[((x) & 0x0f)] 366#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
389#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] 367#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
@@ -396,94 +374,7 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
396} 374}
397 375
398extern int hex_to_bin(char ch); 376extern int hex_to_bin(char ch);
399 377extern void hex2bin(u8 *dst, const char *src, size_t count);
400#ifndef pr_fmt
401#define pr_fmt(fmt) fmt
402#endif
403
404#define pr_emerg(fmt, ...) \
405 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
406#define pr_alert(fmt, ...) \
407 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
408#define pr_crit(fmt, ...) \
409 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
410#define pr_err(fmt, ...) \
411 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
412#define pr_warning(fmt, ...) \
413 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
414#define pr_warn pr_warning
415#define pr_notice(fmt, ...) \
416 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
417#define pr_info(fmt, ...) \
418 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
419#define pr_cont(fmt, ...) \
420 printk(KERN_CONT fmt, ##__VA_ARGS__)
421
422/* pr_devel() should produce zero code unless DEBUG is defined */
423#ifdef DEBUG
424#define pr_devel(fmt, ...) \
425 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
426#else
427#define pr_devel(fmt, ...) \
428 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
429#endif
430
431/* If you are writing a driver, please use dev_dbg instead */
432#if defined(DEBUG)
433#define pr_debug(fmt, ...) \
434 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
435#elif defined(CONFIG_DYNAMIC_DEBUG)
436/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
437#define pr_debug(fmt, ...) \
438 dynamic_pr_debug(fmt, ##__VA_ARGS__)
439#else
440#define pr_debug(fmt, ...) \
441 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
442#endif
443
444/*
445 * ratelimited messages with local ratelimit_state,
446 * no local ratelimit_state used in the !PRINTK case
447 */
448#ifdef CONFIG_PRINTK
449#define printk_ratelimited(fmt, ...) ({ \
450 static DEFINE_RATELIMIT_STATE(_rs, \
451 DEFAULT_RATELIMIT_INTERVAL, \
452 DEFAULT_RATELIMIT_BURST); \
453 \
454 if (__ratelimit(&_rs)) \
455 printk(fmt, ##__VA_ARGS__); \
456})
457#else
458/* No effect, but we still get type checking even in the !PRINTK case: */
459#define printk_ratelimited printk
460#endif
461
462#define pr_emerg_ratelimited(fmt, ...) \
463 printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
464#define pr_alert_ratelimited(fmt, ...) \
465 printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
466#define pr_crit_ratelimited(fmt, ...) \
467 printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
468#define pr_err_ratelimited(fmt, ...) \
469 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
470#define pr_warning_ratelimited(fmt, ...) \
471 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
472#define pr_warn_ratelimited pr_warning_ratelimited
473#define pr_notice_ratelimited(fmt, ...) \
474 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
475#define pr_info_ratelimited(fmt, ...) \
476 printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
477/* no pr_cont_ratelimited, don't do that... */
478/* If you are writing a driver, please use dev_dbg instead */
479#if defined(DEBUG)
480#define pr_debug_ratelimited(fmt, ...) \
481 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
482#else
483#define pr_debug_ratelimited(fmt, ...) \
484 ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
485 ##__VA_ARGS__); 0; })
486#endif
487 378
488/* 379/*
489 * General tracing related utility functions - trace_printk(), 380 * General tracing related utility functions - trace_printk(),
@@ -640,6 +531,34 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
640 (void) (&_max1 == &_max2); \ 531 (void) (&_max1 == &_max2); \
641 _max1 > _max2 ? _max1 : _max2; }) 532 _max1 > _max2 ? _max1 : _max2; })
642 533
534#define min3(x, y, z) ({ \
535 typeof(x) _min1 = (x); \
536 typeof(y) _min2 = (y); \
537 typeof(z) _min3 = (z); \
538 (void) (&_min1 == &_min2); \
539 (void) (&_min1 == &_min3); \
540 _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \
541 (_min2 < _min3 ? _min2 : _min3); })
542
543#define max3(x, y, z) ({ \
544 typeof(x) _max1 = (x); \
545 typeof(y) _max2 = (y); \
546 typeof(z) _max3 = (z); \
547 (void) (&_max1 == &_max2); \
548 (void) (&_max1 == &_max3); \
549 _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
550 (_max2 > _max3 ? _max2 : _max3); })
551
552/**
553 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
554 * @x: value1
555 * @y: value2
556 */
557#define min_not_zero(x, y) ({ \
558 typeof(x) __x = (x); \
559 typeof(y) __y = (y); \
560 __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
561
643/** 562/**
644 * clamp - return a value clamped to a given range with strict typechecking 563 * clamp - return a value clamped to a given range with strict typechecking
645 * @val: current value 564 * @val: current value
@@ -750,11 +669,12 @@ struct sysinfo {
750 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ 669 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
751}; 670};
752 671
753/* Force a compilation error if condition is true */ 672#ifdef __CHECKER__
754#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition)) 673#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
755 674#define BUILD_BUG_ON_ZERO(e) (0)
756/* Force a compilation error if condition is constant and true */ 675#define BUILD_BUG_ON_NULL(e) ((void*)0)
757#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) 676#define BUILD_BUG_ON(condition)
677#else /* __CHECKER__ */
758 678
759/* Force a compilation error if a constant expression is not a power of 2 */ 679/* Force a compilation error if a constant expression is not a power of 2 */
760#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ 680#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
@@ -767,6 +687,33 @@ struct sysinfo {
767#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) 687#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
768#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) 688#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
769 689
690/**
691 * BUILD_BUG_ON - break compile if a condition is true.
692 * @condition: the condition which the compiler should know is false.
693 *
694 * If you have some code which relies on certain constants being equal, or
695 * other compile-time-evaluated condition, you should use BUILD_BUG_ON to
696 * detect if someone changes it.
697 *
698 * The implementation uses gcc's reluctance to create a negative array, but
699 * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments
700 * to inline functions). So as a fallback we use the optimizer; if it can't
701 * prove the condition is false, it will cause a link error on the undefined
702 * "__build_bug_on_failed". This error message can be harder to track down
703 * though, hence the two different methods.
704 */
705#ifndef __OPTIMIZE__
706#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
707#else
708extern int __build_bug_on_failed;
709#define BUILD_BUG_ON(condition) \
710 do { \
711 ((void)sizeof(char[1 - 2*!!(condition)])); \
712 if (condition) __build_bug_on_failed = 1; \
713 } while(0)
714#endif
715#endif /* __CHECKER__ */
716
770/* Trap pasters of __FUNCTION__ at compile-time */ 717/* Trap pasters of __FUNCTION__ at compile-time */
771#define __FUNCTION__ (__func__) 718#define __FUNCTION__ (__func__)
772 719
@@ -777,6 +724,13 @@ struct sysinfo {
777#define NUMA_BUILD 0 724#define NUMA_BUILD 0
778#endif 725#endif
779 726
727/* This helps us avoid #ifdef CONFIG_COMPACTION */
728#ifdef CONFIG_COMPACTION
729#define COMPACTION_BUILD 1
730#else
731#define COMPACTION_BUILD 0
732#endif
733
780/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ 734/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
781#ifdef CONFIG_FTRACE_MCOUNT_RECORD 735#ifdef CONFIG_FTRACE_MCOUNT_RECORD
782# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 736# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index c059044bc6dc..0cce2db580c3 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -33,6 +33,7 @@ struct kernel_stat {
33#ifndef CONFIG_GENERIC_HARDIRQS 33#ifndef CONFIG_GENERIC_HARDIRQS
34 unsigned int irqs[NR_IRQS]; 34 unsigned int irqs[NR_IRQS];
35#endif 35#endif
36 unsigned long irqs_sum;
36 unsigned int softirqs[NR_SOFTIRQS]; 37 unsigned int softirqs[NR_SOFTIRQS];
37}; 38};
38 39
@@ -45,15 +46,14 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
45extern unsigned long long nr_context_switches(void); 46extern unsigned long long nr_context_switches(void);
46 47
47#ifndef CONFIG_GENERIC_HARDIRQS 48#ifndef CONFIG_GENERIC_HARDIRQS
48#define kstat_irqs_this_cpu(irq) \
49 (kstat_this_cpu.irqs[irq])
50 49
51struct irq_desc; 50struct irq_desc;
52 51
53static inline void kstat_incr_irqs_this_cpu(unsigned int irq, 52static inline void kstat_incr_irqs_this_cpu(unsigned int irq,
54 struct irq_desc *desc) 53 struct irq_desc *desc)
55{ 54{
56 kstat_this_cpu.irqs[irq]++; 55 __this_cpu_inc(kstat.irqs[irq]);
56 __this_cpu_inc(kstat.irqs_sum);
57} 57}
58 58
59static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) 59static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
@@ -63,16 +63,18 @@ static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
63#else 63#else
64#include <linux/irq.h> 64#include <linux/irq.h>
65extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu); 65extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu);
66#define kstat_irqs_this_cpu(DESC) \ 66
67 ((DESC)->kstat_irqs[smp_processor_id()]) 67#define kstat_incr_irqs_this_cpu(irqno, DESC) \
68#define kstat_incr_irqs_this_cpu(irqno, DESC) \ 68do { \
69 ((DESC)->kstat_irqs[smp_processor_id()]++) 69 __this_cpu_inc(*(DESC)->kstat_irqs); \
70 __this_cpu_inc(kstat.irqs_sum); \
71} while (0)
70 72
71#endif 73#endif
72 74
73static inline void kstat_incr_softirqs_this_cpu(unsigned int irq) 75static inline void kstat_incr_softirqs_this_cpu(unsigned int irq)
74{ 76{
75 kstat_this_cpu.softirqs[irq]++; 77 __this_cpu_inc(kstat.softirqs[irq]);
76} 78}
77 79
78static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu) 80static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu)
@@ -83,6 +85,7 @@ static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu)
83/* 85/*
84 * Number of interrupts per specific IRQ source, since bootup 86 * Number of interrupts per specific IRQ source, since bootup
85 */ 87 */
88#ifndef CONFIG_GENERIC_HARDIRQS
86static inline unsigned int kstat_irqs(unsigned int irq) 89static inline unsigned int kstat_irqs(unsigned int irq)
87{ 90{
88 unsigned int sum = 0; 91 unsigned int sum = 0;
@@ -93,7 +96,17 @@ static inline unsigned int kstat_irqs(unsigned int irq)
93 96
94 return sum; 97 return sum;
95} 98}
99#else
100extern unsigned int kstat_irqs(unsigned int irq);
101#endif
96 102
103/*
104 * Number of interrupts per cpu, since bootup
105 */
106static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
107{
108 return kstat_cpu(cpu).irqs_sum;
109}
97 110
98/* 111/*
99 * Lock/unlock the current runqueue - to extract task statistics: 112 * Lock/unlock the current runqueue - to extract task statistics:
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 03e8e8dbc577..c2478a342cd7 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -208,6 +208,7 @@ int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
208 unsigned long long *crash_size, unsigned long long *crash_base); 208 unsigned long long *crash_size, unsigned long long *crash_base);
209int crash_shrink_memory(unsigned long new_size); 209int crash_shrink_memory(unsigned long new_size);
210size_t crash_get_memory_size(void); 210size_t crash_get_memory_size(void);
211void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
211 212
212#else /* !CONFIG_KEXEC */ 213#else /* !CONFIG_KEXEC */
213struct pt_regs; 214struct pt_regs;
diff --git a/include/linux/key-type.h b/include/linux/key-type.h
index 65833d4d5998..9efd081bb31e 100644
--- a/include/linux/key-type.h
+++ b/include/linux/key-type.h
@@ -41,6 +41,9 @@ struct key_type {
41 */ 41 */
42 size_t def_datalen; 42 size_t def_datalen;
43 43
44 /* vet a description */
45 int (*vet_description)(const char *description);
46
44 /* instantiate a key of this type 47 /* instantiate a key of this type
45 * - this method should call key_payload_reserve() to determine if the 48 * - this method should call key_payload_reserve() to determine if the
46 * user's quota will hold the payload 49 * user's quota will hold the payload
@@ -102,11 +105,20 @@ extern int key_instantiate_and_link(struct key *key,
102 size_t datalen, 105 size_t datalen,
103 struct key *keyring, 106 struct key *keyring,
104 struct key *instkey); 107 struct key *instkey);
105extern int key_negate_and_link(struct key *key, 108extern int key_reject_and_link(struct key *key,
106 unsigned timeout, 109 unsigned timeout,
110 unsigned error,
107 struct key *keyring, 111 struct key *keyring,
108 struct key *instkey); 112 struct key *instkey);
109extern void complete_request_key(struct key_construction *cons, int error); 113extern void complete_request_key(struct key_construction *cons, int error);
110 114
115static inline int key_negate_and_link(struct key *key,
116 unsigned timeout,
117 struct key *keyring,
118 struct key *instkey)
119{
120 return key_reject_and_link(key, timeout, ENOKEY, keyring, instkey);
121}
122
111#endif /* CONFIG_KEYS */ 123#endif /* CONFIG_KEYS */
112#endif /* _LINUX_KEY_TYPE_H */ 124#endif /* _LINUX_KEY_TYPE_H */
diff --git a/include/linux/key.h b/include/linux/key.h
index cd50dfa1d4c2..6ea4eebd3467 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -9,7 +9,7 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 * 10 *
11 * 11 *
12 * See Documentation/keys.txt for information on keys/keyrings. 12 * See Documentation/security/keys.txt for information on keys/keyrings.
13 */ 13 */
14 14
15#ifndef _LINUX_KEY_H 15#ifndef _LINUX_KEY_H
@@ -170,6 +170,7 @@ struct key {
170 struct list_head link; 170 struct list_head link;
171 unsigned long x[2]; 171 unsigned long x[2];
172 void *p[2]; 172 void *p[2];
173 int reject_error;
173 } type_data; 174 } type_data;
174 175
175 /* key data 176 /* key data
@@ -178,8 +179,9 @@ struct key {
178 */ 179 */
179 union { 180 union {
180 unsigned long value; 181 unsigned long value;
182 void __rcu *rcudata;
181 void *data; 183 void *data;
182 struct keyring_list *subscriptions; 184 struct keyring_list __rcu *subscriptions;
183 } payload; 185 } payload;
184}; 186};
185 187
@@ -274,6 +276,23 @@ static inline key_serial_t key_serial(struct key *key)
274 return key ? key->serial : 0; 276 return key ? key->serial : 0;
275} 277}
276 278
279/**
280 * key_is_instantiated - Determine if a key has been positively instantiated
281 * @key: The key to check.
282 *
283 * Return true if the specified key has been positively instantiated, false
284 * otherwise.
285 */
286static inline bool key_is_instantiated(const struct key *key)
287{
288 return test_bit(KEY_FLAG_INSTANTIATED, &key->flags) &&
289 !test_bit(KEY_FLAG_NEGATIVE, &key->flags);
290}
291
292#define rcu_dereference_key(KEY) \
293 (rcu_dereference_protected((KEY)->payload.rcudata, \
294 rwsem_is_locked(&((struct key *)(KEY))->sem)))
295
277#ifdef CONFIG_SYSCTL 296#ifdef CONFIG_SYSCTL
278extern ctl_table key_sysctls[]; 297extern ctl_table key_sysctls[];
279#endif 298#endif
diff --git a/include/linux/keyctl.h b/include/linux/keyctl.h
index bd383f1944fb..9b0b865ce622 100644
--- a/include/linux/keyctl.h
+++ b/include/linux/keyctl.h
@@ -53,5 +53,7 @@
53#define KEYCTL_ASSUME_AUTHORITY 16 /* assume request_key() authorisation */ 53#define KEYCTL_ASSUME_AUTHORITY 16 /* assume request_key() authorisation */
54#define KEYCTL_GET_SECURITY 17 /* get key security label */ 54#define KEYCTL_GET_SECURITY 17 /* get key security label */
55#define KEYCTL_SESSION_TO_PARENT 18 /* apply session keyring to parent process */ 55#define KEYCTL_SESSION_TO_PARENT 18 /* apply session keyring to parent process */
56#define KEYCTL_REJECT 19 /* reject a partially constructed key */
57#define KEYCTL_INSTANTIATE_IOV 20 /* instantiate a partially constructed key */
56 58
57#endif /* _LINUX_KEYCTL_H */ 59#endif /* _LINUX_KEYCTL_H */
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 62dbee554f60..10308c6a3d1c 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -172,7 +172,13 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
172 172
173 173
174static inline unsigned int __must_check 174static inline unsigned int __must_check
175__kfifo_must_check_helper(unsigned int val) 175__kfifo_uint_must_check_helper(unsigned int val)
176{
177 return val;
178}
179
180static inline int __must_check
181__kfifo_int_must_check_helper(int val)
176{ 182{
177 return val; 183 return val;
178} 184}
@@ -267,7 +273,7 @@ __kfifo_must_check_helper(unsigned int val)
267 * @fifo: address of the fifo to be used 273 * @fifo: address of the fifo to be used
268 */ 274 */
269#define kfifo_avail(fifo) \ 275#define kfifo_avail(fifo) \
270__kfifo_must_check_helper( \ 276__kfifo_uint_must_check_helper( \
271({ \ 277({ \
272 typeof((fifo) + 1) __tmpq = (fifo); \ 278 typeof((fifo) + 1) __tmpq = (fifo); \
273 const size_t __recsize = sizeof(*__tmpq->rectype); \ 279 const size_t __recsize = sizeof(*__tmpq->rectype); \
@@ -300,7 +306,7 @@ __kfifo_must_check_helper( \
300 * This function returns the size of the next fifo record in number of bytes. 306 * This function returns the size of the next fifo record in number of bytes.
301 */ 307 */
302#define kfifo_peek_len(fifo) \ 308#define kfifo_peek_len(fifo) \
303__kfifo_must_check_helper( \ 309__kfifo_uint_must_check_helper( \
304({ \ 310({ \
305 typeof((fifo) + 1) __tmp = (fifo); \ 311 typeof((fifo) + 1) __tmp = (fifo); \
306 const size_t __recsize = sizeof(*__tmp->rectype); \ 312 const size_t __recsize = sizeof(*__tmp->rectype); \
@@ -323,7 +329,7 @@ __kfifo_must_check_helper( \
323 * Return 0 if no error, otherwise an error code. 329 * Return 0 if no error, otherwise an error code.
324 */ 330 */
325#define kfifo_alloc(fifo, size, gfp_mask) \ 331#define kfifo_alloc(fifo, size, gfp_mask) \
326__kfifo_must_check_helper( \ 332__kfifo_int_must_check_helper( \
327({ \ 333({ \
328 typeof((fifo) + 1) __tmp = (fifo); \ 334 typeof((fifo) + 1) __tmp = (fifo); \
329 struct __kfifo *__kfifo = &__tmp->kfifo; \ 335 struct __kfifo *__kfifo = &__tmp->kfifo; \
@@ -419,7 +425,7 @@ __kfifo_must_check_helper( \
419 * writer, you don't need extra locking to use these macro. 425 * writer, you don't need extra locking to use these macro.
420 */ 426 */
421#define kfifo_get(fifo, val) \ 427#define kfifo_get(fifo, val) \
422__kfifo_must_check_helper( \ 428__kfifo_uint_must_check_helper( \
423({ \ 429({ \
424 typeof((fifo) + 1) __tmp = (fifo); \ 430 typeof((fifo) + 1) __tmp = (fifo); \
425 typeof((val) + 1) __val = (val); \ 431 typeof((val) + 1) __val = (val); \
@@ -460,7 +466,7 @@ __kfifo_must_check_helper( \
460 * writer, you don't need extra locking to use these macro. 466 * writer, you don't need extra locking to use these macro.
461 */ 467 */
462#define kfifo_peek(fifo, val) \ 468#define kfifo_peek(fifo, val) \
463__kfifo_must_check_helper( \ 469__kfifo_uint_must_check_helper( \
464({ \ 470({ \
465 typeof((fifo) + 1) __tmp = (fifo); \ 471 typeof((fifo) + 1) __tmp = (fifo); \
466 typeof((val) + 1) __val = (val); \ 472 typeof((val) + 1) __val = (val); \
@@ -552,7 +558,7 @@ __kfifo_must_check_helper( \
552 * writer, you don't need extra locking to use these macro. 558 * writer, you don't need extra locking to use these macro.
553 */ 559 */
554#define kfifo_out(fifo, buf, n) \ 560#define kfifo_out(fifo, buf, n) \
555__kfifo_must_check_helper( \ 561__kfifo_uint_must_check_helper( \
556({ \ 562({ \
557 typeof((fifo) + 1) __tmp = (fifo); \ 563 typeof((fifo) + 1) __tmp = (fifo); \
558 typeof((buf) + 1) __buf = (buf); \ 564 typeof((buf) + 1) __buf = (buf); \
@@ -580,7 +586,7 @@ __kfifo_must_check_helper( \
580 * copied. 586 * copied.
581 */ 587 */
582#define kfifo_out_spinlocked(fifo, buf, n, lock) \ 588#define kfifo_out_spinlocked(fifo, buf, n, lock) \
583__kfifo_must_check_helper( \ 589__kfifo_uint_must_check_helper( \
584({ \ 590({ \
585 unsigned long __flags; \ 591 unsigned long __flags; \
586 unsigned int __ret; \ 592 unsigned int __ret; \
@@ -609,7 +615,7 @@ __kfifo_must_check_helper( \
609 * writer, you don't need extra locking to use these macro. 615 * writer, you don't need extra locking to use these macro.
610 */ 616 */
611#define kfifo_from_user(fifo, from, len, copied) \ 617#define kfifo_from_user(fifo, from, len, copied) \
612__kfifo_must_check_helper( \ 618__kfifo_uint_must_check_helper( \
613({ \ 619({ \
614 typeof((fifo) + 1) __tmp = (fifo); \ 620 typeof((fifo) + 1) __tmp = (fifo); \
615 const void __user *__from = (from); \ 621 const void __user *__from = (from); \
@@ -637,7 +643,7 @@ __kfifo_must_check_helper( \
637 * writer, you don't need extra locking to use these macro. 643 * writer, you don't need extra locking to use these macro.
638 */ 644 */
639#define kfifo_to_user(fifo, to, len, copied) \ 645#define kfifo_to_user(fifo, to, len, copied) \
640__kfifo_must_check_helper( \ 646__kfifo_uint_must_check_helper( \
641({ \ 647({ \
642 typeof((fifo) + 1) __tmp = (fifo); \ 648 typeof((fifo) + 1) __tmp = (fifo); \
643 void __user *__to = (to); \ 649 void __user *__to = (to); \
@@ -764,7 +770,7 @@ __kfifo_must_check_helper( \
764 * writer, you don't need extra locking to use these macro. 770 * writer, you don't need extra locking to use these macro.
765 */ 771 */
766#define kfifo_out_peek(fifo, buf, n) \ 772#define kfifo_out_peek(fifo, buf, n) \
767__kfifo_must_check_helper( \ 773__kfifo_uint_must_check_helper( \
768({ \ 774({ \
769 typeof((fifo) + 1) __tmp = (fifo); \ 775 typeof((fifo) + 1) __tmp = (fifo); \
770 typeof((buf) + 1) __buf = (buf); \ 776 typeof((buf) + 1) __buf = (buf); \
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index cc96f0f23e04..10ca03d0a250 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -35,16 +35,6 @@ struct pt_regs;
35 */ 35 */
36extern int kgdb_skipexception(int exception, struct pt_regs *regs); 36extern int kgdb_skipexception(int exception, struct pt_regs *regs);
37 37
38/**
39 * kgdb_disable_hw_debug - (optional) Disable hardware debugging hook
40 * @regs: Current &struct pt_regs.
41 *
42 * This function will be called if the particular architecture must
43 * disable hardware debugging while it is processing gdb packets or
44 * handling exception.
45 */
46extern void kgdb_disable_hw_debug(struct pt_regs *regs);
47
48struct tasklet_struct; 38struct tasklet_struct;
49struct task_struct; 39struct task_struct;
50struct uart_port; 40struct uart_port;
@@ -243,6 +233,8 @@ extern void kgdb_arch_late(void);
243 * breakpoint. 233 * breakpoint.
244 * @remove_hw_breakpoint: Allow an architecture to specify how to remove a 234 * @remove_hw_breakpoint: Allow an architecture to specify how to remove a
245 * hardware breakpoint. 235 * hardware breakpoint.
236 * @disable_hw_break: Allow an architecture to specify how to disable
237 * hardware breakpoints for a single cpu.
246 * @remove_all_hw_break: Allow an architecture to specify how to remove all 238 * @remove_all_hw_break: Allow an architecture to specify how to remove all
247 * hardware breakpoints. 239 * hardware breakpoints.
248 * @correct_hw_break: Allow an architecture to specify how to correct the 240 * @correct_hw_break: Allow an architecture to specify how to correct the
@@ -256,6 +248,7 @@ struct kgdb_arch {
256 int (*remove_breakpoint)(unsigned long, char *); 248 int (*remove_breakpoint)(unsigned long, char *);
257 int (*set_hw_breakpoint)(unsigned long, int, enum kgdb_bptype); 249 int (*set_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
258 int (*remove_hw_breakpoint)(unsigned long, int, enum kgdb_bptype); 250 int (*remove_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
251 void (*disable_hw_break)(struct pt_regs *regs);
259 void (*remove_all_hw_break)(void); 252 void (*remove_all_hw_break)(void);
260 void (*correct_hw_break)(void); 253 void (*correct_hw_break)(void);
261}; 254};
@@ -304,6 +297,7 @@ extern int
304kgdb_handle_exception(int ex_vector, int signo, int err_code, 297kgdb_handle_exception(int ex_vector, int signo, int err_code,
305 struct pt_regs *regs); 298 struct pt_regs *regs);
306extern int kgdb_nmicallback(int cpu, void *regs); 299extern int kgdb_nmicallback(int cpu, void *regs);
300extern void gdbstub_exit(int status);
307 301
308extern int kgdb_single_step; 302extern int kgdb_single_step;
309extern atomic_t kgdb_active; 303extern atomic_t kgdb_active;
diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h
new file mode 100644
index 000000000000..6b394f0b5148
--- /dev/null
+++ b/include/linux/khugepaged.h
@@ -0,0 +1,67 @@
1#ifndef _LINUX_KHUGEPAGED_H
2#define _LINUX_KHUGEPAGED_H
3
4#include <linux/sched.h> /* MMF_VM_HUGEPAGE */
5
6#ifdef CONFIG_TRANSPARENT_HUGEPAGE
7extern int __khugepaged_enter(struct mm_struct *mm);
8extern void __khugepaged_exit(struct mm_struct *mm);
9extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma);
10
11#define khugepaged_enabled() \
12 (transparent_hugepage_flags & \
13 ((1<<TRANSPARENT_HUGEPAGE_FLAG) | \
14 (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)))
15#define khugepaged_always() \
16 (transparent_hugepage_flags & \
17 (1<<TRANSPARENT_HUGEPAGE_FLAG))
18#define khugepaged_req_madv() \
19 (transparent_hugepage_flags & \
20 (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
21#define khugepaged_defrag() \
22 (transparent_hugepage_flags & \
23 (1<<TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG))
24
25static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
26{
27 if (test_bit(MMF_VM_HUGEPAGE, &oldmm->flags))
28 return __khugepaged_enter(mm);
29 return 0;
30}
31
32static inline void khugepaged_exit(struct mm_struct *mm)
33{
34 if (test_bit(MMF_VM_HUGEPAGE, &mm->flags))
35 __khugepaged_exit(mm);
36}
37
38static inline int khugepaged_enter(struct vm_area_struct *vma)
39{
40 if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags))
41 if ((khugepaged_always() ||
42 (khugepaged_req_madv() &&
43 vma->vm_flags & VM_HUGEPAGE)) &&
44 !(vma->vm_flags & VM_NOHUGEPAGE))
45 if (__khugepaged_enter(vma->vm_mm))
46 return -ENOMEM;
47 return 0;
48}
49#else /* CONFIG_TRANSPARENT_HUGEPAGE */
50static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
51{
52 return 0;
53}
54static inline void khugepaged_exit(struct mm_struct *mm)
55{
56}
57static inline int khugepaged_enter(struct vm_area_struct *vma)
58{
59 return 0;
60}
61static inline int khugepaged_enter_vma_merge(struct vm_area_struct *vma)
62{
63 return 0;
64}
65#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
66
67#endif /* _LINUX_KHUGEPAGED_H */
diff --git a/include/linux/klist.h b/include/linux/klist.h
index e91a4e59b771..a370ce57cf1d 100644
--- a/include/linux/klist.h
+++ b/include/linux/klist.h
@@ -22,7 +22,7 @@ struct klist {
22 struct list_head k_list; 22 struct list_head k_list;
23 void (*get)(struct klist_node *); 23 void (*get)(struct klist_node *);
24 void (*put)(struct klist_node *); 24 void (*put)(struct klist_node *);
25} __attribute__ ((aligned (4))); 25} __attribute__ ((aligned (sizeof(void *))));
26 26
27#define KLIST_INIT(_name, _get, _put) \ 27#define KLIST_INIT(_name, _get, _put) \
28 { .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \ 28 { .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \
diff --git a/include/linux/kmemcheck.h b/include/linux/kmemcheck.h
index 08d7dc4ddf40..39f8453239f7 100644
--- a/include/linux/kmemcheck.h
+++ b/include/linux/kmemcheck.h
@@ -76,7 +76,7 @@ bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size);
76 \ 76 \
77 _n = (long) &((ptr)->name##_end) \ 77 _n = (long) &((ptr)->name##_end) \
78 - (long) &((ptr)->name##_begin); \ 78 - (long) &((ptr)->name##_begin); \
79 MAYBE_BUILD_BUG_ON(_n < 0); \ 79 BUILD_BUG_ON(_n < 0); \
80 \ 80 \
81 kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \ 81 kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
82 } while (0) 82 } while (0)
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 6efd7a78de6a..0da38cf7db7b 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/compiler.h> 25#include <linux/compiler.h>
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/sysctl.h>
27 28
28#define KMOD_PATH_LEN 256 29#define KMOD_PATH_LEN 256
29 30
@@ -44,7 +45,7 @@ static inline int request_module_nowait(const char *name, ...) { return -ENOSYS;
44#endif 45#endif
45 46
46 47
47struct key; 48struct cred;
48struct file; 49struct file;
49 50
50enum umh_wait { 51enum umh_wait {
@@ -61,7 +62,7 @@ struct subprocess_info {
61 char **envp; 62 char **envp;
62 enum umh_wait wait; 63 enum umh_wait wait;
63 int retval; 64 int retval;
64 int (*init)(struct subprocess_info *info); 65 int (*init)(struct subprocess_info *info, struct cred *new);
65 void (*cleanup)(struct subprocess_info *info); 66 void (*cleanup)(struct subprocess_info *info);
66 void *data; 67 void *data;
67}; 68};
@@ -72,7 +73,7 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
72 73
73/* Set various pieces of state into the subprocess_info structure */ 74/* Set various pieces of state into the subprocess_info structure */
74void call_usermodehelper_setfns(struct subprocess_info *info, 75void call_usermodehelper_setfns(struct subprocess_info *info,
75 int (*init)(struct subprocess_info *info), 76 int (*init)(struct subprocess_info *info, struct cred *new),
76 void (*cleanup)(struct subprocess_info *info), 77 void (*cleanup)(struct subprocess_info *info),
77 void *data); 78 void *data);
78 79
@@ -86,7 +87,7 @@ void call_usermodehelper_freeinfo(struct subprocess_info *info);
86static inline int 87static inline int
87call_usermodehelper_fns(char *path, char **argv, char **envp, 88call_usermodehelper_fns(char *path, char **argv, char **envp,
88 enum umh_wait wait, 89 enum umh_wait wait,
89 int (*init)(struct subprocess_info *info), 90 int (*init)(struct subprocess_info *info, struct cred *new),
90 void (*cleanup)(struct subprocess_info *), void *data) 91 void (*cleanup)(struct subprocess_info *), void *data)
91{ 92{
92 struct subprocess_info *info; 93 struct subprocess_info *info;
@@ -109,9 +110,12 @@ call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait)
109 NULL, NULL, NULL); 110 NULL, NULL, NULL);
110} 111}
111 112
113extern struct ctl_table usermodehelper_table[];
114
112extern void usermodehelper_init(void); 115extern void usermodehelper_init(void);
113 116
114extern int usermodehelper_disable(void); 117extern int usermodehelper_disable(void);
115extern void usermodehelper_enable(void); 118extern void usermodehelper_enable(void);
119extern bool usermodehelper_is_disabled(void);
116 120
117#endif /* __LINUX_KMOD_H__ */ 121#endif /* __LINUX_KMOD_H__ */
diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
index 24b44145a886..ee0c952188de 100644
--- a/include/linux/kmsg_dump.h
+++ b/include/linux/kmsg_dump.h
@@ -12,12 +12,17 @@
12#ifndef _LINUX_KMSG_DUMP_H 12#ifndef _LINUX_KMSG_DUMP_H
13#define _LINUX_KMSG_DUMP_H 13#define _LINUX_KMSG_DUMP_H
14 14
15#include <linux/errno.h>
15#include <linux/list.h> 16#include <linux/list.h>
16 17
17enum kmsg_dump_reason { 18enum kmsg_dump_reason {
18 KMSG_DUMP_OOPS, 19 KMSG_DUMP_OOPS,
19 KMSG_DUMP_PANIC, 20 KMSG_DUMP_PANIC,
20 KMSG_DUMP_KEXEC, 21 KMSG_DUMP_KEXEC,
22 KMSG_DUMP_RESTART,
23 KMSG_DUMP_HALT,
24 KMSG_DUMP_POWEROFF,
25 KMSG_DUMP_EMERG,
21}; 26};
22 27
23/** 28/**
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 7950a37a7146..9229b64ee3aa 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -85,11 +85,13 @@ static inline const char *kobject_name(const struct kobject *kobj)
85extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype); 85extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype);
86extern int __must_check kobject_add(struct kobject *kobj, 86extern int __must_check kobject_add(struct kobject *kobj,
87 struct kobject *parent, 87 struct kobject *parent,
88 const char *fmt, ...); 88 const char *fmt, ...)
89 __attribute__((format(printf, 3, 4)));
89extern int __must_check kobject_init_and_add(struct kobject *kobj, 90extern int __must_check kobject_init_and_add(struct kobject *kobj,
90 struct kobj_type *ktype, 91 struct kobj_type *ktype,
91 struct kobject *parent, 92 struct kobject *parent,
92 const char *fmt, ...); 93 const char *fmt, ...)
94 __attribute__((format(printf, 4, 5)));
93 95
94extern void kobject_del(struct kobject *kobj); 96extern void kobject_del(struct kobject *kobj);
95 97
@@ -191,6 +193,8 @@ static inline struct kobj_type *get_ktype(struct kobject *kobj)
191} 193}
192 194
193extern struct kobject *kset_find_obj(struct kset *, const char *); 195extern struct kobject *kset_find_obj(struct kset *, const char *);
196extern struct kobject *kset_find_obj_hinted(struct kset *, const char *,
197 struct kobject *);
194 198
195/* The global /sys/kernel/ kobject for people to chain off of */ 199/* The global /sys/kernel/ kobject for people to chain off of */
196extern struct kobject *kernel_kobj; 200extern struct kobject *kernel_kobj;
@@ -222,8 +226,8 @@ static inline int kobject_uevent_env(struct kobject *kobj,
222 char *envp[]) 226 char *envp[])
223{ return 0; } 227{ return 0; }
224 228
225static inline int add_uevent_var(struct kobj_uevent_env *env, 229static inline __attribute__((format(printf, 2, 3)))
226 const char *format, ...) 230int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
227{ return 0; } 231{ return 0; }
228 232
229static inline int kobject_action_type(const char *buf, size_t count, 233static inline int kobject_action_type(const char *buf, size_t count,
diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
index 82cb5bf461fb..f66b065a8b5f 100644
--- a/include/linux/kobject_ns.h
+++ b/include/linux/kobject_ns.h
@@ -32,15 +32,17 @@ enum kobj_ns_type {
32 32
33/* 33/*
34 * Callbacks so sysfs can determine namespaces 34 * Callbacks so sysfs can determine namespaces
35 * @current_ns: return calling task's namespace 35 * @grab_current_ns: return a new reference to calling task's namespace
36 * @netlink_ns: return namespace to which a sock belongs (right?) 36 * @netlink_ns: return namespace to which a sock belongs (right?)
37 * @initial_ns: return the initial namespace (i.e. init_net_ns) 37 * @initial_ns: return the initial namespace (i.e. init_net_ns)
38 * @drop_ns: drops a reference to namespace
38 */ 39 */
39struct kobj_ns_type_operations { 40struct kobj_ns_type_operations {
40 enum kobj_ns_type type; 41 enum kobj_ns_type type;
41 const void *(*current_ns)(void); 42 void *(*grab_current_ns)(void);
42 const void *(*netlink_ns)(struct sock *sk); 43 const void *(*netlink_ns)(struct sock *sk);
43 const void *(*initial_ns)(void); 44 const void *(*initial_ns)(void);
45 void (*drop_ns)(void *);
44}; 46};
45 47
46int kobj_ns_type_register(const struct kobj_ns_type_operations *ops); 48int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
@@ -48,9 +50,9 @@ int kobj_ns_type_registered(enum kobj_ns_type type);
48const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent); 50const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent);
49const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj); 51const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj);
50 52
51const void *kobj_ns_current(enum kobj_ns_type type); 53void *kobj_ns_grab_current(enum kobj_ns_type type);
52const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk); 54const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk);
53const void *kobj_ns_initial(enum kobj_ns_type type); 55const void *kobj_ns_initial(enum kobj_ns_type type);
54void kobj_ns_exit(enum kobj_ns_type type, const void *ns); 56void kobj_ns_drop(enum kobj_ns_type type, void *ns);
55 57
56#endif /* _LINUX_KOBJECT_NS_H */ 58#endif /* _LINUX_KOBJECT_NS_H */
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index e7d1b2e0070d..dd7c12e875bc 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -275,7 +275,9 @@ extern int arch_prepared_optinsn(struct arch_optimized_insn *optinsn);
275extern int arch_check_optimized_kprobe(struct optimized_kprobe *op); 275extern int arch_check_optimized_kprobe(struct optimized_kprobe *op);
276extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op); 276extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op);
277extern void arch_remove_optimized_kprobe(struct optimized_kprobe *op); 277extern void arch_remove_optimized_kprobe(struct optimized_kprobe *op);
278extern int arch_optimize_kprobe(struct optimized_kprobe *op); 278extern void arch_optimize_kprobes(struct list_head *oplist);
279extern void arch_unoptimize_kprobes(struct list_head *oplist,
280 struct list_head *done_list);
279extern void arch_unoptimize_kprobe(struct optimized_kprobe *op); 281extern void arch_unoptimize_kprobe(struct optimized_kprobe *op);
280extern kprobe_opcode_t *get_optinsn_slot(void); 282extern kprobe_opcode_t *get_optinsn_slot(void);
281extern void free_optinsn_slot(kprobe_opcode_t *slot, int dirty); 283extern void free_optinsn_slot(kprobe_opcode_t *slot, int dirty);
@@ -303,12 +305,12 @@ struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk);
303/* kprobe_running() will just return the current_kprobe on this CPU */ 305/* kprobe_running() will just return the current_kprobe on this CPU */
304static inline struct kprobe *kprobe_running(void) 306static inline struct kprobe *kprobe_running(void)
305{ 307{
306 return (__get_cpu_var(current_kprobe)); 308 return (__this_cpu_read(current_kprobe));
307} 309}
308 310
309static inline void reset_current_kprobe(void) 311static inline void reset_current_kprobe(void)
310{ 312{
311 __get_cpu_var(current_kprobe) = NULL; 313 __this_cpu_write(current_kprobe, NULL);
312} 314}
313 315
314static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void) 316static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
diff --git a/include/linux/kref.h b/include/linux/kref.h
index 6cc38fc07ab7..d4a62ab2ee5e 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -24,5 +24,7 @@ struct kref {
24void kref_init(struct kref *kref); 24void kref_init(struct kref *kref);
25void kref_get(struct kref *kref); 25void kref_get(struct kref *kref);
26int kref_put(struct kref *kref, void (*release) (struct kref *kref)); 26int kref_put(struct kref *kref, void (*release) (struct kref *kref));
27int kref_sub(struct kref *kref, unsigned int count,
28 void (*release) (struct kref *kref));
27 29
28#endif /* _KREF_H_ */ 30#endif /* _KREF_H_ */
diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 685ea65eb803..1e923e5e88e8 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -4,10 +4,15 @@
4#include <linux/err.h> 4#include <linux/err.h>
5#include <linux/sched.h> 5#include <linux/sched.h>
6 6
7struct task_struct *kthread_create(int (*threadfn)(void *data), 7struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
8 void *data, 8 void *data,
9 const char namefmt[], ...) 9 int node,
10 __attribute__((format(printf, 3, 4))); 10 const char namefmt[], ...)
11 __attribute__((format(printf, 4, 5)));
12
13#define kthread_create(threadfn, data, namefmt, arg...) \
14 kthread_create_on_node(threadfn, data, -1, namefmt, ##arg)
15
11 16
12/** 17/**
13 * kthread_run - create and wake a thread. 18 * kthread_run - create and wake a thread.
@@ -34,6 +39,7 @@ void *kthread_data(struct task_struct *k);
34 39
35int kthreadd(void *unused); 40int kthreadd(void *unused);
36extern struct task_struct *kthreadd_task; 41extern struct task_struct *kthreadd_task;
42extern int tsk_fork_get_node(struct task_struct *tsk);
37 43
38/* 44/*
39 * Simple work processor based on kthread. 45 * Simple work processor based on kthread.
@@ -64,7 +70,7 @@ struct kthread_work {
64}; 70};
65 71
66#define KTHREAD_WORKER_INIT(worker) { \ 72#define KTHREAD_WORKER_INIT(worker) { \
67 .lock = SPIN_LOCK_UNLOCKED, \ 73 .lock = __SPIN_LOCK_UNLOCKED((worker).lock), \
68 .work_list = LIST_HEAD_INIT((worker).work_list), \ 74 .work_list = LIST_HEAD_INIT((worker).work_list), \
69 } 75 }
70 76
@@ -81,16 +87,41 @@ struct kthread_work {
81#define DEFINE_KTHREAD_WORK(work, fn) \ 87#define DEFINE_KTHREAD_WORK(work, fn) \
82 struct kthread_work work = KTHREAD_WORK_INIT(work, fn) 88 struct kthread_work work = KTHREAD_WORK_INIT(work, fn)
83 89
84static inline void init_kthread_worker(struct kthread_worker *worker) 90/*
85{ 91 * kthread_worker.lock and kthread_work.done need their own lockdep class
86 *worker = (struct kthread_worker)KTHREAD_WORKER_INIT(*worker); 92 * keys if they are defined on stack with lockdep enabled. Use the
87} 93 * following macros when defining them on stack.
88 94 */
89static inline void init_kthread_work(struct kthread_work *work, 95#ifdef CONFIG_LOCKDEP
90 kthread_work_func_t fn) 96# define KTHREAD_WORKER_INIT_ONSTACK(worker) \
91{ 97 ({ init_kthread_worker(&worker); worker; })
92 *work = (struct kthread_work)KTHREAD_WORK_INIT(*work, fn); 98# define DEFINE_KTHREAD_WORKER_ONSTACK(worker) \
93} 99 struct kthread_worker worker = KTHREAD_WORKER_INIT_ONSTACK(worker)
100# define KTHREAD_WORK_INIT_ONSTACK(work, fn) \
101 ({ init_kthread_work((&work), fn); work; })
102# define DEFINE_KTHREAD_WORK_ONSTACK(work, fn) \
103 struct kthread_work work = KTHREAD_WORK_INIT_ONSTACK(work, fn)
104#else
105# define DEFINE_KTHREAD_WORKER_ONSTACK(worker) DEFINE_KTHREAD_WORKER(worker)
106# define DEFINE_KTHREAD_WORK_ONSTACK(work, fn) DEFINE_KTHREAD_WORK(work, fn)
107#endif
108
109extern void __init_kthread_worker(struct kthread_worker *worker,
110 const char *name, struct lock_class_key *key);
111
112#define init_kthread_worker(worker) \
113 do { \
114 static struct lock_class_key __key; \
115 __init_kthread_worker((worker), "("#worker")->lock", &__key); \
116 } while (0)
117
118#define init_kthread_work(work, fn) \
119 do { \
120 memset((work), 0, sizeof(struct kthread_work)); \
121 INIT_LIST_HEAD(&(work)->node); \
122 (work)->func = (fn); \
123 init_waitqueue_head(&(work)->done); \
124 } while (0)
94 125
95int kthread_worker_fn(void *worker_ptr); 126int kthread_worker_fn(void *worker_ptr);
96 127
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index e1ceaa9b36bb..603bec2913b0 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -35,7 +35,7 @@
35 * 35 *
36 * On 32-bit CPUs an optimized representation of the timespec structure 36 * On 32-bit CPUs an optimized representation of the timespec structure
37 * is used to avoid expensive conversions from and to timespecs. The 37 * is used to avoid expensive conversions from and to timespecs. The
38 * endian-aware order of the tv struct members is choosen to allow 38 * endian-aware order of the tv struct members is chosen to allow
39 * mathematical operations on the tv64 member of the union too, which 39 * mathematical operations on the tv64 member of the union too, which
40 * for certain operations produces better code. 40 * for certain operations produces better code.
41 * 41 *
@@ -158,7 +158,7 @@ static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
158 * @lhs: minuend 158 * @lhs: minuend
159 * @rhs: subtrahend 159 * @rhs: subtrahend
160 * 160 *
161 * Returns the remainder of the substraction 161 * Returns the remainder of the subtraction
162 */ 162 */
163static inline ktime_t ktime_sub(const ktime_t lhs, const ktime_t rhs) 163static inline ktime_t ktime_sub(const ktime_t lhs, const ktime_t rhs)
164{ 164{
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 636fc381c897..55ef181521ff 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -414,6 +414,14 @@ struct kvm_enable_cap {
414 __u8 pad[64]; 414 __u8 pad[64];
415}; 415};
416 416
417/* for KVM_PPC_GET_PVINFO */
418struct kvm_ppc_pvinfo {
419 /* out */
420 __u32 flags;
421 __u32 hcall[4];
422 __u8 pad[108];
423};
424
417#define KVMIO 0xAE 425#define KVMIO 0xAE
418 426
419/* 427/*
@@ -530,6 +538,12 @@ struct kvm_enable_cap {
530#ifdef __KVM_HAVE_XCRS 538#ifdef __KVM_HAVE_XCRS
531#define KVM_CAP_XCRS 56 539#define KVM_CAP_XCRS 56
532#endif 540#endif
541#define KVM_CAP_PPC_GET_PVINFO 57
542#define KVM_CAP_PPC_IRQ_LEVEL 58
543#define KVM_CAP_ASYNC_PF 59
544#define KVM_CAP_TSC_CONTROL 60
545#define KVM_CAP_GET_TSC_KHZ 61
546#define KVM_CAP_PPC_BOOKE_SREGS 62
533 547
534#ifdef KVM_CAP_IRQ_ROUTING 548#ifdef KVM_CAP_IRQ_ROUTING
535 549
@@ -664,6 +678,11 @@ struct kvm_clock_data {
664/* Available with KVM_CAP_PIT_STATE2 */ 678/* Available with KVM_CAP_PIT_STATE2 */
665#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 679#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2)
666#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 680#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
681/* Available with KVM_CAP_PPC_GET_PVINFO */
682#define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo)
683/* Available with KVM_CAP_TSC_CONTROL */
684#define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
685#define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
667 686
668/* 687/*
669 * ioctls for vcpu fds 688 * ioctls for vcpu fds
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index c13cc48697aa..31ebb59cbd2f 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -16,6 +16,8 @@
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/preempt.h> 17#include <linux/preempt.h>
18#include <linux/msi.h> 18#include <linux/msi.h>
19#include <linux/slab.h>
20#include <linux/rcupdate.h>
19#include <asm/signal.h> 21#include <asm/signal.h>
20 22
21#include <linux/kvm.h> 23#include <linux/kvm.h>
@@ -25,6 +27,10 @@
25 27
26#include <asm/kvm_host.h> 28#include <asm/kvm_host.h>
27 29
30#ifndef KVM_MMIO_SIZE
31#define KVM_MMIO_SIZE 8
32#endif
33
28/* 34/*
29 * vcpu->requests bit members 35 * vcpu->requests bit members
30 */ 36 */
@@ -36,9 +42,11 @@
36#define KVM_REQ_PENDING_TIMER 5 42#define KVM_REQ_PENDING_TIMER 5
37#define KVM_REQ_UNHALT 6 43#define KVM_REQ_UNHALT 6
38#define KVM_REQ_MMU_SYNC 7 44#define KVM_REQ_MMU_SYNC 7
39#define KVM_REQ_KVMCLOCK_UPDATE 8 45#define KVM_REQ_CLOCK_UPDATE 8
40#define KVM_REQ_KICK 9 46#define KVM_REQ_KICK 9
41#define KVM_REQ_DEACTIVATE_FPU 10 47#define KVM_REQ_DEACTIVATE_FPU 10
48#define KVM_REQ_EVENT 11
49#define KVM_REQ_APF_HALT 12
42 50
43#define KVM_USERSPACE_IRQ_SOURCE_ID 0 51#define KVM_USERSPACE_IRQ_SOURCE_ID 0
44 52
@@ -73,23 +81,52 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx,
73int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx, 81int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
74 struct kvm_io_device *dev); 82 struct kvm_io_device *dev);
75 83
84#ifdef CONFIG_KVM_ASYNC_PF
85struct kvm_async_pf {
86 struct work_struct work;
87 struct list_head link;
88 struct list_head queue;
89 struct kvm_vcpu *vcpu;
90 struct mm_struct *mm;
91 gva_t gva;
92 unsigned long addr;
93 struct kvm_arch_async_pf arch;
94 struct page *page;
95 bool done;
96};
97
98void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu);
99void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu);
100int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn,
101 struct kvm_arch_async_pf *arch);
102int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu);
103#endif
104
105enum {
106 OUTSIDE_GUEST_MODE,
107 IN_GUEST_MODE,
108 EXITING_GUEST_MODE
109};
110
76struct kvm_vcpu { 111struct kvm_vcpu {
77 struct kvm *kvm; 112 struct kvm *kvm;
78#ifdef CONFIG_PREEMPT_NOTIFIERS 113#ifdef CONFIG_PREEMPT_NOTIFIERS
79 struct preempt_notifier preempt_notifier; 114 struct preempt_notifier preempt_notifier;
80#endif 115#endif
116 int cpu;
81 int vcpu_id; 117 int vcpu_id;
82 struct mutex mutex; 118 int srcu_idx;
83 int cpu; 119 int mode;
84 atomic_t guest_mode;
85 struct kvm_run *run;
86 unsigned long requests; 120 unsigned long requests;
87 unsigned long guest_debug; 121 unsigned long guest_debug;
88 int srcu_idx; 122
123 struct mutex mutex;
124 struct kvm_run *run;
89 125
90 int fpu_active; 126 int fpu_active;
91 int guest_fpu_loaded, guest_xcr0_loaded; 127 int guest_fpu_loaded, guest_xcr0_loaded;
92 wait_queue_head_t wq; 128 wait_queue_head_t wq;
129 struct pid *pid;
93 int sigset_active; 130 int sigset_active;
94 sigset_t sigset; 131 sigset_t sigset;
95 struct kvm_vcpu_stat stat; 132 struct kvm_vcpu_stat stat;
@@ -99,29 +136,47 @@ struct kvm_vcpu {
99 int mmio_read_completed; 136 int mmio_read_completed;
100 int mmio_is_write; 137 int mmio_is_write;
101 int mmio_size; 138 int mmio_size;
102 unsigned char mmio_data[8]; 139 int mmio_index;
140 unsigned char mmio_data[KVM_MMIO_SIZE];
103 gpa_t mmio_phys_addr; 141 gpa_t mmio_phys_addr;
104#endif 142#endif
105 143
144#ifdef CONFIG_KVM_ASYNC_PF
145 struct {
146 u32 queued;
147 struct list_head queue;
148 struct list_head done;
149 spinlock_t lock;
150 } async_pf;
151#endif
152
106 struct kvm_vcpu_arch arch; 153 struct kvm_vcpu_arch arch;
107}; 154};
108 155
156static inline int kvm_vcpu_exiting_guest_mode(struct kvm_vcpu *vcpu)
157{
158 return cmpxchg(&vcpu->mode, IN_GUEST_MODE, EXITING_GUEST_MODE);
159}
160
109/* 161/*
110 * Some of the bitops functions do not support too long bitmaps. 162 * Some of the bitops functions do not support too long bitmaps.
111 * This number must be determined not to exceed such limits. 163 * This number must be determined not to exceed such limits.
112 */ 164 */
113#define KVM_MEM_MAX_NR_PAGES ((1UL << 31) - 1) 165#define KVM_MEM_MAX_NR_PAGES ((1UL << 31) - 1)
114 166
167struct kvm_lpage_info {
168 unsigned long rmap_pde;
169 int write_count;
170};
171
115struct kvm_memory_slot { 172struct kvm_memory_slot {
116 gfn_t base_gfn; 173 gfn_t base_gfn;
117 unsigned long npages; 174 unsigned long npages;
118 unsigned long flags; 175 unsigned long flags;
119 unsigned long *rmap; 176 unsigned long *rmap;
120 unsigned long *dirty_bitmap; 177 unsigned long *dirty_bitmap;
121 struct { 178 unsigned long *dirty_bitmap_head;
122 unsigned long rmap_pde; 179 struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1];
123 int write_count;
124 } *lpage_info[KVM_NR_PAGE_SIZES - 1];
125 unsigned long userspace_addr; 180 unsigned long userspace_addr;
126 int user_alloc; 181 int user_alloc;
127 int id; 182 int id;
@@ -168,13 +223,13 @@ struct kvm_irq_routing_table {};
168 223
169struct kvm_memslots { 224struct kvm_memslots {
170 int nmemslots; 225 int nmemslots;
226 u64 generation;
171 struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + 227 struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS +
172 KVM_PRIVATE_MEM_SLOTS]; 228 KVM_PRIVATE_MEM_SLOTS];
173}; 229};
174 230
175struct kvm { 231struct kvm {
176 spinlock_t mmu_lock; 232 spinlock_t mmu_lock;
177 raw_spinlock_t requests_lock;
178 struct mutex slots_lock; 233 struct mutex slots_lock;
179 struct mm_struct *mm; /* userspace tied to this vm */ 234 struct mm_struct *mm; /* userspace tied to this vm */
180 struct kvm_memslots *memslots; 235 struct kvm_memslots *memslots;
@@ -185,6 +240,7 @@ struct kvm {
185#endif 240#endif
186 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; 241 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
187 atomic_t online_vcpus; 242 atomic_t online_vcpus;
243 int last_boosted_vcpu;
188 struct list_head vm_list; 244 struct list_head vm_list;
189 struct mutex lock; 245 struct mutex lock;
190 struct kvm_io_bus *buses[KVM_NR_BUSES]; 246 struct kvm_io_bus *buses[KVM_NR_BUSES];
@@ -205,7 +261,11 @@ struct kvm {
205 261
206 struct mutex irq_lock; 262 struct mutex irq_lock;
207#ifdef CONFIG_HAVE_KVM_IRQCHIP 263#ifdef CONFIG_HAVE_KVM_IRQCHIP
208 struct kvm_irq_routing_table *irq_routing; 264 /*
265 * Update side is protected by irq_lock and,
266 * if configured, irqfds.lock.
267 */
268 struct kvm_irq_routing_table __rcu *irq_routing;
209 struct hlist_head mask_notifier_list; 269 struct hlist_head mask_notifier_list;
210 struct hlist_head irq_ack_notifier_list; 270 struct hlist_head irq_ack_notifier_list;
211#endif 271#endif
@@ -215,6 +275,7 @@ struct kvm {
215 unsigned long mmu_notifier_seq; 275 unsigned long mmu_notifier_seq;
216 long mmu_notifier_count; 276 long mmu_notifier_count;
217#endif 277#endif
278 long tlbs_dirty;
218}; 279};
219 280
220/* The guest did something we don't support. */ 281/* The guest did something we don't support. */
@@ -235,9 +296,10 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
235} 296}
236 297
237#define kvm_for_each_vcpu(idx, vcpup, kvm) \ 298#define kvm_for_each_vcpu(idx, vcpup, kvm) \
238 for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \ 299 for (idx = 0; \
239 idx < atomic_read(&kvm->online_vcpus) && vcpup; \ 300 idx < atomic_read(&kvm->online_vcpus) && \
240 vcpup = kvm_get_vcpu(kvm, ++idx)) 301 (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
302 idx++)
241 303
242int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id); 304int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
243void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); 305void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
@@ -289,6 +351,9 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
289void kvm_disable_largepages(void); 351void kvm_disable_largepages(void);
290void kvm_arch_flush_shadow(struct kvm *kvm); 352void kvm_arch_flush_shadow(struct kvm *kvm);
291 353
354int gfn_to_page_many_atomic(struct kvm *kvm, gfn_t gfn, struct page **pages,
355 int nr_pages);
356
292struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); 357struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
293unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); 358unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
294void kvm_release_page_clean(struct page *page); 359void kvm_release_page_clean(struct page *page);
@@ -296,10 +361,15 @@ void kvm_release_page_dirty(struct page *page);
296void kvm_set_page_dirty(struct page *page); 361void kvm_set_page_dirty(struct page *page);
297void kvm_set_page_accessed(struct page *page); 362void kvm_set_page_accessed(struct page *page);
298 363
364pfn_t hva_to_pfn_atomic(struct kvm *kvm, unsigned long addr);
365pfn_t gfn_to_pfn_atomic(struct kvm *kvm, gfn_t gfn);
366pfn_t gfn_to_pfn_async(struct kvm *kvm, gfn_t gfn, bool *async,
367 bool write_fault, bool *writable);
299pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn); 368pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn);
369pfn_t gfn_to_pfn_prot(struct kvm *kvm, gfn_t gfn, bool write_fault,
370 bool *writable);
300pfn_t gfn_to_pfn_memslot(struct kvm *kvm, 371pfn_t gfn_to_pfn_memslot(struct kvm *kvm,
301 struct kvm_memory_slot *slot, gfn_t gfn); 372 struct kvm_memory_slot *slot, gfn_t gfn);
302int memslot_id(struct kvm *kvm, gfn_t gfn);
303void kvm_release_pfn_dirty(pfn_t); 373void kvm_release_pfn_dirty(pfn_t);
304void kvm_release_pfn_clean(pfn_t pfn); 374void kvm_release_pfn_clean(pfn_t pfn);
305void kvm_set_pfn_dirty(pfn_t pfn); 375void kvm_set_pfn_dirty(pfn_t pfn);
@@ -315,18 +385,25 @@ int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data,
315 int offset, int len); 385 int offset, int len);
316int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data, 386int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
317 unsigned long len); 387 unsigned long len);
388int kvm_write_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
389 void *data, unsigned long len);
390int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
391 gpa_t gpa);
318int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len); 392int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
319int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len); 393int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
320struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); 394struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
321int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn); 395int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
322unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn); 396unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn);
323void mark_page_dirty(struct kvm *kvm, gfn_t gfn); 397void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
398void mark_page_dirty_in_slot(struct kvm *kvm, struct kvm_memory_slot *memslot,
399 gfn_t gfn);
324 400
325void kvm_vcpu_block(struct kvm_vcpu *vcpu); 401void kvm_vcpu_block(struct kvm_vcpu *vcpu);
326void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu); 402void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu);
327void kvm_resched(struct kvm_vcpu *vcpu); 403void kvm_resched(struct kvm_vcpu *vcpu);
328void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); 404void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
329void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); 405void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
406
330void kvm_flush_remote_tlbs(struct kvm *kvm); 407void kvm_flush_remote_tlbs(struct kvm *kvm);
331void kvm_reload_remote_mmus(struct kvm *kvm); 408void kvm_reload_remote_mmus(struct kvm *kvm);
332 409
@@ -392,7 +469,19 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
392 469
393void kvm_free_physmem(struct kvm *kvm); 470void kvm_free_physmem(struct kvm *kvm);
394 471
395struct kvm *kvm_arch_create_vm(void); 472#ifndef __KVM_HAVE_ARCH_VM_ALLOC
473static inline struct kvm *kvm_arch_alloc_vm(void)
474{
475 return kzalloc(sizeof(struct kvm), GFP_KERNEL);
476}
477
478static inline void kvm_arch_free_vm(struct kvm *kvm)
479{
480 kfree(kvm);
481}
482#endif
483
484int kvm_arch_init_vm(struct kvm *kvm);
396void kvm_arch_destroy_vm(struct kvm *kvm); 485void kvm_arch_destroy_vm(struct kvm *kvm);
397void kvm_free_all_assigned_devices(struct kvm *kvm); 486void kvm_free_all_assigned_devices(struct kvm *kvm);
398void kvm_arch_sync_events(struct kvm *kvm); 487void kvm_arch_sync_events(struct kvm *kvm);
@@ -408,16 +497,8 @@ struct kvm_irq_ack_notifier {
408 void (*irq_acked)(struct kvm_irq_ack_notifier *kian); 497 void (*irq_acked)(struct kvm_irq_ack_notifier *kian);
409}; 498};
410 499
411#define KVM_ASSIGNED_MSIX_PENDING 0x1
412struct kvm_guest_msix_entry {
413 u32 vector;
414 u16 entry;
415 u16 flags;
416};
417
418struct kvm_assigned_dev_kernel { 500struct kvm_assigned_dev_kernel {
419 struct kvm_irq_ack_notifier ack_notifier; 501 struct kvm_irq_ack_notifier ack_notifier;
420 struct work_struct interrupt_work;
421 struct list_head list; 502 struct list_head list;
422 int assigned_dev_id; 503 int assigned_dev_id;
423 int host_segnr; 504 int host_segnr;
@@ -428,13 +509,15 @@ struct kvm_assigned_dev_kernel {
428 bool host_irq_disabled; 509 bool host_irq_disabled;
429 struct msix_entry *host_msix_entries; 510 struct msix_entry *host_msix_entries;
430 int guest_irq; 511 int guest_irq;
431 struct kvm_guest_msix_entry *guest_msix_entries; 512 struct msix_entry *guest_msix_entries;
432 unsigned long irq_requested_type; 513 unsigned long irq_requested_type;
433 int irq_source_id; 514 int irq_source_id;
434 int flags; 515 int flags;
435 struct pci_dev *dev; 516 struct pci_dev *dev;
436 struct kvm *kvm; 517 struct kvm *kvm;
437 spinlock_t assigned_dev_lock; 518 spinlock_t intx_lock;
519 char irq_name[32];
520 struct pci_saved_state *pci_saved_state;
438}; 521};
439 522
440struct kvm_irq_mask_notifier { 523struct kvm_irq_mask_notifier {
@@ -456,6 +539,8 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic,
456 unsigned long *deliver_bitmask); 539 unsigned long *deliver_bitmask);
457#endif 540#endif
458int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level); 541int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level);
542int kvm_set_msi(struct kvm_kernel_irq_routing_entry *irq_entry, struct kvm *kvm,
543 int irq_source_id, int level);
459void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin); 544void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin);
460void kvm_register_irq_ack_notifier(struct kvm *kvm, 545void kvm_register_irq_ack_notifier(struct kvm *kvm,
461 struct kvm_irq_ack_notifier *kian); 546 struct kvm_irq_ack_notifier *kian);
@@ -477,8 +562,7 @@ int kvm_deassign_device(struct kvm *kvm,
477 struct kvm_assigned_dev_kernel *assigned_dev); 562 struct kvm_assigned_dev_kernel *assigned_dev);
478#else /* CONFIG_IOMMU_API */ 563#else /* CONFIG_IOMMU_API */
479static inline int kvm_iommu_map_pages(struct kvm *kvm, 564static inline int kvm_iommu_map_pages(struct kvm *kvm,
480 gfn_t base_gfn, 565 struct kvm_memory_slot *slot)
481 unsigned long npages)
482{ 566{
483 return 0; 567 return 0;
484} 568}
@@ -508,8 +592,17 @@ static inline int kvm_deassign_device(struct kvm *kvm,
508 592
509static inline void kvm_guest_enter(void) 593static inline void kvm_guest_enter(void)
510{ 594{
595 BUG_ON(preemptible());
511 account_system_vtime(current); 596 account_system_vtime(current);
512 current->flags |= PF_VCPU; 597 current->flags |= PF_VCPU;
598 /* KVM does not hold any references to rcu protected data when it
599 * switches CPU into a guest mode. In fact switching to a guest mode
600 * is very similar to exiting to userspase from rcu point of view. In
601 * addition CPU may stay in a guest mode for quite a long time (up to
602 * one time slice). Lets treat guest mode as quiescent state, just like
603 * we do with user-mode execution.
604 */
605 rcu_virt_note_context_switch(smp_processor_id());
513} 606}
514 607
515static inline void kvm_guest_exit(void) 608static inline void kvm_guest_exit(void)
@@ -518,11 +611,27 @@ static inline void kvm_guest_exit(void)
518 current->flags &= ~PF_VCPU; 611 current->flags &= ~PF_VCPU;
519} 612}
520 613
614static inline int memslot_id(struct kvm *kvm, gfn_t gfn)
615{
616 return gfn_to_memslot(kvm, gfn)->id;
617}
618
619static inline unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot,
620 gfn_t gfn)
621{
622 return slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE;
623}
624
521static inline gpa_t gfn_to_gpa(gfn_t gfn) 625static inline gpa_t gfn_to_gpa(gfn_t gfn)
522{ 626{
523 return (gpa_t)gfn << PAGE_SHIFT; 627 return (gpa_t)gfn << PAGE_SHIFT;
524} 628}
525 629
630static inline gfn_t gpa_to_gfn(gpa_t gpa)
631{
632 return (gfn_t)(gpa >> PAGE_SHIFT);
633}
634
526static inline hpa_t pfn_to_hpa(pfn_t pfn) 635static inline hpa_t pfn_to_hpa(pfn_t pfn)
527{ 636{
528 return (hpa_t)pfn << PAGE_SHIFT; 637 return (hpa_t)pfn << PAGE_SHIFT;
@@ -587,17 +696,28 @@ static inline void kvm_free_irq_routing(struct kvm *kvm) {}
587void kvm_eventfd_init(struct kvm *kvm); 696void kvm_eventfd_init(struct kvm *kvm);
588int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags); 697int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags);
589void kvm_irqfd_release(struct kvm *kvm); 698void kvm_irqfd_release(struct kvm *kvm);
699void kvm_irq_routing_update(struct kvm *, struct kvm_irq_routing_table *);
590int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args); 700int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args);
591 701
592#else 702#else
593 703
594static inline void kvm_eventfd_init(struct kvm *kvm) {} 704static inline void kvm_eventfd_init(struct kvm *kvm) {}
705
595static inline int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags) 706static inline int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags)
596{ 707{
597 return -EINVAL; 708 return -EINVAL;
598} 709}
599 710
600static inline void kvm_irqfd_release(struct kvm *kvm) {} 711static inline void kvm_irqfd_release(struct kvm *kvm) {}
712
713#ifdef CONFIG_HAVE_KVM_IRQCHIP
714static inline void kvm_irq_routing_update(struct kvm *kvm,
715 struct kvm_irq_routing_table *irq_rt)
716{
717 rcu_assign_pointer(kvm->irq_routing, irq_rt);
718}
719#endif
720
601static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) 721static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
602{ 722{
603 return -ENOSYS; 723 return -ENOSYS;
@@ -632,11 +752,6 @@ static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu)
632 set_bit(req, &vcpu->requests); 752 set_bit(req, &vcpu->requests);
633} 753}
634 754
635static inline bool kvm_make_check_request(int req, struct kvm_vcpu *vcpu)
636{
637 return test_and_set_bit(req, &vcpu->requests);
638}
639
640static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu) 755static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu)
641{ 756{
642 if (test_bit(req, &vcpu->requests)) { 757 if (test_bit(req, &vcpu->requests)) {
diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
index d73109243fda..47a070b0520e 100644
--- a/include/linux/kvm_para.h
+++ b/include/linux/kvm_para.h
@@ -17,6 +17,8 @@
17 17
18#define KVM_HC_VAPIC_POLL_IRQ 1 18#define KVM_HC_VAPIC_POLL_IRQ 1
19#define KVM_HC_MMU_OP 2 19#define KVM_HC_MMU_OP 2
20#define KVM_HC_FEATURES 3
21#define KVM_HC_PPC_MAP_MAGIC_PAGE 4
20 22
21/* 23/*
22 * hypercalls use architecture specific 24 * hypercalls use architecture specific
@@ -24,11 +26,6 @@
24#include <asm/kvm_para.h> 26#include <asm/kvm_para.h>
25 27
26#ifdef __KERNEL__ 28#ifdef __KERNEL__
27#ifdef CONFIG_KVM_GUEST
28void __init kvm_guest_init(void);
29#else
30#define kvm_guest_init() do { } while (0)
31#endif
32 29
33static inline int kvm_para_has_feature(unsigned int feature) 30static inline int kvm_para_has_feature(unsigned int feature)
34{ 31{
diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
index 7ac0d4eee430..fa7cc7244cbd 100644
--- a/include/linux/kvm_types.h
+++ b/include/linux/kvm_types.h
@@ -67,4 +67,11 @@ struct kvm_lapic_irq {
67 u32 dest_id; 67 u32 dest_id;
68}; 68};
69 69
70struct gfn_to_hva_cache {
71 u64 generation;
72 gpa_t gpa;
73 unsigned long hva;
74 struct kvm_memory_slot *memslot;
75};
76
70#endif /* __KVM_TYPES_H__ */ 77#endif /* __KVM_TYPES_H__ */
diff --git a/include/linux/led-lm3530.h b/include/linux/led-lm3530.h
new file mode 100644
index 000000000000..58592fa67d24
--- /dev/null
+++ b/include/linux/led-lm3530.h
@@ -0,0 +1,107 @@
1/*
2 * Copyright (C) 2011 ST-Ericsson SA.
3 * Copyright (C) 2009 Motorola, Inc.
4 *
5 * License Terms: GNU General Public License v2
6 *
7 * Simple driver for National Semiconductor LM35330 Backlight driver chip
8 *
9 * Author: Shreshtha Kumar SAHU <shreshthakumar.sahu@stericsson.com>
10 * based on leds-lm3530.c by Dan Murphy <D.Murphy@motorola.com>
11 */
12
13#ifndef _LINUX_LED_LM3530_H__
14#define _LINUX_LED_LM3530_H__
15
16#define LM3530_FS_CURR_5mA (0) /* Full Scale Current */
17#define LM3530_FS_CURR_8mA (1)
18#define LM3530_FS_CURR_12mA (2)
19#define LM3530_FS_CURR_15mA (3)
20#define LM3530_FS_CURR_19mA (4)
21#define LM3530_FS_CURR_22mA (5)
22#define LM3530_FS_CURR_26mA (6)
23#define LM3530_FS_CURR_29mA (7)
24
25#define LM3530_ALS_AVRG_TIME_32ms (0) /* ALS Averaging Time */
26#define LM3530_ALS_AVRG_TIME_64ms (1)
27#define LM3530_ALS_AVRG_TIME_128ms (2)
28#define LM3530_ALS_AVRG_TIME_256ms (3)
29#define LM3530_ALS_AVRG_TIME_512ms (4)
30#define LM3530_ALS_AVRG_TIME_1024ms (5)
31#define LM3530_ALS_AVRG_TIME_2048ms (6)
32#define LM3530_ALS_AVRG_TIME_4096ms (7)
33
34#define LM3530_RAMP_TIME_1ms (0) /* Brigtness Ramp Time */
35#define LM3530_RAMP_TIME_130ms (1) /* Max to 0 and vice versa */
36#define LM3530_RAMP_TIME_260ms (2)
37#define LM3530_RAMP_TIME_520ms (3)
38#define LM3530_RAMP_TIME_1s (4)
39#define LM3530_RAMP_TIME_2s (5)
40#define LM3530_RAMP_TIME_4s (6)
41#define LM3530_RAMP_TIME_8s (7)
42
43/* ALS Resistor Select */
44#define LM3530_ALS_IMPD_Z (0x00) /* ALS Impedance */
45#define LM3530_ALS_IMPD_13_53kOhm (0x01)
46#define LM3530_ALS_IMPD_9_01kOhm (0x02)
47#define LM3530_ALS_IMPD_5_41kOhm (0x03)
48#define LM3530_ALS_IMPD_2_27kOhm (0x04)
49#define LM3530_ALS_IMPD_1_94kOhm (0x05)
50#define LM3530_ALS_IMPD_1_81kOhm (0x06)
51#define LM3530_ALS_IMPD_1_6kOhm (0x07)
52#define LM3530_ALS_IMPD_1_138kOhm (0x08)
53#define LM3530_ALS_IMPD_1_05kOhm (0x09)
54#define LM3530_ALS_IMPD_1_011kOhm (0x0A)
55#define LM3530_ALS_IMPD_941Ohm (0x0B)
56#define LM3530_ALS_IMPD_759Ohm (0x0C)
57#define LM3530_ALS_IMPD_719Ohm (0x0D)
58#define LM3530_ALS_IMPD_700Ohm (0x0E)
59#define LM3530_ALS_IMPD_667Ohm (0x0F)
60
61enum lm3530_mode {
62 LM3530_BL_MODE_MANUAL = 0, /* "man" */
63 LM3530_BL_MODE_ALS, /* "als" */
64 LM3530_BL_MODE_PWM, /* "pwm" */
65};
66
67/* ALS input select */
68enum lm3530_als_mode {
69 LM3530_INPUT_AVRG = 0, /* ALS1 and ALS2 input average */
70 LM3530_INPUT_ALS1, /* ALS1 Input */
71 LM3530_INPUT_ALS2, /* ALS2 Input */
72 LM3530_INPUT_CEIL, /* Max of ALS1 and ALS2 */
73};
74
75/**
76 * struct lm3530_platform_data
77 * @mode: mode of operation i.e. Manual, ALS or PWM
78 * @als_input_mode: select source of ALS input - ALS1/2 or average
79 * @max_current: full scale LED current
80 * @pwm_pol_hi: PWM input polarity - active high/active low
81 * @als_avrg_time: ALS input averaging time
82 * @brt_ramp_law: brightness mapping mode - exponential/linear
83 * @brt_ramp_fall: rate of fall of led current
84 * @brt_ramp_rise: rate of rise of led current
85 * @als1_resistor_sel: internal resistance from ALS1 input to ground
86 * @als2_resistor_sel: internal resistance from ALS2 input to ground
87 * @brt_val: brightness value (0-255)
88 */
89struct lm3530_platform_data {
90 enum lm3530_mode mode;
91 enum lm3530_als_mode als_input_mode;
92
93 u8 max_current;
94 bool pwm_pol_hi;
95 u8 als_avrg_time;
96
97 bool brt_ramp_law;
98 u8 brt_ramp_fall;
99 u8 brt_ramp_rise;
100
101 u8 als1_resistor_sel;
102 u8 als2_resistor_sel;
103
104 u8 brt_val;
105};
106
107#endif /* _LINUX_LED_LM3530_H__ */
diff --git a/include/linux/leds-lp5521.h b/include/linux/leds-lp5521.h
new file mode 100644
index 000000000000..fd548d2a8775
--- /dev/null
+++ b/include/linux/leds-lp5521.h
@@ -0,0 +1,48 @@
1/*
2 * LP5521 LED chip driver.
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contact: Samu Onkalo <samu.p.onkalo@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22
23#ifndef __LINUX_LP5521_H
24#define __LINUX_LP5521_H
25
26/* See Documentation/leds/leds-lp5521.txt */
27
28struct lp5521_led_config {
29 u8 chan_nr;
30 u8 led_current; /* mA x10, 0 if led is not connected */
31 u8 max_current;
32};
33
34#define LP5521_CLOCK_AUTO 0
35#define LP5521_CLOCK_INT 1
36#define LP5521_CLOCK_EXT 2
37
38struct lp5521_platform_data {
39 struct lp5521_led_config *led_config;
40 u8 num_channels;
41 u8 clock_mode;
42 int (*setup_resources)(void);
43 void (*release_resources)(void);
44 void (*enable)(bool state);
45 const char *label;
46};
47
48#endif /* __LINUX_LP5521_H */
diff --git a/include/linux/spi/wl12xx.h b/include/linux/leds-lp5523.h
index a223ecbc71ef..2694289babd0 100644
--- a/include/linux/spi/wl12xx.h
+++ b/include/linux/leds-lp5523.h
@@ -1,9 +1,9 @@
1/* 1/*
2 * This file is part of wl12xx 2 * LP5523 LED Driver
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2010 Nokia Corporation
5 * 5 *
6 * Contact: Kalle Valo <kalle.valo@nokia.com> 6 * Contact: Samu Onkalo <samu.p.onkalo@nokia.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 9 * modify it under the terms of the GNU General Public License
@@ -18,17 +18,31 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA 20 * 02110-1301 USA
21 *
22 */ 21 */
23 22
24#ifndef _LINUX_SPI_WL12XX_H 23#ifndef __LINUX_LP5523_H
25#define _LINUX_SPI_WL12XX_H 24#define __LINUX_LP5523_H
25
26/* See Documentation/leds/leds-lp5523.txt */
27
28struct lp5523_led_config {
29 u8 chan_nr;
30 u8 led_current; /* mA x10, 0 if led is not connected */
31 u8 max_current;
32};
33
34#define LP5523_CLOCK_AUTO 0
35#define LP5523_CLOCK_INT 1
36#define LP5523_CLOCK_EXT 2
26 37
27struct wl12xx_platform_data { 38struct lp5523_platform_data {
28 void (*set_power)(bool enable); 39 struct lp5523_led_config *led_config;
29 /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */ 40 u8 num_channels;
30 int irq; 41 u8 clock_mode;
31 bool use_eeprom; 42 int (*setup_resources)(void);
43 void (*release_resources)(void);
44 void (*enable)(bool state);
45 const char *label;
32}; 46};
33 47
34#endif 48#endif /* __LINUX_LP5523_H */
diff --git a/include/linux/leds-pca9532.h b/include/linux/leds-pca9532.h
index f158eb1149aa..b8d6fffed4d8 100644
--- a/include/linux/leds-pca9532.h
+++ b/include/linux/leds-pca9532.h
@@ -25,7 +25,7 @@ enum pca9532_state {
25}; 25};
26 26
27enum pca9532_type { PCA9532_TYPE_NONE, PCA9532_TYPE_LED, 27enum pca9532_type { PCA9532_TYPE_NONE, PCA9532_TYPE_LED,
28 PCA9532_TYPE_N2100_BEEP }; 28 PCA9532_TYPE_N2100_BEEP, PCA9532_TYPE_GPIO };
29 29
30struct pca9532_led { 30struct pca9532_led {
31 u8 id; 31 u8 id;
@@ -41,6 +41,7 @@ struct pca9532_platform_data {
41 struct pca9532_led leds[16]; 41 struct pca9532_led leds[16];
42 u8 pwm[2]; 42 u8 pwm[2];
43 u8 psc[2]; 43 u8 psc[2];
44 int gpio_base;
44}; 45};
45 46
46#endif /* __LINUX_PCA9532_H */ 47#endif /* __LINUX_PCA9532_H */
diff --git a/include/linux/leds-regulator.h b/include/linux/leds-regulator.h
index 5a8eb389aab8..e2337a8c90b0 100644
--- a/include/linux/leds-regulator.h
+++ b/include/linux/leds-regulator.h
@@ -16,7 +16,7 @@
16 * Use "vled" as supply id when declaring the regulator consumer: 16 * Use "vled" as supply id when declaring the regulator consumer:
17 * 17 *
18 * static struct regulator_consumer_supply pcap_regulator_VVIB_consumers [] = { 18 * static struct regulator_consumer_supply pcap_regulator_VVIB_consumers [] = {
19 * { .dev_name = "leds-regulator.0", supply = "vled" }, 19 * { .dev_name = "leds-regulator.0", .supply = "vled" },
20 * }; 20 * };
21 * 21 *
22 * If you have several regulator driven LEDs, you can append a numerical id to 22 * If you have several regulator driven LEDs, you can append a numerical id to
diff --git a/include/linux/leds.h b/include/linux/leds.h
index ba6986a11663..5884def15a24 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -15,6 +15,7 @@
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/rwsem.h> 17#include <linux/rwsem.h>
18#include <linux/timer.h>
18 19
19struct device; 20struct device;
20/* 21/*
@@ -45,10 +46,14 @@ struct led_classdev {
45 /* Get LED brightness level */ 46 /* Get LED brightness level */
46 enum led_brightness (*brightness_get)(struct led_classdev *led_cdev); 47 enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
47 48
48 /* Activate hardware accelerated blink, delays are in 49 /*
49 * miliseconds and if none is provided then a sensible default 50 * Activate hardware accelerated blink, delays are in milliseconds
50 * should be chosen. The call can adjust the timings if it can't 51 * and if both are zero then a sensible default should be chosen.
51 * match the values specified exactly. */ 52 * The call should adjust the timings in that case and if it can't
53 * match the values specified exactly.
54 * Deactivate blinking again when the brightness is set to a fixed
55 * value via the brightness_set() callback.
56 */
52 int (*blink_set)(struct led_classdev *led_cdev, 57 int (*blink_set)(struct led_classdev *led_cdev,
53 unsigned long *delay_on, 58 unsigned long *delay_on,
54 unsigned long *delay_off); 59 unsigned long *delay_off);
@@ -57,6 +62,10 @@ struct led_classdev {
57 struct list_head node; /* LED Device list */ 62 struct list_head node; /* LED Device list */
58 const char *default_trigger; /* Trigger to use */ 63 const char *default_trigger; /* Trigger to use */
59 64
65 unsigned long blink_delay_on, blink_delay_off;
66 struct timer_list blink_timer;
67 int blink_brightness;
68
60#ifdef CONFIG_LEDS_TRIGGERS 69#ifdef CONFIG_LEDS_TRIGGERS
61 /* Protects the trigger data below */ 70 /* Protects the trigger data below */
62 struct rw_semaphore trigger_lock; 71 struct rw_semaphore trigger_lock;
@@ -73,6 +82,36 @@ extern void led_classdev_unregister(struct led_classdev *led_cdev);
73extern void led_classdev_suspend(struct led_classdev *led_cdev); 82extern void led_classdev_suspend(struct led_classdev *led_cdev);
74extern void led_classdev_resume(struct led_classdev *led_cdev); 83extern void led_classdev_resume(struct led_classdev *led_cdev);
75 84
85/**
86 * led_blink_set - set blinking with software fallback
87 * @led_cdev: the LED to start blinking
88 * @delay_on: the time it should be on (in ms)
89 * @delay_off: the time it should ble off (in ms)
90 *
91 * This function makes the LED blink, attempting to use the
92 * hardware acceleration if possible, but falling back to
93 * software blinking if there is no hardware blinking or if
94 * the LED refuses the passed values.
95 *
96 * Note that if software blinking is active, simply calling
97 * led_cdev->brightness_set() will not stop the blinking,
98 * use led_classdev_brightness_set() instead.
99 */
100extern void led_blink_set(struct led_classdev *led_cdev,
101 unsigned long *delay_on,
102 unsigned long *delay_off);
103/**
104 * led_brightness_set - set LED brightness
105 * @led_cdev: the LED to set
106 * @brightness: the brightness to set it to
107 *
108 * Set an LED's brightness, and, if necessary, cancel the
109 * software blink timer that implements blinking when the
110 * hardware doesn't.
111 */
112extern void led_brightness_set(struct led_classdev *led_cdev,
113 enum led_brightness brightness);
114
76/* 115/*
77 * LED Triggers 116 * LED Triggers
78 */ 117 */
@@ -106,6 +145,9 @@ extern void led_trigger_register_simple(const char *name,
106extern void led_trigger_unregister_simple(struct led_trigger *trigger); 145extern void led_trigger_unregister_simple(struct led_trigger *trigger);
107extern void led_trigger_event(struct led_trigger *trigger, 146extern void led_trigger_event(struct led_trigger *trigger,
108 enum led_brightness event); 147 enum led_brightness event);
148extern void led_trigger_blink(struct led_trigger *trigger,
149 unsigned long *delay_on,
150 unsigned long *delay_off);
109 151
110#else 152#else
111 153
@@ -155,15 +197,17 @@ struct gpio_led {
155 197
156struct gpio_led_platform_data { 198struct gpio_led_platform_data {
157 int num_leds; 199 int num_leds;
158 struct gpio_led *leds; 200 const struct gpio_led *leds;
159 201
160#define GPIO_LED_NO_BLINK_LOW 0 /* No blink GPIO state low */ 202#define GPIO_LED_NO_BLINK_LOW 0 /* No blink GPIO state low */
161#define GPIO_LED_NO_BLINK_HIGH 1 /* No blink GPIO state high */ 203#define GPIO_LED_NO_BLINK_HIGH 1 /* No blink GPIO state high */
162#define GPIO_LED_BLINK 2 /* Plase, blink */ 204#define GPIO_LED_BLINK 2 /* Please, blink */
163 int (*gpio_blink_set)(unsigned gpio, int state, 205 int (*gpio_blink_set)(unsigned gpio, int state,
164 unsigned long *delay_on, 206 unsigned long *delay_on,
165 unsigned long *delay_off); 207 unsigned long *delay_off);
166}; 208};
167 209
210struct platform_device *gpio_led_register_device(
211 int id, const struct gpio_led_platform_data *pdata);
168 212
169#endif /* __LINUX_LEDS_H_INCLUDED */ 213#endif /* __LINUX_LEDS_H_INCLUDED */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 45fb2967b66d..5a9926b34072 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -37,6 +37,7 @@
37#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
38#include <linux/acpi.h> 38#include <linux/acpi.h>
39#include <linux/cdrom.h> 39#include <linux/cdrom.h>
40#include <linux/sched.h>
40 41
41/* 42/*
42 * Define if arch has non-standard setup. This is a _PCI_ standard 43 * Define if arch has non-standard setup. This is a _PCI_ standard
@@ -136,8 +137,6 @@ enum {
136 ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */ 137 ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */
137 ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ 138 ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */
138 ATA_DFLAG_AN = (1 << 7), /* AN configured */ 139 ATA_DFLAG_AN = (1 << 7), /* AN configured */
139 ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */
140 ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */
141 ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */ 140 ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */
142 ATA_DFLAG_CFG_MASK = (1 << 12) - 1, 141 ATA_DFLAG_CFG_MASK = (1 << 12) - 1,
143 142
@@ -172,15 +171,12 @@ enum {
172 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ 171 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */
173 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ 172 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */
174 ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */ 173 ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */
174 ATA_LFLAG_NO_LPM = (1 << 8), /* disable LPM on this link */
175 175
176 /* struct ata_port flags */ 176 /* struct ata_port flags */
177 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ 177 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
178 /* (doesn't imply presence) */ 178 /* (doesn't imply presence) */
179 ATA_FLAG_SATA = (1 << 1), 179 ATA_FLAG_SATA = (1 << 1),
180 ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */
181 ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */
182 ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */
183 ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */
184 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */ 180 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
185 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ 181 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */
186 ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ 182 ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */
@@ -196,11 +192,11 @@ enum {
196 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ 192 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */
197 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 193 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
198 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 194 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
199 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */
200 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure 195 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure
201 * management */ 196 * management */
202 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity 197 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
203 * led */ 198 * led */
199 ATA_FLAG_NO_DIPM = (1 << 23), /* host not happy with DIPM */
204 200
205 /* bits 24:31 of ap->flags are reserved for LLD specific flags */ 201 /* bits 24:31 of ap->flags are reserved for LLD specific flags */
206 202
@@ -324,12 +320,11 @@ enum {
324 ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */ 320 ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */
325 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 321 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
326 ATA_EH_ENABLE_LINK = (1 << 3), 322 ATA_EH_ENABLE_LINK = (1 << 3),
327 ATA_EH_LPM = (1 << 4), /* link power management action */
328 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */ 323 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */
329 324
330 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK, 325 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK,
331 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET | 326 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET |
332 ATA_EH_ENABLE_LINK | ATA_EH_LPM, 327 ATA_EH_ENABLE_LINK,
333 328
334 /* ata_eh_info->flags */ 329 /* ata_eh_info->flags */
335 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 330 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -341,7 +336,7 @@ enum {
341 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */ 336 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
342 ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */ 337 ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */
343 ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */ 338 ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */
344 ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */ 339 ATA_EHI_POST_SETMODE = (1 << 20), /* revalidating after setmode */
345 340
346 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, 341 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
347 342
@@ -368,7 +363,7 @@ enum {
368 ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6, 363 ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6,
369 364
370 /* Horkage types. May be set by libata or controller on drives 365 /* Horkage types. May be set by libata or controller on drives
371 (some horkage may be drive/controller pair dependant */ 366 (some horkage may be drive/controller pair dependent */
372 367
373 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */ 368 ATA_HORKAGE_DIAGNOSTIC = (1 << 0), /* Failed boot diag */
374 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */ 369 ATA_HORKAGE_NODMA = (1 << 1), /* DMA problems */
@@ -377,7 +372,6 @@ enum {
377 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ 372 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */
378 ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */ 373 ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */
379 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ 374 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */
380 ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */
381 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ 375 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */
382 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */ 376 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */
383 ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */ 377 ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */
@@ -464,6 +458,22 @@ enum ata_completion_errors {
464 AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */ 458 AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */
465}; 459};
466 460
461/*
462 * Link power management policy: If you alter this, you also need to
463 * alter libata-scsi.c (for the ascii descriptions)
464 */
465enum ata_lpm_policy {
466 ATA_LPM_UNKNOWN,
467 ATA_LPM_MAX_POWER,
468 ATA_LPM_MED_POWER,
469 ATA_LPM_MIN_POWER,
470};
471
472enum ata_lpm_hints {
473 ATA_LPM_EMPTY = (1 << 0), /* port empty/probing */
474 ATA_LPM_HIPM = (1 << 1), /* may use HIPM */
475};
476
467/* forward declarations */ 477/* forward declarations */
468struct scsi_device; 478struct scsi_device;
469struct ata_port_operations; 479struct ata_port_operations;
@@ -478,16 +488,6 @@ typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes,
478 unsigned long deadline); 488 unsigned long deadline);
479typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); 489typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes);
480 490
481/*
482 * host pm policy: If you alter this, you also need to alter libata-scsi.c
483 * (for the ascii descriptions)
484 */
485enum link_pm {
486 NOT_AVAILABLE,
487 MIN_POWER,
488 MAX_PERFORMANCE,
489 MEDIUM_POWER,
490};
491extern struct device_attribute dev_attr_link_power_management_policy; 491extern struct device_attribute dev_attr_link_power_management_policy;
492extern struct device_attribute dev_attr_unload_heads; 492extern struct device_attribute dev_attr_unload_heads;
493extern struct device_attribute dev_attr_em_message_type; 493extern struct device_attribute dev_attr_em_message_type;
@@ -530,6 +530,10 @@ struct ata_host {
530 void *private_data; 530 void *private_data;
531 struct ata_port_operations *ops; 531 struct ata_port_operations *ops;
532 unsigned long flags; 532 unsigned long flags;
533
534 struct mutex eh_mutex;
535 struct task_struct *eh_owner;
536
533#ifdef CONFIG_ATA_ACPI 537#ifdef CONFIG_ATA_ACPI
534 acpi_handle acpi_handle; 538 acpi_handle acpi_handle;
535#endif 539#endif
@@ -560,13 +564,13 @@ struct ata_queued_cmd {
560 unsigned int extrabytes; 564 unsigned int extrabytes;
561 unsigned int curbytes; 565 unsigned int curbytes;
562 566
563 struct scatterlist *cursg;
564 unsigned int cursg_ofs;
565
566 struct scatterlist sgent; 567 struct scatterlist sgent;
567 568
568 struct scatterlist *sg; 569 struct scatterlist *sg;
569 570
571 struct scatterlist *cursg;
572 unsigned int cursg_ofs;
573
570 unsigned int err_mask; 574 unsigned int err_mask;
571 struct ata_taskfile result_tf; 575 struct ata_taskfile result_tf;
572 ata_qc_cb_t complete_fn; 576 ata_qc_cb_t complete_fn;
@@ -604,6 +608,7 @@ struct ata_device {
604 union acpi_object *gtf_cache; 608 union acpi_object *gtf_cache;
605 unsigned int gtf_filter; 609 unsigned int gtf_filter;
606#endif 610#endif
611 struct device tdev;
607 /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */ 612 /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */
608 u64 n_sectors; /* size of device, if ATA */ 613 u64 n_sectors; /* size of device, if ATA */
609 u64 n_native_sectors; /* native size, if ATA */ 614 u64 n_native_sectors; /* native size, if ATA */
@@ -690,6 +695,7 @@ struct ata_link {
690 struct ata_port *ap; 695 struct ata_port *ap;
691 int pmp; /* port multiplier port # */ 696 int pmp; /* port multiplier port # */
692 697
698 struct device tdev;
693 unsigned int active_tag; /* active tag on this link */ 699 unsigned int active_tag; /* active tag on this link */
694 u32 sactive; /* active NCQ commands */ 700 u32 sactive; /* active NCQ commands */
695 701
@@ -699,6 +705,7 @@ struct ata_link {
699 unsigned int hw_sata_spd_limit; 705 unsigned int hw_sata_spd_limit;
700 unsigned int sata_spd_limit; 706 unsigned int sata_spd_limit;
701 unsigned int sata_spd; /* current SATA PHY speed */ 707 unsigned int sata_spd; /* current SATA PHY speed */
708 enum ata_lpm_policy lpm_policy;
702 709
703 /* record runtime error info, protected by host_set lock */ 710 /* record runtime error info, protected by host_set lock */
704 struct ata_eh_info eh_info; 711 struct ata_eh_info eh_info;
@@ -707,6 +714,8 @@ struct ata_link {
707 714
708 struct ata_device device[ATA_MAX_DEVICES]; 715 struct ata_device device[ATA_MAX_DEVICES];
709}; 716};
717#define ATA_LINK_CLEAR_BEGIN offsetof(struct ata_link, active_tag)
718#define ATA_LINK_CLEAR_END offsetof(struct ata_link, device[0])
710 719
711struct ata_port { 720struct ata_port {
712 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ 721 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */
@@ -752,6 +761,7 @@ struct ata_port {
752 struct ata_port_stats stats; 761 struct ata_port_stats stats;
753 struct ata_host *host; 762 struct ata_host *host;
754 struct device *dev; 763 struct device *dev;
764 struct device tdev;
755 765
756 struct mutex scsi_scan_mutex; 766 struct mutex scsi_scan_mutex;
757 struct delayed_work hotplug_task; 767 struct delayed_work hotplug_task;
@@ -767,7 +777,7 @@ struct ata_port {
767 777
768 pm_message_t pm_mesg; 778 pm_message_t pm_mesg;
769 int *pm_result; 779 int *pm_result;
770 enum link_pm pm_policy; 780 enum ata_lpm_policy target_lpm_policy;
771 781
772 struct timer_list fastdrain_timer; 782 struct timer_list fastdrain_timer;
773 unsigned long fastdrain_cnt; 783 unsigned long fastdrain_cnt;
@@ -833,8 +843,8 @@ struct ata_port_operations {
833 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val); 843 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
834 void (*pmp_attach)(struct ata_port *ap); 844 void (*pmp_attach)(struct ata_port *ap);
835 void (*pmp_detach)(struct ata_port *ap); 845 void (*pmp_detach)(struct ata_port *ap);
836 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 846 int (*set_lpm)(struct ata_link *link, enum ata_lpm_policy policy,
837 void (*disable_pm)(struct ata_port *ap); 847 unsigned hints);
838 848
839 /* 849 /*
840 * Start, stop, suspend and resume 850 * Start, stop, suspend and resume
@@ -946,6 +956,8 @@ extern int sata_link_debounce(struct ata_link *link,
946 const unsigned long *params, unsigned long deadline); 956 const unsigned long *params, unsigned long deadline);
947extern int sata_link_resume(struct ata_link *link, const unsigned long *params, 957extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
948 unsigned long deadline); 958 unsigned long deadline);
959extern int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
960 bool spm_wakeup);
949extern int sata_link_hardreset(struct ata_link *link, 961extern int sata_link_hardreset(struct ata_link *link,
950 const unsigned long *timing, unsigned long deadline, 962 const unsigned long *timing, unsigned long deadline,
951 bool *online, int (*check_ready)(struct ata_link *)); 963 bool *online, int (*check_ready)(struct ata_link *));
@@ -968,7 +980,7 @@ extern void ata_host_init(struct ata_host *, struct device *,
968 unsigned long, struct ata_port_operations *); 980 unsigned long, struct ata_port_operations *);
969extern int ata_scsi_detect(struct scsi_host_template *sht); 981extern int ata_scsi_detect(struct scsi_host_template *sht);
970extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 982extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
971extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 983extern int ata_scsi_queuecmd(struct Scsi_Host *h, struct scsi_cmnd *cmd);
972extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev, 984extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,
973 int cmd, void __user *arg); 985 int cmd, void __user *arg);
974extern void ata_sas_port_destroy(struct ata_port *); 986extern void ata_sas_port_destroy(struct ata_port *);
@@ -978,8 +990,7 @@ extern int ata_sas_port_init(struct ata_port *);
978extern int ata_sas_port_start(struct ata_port *ap); 990extern int ata_sas_port_start(struct ata_port *ap);
979extern void ata_sas_port_stop(struct ata_port *ap); 991extern void ata_sas_port_stop(struct ata_port *ap);
980extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); 992extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
981extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 993extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap);
982 struct ata_port *ap);
983extern int sata_scr_valid(struct ata_link *link); 994extern int sata_scr_valid(struct ata_link *link);
984extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 995extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
985extern int sata_scr_write(struct ata_link *link, int reg, u32 val); 996extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
@@ -991,8 +1002,9 @@ extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
991extern void ata_host_resume(struct ata_host *host); 1002extern void ata_host_resume(struct ata_host *host);
992#endif 1003#endif
993extern int ata_ratelimit(void); 1004extern int ata_ratelimit(void);
994extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 1005extern void ata_msleep(struct ata_port *ap, unsigned int msecs);
995 unsigned long interval, unsigned long timeout); 1006extern u32 ata_wait_register(struct ata_port *ap, void __iomem *reg, u32 mask,
1007 u32 val, unsigned long interval, unsigned long timeout);
996extern int atapi_cmd_type(u8 opcode); 1008extern int atapi_cmd_type(u8 opcode);
997extern void ata_tf_to_fis(const struct ata_taskfile *tf, 1009extern void ata_tf_to_fis(const struct ata_taskfile *tf,
998 u8 pmp, int is_cmd, u8 *fis); 1010 u8 pmp, int is_cmd, u8 *fis);
@@ -1021,8 +1033,7 @@ extern unsigned int ata_do_dev_read_id(struct ata_device *dev,
1021 struct ata_taskfile *tf, u16 *id); 1033 struct ata_taskfile *tf, u16 *id);
1022extern void ata_qc_complete(struct ata_queued_cmd *qc); 1034extern void ata_qc_complete(struct ata_queued_cmd *qc);
1023extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active); 1035extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active);
1024extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, 1036extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd);
1025 void (*done)(struct scsi_cmnd *));
1026extern int ata_std_bios_param(struct scsi_device *sdev, 1037extern int ata_std_bios_param(struct scsi_device *sdev,
1027 struct block_device *bdev, 1038 struct block_device *bdev,
1028 sector_t capacity, int geom[]); 1039 sector_t capacity, int geom[]);
@@ -1033,6 +1044,8 @@ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
1033 int queue_depth, int reason); 1044 int queue_depth, int reason);
1034extern struct ata_device *ata_dev_pair(struct ata_device *adev); 1045extern struct ata_device *ata_dev_pair(struct ata_device *adev);
1035extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 1046extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
1047extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap);
1048extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q);
1036 1049
1037extern int ata_cable_40wire(struct ata_port *ap); 1050extern int ata_cable_40wire(struct ata_port *ap);
1038extern int ata_cable_80wire(struct ata_port *ap); 1051extern int ata_cable_80wire(struct ata_port *ap);
@@ -1138,6 +1151,7 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
1138 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 1151 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
1139 ata_postreset_fn_t postreset); 1152 ata_postreset_fn_t postreset);
1140extern void ata_std_error_handler(struct ata_port *ap); 1153extern void ata_std_error_handler(struct ata_port *ap);
1154extern int ata_link_nr_enabled(struct ata_link *link);
1141 1155
1142/* 1156/*
1143 * Base operations to inherit from and initializers for sht 1157 * Base operations to inherit from and initializers for sht
@@ -1596,6 +1610,9 @@ extern void ata_sff_irq_on(struct ata_port *ap);
1596extern void ata_sff_irq_clear(struct ata_port *ap); 1610extern void ata_sff_irq_clear(struct ata_port *ap);
1597extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, 1611extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1598 u8 status, int in_wq); 1612 u8 status, int in_wq);
1613extern void ata_sff_queue_work(struct work_struct *work);
1614extern void ata_sff_queue_delayed_work(struct delayed_work *dwork,
1615 unsigned long delay);
1599extern void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay); 1616extern void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay);
1600extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc); 1617extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
1601extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc); 1618extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index 7135ebc8428c..3f46aedea42f 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -14,10 +14,6 @@
14#define asmlinkage CPP_ASMLINKAGE 14#define asmlinkage CPP_ASMLINKAGE
15#endif 15#endif
16 16
17#ifndef asmregparm
18# define asmregparm
19#endif
20
21#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE) 17#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
22#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE) 18#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
23 19
diff --git a/include/linux/lis3lv02d.h b/include/linux/lis3lv02d.h
index 0e8a346424bb..d4292c8431e0 100644
--- a/include/linux/lis3lv02d.h
+++ b/include/linux/lis3lv02d.h
@@ -1,6 +1,52 @@
1#ifndef __LIS3LV02D_H_ 1#ifndef __LIS3LV02D_H_
2#define __LIS3LV02D_H_ 2#define __LIS3LV02D_H_
3 3
4/**
5 * struct lis3lv02d_platform_data - lis3 chip family platform data
6 * @click_flags: Click detection unit configuration
7 * @click_thresh_x: Click detection unit x axis threshold
8 * @click_thresh_y: Click detection unit y axis threshold
9 * @click_thresh_z: Click detection unit z axis threshold
10 * @click_time_limit: Click detection unit time parameter
11 * @click_latency: Click detection unit latency parameter
12 * @click_window: Click detection unit window parameter
13 * @irq_cfg: On chip irq source and type configuration (click /
14 * data available / wake up, open drain, polarity)
15 * @irq_flags1: Additional irq triggering flags for irq channel 0
16 * @irq_flags2: Additional irq triggering flags for irq channel 1
17 * @duration1: Wake up unit 1 duration parameter
18 * @duration2: Wake up unit 2 duration parameter
19 * @wakeup_flags: Wake up unit 1 flags
20 * @wakeup_thresh: Wake up unit 1 threshold value
21 * @wakeup_flags2: Wake up unit 2 flags
22 * @wakeup_thresh2: Wake up unit 2 threshold value
23 * @hipass_ctrl: High pass filter control (enable / disable, cut off
24 * frequency)
25 * @axis_x: Sensor orientation remapping for x-axis
26 * @axis_y: Sensor orientation remapping for y-axis
27 * @axis_z: Sensor orientation remapping for z-axis
28 * @driver_features: Enable bits for different features. Disabled by default
29 * @default_rate: Default sampling rate. 0 means reset default
30 * @setup_resources: Interrupt line setup call back function
31 * @release_resources: Interrupt line release call back function
32 * @st_min_limits[3]: Selftest acceptance minimum values
33 * @st_max_limits[3]: Selftest acceptance maximum values
34 * @irq2: Irq line 2 number
35 *
36 * Platform data is used to setup the sensor chip. Meaning of the different
37 * chip features can be found from the data sheet. It is publicly available
38 * at www.st.com web pages. Currently the platform data is used
39 * only for the 8 bit device. The 8 bit device has two wake up / free fall
40 * detection units and click detection unit. There are plenty of ways to
41 * configure the chip which makes is quite hard to explain deeper meaning of
42 * the fields here. Behaviour of the detection blocks varies heavily depending
43 * on the configuration. For example, interrupt detection block can use high
44 * pass filtered data which makes it react to the changes in the acceleration.
45 * Irq_flags can be used to enable interrupt detection on the both edges.
46 * With proper chip configuration this produces interrupt when some trigger
47 * starts and when it goes away.
48 */
49
4struct lis3lv02d_platform_data { 50struct lis3lv02d_platform_data {
5 /* please note: the 'click' feature is only supported for 51 /* please note: the 'click' feature is only supported for
6 * LIS[32]02DL variants of the chip and will be ignored for 52 * LIS[32]02DL variants of the chip and will be ignored for
@@ -36,7 +82,10 @@ struct lis3lv02d_platform_data {
36#define LIS3_IRQ_OPEN_DRAIN (1 << 6) 82#define LIS3_IRQ_OPEN_DRAIN (1 << 6)
37#define LIS3_IRQ_ACTIVE_LOW (1 << 7) 83#define LIS3_IRQ_ACTIVE_LOW (1 << 7)
38 unsigned char irq_cfg; 84 unsigned char irq_cfg;
39 85 unsigned char irq_flags1; /* Additional irq edge / level flags */
86 unsigned char irq_flags2; /* Additional irq edge / level flags */
87 unsigned char duration1;
88 unsigned char duration2;
40#define LIS3_WAKEUP_X_LO (1 << 0) 89#define LIS3_WAKEUP_X_LO (1 << 0)
41#define LIS3_WAKEUP_X_HI (1 << 1) 90#define LIS3_WAKEUP_X_HI (1 << 1)
42#define LIS3_WAKEUP_Y_LO (1 << 2) 91#define LIS3_WAKEUP_Y_LO (1 << 2)
@@ -64,6 +113,10 @@ struct lis3lv02d_platform_data {
64 s8 axis_x; 113 s8 axis_x;
65 s8 axis_y; 114 s8 axis_y;
66 s8 axis_z; 115 s8 axis_z;
116#define LIS3_USE_REGULATOR_CTRL 0x01
117#define LIS3_USE_BLOCK_READ 0x02
118 u16 driver_features;
119 int default_rate;
67 int (*setup_resources)(void); 120 int (*setup_resources)(void);
68 int (*release_resources)(void); 121 int (*release_resources)(void);
69 /* Limits for selftest are specified in chip data sheet */ 122 /* Limits for selftest are specified in chip data sheet */
diff --git a/include/linux/list.h b/include/linux/list.h
index d167b5d7c0ac..cc6d2aa6b415 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -4,8 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/stddef.h> 5#include <linux/stddef.h>
6#include <linux/poison.h> 6#include <linux/poison.h>
7#include <linux/prefetch.h> 7#include <linux/const.h>
8#include <asm/system.h>
9 8
10/* 9/*
11 * Simple doubly linked list implementation. 10 * Simple doubly linked list implementation.
@@ -97,6 +96,11 @@ static inline void __list_del(struct list_head * prev, struct list_head * next)
97 * in an undefined state. 96 * in an undefined state.
98 */ 97 */
99#ifndef CONFIG_DEBUG_LIST 98#ifndef CONFIG_DEBUG_LIST
99static inline void __list_del_entry(struct list_head *entry)
100{
101 __list_del(entry->prev, entry->next);
102}
103
100static inline void list_del(struct list_head *entry) 104static inline void list_del(struct list_head *entry)
101{ 105{
102 __list_del(entry->prev, entry->next); 106 __list_del(entry->prev, entry->next);
@@ -104,6 +108,7 @@ static inline void list_del(struct list_head *entry)
104 entry->prev = LIST_POISON2; 108 entry->prev = LIST_POISON2;
105} 109}
106#else 110#else
111extern void __list_del_entry(struct list_head *entry);
107extern void list_del(struct list_head *entry); 112extern void list_del(struct list_head *entry);
108#endif 113#endif
109 114
@@ -136,7 +141,7 @@ static inline void list_replace_init(struct list_head *old,
136 */ 141 */
137static inline void list_del_init(struct list_head *entry) 142static inline void list_del_init(struct list_head *entry)
138{ 143{
139 __list_del(entry->prev, entry->next); 144 __list_del_entry(entry);
140 INIT_LIST_HEAD(entry); 145 INIT_LIST_HEAD(entry);
141} 146}
142 147
@@ -147,7 +152,7 @@ static inline void list_del_init(struct list_head *entry)
147 */ 152 */
148static inline void list_move(struct list_head *list, struct list_head *head) 153static inline void list_move(struct list_head *list, struct list_head *head)
149{ 154{
150 __list_del(list->prev, list->next); 155 __list_del_entry(list);
151 list_add(list, head); 156 list_add(list, head);
152} 157}
153 158
@@ -159,7 +164,7 @@ static inline void list_move(struct list_head *list, struct list_head *head)
159static inline void list_move_tail(struct list_head *list, 164static inline void list_move_tail(struct list_head *list,
160 struct list_head *head) 165 struct list_head *head)
161{ 166{
162 __list_del(list->prev, list->next); 167 __list_del_entry(list);
163 list_add_tail(list, head); 168 list_add_tail(list, head);
164} 169}
165 170
@@ -362,18 +367,15 @@ static inline void list_splice_tail_init(struct list_head *list,
362 * @head: the head for your list. 367 * @head: the head for your list.
363 */ 368 */
364#define list_for_each(pos, head) \ 369#define list_for_each(pos, head) \
365 for (pos = (head)->next; prefetch(pos->next), pos != (head); \ 370 for (pos = (head)->next; pos != (head); pos = pos->next)
366 pos = pos->next)
367 371
368/** 372/**
369 * __list_for_each - iterate over a list 373 * __list_for_each - iterate over a list
370 * @pos: the &struct list_head to use as a loop cursor. 374 * @pos: the &struct list_head to use as a loop cursor.
371 * @head: the head for your list. 375 * @head: the head for your list.
372 * 376 *
373 * This variant differs from list_for_each() in that it's the 377 * This variant doesn't differ from list_for_each() any more.
374 * simplest possible list iteration code, no prefetching is done. 378 * We don't do prefetching in either case.
375 * Use this for code that knows the list to be very short (empty
376 * or 1 entry) most of the time.
377 */ 379 */
378#define __list_for_each(pos, head) \ 380#define __list_for_each(pos, head) \
379 for (pos = (head)->next; pos != (head); pos = pos->next) 381 for (pos = (head)->next; pos != (head); pos = pos->next)
@@ -384,8 +386,7 @@ static inline void list_splice_tail_init(struct list_head *list,
384 * @head: the head for your list. 386 * @head: the head for your list.
385 */ 387 */
386#define list_for_each_prev(pos, head) \ 388#define list_for_each_prev(pos, head) \
387 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ 389 for (pos = (head)->prev; pos != (head); pos = pos->prev)
388 pos = pos->prev)
389 390
390/** 391/**
391 * list_for_each_safe - iterate over a list safe against removal of list entry 392 * list_for_each_safe - iterate over a list safe against removal of list entry
@@ -405,7 +406,7 @@ static inline void list_splice_tail_init(struct list_head *list,
405 */ 406 */
406#define list_for_each_prev_safe(pos, n, head) \ 407#define list_for_each_prev_safe(pos, n, head) \
407 for (pos = (head)->prev, n = pos->prev; \ 408 for (pos = (head)->prev, n = pos->prev; \
408 prefetch(pos->prev), pos != (head); \ 409 pos != (head); \
409 pos = n, n = pos->prev) 410 pos = n, n = pos->prev)
410 411
411/** 412/**
@@ -416,7 +417,7 @@ static inline void list_splice_tail_init(struct list_head *list,
416 */ 417 */
417#define list_for_each_entry(pos, head, member) \ 418#define list_for_each_entry(pos, head, member) \
418 for (pos = list_entry((head)->next, typeof(*pos), member); \ 419 for (pos = list_entry((head)->next, typeof(*pos), member); \
419 prefetch(pos->member.next), &pos->member != (head); \ 420 &pos->member != (head); \
420 pos = list_entry(pos->member.next, typeof(*pos), member)) 421 pos = list_entry(pos->member.next, typeof(*pos), member))
421 422
422/** 423/**
@@ -427,7 +428,7 @@ static inline void list_splice_tail_init(struct list_head *list,
427 */ 428 */
428#define list_for_each_entry_reverse(pos, head, member) \ 429#define list_for_each_entry_reverse(pos, head, member) \
429 for (pos = list_entry((head)->prev, typeof(*pos), member); \ 430 for (pos = list_entry((head)->prev, typeof(*pos), member); \
430 prefetch(pos->member.prev), &pos->member != (head); \ 431 &pos->member != (head); \
431 pos = list_entry(pos->member.prev, typeof(*pos), member)) 432 pos = list_entry(pos->member.prev, typeof(*pos), member))
432 433
433/** 434/**
@@ -452,7 +453,7 @@ static inline void list_splice_tail_init(struct list_head *list,
452 */ 453 */
453#define list_for_each_entry_continue(pos, head, member) \ 454#define list_for_each_entry_continue(pos, head, member) \
454 for (pos = list_entry(pos->member.next, typeof(*pos), member); \ 455 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
455 prefetch(pos->member.next), &pos->member != (head); \ 456 &pos->member != (head); \
456 pos = list_entry(pos->member.next, typeof(*pos), member)) 457 pos = list_entry(pos->member.next, typeof(*pos), member))
457 458
458/** 459/**
@@ -466,7 +467,7 @@ static inline void list_splice_tail_init(struct list_head *list,
466 */ 467 */
467#define list_for_each_entry_continue_reverse(pos, head, member) \ 468#define list_for_each_entry_continue_reverse(pos, head, member) \
468 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ 469 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
469 prefetch(pos->member.prev), &pos->member != (head); \ 470 &pos->member != (head); \
470 pos = list_entry(pos->member.prev, typeof(*pos), member)) 471 pos = list_entry(pos->member.prev, typeof(*pos), member))
471 472
472/** 473/**
@@ -478,7 +479,7 @@ static inline void list_splice_tail_init(struct list_head *list,
478 * Iterate over list of given type, continuing from current position. 479 * Iterate over list of given type, continuing from current position.
479 */ 480 */
480#define list_for_each_entry_from(pos, head, member) \ 481#define list_for_each_entry_from(pos, head, member) \
481 for (; prefetch(pos->member.next), &pos->member != (head); \ 482 for (; &pos->member != (head); \
482 pos = list_entry(pos->member.next, typeof(*pos), member)) 483 pos = list_entry(pos->member.next, typeof(*pos), member))
483 484
484/** 485/**
@@ -637,6 +638,12 @@ static inline void hlist_add_after(struct hlist_node *n,
637 next->next->pprev = &next->next; 638 next->next->pprev = &next->next;
638} 639}
639 640
641/* after that we'll appear to be on some hlist and hlist_del will work */
642static inline void hlist_add_fake(struct hlist_node *n)
643{
644 n->pprev = &n->next;
645}
646
640/* 647/*
641 * Move a list from one list head to another. Fixup the pprev 648 * Move a list from one list head to another. Fixup the pprev
642 * reference of the first entry if it exists. 649 * reference of the first entry if it exists.
@@ -653,8 +660,7 @@ static inline void hlist_move_list(struct hlist_head *old,
653#define hlist_entry(ptr, type, member) container_of(ptr,type,member) 660#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
654 661
655#define hlist_for_each(pos, head) \ 662#define hlist_for_each(pos, head) \
656 for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ 663 for (pos = (head)->first; pos ; pos = pos->next)
657 pos = pos->next)
658 664
659#define hlist_for_each_safe(pos, n, head) \ 665#define hlist_for_each_safe(pos, n, head) \
660 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ 666 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
@@ -669,7 +675,7 @@ static inline void hlist_move_list(struct hlist_head *old,
669 */ 675 */
670#define hlist_for_each_entry(tpos, pos, head, member) \ 676#define hlist_for_each_entry(tpos, pos, head, member) \
671 for (pos = (head)->first; \ 677 for (pos = (head)->first; \
672 pos && ({ prefetch(pos->next); 1;}) && \ 678 pos && \
673 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 679 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
674 pos = pos->next) 680 pos = pos->next)
675 681
@@ -681,7 +687,7 @@ static inline void hlist_move_list(struct hlist_head *old,
681 */ 687 */
682#define hlist_for_each_entry_continue(tpos, pos, member) \ 688#define hlist_for_each_entry_continue(tpos, pos, member) \
683 for (pos = (pos)->next; \ 689 for (pos = (pos)->next; \
684 pos && ({ prefetch(pos->next); 1;}) && \ 690 pos && \
685 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 691 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
686 pos = pos->next) 692 pos = pos->next)
687 693
@@ -692,7 +698,7 @@ static inline void hlist_move_list(struct hlist_head *old,
692 * @member: the name of the hlist_node within the struct. 698 * @member: the name of the hlist_node within the struct.
693 */ 699 */
694#define hlist_for_each_entry_from(tpos, pos, member) \ 700#define hlist_for_each_entry_from(tpos, pos, member) \
695 for (; pos && ({ prefetch(pos->next); 1;}) && \ 701 for (; pos && \
696 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 702 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
697 pos = pos->next) 703 pos = pos->next)
698 704
diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
new file mode 100644
index 000000000000..31f9d75adc5b
--- /dev/null
+++ b/include/linux/list_bl.h
@@ -0,0 +1,156 @@
1#ifndef _LINUX_LIST_BL_H
2#define _LINUX_LIST_BL_H
3
4#include <linux/list.h>
5#include <linux/bit_spinlock.h>
6
7/*
8 * Special version of lists, where head of the list has a lock in the lowest
9 * bit. This is useful for scalable hash tables without increasing memory
10 * footprint overhead.
11 *
12 * For modification operations, the 0 bit of hlist_bl_head->first
13 * pointer must be set.
14 *
15 * With some small modifications, this can easily be adapted to store several
16 * arbitrary bits (not just a single lock bit), if the need arises to store
17 * some fast and compact auxiliary data.
18 */
19
20#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
21#define LIST_BL_LOCKMASK 1UL
22#else
23#define LIST_BL_LOCKMASK 0UL
24#endif
25
26#ifdef CONFIG_DEBUG_LIST
27#define LIST_BL_BUG_ON(x) BUG_ON(x)
28#else
29#define LIST_BL_BUG_ON(x)
30#endif
31
32
33struct hlist_bl_head {
34 struct hlist_bl_node *first;
35};
36
37struct hlist_bl_node {
38 struct hlist_bl_node *next, **pprev;
39};
40#define INIT_HLIST_BL_HEAD(ptr) \
41 ((ptr)->first = NULL)
42
43static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
44{
45 h->next = NULL;
46 h->pprev = NULL;
47}
48
49#define hlist_bl_entry(ptr, type, member) container_of(ptr,type,member)
50
51static inline int hlist_bl_unhashed(const struct hlist_bl_node *h)
52{
53 return !h->pprev;
54}
55
56static inline struct hlist_bl_node *hlist_bl_first(struct hlist_bl_head *h)
57{
58 return (struct hlist_bl_node *)
59 ((unsigned long)h->first & ~LIST_BL_LOCKMASK);
60}
61
62static inline void hlist_bl_set_first(struct hlist_bl_head *h,
63 struct hlist_bl_node *n)
64{
65 LIST_BL_BUG_ON((unsigned long)n & LIST_BL_LOCKMASK);
66 LIST_BL_BUG_ON(((unsigned long)h->first & LIST_BL_LOCKMASK) !=
67 LIST_BL_LOCKMASK);
68 h->first = (struct hlist_bl_node *)((unsigned long)n | LIST_BL_LOCKMASK);
69}
70
71static inline int hlist_bl_empty(const struct hlist_bl_head *h)
72{
73 return !((unsigned long)h->first & ~LIST_BL_LOCKMASK);
74}
75
76static inline void hlist_bl_add_head(struct hlist_bl_node *n,
77 struct hlist_bl_head *h)
78{
79 struct hlist_bl_node *first = hlist_bl_first(h);
80
81 n->next = first;
82 if (first)
83 first->pprev = &n->next;
84 n->pprev = &h->first;
85 hlist_bl_set_first(h, n);
86}
87
88static inline void __hlist_bl_del(struct hlist_bl_node *n)
89{
90 struct hlist_bl_node *next = n->next;
91 struct hlist_bl_node **pprev = n->pprev;
92
93 LIST_BL_BUG_ON((unsigned long)n & LIST_BL_LOCKMASK);
94
95 /* pprev may be `first`, so be careful not to lose the lock bit */
96 *pprev = (struct hlist_bl_node *)
97 ((unsigned long)next |
98 ((unsigned long)*pprev & LIST_BL_LOCKMASK));
99 if (next)
100 next->pprev = pprev;
101}
102
103static inline void hlist_bl_del(struct hlist_bl_node *n)
104{
105 __hlist_bl_del(n);
106 n->next = LIST_POISON1;
107 n->pprev = LIST_POISON2;
108}
109
110static inline void hlist_bl_del_init(struct hlist_bl_node *n)
111{
112 if (!hlist_bl_unhashed(n)) {
113 __hlist_bl_del(n);
114 INIT_HLIST_BL_NODE(n);
115 }
116}
117
118static inline void hlist_bl_lock(struct hlist_bl_head *b)
119{
120 bit_spin_lock(0, (unsigned long *)b);
121}
122
123static inline void hlist_bl_unlock(struct hlist_bl_head *b)
124{
125 __bit_spin_unlock(0, (unsigned long *)b);
126}
127
128/**
129 * hlist_bl_for_each_entry - iterate over list of given type
130 * @tpos: the type * to use as a loop cursor.
131 * @pos: the &struct hlist_node to use as a loop cursor.
132 * @head: the head for your list.
133 * @member: the name of the hlist_node within the struct.
134 *
135 */
136#define hlist_bl_for_each_entry(tpos, pos, head, member) \
137 for (pos = hlist_bl_first(head); \
138 pos && \
139 ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1;}); \
140 pos = pos->next)
141
142/**
143 * hlist_bl_for_each_entry_safe - iterate over list of given type safe against removal of list entry
144 * @tpos: the type * to use as a loop cursor.
145 * @pos: the &struct hlist_node to use as a loop cursor.
146 * @n: another &struct hlist_node to use as temporary storage
147 * @head: the head for your list.
148 * @member: the name of the hlist_node within the struct.
149 */
150#define hlist_bl_for_each_entry_safe(tpos, pos, n, head, member) \
151 for (pos = hlist_bl_first(head); \
152 pos && ({ n = pos->next; 1; }) && \
153 ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1;}); \
154 pos = n)
155
156#endif
diff --git a/include/linux/lockd/debug.h b/include/linux/lockd/debug.h
index 34b2b7f33c3b..257d3779f2ab 100644
--- a/include/linux/lockd/debug.h
+++ b/include/linux/lockd/debug.h
@@ -44,14 +44,4 @@
44#define NLMDBG_XDR 0x0100 44#define NLMDBG_XDR 0x0100
45#define NLMDBG_ALL 0x7fff 45#define NLMDBG_ALL 0x7fff
46 46
47
48/*
49 * Support for printing NLM cookies in dprintk()
50 */
51#ifdef RPC_DEBUG
52struct nlm_cookie;
53/* Call this function with the BKL held (it uses a static buffer) */
54extern const char *nlmdbg_cookie2a(const struct nlm_cookie *);
55#endif
56
57#endif /* LINUX_LOCKD_DEBUG_H */ 47#endif /* LINUX_LOCKD_DEBUG_H */
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index a34dea46b629..ff9abff55aa0 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -43,6 +43,7 @@ struct nlm_host {
43 struct sockaddr_storage h_addr; /* peer address */ 43 struct sockaddr_storage h_addr; /* peer address */
44 size_t h_addrlen; 44 size_t h_addrlen;
45 struct sockaddr_storage h_srcaddr; /* our address (optional) */ 45 struct sockaddr_storage h_srcaddr; /* our address (optional) */
46 size_t h_srcaddrlen;
46 struct rpc_clnt *h_rpcclnt; /* RPC client to talk to peer */ 47 struct rpc_clnt *h_rpcclnt; /* RPC client to talk to peer */
47 char *h_name; /* remote hostname */ 48 char *h_name; /* remote hostname */
48 u32 h_version; /* interface version */ 49 u32 h_version; /* interface version */
@@ -201,9 +202,9 @@ extern u32 nsm_local_state;
201 * Lockd client functions 202 * Lockd client functions
202 */ 203 */
203struct nlm_rqst * nlm_alloc_call(struct nlm_host *host); 204struct nlm_rqst * nlm_alloc_call(struct nlm_host *host);
204void nlm_release_call(struct nlm_rqst *);
205int nlm_async_call(struct nlm_rqst *, u32, const struct rpc_call_ops *); 205int nlm_async_call(struct nlm_rqst *, u32, const struct rpc_call_ops *);
206int nlm_async_reply(struct nlm_rqst *, u32, const struct rpc_call_ops *); 206int nlm_async_reply(struct nlm_rqst *, u32, const struct rpc_call_ops *);
207void nlmclnt_release_call(struct nlm_rqst *);
207struct nlm_wait * nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *fl); 208struct nlm_wait * nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *fl);
208void nlmclnt_finish_block(struct nlm_wait *block); 209void nlmclnt_finish_block(struct nlm_wait *block);
209int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout); 210int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout);
@@ -222,13 +223,14 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
222 const u32 version, 223 const u32 version,
223 const char *hostname, 224 const char *hostname,
224 int noresvport); 225 int noresvport);
226void nlmclnt_release_host(struct nlm_host *);
225struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, 227struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
226 const char *hostname, 228 const char *hostname,
227 const size_t hostname_len); 229 const size_t hostname_len);
230void nlmsvc_release_host(struct nlm_host *);
228struct rpc_clnt * nlm_bind_host(struct nlm_host *); 231struct rpc_clnt * nlm_bind_host(struct nlm_host *);
229void nlm_rebind_host(struct nlm_host *); 232void nlm_rebind_host(struct nlm_host *);
230struct nlm_host * nlm_get_host(struct nlm_host *); 233struct nlm_host * nlm_get_host(struct nlm_host *);
231void nlm_release_host(struct nlm_host *);
232void nlm_shutdown_hosts(void); 234void nlm_shutdown_hosts(void);
233void nlm_host_rebooted(const struct nlm_reboot *); 235void nlm_host_rebooted(const struct nlm_reboot *);
234 236
@@ -266,6 +268,7 @@ unsigned long nlmsvc_retry_blocked(void);
266void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, 268void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
267 nlm_host_match_fn_t match); 269 nlm_host_match_fn_t match);
268void nlmsvc_grant_reply(struct nlm_cookie *, __be32); 270void nlmsvc_grant_reply(struct nlm_cookie *, __be32);
271void nlmsvc_release_call(struct nlm_rqst *);
269 272
270/* 273/*
271 * File handling for the server personality 274 * File handling for the server personality
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 06aed8305bf3..ef820a3c378b 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -32,6 +32,17 @@ extern int lock_stat;
32#define MAX_LOCKDEP_SUBCLASSES 8UL 32#define MAX_LOCKDEP_SUBCLASSES 8UL
33 33
34/* 34/*
35 * NR_LOCKDEP_CACHING_CLASSES ... Number of classes
36 * cached in the instance of lockdep_map
37 *
38 * Currently main class (subclass == 0) and signle depth subclass
39 * are cached in lockdep_map. This optimization is mainly targeting
40 * on rq->lock. double_rq_lock() acquires this highly competitive with
41 * single depth.
42 */
43#define NR_LOCKDEP_CACHING_CLASSES 2
44
45/*
35 * Lock-classes are keyed via unique addresses, by embedding the 46 * Lock-classes are keyed via unique addresses, by embedding the
36 * lockclass-key into the kernel (or module) .data section. (For 47 * lockclass-key into the kernel (or module) .data section. (For
37 * static locks we use the lock address itself as the key.) 48 * static locks we use the lock address itself as the key.)
@@ -138,7 +149,7 @@ void clear_lock_stats(struct lock_class *class);
138 */ 149 */
139struct lockdep_map { 150struct lockdep_map {
140 struct lock_class_key *key; 151 struct lock_class_key *key;
141 struct lock_class *class_cache; 152 struct lock_class *class_cache[NR_LOCKDEP_CACHING_CLASSES];
142 const char *name; 153 const char *name;
143#ifdef CONFIG_LOCK_STAT 154#ifdef CONFIG_LOCK_STAT
144 int cpu; 155 int cpu;
@@ -424,25 +435,9 @@ do { \
424 435
425#endif /* CONFIG_LOCKDEP */ 436#endif /* CONFIG_LOCKDEP */
426 437
427#ifdef CONFIG_GENERIC_HARDIRQS
428extern void early_init_irq_lock_class(void);
429#else
430static inline void early_init_irq_lock_class(void)
431{
432}
433#endif
434
435#ifdef CONFIG_TRACE_IRQFLAGS 438#ifdef CONFIG_TRACE_IRQFLAGS
436extern void early_boot_irqs_off(void);
437extern void early_boot_irqs_on(void);
438extern void print_irqtrace_events(struct task_struct *curr); 439extern void print_irqtrace_events(struct task_struct *curr);
439#else 440#else
440static inline void early_boot_irqs_off(void)
441{
442}
443static inline void early_boot_irqs_on(void)
444{
445}
446static inline void print_irqtrace_events(struct task_struct *curr) 441static inline void print_irqtrace_events(struct task_struct *curr)
447{ 442{
448} 443}
@@ -492,12 +487,15 @@ static inline void print_irqtrace_events(struct task_struct *curr)
492#ifdef CONFIG_DEBUG_LOCK_ALLOC 487#ifdef CONFIG_DEBUG_LOCK_ALLOC
493# ifdef CONFIG_PROVE_LOCKING 488# ifdef CONFIG_PROVE_LOCKING
494# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i) 489# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i)
490# define mutex_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i)
495# else 491# else
496# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i) 492# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
493# define mutex_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i)
497# endif 494# endif
498# define mutex_release(l, n, i) lock_release(l, n, i) 495# define mutex_release(l, n, i) lock_release(l, n, i)
499#else 496#else
500# define mutex_acquire(l, s, t, i) do { } while (0) 497# define mutex_acquire(l, s, t, i) do { } while (0)
498# define mutex_acquire_nest(l, s, t, n, i) do { } while (0)
501# define mutex_release(l, n, i) do { } while (0) 499# define mutex_release(l, n, i) do { } while (0)
502#endif 500#endif
503 501
@@ -519,12 +517,15 @@ static inline void print_irqtrace_events(struct task_struct *curr)
519#ifdef CONFIG_DEBUG_LOCK_ALLOC 517#ifdef CONFIG_DEBUG_LOCK_ALLOC
520# ifdef CONFIG_PROVE_LOCKING 518# ifdef CONFIG_PROVE_LOCKING
521# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_) 519# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_)
520# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 2, NULL, _THIS_IP_)
522# else 521# else
523# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_) 522# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_)
523# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 1, NULL, _THIS_IP_)
524# endif 524# endif
525# define lock_map_release(l) lock_release(l, 1, _THIS_IP_) 525# define lock_map_release(l) lock_release(l, 1, _THIS_IP_)
526#else 526#else
527# define lock_map_acquire(l) do { } while (0) 527# define lock_map_acquire(l) do { } while (0)
528# define lock_map_acquire_read(l) do { } while (0)
528# define lock_map_release(l) do { } while (0) 529# define lock_map_release(l) do { } while (0)
529#endif 530#endif
530 531
diff --git a/include/linux/lru_cache.h b/include/linux/lru_cache.h
index 78fbf24f357a..7a71ffad037c 100644
--- a/include/linux/lru_cache.h
+++ b/include/linux/lru_cache.h
@@ -139,16 +139,16 @@ write intent log information, three of which are mentioned here.
139 * .list is on one of three lists: 139 * .list is on one of three lists:
140 * in_use: currently in use (refcnt > 0, lc_number != LC_FREE) 140 * in_use: currently in use (refcnt > 0, lc_number != LC_FREE)
141 * lru: unused but ready to be reused or recycled 141 * lru: unused but ready to be reused or recycled
142 * (ts_refcnt == 0, lc_number != LC_FREE), 142 * (lc_refcnt == 0, lc_number != LC_FREE),
143 * free: unused but ready to be recycled 143 * free: unused but ready to be recycled
144 * (ts_refcnt == 0, lc_number == LC_FREE), 144 * (lc_refcnt == 0, lc_number == LC_FREE),
145 * 145 *
146 * an element is said to be "in the active set", 146 * an element is said to be "in the active set",
147 * if either on "in_use" or "lru", i.e. lc_number != LC_FREE. 147 * if either on "in_use" or "lru", i.e. lc_number != LC_FREE.
148 * 148 *
149 * DRBD currently (May 2009) only uses 61 elements on the resync lru_cache 149 * DRBD currently (May 2009) only uses 61 elements on the resync lru_cache
150 * (total memory usage 2 pages), and up to 3833 elements on the act_log 150 * (total memory usage 2 pages), and up to 3833 elements on the act_log
151 * lru_cache, totalling ~215 kB for 64bit architechture, ~53 pages. 151 * lru_cache, totalling ~215 kB for 64bit architecture, ~53 pages.
152 * 152 *
153 * We usually do not actually free these objects again, but only "recycle" 153 * We usually do not actually free these objects again, but only "recycle"
154 * them, as the change "index: -old_label, +LC_FREE" would need a transaction 154 * them, as the change "index: -old_label, +LC_FREE" would need a transaction
@@ -160,8 +160,8 @@ struct lc_element {
160 struct hlist_node colision; 160 struct hlist_node colision;
161 struct list_head list; /* LRU list or free list */ 161 struct list_head list; /* LRU list or free list */
162 unsigned refcnt; 162 unsigned refcnt;
163 /* back "pointer" into ts_cache->element[index], 163 /* back "pointer" into lc_cache->element[index],
164 * for paranoia, and for "ts_element_to_index" */ 164 * for paranoia, and for "lc_element_to_index" */
165 unsigned lc_index; 165 unsigned lc_index;
166 /* if we want to track a larger set of objects, 166 /* if we want to track a larger set of objects,
167 * it needs to become arch independend u64 */ 167 * it needs to become arch independend u64 */
@@ -190,8 +190,8 @@ struct lru_cache {
190 /* Arbitrary limit on maximum tracked objects. Practical limit is much 190 /* Arbitrary limit on maximum tracked objects. Practical limit is much
191 * lower due to allocation failures, probably. For typical use cases, 191 * lower due to allocation failures, probably. For typical use cases,
192 * nr_elements should be a few thousand at most. 192 * nr_elements should be a few thousand at most.
193 * This also limits the maximum value of ts_element.ts_index, allowing the 193 * This also limits the maximum value of lc_element.lc_index, allowing the
194 * 8 high bits of .ts_index to be overloaded with flags in the future. */ 194 * 8 high bits of .lc_index to be overloaded with flags in the future. */
195#define LC_MAX_ACTIVE (1<<24) 195#define LC_MAX_ACTIVE (1<<24)
196 196
197 /* statistics */ 197 /* statistics */
diff --git a/include/linux/lsm_audit.h b/include/linux/lsm_audit.h
index 112a55033352..88e78dedc2e8 100644
--- a/include/linux/lsm_audit.h
+++ b/include/linux/lsm_audit.h
@@ -27,7 +27,7 @@
27/* Auxiliary data to use in generating the audit record. */ 27/* Auxiliary data to use in generating the audit record. */
28struct common_audit_data { 28struct common_audit_data {
29 char type; 29 char type;
30#define LSM_AUDIT_DATA_FS 1 30#define LSM_AUDIT_DATA_PATH 1
31#define LSM_AUDIT_DATA_NET 2 31#define LSM_AUDIT_DATA_NET 2
32#define LSM_AUDIT_DATA_CAP 3 32#define LSM_AUDIT_DATA_CAP 3
33#define LSM_AUDIT_DATA_IPC 4 33#define LSM_AUDIT_DATA_IPC 4
@@ -35,12 +35,13 @@ struct common_audit_data {
35#define LSM_AUDIT_DATA_KEY 6 35#define LSM_AUDIT_DATA_KEY 6
36#define LSM_AUDIT_DATA_NONE 7 36#define LSM_AUDIT_DATA_NONE 7
37#define LSM_AUDIT_DATA_KMOD 8 37#define LSM_AUDIT_DATA_KMOD 8
38#define LSM_AUDIT_DATA_INODE 9
39#define LSM_AUDIT_DATA_DENTRY 10
38 struct task_struct *tsk; 40 struct task_struct *tsk;
39 union { 41 union {
40 struct { 42 struct path path;
41 struct path path; 43 struct dentry *dentry;
42 struct inode *inode; 44 struct inode *inode;
43 } fs;
44 struct { 45 struct {
45 int netif; 46 int netif;
46 struct sock *sk; 47 struct sock *sk;
diff --git a/include/linux/magic.h b/include/linux/magic.h
index eb9800f05782..1e5df2af8d84 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -16,16 +16,19 @@
16#define TMPFS_MAGIC 0x01021994 16#define TMPFS_MAGIC 0x01021994
17#define HUGETLBFS_MAGIC 0x958458f6 /* some random number */ 17#define HUGETLBFS_MAGIC 0x958458f6 /* some random number */
18#define SQUASHFS_MAGIC 0x73717368 18#define SQUASHFS_MAGIC 0x73717368
19#define ECRYPTFS_SUPER_MAGIC 0xf15f
19#define EFS_SUPER_MAGIC 0x414A53 20#define EFS_SUPER_MAGIC 0x414A53
20#define EXT2_SUPER_MAGIC 0xEF53 21#define EXT2_SUPER_MAGIC 0xEF53
21#define EXT3_SUPER_MAGIC 0xEF53 22#define EXT3_SUPER_MAGIC 0xEF53
22#define XENFS_SUPER_MAGIC 0xabba1974 23#define XENFS_SUPER_MAGIC 0xabba1974
23#define EXT4_SUPER_MAGIC 0xEF53 24#define EXT4_SUPER_MAGIC 0xEF53
24#define BTRFS_SUPER_MAGIC 0x9123683E 25#define BTRFS_SUPER_MAGIC 0x9123683E
26#define NILFS_SUPER_MAGIC 0x3434
25#define HPFS_SUPER_MAGIC 0xf995e849 27#define HPFS_SUPER_MAGIC 0xf995e849
26#define ISOFS_SUPER_MAGIC 0x9660 28#define ISOFS_SUPER_MAGIC 0x9660
27#define JFFS2_SUPER_MAGIC 0x72b6 29#define JFFS2_SUPER_MAGIC 0x72b6
28#define ANON_INODE_FS_MAGIC 0x09041934 30#define ANON_INODE_FS_MAGIC 0x09041934
31#define PSTOREFS_MAGIC 0x6165676C
29 32
30#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */ 33#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
31#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */ 34#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
@@ -57,5 +60,6 @@
57 60
58#define DEVPTS_SUPER_MAGIC 0x1cd1 61#define DEVPTS_SUPER_MAGIC 0x1cd1
59#define SOCKFS_MAGIC 0x534F434B 62#define SOCKFS_MAGIC 0x534F434B
63#define V9FS_MAGIC 0x01021997
60 64
61#endif /* __LINUX_MAGIC_H__ */ 65#endif /* __LINUX_MAGIC_H__ */
diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
index d0f08018335d..dd3c34ebca9a 100644
--- a/include/linux/marvell_phy.h
+++ b/include/linux/marvell_phy.h
@@ -11,8 +11,9 @@
11#define MARVELL_PHY_ID_88E1118 0x01410e10 11#define MARVELL_PHY_ID_88E1118 0x01410e10
12#define MARVELL_PHY_ID_88E1121R 0x01410cb0 12#define MARVELL_PHY_ID_88E1121R 0x01410cb0
13#define MARVELL_PHY_ID_88E1145 0x01410cd0 13#define MARVELL_PHY_ID_88E1145 0x01410cd0
14#define MARVELL_PHY_ID_88E1149R 0x01410e50
14#define MARVELL_PHY_ID_88E1240 0x01410e30 15#define MARVELL_PHY_ID_88E1240 0x01410e30
15#define MARVELL_PHY_ID_88EC048 0x01410e90 16#define MARVELL_PHY_ID_88E1318S 0x01410e90
16 17
17/* struct phy_device dev_flags definitions */ 18/* struct phy_device dev_flags definitions */
18#define MARVELL_PHY_M1145_FLAGS_RESISTANCE 0x00000001 19#define MARVELL_PHY_M1145_FLAGS_RESISTANCE 0x00000001
diff --git a/include/linux/math64.h b/include/linux/math64.h
index c87f1528703a..23fcdfcba81b 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -35,6 +35,14 @@ static inline u64 div64_u64(u64 dividend, u64 divisor)
35 return dividend / divisor; 35 return dividend / divisor;
36} 36}
37 37
38/**
39 * div64_s64 - signed 64bit divide with 64bit divisor
40 */
41static inline s64 div64_s64(s64 dividend, s64 divisor)
42{
43 return dividend / divisor;
44}
45
38#elif BITS_PER_LONG == 32 46#elif BITS_PER_LONG == 32
39 47
40#ifndef div_u64_rem 48#ifndef div_u64_rem
@@ -53,6 +61,10 @@ extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
53extern u64 div64_u64(u64 dividend, u64 divisor); 61extern u64 div64_u64(u64 dividend, u64 divisor);
54#endif 62#endif
55 63
64#ifndef div64_s64
65extern s64 div64_s64(s64 dividend, s64 divisor);
66#endif
67
56#endif /* BITS_PER_LONG */ 68#endif /* BITS_PER_LONG */
57 69
58/** 70/**
diff --git a/include/linux/mbcache.h b/include/linux/mbcache.h
index 54cbbac1e71d..5525d370701d 100644
--- a/include/linux/mbcache.h
+++ b/include/linux/mbcache.h
@@ -18,6 +18,17 @@ struct mb_cache_entry {
18 } e_index; 18 } e_index;
19}; 19};
20 20
21struct mb_cache {
22 struct list_head c_cache_list;
23 const char *c_name;
24 atomic_t c_entry_count;
25 int c_max_entries;
26 int c_bucket_bits;
27 struct kmem_cache *c_entry_cache;
28 struct list_head *c_block_hash;
29 struct list_head *c_index_hash;
30};
31
21/* Functions on caches */ 32/* Functions on caches */
22 33
23struct mb_cache *mb_cache_create(const char *, int); 34struct mb_cache *mb_cache_create(const char *, int);
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index c779b49a1fda..b1494aced217 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -55,6 +55,7 @@
55#define MDIO_PCS_10GBRT_STAT2 33 /* 10GBASE-R/-T PCS status 2 */ 55#define MDIO_PCS_10GBRT_STAT2 33 /* 10GBASE-R/-T PCS status 2 */
56#define MDIO_AN_10GBT_CTRL 32 /* 10GBASE-T auto-negotiation control */ 56#define MDIO_AN_10GBT_CTRL 32 /* 10GBASE-T auto-negotiation control */
57#define MDIO_AN_10GBT_STAT 33 /* 10GBASE-T auto-negotiation status */ 57#define MDIO_AN_10GBT_STAT 33 /* 10GBASE-T auto-negotiation status */
58#define MDIO_AN_EEE_ADV 60 /* EEE advertisement */
58 59
59/* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */ 60/* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */
60#define MDIO_PMA_LASI_RXCTRL 0x9000 /* RX_ALARM control */ 61#define MDIO_PMA_LASI_RXCTRL 0x9000 /* RX_ALARM control */
@@ -235,6 +236,10 @@
235#define MDIO_AN_10GBT_STAT_MS 0x4000 /* Master/slave config */ 236#define MDIO_AN_10GBT_STAT_MS 0x4000 /* Master/slave config */
236#define MDIO_AN_10GBT_STAT_MSFLT 0x8000 /* Master/slave config fault */ 237#define MDIO_AN_10GBT_STAT_MSFLT 0x8000 /* Master/slave config fault */
237 238
239/* AN EEE Advertisement register. */
240#define MDIO_AN_EEE_ADV_100TX 0x0002 /* Advertise 100TX EEE cap */
241#define MDIO_AN_EEE_ADV_1000T 0x0004 /* Advertise 1000T EEE cap */
242
238/* LASI RX_ALARM control/status registers. */ 243/* LASI RX_ALARM control/status registers. */
239#define MDIO_PMA_LASI_RX_PHYXSLFLT 0x0001 /* PHY XS RX local fault */ 244#define MDIO_PMA_LASI_RX_PHYXSLFLT 0x0001 /* PHY XS RX local fault */
240#define MDIO_PMA_LASI_RX_PCSLFLT 0x0008 /* PCS RX local fault */ 245#define MDIO_PMA_LASI_RX_PCSLFLT 0x0008 /* PCS RX local fault */
diff --git a/include/linux/media.h b/include/linux/media.h
new file mode 100644
index 000000000000..0ef883327de2
--- /dev/null
+++ b/include/linux/media.h
@@ -0,0 +1,132 @@
1/*
2 * Multimedia device API
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef __LINUX_MEDIA_H
24#define __LINUX_MEDIA_H
25
26#include <linux/ioctl.h>
27#include <linux/types.h>
28#include <linux/version.h>
29
30#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
31
32struct media_device_info {
33 char driver[16];
34 char model[32];
35 char serial[40];
36 char bus_info[32];
37 __u32 media_version;
38 __u32 hw_revision;
39 __u32 driver_version;
40 __u32 reserved[31];
41};
42
43#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
44
45#define MEDIA_ENT_TYPE_SHIFT 16
46#define MEDIA_ENT_TYPE_MASK 0x00ff0000
47#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
48
49#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT)
50#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1)
51#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
52#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
53#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
54
55#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT)
56#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
57#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2)
58#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3)
59
60#define MEDIA_ENT_FL_DEFAULT (1 << 0)
61
62struct media_entity_desc {
63 __u32 id;
64 char name[32];
65 __u32 type;
66 __u32 revision;
67 __u32 flags;
68 __u32 group_id;
69 __u16 pads;
70 __u16 links;
71
72 __u32 reserved[4];
73
74 union {
75 /* Node specifications */
76 struct {
77 __u32 major;
78 __u32 minor;
79 } v4l;
80 struct {
81 __u32 major;
82 __u32 minor;
83 } fb;
84 struct {
85 __u32 card;
86 __u32 device;
87 __u32 subdevice;
88 } alsa;
89 int dvb;
90
91 /* Sub-device specifications */
92 /* Nothing needed yet */
93 __u8 raw[184];
94 };
95};
96
97#define MEDIA_PAD_FL_SINK (1 << 0)
98#define MEDIA_PAD_FL_SOURCE (1 << 1)
99
100struct media_pad_desc {
101 __u32 entity; /* entity ID */
102 __u16 index; /* pad index */
103 __u32 flags; /* pad flags */
104 __u32 reserved[2];
105};
106
107#define MEDIA_LNK_FL_ENABLED (1 << 0)
108#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
109#define MEDIA_LNK_FL_DYNAMIC (1 << 2)
110
111struct media_link_desc {
112 struct media_pad_desc source;
113 struct media_pad_desc sink;
114 __u32 flags;
115 __u32 reserved[2];
116};
117
118struct media_links_enum {
119 __u32 entity;
120 /* Should have enough room for pads elements */
121 struct media_pad_desc __user *pads;
122 /* Should have enough room for links elements */
123 struct media_link_desc __user *links;
124 __u32 reserved[4];
125};
126
127#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
128#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
129#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
130#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
131
132#endif /* __LINUX_MEDIA_H */
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index a59faf2b5edd..7525e38c434d 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -2,6 +2,9 @@
2#define _LINUX_MEMBLOCK_H 2#define _LINUX_MEMBLOCK_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#define MEMBLOCK_ERROR 0
6
7#ifdef CONFIG_HAVE_MEMBLOCK
5/* 8/*
6 * Logical memory blocks. 9 * Logical memory blocks.
7 * 10 *
@@ -16,73 +19,155 @@
16#include <linux/init.h> 19#include <linux/init.h>
17#include <linux/mm.h> 20#include <linux/mm.h>
18 21
19#define MAX_MEMBLOCK_REGIONS 128 22#include <asm/memblock.h>
20 23
21struct memblock_property { 24#define INIT_MEMBLOCK_REGIONS 128
22 u64 base;
23 u64 size;
24};
25 25
26struct memblock_region { 26struct memblock_region {
27 unsigned long cnt; 27 phys_addr_t base;
28 u64 size; 28 phys_addr_t size;
29 struct memblock_property region[MAX_MEMBLOCK_REGIONS+1]; 29};
30
31struct memblock_type {
32 unsigned long cnt; /* number of regions */
33 unsigned long max; /* size of the allocated array */
34 struct memblock_region *regions;
30}; 35};
31 36
32struct memblock { 37struct memblock {
33 unsigned long debug; 38 phys_addr_t current_limit;
34 u64 rmo_size; 39 phys_addr_t memory_size; /* Updated by memblock_analyze() */
35 struct memblock_region memory; 40 struct memblock_type memory;
36 struct memblock_region reserved; 41 struct memblock_type reserved;
37}; 42};
38 43
39extern struct memblock memblock; 44extern struct memblock memblock;
45extern int memblock_debug;
46extern int memblock_can_resize;
40 47
41extern void __init memblock_init(void); 48#define memblock_dbg(fmt, ...) \
42extern void __init memblock_analyze(void); 49 if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
43extern long memblock_add(u64 base, u64 size); 50
44extern long memblock_remove(u64 base, u64 size); 51u64 memblock_find_in_range(u64 start, u64 end, u64 size, u64 align);
45extern long __init memblock_free(u64 base, u64 size); 52int memblock_free_reserved_regions(void);
46extern long __init memblock_reserve(u64 base, u64 size); 53int memblock_reserve_reserved_regions(void);
47extern u64 __init memblock_alloc_nid(u64 size, u64 align, int nid, 54
48 u64 (*nid_range)(u64, u64, int *)); 55extern void memblock_init(void);
49extern u64 __init memblock_alloc(u64 size, u64 align); 56extern void memblock_analyze(void);
50extern u64 __init memblock_alloc_base(u64 size, 57extern long memblock_add(phys_addr_t base, phys_addr_t size);
51 u64, u64 max_addr); 58extern long memblock_remove(phys_addr_t base, phys_addr_t size);
52extern u64 __init __memblock_alloc_base(u64 size, 59extern long memblock_free(phys_addr_t base, phys_addr_t size);
53 u64 align, u64 max_addr); 60extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
54extern u64 __init memblock_phys_mem_size(void); 61
55extern u64 memblock_end_of_DRAM(void); 62/* The numa aware allocator is only available if
56extern void __init memblock_enforce_memory_limit(u64 memory_limit); 63 * CONFIG_ARCH_POPULATES_NODE_MAP is set
57extern int __init memblock_is_reserved(u64 addr); 64 */
58extern int memblock_is_region_reserved(u64 base, u64 size); 65extern phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align,
59extern int memblock_find(struct memblock_property *res); 66 int nid);
67extern phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align,
68 int nid);
69
70extern phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align);
71
72/* Flags for memblock_alloc_base() amd __memblock_alloc_base() */
73#define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0)
74#define MEMBLOCK_ALLOC_ACCESSIBLE 0
75
76extern phys_addr_t memblock_alloc_base(phys_addr_t size,
77 phys_addr_t align,
78 phys_addr_t max_addr);
79extern phys_addr_t __memblock_alloc_base(phys_addr_t size,
80 phys_addr_t align,
81 phys_addr_t max_addr);
82extern phys_addr_t memblock_phys_mem_size(void);
83extern phys_addr_t memblock_end_of_DRAM(void);
84extern void memblock_enforce_memory_limit(phys_addr_t memory_limit);
85extern int memblock_is_memory(phys_addr_t addr);
86extern int memblock_is_region_memory(phys_addr_t base, phys_addr_t size);
87extern int memblock_is_reserved(phys_addr_t addr);
88extern int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
60 89
61extern void memblock_dump_all(void); 90extern void memblock_dump_all(void);
62 91
63static inline u64 92/* Provided by the architecture */
64memblock_size_bytes(struct memblock_region *type, unsigned long region_nr) 93extern phys_addr_t memblock_nid_range(phys_addr_t start, phys_addr_t end, int *nid);
94extern int memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
95 phys_addr_t addr2, phys_addr_t size2);
96
97/**
98 * memblock_set_current_limit - Set the current allocation limit to allow
99 * limiting allocations to what is currently
100 * accessible during boot
101 * @limit: New limit value (physical address)
102 */
103extern void memblock_set_current_limit(phys_addr_t limit);
104
105
106/*
107 * pfn conversion functions
108 *
109 * While the memory MEMBLOCKs should always be page aligned, the reserved
110 * MEMBLOCKs may not be. This accessor attempt to provide a very clear
111 * idea of what they return for such non aligned MEMBLOCKs.
112 */
113
114/**
115 * memblock_region_memory_base_pfn - Return the lowest pfn intersecting with the memory region
116 * @reg: memblock_region structure
117 */
118static inline unsigned long memblock_region_memory_base_pfn(const struct memblock_region *reg)
65{ 119{
66 return type->region[region_nr].size; 120 return PFN_UP(reg->base);
67} 121}
68static inline u64 122
69memblock_size_pages(struct memblock_region *type, unsigned long region_nr) 123/**
124 * memblock_region_memory_end_pfn - Return the end_pfn this region
125 * @reg: memblock_region structure
126 */
127static inline unsigned long memblock_region_memory_end_pfn(const struct memblock_region *reg)
70{ 128{
71 return memblock_size_bytes(type, region_nr) >> PAGE_SHIFT; 129 return PFN_DOWN(reg->base + reg->size);
72} 130}
73static inline u64 131
74memblock_start_pfn(struct memblock_region *type, unsigned long region_nr) 132/**
133 * memblock_region_reserved_base_pfn - Return the lowest pfn intersecting with the reserved region
134 * @reg: memblock_region structure
135 */
136static inline unsigned long memblock_region_reserved_base_pfn(const struct memblock_region *reg)
75{ 137{
76 return type->region[region_nr].base >> PAGE_SHIFT; 138 return PFN_DOWN(reg->base);
77} 139}
78static inline u64 140
79memblock_end_pfn(struct memblock_region *type, unsigned long region_nr) 141/**
142 * memblock_region_reserved_end_pfn - Return the end_pfn this region
143 * @reg: memblock_region structure
144 */
145static inline unsigned long memblock_region_reserved_end_pfn(const struct memblock_region *reg)
80{ 146{
81 return memblock_start_pfn(type, region_nr) + 147 return PFN_UP(reg->base + reg->size);
82 memblock_size_pages(type, region_nr);
83} 148}
84 149
85#include <asm/memblock.h> 150#define for_each_memblock(memblock_type, region) \
151 for (region = memblock.memblock_type.regions; \
152 region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \
153 region++)
154
155
156#ifdef ARCH_DISCARD_MEMBLOCK
157#define __init_memblock __init
158#define __initdata_memblock __initdata
159#else
160#define __init_memblock
161#define __initdata_memblock
162#endif
163
164#else
165static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align)
166{
167 return MEMBLOCK_ERROR;
168}
169
170#endif /* CONFIG_HAVE_MEMBLOCK */
86 171
87#endif /* __KERNEL__ */ 172#endif /* __KERNEL__ */
88 173
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 159a0762aeaf..50940da6adf3 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -20,11 +20,18 @@
20#ifndef _LINUX_MEMCONTROL_H 20#ifndef _LINUX_MEMCONTROL_H
21#define _LINUX_MEMCONTROL_H 21#define _LINUX_MEMCONTROL_H
22#include <linux/cgroup.h> 22#include <linux/cgroup.h>
23#include <linux/vm_event_item.h>
24
23struct mem_cgroup; 25struct mem_cgroup;
24struct page_cgroup; 26struct page_cgroup;
25struct page; 27struct page;
26struct mm_struct; 28struct mm_struct;
27 29
30/* Stats that can be updated by kernel. */
31enum mem_cgroup_page_stat_item {
32 MEMCG_NR_FILE_MAPPED, /* # of pages charged as file rss */
33};
34
28extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, 35extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
29 struct list_head *dst, 36 struct list_head *dst,
30 unsigned long *scanned, int order, 37 unsigned long *scanned, int order,
@@ -57,6 +64,7 @@ extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
57 gfp_t gfp_mask); 64 gfp_t gfp_mask);
58extern void mem_cgroup_add_lru_list(struct page *page, enum lru_list lru); 65extern void mem_cgroup_add_lru_list(struct page *page, enum lru_list lru);
59extern void mem_cgroup_del_lru_list(struct page *page, enum lru_list lru); 66extern void mem_cgroup_del_lru_list(struct page *page, enum lru_list lru);
67extern void mem_cgroup_rotate_reclaimable_page(struct page *page);
60extern void mem_cgroup_rotate_lru_list(struct page *page, enum lru_list lru); 68extern void mem_cgroup_rotate_lru_list(struct page *page, enum lru_list lru);
61extern void mem_cgroup_del_lru(struct page *page); 69extern void mem_cgroup_del_lru(struct page *page);
62extern void mem_cgroup_move_lists(struct page *page, 70extern void mem_cgroup_move_lists(struct page *page,
@@ -76,6 +84,7 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
76 84
77extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page); 85extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
78extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); 86extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
87extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
79 88
80static inline 89static inline
81int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup) 90int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
@@ -91,18 +100,19 @@ extern struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem);
91 100
92extern int 101extern int
93mem_cgroup_prepare_migration(struct page *page, 102mem_cgroup_prepare_migration(struct page *page,
94 struct page *newpage, struct mem_cgroup **ptr); 103 struct page *newpage, struct mem_cgroup **ptr, gfp_t gfp_mask);
95extern void mem_cgroup_end_migration(struct mem_cgroup *mem, 104extern void mem_cgroup_end_migration(struct mem_cgroup *mem,
96 struct page *oldpage, struct page *newpage); 105 struct page *oldpage, struct page *newpage, bool migration_ok);
97 106
98/* 107/*
99 * For memory reclaim. 108 * For memory reclaim.
100 */ 109 */
101int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg); 110int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg);
102int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg); 111int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg);
103unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg, 112int mem_cgroup_select_victim_node(struct mem_cgroup *memcg);
104 struct zone *zone, 113unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
105 enum lru_list lru); 114 struct zone *zone,
115 enum lru_list lru);
106struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg, 116struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
107 struct zone *zone); 117 struct zone *zone);
108struct zone_reclaim_stat* 118struct zone_reclaim_stat*
@@ -121,11 +131,36 @@ static inline bool mem_cgroup_disabled(void)
121 return false; 131 return false;
122} 132}
123 133
124void mem_cgroup_update_file_mapped(struct page *page, int val); 134void mem_cgroup_update_page_stat(struct page *page,
135 enum mem_cgroup_page_stat_item idx,
136 int val);
137
138static inline void mem_cgroup_inc_page_stat(struct page *page,
139 enum mem_cgroup_page_stat_item idx)
140{
141 mem_cgroup_update_page_stat(page, idx, 1);
142}
143
144static inline void mem_cgroup_dec_page_stat(struct page *page,
145 enum mem_cgroup_page_stat_item idx)
146{
147 mem_cgroup_update_page_stat(page, idx, -1);
148}
149
125unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, 150unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
126 gfp_t gfp_mask); 151 gfp_t gfp_mask,
152 unsigned long *total_scanned);
127u64 mem_cgroup_get_limit(struct mem_cgroup *mem); 153u64 mem_cgroup_get_limit(struct mem_cgroup *mem);
128 154
155void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx);
156#ifdef CONFIG_TRANSPARENT_HUGEPAGE
157void mem_cgroup_split_huge_fixup(struct page *head, struct page *tail);
158#endif
159
160#ifdef CONFIG_DEBUG_VM
161bool mem_cgroup_bad_page_check(struct page *page);
162void mem_cgroup_print_bad_page(struct page *page);
163#endif
129#else /* CONFIG_CGROUP_MEM_RES_CTLR */ 164#else /* CONFIG_CGROUP_MEM_RES_CTLR */
130struct mem_cgroup; 165struct mem_cgroup;
131 166
@@ -187,6 +222,11 @@ static inline void mem_cgroup_del_lru_list(struct page *page, int lru)
187 return ; 222 return ;
188} 223}
189 224
225static inline void mem_cgroup_rotate_reclaimable_page(struct page *page)
226{
227 return ;
228}
229
190static inline void mem_cgroup_rotate_lru_list(struct page *page, int lru) 230static inline void mem_cgroup_rotate_lru_list(struct page *page, int lru)
191{ 231{
192 return ; 232 return ;
@@ -207,6 +247,11 @@ static inline struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
207 return NULL; 247 return NULL;
208} 248}
209 249
250static inline struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
251{
252 return NULL;
253}
254
210static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem) 255static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem)
211{ 256{
212 return 1; 257 return 1;
@@ -225,14 +270,13 @@ static inline struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem)
225 270
226static inline int 271static inline int
227mem_cgroup_prepare_migration(struct page *page, struct page *newpage, 272mem_cgroup_prepare_migration(struct page *page, struct page *newpage,
228 struct mem_cgroup **ptr) 273 struct mem_cgroup **ptr, gfp_t gfp_mask)
229{ 274{
230 return 0; 275 return 0;
231} 276}
232 277
233static inline void mem_cgroup_end_migration(struct mem_cgroup *mem, 278static inline void mem_cgroup_end_migration(struct mem_cgroup *mem,
234 struct page *oldpage, 279 struct page *oldpage, struct page *newpage, bool migration_ok)
235 struct page *newpage)
236{ 280{
237} 281}
238 282
@@ -269,8 +313,8 @@ mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg)
269} 313}
270 314
271static inline unsigned long 315static inline unsigned long
272mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg, struct zone *zone, 316mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, struct zone *zone,
273 enum lru_list lru) 317 enum lru_list lru)
274{ 318{
275 return 0; 319 return 0;
276} 320}
@@ -293,14 +337,20 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
293{ 337{
294} 338}
295 339
296static inline void mem_cgroup_update_file_mapped(struct page *page, 340static inline void mem_cgroup_inc_page_stat(struct page *page,
297 int val) 341 enum mem_cgroup_page_stat_item idx)
342{
343}
344
345static inline void mem_cgroup_dec_page_stat(struct page *page,
346 enum mem_cgroup_page_stat_item idx)
298{ 347{
299} 348}
300 349
301static inline 350static inline
302unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, 351unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
303 gfp_t gfp_mask) 352 gfp_t gfp_mask,
353 unsigned long *total_scanned)
304{ 354{
305 return 0; 355 return 0;
306} 356}
@@ -311,7 +361,29 @@ u64 mem_cgroup_get_limit(struct mem_cgroup *mem)
311 return 0; 361 return 0;
312} 362}
313 363
364static inline void mem_cgroup_split_huge_fixup(struct page *head,
365 struct page *tail)
366{
367}
368
369static inline
370void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx)
371{
372}
314#endif /* CONFIG_CGROUP_MEM_CONT */ 373#endif /* CONFIG_CGROUP_MEM_CONT */
315 374
375#if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM)
376static inline bool
377mem_cgroup_bad_page_check(struct page *page)
378{
379 return false;
380}
381
382static inline void
383mem_cgroup_print_bad_page(struct page *page)
384{
385}
386#endif
387
316#endif /* _LINUX_MEMCONTROL_H */ 388#endif /* _LINUX_MEMCONTROL_H */
317 389
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 85582e1bcee9..935699b30b7c 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -20,9 +20,14 @@
20#include <linux/compiler.h> 20#include <linux/compiler.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22 22
23#define MIN_MEMORY_BLOCK_SIZE (1 << SECTION_SIZE_BITS)
24
23struct memory_block { 25struct memory_block {
24 unsigned long phys_index; 26 unsigned long start_section_nr;
27 unsigned long end_section_nr;
25 unsigned long state; 28 unsigned long state;
29 int section_count;
30
26 /* 31 /*
27 * This serializes all state change requests. It isn't 32 * This serializes all state change requests. It isn't
28 * held during creation because the control files are 33 * held during creation because the control files are
@@ -113,6 +118,8 @@ extern int memory_dev_init(void);
113extern int remove_memory_block(unsigned long, struct mem_section *, int); 118extern int remove_memory_block(unsigned long, struct mem_section *, int);
114extern int memory_notify(unsigned long val, void *v); 119extern int memory_notify(unsigned long val, void *v);
115extern int memory_isolate_notify(unsigned long val, void *v); 120extern int memory_isolate_notify(unsigned long val, void *v);
121extern struct memory_block *find_memory_block_hinted(struct mem_section *,
122 struct memory_block *);
116extern struct memory_block *find_memory_block(struct mem_section *); 123extern struct memory_block *find_memory_block(struct mem_section *);
117#define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) 124#define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)
118enum mem_add_context { BOOT, HOTPLUG }; 125enum mem_add_context { BOOT, HOTPLUG };
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 864035fb8f8a..8122018d3000 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -13,12 +13,16 @@ struct mem_section;
13#ifdef CONFIG_MEMORY_HOTPLUG 13#ifdef CONFIG_MEMORY_HOTPLUG
14 14
15/* 15/*
16 * Types for free bootmem. 16 * Types for free bootmem stored in page->lru.next. These have to be in
17 * The normal smallest mapcount is -1. Here is smaller value than it. 17 * some random range in unsigned long space for debugging purposes.
18 */ 18 */
19#define SECTION_INFO (-1 - 1) 19enum {
20#define MIX_SECTION_INFO (-1 - 2) 20 MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 12,
21#define NODE_INFO (-1 - 3) 21 SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
22 MIX_SECTION_INFO,
23 NODE_INFO,
24 MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO,
25};
22 26
23/* 27/*
24 * pgdat resizing functions 28 * pgdat resizing functions
@@ -70,6 +74,10 @@ extern void online_page(struct page *page);
70extern int online_pages(unsigned long, unsigned long); 74extern int online_pages(unsigned long, unsigned long);
71extern void __offline_isolated_pages(unsigned long, unsigned long); 75extern void __offline_isolated_pages(unsigned long, unsigned long);
72 76
77#ifdef CONFIG_MEMORY_HOTREMOVE
78extern bool is_pageblock_removable_nolock(struct page *page);
79#endif /* CONFIG_MEMORY_HOTREMOVE */
80
73/* reasonably generic interface to expand the physical pages in a zone */ 81/* reasonably generic interface to expand the physical pages in a zone */
74extern int __add_pages(int nid, struct zone *zone, unsigned long start_pfn, 82extern int __add_pages(int nid, struct zone *zone, unsigned long start_pfn,
75 unsigned long nr_pages); 83 unsigned long nr_pages);
@@ -157,6 +165,15 @@ extern void register_page_bootmem_info_node(struct pglist_data *pgdat);
157extern void put_page_bootmem(struct page *page); 165extern void put_page_bootmem(struct page *page);
158#endif 166#endif
159 167
168/*
169 * Lock for memory hotplug guarantees 1) all callbacks for memory hotplug
170 * notifier will be called under this. 2) offline/online/add/remove memory
171 * will not run simultaneously.
172 */
173
174void lock_memory_hotplug(void);
175void unlock_memory_hotplug(void);
176
160#else /* ! CONFIG_MEMORY_HOTPLUG */ 177#else /* ! CONFIG_MEMORY_HOTPLUG */
161/* 178/*
162 * Stub functions for when hotplug is off 179 * Stub functions for when hotplug is off
@@ -188,6 +205,9 @@ static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
188{ 205{
189} 206}
190 207
208static inline void lock_memory_hotplug(void) {}
209static inline void unlock_memory_hotplug(void) {}
210
191#endif /* ! CONFIG_MEMORY_HOTPLUG */ 211#endif /* ! CONFIG_MEMORY_HOTPLUG */
192 212
193#ifdef CONFIG_MEMORY_HOTREMOVE 213#ifdef CONFIG_MEMORY_HOTREMOVE
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 31ac26ca4acf..7978eec1b7d9 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -199,6 +199,9 @@ void mpol_free_shared_policy(struct shared_policy *p);
199struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp, 199struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp,
200 unsigned long idx); 200 unsigned long idx);
201 201
202struct mempolicy *get_vma_policy(struct task_struct *tsk,
203 struct vm_area_struct *vma, unsigned long addr);
204
202extern void numa_default_policy(void); 205extern void numa_default_policy(void);
203extern void numa_policy_init(void); 206extern void numa_policy_init(void);
204extern void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new, 207extern void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new,
@@ -228,10 +231,10 @@ int do_migrate_pages(struct mm_struct *mm,
228 231
229#ifdef CONFIG_TMPFS 232#ifdef CONFIG_TMPFS
230extern int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context); 233extern int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context);
234#endif
231 235
232extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, 236extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
233 int no_context); 237 int no_context);
234#endif
235 238
236/* Check if a vma is migratable */ 239/* Check if a vma is migratable */
237static inline int vma_migratable(struct vm_area_struct *vma) 240static inline int vma_migratable(struct vm_area_struct *vma)
@@ -368,13 +371,13 @@ static inline int mpol_parse_str(char *str, struct mempolicy **mpol,
368{ 371{
369 return 1; /* error */ 372 return 1; /* error */
370} 373}
374#endif
371 375
372static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, 376static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
373 int no_context) 377 int no_context)
374{ 378{
375 return 0; 379 return 0;
376} 380}
377#endif
378 381
379#endif /* CONFIG_NUMA */ 382#endif /* CONFIG_NUMA */
380#endif /* __KERNEL__ */ 383#endif /* __KERNEL__ */
diff --git a/include/linux/mfd/88pm860x.h b/include/linux/mfd/88pm860x.h
index bfd23bef7363..63b4fb8e3b6f 100644
--- a/include/linux/mfd/88pm860x.h
+++ b/include/linux/mfd/88pm860x.h
@@ -131,14 +131,16 @@ enum {
131 PM8607_ID_LDO8, 131 PM8607_ID_LDO8,
132 PM8607_ID_LDO9, 132 PM8607_ID_LDO9,
133 PM8607_ID_LDO10, 133 PM8607_ID_LDO10,
134 PM8607_ID_LDO11,
134 PM8607_ID_LDO12, 135 PM8607_ID_LDO12,
135 PM8607_ID_LDO13, 136 PM8607_ID_LDO13,
136 PM8607_ID_LDO14, 137 PM8607_ID_LDO14,
138 PM8607_ID_LDO15,
137 139
138 PM8607_ID_RG_MAX, 140 PM8607_ID_RG_MAX,
139}; 141};
140 142
141#define PM8607_VERSION (0x40) /* 8607 chip ID */ 143/* 8607 chip ID is 0x40 or 0x50 */
142#define PM8607_VERSION_MASK (0xF0) /* 8607 chip ID mask */ 144#define PM8607_VERSION_MASK (0xF0) /* 8607 chip ID mask */
143 145
144/* Interrupt Registers */ 146/* Interrupt Registers */
@@ -310,8 +312,6 @@ struct pm860x_chip {
310 312
311}; 313};
312 314
313#define PM8607_MAX_REGULATOR PM8607_ID_RG_MAX /* 3 Bucks, 13 LDOs */
314
315enum { 315enum {
316 GI2C_PORT = 0, 316 GI2C_PORT = 0,
317 PI2C_PORT, 317 PI2C_PORT,
@@ -330,6 +330,11 @@ struct pm860x_led_pdata {
330 unsigned long flags; 330 unsigned long flags;
331}; 331};
332 332
333struct pm860x_rtc_pdata {
334 int (*sync)(unsigned int ticks);
335 int vrtc;
336};
337
333struct pm860x_touch_pdata { 338struct pm860x_touch_pdata {
334 int gpadc_prebias; 339 int gpadc_prebias;
335 int slot_cycle; 340 int slot_cycle;
@@ -349,25 +354,34 @@ struct pm860x_power_pdata {
349struct pm860x_platform_data { 354struct pm860x_platform_data {
350 struct pm860x_backlight_pdata *backlight; 355 struct pm860x_backlight_pdata *backlight;
351 struct pm860x_led_pdata *led; 356 struct pm860x_led_pdata *led;
357 struct pm860x_rtc_pdata *rtc;
352 struct pm860x_touch_pdata *touch; 358 struct pm860x_touch_pdata *touch;
353 struct pm860x_power_pdata *power; 359 struct pm860x_power_pdata *power;
360 struct regulator_init_data *regulator;
354 361
355 unsigned short companion_addr; /* I2C address of companion chip */ 362 unsigned short companion_addr; /* I2C address of companion chip */
356 int i2c_port; /* Controlled by GI2C or PI2C */ 363 int i2c_port; /* Controlled by GI2C or PI2C */
357 int irq_mode; /* Clear interrupt by read/write(0/1) */ 364 int irq_mode; /* Clear interrupt by read/write(0/1) */
358 int irq_base; /* IRQ base number of 88pm860x */ 365 int irq_base; /* IRQ base number of 88pm860x */
359 struct regulator_init_data *regulator[PM8607_MAX_REGULATOR]; 366 int num_leds;
367 int num_backlights;
368 int num_regulators;
360}; 369};
361 370
362extern char pm860x_backlight_name[][MFD_NAME_SIZE];
363extern char pm860x_led_name[][MFD_NAME_SIZE];
364
365extern int pm860x_reg_read(struct i2c_client *, int); 371extern int pm860x_reg_read(struct i2c_client *, int);
366extern int pm860x_reg_write(struct i2c_client *, int, unsigned char); 372extern int pm860x_reg_write(struct i2c_client *, int, unsigned char);
367extern int pm860x_bulk_read(struct i2c_client *, int, int, unsigned char *); 373extern int pm860x_bulk_read(struct i2c_client *, int, int, unsigned char *);
368extern int pm860x_bulk_write(struct i2c_client *, int, int, unsigned char *); 374extern int pm860x_bulk_write(struct i2c_client *, int, int, unsigned char *);
369extern int pm860x_set_bits(struct i2c_client *, int, unsigned char, 375extern int pm860x_set_bits(struct i2c_client *, int, unsigned char,
370 unsigned char); 376 unsigned char);
377extern int pm860x_page_reg_read(struct i2c_client *, int);
378extern int pm860x_page_reg_write(struct i2c_client *, int, unsigned char);
379extern int pm860x_page_bulk_read(struct i2c_client *, int, int,
380 unsigned char *);
381extern int pm860x_page_bulk_write(struct i2c_client *, int, int,
382 unsigned char *);
383extern int pm860x_page_set_bits(struct i2c_client *, int, unsigned char,
384 unsigned char);
371 385
372extern int pm860x_device_init(struct pm860x_chip *chip, 386extern int pm860x_device_init(struct pm860x_chip *chip,
373 struct pm860x_platform_data *pdata) __devinit ; 387 struct pm860x_platform_data *pdata) __devinit ;
diff --git a/include/linux/mfd/ab8500.h b/include/linux/mfd/ab8500.h
index f5cec4500f38..b31843075198 100644
--- a/include/linux/mfd/ab8500.h
+++ b/include/linux/mfd/ab8500.h
@@ -10,6 +10,29 @@
10#include <linux/device.h> 10#include <linux/device.h>
11 11
12/* 12/*
13 * AB8500 bank addresses
14 */
15#define AB8500_SYS_CTRL1_BLOCK 0x1
16#define AB8500_SYS_CTRL2_BLOCK 0x2
17#define AB8500_REGU_CTRL1 0x3
18#define AB8500_REGU_CTRL2 0x4
19#define AB8500_USB 0x5
20#define AB8500_TVOUT 0x6
21#define AB8500_DBI 0x7
22#define AB8500_ECI_AV_ACC 0x8
23#define AB8500_RESERVED 0x9
24#define AB8500_GPADC 0xA
25#define AB8500_CHARGER 0xB
26#define AB8500_GAS_GAUGE 0xC
27#define AB8500_AUDIO 0xD
28#define AB8500_INTERRUPT 0xE
29#define AB8500_RTC 0xF
30#define AB8500_MISC 0x10
31#define AB8500_DEBUG 0x12
32#define AB8500_PROD_TEST 0x13
33#define AB8500_OTP_EMUL 0x15
34
35/*
13 * Interrupts 36 * Interrupts
14 */ 37 */
15 38
@@ -51,40 +74,84 @@
51#define AB8500_INT_ACC_DETECT_21DB_F 37 74#define AB8500_INT_ACC_DETECT_21DB_F 37
52#define AB8500_INT_ACC_DETECT_21DB_R 38 75#define AB8500_INT_ACC_DETECT_21DB_R 38
53#define AB8500_INT_GP_SW_ADC_CONV_END 39 76#define AB8500_INT_GP_SW_ADC_CONV_END 39
54#define AB8500_INT_BTEMP_LOW 72 77#define AB8500_INT_ACC_DETECT_1DB_F 33
55#define AB8500_INT_BTEMP_LOW_MEDIUM 73 78#define AB8500_INT_ACC_DETECT_1DB_R 34
56#define AB8500_INT_BTEMP_MEDIUM_HIGH 74 79#define AB8500_INT_ACC_DETECT_22DB_F 35
57#define AB8500_INT_BTEMP_HIGH 75 80#define AB8500_INT_ACC_DETECT_22DB_R 36
58#define AB8500_INT_USB_CHARGER_NOT_OK 81 81#define AB8500_INT_ACC_DETECT_21DB_F 37
59#define AB8500_INT_ID_WAKEUP_R 82 82#define AB8500_INT_ACC_DETECT_21DB_R 38
60#define AB8500_INT_ID_DET_R1R 84 83#define AB8500_INT_GP_SW_ADC_CONV_END 39
61#define AB8500_INT_ID_DET_R2R 85 84#define AB8500_INT_GPIO6R 40
62#define AB8500_INT_ID_DET_R3R 86 85#define AB8500_INT_GPIO7R 41
63#define AB8500_INT_ID_DET_R4R 87 86#define AB8500_INT_GPIO8R 42
64#define AB8500_INT_ID_WAKEUP_F 88 87#define AB8500_INT_GPIO9R 43
65#define AB8500_INT_ID_DET_R1F 90 88#define AB8500_INT_GPIO10R 44
66#define AB8500_INT_ID_DET_R2F 91 89#define AB8500_INT_GPIO11R 45
67#define AB8500_INT_ID_DET_R3F 92 90#define AB8500_INT_GPIO12R 46
68#define AB8500_INT_ID_DET_R4F 93 91#define AB8500_INT_GPIO13R 47
69#define AB8500_INT_USB_CHG_DET_DONE 94 92#define AB8500_INT_GPIO24R 48
70#define AB8500_INT_USB_CH_TH_PROT_F 96 93#define AB8500_INT_GPIO25R 49
71#define AB8500_INT_USB_CH_TH_PROP_R 97 94#define AB8500_INT_GPIO36R 50
72#define AB8500_INT_MAIN_CH_TH_PROP_F 98 95#define AB8500_INT_GPIO37R 51
73#define AB8500_INT_MAIN_CH_TH_PROT_R 99 96#define AB8500_INT_GPIO38R 52
74#define AB8500_INT_USB_CHARGER_NOT_OKF 103 97#define AB8500_INT_GPIO39R 53
75 98#define AB8500_INT_GPIO40R 54
76#define AB8500_NR_IRQS 104 99#define AB8500_INT_GPIO41R 55
77#define AB8500_NUM_IRQ_REGS 13 100#define AB8500_INT_GPIO6F 56
101#define AB8500_INT_GPIO7F 57
102#define AB8500_INT_GPIO8F 58
103#define AB8500_INT_GPIO9F 59
104#define AB8500_INT_GPIO10F 60
105#define AB8500_INT_GPIO11F 61
106#define AB8500_INT_GPIO12F 62
107#define AB8500_INT_GPIO13F 63
108#define AB8500_INT_GPIO24F 64
109#define AB8500_INT_GPIO25F 65
110#define AB8500_INT_GPIO36F 66
111#define AB8500_INT_GPIO37F 67
112#define AB8500_INT_GPIO38F 68
113#define AB8500_INT_GPIO39F 69
114#define AB8500_INT_GPIO40F 70
115#define AB8500_INT_GPIO41F 71
116#define AB8500_INT_ADP_SOURCE_ERROR 72
117#define AB8500_INT_ADP_SINK_ERROR 73
118#define AB8500_INT_ADP_PROBE_PLUG 74
119#define AB8500_INT_ADP_PROBE_UNPLUG 75
120#define AB8500_INT_ADP_SENSE_OFF 76
121#define AB8500_INT_USB_PHY_POWER_ERR 78
122#define AB8500_INT_USB_LINK_STATUS 79
123#define AB8500_INT_BTEMP_LOW 80
124#define AB8500_INT_BTEMP_LOW_MEDIUM 81
125#define AB8500_INT_BTEMP_MEDIUM_HIGH 82
126#define AB8500_INT_BTEMP_HIGH 83
127#define AB8500_INT_USB_CHARGER_NOT_OK 89
128#define AB8500_INT_ID_WAKEUP_R 90
129#define AB8500_INT_ID_DET_R1R 92
130#define AB8500_INT_ID_DET_R2R 93
131#define AB8500_INT_ID_DET_R3R 94
132#define AB8500_INT_ID_DET_R4R 95
133#define AB8500_INT_ID_WAKEUP_F 96
134#define AB8500_INT_ID_DET_R1F 98
135#define AB8500_INT_ID_DET_R2F 99
136#define AB8500_INT_ID_DET_R3F 100
137#define AB8500_INT_ID_DET_R4F 101
138#define AB8500_INT_USB_CHG_DET_DONE 102
139#define AB8500_INT_USB_CH_TH_PROT_F 104
140#define AB8500_INT_USB_CH_TH_PROT_R 105
141#define AB8500_INT_MAIN_CH_TH_PROT_F 106
142#define AB8500_INT_MAIN_CH_TH_PROT_R 107
143#define AB8500_INT_USB_CHARGER_NOT_OKF 111
78 144
79#define AB8500_NUM_REGULATORS 15 145#define AB8500_NR_IRQS 112
146#define AB8500_NUM_IRQ_REGS 14
80 147
81/** 148/**
82 * struct ab8500 - ab8500 internal structure 149 * struct ab8500 - ab8500 internal structure
83 * @dev: parent device 150 * @dev: parent device
84 * @lock: read/write operations lock 151 * @lock: read/write operations lock
85 * @irq_lock: genirq bus lock 152 * @irq_lock: genirq bus lock
86 * @revision: chip revision
87 * @irq: irq line 153 * @irq: irq line
154 * @chip_id: chip revision id
88 * @write: register write 155 * @write: register write
89 * @read: register read 156 * @read: register read
90 * @rx_buf: rx buf for SPI 157 * @rx_buf: rx buf for SPI
@@ -96,9 +163,10 @@ struct ab8500 {
96 struct device *dev; 163 struct device *dev;
97 struct mutex lock; 164 struct mutex lock;
98 struct mutex irq_lock; 165 struct mutex irq_lock;
99 int revision; 166
100 int irq_base; 167 int irq_base;
101 int irq; 168 int irq;
169 u8 chip_id;
102 170
103 int (*write) (struct ab8500 *a8500, u16 addr, u8 data); 171 int (*write) (struct ab8500 *a8500, u16 addr, u8 data);
104 int (*read) (struct ab8500 *a8500, u16 addr); 172 int (*read) (struct ab8500 *a8500, u16 addr);
@@ -110,24 +178,29 @@ struct ab8500 {
110 u8 oldmask[AB8500_NUM_IRQ_REGS]; 178 u8 oldmask[AB8500_NUM_IRQ_REGS];
111}; 179};
112 180
181struct regulator_reg_init;
113struct regulator_init_data; 182struct regulator_init_data;
183struct ab8500_gpio_platform_data;
114 184
115/** 185/**
116 * struct ab8500_platform_data - AB8500 platform data 186 * struct ab8500_platform_data - AB8500 platform data
117 * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used 187 * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used
118 * @init: board-specific initialization after detection of ab8500 188 * @init: board-specific initialization after detection of ab8500
189 * @num_regulator_reg_init: number of regulator init registers
190 * @regulator_reg_init: regulator init registers
191 * @num_regulator: number of regulators
119 * @regulator: machine-specific constraints for regulators 192 * @regulator: machine-specific constraints for regulators
120 */ 193 */
121struct ab8500_platform_data { 194struct ab8500_platform_data {
122 int irq_base; 195 int irq_base;
123 void (*init) (struct ab8500 *); 196 void (*init) (struct ab8500 *);
124 struct regulator_init_data *regulator[AB8500_NUM_REGULATORS]; 197 int num_regulator_reg_init;
198 struct ab8500_regulator_reg_init *regulator_reg_init;
199 int num_regulator;
200 struct regulator_init_data *regulator;
201 struct ab8500_gpio_platform_data *gpio;
125}; 202};
126 203
127extern int ab8500_write(struct ab8500 *a8500, u16 addr, u8 data);
128extern int ab8500_read(struct ab8500 *a8500, u16 addr);
129extern int ab8500_set_bits(struct ab8500 *a8500, u16 addr, u8 mask, u8 data);
130
131extern int __devinit ab8500_init(struct ab8500 *ab8500); 204extern int __devinit ab8500_init(struct ab8500 *ab8500);
132extern int __devexit ab8500_exit(struct ab8500 *ab8500); 205extern int __devexit ab8500_exit(struct ab8500 *ab8500);
133 206
diff --git a/include/linux/mfd/ab8500/gpadc.h b/include/linux/mfd/ab8500/gpadc.h
new file mode 100644
index 000000000000..46b954011f16
--- /dev/null
+++ b/include/linux/mfd/ab8500/gpadc.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2010 ST-Ericsson SA
3 * Licensed under GPLv2.
4 *
5 * Author: Arun R Murthy <arun.murthy@stericsson.com>
6 * Author: Daniel Willerud <daniel.willerud@stericsson.com>
7 */
8
9#ifndef _AB8500_GPADC_H
10#define _AB8500_GPADC_H
11
12/* GPADC source: From datasheet(ADCSwSel[4:0] in GPADCCtrl2) */
13#define BAT_CTRL 0x01
14#define BTEMP_BALL 0x02
15#define MAIN_CHARGER_V 0x03
16#define ACC_DETECT1 0x04
17#define ACC_DETECT2 0x05
18#define ADC_AUX1 0x06
19#define ADC_AUX2 0x07
20#define MAIN_BAT_V 0x08
21#define VBUS_V 0x09
22#define MAIN_CHARGER_C 0x0A
23#define USB_CHARGER_C 0x0B
24#define BK_BAT_V 0x0C
25#define DIE_TEMP 0x0D
26
27struct ab8500_gpadc;
28
29struct ab8500_gpadc *ab8500_gpadc_get(char *name);
30int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 input);
31
32#endif /* _AB8500_GPADC_H */
diff --git a/include/linux/mfd/ab8500/gpio.h b/include/linux/mfd/ab8500/gpio.h
new file mode 100644
index 000000000000..488a8c920a29
--- /dev/null
+++ b/include/linux/mfd/ab8500/gpio.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright ST-Ericsson 2010.
3 *
4 * Author: Bibek Basu <bibek.basu@stericsson.com>
5 * Licensed under GPLv2.
6 */
7
8#ifndef _AB8500_GPIO_H
9#define _AB8500_GPIO_H
10
11/*
12 * Platform data to register a block: only the initial gpio/irq number.
13 */
14
15struct ab8500_gpio_platform_data {
16 int gpio_base;
17 u32 irq_base;
18 u8 config_reg[7];
19};
20
21#endif /* _AB8500_GPIO_H */
diff --git a/include/linux/mfd/ab8500/sysctrl.h b/include/linux/mfd/ab8500/sysctrl.h
new file mode 100644
index 000000000000..10da0291f8f8
--- /dev/null
+++ b/include/linux/mfd/ab8500/sysctrl.h
@@ -0,0 +1,254 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> for ST Ericsson.
4 * License terms: GNU General Public License (GPL) version 2
5 */
6#ifndef __AB8500_SYSCTRL_H
7#define __AB8500_SYSCTRL_H
8
9#include <linux/bitops.h>
10
11#ifdef CONFIG_AB8500_CORE
12
13int ab8500_sysctrl_read(u16 reg, u8 *value);
14int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value);
15
16#else
17
18static inline int ab8500_sysctrl_read(u16 reg, u8 *value)
19{
20 return 0;
21}
22
23static inline int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
24{
25 return 0;
26}
27
28#endif /* CONFIG_AB8500_CORE */
29
30static inline int ab8500_sysctrl_set(u16 reg, u8 bits)
31{
32 return ab8500_sysctrl_write(reg, bits, bits);
33}
34
35static inline int ab8500_sysctrl_clear(u16 reg, u8 bits)
36{
37 return ab8500_sysctrl_write(reg, bits, 0);
38}
39
40/* Registers */
41#define AB8500_TURNONSTATUS 0x100
42#define AB8500_RESETSTATUS 0x101
43#define AB8500_PONKEY1PRESSSTATUS 0x102
44#define AB8500_SYSCLKREQSTATUS 0x142
45#define AB8500_STW4500CTRL1 0x180
46#define AB8500_STW4500CTRL2 0x181
47#define AB8500_STW4500CTRL3 0x200
48#define AB8500_MAINWDOGCTRL 0x201
49#define AB8500_MAINWDOGTIMER 0x202
50#define AB8500_LOWBAT 0x203
51#define AB8500_BATTOK 0x204
52#define AB8500_SYSCLKTIMER 0x205
53#define AB8500_SMPSCLKCTRL 0x206
54#define AB8500_SMPSCLKSEL1 0x207
55#define AB8500_SMPSCLKSEL2 0x208
56#define AB8500_SMPSCLKSEL3 0x209
57#define AB8500_SYSULPCLKCONF 0x20A
58#define AB8500_SYSULPCLKCTRL1 0x20B
59#define AB8500_SYSCLKCTRL 0x20C
60#define AB8500_SYSCLKREQ1VALID 0x20D
61#define AB8500_SYSTEMCTRLSUP 0x20F
62#define AB8500_SYSCLKREQ1RFCLKBUF 0x210
63#define AB8500_SYSCLKREQ2RFCLKBUF 0x211
64#define AB8500_SYSCLKREQ3RFCLKBUF 0x212
65#define AB8500_SYSCLKREQ4RFCLKBUF 0x213
66#define AB8500_SYSCLKREQ5RFCLKBUF 0x214
67#define AB8500_SYSCLKREQ6RFCLKBUF 0x215
68#define AB8500_SYSCLKREQ7RFCLKBUF 0x216
69#define AB8500_SYSCLKREQ8RFCLKBUF 0x217
70#define AB8500_DITHERCLKCTRL 0x220
71#define AB8500_SWATCTRL 0x230
72#define AB8500_HIQCLKCTRL 0x232
73#define AB8500_VSIMSYSCLKCTRL 0x233
74
75/* Bits */
76#define AB8500_TURNONSTATUS_PORNVBAT BIT(0)
77#define AB8500_TURNONSTATUS_PONKEY1DBF BIT(1)
78#define AB8500_TURNONSTATUS_PONKEY2DBF BIT(2)
79#define AB8500_TURNONSTATUS_RTCALARM BIT(3)
80#define AB8500_TURNONSTATUS_MAINCHDET BIT(4)
81#define AB8500_TURNONSTATUS_VBUSDET BIT(5)
82#define AB8500_TURNONSTATUS_USBIDDETECT BIT(6)
83
84#define AB8500_RESETSTATUS_RESETN4500NSTATUS BIT(0)
85#define AB8500_RESETSTATUS_SWRESETN4500NSTATUS BIT(2)
86
87#define AB8500_PONKEY1PRESSSTATUS_PONKEY1PRESSTIME_MASK 0x7F
88#define AB8500_PONKEY1PRESSSTATUS_PONKEY1PRESSTIME_SHIFT 0
89
90#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ1STATUS BIT(0)
91#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ2STATUS BIT(1)
92#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ3STATUS BIT(2)
93#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ4STATUS BIT(3)
94#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ5STATUS BIT(4)
95#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ6STATUS BIT(5)
96#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ7STATUS BIT(6)
97#define AB8500_SYSCLKREQSTATUS_SYSCLKREQ8STATUS BIT(7)
98
99#define AB8500_STW4500CTRL1_SWOFF BIT(0)
100#define AB8500_STW4500CTRL1_SWRESET4500N BIT(1)
101#define AB8500_STW4500CTRL1_THDB8500SWOFF BIT(2)
102
103#define AB8500_STW4500CTRL2_RESETNVAUX1VALID BIT(0)
104#define AB8500_STW4500CTRL2_RESETNVAUX2VALID BIT(1)
105#define AB8500_STW4500CTRL2_RESETNVAUX3VALID BIT(2)
106#define AB8500_STW4500CTRL2_RESETNVMODVALID BIT(3)
107#define AB8500_STW4500CTRL2_RESETNVEXTSUPPLY1VALID BIT(4)
108#define AB8500_STW4500CTRL2_RESETNVEXTSUPPLY2VALID BIT(5)
109#define AB8500_STW4500CTRL2_RESETNVEXTSUPPLY3VALID BIT(6)
110#define AB8500_STW4500CTRL2_RESETNVSMPS1VALID BIT(7)
111
112#define AB8500_STW4500CTRL3_CLK32KOUT2DIS BIT(0)
113#define AB8500_STW4500CTRL3_RESETAUDN BIT(1)
114#define AB8500_STW4500CTRL3_RESETDENCN BIT(2)
115#define AB8500_STW4500CTRL3_THSDENA BIT(3)
116
117#define AB8500_MAINWDOGCTRL_MAINWDOGENA BIT(0)
118#define AB8500_MAINWDOGCTRL_MAINWDOGKICK BIT(1)
119#define AB8500_MAINWDOGCTRL_WDEXPTURNONVALID BIT(4)
120
121#define AB8500_MAINWDOGTIMER_MAINWDOGTIMER_MASK 0x7F
122#define AB8500_MAINWDOGTIMER_MAINWDOGTIMER_SHIFT 0
123
124#define AB8500_LOWBAT_LOWBATENA BIT(0)
125#define AB8500_LOWBAT_LOWBAT_MASK 0x7E
126#define AB8500_LOWBAT_LOWBAT_SHIFT 1
127
128#define AB8500_BATTOK_BATTOKSEL0THF_MASK 0x0F
129#define AB8500_BATTOK_BATTOKSEL0THF_SHIFT 0
130#define AB8500_BATTOK_BATTOKSEL1THF_MASK 0xF0
131#define AB8500_BATTOK_BATTOKSEL1THF_SHIFT 4
132
133#define AB8500_SYSCLKTIMER_SYSCLKTIMER_MASK 0x0F
134#define AB8500_SYSCLKTIMER_SYSCLKTIMER_SHIFT 0
135#define AB8500_SYSCLKTIMER_SYSCLKTIMERADJ_MASK 0xF0
136#define AB8500_SYSCLKTIMER_SYSCLKTIMERADJ_SHIFT 4
137
138#define AB8500_SMPSCLKCTRL_SMPSCLKINTSEL_MASK 0x03
139#define AB8500_SMPSCLKCTRL_SMPSCLKINTSEL_SHIFT 0
140#define AB8500_SMPSCLKCTRL_3M2CLKINTENA BIT(2)
141
142#define AB8500_SMPSCLKSEL1_VARMCLKSEL_MASK 0x07
143#define AB8500_SMPSCLKSEL1_VARMCLKSEL_SHIFT 0
144#define AB8500_SMPSCLKSEL1_VAPECLKSEL_MASK 0x38
145#define AB8500_SMPSCLKSEL1_VAPECLKSEL_SHIFT 3
146
147#define AB8500_SMPSCLKSEL2_VMODCLKSEL_MASK 0x07
148#define AB8500_SMPSCLKSEL2_VMODCLKSEL_SHIFT 0
149#define AB8500_SMPSCLKSEL2_VSMPS1CLKSEL_MASK 0x38
150#define AB8500_SMPSCLKSEL2_VSMPS1CLKSEL_SHIFT 3
151
152#define AB8500_SMPSCLKSEL3_VSMPS2CLKSEL_MASK 0x07
153#define AB8500_SMPSCLKSEL3_VSMPS2CLKSEL_SHIFT 0
154#define AB8500_SMPSCLKSEL3_VSMPS3CLKSEL_MASK 0x38
155#define AB8500_SMPSCLKSEL3_VSMPS3CLKSEL_SHIFT 3
156
157#define AB8500_SYSULPCLKCONF_ULPCLKCONF_MASK 0x03
158#define AB8500_SYSULPCLKCONF_ULPCLKCONF_SHIFT 0
159#define AB8500_SYSULPCLKCONF_CLK27MHZSTRE BIT(2)
160#define AB8500_SYSULPCLKCONF_TVOUTCLKDELN BIT(3)
161#define AB8500_SYSULPCLKCONF_TVOUTCLKINV BIT(4)
162#define AB8500_SYSULPCLKCONF_ULPCLKSTRE BIT(5)
163#define AB8500_SYSULPCLKCONF_CLK27MHZBUFENA BIT(6)
164#define AB8500_SYSULPCLKCONF_CLK27MHZPDENA BIT(7)
165
166#define AB8500_SYSULPCLKCTRL1_SYSULPCLKINTSEL_MASK 0x03
167#define AB8500_SYSULPCLKCTRL1_SYSULPCLKINTSEL_SHIFT 0
168#define AB8500_SYSULPCLKCTRL1_ULPCLKREQ BIT(2)
169#define AB8500_SYSULPCLKCTRL1_4500SYSCLKREQ BIT(3)
170#define AB8500_SYSULPCLKCTRL1_AUDIOCLKENA BIT(4)
171#define AB8500_SYSULPCLKCTRL1_SYSCLKBUF2REQ BIT(5)
172#define AB8500_SYSULPCLKCTRL1_SYSCLKBUF3REQ BIT(6)
173#define AB8500_SYSULPCLKCTRL1_SYSCLKBUF4REQ BIT(7)
174
175#define AB8500_SYSCLKCTRL_TVOUTPLLENA BIT(0)
176#define AB8500_SYSCLKCTRL_TVOUTCLKENA BIT(1)
177#define AB8500_SYSCLKCTRL_USBCLKENA BIT(2)
178
179#define AB8500_SYSCLKREQ1VALID_SYSCLKREQ1VALID BIT(0)
180#define AB8500_SYSCLKREQ1VALID_ULPCLKREQ1VALID BIT(1)
181#define AB8500_SYSCLKREQ1VALID_USBSYSCLKREQ1VALID BIT(2)
182
183#define AB8500_SYSTEMCTRLSUP_EXTSUP12LPNCLKSEL_MASK 0x03
184#define AB8500_SYSTEMCTRLSUP_EXTSUP12LPNCLKSEL_SHIFT 0
185#define AB8500_SYSTEMCTRLSUP_EXTSUP3LPNCLKSEL_MASK 0x0C
186#define AB8500_SYSTEMCTRLSUP_EXTSUP3LPNCLKSEL_SHIFT 2
187#define AB8500_SYSTEMCTRLSUP_INTDB8500NOD BIT(4)
188
189#define AB8500_SYSCLKREQ1RFCLKBUF_SYSCLKREQ1RFCLKBUF2 BIT(2)
190#define AB8500_SYSCLKREQ1RFCLKBUF_SYSCLKREQ1RFCLKBUF3 BIT(3)
191#define AB8500_SYSCLKREQ1RFCLKBUF_SYSCLKREQ1RFCLKBUF4 BIT(4)
192
193#define AB8500_SYSCLKREQ2RFCLKBUF_SYSCLKREQ2RFCLKBUF2 BIT(2)
194#define AB8500_SYSCLKREQ2RFCLKBUF_SYSCLKREQ2RFCLKBUF3 BIT(3)
195#define AB8500_SYSCLKREQ2RFCLKBUF_SYSCLKREQ2RFCLKBUF4 BIT(4)
196
197#define AB8500_SYSCLKREQ3RFCLKBUF_SYSCLKREQ3RFCLKBUF2 BIT(2)
198#define AB8500_SYSCLKREQ3RFCLKBUF_SYSCLKREQ3RFCLKBUF3 BIT(3)
199#define AB8500_SYSCLKREQ3RFCLKBUF_SYSCLKREQ3RFCLKBUF4 BIT(4)
200
201#define AB8500_SYSCLKREQ4RFCLKBUF_SYSCLKREQ4RFCLKBUF2 BIT(2)
202#define AB8500_SYSCLKREQ4RFCLKBUF_SYSCLKREQ4RFCLKBUF3 BIT(3)
203#define AB8500_SYSCLKREQ4RFCLKBUF_SYSCLKREQ4RFCLKBUF4 BIT(4)
204
205#define AB8500_SYSCLKREQ5RFCLKBUF_SYSCLKREQ5RFCLKBUF2 BIT(2)
206#define AB8500_SYSCLKREQ5RFCLKBUF_SYSCLKREQ5RFCLKBUF3 BIT(3)
207#define AB8500_SYSCLKREQ5RFCLKBUF_SYSCLKREQ5RFCLKBUF4 BIT(4)
208
209#define AB8500_SYSCLKREQ6RFCLKBUF_SYSCLKREQ6RFCLKBUF2 BIT(2)
210#define AB8500_SYSCLKREQ6RFCLKBUF_SYSCLKREQ6RFCLKBUF3 BIT(3)
211#define AB8500_SYSCLKREQ6RFCLKBUF_SYSCLKREQ6RFCLKBUF4 BIT(4)
212
213#define AB8500_SYSCLKREQ7RFCLKBUF_SYSCLKREQ7RFCLKBUF2 BIT(2)
214#define AB8500_SYSCLKREQ7RFCLKBUF_SYSCLKREQ7RFCLKBUF3 BIT(3)
215#define AB8500_SYSCLKREQ7RFCLKBUF_SYSCLKREQ7RFCLKBUF4 BIT(4)
216
217#define AB8500_SYSCLKREQ8RFCLKBUF_SYSCLKREQ8RFCLKBUF2 BIT(2)
218#define AB8500_SYSCLKREQ8RFCLKBUF_SYSCLKREQ8RFCLKBUF3 BIT(3)
219#define AB8500_SYSCLKREQ8RFCLKBUF_SYSCLKREQ8RFCLKBUF4 BIT(4)
220
221#define AB8500_DITHERCLKCTRL_VARMDITHERENA BIT(0)
222#define AB8500_DITHERCLKCTRL_VSMPS3DITHERENA BIT(1)
223#define AB8500_DITHERCLKCTRL_VSMPS1DITHERENA BIT(2)
224#define AB8500_DITHERCLKCTRL_VSMPS2DITHERENA BIT(3)
225#define AB8500_DITHERCLKCTRL_VMODDITHERENA BIT(4)
226#define AB8500_DITHERCLKCTRL_VAPEDITHERENA BIT(5)
227#define AB8500_DITHERCLKCTRL_DITHERDEL_MASK 0xC0
228#define AB8500_DITHERCLKCTRL_DITHERDEL_SHIFT 6
229
230#define AB8500_SWATCTRL_UPDATERF BIT(0)
231#define AB8500_SWATCTRL_SWATENABLE BIT(1)
232#define AB8500_SWATCTRL_RFOFFTIMER_MASK 0x1C
233#define AB8500_SWATCTRL_RFOFFTIMER_SHIFT 2
234#define AB8500_SWATCTRL_SWATBIT5 BIT(6)
235
236#define AB8500_HIQCLKCTRL_SYSCLKREQ1HIQENAVALID BIT(0)
237#define AB8500_HIQCLKCTRL_SYSCLKREQ2HIQENAVALID BIT(1)
238#define AB8500_HIQCLKCTRL_SYSCLKREQ3HIQENAVALID BIT(2)
239#define AB8500_HIQCLKCTRL_SYSCLKREQ4HIQENAVALID BIT(3)
240#define AB8500_HIQCLKCTRL_SYSCLKREQ5HIQENAVALID BIT(4)
241#define AB8500_HIQCLKCTRL_SYSCLKREQ6HIQENAVALID BIT(5)
242#define AB8500_HIQCLKCTRL_SYSCLKREQ7HIQENAVALID BIT(6)
243#define AB8500_HIQCLKCTRL_SYSCLKREQ8HIQENAVALID BIT(7)
244
245#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ1VALID BIT(0)
246#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ2VALID BIT(1)
247#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ3VALID BIT(2)
248#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ4VALID BIT(3)
249#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ5VALID BIT(4)
250#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ6VALID BIT(5)
251#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ7VALID BIT(6)
252#define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ8VALID BIT(7)
253
254#endif /* __AB8500_SYSCTRL_H */
diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h
index 390726fcbcb1..896b5e47f16e 100644
--- a/include/linux/mfd/abx500.h
+++ b/include/linux/mfd/abx500.h
@@ -6,8 +6,7 @@
6 * 6 *
7 * ABX500 core access functions. 7 * ABX500 core access functions.
8 * The abx500 interface is used for the Analog Baseband chip 8 * The abx500 interface is used for the Analog Baseband chip
9 * ab3100, ab3550, ab5500 and possibly comming. It is not used for 9 * ab3100, ab3550, ab5500, and ab8500.
10 * ab4500 and ab8500 since they are another family of chip.
11 * 10 *
12 * Author: Mattias Wallin <mattias.wallin@stericsson.com> 11 * Author: Mattias Wallin <mattias.wallin@stericsson.com>
13 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> 12 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com>
@@ -35,6 +34,13 @@
35#define AB5500_2_0 0x21 34#define AB5500_2_0 0x21
36#define AB5500_2_1 0x22 35#define AB5500_2_1 0x22
37 36
37/* AB8500 CIDs*/
38#define AB8500_CUTEARLY 0x00
39#define AB8500_CUT1P0 0x10
40#define AB8500_CUT1P1 0x11
41#define AB8500_CUT2P0 0x20
42#define AB8500_CUT3P0 0x30
43
38/* 44/*
39 * AB3100, EVENTA1, A2 and A3 event register flags 45 * AB3100, EVENTA1, A2 and A3 event register flags
40 * these are catenated into a single 32-bit flag in the code 46 * these are catenated into a single 32-bit flag in the code
@@ -230,4 +236,5 @@ struct abx500_ops {
230}; 236};
231 237
232int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops); 238int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops);
239void abx500_remove_ops(struct device *dev);
233#endif 240#endif
diff --git a/include/linux/mfd/asic3.h b/include/linux/mfd/asic3.h
index de3c4ad19afb..ed793b77a1c5 100644
--- a/include/linux/mfd/asic3.h
+++ b/include/linux/mfd/asic3.h
@@ -16,6 +16,13 @@
16 16
17#include <linux/types.h> 17#include <linux/types.h>
18 18
19struct led_classdev;
20struct asic3_led {
21 const char *name;
22 const char *default_trigger;
23 struct led_classdev *cdev;
24};
25
19struct asic3_platform_data { 26struct asic3_platform_data {
20 u16 *gpio_config; 27 u16 *gpio_config;
21 unsigned int gpio_config_num; 28 unsigned int gpio_config_num;
@@ -23,6 +30,8 @@ struct asic3_platform_data {
23 unsigned int irq_base; 30 unsigned int irq_base;
24 31
25 unsigned int gpio_base; 32 unsigned int gpio_base;
33
34 struct asic3_led *leds;
26}; 35};
27 36
28#define ASIC3_NUM_GPIO_BANKS 4 37#define ASIC3_NUM_GPIO_BANKS 4
@@ -111,9 +120,9 @@ struct asic3_platform_data {
111#define ASIC3_GPIOA11_PWM0 ASIC3_CONFIG_GPIO(11, 1, 1, 0) 120#define ASIC3_GPIOA11_PWM0 ASIC3_CONFIG_GPIO(11, 1, 1, 0)
112#define ASIC3_GPIOA12_PWM1 ASIC3_CONFIG_GPIO(12, 1, 1, 0) 121#define ASIC3_GPIOA12_PWM1 ASIC3_CONFIG_GPIO(12, 1, 1, 0)
113#define ASIC3_GPIOA15_CONTROL_CX ASIC3_CONFIG_GPIO(15, 1, 1, 0) 122#define ASIC3_GPIOA15_CONTROL_CX ASIC3_CONFIG_GPIO(15, 1, 1, 0)
114#define ASIC3_GPIOC0_LED0 ASIC3_CONFIG_GPIO(32, 1, 1, 0) 123#define ASIC3_GPIOC0_LED0 ASIC3_CONFIG_GPIO(32, 1, 0, 0)
115#define ASIC3_GPIOC1_LED1 ASIC3_CONFIG_GPIO(33, 1, 1, 0) 124#define ASIC3_GPIOC1_LED1 ASIC3_CONFIG_GPIO(33, 1, 0, 0)
116#define ASIC3_GPIOC2_LED2 ASIC3_CONFIG_GPIO(34, 1, 1, 0) 125#define ASIC3_GPIOC2_LED2 ASIC3_CONFIG_GPIO(34, 1, 0, 0)
117#define ASIC3_GPIOC3_SPI_RXD ASIC3_CONFIG_GPIO(35, 1, 0, 0) 126#define ASIC3_GPIOC3_SPI_RXD ASIC3_CONFIG_GPIO(35, 1, 0, 0)
118#define ASIC3_GPIOC4_CF_nCD ASIC3_CONFIG_GPIO(36, 1, 0, 0) 127#define ASIC3_GPIOC4_CF_nCD ASIC3_CONFIG_GPIO(36, 1, 0, 0)
119#define ASIC3_GPIOC4_SPI_TXD ASIC3_CONFIG_GPIO(36, 1, 1, 0) 128#define ASIC3_GPIOC4_SPI_TXD ASIC3_CONFIG_GPIO(36, 1, 1, 0)
@@ -152,6 +161,7 @@ struct asic3_platform_data {
152#define PWM_TIMEBASE_VALUE(x) ((x)&0xf) /* Low 4 bits sets time base */ 161#define PWM_TIMEBASE_VALUE(x) ((x)&0xf) /* Low 4 bits sets time base */
153#define PWM_TIMEBASE_ENABLE (1 << 4) /* Enable clock */ 162#define PWM_TIMEBASE_ENABLE (1 << 4) /* Enable clock */
154 163
164#define ASIC3_NUM_LEDS 3
155#define ASIC3_LED_0_Base 0x0700 165#define ASIC3_LED_0_Base 0x0700
156#define ASIC3_LED_1_Base 0x0800 166#define ASIC3_LED_1_Base 0x0800
157#define ASIC3_LED_2_Base 0x0900 167#define ASIC3_LED_2_Base 0x0900
@@ -287,10 +297,17 @@ struct asic3_platform_data {
287 * 297 *
288 *****************************************************************************/ 298 *****************************************************************************/
289#define ASIC3_SD_CONFIG_BASE 0x0400 /* Assumes 32 bit addressing */ 299#define ASIC3_SD_CONFIG_BASE 0x0400 /* Assumes 32 bit addressing */
300#define ASIC3_SD_CONFIG_SIZE 0x0200 /* Assumes 32 bit addressing */
290#define ASIC3_SD_CTRL_BASE 0x1000 301#define ASIC3_SD_CTRL_BASE 0x1000
291#define ASIC3_SDIO_CTRL_BASE 0x1200 302#define ASIC3_SDIO_CTRL_BASE 0x1200
292 303
293#define ASIC3_MAP_SIZE_32BIT 0x2000 304#define ASIC3_MAP_SIZE_32BIT 0x2000
294#define ASIC3_MAP_SIZE_16BIT 0x1000 305#define ASIC3_MAP_SIZE_16BIT 0x1000
295 306
307/* Functions needed by leds-asic3 */
308
309struct asic3;
310extern void asic3_write_register(struct asic3 *asic, unsigned int reg, u32 val);
311extern u32 asic3_read_register(struct asic3 *asic, unsigned int reg);
312
296#endif /* __ASIC3_H__ */ 313#endif /* __ASIC3_H__ */
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 11d740b8831d..4e76163dd862 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -25,29 +25,73 @@ struct mfd_cell {
25 const char *name; 25 const char *name;
26 int id; 26 int id;
27 27
28 /* refcounting for multiple drivers to use a single cell */
29 atomic_t *usage_count;
28 int (*enable)(struct platform_device *dev); 30 int (*enable)(struct platform_device *dev);
29 int (*disable)(struct platform_device *dev); 31 int (*disable)(struct platform_device *dev);
32
30 int (*suspend)(struct platform_device *dev); 33 int (*suspend)(struct platform_device *dev);
31 int (*resume)(struct platform_device *dev); 34 int (*resume)(struct platform_device *dev);
32 35
33 /* driver-specific data for MFD-aware "cell" drivers */ 36 /* platform data passed to the sub devices drivers */
34 void *driver_data;
35
36 /* platform_data can be used to either pass data to "generic"
37 driver or as a hook to mfd_cell for the "cell" drivers */
38 void *platform_data; 37 void *platform_data;
39 size_t data_size; 38 size_t pdata_size;
40 39
41 /* 40 /*
42 * This resources can be specified relatievly to the parent device. 41 * These resources can be specified relative to the parent device.
43 * For accessing device you should use resources from device 42 * For accessing hardware you should use resources from the platform dev
44 */ 43 */
45 int num_resources; 44 int num_resources;
46 const struct resource *resources; 45 const struct resource *resources;
46
47 /* don't check for resource conflicts */
48 bool ignore_resource_conflicts;
49
50 /*
51 * Disable runtime PM callbacks for this subdevice - see
52 * pm_runtime_no_callbacks().
53 */
54 bool pm_runtime_no_callbacks;
47}; 55};
48 56
57/*
58 * Convenience functions for clients using shared cells. Refcounting
59 * happens automatically, with the cell's enable/disable callbacks
60 * being called only when a device is first being enabled or no other
61 * clients are making use of it.
62 */
63extern int mfd_cell_enable(struct platform_device *pdev);
64extern int mfd_cell_disable(struct platform_device *pdev);
65
66/*
67 * "Clone" multiple platform devices for a single cell. This is to be used
68 * for devices that have multiple users of a cell. For example, if an mfd
69 * driver wants the cell "foo" to be used by a GPIO driver, an MTD driver,
70 * and a platform driver, the following bit of code would be use after first
71 * calling mfd_add_devices():
72 *
73 * const char *fclones[] = { "foo-gpio", "foo-mtd" };
74 * err = mfd_clone_cells("foo", fclones, ARRAY_SIZE(fclones));
75 *
76 * Each driver (MTD, GPIO, and platform driver) would then register
77 * platform_drivers for "foo-mtd", "foo-gpio", and "foo", respectively.
78 * The cell's .enable/.disable hooks should be used to deal with hardware
79 * resource contention.
80 */
81extern int mfd_clone_cell(const char *cell, const char **clones,
82 size_t n_clones);
83
84/*
85 * Given a platform device that's been created by mfd_add_devices(), fetch
86 * the mfd_cell that created it.
87 */
88static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
89{
90 return pdev->mfd_cell;
91}
92
49extern int mfd_add_devices(struct device *parent, int id, 93extern int mfd_add_devices(struct device *parent, int id,
50 const struct mfd_cell *cells, int n_devs, 94 struct mfd_cell *cells, int n_devs,
51 struct resource *mem_base, 95 struct resource *mem_base,
52 int irq_base); 96 int irq_base);
53 97
diff --git a/include/linux/mfd/db5500-prcmu.h b/include/linux/mfd/db5500-prcmu.h
new file mode 100644
index 000000000000..f0977986402c
--- /dev/null
+++ b/include/linux/mfd/db5500-prcmu.h
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 *
6 * U5500 PRCMU API.
7 */
8#ifndef __MACH_PRCMU_U5500_H
9#define __MACH_PRCMU_U5500_H
10
11#ifdef CONFIG_UX500_SOC_DB5500
12
13void db5500_prcmu_early_init(void);
14
15int db5500_prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
16int db5500_prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
17
18#else /* !CONFIG_UX500_SOC_DB5500 */
19
20static inline void db5500_prcmu_early_init(void)
21{
22}
23
24static inline int db5500_prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
25{
26 return -ENOSYS;
27}
28
29static inline int db5500_prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
30{
31 return -ENOSYS;
32}
33
34#endif /* CONFIG_UX500_SOC_DB5500 */
35
36static inline int db5500_prcmu_config_abb_event_readout(u32 abb_events)
37{
38#ifdef CONFIG_MACH_U5500_SIMULATOR
39 return 0;
40#else
41 return -1;
42#endif
43}
44
45#endif /* __MACH_PRCMU_U5500_H */
diff --git a/include/linux/mfd/db8500-prcmu.h b/include/linux/mfd/db8500-prcmu.h
new file mode 100644
index 000000000000..917dbcab701c
--- /dev/null
+++ b/include/linux/mfd/db8500-prcmu.h
@@ -0,0 +1,978 @@
1/*
2 * Copyright (C) STMicroelectronics 2009
3 * Copyright (C) ST-Ericsson SA 2010
4 *
5 * License Terms: GNU General Public License v2
6 * Author: Kumar Sanghvi <kumar.sanghvi@stericsson.com>
7 *
8 * PRCMU f/w APIs
9 */
10#ifndef __MFD_DB8500_PRCMU_H
11#define __MFD_DB8500_PRCMU_H
12
13#include <linux/interrupt.h>
14#include <linux/notifier.h>
15
16/* This portion previously known as <mach/prcmu-fw-defs_v1.h> */
17
18/**
19 * enum state - ON/OFF state definition
20 * @OFF: State is ON
21 * @ON: State is OFF
22 *
23 */
24enum state {
25 OFF = 0x0,
26 ON = 0x1,
27};
28
29/**
30 * enum ret_state - general purpose On/Off/Retention states
31 *
32 */
33enum ret_state {
34 OFFST = 0,
35 ONST = 1,
36 RETST = 2
37};
38
39/**
40 * enum clk_arm - ARM Cortex A9 clock schemes
41 * @A9_OFF:
42 * @A9_BOOT:
43 * @A9_OPPT1:
44 * @A9_OPPT2:
45 * @A9_EXTCLK:
46 */
47enum clk_arm {
48 A9_OFF,
49 A9_BOOT,
50 A9_OPPT1,
51 A9_OPPT2,
52 A9_EXTCLK
53};
54
55/**
56 * enum clk_gen - GEN#0/GEN#1 clock schemes
57 * @GEN_OFF:
58 * @GEN_BOOT:
59 * @GEN_OPPT1:
60 */
61enum clk_gen {
62 GEN_OFF,
63 GEN_BOOT,
64 GEN_OPPT1,
65};
66
67/* some information between arm and xp70 */
68
69/**
70 * enum romcode_write - Romcode message written by A9 AND read by XP70
71 * @RDY_2_DS: Value set when ApDeepSleep state can be executed by XP70
72 * @RDY_2_XP70_RST: Value set when 0x0F has been successfully polled by the
73 * romcode. The xp70 will go into self-reset
74 */
75enum romcode_write {
76 RDY_2_DS = 0x09,
77 RDY_2_XP70_RST = 0x10
78};
79
80/**
81 * enum romcode_read - Romcode message written by XP70 and read by A9
82 * @INIT: Init value when romcode field is not used
83 * @FS_2_DS: Value set when power state is going from ApExecute to
84 * ApDeepSleep
85 * @END_DS: Value set when ApDeepSleep power state is reached coming from
86 * ApExecute state
87 * @DS_TO_FS: Value set when power state is going from ApDeepSleep to
88 * ApExecute
89 * @END_FS: Value set when ApExecute power state is reached coming from
90 * ApDeepSleep state
91 * @SWR: Value set when power state is going to ApReset
92 * @END_SWR: Value set when the xp70 finished executing ApReset actions and
93 * waits for romcode acknowledgment to go to self-reset
94 */
95enum romcode_read {
96 INIT = 0x00,
97 FS_2_DS = 0x0A,
98 END_DS = 0x0B,
99 DS_TO_FS = 0x0C,
100 END_FS = 0x0D,
101 SWR = 0x0E,
102 END_SWR = 0x0F
103};
104
105/**
106 * enum ap_pwrst - current power states defined in PRCMU firmware
107 * @NO_PWRST: Current power state init
108 * @AP_BOOT: Current power state is apBoot
109 * @AP_EXECUTE: Current power state is apExecute
110 * @AP_DEEP_SLEEP: Current power state is apDeepSleep
111 * @AP_SLEEP: Current power state is apSleep
112 * @AP_IDLE: Current power state is apIdle
113 * @AP_RESET: Current power state is apReset
114 */
115enum ap_pwrst {
116 NO_PWRST = 0x00,
117 AP_BOOT = 0x01,
118 AP_EXECUTE = 0x02,
119 AP_DEEP_SLEEP = 0x03,
120 AP_SLEEP = 0x04,
121 AP_IDLE = 0x05,
122 AP_RESET = 0x06
123};
124
125/**
126 * enum ap_pwrst_trans - Transition states defined in PRCMU firmware
127 * @NO_TRANSITION: No power state transition
128 * @APEXECUTE_TO_APSLEEP: Power state transition from ApExecute to ApSleep
129 * @APIDLE_TO_APSLEEP: Power state transition from ApIdle to ApSleep
130 * @APBOOT_TO_APEXECUTE: Power state transition from ApBoot to ApExecute
131 * @APEXECUTE_TO_APDEEPSLEEP: Power state transition from ApExecute to
132 * ApDeepSleep
133 * @APEXECUTE_TO_APIDLE: Power state transition from ApExecute to ApIdle
134 */
135enum ap_pwrst_trans {
136 NO_TRANSITION = 0x00,
137 APEXECUTE_TO_APSLEEP = 0x01,
138 APIDLE_TO_APSLEEP = 0x02, /* To be removed */
139 PRCMU_AP_SLEEP = 0x01,
140 APBOOT_TO_APEXECUTE = 0x03,
141 APEXECUTE_TO_APDEEPSLEEP = 0x04, /* To be removed */
142 PRCMU_AP_DEEP_SLEEP = 0x04,
143 APEXECUTE_TO_APIDLE = 0x05, /* To be removed */
144 PRCMU_AP_IDLE = 0x05,
145 PRCMU_AP_DEEP_IDLE = 0x07,
146};
147
148/**
149 * enum ddr_pwrst - DDR power states definition
150 * @DDR_PWR_STATE_UNCHANGED: SDRAM and DDR controller state is unchanged
151 * @DDR_PWR_STATE_ON:
152 * @DDR_PWR_STATE_OFFLOWLAT:
153 * @DDR_PWR_STATE_OFFHIGHLAT:
154 */
155enum ddr_pwrst {
156 DDR_PWR_STATE_UNCHANGED = 0x00,
157 DDR_PWR_STATE_ON = 0x01,
158 DDR_PWR_STATE_OFFLOWLAT = 0x02,
159 DDR_PWR_STATE_OFFHIGHLAT = 0x03
160};
161
162/**
163 * enum arm_opp - ARM OPP states definition
164 * @ARM_OPP_INIT:
165 * @ARM_NO_CHANGE: The ARM operating point is unchanged
166 * @ARM_100_OPP: The new ARM operating point is arm100opp
167 * @ARM_50_OPP: The new ARM operating point is arm50opp
168 * @ARM_MAX_OPP: Operating point is "max" (more than 100)
169 * @ARM_MAX_FREQ100OPP: Set max opp if available, else 100
170 * @ARM_EXTCLK: The new ARM operating point is armExtClk
171 */
172enum arm_opp {
173 ARM_OPP_INIT = 0x00,
174 ARM_NO_CHANGE = 0x01,
175 ARM_100_OPP = 0x02,
176 ARM_50_OPP = 0x03,
177 ARM_MAX_OPP = 0x04,
178 ARM_MAX_FREQ100OPP = 0x05,
179 ARM_EXTCLK = 0x07
180};
181
182/**
183 * enum ape_opp - APE OPP states definition
184 * @APE_OPP_INIT:
185 * @APE_NO_CHANGE: The APE operating point is unchanged
186 * @APE_100_OPP: The new APE operating point is ape100opp
187 * @APE_50_OPP: 50%
188 */
189enum ape_opp {
190 APE_OPP_INIT = 0x00,
191 APE_NO_CHANGE = 0x01,
192 APE_100_OPP = 0x02,
193 APE_50_OPP = 0x03
194};
195
196/**
197 * enum hw_acc_state - State definition for hardware accelerator
198 * @HW_NO_CHANGE: The hardware accelerator state must remain unchanged
199 * @HW_OFF: The hardware accelerator must be switched off
200 * @HW_OFF_RAMRET: The hardware accelerator must be switched off with its
201 * internal RAM in retention
202 * @HW_ON: The hwa hardware accelerator hwa must be switched on
203 *
204 * NOTE! Deprecated, to be removed when all users switched over to use the
205 * regulator API.
206 */
207enum hw_acc_state {
208 HW_NO_CHANGE = 0x00,
209 HW_OFF = 0x01,
210 HW_OFF_RAMRET = 0x02,
211 HW_ON = 0x04
212};
213
214/**
215 * enum mbox_2_arm_stat - Status messages definition for mbox_arm
216 * @BOOT_TO_EXECUTEOK: The apBoot to apExecute state transition has been
217 * completed
218 * @DEEPSLEEPOK: The apExecute to apDeepSleep state transition has been
219 * completed
220 * @SLEEPOK: The apExecute to apSleep state transition has been completed
221 * @IDLEOK: The apExecute to apIdle state transition has been completed
222 * @SOFTRESETOK: The A9 watchdog/ SoftReset state has been completed
223 * @SOFTRESETGO : The A9 watchdog/SoftReset state is on going
224 * @BOOT_TO_EXECUTE: The apBoot to apExecute state transition is on going
225 * @EXECUTE_TO_DEEPSLEEP: The apExecute to apDeepSleep state transition is on
226 * going
227 * @DEEPSLEEP_TO_EXECUTE: The apDeepSleep to apExecute state transition is on
228 * going
229 * @DEEPSLEEP_TO_EXECUTEOK: The apDeepSleep to apExecute state transition has
230 * been completed
231 * @EXECUTE_TO_SLEEP: The apExecute to apSleep state transition is on going
232 * @SLEEP_TO_EXECUTE: The apSleep to apExecute state transition is on going
233 * @SLEEP_TO_EXECUTEOK: The apSleep to apExecute state transition has been
234 * completed
235 * @EXECUTE_TO_IDLE: The apExecute to apIdle state transition is on going
236 * @IDLE_TO_EXECUTE: The apIdle to apExecute state transition is on going
237 * @IDLE_TO_EXECUTEOK: The apIdle to apExecute state transition has been
238 * completed
239 * @INIT_STATUS: Status init
240 */
241enum ap_pwrsttr_status {
242 BOOT_TO_EXECUTEOK = 0xFF,
243 DEEPSLEEPOK = 0xFE,
244 SLEEPOK = 0xFD,
245 IDLEOK = 0xFC,
246 SOFTRESETOK = 0xFB,
247 SOFTRESETGO = 0xFA,
248 BOOT_TO_EXECUTE = 0xF9,
249 EXECUTE_TO_DEEPSLEEP = 0xF8,
250 DEEPSLEEP_TO_EXECUTE = 0xF7,
251 DEEPSLEEP_TO_EXECUTEOK = 0xF6,
252 EXECUTE_TO_SLEEP = 0xF5,
253 SLEEP_TO_EXECUTE = 0xF4,
254 SLEEP_TO_EXECUTEOK = 0xF3,
255 EXECUTE_TO_IDLE = 0xF2,
256 IDLE_TO_EXECUTE = 0xF1,
257 IDLE_TO_EXECUTEOK = 0xF0,
258 RDYTODS_RETURNTOEXE = 0xEF,
259 NORDYTODS_RETURNTOEXE = 0xEE,
260 EXETOSLEEP_RETURNTOEXE = 0xED,
261 EXETOIDLE_RETURNTOEXE = 0xEC,
262 INIT_STATUS = 0xEB,
263
264 /*error messages */
265 INITERROR = 0x00,
266 PLLARMLOCKP_ER = 0x01,
267 PLLDDRLOCKP_ER = 0x02,
268 PLLSOCLOCKP_ER = 0x03,
269 PLLSOCK1LOCKP_ER = 0x04,
270 ARMWFI_ER = 0x05,
271 SYSCLKOK_ER = 0x06,
272 I2C_NACK_DATA_ER = 0x07,
273 BOOT_ER = 0x08,
274 I2C_STATUS_ALWAYS_1 = 0x0A,
275 I2C_NACK_REG_ADDR_ER = 0x0B,
276 I2C_NACK_DATA0123_ER = 0x1B,
277 I2C_NACK_ADDR_ER = 0x1F,
278 CURAPPWRSTISNOT_BOOT = 0x20,
279 CURAPPWRSTISNOT_EXECUTE = 0x21,
280 CURAPPWRSTISNOT_SLEEPMODE = 0x22,
281 CURAPPWRSTISNOT_CORRECTFORIT10 = 0x23,
282 FIFO4500WUISNOT_WUPEVENT = 0x24,
283 PLL32KLOCKP_ER = 0x29,
284 DDRDEEPSLEEPOK_ER = 0x2A,
285 ROMCODEREADY_ER = 0x50,
286 WUPBEFOREDS = 0x51,
287 DDRCONFIG_ER = 0x52,
288 WUPBEFORESLEEP = 0x53,
289 WUPBEFOREIDLE = 0x54
290}; /* earlier called as mbox_2_arm_stat */
291
292/**
293 * enum dvfs_stat - DVFS status messages definition
294 * @DVFS_GO: A state transition DVFS is on going
295 * @DVFS_ARM100OPPOK: The state transition DVFS has been completed for 100OPP
296 * @DVFS_ARM50OPPOK: The state transition DVFS has been completed for 50OPP
297 * @DVFS_ARMEXTCLKOK: The state transition DVFS has been completed for EXTCLK
298 * @DVFS_NOCHGTCLKOK: The state transition DVFS has been completed for
299 * NOCHGCLK
300 * @DVFS_INITSTATUS: Value init
301 */
302enum dvfs_stat {
303 DVFS_GO = 0xFF,
304 DVFS_ARM100OPPOK = 0xFE,
305 DVFS_ARM50OPPOK = 0xFD,
306 DVFS_ARMEXTCLKOK = 0xFC,
307 DVFS_NOCHGTCLKOK = 0xFB,
308 DVFS_INITSTATUS = 0x00
309};
310
311/**
312 * enum sva_mmdsp_stat - SVA MMDSP status messages
313 * @SVA_MMDSP_GO: SVAMMDSP interrupt has happened
314 * @SVA_MMDSP_INIT: Status init
315 */
316enum sva_mmdsp_stat {
317 SVA_MMDSP_GO = 0xFF,
318 SVA_MMDSP_INIT = 0x00
319};
320
321/**
322 * enum sia_mmdsp_stat - SIA MMDSP status messages
323 * @SIA_MMDSP_GO: SIAMMDSP interrupt has happened
324 * @SIA_MMDSP_INIT: Status init
325 */
326enum sia_mmdsp_stat {
327 SIA_MMDSP_GO = 0xFF,
328 SIA_MMDSP_INIT = 0x00
329};
330
331/**
332 * enum mbox_to_arm_err - Error messages definition
333 * @INIT_ERR: Init value
334 * @PLLARMLOCKP_ERR: PLLARM has not been correctly locked in given time
335 * @PLLDDRLOCKP_ERR: PLLDDR has not been correctly locked in the given time
336 * @PLLSOC0LOCKP_ERR: PLLSOC0 has not been correctly locked in the given time
337 * @PLLSOC1LOCKP_ERR: PLLSOC1 has not been correctly locked in the given time
338 * @ARMWFI_ERR: The ARM WFI has not been correctly executed in the given time
339 * @SYSCLKOK_ERR: The SYSCLK is not available in the given time
340 * @BOOT_ERR: Romcode has not validated the XP70 self reset in the given time
341 * @ROMCODESAVECONTEXT: The Romcode didn.t correctly save it secure context
342 * @VARMHIGHSPEEDVALTO_ERR: The ARM high speed supply value transfered
343 * through I2C has not been correctly executed in the given time
344 * @VARMHIGHSPEEDACCESS_ERR: The command value of VarmHighSpeedVal transfered
345 * through I2C has not been correctly executed in the given time
346 * @VARMLOWSPEEDVALTO_ERR:The ARM low speed supply value transfered through
347 * I2C has not been correctly executed in the given time
348 * @VARMLOWSPEEDACCESS_ERR: The command value of VarmLowSpeedVal transfered
349 * through I2C has not been correctly executed in the given time
350 * @VARMRETENTIONVALTO_ERR: The ARM retention supply value transfered through
351 * I2C has not been correctly executed in the given time
352 * @VARMRETENTIONACCESS_ERR: The command value of VarmRetentionVal transfered
353 * through I2C has not been correctly executed in the given time
354 * @VAPEHIGHSPEEDVALTO_ERR: The APE highspeed supply value transfered through
355 * I2C has not been correctly executed in the given time
356 * @VSAFEHPVALTO_ERR: The SAFE high power supply value transfered through I2C
357 * has not been correctly executed in the given time
358 * @VMODSEL1VALTO_ERR: The MODEM sel1 supply value transfered through I2C has
359 * not been correctly executed in the given time
360 * @VMODSEL2VALTO_ERR: The MODEM sel2 supply value transfered through I2C has
361 * not been correctly executed in the given time
362 * @VARMOFFACCESS_ERR: The command value of Varm ON/OFF transfered through
363 * I2C has not been correctly executed in the given time
364 * @VAPEOFFACCESS_ERR: The command value of Vape ON/OFF transfered through
365 * I2C has not been correctly executed in the given time
366 * @VARMRETACCES_ERR: The command value of Varm retention ON/OFF transfered
367 * through I2C has not been correctly executed in the given time
368 * @CURAPPWRSTISNOTBOOT:Generated when Arm want to do power state transition
369 * ApBoot to ApExecute but the power current state is not Apboot
370 * @CURAPPWRSTISNOTEXECUTE: Generated when Arm want to do power state
371 * transition from ApExecute to others power state but the
372 * power current state is not ApExecute
373 * @CURAPPWRSTISNOTSLEEPMODE: Generated when wake up events are transmitted
374 * but the power current state is not ApDeepSleep/ApSleep/ApIdle
375 * @CURAPPWRSTISNOTCORRECTDBG: Generated when wake up events are transmitted
376 * but the power current state is not correct
377 * @ARMREGU1VALTO_ERR:The ArmRegu1 value transferred through I2C has not
378 * been correctly executed in the given time
379 * @ARMREGU2VALTO_ERR: The ArmRegu2 value transferred through I2C has not
380 * been correctly executed in the given time
381 * @VAPEREGUVALTO_ERR: The VApeRegu value transfered through I2C has not
382 * been correctly executed in the given time
383 * @VSMPS3REGUVALTO_ERR: The VSmps3Regu value transfered through I2C has not
384 * been correctly executed in the given time
385 * @VMODREGUVALTO_ERR: The VModemRegu value transfered through I2C has not
386 * been correctly executed in the given time
387 */
388enum mbox_to_arm_err {
389 INIT_ERR = 0x00,
390 PLLARMLOCKP_ERR = 0x01,
391 PLLDDRLOCKP_ERR = 0x02,
392 PLLSOC0LOCKP_ERR = 0x03,
393 PLLSOC1LOCKP_ERR = 0x04,
394 ARMWFI_ERR = 0x05,
395 SYSCLKOK_ERR = 0x06,
396 BOOT_ERR = 0x07,
397 ROMCODESAVECONTEXT = 0x08,
398 VARMHIGHSPEEDVALTO_ERR = 0x10,
399 VARMHIGHSPEEDACCESS_ERR = 0x11,
400 VARMLOWSPEEDVALTO_ERR = 0x12,
401 VARMLOWSPEEDACCESS_ERR = 0x13,
402 VARMRETENTIONVALTO_ERR = 0x14,
403 VARMRETENTIONACCESS_ERR = 0x15,
404 VAPEHIGHSPEEDVALTO_ERR = 0x16,
405 VSAFEHPVALTO_ERR = 0x17,
406 VMODSEL1VALTO_ERR = 0x18,
407 VMODSEL2VALTO_ERR = 0x19,
408 VARMOFFACCESS_ERR = 0x1A,
409 VAPEOFFACCESS_ERR = 0x1B,
410 VARMRETACCES_ERR = 0x1C,
411 CURAPPWRSTISNOTBOOT = 0x20,
412 CURAPPWRSTISNOTEXECUTE = 0x21,
413 CURAPPWRSTISNOTSLEEPMODE = 0x22,
414 CURAPPWRSTISNOTCORRECTDBG = 0x23,
415 ARMREGU1VALTO_ERR = 0x24,
416 ARMREGU2VALTO_ERR = 0x25,
417 VAPEREGUVALTO_ERR = 0x26,
418 VSMPS3REGUVALTO_ERR = 0x27,
419 VMODREGUVALTO_ERR = 0x28
420};
421
422enum hw_acc {
423 SVAMMDSP = 0,
424 SVAPIPE = 1,
425 SIAMMDSP = 2,
426 SIAPIPE = 3,
427 SGA = 4,
428 B2R2MCDE = 5,
429 ESRAM12 = 6,
430 ESRAM34 = 7,
431};
432
433enum cs_pwrmgt {
434 PWRDNCS0 = 0,
435 WKUPCS0 = 1,
436 PWRDNCS1 = 2,
437 WKUPCS1 = 3
438};
439
440/* Defs related to autonomous power management */
441
442/**
443 * enum sia_sva_pwr_policy - Power policy
444 * @NO_CHGT: No change
445 * @DSPOFF_HWPOFF:
446 * @DSPOFFRAMRET_HWPOFF:
447 * @DSPCLKOFF_HWPOFF:
448 * @DSPCLKOFF_HWPCLKOFF:
449 *
450 */
451enum sia_sva_pwr_policy {
452 NO_CHGT = 0x0,
453 DSPOFF_HWPOFF = 0x1,
454 DSPOFFRAMRET_HWPOFF = 0x2,
455 DSPCLKOFF_HWPOFF = 0x3,
456 DSPCLKOFF_HWPCLKOFF = 0x4,
457};
458
459/**
460 * enum auto_enable - Auto Power enable
461 * @AUTO_OFF:
462 * @AUTO_ON:
463 *
464 */
465enum auto_enable {
466 AUTO_OFF = 0x0,
467 AUTO_ON = 0x1,
468};
469
470/* End of file previously known as prcmu-fw-defs_v1.h */
471
472/* PRCMU Wakeup defines */
473enum prcmu_wakeup_index {
474 PRCMU_WAKEUP_INDEX_RTC,
475 PRCMU_WAKEUP_INDEX_RTT0,
476 PRCMU_WAKEUP_INDEX_RTT1,
477 PRCMU_WAKEUP_INDEX_HSI0,
478 PRCMU_WAKEUP_INDEX_HSI1,
479 PRCMU_WAKEUP_INDEX_USB,
480 PRCMU_WAKEUP_INDEX_ABB,
481 PRCMU_WAKEUP_INDEX_ABB_FIFO,
482 PRCMU_WAKEUP_INDEX_ARM,
483 NUM_PRCMU_WAKEUP_INDICES
484};
485#define PRCMU_WAKEUP(_name) (BIT(PRCMU_WAKEUP_INDEX_##_name))
486
487/* PRCMU QoS APE OPP class */
488#define PRCMU_QOS_APE_OPP 1
489#define PRCMU_QOS_DDR_OPP 2
490#define PRCMU_QOS_DEFAULT_VALUE -1
491
492/**
493 * enum hw_acc_dev - enum for hw accelerators
494 * @HW_ACC_SVAMMDSP: for SVAMMDSP
495 * @HW_ACC_SVAPIPE: for SVAPIPE
496 * @HW_ACC_SIAMMDSP: for SIAMMDSP
497 * @HW_ACC_SIAPIPE: for SIAPIPE
498 * @HW_ACC_SGA: for SGA
499 * @HW_ACC_B2R2: for B2R2
500 * @HW_ACC_MCDE: for MCDE
501 * @HW_ACC_ESRAM1: for ESRAM1
502 * @HW_ACC_ESRAM2: for ESRAM2
503 * @HW_ACC_ESRAM3: for ESRAM3
504 * @HW_ACC_ESRAM4: for ESRAM4
505 * @NUM_HW_ACC: number of hardware accelerators
506 *
507 * Different hw accelerators which can be turned ON/
508 * OFF or put into retention (MMDSPs and ESRAMs).
509 * Used with EPOD API.
510 *
511 * NOTE! Deprecated, to be removed when all users switched over to use the
512 * regulator API.
513 */
514enum hw_acc_dev {
515 HW_ACC_SVAMMDSP,
516 HW_ACC_SVAPIPE,
517 HW_ACC_SIAMMDSP,
518 HW_ACC_SIAPIPE,
519 HW_ACC_SGA,
520 HW_ACC_B2R2,
521 HW_ACC_MCDE,
522 HW_ACC_ESRAM1,
523 HW_ACC_ESRAM2,
524 HW_ACC_ESRAM3,
525 HW_ACC_ESRAM4,
526 NUM_HW_ACC
527};
528
529/*
530 * Ids for all EPODs (power domains)
531 * - EPOD_ID_SVAMMDSP: power domain for SVA MMDSP
532 * - EPOD_ID_SVAPIPE: power domain for SVA pipe
533 * - EPOD_ID_SIAMMDSP: power domain for SIA MMDSP
534 * - EPOD_ID_SIAPIPE: power domain for SIA pipe
535 * - EPOD_ID_SGA: power domain for SGA
536 * - EPOD_ID_B2R2_MCDE: power domain for B2R2 and MCDE
537 * - EPOD_ID_ESRAM12: power domain for ESRAM 1 and 2
538 * - EPOD_ID_ESRAM34: power domain for ESRAM 3 and 4
539 * - NUM_EPOD_ID: number of power domains
540 */
541#define EPOD_ID_SVAMMDSP 0
542#define EPOD_ID_SVAPIPE 1
543#define EPOD_ID_SIAMMDSP 2
544#define EPOD_ID_SIAPIPE 3
545#define EPOD_ID_SGA 4
546#define EPOD_ID_B2R2_MCDE 5
547#define EPOD_ID_ESRAM12 6
548#define EPOD_ID_ESRAM34 7
549#define NUM_EPOD_ID 8
550
551/*
552 * state definition for EPOD (power domain)
553 * - EPOD_STATE_NO_CHANGE: The EPOD should remain unchanged
554 * - EPOD_STATE_OFF: The EPOD is switched off
555 * - EPOD_STATE_RAMRET: The EPOD is switched off with its internal RAM in
556 * retention
557 * - EPOD_STATE_ON_CLK_OFF: The EPOD is switched on, clock is still off
558 * - EPOD_STATE_ON: Same as above, but with clock enabled
559 */
560#define EPOD_STATE_NO_CHANGE 0x00
561#define EPOD_STATE_OFF 0x01
562#define EPOD_STATE_RAMRET 0x02
563#define EPOD_STATE_ON_CLK_OFF 0x03
564#define EPOD_STATE_ON 0x04
565
566/*
567 * CLKOUT sources
568 */
569#define PRCMU_CLKSRC_CLK38M 0x00
570#define PRCMU_CLKSRC_ACLK 0x01
571#define PRCMU_CLKSRC_SYSCLK 0x02
572#define PRCMU_CLKSRC_LCDCLK 0x03
573#define PRCMU_CLKSRC_SDMMCCLK 0x04
574#define PRCMU_CLKSRC_TVCLK 0x05
575#define PRCMU_CLKSRC_TIMCLK 0x06
576#define PRCMU_CLKSRC_CLK009 0x07
577/* These are only valid for CLKOUT1: */
578#define PRCMU_CLKSRC_SIAMMDSPCLK 0x40
579#define PRCMU_CLKSRC_I2CCLK 0x41
580#define PRCMU_CLKSRC_MSP02CLK 0x42
581#define PRCMU_CLKSRC_ARMPLL_OBSCLK 0x43
582#define PRCMU_CLKSRC_HSIRXCLK 0x44
583#define PRCMU_CLKSRC_HSITXCLK 0x45
584#define PRCMU_CLKSRC_ARMCLKFIX 0x46
585#define PRCMU_CLKSRC_HDMICLK 0x47
586
587/*
588 * Definitions for autonomous power management configuration.
589 */
590
591#define PRCMU_AUTO_PM_OFF 0
592#define PRCMU_AUTO_PM_ON 1
593
594#define PRCMU_AUTO_PM_POWER_ON_HSEM BIT(0)
595#define PRCMU_AUTO_PM_POWER_ON_ABB_FIFO_IT BIT(1)
596
597enum prcmu_auto_pm_policy {
598 PRCMU_AUTO_PM_POLICY_NO_CHANGE,
599 PRCMU_AUTO_PM_POLICY_DSP_OFF_HWP_OFF,
600 PRCMU_AUTO_PM_POLICY_DSP_OFF_RAMRET_HWP_OFF,
601 PRCMU_AUTO_PM_POLICY_DSP_CLK_OFF_HWP_OFF,
602 PRCMU_AUTO_PM_POLICY_DSP_CLK_OFF_HWP_CLK_OFF,
603};
604
605/**
606 * struct prcmu_auto_pm_config - Autonomous power management configuration.
607 * @sia_auto_pm_enable: SIA autonomous pm enable. (PRCMU_AUTO_PM_{OFF,ON})
608 * @sia_power_on: SIA power ON enable. (PRCMU_AUTO_PM_POWER_ON_* bitmask)
609 * @sia_policy: SIA power policy. (enum prcmu_auto_pm_policy)
610 * @sva_auto_pm_enable: SVA autonomous pm enable. (PRCMU_AUTO_PM_{OFF,ON})
611 * @sva_power_on: SVA power ON enable. (PRCMU_AUTO_PM_POWER_ON_* bitmask)
612 * @sva_policy: SVA power policy. (enum prcmu_auto_pm_policy)
613 */
614struct prcmu_auto_pm_config {
615 u8 sia_auto_pm_enable;
616 u8 sia_power_on;
617 u8 sia_policy;
618 u8 sva_auto_pm_enable;
619 u8 sva_power_on;
620 u8 sva_policy;
621};
622
623/**
624 * enum ddr_opp - DDR OPP states definition
625 * @DDR_100_OPP: The new DDR operating point is ddr100opp
626 * @DDR_50_OPP: The new DDR operating point is ddr50opp
627 * @DDR_25_OPP: The new DDR operating point is ddr25opp
628 */
629enum ddr_opp {
630 DDR_100_OPP = 0x00,
631 DDR_50_OPP = 0x01,
632 DDR_25_OPP = 0x02,
633};
634
635/*
636 * Clock identifiers.
637 */
638enum prcmu_clock {
639 PRCMU_SGACLK,
640 PRCMU_UARTCLK,
641 PRCMU_MSP02CLK,
642 PRCMU_MSP1CLK,
643 PRCMU_I2CCLK,
644 PRCMU_SDMMCCLK,
645 PRCMU_SLIMCLK,
646 PRCMU_PER1CLK,
647 PRCMU_PER2CLK,
648 PRCMU_PER3CLK,
649 PRCMU_PER5CLK,
650 PRCMU_PER6CLK,
651 PRCMU_PER7CLK,
652 PRCMU_LCDCLK,
653 PRCMU_BMLCLK,
654 PRCMU_HSITXCLK,
655 PRCMU_HSIRXCLK,
656 PRCMU_HDMICLK,
657 PRCMU_APEATCLK,
658 PRCMU_APETRACECLK,
659 PRCMU_MCDECLK,
660 PRCMU_IPI2CCLK,
661 PRCMU_DSIALTCLK,
662 PRCMU_DMACLK,
663 PRCMU_B2R2CLK,
664 PRCMU_TVCLK,
665 PRCMU_SSPCLK,
666 PRCMU_RNGCLK,
667 PRCMU_UICCCLK,
668 PRCMU_NUM_REG_CLOCKS,
669 PRCMU_SYSCLK = PRCMU_NUM_REG_CLOCKS,
670 PRCMU_TIMCLK,
671};
672
673/*
674 * Definitions for controlling ESRAM0 in deep sleep.
675 */
676#define ESRAM0_DEEP_SLEEP_STATE_OFF 1
677#define ESRAM0_DEEP_SLEEP_STATE_RET 2
678
679#ifdef CONFIG_MFD_DB8500_PRCMU
680void __init prcmu_early_init(void);
681int prcmu_set_display_clocks(void);
682int prcmu_disable_dsipll(void);
683int prcmu_enable_dsipll(void);
684#else
685static inline void __init prcmu_early_init(void) {}
686#endif
687
688#ifdef CONFIG_MFD_DB8500_PRCMU
689
690int prcmu_set_rc_a2p(enum romcode_write);
691enum romcode_read prcmu_get_rc_p2a(void);
692enum ap_pwrst prcmu_get_xp70_current_state(void);
693int prcmu_set_power_state(u8 state, bool keep_ulp_clk, bool keep_ap_pll);
694
695void prcmu_enable_wakeups(u32 wakeups);
696static inline void prcmu_disable_wakeups(void)
697{
698 prcmu_enable_wakeups(0);
699}
700
701void prcmu_config_abb_event_readout(u32 abb_events);
702void prcmu_get_abb_event_buffer(void __iomem **buf);
703int prcmu_set_arm_opp(u8 opp);
704int prcmu_get_arm_opp(void);
705bool prcmu_has_arm_maxopp(void);
706bool prcmu_is_u8400(void);
707int prcmu_set_ape_opp(u8 opp);
708int prcmu_get_ape_opp(void);
709int prcmu_request_ape_opp_100_voltage(bool enable);
710int prcmu_release_usb_wakeup_state(void);
711int prcmu_set_ddr_opp(u8 opp);
712int prcmu_get_ddr_opp(void);
713unsigned long prcmu_qos_get_cpufreq_opp_delay(void);
714void prcmu_qos_set_cpufreq_opp_delay(unsigned long);
715/* NOTE! Use regulator framework instead */
716int prcmu_set_hwacc(u16 hw_acc_dev, u8 state);
717int prcmu_set_epod(u16 epod_id, u8 epod_state);
718void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep,
719 struct prcmu_auto_pm_config *idle);
720bool prcmu_is_auto_pm_enabled(void);
721
722int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
723int prcmu_request_clock(u8 clock, bool enable);
724int prcmu_set_clock_divider(u8 clock, u8 divider);
725int prcmu_config_esram0_deep_sleep(u8 state);
726int prcmu_config_hotdog(u8 threshold);
727int prcmu_config_hotmon(u8 low, u8 high);
728int prcmu_start_temp_sense(u16 cycles32k);
729int prcmu_stop_temp_sense(void);
730int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
731int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
732
733void prcmu_ac_wake_req(void);
734void prcmu_ac_sleep_req(void);
735void prcmu_system_reset(u16 reset_code);
736void prcmu_modem_reset(void);
737bool prcmu_is_ac_wake_requested(void);
738void prcmu_enable_spi2(void);
739void prcmu_disable_spi2(void);
740
741#else /* !CONFIG_MFD_DB8500_PRCMU */
742
743static inline int prcmu_set_rc_a2p(enum romcode_write code)
744{
745 return 0;
746}
747
748static inline enum romcode_read prcmu_get_rc_p2a(void)
749{
750 return INIT;
751}
752
753static inline enum ap_pwrst prcmu_get_xp70_current_state(void)
754{
755 return AP_EXECUTE;
756}
757
758static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
759 bool keep_ap_pll)
760{
761 return 0;
762}
763
764static inline void prcmu_enable_wakeups(u32 wakeups) {}
765
766static inline void prcmu_disable_wakeups(void) {}
767
768static inline void prcmu_config_abb_event_readout(u32 abb_events) {}
769
770static inline int prcmu_set_arm_opp(u8 opp)
771{
772 return 0;
773}
774
775static inline int prcmu_get_arm_opp(void)
776{
777 return ARM_100_OPP;
778}
779
780static bool prcmu_has_arm_maxopp(void)
781{
782 return false;
783}
784
785static bool prcmu_is_u8400(void)
786{
787 return false;
788}
789
790static inline int prcmu_set_ape_opp(u8 opp)
791{
792 return 0;
793}
794
795static inline int prcmu_get_ape_opp(void)
796{
797 return APE_100_OPP;
798}
799
800static inline int prcmu_request_ape_opp_100_voltage(bool enable)
801{
802 return 0;
803}
804
805static inline int prcmu_release_usb_wakeup_state(void)
806{
807 return 0;
808}
809
810static inline int prcmu_set_ddr_opp(u8 opp)
811{
812 return 0;
813}
814
815static inline int prcmu_get_ddr_opp(void)
816{
817 return DDR_100_OPP;
818}
819
820static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void)
821{
822 return 0;
823}
824
825static inline void prcmu_qos_set_cpufreq_opp_delay(unsigned long n) {}
826
827static inline int prcmu_set_hwacc(u16 hw_acc_dev, u8 state)
828{
829 return 0;
830}
831
832static inline void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep,
833 struct prcmu_auto_pm_config *idle)
834{
835}
836
837static inline bool prcmu_is_auto_pm_enabled(void)
838{
839 return false;
840}
841
842static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
843{
844 return 0;
845}
846
847static inline int prcmu_request_clock(u8 clock, bool enable)
848{
849 return 0;
850}
851
852static inline int prcmu_set_clock_divider(u8 clock, u8 divider)
853{
854 return 0;
855}
856
857int prcmu_config_esram0_deep_sleep(u8 state)
858{
859 return 0;
860}
861
862static inline int prcmu_config_hotdog(u8 threshold)
863{
864 return 0;
865}
866
867static inline int prcmu_config_hotmon(u8 low, u8 high)
868{
869 return 0;
870}
871
872static inline int prcmu_start_temp_sense(u16 cycles32k)
873{
874 return 0;
875}
876
877static inline int prcmu_stop_temp_sense(void)
878{
879 return 0;
880}
881
882static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
883{
884 return -ENOSYS;
885}
886
887static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
888{
889 return -ENOSYS;
890}
891
892static inline void prcmu_ac_wake_req(void) {}
893
894static inline void prcmu_ac_sleep_req(void) {}
895
896static inline void prcmu_system_reset(u16 reset_code) {}
897
898static inline void prcmu_modem_reset(void) {}
899
900static inline bool prcmu_is_ac_wake_requested(void)
901{
902 return false;
903}
904
905#ifndef CONFIG_UX500_SOC_DB5500
906static inline int prcmu_set_display_clocks(void)
907{
908 return 0;
909}
910
911static inline int prcmu_disable_dsipll(void)
912{
913 return 0;
914}
915
916static inline int prcmu_enable_dsipll(void)
917{
918 return 0;
919}
920#endif
921
922static inline int prcmu_enable_spi2(void)
923{
924 return 0;
925}
926
927static inline int prcmu_disable_spi2(void)
928{
929 return 0;
930}
931
932#endif /* !CONFIG_MFD_DB8500_PRCMU */
933
934#ifdef CONFIG_UX500_PRCMU_QOS_POWER
935int prcmu_qos_requirement(int pm_qos_class);
936int prcmu_qos_add_requirement(int pm_qos_class, char *name, s32 value);
937int prcmu_qos_update_requirement(int pm_qos_class, char *name, s32 new_value);
938void prcmu_qos_remove_requirement(int pm_qos_class, char *name);
939int prcmu_qos_add_notifier(int prcmu_qos_class,
940 struct notifier_block *notifier);
941int prcmu_qos_remove_notifier(int prcmu_qos_class,
942 struct notifier_block *notifier);
943#else
944static inline int prcmu_qos_requirement(int prcmu_qos_class)
945{
946 return 0;
947}
948
949static inline int prcmu_qos_add_requirement(int prcmu_qos_class,
950 char *name, s32 value)
951{
952 return 0;
953}
954
955static inline int prcmu_qos_update_requirement(int prcmu_qos_class,
956 char *name, s32 new_value)
957{
958 return 0;
959}
960
961static inline void prcmu_qos_remove_requirement(int prcmu_qos_class, char *name)
962{
963}
964
965static inline int prcmu_qos_add_notifier(int prcmu_qos_class,
966 struct notifier_block *notifier)
967{
968 return 0;
969}
970static inline int prcmu_qos_remove_notifier(int prcmu_qos_class,
971 struct notifier_block *notifier)
972{
973 return 0;
974}
975
976#endif
977
978#endif /* __MFD_DB8500_PRCMU_H */
diff --git a/include/linux/mfd/ds1wm.h b/include/linux/mfd/ds1wm.h
index be469a357cbb..38a372a0e285 100644
--- a/include/linux/mfd/ds1wm.h
+++ b/include/linux/mfd/ds1wm.h
@@ -3,4 +3,11 @@
3struct ds1wm_driver_data { 3struct ds1wm_driver_data {
4 int active_high; 4 int active_high;
5 int clock_rate; 5 int clock_rate;
6 /* in milliseconds, the amount of time to */
7 /* sleep following a reset pulse. Zero */
8 /* should work if your bus devices recover*/
9 /* time respects the 1-wire spec since the*/
10 /* ds1wm implements the precise timings of*/
11 /* a reset pulse/presence detect sequence.*/
12 unsigned int reset_recover_delay;
6}; 13};
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
new file mode 100644
index 000000000000..5ff2400ad46c
--- /dev/null
+++ b/include/linux/mfd/max8997-private.h
@@ -0,0 +1,364 @@
1/*
2 * max8997.h - Voltage regulator driver for the Maxim 8997
3 *
4 * Copyright (C) 2010 Samsung Electrnoics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef __LINUX_MFD_MAX8997_PRIV_H
23#define __LINUX_MFD_MAX8997_PRIV_H
24
25#include <linux/i2c.h>
26
27#define MAX8997_REG_INVALID (0xff)
28
29enum max8997_pmic_reg {
30 MAX8997_REG_PMIC_ID0 = 0x00,
31 MAX8997_REG_PMIC_ID1 = 0x01,
32 MAX8997_REG_INTSRC = 0x02,
33 MAX8997_REG_INT1 = 0x03,
34 MAX8997_REG_INT2 = 0x04,
35 MAX8997_REG_INT3 = 0x05,
36 MAX8997_REG_INT4 = 0x06,
37
38 MAX8997_REG_INT1MSK = 0x08,
39 MAX8997_REG_INT2MSK = 0x09,
40 MAX8997_REG_INT3MSK = 0x0a,
41 MAX8997_REG_INT4MSK = 0x0b,
42
43 MAX8997_REG_STATUS1 = 0x0d,
44 MAX8997_REG_STATUS2 = 0x0e,
45 MAX8997_REG_STATUS3 = 0x0f,
46 MAX8997_REG_STATUS4 = 0x10,
47
48 MAX8997_REG_MAINCON1 = 0x13,
49 MAX8997_REG_MAINCON2 = 0x14,
50 MAX8997_REG_BUCKRAMP = 0x15,
51
52 MAX8997_REG_BUCK1CTRL = 0x18,
53 MAX8997_REG_BUCK1DVS1 = 0x19,
54 MAX8997_REG_BUCK1DVS2 = 0x1a,
55 MAX8997_REG_BUCK1DVS3 = 0x1b,
56 MAX8997_REG_BUCK1DVS4 = 0x1c,
57 MAX8997_REG_BUCK1DVS5 = 0x1d,
58 MAX8997_REG_BUCK1DVS6 = 0x1e,
59 MAX8997_REG_BUCK1DVS7 = 0x1f,
60 MAX8997_REG_BUCK1DVS8 = 0x20,
61 MAX8997_REG_BUCK2CTRL = 0x21,
62 MAX8997_REG_BUCK2DVS1 = 0x22,
63 MAX8997_REG_BUCK2DVS2 = 0x23,
64 MAX8997_REG_BUCK2DVS3 = 0x24,
65 MAX8997_REG_BUCK2DVS4 = 0x25,
66 MAX8997_REG_BUCK2DVS5 = 0x26,
67 MAX8997_REG_BUCK2DVS6 = 0x27,
68 MAX8997_REG_BUCK2DVS7 = 0x28,
69 MAX8997_REG_BUCK2DVS8 = 0x29,
70 MAX8997_REG_BUCK3CTRL = 0x2a,
71 MAX8997_REG_BUCK3DVS = 0x2b,
72 MAX8997_REG_BUCK4CTRL = 0x2c,
73 MAX8997_REG_BUCK4DVS = 0x2d,
74 MAX8997_REG_BUCK5CTRL = 0x2e,
75 MAX8997_REG_BUCK5DVS1 = 0x2f,
76 MAX8997_REG_BUCK5DVS2 = 0x30,
77 MAX8997_REG_BUCK5DVS3 = 0x31,
78 MAX8997_REG_BUCK5DVS4 = 0x32,
79 MAX8997_REG_BUCK5DVS5 = 0x33,
80 MAX8997_REG_BUCK5DVS6 = 0x34,
81 MAX8997_REG_BUCK5DVS7 = 0x35,
82 MAX8997_REG_BUCK5DVS8 = 0x36,
83 MAX8997_REG_BUCK6CTRL = 0x37,
84 MAX8997_REG_BUCK6BPSKIPCTRL = 0x38,
85 MAX8997_REG_BUCK7CTRL = 0x39,
86 MAX8997_REG_BUCK7DVS = 0x3a,
87 MAX8997_REG_LDO1CTRL = 0x3b,
88 MAX8997_REG_LDO2CTRL = 0x3c,
89 MAX8997_REG_LDO3CTRL = 0x3d,
90 MAX8997_REG_LDO4CTRL = 0x3e,
91 MAX8997_REG_LDO5CTRL = 0x3f,
92 MAX8997_REG_LDO6CTRL = 0x40,
93 MAX8997_REG_LDO7CTRL = 0x41,
94 MAX8997_REG_LDO8CTRL = 0x42,
95 MAX8997_REG_LDO9CTRL = 0x43,
96 MAX8997_REG_LDO10CTRL = 0x44,
97 MAX8997_REG_LDO11CTRL = 0x45,
98 MAX8997_REG_LDO12CTRL = 0x46,
99 MAX8997_REG_LDO13CTRL = 0x47,
100 MAX8997_REG_LDO14CTRL = 0x48,
101 MAX8997_REG_LDO15CTRL = 0x49,
102 MAX8997_REG_LDO16CTRL = 0x4a,
103 MAX8997_REG_LDO17CTRL = 0x4b,
104 MAX8997_REG_LDO18CTRL = 0x4c,
105 MAX8997_REG_LDO21CTRL = 0x4d,
106
107 MAX8997_REG_MBCCTRL1 = 0x50,
108 MAX8997_REG_MBCCTRL2 = 0x51,
109 MAX8997_REG_MBCCTRL3 = 0x52,
110 MAX8997_REG_MBCCTRL4 = 0x53,
111 MAX8997_REG_MBCCTRL5 = 0x54,
112 MAX8997_REG_MBCCTRL6 = 0x55,
113 MAX8997_REG_OTPCGHCVS = 0x56,
114
115 MAX8997_REG_SAFEOUTCTRL = 0x5a,
116
117 MAX8997_REG_LBCNFG1 = 0x5e,
118 MAX8997_REG_LBCNFG2 = 0x5f,
119 MAX8997_REG_BBCCTRL = 0x60,
120
121 MAX8997_REG_FLASH1_CUR = 0x63, /* 0x63 ~ 0x6e for FLASH */
122 MAX8997_REG_FLASH2_CUR = 0x64,
123 MAX8997_REG_MOVIE_CUR = 0x65,
124 MAX8997_REG_GSMB_CUR = 0x66,
125 MAX8997_REG_BOOST_CNTL = 0x67,
126 MAX8997_REG_LEN_CNTL = 0x68,
127 MAX8997_REG_FLASH_CNTL = 0x69,
128 MAX8997_REG_WDT_CNTL = 0x6a,
129 MAX8997_REG_MAXFLASH1 = 0x6b,
130 MAX8997_REG_MAXFLASH2 = 0x6c,
131 MAX8997_REG_FLASHSTATUS = 0x6d,
132 MAX8997_REG_FLASHSTATUSMASK = 0x6e,
133
134 MAX8997_REG_GPIOCNTL1 = 0x70,
135 MAX8997_REG_GPIOCNTL2 = 0x71,
136 MAX8997_REG_GPIOCNTL3 = 0x72,
137 MAX8997_REG_GPIOCNTL4 = 0x73,
138 MAX8997_REG_GPIOCNTL5 = 0x74,
139 MAX8997_REG_GPIOCNTL6 = 0x75,
140 MAX8997_REG_GPIOCNTL7 = 0x76,
141 MAX8997_REG_GPIOCNTL8 = 0x77,
142 MAX8997_REG_GPIOCNTL9 = 0x78,
143 MAX8997_REG_GPIOCNTL10 = 0x79,
144 MAX8997_REG_GPIOCNTL11 = 0x7a,
145 MAX8997_REG_GPIOCNTL12 = 0x7b,
146
147 MAX8997_REG_LDO1CONFIG = 0x80,
148 MAX8997_REG_LDO2CONFIG = 0x81,
149 MAX8997_REG_LDO3CONFIG = 0x82,
150 MAX8997_REG_LDO4CONFIG = 0x83,
151 MAX8997_REG_LDO5CONFIG = 0x84,
152 MAX8997_REG_LDO6CONFIG = 0x85,
153 MAX8997_REG_LDO7CONFIG = 0x86,
154 MAX8997_REG_LDO8CONFIG = 0x87,
155 MAX8997_REG_LDO9CONFIG = 0x88,
156 MAX8997_REG_LDO10CONFIG = 0x89,
157 MAX8997_REG_LDO11CONFIG = 0x8a,
158 MAX8997_REG_LDO12CONFIG = 0x8b,
159 MAX8997_REG_LDO13CONFIG = 0x8c,
160 MAX8997_REG_LDO14CONFIG = 0x8d,
161 MAX8997_REG_LDO15CONFIG = 0x8e,
162 MAX8997_REG_LDO16CONFIG = 0x8f,
163 MAX8997_REG_LDO17CONFIG = 0x90,
164 MAX8997_REG_LDO18CONFIG = 0x91,
165 MAX8997_REG_LDO21CONFIG = 0x92,
166
167 MAX8997_REG_DVSOKTIMER1 = 0x97,
168 MAX8997_REG_DVSOKTIMER2 = 0x98,
169 MAX8997_REG_DVSOKTIMER4 = 0x99,
170 MAX8997_REG_DVSOKTIMER5 = 0x9a,
171
172 MAX8997_REG_PMIC_END = 0x9b,
173};
174
175enum max8997_muic_reg {
176 MAX8997_MUIC_REG_ID = 0x0,
177 MAX8997_MUIC_REG_INT1 = 0x1,
178 MAX8997_MUIC_REG_INT2 = 0x2,
179 MAX8997_MUIC_REG_INT3 = 0x3,
180 MAX8997_MUIC_REG_STATUS1 = 0x4,
181 MAX8997_MUIC_REG_STATUS2 = 0x5,
182 MAX8997_MUIC_REG_STATUS3 = 0x6,
183 MAX8997_MUIC_REG_INTMASK1 = 0x7,
184 MAX8997_MUIC_REG_INTMASK2 = 0x8,
185 MAX8997_MUIC_REG_INTMASK3 = 0x9,
186 MAX8997_MUIC_REG_CDETCTRL = 0xa,
187
188 MAX8997_MUIC_REG_CONTROL1 = 0xc,
189 MAX8997_MUIC_REG_CONTROL2 = 0xd,
190 MAX8997_MUIC_REG_CONTROL3 = 0xe,
191
192 MAX8997_MUIC_REG_END = 0xf,
193};
194
195enum max8997_haptic_reg {
196 MAX8997_HAPTIC_REG_GENERAL = 0x00,
197 MAX8997_HAPTIC_REG_CONF1 = 0x01,
198 MAX8997_HAPTIC_REG_CONF2 = 0x02,
199 MAX8997_HAPTIC_REG_DRVCONF = 0x03,
200 MAX8997_HAPTIC_REG_CYCLECONF1 = 0x04,
201 MAX8997_HAPTIC_REG_CYCLECONF2 = 0x05,
202 MAX8997_HAPTIC_REG_SIGCONF1 = 0x06,
203 MAX8997_HAPTIC_REG_SIGCONF2 = 0x07,
204 MAX8997_HAPTIC_REG_SIGCONF3 = 0x08,
205 MAX8997_HAPTIC_REG_SIGCONF4 = 0x09,
206 MAX8997_HAPTIC_REG_SIGDC1 = 0x0a,
207 MAX8997_HAPTIC_REG_SIGDC2 = 0x0b,
208 MAX8997_HAPTIC_REG_SIGPWMDC1 = 0x0c,
209 MAX8997_HAPTIC_REG_SIGPWMDC2 = 0x0d,
210 MAX8997_HAPTIC_REG_SIGPWMDC3 = 0x0e,
211 MAX8997_HAPTIC_REG_SIGPWMDC4 = 0x0f,
212 MAX8997_HAPTIC_REG_MTR_REV = 0x10,
213
214 MAX8997_HAPTIC_REG_END = 0x11,
215};
216
217/* slave addr = 0x0c: using "2nd part" of rev4 datasheet */
218enum max8997_rtc_reg {
219 MAX8997_RTC_CTRLMASK = 0x02,
220 MAX8997_RTC_CTRL = 0x03,
221 MAX8997_RTC_UPDATE1 = 0x04,
222 MAX8997_RTC_UPDATE2 = 0x05,
223 MAX8997_RTC_WTSR_SMPL = 0x06,
224
225 MAX8997_RTC_SEC = 0x10,
226 MAX8997_RTC_MIN = 0x11,
227 MAX8997_RTC_HOUR = 0x12,
228 MAX8997_RTC_DAY_OF_WEEK = 0x13,
229 MAX8997_RTC_MONTH = 0x14,
230 MAX8997_RTC_YEAR = 0x15,
231 MAX8997_RTC_DAY_OF_MONTH = 0x16,
232 MAX8997_RTC_ALARM1_SEC = 0x17,
233 MAX8997_RTC_ALARM1_MIN = 0x18,
234 MAX8997_RTC_ALARM1_HOUR = 0x19,
235 MAX8997_RTC_ALARM1_DAY_OF_WEEK = 0x1a,
236 MAX8997_RTC_ALARM1_MONTH = 0x1b,
237 MAX8997_RTC_ALARM1_YEAR = 0x1c,
238 MAX8997_RTC_ALARM1_DAY_OF_MONTH = 0x1d,
239 MAX8997_RTC_ALARM2_SEC = 0x1e,
240 MAX8997_RTC_ALARM2_MIN = 0x1f,
241 MAX8997_RTC_ALARM2_HOUR = 0x20,
242 MAX8997_RTC_ALARM2_DAY_OF_WEEK = 0x21,
243 MAX8997_RTC_ALARM2_MONTH = 0x22,
244 MAX8997_RTC_ALARM2_YEAR = 0x23,
245 MAX8997_RTC_ALARM2_DAY_OF_MONTH = 0x24,
246};
247
248enum max8997_irq_source {
249 PMIC_INT1 = 0,
250 PMIC_INT2,
251 PMIC_INT3,
252 PMIC_INT4,
253
254 FUEL_GAUGE, /* Ignored (MAX17042 driver handles) */
255
256 MUIC_INT1,
257 MUIC_INT2,
258 MUIC_INT3,
259
260 GPIO_LOW, /* Not implemented */
261 GPIO_HI, /* Not implemented */
262
263 FLASH_STATUS, /* Not implemented */
264
265 MAX8997_IRQ_GROUP_NR,
266};
267
268enum max8997_irq {
269 MAX8997_PMICIRQ_PWRONR,
270 MAX8997_PMICIRQ_PWRONF,
271 MAX8997_PMICIRQ_PWRON1SEC,
272 MAX8997_PMICIRQ_JIGONR,
273 MAX8997_PMICIRQ_JIGONF,
274 MAX8997_PMICIRQ_LOWBAT2,
275 MAX8997_PMICIRQ_LOWBAT1,
276
277 MAX8997_PMICIRQ_JIGR,
278 MAX8997_PMICIRQ_JIGF,
279 MAX8997_PMICIRQ_MR,
280 MAX8997_PMICIRQ_DVS1OK,
281 MAX8997_PMICIRQ_DVS2OK,
282 MAX8997_PMICIRQ_DVS3OK,
283 MAX8997_PMICIRQ_DVS4OK,
284
285 MAX8997_PMICIRQ_CHGINS,
286 MAX8997_PMICIRQ_CHGRM,
287 MAX8997_PMICIRQ_DCINOVP,
288 MAX8997_PMICIRQ_TOPOFFR,
289 MAX8997_PMICIRQ_CHGRSTF,
290 MAX8997_PMICIRQ_MBCHGTMEXPD,
291
292 MAX8997_PMICIRQ_RTC60S,
293 MAX8997_PMICIRQ_RTCA1,
294 MAX8997_PMICIRQ_RTCA2,
295 MAX8997_PMICIRQ_SMPL_INT,
296 MAX8997_PMICIRQ_RTC1S,
297 MAX8997_PMICIRQ_WTSR,
298
299 MAX8997_MUICIRQ_ADCError,
300 MAX8997_MUICIRQ_ADCLow,
301 MAX8997_MUICIRQ_ADC,
302
303 MAX8997_MUICIRQ_VBVolt,
304 MAX8997_MUICIRQ_DBChg,
305 MAX8997_MUICIRQ_DCDTmr,
306 MAX8997_MUICIRQ_ChgDetRun,
307 MAX8997_MUICIRQ_ChgTyp,
308
309 MAX8997_MUICIRQ_OVP,
310
311 MAX8997_IRQ_NR,
312};
313
314#define MAX8997_NUM_GPIO 12
315struct max8997_dev {
316 struct device *dev;
317 struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
318 struct i2c_client *rtc; /* slave addr 0x0c */
319 struct i2c_client *haptic; /* slave addr 0x90 */
320 struct i2c_client *muic; /* slave addr 0x4a */
321 struct mutex iolock;
322
323 int type;
324 struct platform_device *battery; /* battery control (not fuel gauge) */
325
326 int irq;
327 int ono;
328 int irq_base;
329 bool wakeup;
330 struct mutex irqlock;
331 int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
332 int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
333
334 /* For hibernation */
335 u8 reg_dump[MAX8997_REG_PMIC_END + MAX8997_MUIC_REG_END +
336 MAX8997_HAPTIC_REG_END];
337
338 bool gpio_status[MAX8997_NUM_GPIO];
339};
340
341enum max8997_types {
342 TYPE_MAX8997,
343 TYPE_MAX8966,
344};
345
346extern int max8997_irq_init(struct max8997_dev *max8997);
347extern void max8997_irq_exit(struct max8997_dev *max8997);
348extern int max8997_irq_resume(struct max8997_dev *max8997);
349
350extern int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
351extern int max8997_bulk_read(struct i2c_client *i2c, u8 reg, int count,
352 u8 *buf);
353extern int max8997_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
354extern int max8997_bulk_write(struct i2c_client *i2c, u8 reg, int count,
355 u8 *buf);
356extern int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
357
358#define MAX8997_GPIO_INT_BOTH (0x3 << 4)
359#define MAX8997_GPIO_INT_RISE (0x2 << 4)
360#define MAX8997_GPIO_INT_FALL (0x1 << 4)
361
362#define MAX8997_GPIO_INT_MASK (0x3 << 4)
363#define MAX8997_GPIO_DATA_MASK (0x1 << 2)
364#endif /* __LINUX_MFD_MAX8997_PRIV_H */
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
new file mode 100644
index 000000000000..60931d089422
--- /dev/null
+++ b/include/linux/mfd/max8997.h
@@ -0,0 +1,117 @@
1/*
2 * max8997.h - Driver for the Maxim 8997/8966
3 *
4 * Copyright (C) 2009-2010 Samsung Electrnoics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * This driver is based on max8998.h
22 *
23 * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices.
24 * Except Fuel Gauge, every device shares the same I2C bus and included in
25 * this mfd driver. Although the fuel gauge is included in the chip, it is
26 * excluded from the driver because a) it has a different I2C bus from
27 * others and b) it can be enabled simply by using MAX17042 driver.
28 */
29
30#ifndef __LINUX_MFD_MAX8998_H
31#define __LINUX_MFD_MAX8998_H
32
33#include <linux/regulator/consumer.h>
34
35/* MAX8997/8966 regulator IDs */
36enum max8998_regulators {
37 MAX8997_LDO1 = 0,
38 MAX8997_LDO2,
39 MAX8997_LDO3,
40 MAX8997_LDO4,
41 MAX8997_LDO5,
42 MAX8997_LDO6,
43 MAX8997_LDO7,
44 MAX8997_LDO8,
45 MAX8997_LDO9,
46 MAX8997_LDO10,
47 MAX8997_LDO11,
48 MAX8997_LDO12,
49 MAX8997_LDO13,
50 MAX8997_LDO14,
51 MAX8997_LDO15,
52 MAX8997_LDO16,
53 MAX8997_LDO17,
54 MAX8997_LDO18,
55 MAX8997_LDO21,
56 MAX8997_BUCK1,
57 MAX8997_BUCK2,
58 MAX8997_BUCK3,
59 MAX8997_BUCK4,
60 MAX8997_BUCK5,
61 MAX8997_BUCK6,
62 MAX8997_BUCK7,
63 MAX8997_EN32KHZ_AP,
64 MAX8997_EN32KHZ_CP,
65 MAX8997_ENVICHG,
66 MAX8997_ESAFEOUT1,
67 MAX8997_ESAFEOUT2,
68 MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */
69 MAX8997_CHARGER, /* charger current, MBCCTRL4 */
70 MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */
71
72 MAX8997_REG_MAX,
73};
74
75struct max8997_regulator_data {
76 int id;
77 struct regulator_init_data *initdata;
78};
79
80struct max8997_platform_data {
81 /* IRQ */
82 int irq_base;
83 int ono;
84 int wakeup;
85
86 /* ---- PMIC ---- */
87 struct max8997_regulator_data *regulators;
88 int num_regulators;
89
90 /*
91 * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore,
92 * With buckx_gpiodvs enabled, the buckx cannot be controlled
93 * independently. To control buckx (of 1, 2, and 5) independently,
94 * disable buckx_gpiodvs and control with BUCKxDVS1 register.
95 *
96 * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage
97 * on buckx will change the voltage of bucky at the same time.
98 *
99 */
100 bool ignore_gpiodvs_side_effect;
101 int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */
102 int buck125_default_idx; /* Default value of SET1, 2, 3 */
103 unsigned int buck1_voltage[8]; /* buckx_voltage in uV */
104 bool buck1_gpiodvs;
105 unsigned int buck2_voltage[8];
106 bool buck2_gpiodvs;
107 unsigned int buck5_voltage[8];
108 bool buck5_gpiodvs;
109
110 /* MUIC: Not implemented */
111 /* HAPTIC: Not implemented */
112 /* RTC: Not implemented */
113 /* Flash: Not implemented */
114 /* Charger control: Not implemented */
115};
116
117#endif /* __LINUX_MFD_MAX8998_H */
diff --git a/include/linux/mfd/max8998-private.h b/include/linux/mfd/max8998-private.h
index 6dc75b3e2d33..effa5d3b96ae 100644
--- a/include/linux/mfd/max8998-private.h
+++ b/include/linux/mfd/max8998-private.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * max8698.h - Voltage regulator driver for the Maxim 8998 2 * max8998.h - Voltage regulator driver for the Maxim 8998
3 * 3 *
4 * Copyright (C) 2009-2010 Samsung Electrnoics 4 * Copyright (C) 2009-2010 Samsung Electrnoics
5 * Kyungmin Park <kyungmin.park@samsung.com> 5 * Kyungmin Park <kyungmin.park@samsung.com>
@@ -23,6 +23,8 @@
23#ifndef __LINUX_MFD_MAX8998_PRIV_H 23#ifndef __LINUX_MFD_MAX8998_PRIV_H
24#define __LINUX_MFD_MAX8998_PRIV_H 24#define __LINUX_MFD_MAX8998_PRIV_H
25 25
26#define MAX8998_NUM_IRQ_REGS 4
27
26/* MAX 8998 registers */ 28/* MAX 8998 registers */
27enum { 29enum {
28 MAX8998_REG_IRQ1, 30 MAX8998_REG_IRQ1,
@@ -46,12 +48,12 @@ enum {
46 MAX8998_REG_ONOFF2, 48 MAX8998_REG_ONOFF2,
47 MAX8998_REG_ONOFF3, 49 MAX8998_REG_ONOFF3,
48 MAX8998_REG_ONOFF4, 50 MAX8998_REG_ONOFF4,
49 MAX8998_REG_BUCK1_DVSARM1, 51 MAX8998_REG_BUCK1_VOLTAGE1,
50 MAX8998_REG_BUCK1_DVSARM2, 52 MAX8998_REG_BUCK1_VOLTAGE2,
51 MAX8998_REG_BUCK1_DVSARM3, 53 MAX8998_REG_BUCK1_VOLTAGE3,
52 MAX8998_REG_BUCK1_DVSARM4, 54 MAX8998_REG_BUCK1_VOLTAGE4,
53 MAX8998_REG_BUCK2_DVSINT1, 55 MAX8998_REG_BUCK2_VOLTAGE1,
54 MAX8998_REG_BUCK2_DVSINT2, 56 MAX8998_REG_BUCK2_VOLTAGE2,
55 MAX8998_REG_BUCK3, 57 MAX8998_REG_BUCK3,
56 MAX8998_REG_BUCK4, 58 MAX8998_REG_BUCK4,
57 MAX8998_REG_LDO2_LDO3, 59 MAX8998_REG_LDO2_LDO3,
@@ -72,41 +74,104 @@ enum {
72 MAX8998_REG_LBCNFG2, 74 MAX8998_REG_LBCNFG2,
73}; 75};
74 76
77/* IRQ definitions */
78enum {
79 MAX8998_IRQ_DCINF,
80 MAX8998_IRQ_DCINR,
81 MAX8998_IRQ_JIGF,
82 MAX8998_IRQ_JIGR,
83 MAX8998_IRQ_PWRONF,
84 MAX8998_IRQ_PWRONR,
85
86 MAX8998_IRQ_WTSREVNT,
87 MAX8998_IRQ_SMPLEVNT,
88 MAX8998_IRQ_ALARM1,
89 MAX8998_IRQ_ALARM0,
90
91 MAX8998_IRQ_ONKEY1S,
92 MAX8998_IRQ_TOPOFFR,
93 MAX8998_IRQ_DCINOVPR,
94 MAX8998_IRQ_CHGRSTF,
95 MAX8998_IRQ_DONER,
96 MAX8998_IRQ_CHGFAULT,
97
98 MAX8998_IRQ_LOBAT1,
99 MAX8998_IRQ_LOBAT2,
100
101 MAX8998_IRQ_NR,
102};
103
104/* MAX8998 various variants */
105enum {
106 TYPE_MAX8998 = 0, /* Default */
107 TYPE_LP3974, /* National version of MAX8998 */
108 TYPE_LP3979, /* Added AVS */
109};
110
111#define MAX8998_IRQ_DCINF_MASK (1 << 2)
112#define MAX8998_IRQ_DCINR_MASK (1 << 3)
113#define MAX8998_IRQ_JIGF_MASK (1 << 4)
114#define MAX8998_IRQ_JIGR_MASK (1 << 5)
115#define MAX8998_IRQ_PWRONF_MASK (1 << 6)
116#define MAX8998_IRQ_PWRONR_MASK (1 << 7)
117
118#define MAX8998_IRQ_WTSREVNT_MASK (1 << 0)
119#define MAX8998_IRQ_SMPLEVNT_MASK (1 << 1)
120#define MAX8998_IRQ_ALARM1_MASK (1 << 2)
121#define MAX8998_IRQ_ALARM0_MASK (1 << 3)
122
123#define MAX8998_IRQ_ONKEY1S_MASK (1 << 0)
124#define MAX8998_IRQ_TOPOFFR_MASK (1 << 2)
125#define MAX8998_IRQ_DCINOVPR_MASK (1 << 3)
126#define MAX8998_IRQ_CHGRSTF_MASK (1 << 4)
127#define MAX8998_IRQ_DONER_MASK (1 << 5)
128#define MAX8998_IRQ_CHGFAULT_MASK (1 << 7)
129
130#define MAX8998_IRQ_LOBAT1_MASK (1 << 0)
131#define MAX8998_IRQ_LOBAT2_MASK (1 << 1)
132
133#define MAX8998_ENRAMP (1 << 4)
134
75/** 135/**
76 * struct max8998_dev - max8998 master device for sub-drivers 136 * struct max8998_dev - max8998 master device for sub-drivers
77 * @dev: master device of the chip (can be used to access platform data) 137 * @dev: master device of the chip (can be used to access platform data)
78 * @i2c_client: i2c client private data 138 * @i2c: i2c client private data for regulator
79 * @dev_read(): chip register read function 139 * @rtc: i2c client private data for rtc
80 * @dev_write(): chip register write function
81 * @dev_update(): chip register update function
82 * @iolock: mutex for serializing io access 140 * @iolock: mutex for serializing io access
141 * @irqlock: mutex for buslock
142 * @irq_base: base IRQ number for max8998, required for IRQs
143 * @irq: generic IRQ number for max8998
144 * @ono: power onoff IRQ number for max8998
145 * @irq_masks_cur: currently active value
146 * @irq_masks_cache: cached hardware value
147 * @type: indicate which max8998 "variant" is used
83 */ 148 */
84
85struct max8998_dev { 149struct max8998_dev {
86 struct device *dev; 150 struct device *dev;
87 struct i2c_client *i2c_client; 151 struct i2c_client *i2c;
88 int (*dev_read)(struct max8998_dev *max8998, u8 reg, u8 *dest); 152 struct i2c_client *rtc;
89 int (*dev_write)(struct max8998_dev *max8998, u8 reg, u8 val);
90 int (*dev_update)(struct max8998_dev *max8998, u8 reg, u8 val, u8 mask);
91 struct mutex iolock; 153 struct mutex iolock;
154 struct mutex irqlock;
155
156 int irq_base;
157 int irq;
158 int ono;
159 u8 irq_masks_cur[MAX8998_NUM_IRQ_REGS];
160 u8 irq_masks_cache[MAX8998_NUM_IRQ_REGS];
161 int type;
162 bool wakeup;
92}; 163};
93 164
94static inline int max8998_read_reg(struct max8998_dev *max8998, u8 reg, 165int max8998_irq_init(struct max8998_dev *max8998);
95 u8 *value) 166void max8998_irq_exit(struct max8998_dev *max8998);
96{ 167int max8998_irq_resume(struct max8998_dev *max8998);
97 return max8998->dev_read(max8998, reg, value); 168
98} 169extern int max8998_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
99 170extern int max8998_bulk_read(struct i2c_client *i2c, u8 reg, int count,
100static inline int max8998_write_reg(struct max8998_dev *max8998, u8 reg, 171 u8 *buf);
101 u8 value) 172extern int max8998_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
102{ 173extern int max8998_bulk_write(struct i2c_client *i2c, u8 reg, int count,
103 return max8998->dev_write(max8998, reg, value); 174 u8 *buf);
104} 175extern int max8998_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
105
106static inline int max8998_update_reg(struct max8998_dev *max8998, u8 reg,
107 u8 value, u8 mask)
108{
109 return max8998->dev_update(max8998, reg, value, mask);
110}
111 176
112#endif /* __LINUX_MFD_MAX8998_PRIV_H */ 177#endif /* __LINUX_MFD_MAX8998_PRIV_H */
diff --git a/include/linux/mfd/max8998.h b/include/linux/mfd/max8998.h
index 1d3601a2d853..61daa167b576 100644
--- a/include/linux/mfd/max8998.h
+++ b/include/linux/mfd/max8998.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * max8698.h - Voltage regulator driver for the Maxim 8998 2 * max8998.h - Voltage regulator driver for the Maxim 8998
3 * 3 *
4 * Copyright (C) 2009-2010 Samsung Electrnoics 4 * Copyright (C) 2009-2010 Samsung Electrnoics
5 * Kyungmin Park <kyungmin.park@samsung.com> 5 * Kyungmin Park <kyungmin.park@samsung.com>
@@ -66,13 +66,47 @@ struct max8998_regulator_data {
66 66
67/** 67/**
68 * struct max8998_board - packages regulator init data 68 * struct max8998_board - packages regulator init data
69 * @num_regulators: number of regultors used
70 * @regulators: array of defined regulators 69 * @regulators: array of defined regulators
70 * @num_regulators: number of regultors used
71 * @irq_base: base IRQ number for max8998, required for IRQs
72 * @ono: power onoff IRQ number for max8998
73 * @buck_voltage_lock: Do NOT change the values of the following six
74 * registers set by buck?_voltage?. The voltage of BUCK1/2 cannot
75 * be other than the preset values.
76 * @buck1_voltage1: BUCK1 DVS mode 1 voltage register
77 * @buck1_voltage2: BUCK1 DVS mode 2 voltage register
78 * @buck1_voltage3: BUCK1 DVS mode 3 voltage register
79 * @buck1_voltage4: BUCK1 DVS mode 4 voltage register
80 * @buck2_voltage1: BUCK2 DVS mode 1 voltage register
81 * @buck2_voltage2: BUCK2 DVS mode 2 voltage register
82 * @buck1_set1: BUCK1 gpio pin 1 to set output voltage
83 * @buck1_set2: BUCK1 gpio pin 2 to set output voltage
84 * @buck1_default_idx: Default for BUCK1 gpio pin 1, 2
85 * @buck2_set3: BUCK2 gpio pin to set output voltage
86 * @buck2_default_idx: Default for BUCK2 gpio pin.
87 * @wakeup: Allow to wake up from suspend
88 * @rtc_delay: LP3974 RTC chip bug that requires delay after a register
89 * write before reading it.
71 */ 90 */
72
73struct max8998_platform_data { 91struct max8998_platform_data {
74 int num_regulators;
75 struct max8998_regulator_data *regulators; 92 struct max8998_regulator_data *regulators;
93 int num_regulators;
94 int irq_base;
95 int ono;
96 bool buck_voltage_lock;
97 int buck1_voltage1;
98 int buck1_voltage2;
99 int buck1_voltage3;
100 int buck1_voltage4;
101 int buck2_voltage1;
102 int buck2_voltage2;
103 int buck1_set1;
104 int buck1_set2;
105 int buck1_default_idx;
106 int buck2_set3;
107 int buck2_default_idx;
108 bool wakeup;
109 bool rtc_delay;
76}; 110};
77 111
78#endif /* __LINUX_MFD_MAX8998_H */ 112#endif /* __LINUX_MFD_MAX8998_H */
diff --git a/include/linux/mfd/mc13783.h b/include/linux/mfd/mc13783.h
index 0fa44fb8dd26..7d0f3d6a0002 100644
--- a/include/linux/mfd/mc13783.h
+++ b/include/linux/mfd/mc13783.h
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright 2009 Pengutronix 2 * Copyright 2010 Yong Shen <yong.shen@linaro.org>
3 * Copyright 2009-2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> 4 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify it under 6 * This program is free software; you can redistribute it and/or modify it under
@@ -9,48 +10,83 @@
9#ifndef __LINUX_MFD_MC13783_H 10#ifndef __LINUX_MFD_MC13783_H
10#define __LINUX_MFD_MC13783_H 11#define __LINUX_MFD_MC13783_H
11 12
12#include <linux/interrupt.h> 13#include <linux/mfd/mc13xxx.h>
13 14
14struct mc13783; 15struct mc13783;
15 16
16void mc13783_lock(struct mc13783 *mc13783); 17struct mc13xxx *mc13783_to_mc13xxx(struct mc13783 *mc13783);
17void mc13783_unlock(struct mc13783 *mc13783);
18 18
19int mc13783_reg_read(struct mc13783 *mc13783, unsigned int offset, u32 *val); 19static inline void mc13783_lock(struct mc13783 *mc13783)
20int mc13783_reg_write(struct mc13783 *mc13783, unsigned int offset, u32 val); 20{
21int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset, 21 mc13xxx_lock(mc13783_to_mc13xxx(mc13783));
22 u32 mask, u32 val); 22}
23
24static inline void mc13783_unlock(struct mc13783 *mc13783)
25{
26 mc13xxx_unlock(mc13783_to_mc13xxx(mc13783));
27}
28
29static inline int mc13783_reg_read(struct mc13783 *mc13783,
30 unsigned int offset, u32 *val)
31{
32 return mc13xxx_reg_read(mc13783_to_mc13xxx(mc13783), offset, val);
33}
34
35static inline int mc13783_reg_write(struct mc13783 *mc13783,
36 unsigned int offset, u32 val)
37{
38 return mc13xxx_reg_write(mc13783_to_mc13xxx(mc13783), offset, val);
39}
40
41static inline int mc13783_reg_rmw(struct mc13783 *mc13783,
42 unsigned int offset, u32 mask, u32 val)
43{
44 return mc13xxx_reg_rmw(mc13783_to_mc13xxx(mc13783), offset, mask, val);
45}
23 46
24int mc13783_get_flags(struct mc13783 *mc13783); 47static inline int mc13783_get_flags(struct mc13783 *mc13783)
48{
49 return mc13xxx_get_flags(mc13783_to_mc13xxx(mc13783));
50}
25 51
26int mc13783_irq_request(struct mc13783 *mc13783, int irq, 52static inline int mc13783_irq_request(struct mc13783 *mc13783, int irq,
27 irq_handler_t handler, const char *name, void *dev); 53 irq_handler_t handler, const char *name, void *dev)
28int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq, 54{
29 irq_handler_t handler, const char *name, void *dev); 55 return mc13xxx_irq_request(mc13783_to_mc13xxx(mc13783), irq,
30int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev); 56 handler, name, dev);
57}
31 58
32int mc13783_irq_mask(struct mc13783 *mc13783, int irq); 59static inline int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq,
33int mc13783_irq_unmask(struct mc13783 *mc13783, int irq); 60 irq_handler_t handler, const char *name, void *dev)
34int mc13783_irq_status(struct mc13783 *mc13783, int irq, 61{
35 int *enabled, int *pending); 62 return mc13xxx_irq_request_nounmask(mc13783_to_mc13xxx(mc13783), irq,
36int mc13783_irq_ack(struct mc13783 *mc13783, int irq); 63 handler, name, dev);
64}
37 65
38static inline int mc13783_mask(struct mc13783 *mc13783, int irq) __deprecated; 66static inline int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev)
39static inline int mc13783_mask(struct mc13783 *mc13783, int irq)
40{ 67{
41 return mc13783_irq_mask(mc13783, irq); 68 return mc13xxx_irq_free(mc13783_to_mc13xxx(mc13783), irq, dev);
42} 69}
43 70
44static inline int mc13783_unmask(struct mc13783 *mc13783, int irq) __deprecated; 71static inline int mc13783_irq_mask(struct mc13783 *mc13783, int irq)
45static inline int mc13783_unmask(struct mc13783 *mc13783, int irq)
46{ 72{
47 return mc13783_irq_unmask(mc13783, irq); 73 return mc13xxx_irq_mask(mc13783_to_mc13xxx(mc13783), irq);
48} 74}
49 75
50static inline int mc13783_ackirq(struct mc13783 *mc13783, int irq) __deprecated; 76static inline int mc13783_irq_unmask(struct mc13783 *mc13783, int irq)
51static inline int mc13783_ackirq(struct mc13783 *mc13783, int irq)
52{ 77{
53 return mc13783_irq_ack(mc13783, irq); 78 return mc13xxx_irq_unmask(mc13783_to_mc13xxx(mc13783), irq);
79}
80static inline int mc13783_irq_status(struct mc13783 *mc13783, int irq,
81 int *enabled, int *pending)
82{
83 return mc13xxx_irq_status(mc13783_to_mc13xxx(mc13783),
84 irq, enabled, pending);
85}
86
87static inline int mc13783_irq_ack(struct mc13783 *mc13783, int irq)
88{
89 return mc13xxx_irq_ack(mc13783_to_mc13xxx(mc13783), irq);
54} 90}
55 91
56#define MC13783_ADC0 43 92#define MC13783_ADC0 43
@@ -66,96 +102,18 @@ static inline int mc13783_ackirq(struct mc13783 *mc13783, int irq)
66 MC13783_ADC0_TSMOD1 | \ 102 MC13783_ADC0_TSMOD1 | \
67 MC13783_ADC0_TSMOD2) 103 MC13783_ADC0_TSMOD2)
68 104
69struct mc13783_led_platform_data { 105#define mc13783_regulator_init_data mc13xxx_regulator_init_data
70#define MC13783_LED_MD 0 106#define mc13783_regulator_platform_data mc13xxx_regulator_platform_data
71#define MC13783_LED_AD 1 107#define mc13783_led_platform_data mc13xxx_led_platform_data
72#define MC13783_LED_KP 2 108#define mc13783_leds_platform_data mc13xxx_leds_platform_data
73#define MC13783_LED_R1 3 109
74#define MC13783_LED_G1 4 110#define mc13783_platform_data mc13xxx_platform_data
75#define MC13783_LED_B1 5 111#define MC13783_USE_TOUCHSCREEN MC13XXX_USE_TOUCHSCREEN
76#define MC13783_LED_R2 6 112#define MC13783_USE_CODEC MC13XXX_USE_CODEC
77#define MC13783_LED_G2 7 113#define MC13783_USE_ADC MC13XXX_USE_ADC
78#define MC13783_LED_B2 8 114#define MC13783_USE_RTC MC13XXX_USE_RTC
79#define MC13783_LED_R3 9 115#define MC13783_USE_REGULATOR MC13XXX_USE_REGULATOR
80#define MC13783_LED_G3 10 116#define MC13783_USE_LED MC13XXX_USE_LED
81#define MC13783_LED_B3 11
82#define MC13783_LED_MAX MC13783_LED_B3
83 int id;
84 const char *name;
85 const char *default_trigger;
86
87/* Three or two bits current selection depending on the led */
88 char max_current;
89};
90
91struct mc13783_leds_platform_data {
92 int num_leds;
93 struct mc13783_led_platform_data *led;
94
95#define MC13783_LED_TRIODE_MD (1 << 0)
96#define MC13783_LED_TRIODE_AD (1 << 1)
97#define MC13783_LED_TRIODE_KP (1 << 2)
98#define MC13783_LED_BOOST_EN (1 << 3)
99#define MC13783_LED_TC1HALF (1 << 4)
100#define MC13783_LED_SLEWLIMTC (1 << 5)
101#define MC13783_LED_SLEWLIMBL (1 << 6)
102#define MC13783_LED_TRIODE_TC1 (1 << 7)
103#define MC13783_LED_TRIODE_TC2 (1 << 8)
104#define MC13783_LED_TRIODE_TC3 (1 << 9)
105 int flags;
106
107#define MC13783_LED_AB_DISABLED 0
108#define MC13783_LED_AB_MD1 1
109#define MC13783_LED_AB_MD12 2
110#define MC13783_LED_AB_MD123 3
111#define MC13783_LED_AB_MD1234 4
112#define MC13783_LED_AB_MD1234_AD1 5
113#define MC13783_LED_AB_MD1234_AD12 6
114#define MC13783_LED_AB_MD1_AD 7
115 char abmode;
116
117#define MC13783_LED_ABREF_200MV 0
118#define MC13783_LED_ABREF_400MV 1
119#define MC13783_LED_ABREF_600MV 2
120#define MC13783_LED_ABREF_800MV 3
121 char abref;
122
123#define MC13783_LED_PERIOD_10MS 0
124#define MC13783_LED_PERIOD_100MS 1
125#define MC13783_LED_PERIOD_500MS 2
126#define MC13783_LED_PERIOD_2S 3
127 char bl_period;
128 char tc1_period;
129 char tc2_period;
130 char tc3_period;
131};
132
133/* to be cleaned up */
134struct regulator_init_data;
135
136struct mc13783_regulator_init_data {
137 int id;
138 struct regulator_init_data *init_data;
139};
140
141struct mc13783_regulator_platform_data {
142 int num_regulators;
143 struct mc13783_regulator_init_data *regulators;
144};
145
146struct mc13783_platform_data {
147 int num_regulators;
148 struct mc13783_regulator_init_data *regulators;
149 struct mc13783_leds_platform_data *leds;
150
151#define MC13783_USE_TOUCHSCREEN (1 << 0)
152#define MC13783_USE_CODEC (1 << 1)
153#define MC13783_USE_ADC (1 << 2)
154#define MC13783_USE_RTC (1 << 3)
155#define MC13783_USE_REGULATOR (1 << 4)
156#define MC13783_USE_LED (1 << 5)
157 unsigned int flags;
158};
159 117
160#define MC13783_ADC_MODE_TS 1 118#define MC13783_ADC_MODE_TS 1
161#define MC13783_ADC_MODE_SINGLE_CHAN 2 119#define MC13783_ADC_MODE_SINGLE_CHAN 2
@@ -165,80 +123,80 @@ int mc13783_adc_do_conversion(struct mc13783 *mc13783, unsigned int mode,
165 unsigned int channel, unsigned int *sample); 123 unsigned int channel, unsigned int *sample);
166 124
167 125
168#define MC13783_SW_SW1A 0 126#define MC13783_REG_SW1A 0
169#define MC13783_SW_SW1B 1 127#define MC13783_REG_SW1B 1
170#define MC13783_SW_SW2A 2 128#define MC13783_REG_SW2A 2
171#define MC13783_SW_SW2B 3 129#define MC13783_REG_SW2B 3
172#define MC13783_SW_SW3 4 130#define MC13783_REG_SW3 4
173#define MC13783_SW_PLL 5 131#define MC13783_REG_PLL 5
174#define MC13783_REGU_VAUDIO 6 132#define MC13783_REG_VAUDIO 6
175#define MC13783_REGU_VIOHI 7 133#define MC13783_REG_VIOHI 7
176#define MC13783_REGU_VIOLO 8 134#define MC13783_REG_VIOLO 8
177#define MC13783_REGU_VDIG 9 135#define MC13783_REG_VDIG 9
178#define MC13783_REGU_VGEN 10 136#define MC13783_REG_VGEN 10
179#define MC13783_REGU_VRFDIG 11 137#define MC13783_REG_VRFDIG 11
180#define MC13783_REGU_VRFREF 12 138#define MC13783_REG_VRFREF 12
181#define MC13783_REGU_VRFCP 13 139#define MC13783_REG_VRFCP 13
182#define MC13783_REGU_VSIM 14 140#define MC13783_REG_VSIM 14
183#define MC13783_REGU_VESIM 15 141#define MC13783_REG_VESIM 15
184#define MC13783_REGU_VCAM 16 142#define MC13783_REG_VCAM 16
185#define MC13783_REGU_VRFBG 17 143#define MC13783_REG_VRFBG 17
186#define MC13783_REGU_VVIB 18 144#define MC13783_REG_VVIB 18
187#define MC13783_REGU_VRF1 19 145#define MC13783_REG_VRF1 19
188#define MC13783_REGU_VRF2 20 146#define MC13783_REG_VRF2 20
189#define MC13783_REGU_VMMC1 21 147#define MC13783_REG_VMMC1 21
190#define MC13783_REGU_VMMC2 22 148#define MC13783_REG_VMMC2 22
191#define MC13783_REGU_GPO1 23 149#define MC13783_REG_GPO1 23
192#define MC13783_REGU_GPO2 24 150#define MC13783_REG_GPO2 24
193#define MC13783_REGU_GPO3 25 151#define MC13783_REG_GPO3 25
194#define MC13783_REGU_GPO4 26 152#define MC13783_REG_GPO4 26
195#define MC13783_REGU_V1 27 153#define MC13783_REG_V1 27
196#define MC13783_REGU_V2 28 154#define MC13783_REG_V2 28
197#define MC13783_REGU_V3 29 155#define MC13783_REG_V3 29
198#define MC13783_REGU_V4 30 156#define MC13783_REG_V4 30
199#define MC13783_REGU_PWGT1SPI 31 157#define MC13783_REG_PWGT1SPI 31
200#define MC13783_REGU_PWGT2SPI 32 158#define MC13783_REG_PWGT2SPI 32
201 159
202#define MC13783_IRQ_ADCDONE 0 160#define MC13783_IRQ_ADCDONE MC13XXX_IRQ_ADCDONE
203#define MC13783_IRQ_ADCBISDONE 1 161#define MC13783_IRQ_ADCBISDONE MC13XXX_IRQ_ADCBISDONE
204#define MC13783_IRQ_TS 2 162#define MC13783_IRQ_TS MC13XXX_IRQ_TS
205#define MC13783_IRQ_WHIGH 3 163#define MC13783_IRQ_WHIGH 3
206#define MC13783_IRQ_WLOW 4 164#define MC13783_IRQ_WLOW 4
207#define MC13783_IRQ_CHGDET 6 165#define MC13783_IRQ_CHGDET MC13XXX_IRQ_CHGDET
208#define MC13783_IRQ_CHGOV 7 166#define MC13783_IRQ_CHGOV 7
209#define MC13783_IRQ_CHGREV 8 167#define MC13783_IRQ_CHGREV MC13XXX_IRQ_CHGREV
210#define MC13783_IRQ_CHGSHORT 9 168#define MC13783_IRQ_CHGSHORT MC13XXX_IRQ_CHGSHORT
211#define MC13783_IRQ_CCCV 10 169#define MC13783_IRQ_CCCV MC13XXX_IRQ_CCCV
212#define MC13783_IRQ_CHGCURR 11 170#define MC13783_IRQ_CHGCURR MC13XXX_IRQ_CHGCURR
213#define MC13783_IRQ_BPON 12 171#define MC13783_IRQ_BPON MC13XXX_IRQ_BPON
214#define MC13783_IRQ_LOBATL 13 172#define MC13783_IRQ_LOBATL MC13XXX_IRQ_LOBATL
215#define MC13783_IRQ_LOBATH 14 173#define MC13783_IRQ_LOBATH MC13XXX_IRQ_LOBATH
216#define MC13783_IRQ_UDP 15 174#define MC13783_IRQ_UDP 15
217#define MC13783_IRQ_USB 16 175#define MC13783_IRQ_USB 16
218#define MC13783_IRQ_ID 19 176#define MC13783_IRQ_ID 19
219#define MC13783_IRQ_SE1 21 177#define MC13783_IRQ_SE1 21
220#define MC13783_IRQ_CKDET 22 178#define MC13783_IRQ_CKDET 22
221#define MC13783_IRQ_UDM 23 179#define MC13783_IRQ_UDM 23
222#define MC13783_IRQ_1HZ 24 180#define MC13783_IRQ_1HZ MC13XXX_IRQ_1HZ
223#define MC13783_IRQ_TODA 25 181#define MC13783_IRQ_TODA MC13XXX_IRQ_TODA
224#define MC13783_IRQ_ONOFD1 27 182#define MC13783_IRQ_ONOFD1 27
225#define MC13783_IRQ_ONOFD2 28 183#define MC13783_IRQ_ONOFD2 28
226#define MC13783_IRQ_ONOFD3 29 184#define MC13783_IRQ_ONOFD3 29
227#define MC13783_IRQ_SYSRST 30 185#define MC13783_IRQ_SYSRST MC13XXX_IRQ_SYSRST
228#define MC13783_IRQ_RTCRST 31 186#define MC13783_IRQ_RTCRST MC13XXX_IRQ_RTCRST
229#define MC13783_IRQ_PC 32 187#define MC13783_IRQ_PC MC13XXX_IRQ_PC
230#define MC13783_IRQ_WARM 33 188#define MC13783_IRQ_WARM MC13XXX_IRQ_WARM
231#define MC13783_IRQ_MEMHLD 34 189#define MC13783_IRQ_MEMHLD MC13XXX_IRQ_MEMHLD
232#define MC13783_IRQ_PWRRDY 35 190#define MC13783_IRQ_PWRRDY 35
233#define MC13783_IRQ_THWARNL 36 191#define MC13783_IRQ_THWARNL MC13XXX_IRQ_THWARNL
234#define MC13783_IRQ_THWARNH 37 192#define MC13783_IRQ_THWARNH MC13XXX_IRQ_THWARNH
235#define MC13783_IRQ_CLK 38 193#define MC13783_IRQ_CLK MC13XXX_IRQ_CLK
236#define MC13783_IRQ_SEMAF 39 194#define MC13783_IRQ_SEMAF 39
237#define MC13783_IRQ_MC2B 41 195#define MC13783_IRQ_MC2B 41
238#define MC13783_IRQ_HSDET 42 196#define MC13783_IRQ_HSDET 42
239#define MC13783_IRQ_HSL 43 197#define MC13783_IRQ_HSL 43
240#define MC13783_IRQ_ALSPTH 44 198#define MC13783_IRQ_ALSPTH 44
241#define MC13783_IRQ_AHSSHORT 45 199#define MC13783_IRQ_AHSSHORT 45
242#define MC13783_NUM_IRQ 46 200#define MC13783_NUM_IRQ MC13XXX_NUM_IRQ
243 201
244#endif /* __LINUX_MFD_MC13783_H */ 202#endif /* ifndef __LINUX_MFD_MC13783_H */
diff --git a/include/linux/mfd/mc13892.h b/include/linux/mfd/mc13892.h
new file mode 100644
index 000000000000..a00f2bec178c
--- /dev/null
+++ b/include/linux/mfd/mc13892.h
@@ -0,0 +1,39 @@
1/*
2 * Copyright 2010 Yong Shen <yong.shen@linaro.org>
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License version 2 as published by the
6 * Free Software Foundation.
7 */
8
9#ifndef __LINUX_MFD_MC13892_H
10#define __LINUX_MFD_MC13892_H
11
12#include <linux/mfd/mc13xxx.h>
13
14#define MC13892_SW1 0
15#define MC13892_SW2 1
16#define MC13892_SW3 2
17#define MC13892_SW4 3
18#define MC13892_SWBST 4
19#define MC13892_VIOHI 5
20#define MC13892_VPLL 6
21#define MC13892_VDIG 7
22#define MC13892_VSD 8
23#define MC13892_VUSB2 9
24#define MC13892_VVIDEO 10
25#define MC13892_VAUDIO 11
26#define MC13892_VCAM 12
27#define MC13892_VGEN1 13
28#define MC13892_VGEN2 14
29#define MC13892_VGEN3 15
30#define MC13892_VUSB 16
31#define MC13892_GPO1 17
32#define MC13892_GPO2 18
33#define MC13892_GPO3 19
34#define MC13892_GPO4 20
35#define MC13892_PWGT1SPI 21
36#define MC13892_PWGT2SPI 22
37#define MC13892_VCOINCELL 23
38
39#endif
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
new file mode 100644
index 000000000000..c064beaaccb7
--- /dev/null
+++ b/include/linux/mfd/mc13xxx.h
@@ -0,0 +1,153 @@
1/*
2 * Copyright 2009-2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#ifndef __LINUX_MFD_MC13XXX_H
10#define __LINUX_MFD_MC13XXX_H
11
12#include <linux/interrupt.h>
13
14struct mc13xxx;
15
16void mc13xxx_lock(struct mc13xxx *mc13xxx);
17void mc13xxx_unlock(struct mc13xxx *mc13xxx);
18
19int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val);
20int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val);
21int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset,
22 u32 mask, u32 val);
23
24int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
25
26int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq,
27 irq_handler_t handler, const char *name, void *dev);
28int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq,
29 irq_handler_t handler, const char *name, void *dev);
30int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev);
31
32int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq);
33int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
34int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq,
35 int *enabled, int *pending);
36int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq);
37
38int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
39
40#define MC13XXX_IRQ_ADCDONE 0
41#define MC13XXX_IRQ_ADCBISDONE 1
42#define MC13XXX_IRQ_TS 2
43#define MC13XXX_IRQ_CHGDET 6
44#define MC13XXX_IRQ_CHGREV 8
45#define MC13XXX_IRQ_CHGSHORT 9
46#define MC13XXX_IRQ_CCCV 10
47#define MC13XXX_IRQ_CHGCURR 11
48#define MC13XXX_IRQ_BPON 12
49#define MC13XXX_IRQ_LOBATL 13
50#define MC13XXX_IRQ_LOBATH 14
51#define MC13XXX_IRQ_1HZ 24
52#define MC13XXX_IRQ_TODA 25
53#define MC13XXX_IRQ_SYSRST 30
54#define MC13XXX_IRQ_RTCRST 31
55#define MC13XXX_IRQ_PC 32
56#define MC13XXX_IRQ_WARM 33
57#define MC13XXX_IRQ_MEMHLD 34
58#define MC13XXX_IRQ_THWARNL 36
59#define MC13XXX_IRQ_THWARNH 37
60#define MC13XXX_IRQ_CLK 38
61
62#define MC13XXX_NUM_IRQ 46
63
64struct regulator_init_data;
65
66struct mc13xxx_regulator_init_data {
67 int id;
68 struct regulator_init_data *init_data;
69};
70
71struct mc13xxx_regulator_platform_data {
72 int num_regulators;
73 struct mc13xxx_regulator_init_data *regulators;
74};
75
76struct mc13xxx_led_platform_data {
77#define MC13783_LED_MD 0
78#define MC13783_LED_AD 1
79#define MC13783_LED_KP 2
80#define MC13783_LED_R1 3
81#define MC13783_LED_G1 4
82#define MC13783_LED_B1 5
83#define MC13783_LED_R2 6
84#define MC13783_LED_G2 7
85#define MC13783_LED_B2 8
86#define MC13783_LED_R3 9
87#define MC13783_LED_G3 10
88#define MC13783_LED_B3 11
89#define MC13783_LED_MAX MC13783_LED_B3
90 int id;
91 const char *name;
92 const char *default_trigger;
93
94/* Three or two bits current selection depending on the led */
95 char max_current;
96};
97
98struct mc13xxx_leds_platform_data {
99 int num_leds;
100 struct mc13xxx_led_platform_data *led;
101
102#define MC13783_LED_TRIODE_MD (1 << 0)
103#define MC13783_LED_TRIODE_AD (1 << 1)
104#define MC13783_LED_TRIODE_KP (1 << 2)
105#define MC13783_LED_BOOST_EN (1 << 3)
106#define MC13783_LED_TC1HALF (1 << 4)
107#define MC13783_LED_SLEWLIMTC (1 << 5)
108#define MC13783_LED_SLEWLIMBL (1 << 6)
109#define MC13783_LED_TRIODE_TC1 (1 << 7)
110#define MC13783_LED_TRIODE_TC2 (1 << 8)
111#define MC13783_LED_TRIODE_TC3 (1 << 9)
112 int flags;
113
114#define MC13783_LED_AB_DISABLED 0
115#define MC13783_LED_AB_MD1 1
116#define MC13783_LED_AB_MD12 2
117#define MC13783_LED_AB_MD123 3
118#define MC13783_LED_AB_MD1234 4
119#define MC13783_LED_AB_MD1234_AD1 5
120#define MC13783_LED_AB_MD1234_AD12 6
121#define MC13783_LED_AB_MD1_AD 7
122 char abmode;
123
124#define MC13783_LED_ABREF_200MV 0
125#define MC13783_LED_ABREF_400MV 1
126#define MC13783_LED_ABREF_600MV 2
127#define MC13783_LED_ABREF_800MV 3
128 char abref;
129
130#define MC13783_LED_PERIOD_10MS 0
131#define MC13783_LED_PERIOD_100MS 1
132#define MC13783_LED_PERIOD_500MS 2
133#define MC13783_LED_PERIOD_2S 3
134 char bl_period;
135 char tc1_period;
136 char tc2_period;
137 char tc3_period;
138};
139
140struct mc13xxx_platform_data {
141#define MC13XXX_USE_TOUCHSCREEN (1 << 0)
142#define MC13XXX_USE_CODEC (1 << 1)
143#define MC13XXX_USE_ADC (1 << 2)
144#define MC13XXX_USE_RTC (1 << 3)
145#define MC13XXX_USE_REGULATOR (1 << 4)
146#define MC13XXX_USE_LED (1 << 5)
147 unsigned int flags;
148
149 struct mc13xxx_regulator_platform_data regulators;
150 struct mc13xxx_leds_platform_data *leds;
151};
152
153#endif /* ifndef __LINUX_MFD_MC13XXX_H */
diff --git a/include/linux/mfd/pcf50633/core.h b/include/linux/mfd/pcf50633/core.h
index ad411a78870c..50d4a047118d 100644
--- a/include/linux/mfd/pcf50633/core.h
+++ b/include/linux/mfd/pcf50633/core.h
@@ -227,4 +227,11 @@ static inline struct pcf50633 *dev_to_pcf50633(struct device *dev)
227 return dev_get_drvdata(dev); 227 return dev_get_drvdata(dev);
228} 228}
229 229
230int pcf50633_irq_init(struct pcf50633 *pcf, int irq);
231void pcf50633_irq_free(struct pcf50633 *pcf);
232#ifdef CONFIG_PM
233int pcf50633_irq_suspend(struct pcf50633 *pcf);
234int pcf50633_irq_resume(struct pcf50633 *pcf);
235#endif
236
230#endif 237#endif
diff --git a/include/linux/mfd/pm8xxx/core.h b/include/linux/mfd/pm8xxx/core.h
new file mode 100644
index 000000000000..bd2f4f64e931
--- /dev/null
+++ b/include/linux/mfd/pm8xxx/core.h
@@ -0,0 +1,81 @@
1/*
2 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13/*
14 * Qualcomm PMIC 8xxx driver header file
15 *
16 */
17
18#ifndef __MFD_PM8XXX_CORE_H
19#define __MFD_PM8XXX_CORE_H
20
21#include <linux/mfd/core.h>
22
23struct pm8xxx_drvdata {
24 int (*pmic_readb) (const struct device *dev, u16 addr, u8 *val);
25 int (*pmic_writeb) (const struct device *dev, u16 addr, u8 val);
26 int (*pmic_read_buf) (const struct device *dev, u16 addr, u8 *buf,
27 int n);
28 int (*pmic_write_buf) (const struct device *dev, u16 addr, u8 *buf,
29 int n);
30 int (*pmic_read_irq_stat) (const struct device *dev, int irq);
31 void *pm_chip_data;
32};
33
34static inline int pm8xxx_readb(const struct device *dev, u16 addr, u8 *val)
35{
36 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
37
38 if (!dd)
39 return -EINVAL;
40 return dd->pmic_readb(dev, addr, val);
41}
42
43static inline int pm8xxx_writeb(const struct device *dev, u16 addr, u8 val)
44{
45 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
46
47 if (!dd)
48 return -EINVAL;
49 return dd->pmic_writeb(dev, addr, val);
50}
51
52static inline int pm8xxx_read_buf(const struct device *dev, u16 addr, u8 *buf,
53 int n)
54{
55 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
56
57 if (!dd)
58 return -EINVAL;
59 return dd->pmic_read_buf(dev, addr, buf, n);
60}
61
62static inline int pm8xxx_write_buf(const struct device *dev, u16 addr, u8 *buf,
63 int n)
64{
65 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
66
67 if (!dd)
68 return -EINVAL;
69 return dd->pmic_write_buf(dev, addr, buf, n);
70}
71
72static inline int pm8xxx_read_irq_stat(const struct device *dev, int irq)
73{
74 struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
75
76 if (!dd)
77 return -EINVAL;
78 return dd->pmic_read_irq_stat(dev, irq);
79}
80
81#endif
diff --git a/include/linux/mfd/pm8xxx/irq.h b/include/linux/mfd/pm8xxx/irq.h
new file mode 100644
index 000000000000..4b21769f4483
--- /dev/null
+++ b/include/linux/mfd/pm8xxx/irq.h
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13/*
14 * Qualcomm PMIC irq 8xxx driver header file
15 *
16 */
17
18#ifndef __MFD_PM8XXX_IRQ_H
19#define __MFD_PM8XXX_IRQ_H
20
21#include <linux/errno.h>
22#include <linux/err.h>
23
24struct pm8xxx_irq_core_data {
25 u32 rev;
26 int nirqs;
27};
28
29struct pm8xxx_irq_platform_data {
30 int irq_base;
31 struct pm8xxx_irq_core_data irq_cdata;
32 int devirq;
33 int irq_trigger_flag;
34};
35
36struct pm_irq_chip;
37
38#ifdef CONFIG_MFD_PM8XXX_IRQ
39int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq);
40struct pm_irq_chip * __devinit pm8xxx_irq_init(struct device *dev,
41 const struct pm8xxx_irq_platform_data *pdata);
42int __devexit pm8xxx_irq_exit(struct pm_irq_chip *chip);
43#else
44static inline int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq)
45{
46 return -ENXIO;
47}
48static inline struct pm_irq_chip * __devinit pm8xxx_irq_init(
49 const struct device *dev,
50 const struct pm8xxx_irq_platform_data *pdata)
51{
52 return ERR_PTR(-ENXIO);
53}
54static inline int __devexit pm8xxx_irq_exit(struct pm_irq_chip *chip)
55{
56 return -ENXIO;
57}
58#endif /* CONFIG_MFD_PM8XXX_IRQ */
59#endif /* __MFD_PM8XXX_IRQ_H */
diff --git a/include/linux/mfd/pm8xxx/pm8921.h b/include/linux/mfd/pm8xxx/pm8921.h
new file mode 100644
index 000000000000..d5517fd32d1b
--- /dev/null
+++ b/include/linux/mfd/pm8xxx/pm8921.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13/*
14 * Qualcomm PMIC 8921 driver header file
15 *
16 */
17
18#ifndef __MFD_PM8921_H
19#define __MFD_PM8921_H
20
21#include <linux/device.h>
22#include <linux/mfd/pm8xxx/irq.h>
23
24#define PM8921_NR_IRQS 256
25
26struct pm8921_platform_data {
27 int irq_base;
28 struct pm8xxx_irq_platform_data *irq_pdata;
29};
30
31#endif
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 39ca7588659b..e762c270d8d4 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -112,13 +112,19 @@ struct stmpe_keypad_platform_data {
112 bool no_autorepeat; 112 bool no_autorepeat;
113}; 113};
114 114
115#define STMPE_GPIO_NOREQ_811_TOUCH (0xf0)
116
115/** 117/**
116 * struct stmpe_gpio_platform_data - STMPE GPIO platform data 118 * struct stmpe_gpio_platform_data - STMPE GPIO platform data
117 * @gpio_base: first gpio number assigned. A maximum of 119 * @gpio_base: first gpio number assigned. A maximum of
118 * %STMPE_NR_GPIOS GPIOs will be allocated. 120 * %STMPE_NR_GPIOS GPIOs will be allocated.
121 * @norequest_mask: bitmask specifying which GPIOs should _not_ be
122 * requestable due to different usage (e.g. touch, keypad)
123 * STMPE_GPIO_NOREQ_* macros can be used here.
119 */ 124 */
120struct stmpe_gpio_platform_data { 125struct stmpe_gpio_platform_data {
121 int gpio_base; 126 int gpio_base;
127 unsigned norequest_mask;
122 void (*setup)(struct stmpe *stmpe, unsigned gpio_base); 128 void (*setup)(struct stmpe *stmpe, unsigned gpio_base);
123 void (*remove)(struct stmpe *stmpe, unsigned gpio_base); 129 void (*remove)(struct stmpe *stmpe, unsigned gpio_base);
124}; 130};
diff --git a/include/linux/mfd/tc35892.h b/include/linux/mfd/tc35892.h
deleted file mode 100644
index e47f770d3068..000000000000
--- a/include/linux/mfd/tc35892.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License, version 2
5 */
6
7#ifndef __LINUX_MFD_TC35892_H
8#define __LINUX_MFD_TC35892_H
9
10#include <linux/device.h>
11
12#define TC35892_RSTCTRL_IRQRST (1 << 4)
13#define TC35892_RSTCTRL_TIMRST (1 << 3)
14#define TC35892_RSTCTRL_ROTRST (1 << 2)
15#define TC35892_RSTCTRL_KBDRST (1 << 1)
16#define TC35892_RSTCTRL_GPIRST (1 << 0)
17
18#define TC35892_IRQST 0x91
19
20#define TC35892_MANFCODE_MAGIC 0x03
21#define TC35892_MANFCODE 0x80
22#define TC35892_VERSION 0x81
23#define TC35892_IOCFG 0xA7
24
25#define TC35892_CLKMODE 0x88
26#define TC35892_CLKCFG 0x89
27#define TC35892_CLKEN 0x8A
28
29#define TC35892_RSTCTRL 0x82
30#define TC35892_EXTRSTN 0x83
31#define TC35892_RSTINTCLR 0x84
32
33#define TC35892_GPIOIS0 0xC9
34#define TC35892_GPIOIS1 0xCA
35#define TC35892_GPIOIS2 0xCB
36#define TC35892_GPIOIBE0 0xCC
37#define TC35892_GPIOIBE1 0xCD
38#define TC35892_GPIOIBE2 0xCE
39#define TC35892_GPIOIEV0 0xCF
40#define TC35892_GPIOIEV1 0xD0
41#define TC35892_GPIOIEV2 0xD1
42#define TC35892_GPIOIE0 0xD2
43#define TC35892_GPIOIE1 0xD3
44#define TC35892_GPIOIE2 0xD4
45#define TC35892_GPIORIS0 0xD6
46#define TC35892_GPIORIS1 0xD7
47#define TC35892_GPIORIS2 0xD8
48#define TC35892_GPIOMIS0 0xD9
49#define TC35892_GPIOMIS1 0xDA
50#define TC35892_GPIOMIS2 0xDB
51#define TC35892_GPIOIC0 0xDC
52#define TC35892_GPIOIC1 0xDD
53#define TC35892_GPIOIC2 0xDE
54
55#define TC35892_GPIODATA0 0xC0
56#define TC35892_GPIOMASK0 0xc1
57#define TC35892_GPIODATA1 0xC2
58#define TC35892_GPIOMASK1 0xc3
59#define TC35892_GPIODATA2 0xC4
60#define TC35892_GPIOMASK2 0xC5
61
62#define TC35892_GPIODIR0 0xC6
63#define TC35892_GPIODIR1 0xC7
64#define TC35892_GPIODIR2 0xC8
65
66#define TC35892_GPIOSYNC0 0xE6
67#define TC35892_GPIOSYNC1 0xE7
68#define TC35892_GPIOSYNC2 0xE8
69
70#define TC35892_GPIOWAKE0 0xE9
71#define TC35892_GPIOWAKE1 0xEA
72#define TC35892_GPIOWAKE2 0xEB
73
74#define TC35892_GPIOODM0 0xE0
75#define TC35892_GPIOODE0 0xE1
76#define TC35892_GPIOODM1 0xE2
77#define TC35892_GPIOODE1 0xE3
78#define TC35892_GPIOODM2 0xE4
79#define TC35892_GPIOODE2 0xE5
80
81#define TC35892_INT_GPIIRQ 0
82#define TC35892_INT_TI0IRQ 1
83#define TC35892_INT_TI1IRQ 2
84#define TC35892_INT_TI2IRQ 3
85#define TC35892_INT_ROTIRQ 5
86#define TC35892_INT_KBDIRQ 6
87#define TC35892_INT_PORIRQ 7
88
89#define TC35892_NR_INTERNAL_IRQS 8
90#define TC35892_INT_GPIO(x) (TC35892_NR_INTERNAL_IRQS + (x))
91
92struct tc35892 {
93 struct mutex lock;
94 struct device *dev;
95 struct i2c_client *i2c;
96
97 int irq_base;
98 int num_gpio;
99 struct tc35892_platform_data *pdata;
100};
101
102extern int tc35892_reg_write(struct tc35892 *tc35892, u8 reg, u8 data);
103extern int tc35892_reg_read(struct tc35892 *tc35892, u8 reg);
104extern int tc35892_block_read(struct tc35892 *tc35892, u8 reg, u8 length,
105 u8 *values);
106extern int tc35892_block_write(struct tc35892 *tc35892, u8 reg, u8 length,
107 const u8 *values);
108extern int tc35892_set_bits(struct tc35892 *tc35892, u8 reg, u8 mask, u8 val);
109
110/**
111 * struct tc35892_gpio_platform_data - TC35892 GPIO platform data
112 * @gpio_base: first gpio number assigned to TC35892. A maximum of
113 * %TC35892_NR_GPIOS GPIOs will be allocated.
114 */
115struct tc35892_gpio_platform_data {
116 int gpio_base;
117};
118
119/**
120 * struct tc35892_platform_data - TC35892 platform data
121 * @irq_base: base IRQ number. %TC35892_NR_IRQS irqs will be used.
122 * @gpio: GPIO-specific platform data
123 */
124struct tc35892_platform_data {
125 int irq_base;
126 struct tc35892_gpio_platform_data *gpio;
127};
128
129#define TC35892_NR_GPIOS 24
130#define TC35892_NR_IRQS TC35892_INT_GPIO(TC35892_NR_GPIOS)
131
132#endif
diff --git a/include/linux/mfd/tc3589x.h b/include/linux/mfd/tc3589x.h
new file mode 100644
index 000000000000..16c76e124f9c
--- /dev/null
+++ b/include/linux/mfd/tc3589x.h
@@ -0,0 +1,195 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License, version 2
5 */
6
7#ifndef __LINUX_MFD_TC3589x_H
8#define __LINUX_MFD_TC3589x_H
9
10#include <linux/device.h>
11
12enum tx3589x_block {
13 TC3589x_BLOCK_GPIO = 1 << 0,
14 TC3589x_BLOCK_KEYPAD = 1 << 1,
15};
16
17#define TC3589x_RSTCTRL_IRQRST (1 << 4)
18#define TC3589x_RSTCTRL_TIMRST (1 << 3)
19#define TC3589x_RSTCTRL_ROTRST (1 << 2)
20#define TC3589x_RSTCTRL_KBDRST (1 << 1)
21#define TC3589x_RSTCTRL_GPIRST (1 << 0)
22
23/* Keyboard Configuration Registers */
24#define TC3589x_KBDSETTLE_REG 0x01
25#define TC3589x_KBDBOUNCE 0x02
26#define TC3589x_KBDSIZE 0x03
27#define TC3589x_KBCFG_LSB 0x04
28#define TC3589x_KBCFG_MSB 0x05
29#define TC3589x_KBDIC 0x08
30#define TC3589x_KBDMSK 0x09
31#define TC3589x_EVTCODE_FIFO 0x10
32#define TC3589x_KBDMFS 0x8F
33
34#define TC3589x_IRQST 0x91
35
36#define TC3589x_MANFCODE_MAGIC 0x03
37#define TC3589x_MANFCODE 0x80
38#define TC3589x_VERSION 0x81
39#define TC3589x_IOCFG 0xA7
40
41#define TC3589x_CLKMODE 0x88
42#define TC3589x_CLKCFG 0x89
43#define TC3589x_CLKEN 0x8A
44
45#define TC3589x_RSTCTRL 0x82
46#define TC3589x_EXTRSTN 0x83
47#define TC3589x_RSTINTCLR 0x84
48
49/* Pull up/down configuration registers */
50#define TC3589x_IOCFG 0xA7
51#define TC3589x_IOPULLCFG0_LSB 0xAA
52#define TC3589x_IOPULLCFG0_MSB 0xAB
53#define TC3589x_IOPULLCFG1_LSB 0xAC
54#define TC3589x_IOPULLCFG1_MSB 0xAD
55#define TC3589x_IOPULLCFG2_LSB 0xAE
56
57#define TC3589x_GPIOIS0 0xC9
58#define TC3589x_GPIOIS1 0xCA
59#define TC3589x_GPIOIS2 0xCB
60#define TC3589x_GPIOIBE0 0xCC
61#define TC3589x_GPIOIBE1 0xCD
62#define TC3589x_GPIOIBE2 0xCE
63#define TC3589x_GPIOIEV0 0xCF
64#define TC3589x_GPIOIEV1 0xD0
65#define TC3589x_GPIOIEV2 0xD1
66#define TC3589x_GPIOIE0 0xD2
67#define TC3589x_GPIOIE1 0xD3
68#define TC3589x_GPIOIE2 0xD4
69#define TC3589x_GPIORIS0 0xD6
70#define TC3589x_GPIORIS1 0xD7
71#define TC3589x_GPIORIS2 0xD8
72#define TC3589x_GPIOMIS0 0xD9
73#define TC3589x_GPIOMIS1 0xDA
74#define TC3589x_GPIOMIS2 0xDB
75#define TC3589x_GPIOIC0 0xDC
76#define TC3589x_GPIOIC1 0xDD
77#define TC3589x_GPIOIC2 0xDE
78
79#define TC3589x_GPIODATA0 0xC0
80#define TC3589x_GPIOMASK0 0xc1
81#define TC3589x_GPIODATA1 0xC2
82#define TC3589x_GPIOMASK1 0xc3
83#define TC3589x_GPIODATA2 0xC4
84#define TC3589x_GPIOMASK2 0xC5
85
86#define TC3589x_GPIODIR0 0xC6
87#define TC3589x_GPIODIR1 0xC7
88#define TC3589x_GPIODIR2 0xC8
89
90#define TC3589x_GPIOSYNC0 0xE6
91#define TC3589x_GPIOSYNC1 0xE7
92#define TC3589x_GPIOSYNC2 0xE8
93
94#define TC3589x_GPIOWAKE0 0xE9
95#define TC3589x_GPIOWAKE1 0xEA
96#define TC3589x_GPIOWAKE2 0xEB
97
98#define TC3589x_GPIOODM0 0xE0
99#define TC3589x_GPIOODE0 0xE1
100#define TC3589x_GPIOODM1 0xE2
101#define TC3589x_GPIOODE1 0xE3
102#define TC3589x_GPIOODM2 0xE4
103#define TC3589x_GPIOODE2 0xE5
104
105#define TC3589x_INT_GPIIRQ 0
106#define TC3589x_INT_TI0IRQ 1
107#define TC3589x_INT_TI1IRQ 2
108#define TC3589x_INT_TI2IRQ 3
109#define TC3589x_INT_ROTIRQ 5
110#define TC3589x_INT_KBDIRQ 6
111#define TC3589x_INT_PORIRQ 7
112
113#define TC3589x_NR_INTERNAL_IRQS 8
114#define TC3589x_INT_GPIO(x) (TC3589x_NR_INTERNAL_IRQS + (x))
115
116struct tc3589x {
117 struct mutex lock;
118 struct device *dev;
119 struct i2c_client *i2c;
120
121 int irq_base;
122 int num_gpio;
123 struct tc3589x_platform_data *pdata;
124};
125
126extern int tc3589x_reg_write(struct tc3589x *tc3589x, u8 reg, u8 data);
127extern int tc3589x_reg_read(struct tc3589x *tc3589x, u8 reg);
128extern int tc3589x_block_read(struct tc3589x *tc3589x, u8 reg, u8 length,
129 u8 *values);
130extern int tc3589x_block_write(struct tc3589x *tc3589x, u8 reg, u8 length,
131 const u8 *values);
132extern int tc3589x_set_bits(struct tc3589x *tc3589x, u8 reg, u8 mask, u8 val);
133
134/*
135 * Keypad related platform specific constants
136 * These values may be modified for fine tuning
137 */
138#define TC_KPD_ROWS 0x8
139#define TC_KPD_COLUMNS 0x8
140#define TC_KPD_DEBOUNCE_PERIOD 0xA3
141#define TC_KPD_SETTLE_TIME 0xA3
142
143/**
144 * struct tc35893_platform_data - data structure for platform specific data
145 * @keymap_data: matrix scan code table for keycodes
146 * @krow: mask for available rows, value is 0xFF
147 * @kcol: mask for available columns, value is 0xFF
148 * @debounce_period: platform specific debounce time
149 * @settle_time: platform specific settle down time
150 * @irqtype: type of interrupt, falling or rising edge
151 * @enable_wakeup: specifies if keypad event can wake up system from sleep
152 * @no_autorepeat: flag for auto repetition
153 */
154struct tc3589x_keypad_platform_data {
155 const struct matrix_keymap_data *keymap_data;
156 u8 krow;
157 u8 kcol;
158 u8 debounce_period;
159 u8 settle_time;
160 unsigned long irqtype;
161 bool enable_wakeup;
162 bool no_autorepeat;
163};
164
165/**
166 * struct tc3589x_gpio_platform_data - TC3589x GPIO platform data
167 * @gpio_base: first gpio number assigned to TC3589x. A maximum of
168 * %TC3589x_NR_GPIOS GPIOs will be allocated.
169 * @setup: callback for board-specific initialization
170 * @remove: callback for board-specific teardown
171 */
172struct tc3589x_gpio_platform_data {
173 int gpio_base;
174 void (*setup)(struct tc3589x *tc3589x, unsigned gpio_base);
175 void (*remove)(struct tc3589x *tc3589x, unsigned gpio_base);
176};
177
178/**
179 * struct tc3589x_platform_data - TC3589x platform data
180 * @block: bitmask of blocks to enable (use TC3589x_BLOCK_*)
181 * @irq_base: base IRQ number. %TC3589x_NR_IRQS irqs will be used.
182 * @gpio: GPIO-specific platform data
183 * @keypad: keypad-specific platform data
184 */
185struct tc3589x_platform_data {
186 unsigned int block;
187 int irq_base;
188 struct tc3589x_gpio_platform_data *gpio;
189 const struct tc3589x_keypad_platform_data *keypad;
190};
191
192#define TC3589x_NR_GPIOS 24
193#define TC3589x_NR_IRQS TC3589x_INT_GPIO(TC3589x_NR_GPIOS)
194
195#endif
diff --git a/include/linux/mfd/ti_ssp.h b/include/linux/mfd/ti_ssp.h
new file mode 100644
index 000000000000..dbb4b43bd20e
--- /dev/null
+++ b/include/linux/mfd/ti_ssp.h
@@ -0,0 +1,93 @@
1/*
2 * Sequencer Serial Port (SSP) driver for Texas Instruments' SoCs
3 *
4 * Copyright (C) 2010 Texas Instruments Inc
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef __TI_SSP_H__
22#define __TI_SSP_H__
23
24struct ti_ssp_dev_data {
25 const char *dev_name;
26 void *pdata;
27 size_t pdata_size;
28};
29
30struct ti_ssp_data {
31 unsigned long out_clock;
32 struct ti_ssp_dev_data dev_data[2];
33};
34
35struct ti_ssp_spi_data {
36 unsigned long iosel;
37 int num_cs;
38 void (*select)(int cs);
39};
40
41/*
42 * Sequencer port IO pin configuration bits. These do not correlate 1-1 with
43 * the hardware. The iosel field in the port data combines iosel1 and iosel2,
44 * and is therefore not a direct map to register space. It is best to use the
45 * macros below to construct iosel values.
46 *
47 * least significant 16 bits --> iosel1
48 * most significant 16 bits --> iosel2
49 */
50
51#define SSP_IN 0x0000
52#define SSP_DATA 0x0001
53#define SSP_CLOCK 0x0002
54#define SSP_CHIPSEL 0x0003
55#define SSP_OUT 0x0004
56#define SSP_PIN_SEL(pin, v) ((v) << ((pin) * 3))
57#define SSP_PIN_MASK(pin) SSP_PIN_SEL(pin, 0x7)
58#define SSP_INPUT_SEL(pin) ((pin) << 16)
59
60/* Sequencer port config bits */
61#define SSP_EARLY_DIN BIT(8)
62#define SSP_DELAY_DOUT BIT(9)
63
64/* Sequence map definitions */
65#define SSP_CLK_HIGH BIT(0)
66#define SSP_CLK_LOW 0
67#define SSP_DATA_HIGH BIT(1)
68#define SSP_DATA_LOW 0
69#define SSP_CS_HIGH BIT(2)
70#define SSP_CS_LOW 0
71#define SSP_OUT_MODE BIT(3)
72#define SSP_IN_MODE 0
73#define SSP_DATA_REG BIT(4)
74#define SSP_ADDR_REG 0
75
76#define SSP_OPCODE_DIRECT ((0x0) << 5)
77#define SSP_OPCODE_TOGGLE ((0x1) << 5)
78#define SSP_OPCODE_SHIFT ((0x2) << 5)
79#define SSP_OPCODE_BRANCH0 ((0x4) << 5)
80#define SSP_OPCODE_BRANCH1 ((0x5) << 5)
81#define SSP_OPCODE_BRANCH ((0x6) << 5)
82#define SSP_OPCODE_STOP ((0x7) << 5)
83#define SSP_BRANCH(addr) ((addr) << 8)
84#define SSP_COUNT(cycles) ((cycles) << 8)
85
86int ti_ssp_raw_read(struct device *dev);
87int ti_ssp_raw_write(struct device *dev, u32 val);
88int ti_ssp_load(struct device *dev, int offs, u32* prog, int len);
89int ti_ssp_run(struct device *dev, u32 pc, u32 input, u32 *output);
90int ti_ssp_set_mode(struct device *dev, int mode);
91int ti_ssp_set_iosel(struct device *dev, u32 iosel);
92
93#endif /* __TI_SSP_H__ */
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index f07425bc3dcd..5a90266c3a5a 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -4,6 +4,7 @@
4#include <linux/fb.h> 4#include <linux/fb.h>
5#include <linux/io.h> 5#include <linux/io.h>
6#include <linux/platform_device.h> 6#include <linux/platform_device.h>
7#include <linux/pm_runtime.h>
7 8
8#define tmio_ioread8(addr) readb(addr) 9#define tmio_ioread8(addr) readb(addr)
9#define tmio_ioread16(addr) readw(addr) 10#define tmio_ioread16(addr) readw(addr)
@@ -52,6 +53,21 @@
52 53
53/* tmio MMC platform flags */ 54/* tmio MMC platform flags */
54#define TMIO_MMC_WRPROTECT_DISABLE (1 << 0) 55#define TMIO_MMC_WRPROTECT_DISABLE (1 << 0)
56/*
57 * Some controllers can support a 2-byte block size when the bus width
58 * is configured in 4-bit mode.
59 */
60#define TMIO_MMC_BLKSZ_2BYTES (1 << 1)
61/*
62 * Some controllers can support SDIO IRQ signalling.
63 */
64#define TMIO_MMC_SDIO_IRQ (1 << 2)
65/*
66 * Some platforms can detect card insertion events with controller powered
67 * down, in which case they have to call tmio_mmc_cd_wakeup() to power up the
68 * controller and report the event to the driver.
69 */
70#define TMIO_MMC_HAS_COLD_CD (1 << 3)
55 71
56int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base); 72int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base);
57int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base); 73int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base);
@@ -61,6 +77,7 @@ void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state);
61struct tmio_mmc_dma { 77struct tmio_mmc_dma {
62 void *chan_priv_tx; 78 void *chan_priv_tx;
63 void *chan_priv_rx; 79 void *chan_priv_rx;
80 int alignment_shift;
64}; 81};
65 82
66/* 83/*
@@ -72,10 +89,21 @@ struct tmio_mmc_data {
72 unsigned long flags; 89 unsigned long flags;
73 u32 ocr_mask; /* available voltages */ 90 u32 ocr_mask; /* available voltages */
74 struct tmio_mmc_dma *dma; 91 struct tmio_mmc_dma *dma;
92 struct device *dev;
93 bool power;
75 void (*set_pwr)(struct platform_device *host, int state); 94 void (*set_pwr)(struct platform_device *host, int state);
76 void (*set_clk_div)(struct platform_device *host, int state); 95 void (*set_clk_div)(struct platform_device *host, int state);
96 int (*get_cd)(struct platform_device *host);
77}; 97};
78 98
99static inline void tmio_mmc_cd_wakeup(struct tmio_mmc_data *pdata)
100{
101 if (pdata && !pdata->power) {
102 pdata->power = true;
103 pm_runtime_get(pdata->dev);
104 }
105}
106
79/* 107/*
80 * data for the NAND controller 108 * data for the NAND controller
81 */ 109 */
diff --git a/include/linux/mfd/tps6105x.h b/include/linux/mfd/tps6105x.h
new file mode 100644
index 000000000000..386743dd931c
--- /dev/null
+++ b/include/linux/mfd/tps6105x.h
@@ -0,0 +1,101 @@
1/*
2 * Copyright (C) 2011 ST-Ericsson SA
3 * Written on behalf of Linaro for ST-Ericsson
4 *
5 * Author: Linus Walleij <linus.walleij@linaro.org>
6 *
7 * License terms: GNU General Public License (GPL) version 2
8 */
9#ifndef MFD_TPS6105X_H
10#define MFD_TPS6105X_H
11
12#include <linux/i2c.h>
13#include <linux/regulator/machine.h>
14
15/*
16 * Register definitions to all subdrivers
17 */
18#define TPS6105X_REG_0 0x00
19#define TPS6105X_REG0_MODE_SHIFT 6
20#define TPS6105X_REG0_MODE_MASK (0x03<<6)
21/* These defines for both reg0 and reg1 */
22#define TPS6105X_REG0_MODE_SHUTDOWN 0x00
23#define TPS6105X_REG0_MODE_TORCH 0x01
24#define TPS6105X_REG0_MODE_TORCH_FLASH 0x02
25#define TPS6105X_REG0_MODE_VOLTAGE 0x03
26#define TPS6105X_REG0_VOLTAGE_SHIFT 4
27#define TPS6105X_REG0_VOLTAGE_MASK (3<<4)
28#define TPS6105X_REG0_VOLTAGE_450 0
29#define TPS6105X_REG0_VOLTAGE_500 1
30#define TPS6105X_REG0_VOLTAGE_525 2
31#define TPS6105X_REG0_VOLTAGE_500_2 3
32#define TPS6105X_REG0_DIMMING_SHIFT 3
33#define TPS6105X_REG0_TORCHC_SHIFT 0
34#define TPS6105X_REG0_TORCHC_MASK (7<<0)
35#define TPS6105X_REG0_TORCHC_0 0x00
36#define TPS6105X_REG0_TORCHC_50 0x01
37#define TPS6105X_REG0_TORCHC_75 0x02
38#define TPS6105X_REG0_TORCHC_100 0x03
39#define TPS6105X_REG0_TORCHC_150 0x04
40#define TPS6105X_REG0_TORCHC_200 0x05
41#define TPS6105X_REG0_TORCHC_250_400 0x06
42#define TPS6105X_REG0_TORCHC_250_500 0x07
43#define TPS6105X_REG_1 0x01
44#define TPS6105X_REG1_MODE_SHIFT 6
45#define TPS6105X_REG1_MODE_MASK (0x03<<6)
46#define TPS6105X_REG1_MODE_SHUTDOWN 0x00
47#define TPS6105X_REG1_MODE_TORCH 0x01
48#define TPS6105X_REG1_MODE_TORCH_FLASH 0x02
49#define TPS6105X_REG1_MODE_VOLTAGE 0x03
50#define TPS6105X_REG_2 0x02
51#define TPS6105X_REG_3 0x03
52
53/**
54 * enum tps6105x_mode - desired mode for the TPS6105x
55 * @TPS6105X_MODE_SHUTDOWN: this instance is inactive, not used for anything
56 * @TPS61905X_MODE_TORCH: this instance is used as a LED, usually a while
57 * LED, for example as backlight or flashlight. If this is set, the
58 * TPS6105X will register to the LED framework
59 * @TPS6105X_MODE_TORCH_FLASH: this instance is used as a flashgun, usually
60 * in a camera
61 * @TPS6105X_MODE_VOLTAGE: this instance is used as a voltage regulator and
62 * will register to the regulator framework
63 */
64enum tps6105x_mode {
65 TPS6105X_MODE_SHUTDOWN,
66 TPS6105X_MODE_TORCH,
67 TPS6105X_MODE_TORCH_FLASH,
68 TPS6105X_MODE_VOLTAGE,
69};
70
71/**
72 * struct tps6105x_platform_data - TPS61905x platform data
73 * @mode: what mode this instance shall be operated in,
74 * this is not selectable at runtime
75 * @regulator_data: initialization data for the voltage
76 * regulator if used as a voltage source
77 */
78struct tps6105x_platform_data {
79 enum tps6105x_mode mode;
80 struct regulator_init_data *regulator_data;
81};
82
83/**
84 * struct tps6105x - state holder for the TPS6105x drivers
85 * @mutex: mutex to serialize I2C accesses
86 * @i2c_client: corresponding I2C client
87 * @regulator: regulator device if used in voltage mode
88 */
89struct tps6105x {
90 struct tps6105x_platform_data *pdata;
91 struct mutex lock;
92 struct i2c_client *client;
93 struct regulator_dev *regulator;
94};
95
96extern int tps6105x_set(struct tps6105x *tps6105x, u8 reg, u8 value);
97extern int tps6105x_get(struct tps6105x *tps6105x, u8 reg, u8 *buf);
98extern int tps6105x_mask_and_set(struct tps6105x *tps6105x, u8 reg,
99 u8 bitmask, u8 bitvalues);
100
101#endif
diff --git a/include/linux/mfd/tps6586x.h b/include/linux/mfd/tps6586x.h
index 772b3ae640af..b6bab1b04e25 100644
--- a/include/linux/mfd/tps6586x.h
+++ b/include/linux/mfd/tps6586x.h
@@ -18,6 +18,36 @@ enum {
18 TPS6586X_ID_LDO_RTC, 18 TPS6586X_ID_LDO_RTC,
19}; 19};
20 20
21enum {
22 TPS6586X_INT_PLDO_0,
23 TPS6586X_INT_PLDO_1,
24 TPS6586X_INT_PLDO_2,
25 TPS6586X_INT_PLDO_3,
26 TPS6586X_INT_PLDO_4,
27 TPS6586X_INT_PLDO_5,
28 TPS6586X_INT_PLDO_6,
29 TPS6586X_INT_PLDO_7,
30 TPS6586X_INT_COMP_DET,
31 TPS6586X_INT_ADC,
32 TPS6586X_INT_PLDO_8,
33 TPS6586X_INT_PLDO_9,
34 TPS6586X_INT_PSM_0,
35 TPS6586X_INT_PSM_1,
36 TPS6586X_INT_PSM_2,
37 TPS6586X_INT_PSM_3,
38 TPS6586X_INT_RTC_ALM1,
39 TPS6586X_INT_ACUSB_OVP,
40 TPS6586X_INT_USB_DET,
41 TPS6586X_INT_AC_DET,
42 TPS6586X_INT_BAT_DET,
43 TPS6586X_INT_CHG_STAT,
44 TPS6586X_INT_CHG_TEMP,
45 TPS6586X_INT_PP,
46 TPS6586X_INT_RESUME,
47 TPS6586X_INT_LOW_SYS,
48 TPS6586X_INT_RTC_ALM2,
49};
50
21struct tps6586x_subdev_info { 51struct tps6586x_subdev_info {
22 int id; 52 int id;
23 const char *name; 53 const char *name;
@@ -29,6 +59,7 @@ struct tps6586x_platform_data {
29 struct tps6586x_subdev_info *subdevs; 59 struct tps6586x_subdev_info *subdevs;
30 60
31 int gpio_base; 61 int gpio_base;
62 int irq_base;
32}; 63};
33 64
34/* 65/*
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h
new file mode 100644
index 000000000000..8bb85b930c07
--- /dev/null
+++ b/include/linux/mfd/tps65910.h
@@ -0,0 +1,800 @@
1/*
2 * tps65910.h -- TI TPS6591x
3 *
4 * Copyright 2010-2011 Texas Instruments Inc.
5 *
6 * Author: Graeme Gregory <gg@slimlogic.co.uk>
7 * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk>
8 * Author: Arnaud Deconinck <a-deconinck@ti.com>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#ifndef __LINUX_MFD_TPS65910_H
18#define __LINUX_MFD_TPS65910_H
19
20/* TPS chip id list */
21#define TPS65910 0
22#define TPS65911 1
23
24/* TPS regulator type list */
25#define REGULATOR_LDO 0
26#define REGULATOR_DCDC 1
27
28/*
29 * List of registers for component TPS65910
30 *
31 */
32
33#define TPS65910_SECONDS 0x0
34#define TPS65910_MINUTES 0x1
35#define TPS65910_HOURS 0x2
36#define TPS65910_DAYS 0x3
37#define TPS65910_MONTHS 0x4
38#define TPS65910_YEARS 0x5
39#define TPS65910_WEEKS 0x6
40#define TPS65910_ALARM_SECONDS 0x8
41#define TPS65910_ALARM_MINUTES 0x9
42#define TPS65910_ALARM_HOURS 0xA
43#define TPS65910_ALARM_DAYS 0xB
44#define TPS65910_ALARM_MONTHS 0xC
45#define TPS65910_ALARM_YEARS 0xD
46#define TPS65910_RTC_CTRL 0x10
47#define TPS65910_RTC_STATUS 0x11
48#define TPS65910_RTC_INTERRUPTS 0x12
49#define TPS65910_RTC_COMP_LSB 0x13
50#define TPS65910_RTC_COMP_MSB 0x14
51#define TPS65910_RTC_RES_PROG 0x15
52#define TPS65910_RTC_RESET_STATUS 0x16
53#define TPS65910_BCK1 0x17
54#define TPS65910_BCK2 0x18
55#define TPS65910_BCK3 0x19
56#define TPS65910_BCK4 0x1A
57#define TPS65910_BCK5 0x1B
58#define TPS65910_PUADEN 0x1C
59#define TPS65910_REF 0x1D
60#define TPS65910_VRTC 0x1E
61#define TPS65910_VIO 0x20
62#define TPS65910_VDD1 0x21
63#define TPS65910_VDD1_OP 0x22
64#define TPS65910_VDD1_SR 0x23
65#define TPS65910_VDD2 0x24
66#define TPS65910_VDD2_OP 0x25
67#define TPS65910_VDD2_SR 0x26
68#define TPS65910_VDD3 0x27
69#define TPS65910_VDIG1 0x30
70#define TPS65910_VDIG2 0x31
71#define TPS65910_VAUX1 0x32
72#define TPS65910_VAUX2 0x33
73#define TPS65910_VAUX33 0x34
74#define TPS65910_VMMC 0x35
75#define TPS65910_VPLL 0x36
76#define TPS65910_VDAC 0x37
77#define TPS65910_THERM 0x38
78#define TPS65910_BBCH 0x39
79#define TPS65910_DCDCCTRL 0x3E
80#define TPS65910_DEVCTRL 0x3F
81#define TPS65910_DEVCTRL2 0x40
82#define TPS65910_SLEEP_KEEP_LDO_ON 0x41
83#define TPS65910_SLEEP_KEEP_RES_ON 0x42
84#define TPS65910_SLEEP_SET_LDO_OFF 0x43
85#define TPS65910_SLEEP_SET_RES_OFF 0x44
86#define TPS65910_EN1_LDO_ASS 0x45
87#define TPS65910_EN1_SMPS_ASS 0x46
88#define TPS65910_EN2_LDO_ASS 0x47
89#define TPS65910_EN2_SMPS_ASS 0x48
90#define TPS65910_EN3_LDO_ASS 0x49
91#define TPS65910_SPARE 0x4A
92#define TPS65910_INT_STS 0x50
93#define TPS65910_INT_MSK 0x51
94#define TPS65910_INT_STS2 0x52
95#define TPS65910_INT_MSK2 0x53
96#define TPS65910_INT_STS3 0x54
97#define TPS65910_INT_MSK3 0x55
98#define TPS65910_GPIO0 0x60
99#define TPS65910_GPIO1 0x61
100#define TPS65910_GPIO2 0x62
101#define TPS65910_GPIO3 0x63
102#define TPS65910_GPIO4 0x64
103#define TPS65910_GPIO5 0x65
104#define TPS65910_GPIO6 0x66
105#define TPS65910_GPIO7 0x67
106#define TPS65910_GPIO8 0x68
107#define TPS65910_JTAGVERNUM 0x80
108#define TPS65910_MAX_REGISTER 0x80
109
110/*
111 * List of registers specific to TPS65911
112 */
113#define TPS65911_VDDCTRL 0x27
114#define TPS65911_VDDCTRL_OP 0x28
115#define TPS65911_VDDCTRL_SR 0x29
116#define TPS65911_LDO1 0x30
117#define TPS65911_LDO2 0x31
118#define TPS65911_LDO5 0x32
119#define TPS65911_LDO8 0x33
120#define TPS65911_LDO7 0x34
121#define TPS65911_LDO6 0x35
122#define TPS65911_LDO4 0x36
123#define TPS65911_LDO3 0x37
124#define TPS65911_VMBCH 0x6A
125#define TPS65911_VMBCH2 0x6B
126
127/*
128 * List of register bitfields for component TPS65910
129 *
130 */
131
132
133/*Register BCK1 (0x80) register.RegisterDescription */
134#define BCK1_BCKUP_MASK 0xFF
135#define BCK1_BCKUP_SHIFT 0
136
137
138/*Register BCK2 (0x80) register.RegisterDescription */
139#define BCK2_BCKUP_MASK 0xFF
140#define BCK2_BCKUP_SHIFT 0
141
142
143/*Register BCK3 (0x80) register.RegisterDescription */
144#define BCK3_BCKUP_MASK 0xFF
145#define BCK3_BCKUP_SHIFT 0
146
147
148/*Register BCK4 (0x80) register.RegisterDescription */
149#define BCK4_BCKUP_MASK 0xFF
150#define BCK4_BCKUP_SHIFT 0
151
152
153/*Register BCK5 (0x80) register.RegisterDescription */
154#define BCK5_BCKUP_MASK 0xFF
155#define BCK5_BCKUP_SHIFT 0
156
157
158/*Register PUADEN (0x80) register.RegisterDescription */
159#define PUADEN_EN3P_MASK 0x80
160#define PUADEN_EN3P_SHIFT 7
161#define PUADEN_I2CCTLP_MASK 0x40
162#define PUADEN_I2CCTLP_SHIFT 6
163#define PUADEN_I2CSRP_MASK 0x20
164#define PUADEN_I2CSRP_SHIFT 5
165#define PUADEN_PWRONP_MASK 0x10
166#define PUADEN_PWRONP_SHIFT 4
167#define PUADEN_SLEEPP_MASK 0x08
168#define PUADEN_SLEEPP_SHIFT 3
169#define PUADEN_PWRHOLDP_MASK 0x04
170#define PUADEN_PWRHOLDP_SHIFT 2
171#define PUADEN_BOOT1P_MASK 0x02
172#define PUADEN_BOOT1P_SHIFT 1
173#define PUADEN_BOOT0P_MASK 0x01
174#define PUADEN_BOOT0P_SHIFT 0
175
176
177/*Register REF (0x80) register.RegisterDescription */
178#define REF_VMBCH_SEL_MASK 0x0C
179#define REF_VMBCH_SEL_SHIFT 2
180#define REF_ST_MASK 0x03
181#define REF_ST_SHIFT 0
182
183
184/*Register VRTC (0x80) register.RegisterDescription */
185#define VRTC_VRTC_OFFMASK_MASK 0x08
186#define VRTC_VRTC_OFFMASK_SHIFT 3
187#define VRTC_ST_MASK 0x03
188#define VRTC_ST_SHIFT 0
189
190
191/*Register VIO (0x80) register.RegisterDescription */
192#define VIO_ILMAX_MASK 0xC0
193#define VIO_ILMAX_SHIFT 6
194#define VIO_SEL_MASK 0x0C
195#define VIO_SEL_SHIFT 2
196#define VIO_ST_MASK 0x03
197#define VIO_ST_SHIFT 0
198
199
200/*Register VDD1 (0x80) register.RegisterDescription */
201#define VDD1_VGAIN_SEL_MASK 0xC0
202#define VDD1_VGAIN_SEL_SHIFT 6
203#define VDD1_ILMAX_MASK 0x20
204#define VDD1_ILMAX_SHIFT 5
205#define VDD1_TSTEP_MASK 0x1C
206#define VDD1_TSTEP_SHIFT 2
207#define VDD1_ST_MASK 0x03
208#define VDD1_ST_SHIFT 0
209
210
211/*Register VDD1_OP (0x80) register.RegisterDescription */
212#define VDD1_OP_CMD_MASK 0x80
213#define VDD1_OP_CMD_SHIFT 7
214#define VDD1_OP_SEL_MASK 0x7F
215#define VDD1_OP_SEL_SHIFT 0
216
217
218/*Register VDD1_SR (0x80) register.RegisterDescription */
219#define VDD1_SR_SEL_MASK 0x7F
220#define VDD1_SR_SEL_SHIFT 0
221
222
223/*Register VDD2 (0x80) register.RegisterDescription */
224#define VDD2_VGAIN_SEL_MASK 0xC0
225#define VDD2_VGAIN_SEL_SHIFT 6
226#define VDD2_ILMAX_MASK 0x20
227#define VDD2_ILMAX_SHIFT 5
228#define VDD2_TSTEP_MASK 0x1C
229#define VDD2_TSTEP_SHIFT 2
230#define VDD2_ST_MASK 0x03
231#define VDD2_ST_SHIFT 0
232
233
234/*Register VDD2_OP (0x80) register.RegisterDescription */
235#define VDD2_OP_CMD_MASK 0x80
236#define VDD2_OP_CMD_SHIFT 7
237#define VDD2_OP_SEL_MASK 0x7F
238#define VDD2_OP_SEL_SHIFT 0
239
240/*Register VDD2_SR (0x80) register.RegisterDescription */
241#define VDD2_SR_SEL_MASK 0x7F
242#define VDD2_SR_SEL_SHIFT 0
243
244
245/*Registers VDD1, VDD2 voltage values definitions */
246#define VDD1_2_NUM_VOLTS 73
247#define VDD1_2_MIN_VOLT 6000
248#define VDD1_2_OFFSET 125
249
250
251/*Register VDD3 (0x80) register.RegisterDescription */
252#define VDD3_CKINEN_MASK 0x04
253#define VDD3_CKINEN_SHIFT 2
254#define VDD3_ST_MASK 0x03
255#define VDD3_ST_SHIFT 0
256#define VDDCTRL_MIN_VOLT 6000
257#define VDDCTRL_OFFSET 125
258
259/*Registers VDIG (0x80) to VDAC register.RegisterDescription */
260#define LDO_SEL_MASK 0x0C
261#define LDO_SEL_SHIFT 2
262#define LDO_ST_MASK 0x03
263#define LDO_ST_SHIFT 0
264#define LDO_ST_ON_BIT 0x01
265#define LDO_ST_MODE_BIT 0x02
266
267
268/* Registers LDO1 to LDO8 in tps65910 */
269#define LDO1_SEL_MASK 0xFC
270#define LDO3_SEL_MASK 0x7C
271#define LDO_MIN_VOLT 1000
272#define LDO_MAX_VOLT 3300;
273
274
275/*Register VDIG1 (0x80) register.RegisterDescription */
276#define VDIG1_SEL_MASK 0x0C
277#define VDIG1_SEL_SHIFT 2
278#define VDIG1_ST_MASK 0x03
279#define VDIG1_ST_SHIFT 0
280
281
282/*Register VDIG2 (0x80) register.RegisterDescription */
283#define VDIG2_SEL_MASK 0x0C
284#define VDIG2_SEL_SHIFT 2
285#define VDIG2_ST_MASK 0x03
286#define VDIG2_ST_SHIFT 0
287
288
289/*Register VAUX1 (0x80) register.RegisterDescription */
290#define VAUX1_SEL_MASK 0x0C
291#define VAUX1_SEL_SHIFT 2
292#define VAUX1_ST_MASK 0x03
293#define VAUX1_ST_SHIFT 0
294
295
296/*Register VAUX2 (0x80) register.RegisterDescription */
297#define VAUX2_SEL_MASK 0x0C
298#define VAUX2_SEL_SHIFT 2
299#define VAUX2_ST_MASK 0x03
300#define VAUX2_ST_SHIFT 0
301
302
303/*Register VAUX33 (0x80) register.RegisterDescription */
304#define VAUX33_SEL_MASK 0x0C
305#define VAUX33_SEL_SHIFT 2
306#define VAUX33_ST_MASK 0x03
307#define VAUX33_ST_SHIFT 0
308
309
310/*Register VMMC (0x80) register.RegisterDescription */
311#define VMMC_SEL_MASK 0x0C
312#define VMMC_SEL_SHIFT 2
313#define VMMC_ST_MASK 0x03
314#define VMMC_ST_SHIFT 0
315
316
317/*Register VPLL (0x80) register.RegisterDescription */
318#define VPLL_SEL_MASK 0x0C
319#define VPLL_SEL_SHIFT 2
320#define VPLL_ST_MASK 0x03
321#define VPLL_ST_SHIFT 0
322
323
324/*Register VDAC (0x80) register.RegisterDescription */
325#define VDAC_SEL_MASK 0x0C
326#define VDAC_SEL_SHIFT 2
327#define VDAC_ST_MASK 0x03
328#define VDAC_ST_SHIFT 0
329
330
331/*Register THERM (0x80) register.RegisterDescription */
332#define THERM_THERM_HD_MASK 0x20
333#define THERM_THERM_HD_SHIFT 5
334#define THERM_THERM_TS_MASK 0x10
335#define THERM_THERM_TS_SHIFT 4
336#define THERM_THERM_HDSEL_MASK 0x0C
337#define THERM_THERM_HDSEL_SHIFT 2
338#define THERM_RSVD1_MASK 0x02
339#define THERM_RSVD1_SHIFT 1
340#define THERM_THERM_STATE_MASK 0x01
341#define THERM_THERM_STATE_SHIFT 0
342
343
344/*Register BBCH (0x80) register.RegisterDescription */
345#define BBCH_BBSEL_MASK 0x06
346#define BBCH_BBSEL_SHIFT 1
347#define BBCH_BBCHEN_MASK 0x01
348#define BBCH_BBCHEN_SHIFT 0
349
350
351/*Register DCDCCTRL (0x80) register.RegisterDescription */
352#define DCDCCTRL_VDD2_PSKIP_MASK 0x20
353#define DCDCCTRL_VDD2_PSKIP_SHIFT 5
354#define DCDCCTRL_VDD1_PSKIP_MASK 0x10
355#define DCDCCTRL_VDD1_PSKIP_SHIFT 4
356#define DCDCCTRL_VIO_PSKIP_MASK 0x08
357#define DCDCCTRL_VIO_PSKIP_SHIFT 3
358#define DCDCCTRL_DCDCCKEXT_MASK 0x04
359#define DCDCCTRL_DCDCCKEXT_SHIFT 2
360#define DCDCCTRL_DCDCCKSYNC_MASK 0x03
361#define DCDCCTRL_DCDCCKSYNC_SHIFT 0
362
363
364/*Register DEVCTRL (0x80) register.RegisterDescription */
365#define DEVCTRL_RTC_PWDN_MASK 0x40
366#define DEVCTRL_RTC_PWDN_SHIFT 6
367#define DEVCTRL_CK32K_CTRL_MASK 0x20
368#define DEVCTRL_CK32K_CTRL_SHIFT 5
369#define DEVCTRL_SR_CTL_I2C_SEL_MASK 0x10
370#define DEVCTRL_SR_CTL_I2C_SEL_SHIFT 4
371#define DEVCTRL_DEV_OFF_RST_MASK 0x08
372#define DEVCTRL_DEV_OFF_RST_SHIFT 3
373#define DEVCTRL_DEV_ON_MASK 0x04
374#define DEVCTRL_DEV_ON_SHIFT 2
375#define DEVCTRL_DEV_SLP_MASK 0x02
376#define DEVCTRL_DEV_SLP_SHIFT 1
377#define DEVCTRL_DEV_OFF_MASK 0x01
378#define DEVCTRL_DEV_OFF_SHIFT 0
379
380
381/*Register DEVCTRL2 (0x80) register.RegisterDescription */
382#define DEVCTRL2_TSLOT_LENGTH_MASK 0x30
383#define DEVCTRL2_TSLOT_LENGTH_SHIFT 4
384#define DEVCTRL2_SLEEPSIG_POL_MASK 0x08
385#define DEVCTRL2_SLEEPSIG_POL_SHIFT 3
386#define DEVCTRL2_PWON_LP_OFF_MASK 0x04
387#define DEVCTRL2_PWON_LP_OFF_SHIFT 2
388#define DEVCTRL2_PWON_LP_RST_MASK 0x02
389#define DEVCTRL2_PWON_LP_RST_SHIFT 1
390#define DEVCTRL2_IT_POL_MASK 0x01
391#define DEVCTRL2_IT_POL_SHIFT 0
392
393
394/*Register SLEEP_KEEP_LDO_ON (0x80) register.RegisterDescription */
395#define SLEEP_KEEP_LDO_ON_VDAC_KEEPON_MASK 0x80
396#define SLEEP_KEEP_LDO_ON_VDAC_KEEPON_SHIFT 7
397#define SLEEP_KEEP_LDO_ON_VPLL_KEEPON_MASK 0x40
398#define SLEEP_KEEP_LDO_ON_VPLL_KEEPON_SHIFT 6
399#define SLEEP_KEEP_LDO_ON_VAUX33_KEEPON_MASK 0x20
400#define SLEEP_KEEP_LDO_ON_VAUX33_KEEPON_SHIFT 5
401#define SLEEP_KEEP_LDO_ON_VAUX2_KEEPON_MASK 0x10
402#define SLEEP_KEEP_LDO_ON_VAUX2_KEEPON_SHIFT 4
403#define SLEEP_KEEP_LDO_ON_VAUX1_KEEPON_MASK 0x08
404#define SLEEP_KEEP_LDO_ON_VAUX1_KEEPON_SHIFT 3
405#define SLEEP_KEEP_LDO_ON_VDIG2_KEEPON_MASK 0x04
406#define SLEEP_KEEP_LDO_ON_VDIG2_KEEPON_SHIFT 2
407#define SLEEP_KEEP_LDO_ON_VDIG1_KEEPON_MASK 0x02
408#define SLEEP_KEEP_LDO_ON_VDIG1_KEEPON_SHIFT 1
409#define SLEEP_KEEP_LDO_ON_VMMC_KEEPON_MASK 0x01
410#define SLEEP_KEEP_LDO_ON_VMMC_KEEPON_SHIFT 0
411
412
413/*Register SLEEP_KEEP_RES_ON (0x80) register.RegisterDescription */
414#define SLEEP_KEEP_RES_ON_THERM_KEEPON_MASK 0x80
415#define SLEEP_KEEP_RES_ON_THERM_KEEPON_SHIFT 7
416#define SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_MASK 0x40
417#define SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_SHIFT 6
418#define SLEEP_KEEP_RES_ON_VRTC_KEEPON_MASK 0x20
419#define SLEEP_KEEP_RES_ON_VRTC_KEEPON_SHIFT 5
420#define SLEEP_KEEP_RES_ON_I2CHS_KEEPON_MASK 0x10
421#define SLEEP_KEEP_RES_ON_I2CHS_KEEPON_SHIFT 4
422#define SLEEP_KEEP_RES_ON_VDD3_KEEPON_MASK 0x08
423#define SLEEP_KEEP_RES_ON_VDD3_KEEPON_SHIFT 3
424#define SLEEP_KEEP_RES_ON_VDD2_KEEPON_MASK 0x04
425#define SLEEP_KEEP_RES_ON_VDD2_KEEPON_SHIFT 2
426#define SLEEP_KEEP_RES_ON_VDD1_KEEPON_MASK 0x02
427#define SLEEP_KEEP_RES_ON_VDD1_KEEPON_SHIFT 1
428#define SLEEP_KEEP_RES_ON_VIO_KEEPON_MASK 0x01
429#define SLEEP_KEEP_RES_ON_VIO_KEEPON_SHIFT 0
430
431
432/*Register SLEEP_SET_LDO_OFF (0x80) register.RegisterDescription */
433#define SLEEP_SET_LDO_OFF_VDAC_SETOFF_MASK 0x80
434#define SLEEP_SET_LDO_OFF_VDAC_SETOFF_SHIFT 7
435#define SLEEP_SET_LDO_OFF_VPLL_SETOFF_MASK 0x40
436#define SLEEP_SET_LDO_OFF_VPLL_SETOFF_SHIFT 6
437#define SLEEP_SET_LDO_OFF_VAUX33_SETOFF_MASK 0x20
438#define SLEEP_SET_LDO_OFF_VAUX33_SETOFF_SHIFT 5
439#define SLEEP_SET_LDO_OFF_VAUX2_SETOFF_MASK 0x10
440#define SLEEP_SET_LDO_OFF_VAUX2_SETOFF_SHIFT 4
441#define SLEEP_SET_LDO_OFF_VAUX1_SETOFF_MASK 0x08
442#define SLEEP_SET_LDO_OFF_VAUX1_SETOFF_SHIFT 3
443#define SLEEP_SET_LDO_OFF_VDIG2_SETOFF_MASK 0x04
444#define SLEEP_SET_LDO_OFF_VDIG2_SETOFF_SHIFT 2
445#define SLEEP_SET_LDO_OFF_VDIG1_SETOFF_MASK 0x02
446#define SLEEP_SET_LDO_OFF_VDIG1_SETOFF_SHIFT 1
447#define SLEEP_SET_LDO_OFF_VMMC_SETOFF_MASK 0x01
448#define SLEEP_SET_LDO_OFF_VMMC_SETOFF_SHIFT 0
449
450
451/*Register SLEEP_SET_RES_OFF (0x80) register.RegisterDescription */
452#define SLEEP_SET_RES_OFF_DEFAULT_VOLT_MASK 0x80
453#define SLEEP_SET_RES_OFF_DEFAULT_VOLT_SHIFT 7
454#define SLEEP_SET_RES_OFF_RSVD_MASK 0x60
455#define SLEEP_SET_RES_OFF_RSVD_SHIFT 5
456#define SLEEP_SET_RES_OFF_SPARE_SETOFF_MASK 0x10
457#define SLEEP_SET_RES_OFF_SPARE_SETOFF_SHIFT 4
458#define SLEEP_SET_RES_OFF_VDD3_SETOFF_MASK 0x08
459#define SLEEP_SET_RES_OFF_VDD3_SETOFF_SHIFT 3
460#define SLEEP_SET_RES_OFF_VDD2_SETOFF_MASK 0x04
461#define SLEEP_SET_RES_OFF_VDD2_SETOFF_SHIFT 2
462#define SLEEP_SET_RES_OFF_VDD1_SETOFF_MASK 0x02
463#define SLEEP_SET_RES_OFF_VDD1_SETOFF_SHIFT 1
464#define SLEEP_SET_RES_OFF_VIO_SETOFF_MASK 0x01
465#define SLEEP_SET_RES_OFF_VIO_SETOFF_SHIFT 0
466
467
468/*Register EN1_LDO_ASS (0x80) register.RegisterDescription */
469#define EN1_LDO_ASS_VDAC_EN1_MASK 0x80
470#define EN1_LDO_ASS_VDAC_EN1_SHIFT 7
471#define EN1_LDO_ASS_VPLL_EN1_MASK 0x40
472#define EN1_LDO_ASS_VPLL_EN1_SHIFT 6
473#define EN1_LDO_ASS_VAUX33_EN1_MASK 0x20
474#define EN1_LDO_ASS_VAUX33_EN1_SHIFT 5
475#define EN1_LDO_ASS_VAUX2_EN1_MASK 0x10
476#define EN1_LDO_ASS_VAUX2_EN1_SHIFT 4
477#define EN1_LDO_ASS_VAUX1_EN1_MASK 0x08
478#define EN1_LDO_ASS_VAUX1_EN1_SHIFT 3
479#define EN1_LDO_ASS_VDIG2_EN1_MASK 0x04
480#define EN1_LDO_ASS_VDIG2_EN1_SHIFT 2
481#define EN1_LDO_ASS_VDIG1_EN1_MASK 0x02
482#define EN1_LDO_ASS_VDIG1_EN1_SHIFT 1
483#define EN1_LDO_ASS_VMMC_EN1_MASK 0x01
484#define EN1_LDO_ASS_VMMC_EN1_SHIFT 0
485
486
487/*Register EN1_SMPS_ASS (0x80) register.RegisterDescription */
488#define EN1_SMPS_ASS_RSVD_MASK 0xE0
489#define EN1_SMPS_ASS_RSVD_SHIFT 5
490#define EN1_SMPS_ASS_SPARE_EN1_MASK 0x10
491#define EN1_SMPS_ASS_SPARE_EN1_SHIFT 4
492#define EN1_SMPS_ASS_VDD3_EN1_MASK 0x08
493#define EN1_SMPS_ASS_VDD3_EN1_SHIFT 3
494#define EN1_SMPS_ASS_VDD2_EN1_MASK 0x04
495#define EN1_SMPS_ASS_VDD2_EN1_SHIFT 2
496#define EN1_SMPS_ASS_VDD1_EN1_MASK 0x02
497#define EN1_SMPS_ASS_VDD1_EN1_SHIFT 1
498#define EN1_SMPS_ASS_VIO_EN1_MASK 0x01
499#define EN1_SMPS_ASS_VIO_EN1_SHIFT 0
500
501
502/*Register EN2_LDO_ASS (0x80) register.RegisterDescription */
503#define EN2_LDO_ASS_VDAC_EN2_MASK 0x80
504#define EN2_LDO_ASS_VDAC_EN2_SHIFT 7
505#define EN2_LDO_ASS_VPLL_EN2_MASK 0x40
506#define EN2_LDO_ASS_VPLL_EN2_SHIFT 6
507#define EN2_LDO_ASS_VAUX33_EN2_MASK 0x20
508#define EN2_LDO_ASS_VAUX33_EN2_SHIFT 5
509#define EN2_LDO_ASS_VAUX2_EN2_MASK 0x10
510#define EN2_LDO_ASS_VAUX2_EN2_SHIFT 4
511#define EN2_LDO_ASS_VAUX1_EN2_MASK 0x08
512#define EN2_LDO_ASS_VAUX1_EN2_SHIFT 3
513#define EN2_LDO_ASS_VDIG2_EN2_MASK 0x04
514#define EN2_LDO_ASS_VDIG2_EN2_SHIFT 2
515#define EN2_LDO_ASS_VDIG1_EN2_MASK 0x02
516#define EN2_LDO_ASS_VDIG1_EN2_SHIFT 1
517#define EN2_LDO_ASS_VMMC_EN2_MASK 0x01
518#define EN2_LDO_ASS_VMMC_EN2_SHIFT 0
519
520
521/*Register EN2_SMPS_ASS (0x80) register.RegisterDescription */
522#define EN2_SMPS_ASS_RSVD_MASK 0xE0
523#define EN2_SMPS_ASS_RSVD_SHIFT 5
524#define EN2_SMPS_ASS_SPARE_EN2_MASK 0x10
525#define EN2_SMPS_ASS_SPARE_EN2_SHIFT 4
526#define EN2_SMPS_ASS_VDD3_EN2_MASK 0x08
527#define EN2_SMPS_ASS_VDD3_EN2_SHIFT 3
528#define EN2_SMPS_ASS_VDD2_EN2_MASK 0x04
529#define EN2_SMPS_ASS_VDD2_EN2_SHIFT 2
530#define EN2_SMPS_ASS_VDD1_EN2_MASK 0x02
531#define EN2_SMPS_ASS_VDD1_EN2_SHIFT 1
532#define EN2_SMPS_ASS_VIO_EN2_MASK 0x01
533#define EN2_SMPS_ASS_VIO_EN2_SHIFT 0
534
535
536/*Register EN3_LDO_ASS (0x80) register.RegisterDescription */
537#define EN3_LDO_ASS_VDAC_EN3_MASK 0x80
538#define EN3_LDO_ASS_VDAC_EN3_SHIFT 7
539#define EN3_LDO_ASS_VPLL_EN3_MASK 0x40
540#define EN3_LDO_ASS_VPLL_EN3_SHIFT 6
541#define EN3_LDO_ASS_VAUX33_EN3_MASK 0x20
542#define EN3_LDO_ASS_VAUX33_EN3_SHIFT 5
543#define EN3_LDO_ASS_VAUX2_EN3_MASK 0x10
544#define EN3_LDO_ASS_VAUX2_EN3_SHIFT 4
545#define EN3_LDO_ASS_VAUX1_EN3_MASK 0x08
546#define EN3_LDO_ASS_VAUX1_EN3_SHIFT 3
547#define EN3_LDO_ASS_VDIG2_EN3_MASK 0x04
548#define EN3_LDO_ASS_VDIG2_EN3_SHIFT 2
549#define EN3_LDO_ASS_VDIG1_EN3_MASK 0x02
550#define EN3_LDO_ASS_VDIG1_EN3_SHIFT 1
551#define EN3_LDO_ASS_VMMC_EN3_MASK 0x01
552#define EN3_LDO_ASS_VMMC_EN3_SHIFT 0
553
554
555/*Register SPARE (0x80) register.RegisterDescription */
556#define SPARE_SPARE_MASK 0xFF
557#define SPARE_SPARE_SHIFT 0
558
559
560/*Register INT_STS (0x80) register.RegisterDescription */
561#define INT_STS_RTC_PERIOD_IT_MASK 0x80
562#define INT_STS_RTC_PERIOD_IT_SHIFT 7
563#define INT_STS_RTC_ALARM_IT_MASK 0x40
564#define INT_STS_RTC_ALARM_IT_SHIFT 6
565#define INT_STS_HOTDIE_IT_MASK 0x20
566#define INT_STS_HOTDIE_IT_SHIFT 5
567#define INT_STS_PWRHOLD_IT_MASK 0x10
568#define INT_STS_PWRHOLD_IT_SHIFT 4
569#define INT_STS_PWRON_LP_IT_MASK 0x08
570#define INT_STS_PWRON_LP_IT_SHIFT 3
571#define INT_STS_PWRON_IT_MASK 0x04
572#define INT_STS_PWRON_IT_SHIFT 2
573#define INT_STS_VMBHI_IT_MASK 0x02
574#define INT_STS_VMBHI_IT_SHIFT 1
575#define INT_STS_VMBDCH_IT_MASK 0x01
576#define INT_STS_VMBDCH_IT_SHIFT 0
577
578
579/*Register INT_MSK (0x80) register.RegisterDescription */
580#define INT_MSK_RTC_PERIOD_IT_MSK_MASK 0x80
581#define INT_MSK_RTC_PERIOD_IT_MSK_SHIFT 7
582#define INT_MSK_RTC_ALARM_IT_MSK_MASK 0x40
583#define INT_MSK_RTC_ALARM_IT_MSK_SHIFT 6
584#define INT_MSK_HOTDIE_IT_MSK_MASK 0x20
585#define INT_MSK_HOTDIE_IT_MSK_SHIFT 5
586#define INT_MSK_PWRHOLD_IT_MSK_MASK 0x10
587#define INT_MSK_PWRHOLD_IT_MSK_SHIFT 4
588#define INT_MSK_PWRON_LP_IT_MSK_MASK 0x08
589#define INT_MSK_PWRON_LP_IT_MSK_SHIFT 3
590#define INT_MSK_PWRON_IT_MSK_MASK 0x04
591#define INT_MSK_PWRON_IT_MSK_SHIFT 2
592#define INT_MSK_VMBHI_IT_MSK_MASK 0x02
593#define INT_MSK_VMBHI_IT_MSK_SHIFT 1
594#define INT_MSK_VMBDCH_IT_MSK_MASK 0x01
595#define INT_MSK_VMBDCH_IT_MSK_SHIFT 0
596
597
598/*Register INT_STS2 (0x80) register.RegisterDescription */
599#define INT_STS2_GPIO3_F_IT_MASK 0x80
600#define INT_STS2_GPIO3_F_IT_SHIFT 7
601#define INT_STS2_GPIO3_R_IT_MASK 0x40
602#define INT_STS2_GPIO3_R_IT_SHIFT 6
603#define INT_STS2_GPIO2_F_IT_MASK 0x20
604#define INT_STS2_GPIO2_F_IT_SHIFT 5
605#define INT_STS2_GPIO2_R_IT_MASK 0x10
606#define INT_STS2_GPIO2_R_IT_SHIFT 4
607#define INT_STS2_GPIO1_F_IT_MASK 0x08
608#define INT_STS2_GPIO1_F_IT_SHIFT 3
609#define INT_STS2_GPIO1_R_IT_MASK 0x04
610#define INT_STS2_GPIO1_R_IT_SHIFT 2
611#define INT_STS2_GPIO0_F_IT_MASK 0x02
612#define INT_STS2_GPIO0_F_IT_SHIFT 1
613#define INT_STS2_GPIO0_R_IT_MASK 0x01
614#define INT_STS2_GPIO0_R_IT_SHIFT 0
615
616
617/*Register INT_MSK2 (0x80) register.RegisterDescription */
618#define INT_MSK2_GPIO3_F_IT_MSK_MASK 0x80
619#define INT_MSK2_GPIO3_F_IT_MSK_SHIFT 7
620#define INT_MSK2_GPIO3_R_IT_MSK_MASK 0x40
621#define INT_MSK2_GPIO3_R_IT_MSK_SHIFT 6
622#define INT_MSK2_GPIO2_F_IT_MSK_MASK 0x20
623#define INT_MSK2_GPIO2_F_IT_MSK_SHIFT 5
624#define INT_MSK2_GPIO2_R_IT_MSK_MASK 0x10
625#define INT_MSK2_GPIO2_R_IT_MSK_SHIFT 4
626#define INT_MSK2_GPIO1_F_IT_MSK_MASK 0x08
627#define INT_MSK2_GPIO1_F_IT_MSK_SHIFT 3
628#define INT_MSK2_GPIO1_R_IT_MSK_MASK 0x04
629#define INT_MSK2_GPIO1_R_IT_MSK_SHIFT 2
630#define INT_MSK2_GPIO0_F_IT_MSK_MASK 0x02
631#define INT_MSK2_GPIO0_F_IT_MSK_SHIFT 1
632#define INT_MSK2_GPIO0_R_IT_MSK_MASK 0x01
633#define INT_MSK2_GPIO0_R_IT_MSK_SHIFT 0
634
635
636/*Register INT_STS3 (0x80) register.RegisterDescription */
637#define INT_STS3_GPIO5_F_IT_MASK 0x08
638#define INT_STS3_GPIO5_F_IT_SHIFT 3
639#define INT_STS3_GPIO5_R_IT_MASK 0x04
640#define INT_STS3_GPIO5_R_IT_SHIFT 2
641#define INT_STS3_GPIO4_F_IT_MASK 0x02
642#define INT_STS3_GPIO4_F_IT_SHIFT 1
643#define INT_STS3_GPIO4_R_IT_MASK 0x01
644#define INT_STS3_GPIO4_R_IT_SHIFT 0
645
646
647/*Register INT_MSK3 (0x80) register.RegisterDescription */
648#define INT_MSK3_GPIO5_F_IT_MSK_MASK 0x08
649#define INT_MSK3_GPIO5_F_IT_MSK_SHIFT 3
650#define INT_MSK3_GPIO5_R_IT_MSK_MASK 0x04
651#define INT_MSK3_GPIO5_R_IT_MSK_SHIFT 2
652#define INT_MSK3_GPIO4_F_IT_MSK_MASK 0x02
653#define INT_MSK3_GPIO4_F_IT_MSK_SHIFT 1
654#define INT_MSK3_GPIO4_R_IT_MSK_MASK 0x01
655#define INT_MSK3_GPIO4_R_IT_MSK_SHIFT 0
656
657
658/*Register GPIO (0x80) register.RegisterDescription */
659#define GPIO_DEB_MASK 0x10
660#define GPIO_DEB_SHIFT 4
661#define GPIO_PUEN_MASK 0x08
662#define GPIO_PUEN_SHIFT 3
663#define GPIO_CFG_MASK 0x04
664#define GPIO_CFG_SHIFT 2
665#define GPIO_STS_MASK 0x02
666#define GPIO_STS_SHIFT 1
667#define GPIO_SET_MASK 0x01
668#define GPIO_SET_SHIFT 0
669
670
671/*Register JTAGVERNUM (0x80) register.RegisterDescription */
672#define JTAGVERNUM_VERNUM_MASK 0x0F
673#define JTAGVERNUM_VERNUM_SHIFT 0
674
675
676/* Register VDDCTRL (0x27) bit definitions */
677#define VDDCTRL_ST_MASK 0x03
678#define VDDCTRL_ST_SHIFT 0
679
680
681/*Register VDDCTRL_OP (0x28) bit definitios */
682#define VDDCTRL_OP_CMD_MASK 0x80
683#define VDDCTRL_OP_CMD_SHIFT 7
684#define VDDCTRL_OP_SEL_MASK 0x7F
685#define VDDCTRL_OP_SEL_SHIFT 0
686
687
688/*Register VDDCTRL_SR (0x29) bit definitions */
689#define VDDCTRL_SR_SEL_MASK 0x7F
690#define VDDCTRL_SR_SEL_SHIFT 0
691
692
693/* IRQ Definitions */
694#define TPS65910_IRQ_VBAT_VMBDCH 0
695#define TPS65910_IRQ_VBAT_VMHI 1
696#define TPS65910_IRQ_PWRON 2
697#define TPS65910_IRQ_PWRON_LP 3
698#define TPS65910_IRQ_PWRHOLD 4
699#define TPS65910_IRQ_HOTDIE 5
700#define TPS65910_IRQ_RTC_ALARM 6
701#define TPS65910_IRQ_RTC_PERIOD 7
702#define TPS65910_IRQ_GPIO_R 8
703#define TPS65910_IRQ_GPIO_F 9
704#define TPS65910_NUM_IRQ 10
705
706#define TPS65911_IRQ_VBAT_VMBDCH 0
707#define TPS65911_IRQ_VBAT_VMBDCH2L 1
708#define TPS65911_IRQ_VBAT_VMBDCH2H 2
709#define TPS65911_IRQ_VBAT_VMHI 3
710#define TPS65911_IRQ_PWRON 4
711#define TPS65911_IRQ_PWRON_LP 5
712#define TPS65911_IRQ_PWRHOLD_F 6
713#define TPS65911_IRQ_PWRHOLD_R 7
714#define TPS65911_IRQ_HOTDIE 8
715#define TPS65911_IRQ_RTC_ALARM 9
716#define TPS65911_IRQ_RTC_PERIOD 10
717#define TPS65911_IRQ_GPIO0_R 11
718#define TPS65911_IRQ_GPIO0_F 12
719#define TPS65911_IRQ_GPIO1_R 13
720#define TPS65911_IRQ_GPIO1_F 14
721#define TPS65911_IRQ_GPIO2_R 15
722#define TPS65911_IRQ_GPIO2_F 16
723#define TPS65911_IRQ_GPIO3_R 17
724#define TPS65911_IRQ_GPIO3_F 18
725#define TPS65911_IRQ_GPIO4_R 19
726#define TPS65911_IRQ_GPIO4_F 20
727#define TPS65911_IRQ_GPIO5_R 21
728#define TPS65911_IRQ_GPIO5_F 22
729#define TPS65911_IRQ_WTCHDG 23
730#define TPS65911_IRQ_PWRDN 24
731
732#define TPS65911_NUM_IRQ 25
733
734
735/* GPIO Register Definitions */
736#define TPS65910_GPIO_DEB BIT(2)
737#define TPS65910_GPIO_PUEN BIT(3)
738#define TPS65910_GPIO_CFG BIT(2)
739#define TPS65910_GPIO_STS BIT(1)
740#define TPS65910_GPIO_SET BIT(0)
741
742/**
743 * struct tps65910_board
744 * Board platform data may be used to initialize regulators.
745 */
746
747struct tps65910_board {
748 int gpio_base;
749 int irq;
750 int irq_base;
751 int vmbch_threshold;
752 int vmbch2_threshold;
753 struct regulator_init_data *tps65910_pmic_init_data;
754};
755
756/**
757 * struct tps65910 - tps65910 sub-driver chip access routines
758 */
759
760struct tps65910 {
761 struct device *dev;
762 struct i2c_client *i2c_client;
763 struct mutex io_mutex;
764 unsigned int id;
765 int (*read)(struct tps65910 *tps65910, u8 reg, int size, void *dest);
766 int (*write)(struct tps65910 *tps65910, u8 reg, int size, void *src);
767
768 /* Client devices */
769 struct tps65910_pmic *pmic;
770 struct tps65910_rtc *rtc;
771 struct tps65910_power *power;
772
773 /* GPIO Handling */
774 struct gpio_chip gpio;
775
776 /* IRQ Handling */
777 struct mutex irq_lock;
778 int chip_irq;
779 int irq_base;
780 int irq_num;
781 u32 irq_mask;
782};
783
784struct tps65910_platform_data {
785 int irq;
786 int irq_base;
787};
788
789int tps65910_set_bits(struct tps65910 *tps65910, u8 reg, u8 mask);
790int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask);
791void tps65910_gpio_init(struct tps65910 *tps65910, int gpio_base);
792int tps65910_irq_init(struct tps65910 *tps65910, int irq,
793 struct tps65910_platform_data *pdata);
794
795static inline int tps65910_chip_id(struct tps65910 *tps65910)
796{
797 return tps65910->id;
798}
799
800#endif /* __LINUX_MFD_TPS65910_H */
diff --git a/include/linux/mfd/twl4030-codec.h b/include/linux/mfd/twl4030-codec.h
index 2ec317c68e59..5cc16bbd1da1 100644
--- a/include/linux/mfd/twl4030-codec.h
+++ b/include/linux/mfd/twl4030-codec.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * MFD driver for twl4030 codec submodule 2 * MFD driver for twl4030 codec submodule
3 * 3 *
4 * Author: Peter Ujfalusi <peter.ujfalusi@nokia.com> 4 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
5 * 5 *
6 * Copyright: (C) 2009 Nokia Corporation 6 * Copyright: (C) 2009 Nokia Corporation
7 * 7 *
diff --git a/include/linux/mfd/wl1273-core.h b/include/linux/mfd/wl1273-core.h
new file mode 100644
index 000000000000..db2f3f454a1b
--- /dev/null
+++ b/include/linux/mfd/wl1273-core.h
@@ -0,0 +1,290 @@
1/*
2 * include/linux/mfd/wl1273-core.h
3 *
4 * Some definitions for the wl1273 radio receiver/transmitter chip.
5 *
6 * Copyright (C) 2010 Nokia Corporation
7 * Author: Matti J. Aaltonen <matti.j.aaltonen@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24#ifndef WL1273_CORE_H
25#define WL1273_CORE_H
26
27#include <linux/i2c.h>
28#include <linux/mfd/core.h>
29
30#define WL1273_FM_DRIVER_NAME "wl1273-fm"
31#define RX71_FM_I2C_ADDR 0x22
32
33#define WL1273_STEREO_GET 0
34#define WL1273_RSSI_LVL_GET 1
35#define WL1273_IF_COUNT_GET 2
36#define WL1273_FLAG_GET 3
37#define WL1273_RDS_SYNC_GET 4
38#define WL1273_RDS_DATA_GET 5
39#define WL1273_FREQ_SET 10
40#define WL1273_AF_FREQ_SET 11
41#define WL1273_MOST_MODE_SET 12
42#define WL1273_MOST_BLEND_SET 13
43#define WL1273_DEMPH_MODE_SET 14
44#define WL1273_SEARCH_LVL_SET 15
45#define WL1273_BAND_SET 16
46#define WL1273_MUTE_STATUS_SET 17
47#define WL1273_RDS_PAUSE_LVL_SET 18
48#define WL1273_RDS_PAUSE_DUR_SET 19
49#define WL1273_RDS_MEM_SET 20
50#define WL1273_RDS_BLK_B_SET 21
51#define WL1273_RDS_MSK_B_SET 22
52#define WL1273_RDS_PI_MASK_SET 23
53#define WL1273_RDS_PI_SET 24
54#define WL1273_RDS_SYSTEM_SET 25
55#define WL1273_INT_MASK_SET 26
56#define WL1273_SEARCH_DIR_SET 27
57#define WL1273_VOLUME_SET 28
58#define WL1273_AUDIO_ENABLE 29
59#define WL1273_PCM_MODE_SET 30
60#define WL1273_I2S_MODE_CONFIG_SET 31
61#define WL1273_POWER_SET 32
62#define WL1273_INTX_CONFIG_SET 33
63#define WL1273_PULL_EN_SET 34
64#define WL1273_HILO_SET 35
65#define WL1273_SWITCH2FREF 36
66#define WL1273_FREQ_DRIFT_REPORT 37
67
68#define WL1273_PCE_GET 40
69#define WL1273_FIRM_VER_GET 41
70#define WL1273_ASIC_VER_GET 42
71#define WL1273_ASIC_ID_GET 43
72#define WL1273_MAN_ID_GET 44
73#define WL1273_TUNER_MODE_SET 45
74#define WL1273_STOP_SEARCH 46
75#define WL1273_RDS_CNTRL_SET 47
76
77#define WL1273_WRITE_HARDWARE_REG 100
78#define WL1273_CODE_DOWNLOAD 101
79#define WL1273_RESET 102
80
81#define WL1273_FM_POWER_MODE 254
82#define WL1273_FM_INTERRUPT 255
83
84/* Transmitter API */
85
86#define WL1273_CHANL_SET 55
87#define WL1273_SCAN_SPACING_SET 56
88#define WL1273_REF_SET 57
89#define WL1273_POWER_ENB_SET 90
90#define WL1273_POWER_ATT_SET 58
91#define WL1273_POWER_LEV_SET 59
92#define WL1273_AUDIO_DEV_SET 60
93#define WL1273_PILOT_DEV_SET 61
94#define WL1273_RDS_DEV_SET 62
95#define WL1273_PUPD_SET 91
96#define WL1273_AUDIO_IO_SET 63
97#define WL1273_PREMPH_SET 64
98#define WL1273_MONO_SET 66
99#define WL1273_MUTE 92
100#define WL1273_MPX_LMT_ENABLE 67
101#define WL1273_PI_SET 93
102#define WL1273_ECC_SET 69
103#define WL1273_PTY 70
104#define WL1273_AF 71
105#define WL1273_DISPLAY_MODE 74
106#define WL1273_RDS_REP_SET 77
107#define WL1273_RDS_CONFIG_DATA_SET 98
108#define WL1273_RDS_DATA_SET 99
109#define WL1273_RDS_DATA_ENB 94
110#define WL1273_TA_SET 78
111#define WL1273_TP_SET 79
112#define WL1273_DI_SET 80
113#define WL1273_MS_SET 81
114#define WL1273_PS_SCROLL_SPEED 82
115#define WL1273_TX_AUDIO_LEVEL_TEST 96
116#define WL1273_TX_AUDIO_LEVEL_TEST_THRESHOLD 73
117#define WL1273_TX_AUDIO_INPUT_LEVEL_RANGE_SET 54
118#define WL1273_RX_ANTENNA_SELECT 87
119#define WL1273_I2C_DEV_ADDR_SET 86
120#define WL1273_REF_ERR_CALIB_PARAM_SET 88
121#define WL1273_REF_ERR_CALIB_PERIODICITY_SET 89
122#define WL1273_SOC_INT_TRIGGER 52
123#define WL1273_SOC_AUDIO_PATH_SET 83
124#define WL1273_SOC_PCMI_OVERRIDE 84
125#define WL1273_SOC_I2S_OVERRIDE 85
126#define WL1273_RSSI_BLOCK_SCAN_FREQ_SET 95
127#define WL1273_RSSI_BLOCK_SCAN_START 97
128#define WL1273_RSSI_BLOCK_SCAN_DATA_GET 5
129#define WL1273_READ_FMANT_TUNE_VALUE 104
130
131#define WL1273_RDS_OFF 0
132#define WL1273_RDS_ON 1
133#define WL1273_RDS_RESET 2
134
135#define WL1273_AUDIO_DIGITAL 0
136#define WL1273_AUDIO_ANALOG 1
137
138#define WL1273_MODE_RX BIT(0)
139#define WL1273_MODE_TX BIT(1)
140#define WL1273_MODE_OFF BIT(2)
141#define WL1273_MODE_SUSPENDED BIT(3)
142
143#define WL1273_RADIO_CHILD BIT(0)
144#define WL1273_CODEC_CHILD BIT(1)
145
146#define WL1273_RX_MONO 1
147#define WL1273_RX_STEREO 0
148#define WL1273_TX_MONO 0
149#define WL1273_TX_STEREO 1
150
151#define WL1273_MAX_VOLUME 0xffff
152#define WL1273_DEFAULT_VOLUME 0x78b8
153
154/* I2S protocol, left channel first, data width 16 bits */
155#define WL1273_PCM_DEF_MODE 0x00
156
157/* Rx */
158#define WL1273_AUDIO_ENABLE_I2S BIT(0)
159#define WL1273_AUDIO_ENABLE_ANALOG BIT(1)
160
161/* Tx */
162#define WL1273_AUDIO_IO_SET_ANALOG 0
163#define WL1273_AUDIO_IO_SET_I2S 1
164
165#define WL1273_PUPD_SET_OFF 0x00
166#define WL1273_PUPD_SET_ON 0x01
167#define WL1273_PUPD_SET_RETENTION 0x10
168
169/* I2S mode */
170#define WL1273_IS2_WIDTH_32 0x0
171#define WL1273_IS2_WIDTH_40 0x1
172#define WL1273_IS2_WIDTH_22_23 0x2
173#define WL1273_IS2_WIDTH_23_22 0x3
174#define WL1273_IS2_WIDTH_48 0x4
175#define WL1273_IS2_WIDTH_50 0x5
176#define WL1273_IS2_WIDTH_60 0x6
177#define WL1273_IS2_WIDTH_64 0x7
178#define WL1273_IS2_WIDTH_80 0x8
179#define WL1273_IS2_WIDTH_96 0x9
180#define WL1273_IS2_WIDTH_128 0xa
181#define WL1273_IS2_WIDTH 0xf
182
183#define WL1273_IS2_FORMAT_STD (0x0 << 4)
184#define WL1273_IS2_FORMAT_LEFT (0x1 << 4)
185#define WL1273_IS2_FORMAT_RIGHT (0x2 << 4)
186#define WL1273_IS2_FORMAT_USER (0x3 << 4)
187
188#define WL1273_IS2_MASTER (0x0 << 6)
189#define WL1273_IS2_SLAVEW (0x1 << 6)
190
191#define WL1273_IS2_TRI_AFTER_SENDING (0x0 << 7)
192#define WL1273_IS2_TRI_ALWAYS_ACTIVE (0x1 << 7)
193
194#define WL1273_IS2_SDOWS_RR (0x0 << 8)
195#define WL1273_IS2_SDOWS_RF (0x1 << 8)
196#define WL1273_IS2_SDOWS_FR (0x2 << 8)
197#define WL1273_IS2_SDOWS_FF (0x3 << 8)
198
199#define WL1273_IS2_TRI_OPT (0x0 << 10)
200#define WL1273_IS2_TRI_ALWAYS (0x1 << 10)
201
202#define WL1273_IS2_RATE_48K (0x0 << 12)
203#define WL1273_IS2_RATE_44_1K (0x1 << 12)
204#define WL1273_IS2_RATE_32K (0x2 << 12)
205#define WL1273_IS2_RATE_22_05K (0x4 << 12)
206#define WL1273_IS2_RATE_16K (0x5 << 12)
207#define WL1273_IS2_RATE_12K (0x8 << 12)
208#define WL1273_IS2_RATE_11_025 (0x9 << 12)
209#define WL1273_IS2_RATE_8K (0xa << 12)
210#define WL1273_IS2_RATE (0xf << 12)
211
212#define WL1273_I2S_DEF_MODE (WL1273_IS2_WIDTH_32 | \
213 WL1273_IS2_FORMAT_STD | \
214 WL1273_IS2_MASTER | \
215 WL1273_IS2_TRI_AFTER_SENDING | \
216 WL1273_IS2_SDOWS_RR | \
217 WL1273_IS2_TRI_OPT | \
218 WL1273_IS2_RATE_48K)
219
220#define SCHAR_MIN (-128)
221#define SCHAR_MAX 127
222
223#define WL1273_FR_EVENT BIT(0)
224#define WL1273_BL_EVENT BIT(1)
225#define WL1273_RDS_EVENT BIT(2)
226#define WL1273_BBLK_EVENT BIT(3)
227#define WL1273_LSYNC_EVENT BIT(4)
228#define WL1273_LEV_EVENT BIT(5)
229#define WL1273_IFFR_EVENT BIT(6)
230#define WL1273_PI_EVENT BIT(7)
231#define WL1273_PD_EVENT BIT(8)
232#define WL1273_STIC_EVENT BIT(9)
233#define WL1273_MAL_EVENT BIT(10)
234#define WL1273_POW_ENB_EVENT BIT(11)
235#define WL1273_SCAN_OVER_EVENT BIT(12)
236#define WL1273_ERROR_EVENT BIT(13)
237
238#define TUNER_MODE_STOP_SEARCH 0
239#define TUNER_MODE_PRESET 1
240#define TUNER_MODE_AUTO_SEEK 2
241#define TUNER_MODE_AF 3
242#define TUNER_MODE_AUTO_SEEK_PI 4
243#define TUNER_MODE_AUTO_SEEK_BULK 5
244
245#define RDS_BLOCK_SIZE 3
246
247struct wl1273_fm_platform_data {
248 int (*request_resources) (struct i2c_client *client);
249 void (*free_resources) (void);
250 void (*enable) (void);
251 void (*disable) (void);
252
253 u8 forbidden_modes;
254 unsigned int children;
255};
256
257#define WL1273_FM_CORE_CELLS 2
258
259#define WL1273_BAND_OTHER 0
260#define WL1273_BAND_JAPAN 1
261
262#define WL1273_BAND_JAPAN_LOW 76000
263#define WL1273_BAND_JAPAN_HIGH 90000
264#define WL1273_BAND_OTHER_LOW 87500
265#define WL1273_BAND_OTHER_HIGH 108000
266
267#define WL1273_BAND_TX_LOW 76000
268#define WL1273_BAND_TX_HIGH 108000
269
270struct wl1273_core {
271 struct mfd_cell cells[WL1273_FM_CORE_CELLS];
272 struct wl1273_fm_platform_data *pdata;
273
274 unsigned int mode;
275 unsigned int i2s_mode;
276 unsigned int volume;
277 unsigned int audio_mode;
278 unsigned int channel_number;
279 struct mutex lock; /* for serializing fm radio operations */
280
281 struct i2c_client *client;
282
283 int (*read)(struct wl1273_core *core, u8, u16 *);
284 int (*write)(struct wl1273_core *core, u8, u16);
285 int (*write_data)(struct wl1273_core *core, u8 *, u16);
286 int (*set_audio)(struct wl1273_core *core, unsigned int);
287 int (*set_volume)(struct wl1273_core *core, unsigned int);
288};
289
290#endif /* ifndef WL1273_CORE_H */
diff --git a/include/linux/mfd/wm831x/core.h b/include/linux/mfd/wm831x/core.h
index eb5bd4e0e03c..0d515ee1c247 100644
--- a/include/linux/mfd/wm831x/core.h
+++ b/include/linux/mfd/wm831x/core.h
@@ -238,6 +238,16 @@ struct regulator_dev;
238 238
239#define WM831X_NUM_IRQ_REGS 5 239#define WM831X_NUM_IRQ_REGS 5
240 240
241enum wm831x_parent {
242 WM8310 = 0x8310,
243 WM8311 = 0x8311,
244 WM8312 = 0x8312,
245 WM8320 = 0x8320,
246 WM8321 = 0x8321,
247 WM8325 = 0x8325,
248 WM8326 = 0x8326,
249};
250
241struct wm831x { 251struct wm831x {
242 struct mutex io_lock; 252 struct mutex io_lock;
243 253
@@ -285,33 +295,10 @@ int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg,
285int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg, 295int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
286 int count, u16 *buf); 296 int count, u16 *buf);
287 297
298int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq);
299void wm831x_device_exit(struct wm831x *wm831x);
300int wm831x_device_suspend(struct wm831x *wm831x);
288int wm831x_irq_init(struct wm831x *wm831x, int irq); 301int wm831x_irq_init(struct wm831x *wm831x, int irq);
289void wm831x_irq_exit(struct wm831x *wm831x); 302void wm831x_irq_exit(struct wm831x *wm831x);
290 303
291static inline int __must_check wm831x_request_irq(struct wm831x *wm831x,
292 unsigned int irq,
293 irq_handler_t handler,
294 unsigned long flags,
295 const char *name,
296 void *dev)
297{
298 return request_threaded_irq(irq, NULL, handler, flags, name, dev);
299}
300
301static inline void wm831x_free_irq(struct wm831x *wm831x,
302 unsigned int irq, void *dev)
303{
304 free_irq(irq, dev);
305}
306
307static inline void wm831x_disable_irq(struct wm831x *wm831x, int irq)
308{
309 disable_irq(irq);
310}
311
312static inline void wm831x_enable_irq(struct wm831x *wm831x, int irq)
313{
314 enable_irq(irq);
315}
316
317#endif 304#endif
diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h
index fd322aca33ba..ff42d700293f 100644
--- a/include/linux/mfd/wm831x/pdata.h
+++ b/include/linux/mfd/wm831x/pdata.h
@@ -80,7 +80,10 @@ struct wm831x_touch_pdata {
80 int isel; /** Current for pen down (uA) */ 80 int isel; /** Current for pen down (uA) */
81 int rpu; /** Pen down sensitivity resistor divider */ 81 int rpu; /** Pen down sensitivity resistor divider */
82 int pressure; /** Report pressure (boolean) */ 82 int pressure; /** Report pressure (boolean) */
83 int data_irq; /** Touch data ready IRQ */ 83 unsigned int data_irq; /** Touch data ready IRQ */
84 int data_irqf; /** IRQ flags for data ready IRQ */
85 unsigned int pd_irq; /** Touch pendown detect IRQ */
86 int pd_irqf; /** IRQ flags for pen down IRQ */
84}; 87};
85 88
86enum wm831x_watchdog_action { 89enum wm831x_watchdog_action {
@@ -102,14 +105,24 @@ struct wm831x_watchdog_pdata {
102#define WM831X_MAX_LDO 11 105#define WM831X_MAX_LDO 11
103#define WM831X_MAX_ISINK 2 106#define WM831X_MAX_ISINK 2
104 107
108#define WM831X_GPIO_CONFIGURE 0x10000
109#define WM831X_GPIO_NUM 16
110
105struct wm831x_pdata { 111struct wm831x_pdata {
112 /** Used to distinguish multiple WM831x chips */
113 int wm831x_num;
114
106 /** Called before subdevices are set up */ 115 /** Called before subdevices are set up */
107 int (*pre_init)(struct wm831x *wm831x); 116 int (*pre_init)(struct wm831x *wm831x);
108 /** Called after subdevices are set up */ 117 /** Called after subdevices are set up */
109 int (*post_init)(struct wm831x *wm831x); 118 int (*post_init)(struct wm831x *wm831x);
110 119
120 /** Put the /IRQ line into CMOS mode */
121 bool irq_cmos;
122
111 int irq_base; 123 int irq_base;
112 int gpio_base; 124 int gpio_base;
125 int gpio_defaults[WM831X_GPIO_NUM];
113 struct wm831x_backlight_pdata *backlight; 126 struct wm831x_backlight_pdata *backlight;
114 struct wm831x_backup_pdata *backup; 127 struct wm831x_backup_pdata *backup;
115 struct wm831x_battery_pdata *battery; 128 struct wm831x_battery_pdata *battery;
diff --git a/include/linux/mfd/wm8350/audio.h b/include/linux/mfd/wm8350/audio.h
index a95141eafce3..bd581c6fa085 100644
--- a/include/linux/mfd/wm8350/audio.h
+++ b/include/linux/mfd/wm8350/audio.h
@@ -522,9 +522,6 @@
522#define WM8350_MCLK_SEL_PLL_32K 3 522#define WM8350_MCLK_SEL_PLL_32K 3
523#define WM8350_MCLK_SEL_MCLK 5 523#define WM8350_MCLK_SEL_MCLK 5
524 524
525#define WM8350_MCLK_DIR_OUT 0
526#define WM8350_MCLK_DIR_IN 1
527
528/* clock divider id's */ 525/* clock divider id's */
529#define WM8350_ADC_CLKDIV 0 526#define WM8350_ADC_CLKDIV 0
530#define WM8350_DAC_CLKDIV 1 527#define WM8350_DAC_CLKDIV 1
diff --git a/include/linux/mfd/wm8350/pmic.h b/include/linux/mfd/wm8350/pmic.h
index e786fe9841ef..579b50ca2e02 100644
--- a/include/linux/mfd/wm8350/pmic.h
+++ b/include/linux/mfd/wm8350/pmic.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * pmic.h -- Power Managment Driver for Wolfson WM8350 PMIC 2 * pmic.h -- Power Management Driver for Wolfson WM8350 PMIC
3 * 3 *
4 * Copyright 2007 Wolfson Microelectronics PLC 4 * Copyright 2007 Wolfson Microelectronics PLC
5 * 5 *
diff --git a/include/linux/mfd/wm8994/core.h b/include/linux/mfd/wm8994/core.h
index de79baee4925..f0b69cdae41c 100644
--- a/include/linux/mfd/wm8994/core.h
+++ b/include/linux/mfd/wm8994/core.h
@@ -17,6 +17,11 @@
17 17
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19 19
20enum wm8994_type {
21 WM8994 = 0,
22 WM8958 = 1,
23};
24
20struct regulator_dev; 25struct regulator_dev;
21struct regulator_bulk_data; 26struct regulator_bulk_data;
22 27
@@ -48,11 +53,13 @@ struct wm8994 {
48 struct mutex io_lock; 53 struct mutex io_lock;
49 struct mutex irq_lock; 54 struct mutex irq_lock;
50 55
56 enum wm8994_type type;
57
51 struct device *dev; 58 struct device *dev;
52 int (*read_dev)(struct wm8994 *wm8994, unsigned short reg, 59 int (*read_dev)(struct wm8994 *wm8994, unsigned short reg,
53 int bytes, void *dest); 60 int bytes, void *dest);
54 int (*write_dev)(struct wm8994 *wm8994, unsigned short reg, 61 int (*write_dev)(struct wm8994 *wm8994, unsigned short reg,
55 int bytes, void *src); 62 int bytes, const void *src);
56 63
57 void *control_data; 64 void *control_data;
58 65
@@ -64,10 +71,12 @@ struct wm8994 {
64 u16 irq_masks_cache[WM8994_NUM_IRQ_REGS]; 71 u16 irq_masks_cache[WM8994_NUM_IRQ_REGS];
65 72
66 /* Used over suspend/resume */ 73 /* Used over suspend/resume */
74 bool suspended;
67 u16 ldo_regs[WM8994_NUM_LDO_REGS]; 75 u16 ldo_regs[WM8994_NUM_LDO_REGS];
68 u16 gpio_regs[WM8994_NUM_GPIO_REGS]; 76 u16 gpio_regs[WM8994_NUM_GPIO_REGS];
69 77
70 struct regulator_dev *dbvdd; 78 struct regulator_dev *dbvdd;
79 int num_supplies;
71 struct regulator_bulk_data *supplies; 80 struct regulator_bulk_data *supplies;
72}; 81};
73 82
@@ -79,6 +88,8 @@ int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
79 unsigned short mask, unsigned short val); 88 unsigned short mask, unsigned short val);
80int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg, 89int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
81 int count, u16 *buf); 90 int count, u16 *buf);
91int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
92 int count, const u16 *buf);
82 93
83 94
84/* Helper to save on boilerplate */ 95/* Helper to save on boilerplate */
diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h
index 5c51f367c061..d12f8d635a81 100644
--- a/include/linux/mfd/wm8994/pdata.h
+++ b/include/linux/mfd/wm8994/pdata.h
@@ -29,7 +29,13 @@ struct wm8994_ldo_pdata {
29#define WM8994_CONFIGURE_GPIO 0x8000 29#define WM8994_CONFIGURE_GPIO 0x8000
30 30
31#define WM8994_DRC_REGS 5 31#define WM8994_DRC_REGS 5
32#define WM8994_EQ_REGS 19 32#define WM8994_EQ_REGS 20
33#define WM8958_MBC_CUTOFF_REGS 20
34#define WM8958_MBC_COEFF_REGS 48
35#define WM8958_MBC_COMBINED_REGS 56
36#define WM8958_VSS_HPF_REGS 2
37#define WM8958_VSS_REGS 148
38#define WM8958_ENH_EQ_REGS 32
33 39
34/** 40/**
35 * DRC configurations are specified with a label and a set of register 41 * DRC configurations are specified with a label and a set of register
@@ -59,6 +65,54 @@ struct wm8994_retune_mobile_cfg {
59 u16 regs[WM8994_EQ_REGS]; 65 u16 regs[WM8994_EQ_REGS];
60}; 66};
61 67
68/**
69 * Multiband compressor configurations are specified with a label and
70 * two sets of values to write. Configurations are expected to be
71 * generated using the multiband compressor configuration panel in
72 * WISCE - see http://www.wolfsonmicro.com/wisce/
73 */
74struct wm8958_mbc_cfg {
75 const char *name;
76 u16 cutoff_regs[WM8958_MBC_CUTOFF_REGS];
77 u16 coeff_regs[WM8958_MBC_COEFF_REGS];
78
79 /* Coefficient layout when using MBC+VSS firmware */
80 u16 combined_regs[WM8958_MBC_COMBINED_REGS];
81};
82
83/**
84 * VSS HPF configurations are specified with a label and two values to
85 * write. Configurations are expected to be generated using the
86 * multiband compressor configuration panel in WISCE - see
87 * http://www.wolfsonmicro.com/wisce/
88 */
89struct wm8958_vss_hpf_cfg {
90 const char *name;
91 u16 regs[WM8958_VSS_HPF_REGS];
92};
93
94/**
95 * VSS configurations are specified with a label and array of values
96 * to write. Configurations are expected to be generated using the
97 * multiband compressor configuration panel in WISCE - see
98 * http://www.wolfsonmicro.com/wisce/
99 */
100struct wm8958_vss_cfg {
101 const char *name;
102 u16 regs[WM8958_VSS_REGS];
103};
104
105/**
106 * Enhanced EQ configurations are specified with a label and array of
107 * values to write. Configurations are expected to be generated using
108 * the multiband compressor configuration panel in WISCE - see
109 * http://www.wolfsonmicro.com/wisce/
110 */
111struct wm8958_enh_eq_cfg {
112 const char *name;
113 u16 regs[WM8958_ENH_EQ_REGS];
114};
115
62struct wm8994_pdata { 116struct wm8994_pdata {
63 int gpio_base; 117 int gpio_base;
64 118
@@ -78,6 +132,18 @@ struct wm8994_pdata {
78 int num_retune_mobile_cfgs; 132 int num_retune_mobile_cfgs;
79 struct wm8994_retune_mobile_cfg *retune_mobile_cfgs; 133 struct wm8994_retune_mobile_cfg *retune_mobile_cfgs;
80 134
135 int num_mbc_cfgs;
136 struct wm8958_mbc_cfg *mbc_cfgs;
137
138 int num_vss_cfgs;
139 struct wm8958_vss_cfg *vss_cfgs;
140
141 int num_vss_hpf_cfgs;
142 struct wm8958_vss_hpf_cfg *vss_hpf_cfgs;
143
144 int num_enh_eq_cfgs;
145 struct wm8958_enh_eq_cfg *enh_eq_cfgs;
146
81 /* LINEOUT can be differential or single ended */ 147 /* LINEOUT can be differential or single ended */
82 unsigned int lineout1_diff:1; 148 unsigned int lineout1_diff:1;
83 unsigned int lineout2_diff:1; 149 unsigned int lineout2_diff:1;
@@ -86,13 +152,21 @@ struct wm8994_pdata {
86 unsigned int lineout1fb:1; 152 unsigned int lineout1fb:1;
87 unsigned int lineout2fb:1; 153 unsigned int lineout2fb:1;
88 154
89 /* Microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */ 155 /* IRQ for microphone detection if brought out directly as a
156 * signal.
157 */
158 int micdet_irq;
159
160 /* WM8994 microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */
90 unsigned int micbias1_lvl:1; 161 unsigned int micbias1_lvl:1;
91 unsigned int micbias2_lvl:1; 162 unsigned int micbias2_lvl:1;
92 163
93 /* Jack detect threashold levels, see datasheet for values */ 164 /* WM8994 jack detect threashold levels, see datasheet for values */
94 unsigned int jd_scthr:2; 165 unsigned int jd_scthr:2;
95 unsigned int jd_thr:2; 166 unsigned int jd_thr:2;
167
168 /* WM8958 microphone bias configuration */
169 int micbias[2];
96}; 170};
97 171
98#endif 172#endif
diff --git a/include/linux/mfd/wm8994/registers.h b/include/linux/mfd/wm8994/registers.h
index 967f62f54159..f3ee84284670 100644
--- a/include/linux/mfd/wm8994/registers.h
+++ b/include/linux/mfd/wm8994/registers.h
@@ -63,13 +63,19 @@
63#define WM8994_MICBIAS 0x3A 63#define WM8994_MICBIAS 0x3A
64#define WM8994_LDO_1 0x3B 64#define WM8994_LDO_1 0x3B
65#define WM8994_LDO_2 0x3C 65#define WM8994_LDO_2 0x3C
66#define WM8958_MICBIAS1 0x3D
67#define WM8958_MICBIAS2 0x3E
66#define WM8994_CHARGE_PUMP_1 0x4C 68#define WM8994_CHARGE_PUMP_1 0x4C
69#define WM8958_CHARGE_PUMP_2 0x4D
67#define WM8994_CLASS_W_1 0x51 70#define WM8994_CLASS_W_1 0x51
68#define WM8994_DC_SERVO_1 0x54 71#define WM8994_DC_SERVO_1 0x54
69#define WM8994_DC_SERVO_2 0x55 72#define WM8994_DC_SERVO_2 0x55
70#define WM8994_DC_SERVO_4 0x57 73#define WM8994_DC_SERVO_4 0x57
71#define WM8994_DC_SERVO_READBACK 0x58 74#define WM8994_DC_SERVO_READBACK 0x58
72#define WM8994_ANALOGUE_HP_1 0x60 75#define WM8994_ANALOGUE_HP_1 0x60
76#define WM8958_MIC_DETECT_1 0xD0
77#define WM8958_MIC_DETECT_2 0xD1
78#define WM8958_MIC_DETECT_3 0xD2
73#define WM8994_CHIP_REVISION 0x100 79#define WM8994_CHIP_REVISION 0x100
74#define WM8994_CONTROL_INTERFACE 0x101 80#define WM8994_CONTROL_INTERFACE 0x101
75#define WM8994_WRITE_SEQUENCER_CTRL_1 0x110 81#define WM8994_WRITE_SEQUENCER_CTRL_1 0x110
@@ -109,6 +115,10 @@
109#define WM8994_AIF2DAC_LRCLK 0x315 115#define WM8994_AIF2DAC_LRCLK 0x315
110#define WM8994_AIF2DAC_DATA 0x316 116#define WM8994_AIF2DAC_DATA 0x316
111#define WM8994_AIF2ADC_DATA 0x317 117#define WM8994_AIF2ADC_DATA 0x317
118#define WM8958_AIF3_CONTROL_1 0x320
119#define WM8958_AIF3_CONTROL_2 0x321
120#define WM8958_AIF3DAC_DATA 0x322
121#define WM8958_AIF3ADC_DATA 0x323
112#define WM8994_AIF1_ADC1_LEFT_VOLUME 0x400 122#define WM8994_AIF1_ADC1_LEFT_VOLUME 0x400
113#define WM8994_AIF1_ADC1_RIGHT_VOLUME 0x401 123#define WM8994_AIF1_ADC1_RIGHT_VOLUME 0x401
114#define WM8994_AIF1_DAC1_LEFT_VOLUME 0x402 124#define WM8994_AIF1_DAC1_LEFT_VOLUME 0x402
@@ -242,6 +252,83 @@
242#define WM8994_INTERRUPT_STATUS_2_MASK 0x739 252#define WM8994_INTERRUPT_STATUS_2_MASK 0x739
243#define WM8994_INTERRUPT_CONTROL 0x740 253#define WM8994_INTERRUPT_CONTROL 0x740
244#define WM8994_IRQ_DEBOUNCE 0x748 254#define WM8994_IRQ_DEBOUNCE 0x748
255#define WM8958_DSP2_PROGRAM 0x900
256#define WM8958_DSP2_CONFIG 0x901
257#define WM8958_DSP2_MAGICNUM 0xA00
258#define WM8958_DSP2_RELEASEYEAR 0xA01
259#define WM8958_DSP2_RELEASEMONTHDAY 0xA02
260#define WM8958_DSP2_RELEASETIME 0xA03
261#define WM8958_DSP2_VERMAJMIN 0xA04
262#define WM8958_DSP2_VERBUILD 0xA05
263#define WM8958_DSP2_EXECCONTROL 0xA0D
264#define WM8958_MBC_BAND_2_LOWER_CUTOFF_C1_1 0x2200
265#define WM8958_MBC_BAND_2_LOWER_CUTOFF_C1_2 0x2201
266#define WM8958_MBC_BAND_2_LOWER_CUTOFF_C2_1 0x2202
267#define WM8958_MBC_BAND_2_LOWER_CUTOFF_C2_2 0x2203
268#define WM8958_MBC_BAND_2_LOWER_CUTOFF_C3_1 0x2204
269#define WM8958_MBC_BAND_2_LOWER_CUTOFF_C3_2 0x2205
270#define WM8958_MBC_BAND_2_UPPER_CUTOFF_C2_1 0x2206
271#define WM8958_MBC_BAND_2_UPPER_CUTOFF_C2_2 0x2207
272#define WM8958_MBC_BAND_2_UPPER_CUTOFF_C3_1 0x2208
273#define WM8958_MBC_BAND_2_UPPER_CUTOFF_C3_2 0x2209
274#define WM8958_MBC_BAND_2_UPPER_CUTOFF_C1_1 0x220A
275#define WM8958_MBC_BAND_2_UPPER_CUTOFF_C1_2 0x220B
276#define WM8958_MBC_BAND_1_UPPER_CUTOFF_C1_1 0x220C
277#define WM8958_MBC_BAND_1_UPPER_CUTOFF_C1_2 0x220D
278#define WM8958_MBC_BAND_1_UPPER_CUTOFF_C2_1 0x220E
279#define WM8958_MBC_BAND_1_UPPER_CUTOFF_C2_2 0x220F
280#define WM8958_MBC_BAND_1_UPPER_CUTOFF_C3_1 0x2210
281#define WM8958_MBC_BAND_1_UPPER_CUTOFF_C3_2 0x2211
282#define WM8958_MBC_BAND_1_LOWER_CUTOFF_1 0x2212
283#define WM8958_MBC_BAND_1_LOWER_CUTOFF_2 0x2213
284#define WM8958_MBC_BAND_1_K_1 0x2400
285#define WM8958_MBC_BAND_1_K_2 0x2401
286#define WM8958_MBC_BAND_1_N1_1 0x2402
287#define WM8958_MBC_BAND_1_N1_2 0x2403
288#define WM8958_MBC_BAND_1_N2_1 0x2404
289#define WM8958_MBC_BAND_1_N2_2 0x2405
290#define WM8958_MBC_BAND_1_N3_1 0x2406
291#define WM8958_MBC_BAND_1_N3_2 0x2407
292#define WM8958_MBC_BAND_1_N4_1 0x2408
293#define WM8958_MBC_BAND_1_N4_2 0x2409
294#define WM8958_MBC_BAND_1_N5_1 0x240A
295#define WM8958_MBC_BAND_1_N5_2 0x240B
296#define WM8958_MBC_BAND_1_X1_1 0x240C
297#define WM8958_MBC_BAND_1_X1_2 0x240D
298#define WM8958_MBC_BAND_1_X2_1 0x240E
299#define WM8958_MBC_BAND_1_X2_2 0x240F
300#define WM8958_MBC_BAND_1_X3_1 0x2410
301#define WM8958_MBC_BAND_1_X3_2 0x2411
302#define WM8958_MBC_BAND_1_ATTACK_1 0x2412
303#define WM8958_MBC_BAND_1_ATTACK_2 0x2413
304#define WM8958_MBC_BAND_1_DECAY_1 0x2414
305#define WM8958_MBC_BAND_1_DECAY_2 0x2415
306#define WM8958_MBC_BAND_2_K_1 0x2416
307#define WM8958_MBC_BAND_2_K_2 0x2417
308#define WM8958_MBC_BAND_2_N1_1 0x2418
309#define WM8958_MBC_BAND_2_N1_2 0x2419
310#define WM8958_MBC_BAND_2_N2_1 0x241A
311#define WM8958_MBC_BAND_2_N2_2 0x241B
312#define WM8958_MBC_BAND_2_N3_1 0x241C
313#define WM8958_MBC_BAND_2_N3_2 0x241D
314#define WM8958_MBC_BAND_2_N4_1 0x241E
315#define WM8958_MBC_BAND_2_N4_2 0x241F
316#define WM8958_MBC_BAND_2_N5_1 0x2420
317#define WM8958_MBC_BAND_2_N5_2 0x2421
318#define WM8958_MBC_BAND_2_X1_1 0x2422
319#define WM8958_MBC_BAND_2_X1_2 0x2423
320#define WM8958_MBC_BAND_2_X2_1 0x2424
321#define WM8958_MBC_BAND_2_X2_2 0x2425
322#define WM8958_MBC_BAND_2_X3_1 0x2426
323#define WM8958_MBC_BAND_2_X3_2 0x2427
324#define WM8958_MBC_BAND_2_ATTACK_1 0x2428
325#define WM8958_MBC_BAND_2_ATTACK_2 0x2429
326#define WM8958_MBC_BAND_2_DECAY_1 0x242A
327#define WM8958_MBC_BAND_2_DECAY_2 0x242B
328#define WM8958_MBC_B2_PG2_1 0x242C
329#define WM8958_MBC_B2_PG2_2 0x242D
330#define WM8958_MBC_B1_PG2_1 0x242E
331#define WM8958_MBC_B1_PG2_2 0x242F
245#define WM8994_WRITE_SEQUENCER_0 0x3000 332#define WM8994_WRITE_SEQUENCER_0 0x3000
246#define WM8994_WRITE_SEQUENCER_1 0x3001 333#define WM8994_WRITE_SEQUENCER_1 0x3001
247#define WM8994_WRITE_SEQUENCER_2 0x3002 334#define WM8994_WRITE_SEQUENCER_2 0x3002
@@ -992,6 +1079,12 @@
992/* 1079/*
993 * R6 (0x06) - Power Management (6) 1080 * R6 (0x06) - Power Management (6)
994 */ 1081 */
1082#define WM8958_AIF3ADC_SRC_MASK 0x0600 /* AIF3ADC_SRC - [10:9] */
1083#define WM8958_AIF3ADC_SRC_SHIFT 9 /* AIF3ADC_SRC - [10:9] */
1084#define WM8958_AIF3ADC_SRC_WIDTH 2 /* AIF3ADC_SRC - [10:9] */
1085#define WM8958_AIF2DAC_SRC_MASK 0x0180 /* AIF2DAC_SRC - [8:7] */
1086#define WM8958_AIF2DAC_SRC_SHIFT 7 /* AIF2DAC_SRC - [8:7] */
1087#define WM8958_AIF2DAC_SRC_WIDTH 2 /* AIF2DAC_SRC - [8:7] */
995#define WM8994_AIF3_TRI 0x0020 /* AIF3_TRI */ 1088#define WM8994_AIF3_TRI 0x0020 /* AIF3_TRI */
996#define WM8994_AIF3_TRI_MASK 0x0020 /* AIF3_TRI */ 1089#define WM8994_AIF3_TRI_MASK 0x0020 /* AIF3_TRI */
997#define WM8994_AIF3_TRI_SHIFT 5 /* AIF3_TRI */ 1090#define WM8994_AIF3_TRI_SHIFT 5 /* AIF3_TRI */
@@ -1836,6 +1929,14 @@
1836#define WM8994_CP_ENA_WIDTH 1 /* CP_ENA */ 1929#define WM8994_CP_ENA_WIDTH 1 /* CP_ENA */
1837 1930
1838/* 1931/*
1932 * R77 (0x4D) - Charge Pump (2)
1933 */
1934#define WM8958_CP_DISCH 0x8000 /* CP_DISCH */
1935#define WM8958_CP_DISCH_MASK 0x8000 /* CP_DISCH */
1936#define WM8958_CP_DISCH_SHIFT 15 /* CP_DISCH */
1937#define WM8958_CP_DISCH_WIDTH 1 /* CP_DISCH */
1938
1939/*
1839 * R81 (0x51) - Class W (1) 1940 * R81 (0x51) - Class W (1)
1840 */ 1941 */
1841#define WM8994_CP_DYN_SRC_SEL_MASK 0x0300 /* CP_DYN_SRC_SEL - [9:8] */ 1942#define WM8994_CP_DYN_SRC_SEL_MASK 0x0300 /* CP_DYN_SRC_SEL - [9:8] */
@@ -1952,6 +2053,46 @@
1952#define WM8994_HPOUT1R_DLY_WIDTH 1 /* HPOUT1R_DLY */ 2053#define WM8994_HPOUT1R_DLY_WIDTH 1 /* HPOUT1R_DLY */
1953 2054
1954/* 2055/*
2056 * R208 (0xD0) - Mic Detect 1
2057 */
2058#define WM8958_MICD_BIAS_STARTTIME_MASK 0xF000 /* MICD_BIAS_STARTTIME - [15:12] */
2059#define WM8958_MICD_BIAS_STARTTIME_SHIFT 12 /* MICD_BIAS_STARTTIME - [15:12] */
2060#define WM8958_MICD_BIAS_STARTTIME_WIDTH 4 /* MICD_BIAS_STARTTIME - [15:12] */
2061#define WM8958_MICD_RATE_MASK 0x0F00 /* MICD_RATE - [11:8] */
2062#define WM8958_MICD_RATE_SHIFT 8 /* MICD_RATE - [11:8] */
2063#define WM8958_MICD_RATE_WIDTH 4 /* MICD_RATE - [11:8] */
2064#define WM8958_MICD_DBTIME 0x0002 /* MICD_DBTIME */
2065#define WM8958_MICD_DBTIME_MASK 0x0002 /* MICD_DBTIME */
2066#define WM8958_MICD_DBTIME_SHIFT 1 /* MICD_DBTIME */
2067#define WM8958_MICD_DBTIME_WIDTH 1 /* MICD_DBTIME */
2068#define WM8958_MICD_ENA 0x0001 /* MICD_ENA */
2069#define WM8958_MICD_ENA_MASK 0x0001 /* MICD_ENA */
2070#define WM8958_MICD_ENA_SHIFT 0 /* MICD_ENA */
2071#define WM8958_MICD_ENA_WIDTH 1 /* MICD_ENA */
2072
2073/*
2074 * R209 (0xD1) - Mic Detect 2
2075 */
2076#define WM8958_MICD_LVL_SEL_MASK 0x00FF /* MICD_LVL_SEL - [7:0] */
2077#define WM8958_MICD_LVL_SEL_SHIFT 0 /* MICD_LVL_SEL - [7:0] */
2078#define WM8958_MICD_LVL_SEL_WIDTH 8 /* MICD_LVL_SEL - [7:0] */
2079
2080/*
2081 * R210 (0xD2) - Mic Detect 3
2082 */
2083#define WM8958_MICD_LVL_MASK 0x07FC /* MICD_LVL - [10:2] */
2084#define WM8958_MICD_LVL_SHIFT 2 /* MICD_LVL - [10:2] */
2085#define WM8958_MICD_LVL_WIDTH 9 /* MICD_LVL - [10:2] */
2086#define WM8958_MICD_VALID 0x0002 /* MICD_VALID */
2087#define WM8958_MICD_VALID_MASK 0x0002 /* MICD_VALID */
2088#define WM8958_MICD_VALID_SHIFT 1 /* MICD_VALID */
2089#define WM8958_MICD_VALID_WIDTH 1 /* MICD_VALID */
2090#define WM8958_MICD_STS 0x0001 /* MICD_STS */
2091#define WM8958_MICD_STS_MASK 0x0001 /* MICD_STS */
2092#define WM8958_MICD_STS_SHIFT 0 /* MICD_STS */
2093#define WM8958_MICD_STS_WIDTH 1 /* MICD_STS */
2094
2095/*
1955 * R256 (0x100) - Chip Revision 2096 * R256 (0x100) - Chip Revision
1956 */ 2097 */
1957#define WM8994_CHIP_REV_MASK 0x000F /* CHIP_REV - [3:0] */ 2098#define WM8994_CHIP_REV_MASK 0x000F /* CHIP_REV - [3:0] */
@@ -2069,6 +2210,14 @@
2069/* 2210/*
2070 * R520 (0x208) - Clocking (1) 2211 * R520 (0x208) - Clocking (1)
2071 */ 2212 */
2213#define WM8958_DSP2CLK_ENA 0x4000 /* DSP2CLK_ENA */
2214#define WM8958_DSP2CLK_ENA_MASK 0x4000 /* DSP2CLK_ENA */
2215#define WM8958_DSP2CLK_ENA_SHIFT 14 /* DSP2CLK_ENA */
2216#define WM8958_DSP2CLK_ENA_WIDTH 1 /* DSP2CLK_ENA */
2217#define WM8958_DSP2CLK_SRC 0x1000 /* DSP2CLK_SRC */
2218#define WM8958_DSP2CLK_SRC_MASK 0x1000 /* DSP2CLK_SRC */
2219#define WM8958_DSP2CLK_SRC_SHIFT 12 /* DSP2CLK_SRC */
2220#define WM8958_DSP2CLK_SRC_WIDTH 1 /* DSP2CLK_SRC */
2072#define WM8994_TOCLK_ENA 0x0010 /* TOCLK_ENA */ 2221#define WM8994_TOCLK_ENA 0x0010 /* TOCLK_ENA */
2073#define WM8994_TOCLK_ENA_MASK 0x0010 /* TOCLK_ENA */ 2222#define WM8994_TOCLK_ENA_MASK 0x0010 /* TOCLK_ENA */
2074#define WM8994_TOCLK_ENA_SHIFT 4 /* TOCLK_ENA */ 2223#define WM8994_TOCLK_ENA_SHIFT 4 /* TOCLK_ENA */
@@ -2553,6 +2702,63 @@
2553#define WM8994_AIF2ADCR_DAT_INV_WIDTH 1 /* AIF2ADCR_DAT_INV */ 2702#define WM8994_AIF2ADCR_DAT_INV_WIDTH 1 /* AIF2ADCR_DAT_INV */
2554 2703
2555/* 2704/*
2705 * R800 (0x320) - AIF3 Control (1)
2706 */
2707#define WM8958_AIF3_LRCLK_INV 0x0080 /* AIF3_LRCLK_INV */
2708#define WM8958_AIF3_LRCLK_INV_MASK 0x0080 /* AIF3_LRCLK_INV */
2709#define WM8958_AIF3_LRCLK_INV_SHIFT 7 /* AIF3_LRCLK_INV */
2710#define WM8958_AIF3_LRCLK_INV_WIDTH 1 /* AIF3_LRCLK_INV */
2711#define WM8958_AIF3_WL_MASK 0x0060 /* AIF3_WL - [6:5] */
2712#define WM8958_AIF3_WL_SHIFT 5 /* AIF3_WL - [6:5] */
2713#define WM8958_AIF3_WL_WIDTH 2 /* AIF3_WL - [6:5] */
2714#define WM8958_AIF3_FMT_MASK 0x0018 /* AIF3_FMT - [4:3] */
2715#define WM8958_AIF3_FMT_SHIFT 3 /* AIF3_FMT - [4:3] */
2716#define WM8958_AIF3_FMT_WIDTH 2 /* AIF3_FMT - [4:3] */
2717
2718/*
2719 * R801 (0x321) - AIF3 Control (2)
2720 */
2721#define WM8958_AIF3DAC_BOOST_MASK 0x0C00 /* AIF3DAC_BOOST - [11:10] */
2722#define WM8958_AIF3DAC_BOOST_SHIFT 10 /* AIF3DAC_BOOST - [11:10] */
2723#define WM8958_AIF3DAC_BOOST_WIDTH 2 /* AIF3DAC_BOOST - [11:10] */
2724#define WM8958_AIF3DAC_COMP 0x0010 /* AIF3DAC_COMP */
2725#define WM8958_AIF3DAC_COMP_MASK 0x0010 /* AIF3DAC_COMP */
2726#define WM8958_AIF3DAC_COMP_SHIFT 4 /* AIF3DAC_COMP */
2727#define WM8958_AIF3DAC_COMP_WIDTH 1 /* AIF3DAC_COMP */
2728#define WM8958_AIF3DAC_COMPMODE 0x0008 /* AIF3DAC_COMPMODE */
2729#define WM8958_AIF3DAC_COMPMODE_MASK 0x0008 /* AIF3DAC_COMPMODE */
2730#define WM8958_AIF3DAC_COMPMODE_SHIFT 3 /* AIF3DAC_COMPMODE */
2731#define WM8958_AIF3DAC_COMPMODE_WIDTH 1 /* AIF3DAC_COMPMODE */
2732#define WM8958_AIF3ADC_COMP 0x0004 /* AIF3ADC_COMP */
2733#define WM8958_AIF3ADC_COMP_MASK 0x0004 /* AIF3ADC_COMP */
2734#define WM8958_AIF3ADC_COMP_SHIFT 2 /* AIF3ADC_COMP */
2735#define WM8958_AIF3ADC_COMP_WIDTH 1 /* AIF3ADC_COMP */
2736#define WM8958_AIF3ADC_COMPMODE 0x0002 /* AIF3ADC_COMPMODE */
2737#define WM8958_AIF3ADC_COMPMODE_MASK 0x0002 /* AIF3ADC_COMPMODE */
2738#define WM8958_AIF3ADC_COMPMODE_SHIFT 1 /* AIF3ADC_COMPMODE */
2739#define WM8958_AIF3ADC_COMPMODE_WIDTH 1 /* AIF3ADC_COMPMODE */
2740#define WM8958_AIF3_LOOPBACK 0x0001 /* AIF3_LOOPBACK */
2741#define WM8958_AIF3_LOOPBACK_MASK 0x0001 /* AIF3_LOOPBACK */
2742#define WM8958_AIF3_LOOPBACK_SHIFT 0 /* AIF3_LOOPBACK */
2743#define WM8958_AIF3_LOOPBACK_WIDTH 1 /* AIF3_LOOPBACK */
2744
2745/*
2746 * R802 (0x322) - AIF3DAC Data
2747 */
2748#define WM8958_AIF3DAC_DAT_INV 0x0001 /* AIF3DAC_DAT_INV */
2749#define WM8958_AIF3DAC_DAT_INV_MASK 0x0001 /* AIF3DAC_DAT_INV */
2750#define WM8958_AIF3DAC_DAT_INV_SHIFT 0 /* AIF3DAC_DAT_INV */
2751#define WM8958_AIF3DAC_DAT_INV_WIDTH 1 /* AIF3DAC_DAT_INV */
2752
2753/*
2754 * R803 (0x323) - AIF3ADC Data
2755 */
2756#define WM8958_AIF3ADC_DAT_INV 0x0001 /* AIF3ADC_DAT_INV */
2757#define WM8958_AIF3ADC_DAT_INV_MASK 0x0001 /* AIF3ADC_DAT_INV */
2758#define WM8958_AIF3ADC_DAT_INV_SHIFT 0 /* AIF3ADC_DAT_INV */
2759#define WM8958_AIF3ADC_DAT_INV_WIDTH 1 /* AIF3ADC_DAT_INV */
2760
2761/*
2556 * R1024 (0x400) - AIF1 ADC1 Left Volume 2762 * R1024 (0x400) - AIF1 ADC1 Left Volume
2557 */ 2763 */
2558#define WM8994_AIF1ADC1_VU 0x0100 /* AIF1ADC1_VU */ 2764#define WM8994_AIF1ADC1_VU 0x0100 /* AIF1ADC1_VU */
@@ -4289,4 +4495,102 @@
4289#define WM8994_TEMP_SHUT_DB_SHIFT 0 /* TEMP_SHUT_DB */ 4495#define WM8994_TEMP_SHUT_DB_SHIFT 0 /* TEMP_SHUT_DB */
4290#define WM8994_TEMP_SHUT_DB_WIDTH 1 /* TEMP_SHUT_DB */ 4496#define WM8994_TEMP_SHUT_DB_WIDTH 1 /* TEMP_SHUT_DB */
4291 4497
4498/*
4499 * R2304 (0x900) - DSP2_Program
4500 */
4501#define WM8958_DSP2_ENA 0x0001 /* DSP2_ENA */
4502#define WM8958_DSP2_ENA_MASK 0x0001 /* DSP2_ENA */
4503#define WM8958_DSP2_ENA_SHIFT 0 /* DSP2_ENA */
4504#define WM8958_DSP2_ENA_WIDTH 1 /* DSP2_ENA */
4505
4506/*
4507 * R2305 (0x901) - DSP2_Config
4508 */
4509#define WM8958_MBC_SEL_MASK 0x0030 /* MBC_SEL - [5:4] */
4510#define WM8958_MBC_SEL_SHIFT 4 /* MBC_SEL - [5:4] */
4511#define WM8958_MBC_SEL_WIDTH 2 /* MBC_SEL - [5:4] */
4512#define WM8958_MBC_ENA 0x0001 /* MBC_ENA */
4513#define WM8958_MBC_ENA_MASK 0x0001 /* MBC_ENA */
4514#define WM8958_MBC_ENA_SHIFT 0 /* MBC_ENA */
4515#define WM8958_MBC_ENA_WIDTH 1 /* MBC_ENA */
4516
4517/*
4518 * R2560 (0xA00) - DSP2_MagicNum
4519 */
4520#define WM8958_DSP2_MAGIC_NUM_MASK 0xFFFF /* DSP2_MAGIC_NUM - [15:0] */
4521#define WM8958_DSP2_MAGIC_NUM_SHIFT 0 /* DSP2_MAGIC_NUM - [15:0] */
4522#define WM8958_DSP2_MAGIC_NUM_WIDTH 16 /* DSP2_MAGIC_NUM - [15:0] */
4523
4524/*
4525 * R2561 (0xA01) - DSP2_ReleaseYear
4526 */
4527#define WM8958_DSP2_RELEASE_YEAR_MASK 0xFFFF /* DSP2_RELEASE_YEAR - [15:0] */
4528#define WM8958_DSP2_RELEASE_YEAR_SHIFT 0 /* DSP2_RELEASE_YEAR - [15:0] */
4529#define WM8958_DSP2_RELEASE_YEAR_WIDTH 16 /* DSP2_RELEASE_YEAR - [15:0] */
4530
4531/*
4532 * R2562 (0xA02) - DSP2_ReleaseMonthDay
4533 */
4534#define WM8958_DSP2_RELEASE_MONTH_MASK 0xFF00 /* DSP2_RELEASE_MONTH - [15:8] */
4535#define WM8958_DSP2_RELEASE_MONTH_SHIFT 8 /* DSP2_RELEASE_MONTH - [15:8] */
4536#define WM8958_DSP2_RELEASE_MONTH_WIDTH 8 /* DSP2_RELEASE_MONTH - [15:8] */
4537#define WM8958_DSP2_RELEASE_DAY_MASK 0x00FF /* DSP2_RELEASE_DAY - [7:0] */
4538#define WM8958_DSP2_RELEASE_DAY_SHIFT 0 /* DSP2_RELEASE_DAY - [7:0] */
4539#define WM8958_DSP2_RELEASE_DAY_WIDTH 8 /* DSP2_RELEASE_DAY - [7:0] */
4540
4541/*
4542 * R2563 (0xA03) - DSP2_ReleaseTime
4543 */
4544#define WM8958_DSP2_RELEASE_HOURS_MASK 0xFF00 /* DSP2_RELEASE_HOURS - [15:8] */
4545#define WM8958_DSP2_RELEASE_HOURS_SHIFT 8 /* DSP2_RELEASE_HOURS - [15:8] */
4546#define WM8958_DSP2_RELEASE_HOURS_WIDTH 8 /* DSP2_RELEASE_HOURS - [15:8] */
4547#define WM8958_DSP2_RELEASE_MINS_MASK 0x00FF /* DSP2_RELEASE_MINS - [7:0] */
4548#define WM8958_DSP2_RELEASE_MINS_SHIFT 0 /* DSP2_RELEASE_MINS - [7:0] */
4549#define WM8958_DSP2_RELEASE_MINS_WIDTH 8 /* DSP2_RELEASE_MINS - [7:0] */
4550
4551/*
4552 * R2564 (0xA04) - DSP2_VerMajMin
4553 */
4554#define WM8958_DSP2_MAJOR_VER_MASK 0xFF00 /* DSP2_MAJOR_VER - [15:8] */
4555#define WM8958_DSP2_MAJOR_VER_SHIFT 8 /* DSP2_MAJOR_VER - [15:8] */
4556#define WM8958_DSP2_MAJOR_VER_WIDTH 8 /* DSP2_MAJOR_VER - [15:8] */
4557#define WM8958_DSP2_MINOR_VER_MASK 0x00FF /* DSP2_MINOR_VER - [7:0] */
4558#define WM8958_DSP2_MINOR_VER_SHIFT 0 /* DSP2_MINOR_VER - [7:0] */
4559#define WM8958_DSP2_MINOR_VER_WIDTH 8 /* DSP2_MINOR_VER - [7:0] */
4560
4561/*
4562 * R2565 (0xA05) - DSP2_VerBuild
4563 */
4564#define WM8958_DSP2_BUILD_VER_MASK 0xFFFF /* DSP2_BUILD_VER - [15:0] */
4565#define WM8958_DSP2_BUILD_VER_SHIFT 0 /* DSP2_BUILD_VER - [15:0] */
4566#define WM8958_DSP2_BUILD_VER_WIDTH 16 /* DSP2_BUILD_VER - [15:0] */
4567
4568/*
4569 * R2573 (0xA0D) - DSP2_ExecControl
4570 */
4571#define WM8958_DSP2_STOPC 0x0020 /* DSP2_STOPC */
4572#define WM8958_DSP2_STOPC_MASK 0x0020 /* DSP2_STOPC */
4573#define WM8958_DSP2_STOPC_SHIFT 5 /* DSP2_STOPC */
4574#define WM8958_DSP2_STOPC_WIDTH 1 /* DSP2_STOPC */
4575#define WM8958_DSP2_STOPS 0x0010 /* DSP2_STOPS */
4576#define WM8958_DSP2_STOPS_MASK 0x0010 /* DSP2_STOPS */
4577#define WM8958_DSP2_STOPS_SHIFT 4 /* DSP2_STOPS */
4578#define WM8958_DSP2_STOPS_WIDTH 1 /* DSP2_STOPS */
4579#define WM8958_DSP2_STOPI 0x0008 /* DSP2_STOPI */
4580#define WM8958_DSP2_STOPI_MASK 0x0008 /* DSP2_STOPI */
4581#define WM8958_DSP2_STOPI_SHIFT 3 /* DSP2_STOPI */
4582#define WM8958_DSP2_STOPI_WIDTH 1 /* DSP2_STOPI */
4583#define WM8958_DSP2_STOP 0x0004 /* DSP2_STOP */
4584#define WM8958_DSP2_STOP_MASK 0x0004 /* DSP2_STOP */
4585#define WM8958_DSP2_STOP_SHIFT 2 /* DSP2_STOP */
4586#define WM8958_DSP2_STOP_WIDTH 1 /* DSP2_STOP */
4587#define WM8958_DSP2_RUNR 0x0002 /* DSP2_RUNR */
4588#define WM8958_DSP2_RUNR_MASK 0x0002 /* DSP2_RUNR */
4589#define WM8958_DSP2_RUNR_SHIFT 1 /* DSP2_RUNR */
4590#define WM8958_DSP2_RUNR_WIDTH 1 /* DSP2_RUNR */
4591#define WM8958_DSP2_RUN 0x0001 /* DSP2_RUN */
4592#define WM8958_DSP2_RUN_MASK 0x0001 /* DSP2_RUN */
4593#define WM8958_DSP2_RUN_SHIFT 0 /* DSP2_RUN */
4594#define WM8958_DSP2_RUN_WIDTH 1 /* DSP2_RUN */
4595
4292#endif 4596#endif
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
new file mode 100644
index 000000000000..dd8da342a991
--- /dev/null
+++ b/include/linux/micrel_phy.h
@@ -0,0 +1,16 @@
1#ifndef _MICREL_PHY_H
2#define _MICREL_PHY_H
3
4#define MICREL_PHY_ID_MASK 0x00fffff0
5
6#define PHY_ID_KSZ9021 0x00221611
7#define PHY_ID_KS8737 0x00221720
8#define PHY_ID_KS8041 0x00221510
9#define PHY_ID_KS8051 0x00221550
10/* both for ks8001 Rev. A/B, and for ks8721 Rev 3. */
11#define PHY_ID_KS8001 0x0022161A
12
13/* struct phy_device dev_flags definitions */
14#define MICREL_PHY_50MHZ_CLK 0x00000001
15
16#endif /* _MICREL_PHY_H */
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 7238231b8dd4..e39aeecfe9a2 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -13,7 +13,11 @@ extern void putback_lru_pages(struct list_head *l);
13extern int migrate_page(struct address_space *, 13extern int migrate_page(struct address_space *,
14 struct page *, struct page *); 14 struct page *, struct page *);
15extern int migrate_pages(struct list_head *l, new_page_t x, 15extern int migrate_pages(struct list_head *l, new_page_t x,
16 unsigned long private, int offlining); 16 unsigned long private, bool offlining,
17 bool sync);
18extern int migrate_huge_pages(struct list_head *l, new_page_t x,
19 unsigned long private, bool offlining,
20 bool sync);
17 21
18extern int fail_migrate_page(struct address_space *, 22extern int fail_migrate_page(struct address_space *,
19 struct page *, struct page *); 23 struct page *, struct page *);
@@ -23,12 +27,19 @@ extern int migrate_prep_local(void);
23extern int migrate_vmas(struct mm_struct *mm, 27extern int migrate_vmas(struct mm_struct *mm,
24 const nodemask_t *from, const nodemask_t *to, 28 const nodemask_t *from, const nodemask_t *to,
25 unsigned long flags); 29 unsigned long flags);
30extern void migrate_page_copy(struct page *newpage, struct page *page);
31extern int migrate_huge_page_move_mapping(struct address_space *mapping,
32 struct page *newpage, struct page *page);
26#else 33#else
27#define PAGE_MIGRATION 0 34#define PAGE_MIGRATION 0
28 35
29static inline void putback_lru_pages(struct list_head *l) {} 36static inline void putback_lru_pages(struct list_head *l) {}
30static inline int migrate_pages(struct list_head *l, new_page_t x, 37static inline int migrate_pages(struct list_head *l, new_page_t x,
31 unsigned long private, int offlining) { return -ENOSYS; } 38 unsigned long private, bool offlining,
39 bool sync) { return -ENOSYS; }
40static inline int migrate_huge_pages(struct list_head *l, new_page_t x,
41 unsigned long private, bool offlining,
42 bool sync) { return -ENOSYS; }
32 43
33static inline int migrate_prep(void) { return -ENOSYS; } 44static inline int migrate_prep(void) { return -ENOSYS; }
34static inline int migrate_prep_local(void) { return -ENOSYS; } 45static inline int migrate_prep_local(void) { return -ENOSYS; }
@@ -40,6 +51,15 @@ static inline int migrate_vmas(struct mm_struct *mm,
40 return -ENOSYS; 51 return -ENOSYS;
41} 52}
42 53
54static inline void migrate_page_copy(struct page *newpage,
55 struct page *page) {}
56
57static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
58 struct page *newpage, struct page *page)
59{
60 return -ENOSYS;
61}
62
43/* Possible settings for the migrate_page() method in address_operations */ 63/* Possible settings for the migrate_page() method in address_operations */
44#define migrate_page NULL 64#define migrate_page NULL
45#define fail_migrate_page NULL 65#define fail_migrate_page NULL
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h
index 0f82293a82ed..9a18667c13cc 100644
--- a/include/linux/mlx4/cmd.h
+++ b/include/linux/mlx4/cmd.h
@@ -56,7 +56,9 @@ enum {
56 MLX4_CMD_QUERY_HCA = 0xb, 56 MLX4_CMD_QUERY_HCA = 0xb,
57 MLX4_CMD_QUERY_PORT = 0x43, 57 MLX4_CMD_QUERY_PORT = 0x43,
58 MLX4_CMD_SENSE_PORT = 0x4d, 58 MLX4_CMD_SENSE_PORT = 0x4d,
59 MLX4_CMD_HW_HEALTH_CHECK = 0x50,
59 MLX4_CMD_SET_PORT = 0xc, 60 MLX4_CMD_SET_PORT = 0xc,
61 MLX4_CMD_SET_NODE = 0x5a,
60 MLX4_CMD_ACCESS_DDR = 0x2e, 62 MLX4_CMD_ACCESS_DDR = 0x2e,
61 MLX4_CMD_MAP_ICM = 0xffa, 63 MLX4_CMD_MAP_ICM = 0xffa,
62 MLX4_CMD_UNMAP_ICM = 0xff9, 64 MLX4_CMD_UNMAP_ICM = 0xff9,
@@ -140,6 +142,7 @@ enum {
140 MLX4_SET_PORT_MAC_TABLE = 0x2, 142 MLX4_SET_PORT_MAC_TABLE = 0x2,
141 MLX4_SET_PORT_VLAN_TABLE = 0x3, 143 MLX4_SET_PORT_VLAN_TABLE = 0x3,
142 MLX4_SET_PORT_PRIO_MAP = 0x4, 144 MLX4_SET_PORT_PRIO_MAP = 0x4,
145 MLX4_SET_PORT_GID_TABLE = 0x5,
143}; 146};
144 147
145struct mlx4_dev; 148struct mlx4_dev;
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 7a7f9c1e679a..8985768e2c0d 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -39,6 +39,11 @@
39 39
40#include <asm/atomic.h> 40#include <asm/atomic.h>
41 41
42#define MAX_MSIX_P_PORT 17
43#define MAX_MSIX 64
44#define MSIX_LEGACY_SZ 4
45#define MIN_MSIX_P_PORT 5
46
42enum { 47enum {
43 MLX4_FLAG_MSI_X = 1 << 0, 48 MLX4_FLAG_MSI_X = 1 << 0,
44 MLX4_FLAG_OLD_PORT_CMDS = 1 << 1, 49 MLX4_FLAG_OLD_PORT_CMDS = 1 << 1,
@@ -67,7 +72,8 @@ enum {
67 MLX4_DEV_CAP_FLAG_ATOMIC = 1 << 18, 72 MLX4_DEV_CAP_FLAG_ATOMIC = 1 << 18,
68 MLX4_DEV_CAP_FLAG_RAW_MCAST = 1 << 19, 73 MLX4_DEV_CAP_FLAG_RAW_MCAST = 1 << 19,
69 MLX4_DEV_CAP_FLAG_UD_AV_PORT = 1 << 20, 74 MLX4_DEV_CAP_FLAG_UD_AV_PORT = 1 << 20,
70 MLX4_DEV_CAP_FLAG_UD_MCAST = 1 << 21 75 MLX4_DEV_CAP_FLAG_UD_MCAST = 1 << 21,
76 MLX4_DEV_CAP_FLAG_IBOE = 1 << 30
71}; 77};
72 78
73enum { 79enum {
@@ -143,6 +149,13 @@ enum {
143 MLX4_STAT_RATE_OFFSET = 5 149 MLX4_STAT_RATE_OFFSET = 5
144}; 150};
145 151
152enum mlx4_protocol {
153 MLX4_PROT_IB_IPV6 = 0,
154 MLX4_PROT_ETH,
155 MLX4_PROT_IB_IPV4,
156 MLX4_PROT_FCOE
157};
158
146enum { 159enum {
147 MLX4_MTT_FLAG_PRESENT = 1 160 MLX4_MTT_FLAG_PRESENT = 1
148}; 161};
@@ -167,10 +180,20 @@ enum mlx4_special_vlan_idx {
167 MLX4_VLAN_REGULAR 180 MLX4_VLAN_REGULAR
168}; 181};
169 182
183enum mlx4_steer_type {
184 MLX4_MC_STEER = 0,
185 MLX4_UC_STEER,
186 MLX4_NUM_STEERS
187};
188
170enum { 189enum {
171 MLX4_NUM_FEXCH = 64 * 1024, 190 MLX4_NUM_FEXCH = 64 * 1024,
172}; 191};
173 192
193enum {
194 MLX4_MAX_FAST_REG_PAGES = 511,
195};
196
174static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor) 197static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
175{ 198{
176 return (major << 32) | (minor << 16) | subminor; 199 return (major << 32) | (minor << 16) | subminor;
@@ -186,6 +209,10 @@ struct mlx4_caps {
186 int eth_mtu_cap[MLX4_MAX_PORTS + 1]; 209 int eth_mtu_cap[MLX4_MAX_PORTS + 1];
187 int gid_table_len[MLX4_MAX_PORTS + 1]; 210 int gid_table_len[MLX4_MAX_PORTS + 1];
188 int pkey_table_len[MLX4_MAX_PORTS + 1]; 211 int pkey_table_len[MLX4_MAX_PORTS + 1];
212 int trans_type[MLX4_MAX_PORTS + 1];
213 int vendor_oui[MLX4_MAX_PORTS + 1];
214 int wavelength[MLX4_MAX_PORTS + 1];
215 u64 trans_code[MLX4_MAX_PORTS + 1];
189 int local_ca_ack_delay; 216 int local_ca_ack_delay;
190 int num_uars; 217 int num_uars;
191 int bf_reg_size; 218 int bf_reg_size;
@@ -209,6 +236,7 @@ struct mlx4_caps {
209 int num_eqs; 236 int num_eqs;
210 int reserved_eqs; 237 int reserved_eqs;
211 int num_comp_vectors; 238 int num_comp_vectors;
239 int comp_pool;
212 int num_mpts; 240 int num_mpts;
213 int num_mtt_segs; 241 int num_mtt_segs;
214 int mtts_per_seg; 242 int mtts_per_seg;
@@ -229,6 +257,11 @@ struct mlx4_caps {
229 u32 bmme_flags; 257 u32 bmme_flags;
230 u32 reserved_lkey; 258 u32 reserved_lkey;
231 u16 stat_rate_support; 259 u16 stat_rate_support;
260 int udp_rss;
261 int loopback_support;
262 int vep_uc_steering;
263 int vep_mc_steering;
264 int wol;
232 u8 port_width_cap[MLX4_MAX_PORTS + 1]; 265 u8 port_width_cap[MLX4_MAX_PORTS + 1];
233 int max_gso_sz; 266 int max_gso_sz;
234 int reserved_qps_cnt[MLX4_NUM_QP_REGION]; 267 int reserved_qps_cnt[MLX4_NUM_QP_REGION];
@@ -318,6 +351,17 @@ struct mlx4_fmr {
318struct mlx4_uar { 351struct mlx4_uar {
319 unsigned long pfn; 352 unsigned long pfn;
320 int index; 353 int index;
354 struct list_head bf_list;
355 unsigned free_bf_bmap;
356 void __iomem *map;
357 void __iomem *bf_map;
358};
359
360struct mlx4_bf {
361 unsigned long offset;
362 int buf_size;
363 struct mlx4_uar *uar;
364 void __iomem *reg;
321}; 365};
322 366
323struct mlx4_cq { 367struct mlx4_cq {
@@ -373,12 +417,33 @@ struct mlx4_av {
373 u8 dgid[16]; 417 u8 dgid[16];
374}; 418};
375 419
420struct mlx4_eth_av {
421 __be32 port_pd;
422 u8 reserved1;
423 u8 smac_idx;
424 u16 reserved2;
425 u8 reserved3;
426 u8 gid_index;
427 u8 stat_rate;
428 u8 hop_limit;
429 __be32 sl_tclass_flowlabel;
430 u8 dgid[16];
431 u32 reserved4[2];
432 __be16 vlan;
433 u8 mac[6];
434};
435
436union mlx4_ext_av {
437 struct mlx4_av ib;
438 struct mlx4_eth_av eth;
439};
440
376struct mlx4_dev { 441struct mlx4_dev {
377 struct pci_dev *pdev; 442 struct pci_dev *pdev;
378 unsigned long flags; 443 unsigned long flags;
379 struct mlx4_caps caps; 444 struct mlx4_caps caps;
380 struct radix_tree_root qp_table_tree; 445 struct radix_tree_root qp_table_tree;
381 u32 rev_id; 446 u8 rev_id;
382 char board_id[MLX4_BOARD_ID_LEN]; 447 char board_id[MLX4_BOARD_ID_LEN];
383}; 448};
384 449
@@ -401,6 +466,12 @@ struct mlx4_init_port_param {
401 if (((type) == MLX4_PORT_TYPE_IB ? (dev)->caps.port_mask : \ 466 if (((type) == MLX4_PORT_TYPE_IB ? (dev)->caps.port_mask : \
402 ~(dev)->caps.port_mask) & 1 << ((port) - 1)) 467 ~(dev)->caps.port_mask) & 1 << ((port) - 1))
403 468
469#define mlx4_foreach_ib_transport_port(port, dev) \
470 for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \
471 if (((dev)->caps.port_mask & 1 << ((port) - 1)) || \
472 ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
473
474
404int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, 475int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
405 struct mlx4_buf *buf); 476 struct mlx4_buf *buf);
406void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); 477void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf);
@@ -418,6 +489,8 @@ void mlx4_pd_free(struct mlx4_dev *dev, u32 pdn);
418 489
419int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar); 490int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar);
420void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar); 491void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar);
492int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf);
493void mlx4_bf_free(struct mlx4_dev *dev, struct mlx4_bf *bf);
421 494
422int mlx4_mtt_init(struct mlx4_dev *dev, int npages, int page_shift, 495int mlx4_mtt_init(struct mlx4_dev *dev, int npages, int page_shift,
423 struct mlx4_mtt *mtt); 496 struct mlx4_mtt *mtt);
@@ -462,12 +535,20 @@ int mlx4_INIT_PORT(struct mlx4_dev *dev, int port);
462int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port); 535int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
463 536
464int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], 537int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
465 int block_mcast_loopback); 538 int block_mcast_loopback, enum mlx4_protocol protocol);
466int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]); 539int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
467 540 enum mlx4_protocol protocol);
468int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index); 541int mlx4_multicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
469void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int index); 542int mlx4_multicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
470 543int mlx4_unicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
544int mlx4_unicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
545int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode);
546
547int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *qpn, u8 wrap);
548void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int qpn);
549int mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac, u8 wrap);
550
551int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
471int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); 552int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
472void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index); 553void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index);
473 554
@@ -480,5 +561,11 @@ void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr,
480 u32 *lkey, u32 *rkey); 561 u32 *lkey, u32 *rkey);
481int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr); 562int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr);
482int mlx4_SYNC_TPT(struct mlx4_dev *dev); 563int mlx4_SYNC_TPT(struct mlx4_dev *dev);
564int mlx4_test_interrupts(struct mlx4_dev *dev);
565int mlx4_assign_eq(struct mlx4_dev *dev, char* name , int* vector);
566void mlx4_release_eq(struct mlx4_dev *dev, int vec);
567
568int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port);
569int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port);
483 570
484#endif /* MLX4_DEVICE_H */ 571#endif /* MLX4_DEVICE_H */
diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h
index 53c5fdb6eac4..e1eebf78caba 100644
--- a/include/linux/mlx4/driver.h
+++ b/include/linux/mlx4/driver.h
@@ -34,6 +34,7 @@
34#define MLX4_DRIVER_H 34#define MLX4_DRIVER_H
35 35
36#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/mlx4/device.h>
37 38
38struct mlx4_dev; 39struct mlx4_dev;
39 40
@@ -49,10 +50,14 @@ struct mlx4_interface {
49 void (*remove)(struct mlx4_dev *dev, void *context); 50 void (*remove)(struct mlx4_dev *dev, void *context);
50 void (*event) (struct mlx4_dev *dev, void *context, 51 void (*event) (struct mlx4_dev *dev, void *context,
51 enum mlx4_dev_event event, int port); 52 enum mlx4_dev_event event, int port);
53 void * (*get_dev)(struct mlx4_dev *dev, void *context, u8 port);
52 struct list_head list; 54 struct list_head list;
55 enum mlx4_protocol protocol;
53}; 56};
54 57
55int mlx4_register_interface(struct mlx4_interface *intf); 58int mlx4_register_interface(struct mlx4_interface *intf);
56void mlx4_unregister_interface(struct mlx4_interface *intf); 59void mlx4_unregister_interface(struct mlx4_interface *intf);
57 60
61void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port);
62
58#endif /* MLX4_DRIVER_H */ 63#endif /* MLX4_DRIVER_H */
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index 7abe64326f72..9e9eb21056ca 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -109,10 +109,11 @@ struct mlx4_qp_path {
109 __be32 tclass_flowlabel; 109 __be32 tclass_flowlabel;
110 u8 rgid[16]; 110 u8 rgid[16];
111 u8 sched_queue; 111 u8 sched_queue;
112 u8 snooper_flags; 112 u8 vlan_index;
113 u8 reserved3[2]; 113 u8 reserved3[2];
114 u8 counter_index; 114 u8 counter_index;
115 u8 reserved4[7]; 115 u8 reserved4;
116 u8 dmac[6];
116}; 117};
117 118
118struct mlx4_qp_context { 119struct mlx4_qp_context {
@@ -166,6 +167,7 @@ enum {
166 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5, 167 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5,
167 MLX4_WQE_CTRL_INS_VLAN = 1 << 6, 168 MLX4_WQE_CTRL_INS_VLAN = 1 << 6,
168 MLX4_WQE_CTRL_STRONG_ORDER = 1 << 7, 169 MLX4_WQE_CTRL_STRONG_ORDER = 1 << 7,
170 MLX4_WQE_CTRL_FORCE_LOOPBACK = 1 << 0,
169}; 171};
170 172
171struct mlx4_wqe_ctrl_seg { 173struct mlx4_wqe_ctrl_seg {
@@ -219,7 +221,8 @@ struct mlx4_wqe_datagram_seg {
219 __be32 av[8]; 221 __be32 av[8];
220 __be32 dqpn; 222 __be32 dqpn;
221 __be32 qkey; 223 __be32 qkey;
222 __be32 reservd[2]; 224 __be16 vlan;
225 u8 mac[6];
223}; 226};
224 227
225struct mlx4_wqe_lso_seg { 228struct mlx4_wqe_lso_seg {
@@ -300,6 +303,7 @@ struct mlx4_wqe_data_seg {
300 303
301enum { 304enum {
302 MLX4_INLINE_ALIGN = 64, 305 MLX4_INLINE_ALIGN = 64,
306 MLX4_INLINE_SEG = 1 << 31,
303}; 307};
304 308
305struct mlx4_wqe_inline_seg { 309struct mlx4_wqe_inline_seg {
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 74949fbef8c6..9670f71d7be9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -14,6 +14,7 @@
14#include <linux/mm_types.h> 14#include <linux/mm_types.h>
15#include <linux/range.h> 15#include <linux/range.h>
16#include <linux/pfn.h> 16#include <linux/pfn.h>
17#include <linux/bit_spinlock.h>
17 18
18struct mempolicy; 19struct mempolicy;
19struct anon_vma; 20struct anon_vma;
@@ -82,6 +83,7 @@ extern unsigned int kobjsize(const void *objp);
82#define VM_GROWSUP 0x00000200 83#define VM_GROWSUP 0x00000200
83#else 84#else
84#define VM_GROWSUP 0x00000000 85#define VM_GROWSUP 0x00000000
86#define VM_NOHUGEPAGE 0x00000200 /* MADV_NOHUGEPAGE marked this vma */
85#endif 87#endif
86#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */ 88#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */
87#define VM_DENYWRITE 0x00000800 /* ETXTBSY on write attempts.. */ 89#define VM_DENYWRITE 0x00000800 /* ETXTBSY on write attempts.. */
@@ -101,7 +103,11 @@ extern unsigned int kobjsize(const void *objp);
101#define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */ 103#define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
102#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */ 104#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
103#define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */ 105#define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
106#ifndef CONFIG_TRANSPARENT_HUGEPAGE
104#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */ 107#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */
108#else
109#define VM_HUGEPAGE 0x01000000 /* MADV_HUGEPAGE marked this vma */
110#endif
105#define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */ 111#define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */
106#define VM_ALWAYSDUMP 0x04000000 /* Always include in core dumps */ 112#define VM_ALWAYSDUMP 0x04000000 /* Always include in core dumps */
107 113
@@ -131,7 +137,8 @@ extern unsigned int kobjsize(const void *objp);
131#define VM_RandomReadHint(v) ((v)->vm_flags & VM_RAND_READ) 137#define VM_RandomReadHint(v) ((v)->vm_flags & VM_RAND_READ)
132 138
133/* 139/*
134 * special vmas that are non-mergable, non-mlock()able 140 * Special vmas that are non-mergable, non-mlock()able.
141 * Note: mm/huge_memory.c VM_NO_THP depends on this definition.
135 */ 142 */
136#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP) 143#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP)
137 144
@@ -144,6 +151,9 @@ extern pgprot_t protection_map[16];
144#define FAULT_FLAG_WRITE 0x01 /* Fault was a write access */ 151#define FAULT_FLAG_WRITE 0x01 /* Fault was a write access */
145#define FAULT_FLAG_NONLINEAR 0x02 /* Fault was via a nonlinear mapping */ 152#define FAULT_FLAG_NONLINEAR 0x02 /* Fault was via a nonlinear mapping */
146#define FAULT_FLAG_MKWRITE 0x04 /* Fault was mkwrite of existing pte */ 153#define FAULT_FLAG_MKWRITE 0x04 /* Fault was mkwrite of existing pte */
154#define FAULT_FLAG_ALLOW_RETRY 0x08 /* Retry fault if blocking */
155#define FAULT_FLAG_RETRY_NOWAIT 0x10 /* Don't drop mmap_sem and wait when retrying */
156#define FAULT_FLAG_KILLABLE 0x20 /* The fault task is in SIGKILL killable region */
147 157
148/* 158/*
149 * This interface is used by x86 PAT code to identify a pfn mapping that is 159 * This interface is used by x86 PAT code to identify a pfn mapping that is
@@ -155,12 +165,12 @@ extern pgprot_t protection_map[16];
155 */ 165 */
156static inline int is_linear_pfn_mapping(struct vm_area_struct *vma) 166static inline int is_linear_pfn_mapping(struct vm_area_struct *vma)
157{ 167{
158 return (vma->vm_flags & VM_PFN_AT_MMAP); 168 return !!(vma->vm_flags & VM_PFN_AT_MMAP);
159} 169}
160 170
161static inline int is_pfn_mapping(struct vm_area_struct *vma) 171static inline int is_pfn_mapping(struct vm_area_struct *vma)
162{ 172{
163 return (vma->vm_flags & VM_PFNMAP); 173 return !!(vma->vm_flags & VM_PFNMAP);
164} 174}
165 175
166/* 176/*
@@ -241,6 +251,7 @@ struct inode;
241 * files which need it (119 of them) 251 * files which need it (119 of them)
242 */ 252 */
243#include <linux/page-flags.h> 253#include <linux/page-flags.h>
254#include <linux/huge_mm.h>
244 255
245/* 256/*
246 * Methods to modify the page usage count. 257 * Methods to modify the page usage count.
@@ -304,6 +315,39 @@ static inline int is_vmalloc_or_module_addr(const void *x)
304} 315}
305#endif 316#endif
306 317
318static inline void compound_lock(struct page *page)
319{
320#ifdef CONFIG_TRANSPARENT_HUGEPAGE
321 bit_spin_lock(PG_compound_lock, &page->flags);
322#endif
323}
324
325static inline void compound_unlock(struct page *page)
326{
327#ifdef CONFIG_TRANSPARENT_HUGEPAGE
328 bit_spin_unlock(PG_compound_lock, &page->flags);
329#endif
330}
331
332static inline unsigned long compound_lock_irqsave(struct page *page)
333{
334 unsigned long uninitialized_var(flags);
335#ifdef CONFIG_TRANSPARENT_HUGEPAGE
336 local_irq_save(flags);
337 compound_lock(page);
338#endif
339 return flags;
340}
341
342static inline void compound_unlock_irqrestore(struct page *page,
343 unsigned long flags)
344{
345#ifdef CONFIG_TRANSPARENT_HUGEPAGE
346 compound_unlock(page);
347 local_irq_restore(flags);
348#endif
349}
350
307static inline struct page *compound_head(struct page *page) 351static inline struct page *compound_head(struct page *page)
308{ 352{
309 if (unlikely(PageTail(page))) 353 if (unlikely(PageTail(page)))
@@ -318,9 +362,29 @@ static inline int page_count(struct page *page)
318 362
319static inline void get_page(struct page *page) 363static inline void get_page(struct page *page)
320{ 364{
321 page = compound_head(page); 365 /*
322 VM_BUG_ON(atomic_read(&page->_count) == 0); 366 * Getting a normal page or the head of a compound page
367 * requires to already have an elevated page->_count. Only if
368 * we're getting a tail page, the elevated page->_count is
369 * required only in the head page, so for tail pages the
370 * bugcheck only verifies that the page->_count isn't
371 * negative.
372 */
373 VM_BUG_ON(atomic_read(&page->_count) < !PageTail(page));
323 atomic_inc(&page->_count); 374 atomic_inc(&page->_count);
375 /*
376 * Getting a tail page will elevate both the head and tail
377 * page->_count(s).
378 */
379 if (unlikely(PageTail(page))) {
380 /*
381 * This is safe only because
382 * __split_huge_page_refcount can't run under
383 * get_page().
384 */
385 VM_BUG_ON(atomic_read(&page->first_page->_count) <= 0);
386 atomic_inc(&page->first_page->_count);
387 }
324} 388}
325 389
326static inline struct page *virt_to_head_page(const void *x) 390static inline struct page *virt_to_head_page(const void *x)
@@ -338,6 +402,34 @@ static inline void init_page_count(struct page *page)
338 atomic_set(&page->_count, 1); 402 atomic_set(&page->_count, 1);
339} 403}
340 404
405/*
406 * PageBuddy() indicate that the page is free and in the buddy system
407 * (see mm/page_alloc.c).
408 *
409 * PAGE_BUDDY_MAPCOUNT_VALUE must be <= -2 but better not too close to
410 * -2 so that an underflow of the page_mapcount() won't be mistaken
411 * for a genuine PAGE_BUDDY_MAPCOUNT_VALUE. -128 can be created very
412 * efficiently by most CPU architectures.
413 */
414#define PAGE_BUDDY_MAPCOUNT_VALUE (-128)
415
416static inline int PageBuddy(struct page *page)
417{
418 return atomic_read(&page->_mapcount) == PAGE_BUDDY_MAPCOUNT_VALUE;
419}
420
421static inline void __SetPageBuddy(struct page *page)
422{
423 VM_BUG_ON(atomic_read(&page->_mapcount) != -1);
424 atomic_set(&page->_mapcount, PAGE_BUDDY_MAPCOUNT_VALUE);
425}
426
427static inline void __ClearPageBuddy(struct page *page)
428{
429 VM_BUG_ON(!PageBuddy(page));
430 atomic_set(&page->_mapcount, -1);
431}
432
341void put_page(struct page *page); 433void put_page(struct page *page);
342void put_pages_list(struct list_head *pages); 434void put_pages_list(struct list_head *pages);
343 435
@@ -369,11 +461,40 @@ static inline int compound_order(struct page *page)
369 return (unsigned long)page[1].lru.prev; 461 return (unsigned long)page[1].lru.prev;
370} 462}
371 463
464static inline int compound_trans_order(struct page *page)
465{
466 int order;
467 unsigned long flags;
468
469 if (!PageHead(page))
470 return 0;
471
472 flags = compound_lock_irqsave(page);
473 order = compound_order(page);
474 compound_unlock_irqrestore(page, flags);
475 return order;
476}
477
372static inline void set_compound_order(struct page *page, unsigned long order) 478static inline void set_compound_order(struct page *page, unsigned long order)
373{ 479{
374 page[1].lru.prev = (void *)order; 480 page[1].lru.prev = (void *)order;
375} 481}
376 482
483#ifdef CONFIG_MMU
484/*
485 * Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when
486 * servicing faults for write access. In the normal case, do always want
487 * pte_mkwrite. But get_user_pages can cause write faults for mappings
488 * that do not have writing enabled, when used by access_process_vm.
489 */
490static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
491{
492 if (likely(vma->vm_flags & VM_WRITE))
493 pte = pte_mkwrite(pte);
494 return pte;
495}
496#endif
497
377/* 498/*
378 * Multiple processes may "see" the same page. E.g. for untouched 499 * Multiple processes may "see" the same page. E.g. for untouched
379 * mappings of /dev/null, all processes see the same page full of 500 * mappings of /dev/null, all processes see the same page full of
@@ -484,12 +605,8 @@ static inline void set_compound_order(struct page *page, unsigned long order)
484#define NODE_NOT_IN_PAGE_FLAGS 605#define NODE_NOT_IN_PAGE_FLAGS
485#endif 606#endif
486 607
487#ifndef PFN_SECTION_SHIFT
488#define PFN_SECTION_SHIFT 0
489#endif
490
491/* 608/*
492 * Define the bit shifts to access each section. For non-existant 609 * Define the bit shifts to access each section. For non-existent
493 * sections we define the shift as 0; that plus a 0 mask ensures 610 * sections we define the shift as 0; that plus a 0 mask ensures
494 * the compiler will optimise away reference to them. 611 * the compiler will optimise away reference to them.
495 */ 612 */
@@ -497,8 +614,8 @@ static inline void set_compound_order(struct page *page, unsigned long order)
497#define NODES_PGSHIFT (NODES_PGOFF * (NODES_WIDTH != 0)) 614#define NODES_PGSHIFT (NODES_PGOFF * (NODES_WIDTH != 0))
498#define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_WIDTH != 0)) 615#define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_WIDTH != 0))
499 616
500/* NODE:ZONE or SECTION:ZONE is used to ID a zone for the buddy allcator */ 617/* NODE:ZONE or SECTION:ZONE is used to ID a zone for the buddy allocator */
501#ifdef NODE_NOT_IN_PAGEFLAGS 618#ifdef NODE_NOT_IN_PAGE_FLAGS
502#define ZONEID_SHIFT (SECTIONS_SHIFT + ZONES_SHIFT) 619#define ZONEID_SHIFT (SECTIONS_SHIFT + ZONES_SHIFT)
503#define ZONEID_PGOFF ((SECTIONS_PGOFF < ZONES_PGOFF)? \ 620#define ZONEID_PGOFF ((SECTIONS_PGOFF < ZONES_PGOFF)? \
504 SECTIONS_PGOFF : ZONES_PGOFF) 621 SECTIONS_PGOFF : ZONES_PGOFF)
@@ -561,6 +678,12 @@ static inline struct zone *page_zone(struct page *page)
561} 678}
562 679
563#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) 680#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
681static inline void set_page_section(struct page *page, unsigned long section)
682{
683 page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
684 page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;
685}
686
564static inline unsigned long page_to_section(struct page *page) 687static inline unsigned long page_to_section(struct page *page)
565{ 688{
566 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; 689 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
@@ -579,18 +702,14 @@ static inline void set_page_node(struct page *page, unsigned long node)
579 page->flags |= (node & NODES_MASK) << NODES_PGSHIFT; 702 page->flags |= (node & NODES_MASK) << NODES_PGSHIFT;
580} 703}
581 704
582static inline void set_page_section(struct page *page, unsigned long section)
583{
584 page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
585 page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;
586}
587
588static inline void set_page_links(struct page *page, enum zone_type zone, 705static inline void set_page_links(struct page *page, enum zone_type zone,
589 unsigned long node, unsigned long pfn) 706 unsigned long node, unsigned long pfn)
590{ 707{
591 set_page_zone(page, zone); 708 set_page_zone(page, zone);
592 set_page_node(page, node); 709 set_page_node(page, node);
710#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
593 set_page_section(page, pfn_to_section_nr(pfn)); 711 set_page_section(page, pfn_to_section_nr(pfn));
712#endif
594} 713}
595 714
596/* 715/*
@@ -656,7 +775,7 @@ static inline struct address_space *page_mapping(struct page *page)
656 VM_BUG_ON(PageSlab(page)); 775 VM_BUG_ON(PageSlab(page));
657 if (unlikely(PageSwapCache(page))) 776 if (unlikely(PageSwapCache(page)))
658 mapping = &swapper_space; 777 mapping = &swapper_space;
659 else if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON)) 778 else if ((unsigned long)mapping & PAGE_MAPPING_ANON)
660 mapping = NULL; 779 mapping = NULL;
661 return mapping; 780 return mapping;
662} 781}
@@ -718,12 +837,21 @@ static inline int page_mapped(struct page *page)
718#define VM_FAULT_SIGBUS 0x0002 837#define VM_FAULT_SIGBUS 0x0002
719#define VM_FAULT_MAJOR 0x0004 838#define VM_FAULT_MAJOR 0x0004
720#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ 839#define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */
721#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned page */ 840#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */
841#define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */
722 842
723#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ 843#define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */
724#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ 844#define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */
845#define VM_FAULT_RETRY 0x0400 /* ->fault blocked, must retry */
846
847#define VM_FAULT_HWPOISON_LARGE_MASK 0xf000 /* encodes hpage index for large hwpoison */
725 848
726#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_HWPOISON) 849#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_HWPOISON | \
850 VM_FAULT_HWPOISON_LARGE)
851
852/* Encode hstate index for a hwpoisoned large page */
853#define VM_FAULT_SET_HINDEX(x) ((x) << 12)
854#define VM_FAULT_GET_HINDEX(x) (((x) >> 12) & 0xf)
727 855
728/* 856/*
729 * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. 857 * Can be called by the pagefault handler when it gets a VM_FAULT_OOM.
@@ -732,20 +860,19 @@ extern void pagefault_out_of_memory(void);
732 860
733#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) 861#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
734 862
735extern void show_free_areas(void); 863/*
864 * Flags passed to show_mem() and show_free_areas() to suppress output in
865 * various contexts.
866 */
867#define SHOW_MEM_FILTER_NODES (0x0001u) /* filter disallowed nodes */
868
869extern void show_free_areas(unsigned int flags);
870extern bool skip_free_areas_node(unsigned int flags, int nid);
736 871
737int shmem_lock(struct file *file, int lock, struct user_struct *user); 872int shmem_lock(struct file *file, int lock, struct user_struct *user);
738struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags); 873struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);
739int shmem_zero_setup(struct vm_area_struct *); 874int shmem_zero_setup(struct vm_area_struct *);
740 875
741#ifndef CONFIG_MMU
742extern unsigned long shmem_get_unmapped_area(struct file *file,
743 unsigned long addr,
744 unsigned long len,
745 unsigned long pgoff,
746 unsigned long flags);
747#endif
748
749extern int can_do_mlock(void); 876extern int can_do_mlock(void);
750extern int user_shm_lock(size_t, struct user_struct *); 877extern int user_shm_lock(size_t, struct user_struct *);
751extern void user_shm_unlock(size_t, struct user_struct *); 878extern void user_shm_unlock(size_t, struct user_struct *);
@@ -758,8 +885,6 @@ struct zap_details {
758 struct address_space *check_mapping; /* Check page->mapping if set */ 885 struct address_space *check_mapping; /* Check page->mapping if set */
759 pgoff_t first_index; /* Lowest page->index to unmap */ 886 pgoff_t first_index; /* Lowest page->index to unmap */
760 pgoff_t last_index; /* Highest page->index to unmap */ 887 pgoff_t last_index; /* Highest page->index to unmap */
761 spinlock_t *i_mmap_lock; /* For unmap_mapping_range: */
762 unsigned long truncate_count; /* Compare vm_truncate_count */
763}; 888};
764 889
765struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, 890struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
@@ -769,7 +894,7 @@ int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
769 unsigned long size); 894 unsigned long size);
770unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address, 895unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
771 unsigned long size, struct zap_details *); 896 unsigned long size, struct zap_details *);
772unsigned long unmap_vmas(struct mmu_gather **tlb, 897unsigned long unmap_vmas(struct mmu_gather *tlb,
773 struct vm_area_struct *start_vma, unsigned long start_addr, 898 struct vm_area_struct *start_vma, unsigned long start_addr,
774 unsigned long end_addr, unsigned long *nr_accounted, 899 unsigned long end_addr, unsigned long *nr_accounted,
775 struct zap_details *); 900 struct zap_details *);
@@ -779,6 +904,9 @@ unsigned long unmap_vmas(struct mmu_gather **tlb,
779 * @pgd_entry: if set, called for each non-empty PGD (top-level) entry 904 * @pgd_entry: if set, called for each non-empty PGD (top-level) entry
780 * @pud_entry: if set, called for each non-empty PUD (2nd-level) entry 905 * @pud_entry: if set, called for each non-empty PUD (2nd-level) entry
781 * @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry 906 * @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry
907 * this handler is required to be able to handle
908 * pmd_trans_huge() pmds. They may simply choose to
909 * split_huge_page() instead of handling it explicitly.
782 * @pte_entry: if set, called for each non-empty PTE (4th-level) entry 910 * @pte_entry: if set, called for each non-empty PTE (4th-level) entry
783 * @pte_hole: if set, called for each hole at all levels 911 * @pte_hole: if set, called for each hole at all levels
784 * @hugetlb_entry: if set, called for each hugetlb entry 912 * @hugetlb_entry: if set, called for each hugetlb entry
@@ -844,7 +972,13 @@ static inline int handle_mm_fault(struct mm_struct *mm,
844 972
845extern int make_pages_present(unsigned long addr, unsigned long end); 973extern int make_pages_present(unsigned long addr, unsigned long end);
846extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); 974extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
975extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
976 void *buf, int len, int write);
847 977
978int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
979 unsigned long start, int len, unsigned int foll_flags,
980 struct page **pages, struct vm_area_struct **vmas,
981 int *nonblocking);
848int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 982int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
849 unsigned long start, int nr_pages, int write, int force, 983 unsigned long start, int nr_pages, int write, int force,
850 struct page **pages, struct vm_area_struct **vmas); 984 struct page **pages, struct vm_area_struct **vmas);
@@ -860,16 +994,39 @@ int __set_page_dirty_no_writeback(struct page *page);
860int redirty_page_for_writepage(struct writeback_control *wbc, 994int redirty_page_for_writepage(struct writeback_control *wbc,
861 struct page *page); 995 struct page *page);
862void account_page_dirtied(struct page *page, struct address_space *mapping); 996void account_page_dirtied(struct page *page, struct address_space *mapping);
997void account_page_writeback(struct page *page);
863int set_page_dirty(struct page *page); 998int set_page_dirty(struct page *page);
864int set_page_dirty_lock(struct page *page); 999int set_page_dirty_lock(struct page *page);
865int clear_page_dirty_for_io(struct page *page); 1000int clear_page_dirty_for_io(struct page *page);
866 1001
867/* Is the vma a continuation of the stack vma above it? */ 1002/* Is the vma a continuation of the stack vma above it? */
868static inline int vma_stack_continue(struct vm_area_struct *vma, unsigned long addr) 1003static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
869{ 1004{
870 return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN); 1005 return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
871} 1006}
872 1007
1008static inline int stack_guard_page_start(struct vm_area_struct *vma,
1009 unsigned long addr)
1010{
1011 return (vma->vm_flags & VM_GROWSDOWN) &&
1012 (vma->vm_start == addr) &&
1013 !vma_growsdown(vma->vm_prev, addr);
1014}
1015
1016/* Is the vma a continuation of the stack vma below it? */
1017static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
1018{
1019 return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
1020}
1021
1022static inline int stack_guard_page_end(struct vm_area_struct *vma,
1023 unsigned long addr)
1024{
1025 return (vma->vm_flags & VM_GROWSUP) &&
1026 (vma->vm_end == addr) &&
1027 !vma_growsup(vma->vm_next, addr);
1028}
1029
873extern unsigned long move_page_tables(struct vm_area_struct *vma, 1030extern unsigned long move_page_tables(struct vm_area_struct *vma,
874 unsigned long old_addr, struct vm_area_struct *new_vma, 1031 unsigned long old_addr, struct vm_area_struct *new_vma,
875 unsigned long new_addr, unsigned long len); 1032 unsigned long new_addr, unsigned long len);
@@ -888,65 +1045,35 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
888/* 1045/*
889 * per-process(per-mm_struct) statistics. 1046 * per-process(per-mm_struct) statistics.
890 */ 1047 */
891#if defined(SPLIT_RSS_COUNTING)
892/*
893 * The mm counters are not protected by its page_table_lock,
894 * so must be incremented atomically.
895 */
896static inline void set_mm_counter(struct mm_struct *mm, int member, long value) 1048static inline void set_mm_counter(struct mm_struct *mm, int member, long value)
897{ 1049{
898 atomic_long_set(&mm->rss_stat.count[member], value); 1050 atomic_long_set(&mm->rss_stat.count[member], value);
899} 1051}
900 1052
1053#if defined(SPLIT_RSS_COUNTING)
901unsigned long get_mm_counter(struct mm_struct *mm, int member); 1054unsigned long get_mm_counter(struct mm_struct *mm, int member);
902 1055#else
903static inline void add_mm_counter(struct mm_struct *mm, int member, long value)
904{
905 atomic_long_add(value, &mm->rss_stat.count[member]);
906}
907
908static inline void inc_mm_counter(struct mm_struct *mm, int member)
909{
910 atomic_long_inc(&mm->rss_stat.count[member]);
911}
912
913static inline void dec_mm_counter(struct mm_struct *mm, int member)
914{
915 atomic_long_dec(&mm->rss_stat.count[member]);
916}
917
918#else /* !USE_SPLIT_PTLOCKS */
919/*
920 * The mm counters are protected by its page_table_lock,
921 * so can be incremented directly.
922 */
923static inline void set_mm_counter(struct mm_struct *mm, int member, long value)
924{
925 mm->rss_stat.count[member] = value;
926}
927
928static inline unsigned long get_mm_counter(struct mm_struct *mm, int member) 1056static inline unsigned long get_mm_counter(struct mm_struct *mm, int member)
929{ 1057{
930 return mm->rss_stat.count[member]; 1058 return atomic_long_read(&mm->rss_stat.count[member]);
931} 1059}
1060#endif
932 1061
933static inline void add_mm_counter(struct mm_struct *mm, int member, long value) 1062static inline void add_mm_counter(struct mm_struct *mm, int member, long value)
934{ 1063{
935 mm->rss_stat.count[member] += value; 1064 atomic_long_add(value, &mm->rss_stat.count[member]);
936} 1065}
937 1066
938static inline void inc_mm_counter(struct mm_struct *mm, int member) 1067static inline void inc_mm_counter(struct mm_struct *mm, int member)
939{ 1068{
940 mm->rss_stat.count[member]++; 1069 atomic_long_inc(&mm->rss_stat.count[member]);
941} 1070}
942 1071
943static inline void dec_mm_counter(struct mm_struct *mm, int member) 1072static inline void dec_mm_counter(struct mm_struct *mm, int member)
944{ 1073{
945 mm->rss_stat.count[member]--; 1074 atomic_long_dec(&mm->rss_stat.count[member]);
946} 1075}
947 1076
948#endif /* !USE_SPLIT_PTLOCKS */
949
950static inline unsigned long get_mm_rss(struct mm_struct *mm) 1077static inline unsigned long get_mm_rss(struct mm_struct *mm)
951{ 1078{
952 return get_mm_counter(mm, MM_FILEPAGES) + 1079 return get_mm_counter(mm, MM_FILEPAGES) +
@@ -995,13 +1122,24 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
995#endif 1122#endif
996 1123
997/* 1124/*
1125 * This struct is used to pass information from page reclaim to the shrinkers.
1126 * We consolidate the values for easier extention later.
1127 */
1128struct shrink_control {
1129 gfp_t gfp_mask;
1130
1131 /* How many slab objects shrinker() should scan and try to reclaim */
1132 unsigned long nr_to_scan;
1133};
1134
1135/*
998 * A callback you can register to apply pressure to ageable caches. 1136 * A callback you can register to apply pressure to ageable caches.
999 * 1137 *
1000 * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should 1138 * 'sc' is passed shrink_control which includes a count 'nr_to_scan'
1001 * look through the least-recently-used 'nr_to_scan' entries and 1139 * and a 'gfpmask'. It should look through the least-recently-used
1002 * attempt to free them up. It should return the number of objects 1140 * 'nr_to_scan' entries and attempt to free them up. It should return
1003 * which remain in the cache. If it returns -1, it means it cannot do 1141 * the number of objects which remain in the cache. If it returns -1, it means
1004 * any scanning at this time (eg. there is a risk of deadlock). 1142 * it cannot do any scanning at this time (eg. there is a risk of deadlock).
1005 * 1143 *
1006 * The 'gfpmask' refers to the allocation we are currently trying to 1144 * The 'gfpmask' refers to the allocation we are currently trying to
1007 * fulfil. 1145 * fulfil.
@@ -1010,7 +1148,7 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
1010 * querying the cache size, so a fastpath for that case is appropriate. 1148 * querying the cache size, so a fastpath for that case is appropriate.
1011 */ 1149 */
1012struct shrinker { 1150struct shrinker {
1013 int (*shrink)(struct shrinker *, int nr_to_scan, gfp_t gfp_mask); 1151 int (*shrink)(struct shrinker *, struct shrink_control *sc);
1014 int seeks; /* seeks to recreate an obj */ 1152 int seeks; /* seeks to recreate an obj */
1015 1153
1016 /* These are for internal use */ 1154 /* These are for internal use */
@@ -1023,7 +1161,15 @@ extern void unregister_shrinker(struct shrinker *);
1023 1161
1024int vma_wants_writenotify(struct vm_area_struct *vma); 1162int vma_wants_writenotify(struct vm_area_struct *vma);
1025 1163
1026extern pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl); 1164extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
1165 spinlock_t **ptl);
1166static inline pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,
1167 spinlock_t **ptl)
1168{
1169 pte_t *ptep;
1170 __cond_lock(*ptl, ptep = __get_locked_pte(mm, addr, ptl));
1171 return ptep;
1172}
1027 1173
1028#ifdef __PAGETABLE_PUD_FOLDED 1174#ifdef __PAGETABLE_PUD_FOLDED
1029static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, 1175static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
@@ -1045,7 +1191,8 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
1045int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address); 1191int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
1046#endif 1192#endif
1047 1193
1048int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address); 1194int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
1195 pmd_t *pmd, unsigned long address);
1049int __pte_alloc_kernel(pmd_t *pmd, unsigned long address); 1196int __pte_alloc_kernel(pmd_t *pmd, unsigned long address);
1050 1197
1051/* 1198/*
@@ -1114,16 +1261,18 @@ static inline void pgtable_page_dtor(struct page *page)
1114 pte_unmap(pte); \ 1261 pte_unmap(pte); \
1115} while (0) 1262} while (0)
1116 1263
1117#define pte_alloc_map(mm, pmd, address) \ 1264#define pte_alloc_map(mm, vma, pmd, address) \
1118 ((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \ 1265 ((unlikely(pmd_none(*(pmd))) && __pte_alloc(mm, vma, \
1119 NULL: pte_offset_map(pmd, address)) 1266 pmd, address))? \
1267 NULL: pte_offset_map(pmd, address))
1120 1268
1121#define pte_alloc_map_lock(mm, pmd, address, ptlp) \ 1269#define pte_alloc_map_lock(mm, pmd, address, ptlp) \
1122 ((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \ 1270 ((unlikely(pmd_none(*(pmd))) && __pte_alloc(mm, NULL, \
1271 pmd, address))? \
1123 NULL: pte_offset_map_lock(mm, pmd, address, ptlp)) 1272 NULL: pte_offset_map_lock(mm, pmd, address, ptlp))
1124 1273
1125#define pte_alloc_kernel(pmd, address) \ 1274#define pte_alloc_kernel(pmd, address) \
1126 ((unlikely(!pmd_present(*(pmd))) && __pte_alloc_kernel(pmd, address))? \ 1275 ((unlikely(pmd_none(*(pmd))) && __pte_alloc_kernel(pmd, address))? \
1127 NULL: pte_offset_kernel(pmd, address)) 1276 NULL: pte_offset_kernel(pmd, address))
1128 1277
1129extern void free_area_init(unsigned long * zones_size); 1278extern void free_area_init(unsigned long * zones_size);
@@ -1175,8 +1324,8 @@ extern void free_bootmem_with_active_regions(int nid,
1175 unsigned long max_low_pfn); 1324 unsigned long max_low_pfn);
1176int add_from_early_node_map(struct range *range, int az, 1325int add_from_early_node_map(struct range *range, int az,
1177 int nr_range, int nid); 1326 int nr_range, int nid);
1178void *__alloc_memory_core_early(int nodeid, u64 size, u64 align, 1327u64 __init find_memory_core_early(int nid, u64 size, u64 align,
1179 u64 goal, u64 limit); 1328 u64 goal, u64 limit);
1180typedef int (*work_fn_t)(unsigned long, unsigned long, void *); 1329typedef int (*work_fn_t)(unsigned long, unsigned long, void *);
1181extern void work_with_active_regions(int nid, work_fn_t work_fn, void *data); 1330extern void work_with_active_regions(int nid, work_fn_t work_fn, void *data);
1182extern void sparse_memory_present_with_active_regions(int nid); 1331extern void sparse_memory_present_with_active_regions(int nid);
@@ -1201,14 +1350,16 @@ extern void set_dma_reserve(unsigned long new_dma_reserve);
1201extern void memmap_init_zone(unsigned long, int, unsigned long, 1350extern void memmap_init_zone(unsigned long, int, unsigned long,
1202 unsigned long, enum memmap_context); 1351 unsigned long, enum memmap_context);
1203extern void setup_per_zone_wmarks(void); 1352extern void setup_per_zone_wmarks(void);
1204extern void calculate_zone_inactive_ratio(struct zone *zone); 1353extern int __meminit init_per_zone_wmark_min(void);
1205extern void mem_init(void); 1354extern void mem_init(void);
1206extern void __init mmap_init(void); 1355extern void __init mmap_init(void);
1207extern void show_mem(void); 1356extern void show_mem(unsigned int flags);
1208extern void si_meminfo(struct sysinfo * val); 1357extern void si_meminfo(struct sysinfo * val);
1209extern void si_meminfo_node(struct sysinfo *val, int nid); 1358extern void si_meminfo_node(struct sysinfo *val, int nid);
1210extern int after_bootmem; 1359extern int after_bootmem;
1211 1360
1361extern void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...);
1362
1212extern void setup_per_cpu_pageset(void); 1363extern void setup_per_cpu_pageset(void);
1213 1364
1214extern void zone_pcp_update(struct zone *zone); 1365extern void zone_pcp_update(struct zone *zone);
@@ -1257,17 +1408,11 @@ extern void exit_mmap(struct mm_struct *);
1257extern int mm_take_all_locks(struct mm_struct *mm); 1408extern int mm_take_all_locks(struct mm_struct *mm);
1258extern void mm_drop_all_locks(struct mm_struct *mm); 1409extern void mm_drop_all_locks(struct mm_struct *mm);
1259 1410
1260#ifdef CONFIG_PROC_FS
1261/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */ 1411/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */
1262extern void added_exe_file_vma(struct mm_struct *mm); 1412extern void added_exe_file_vma(struct mm_struct *mm);
1263extern void removed_exe_file_vma(struct mm_struct *mm); 1413extern void removed_exe_file_vma(struct mm_struct *mm);
1264#else 1414extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
1265static inline void added_exe_file_vma(struct mm_struct *mm) 1415extern struct file *get_mm_exe_file(struct mm_struct *mm);
1266{}
1267
1268static inline void removed_exe_file_vma(struct mm_struct *mm)
1269{}
1270#endif /* CONFIG_PROC_FS */
1271 1416
1272extern int may_expand_vm(struct mm_struct *mm, unsigned long npages); 1417extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
1273extern int install_special_mapping(struct mm_struct *mm, 1418extern int install_special_mapping(struct mm_struct *mm,
@@ -1281,7 +1426,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1281 unsigned long flag, unsigned long pgoff); 1426 unsigned long flag, unsigned long pgoff);
1282extern unsigned long mmap_region(struct file *file, unsigned long addr, 1427extern unsigned long mmap_region(struct file *file, unsigned long addr,
1283 unsigned long len, unsigned long flags, 1428 unsigned long len, unsigned long flags,
1284 unsigned int vm_flags, unsigned long pgoff); 1429 vm_flags_t vm_flags, unsigned long pgoff);
1285 1430
1286static inline unsigned long do_mmap(struct file *file, unsigned long addr, 1431static inline unsigned long do_mmap(struct file *file, unsigned long addr,
1287 unsigned long len, unsigned long prot, 1432 unsigned long len, unsigned long prot,
@@ -1338,15 +1483,17 @@ unsigned long ra_submit(struct file_ra_state *ra,
1338 struct address_space *mapping, 1483 struct address_space *mapping,
1339 struct file *filp); 1484 struct file *filp);
1340 1485
1341/* Do stack extension */ 1486/* Generic expand stack which grows the stack according to GROWS{UP,DOWN} */
1342extern int expand_stack(struct vm_area_struct *vma, unsigned long address); 1487extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
1488
1489/* CONFIG_STACK_GROWSUP still needs to to grow downwards at some places */
1490extern int expand_downwards(struct vm_area_struct *vma,
1491 unsigned long address);
1343#if VM_GROWSUP 1492#if VM_GROWSUP
1344extern int expand_upwards(struct vm_area_struct *vma, unsigned long address); 1493extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
1345#else 1494#else
1346 #define expand_upwards(vma, address) do { } while (0) 1495 #define expand_upwards(vma, address) do { } while (0)
1347#endif 1496#endif
1348extern int expand_stack_downwards(struct vm_area_struct *vma,
1349 unsigned long address);
1350 1497
1351/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ 1498/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
1352extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr); 1499extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
@@ -1394,6 +1541,11 @@ struct page *follow_page(struct vm_area_struct *, unsigned long address,
1394#define FOLL_GET 0x04 /* do get_page on page */ 1541#define FOLL_GET 0x04 /* do get_page on page */
1395#define FOLL_DUMP 0x08 /* give error on hole if it would be zero */ 1542#define FOLL_DUMP 0x08 /* give error on hole if it would be zero */
1396#define FOLL_FORCE 0x10 /* get_user_pages read/write w/o permission */ 1543#define FOLL_FORCE 0x10 /* get_user_pages read/write w/o permission */
1544#define FOLL_NOWAIT 0x20 /* if a disk transfer is needed, start the IO
1545 * and return without waiting upon it */
1546#define FOLL_MLOCK 0x40 /* mark page as mlocked */
1547#define FOLL_SPLIT 0x80 /* don't return transhuge pages, split them */
1548#define FOLL_HWPOISON 0x100 /* check page is hwpoisoned */
1397 1549
1398typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr, 1550typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr,
1399 void *data); 1551 void *data);
@@ -1432,19 +1584,20 @@ static inline bool kernel_page_present(struct page *page) { return true; }
1432#endif /* CONFIG_HIBERNATION */ 1584#endif /* CONFIG_HIBERNATION */
1433#endif 1585#endif
1434 1586
1435extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk); 1587extern struct vm_area_struct *get_gate_vma(struct mm_struct *mm);
1436#ifdef __HAVE_ARCH_GATE_AREA 1588#ifdef __HAVE_ARCH_GATE_AREA
1437int in_gate_area_no_task(unsigned long addr); 1589int in_gate_area_no_mm(unsigned long addr);
1438int in_gate_area(struct task_struct *task, unsigned long addr); 1590int in_gate_area(struct mm_struct *mm, unsigned long addr);
1439#else 1591#else
1440int in_gate_area_no_task(unsigned long addr); 1592int in_gate_area_no_mm(unsigned long addr);
1441#define in_gate_area(task, addr) ({(void)task; in_gate_area_no_task(addr);}) 1593#define in_gate_area(mm, addr) ({(void)mm; in_gate_area_no_mm(addr);})
1442#endif /* __HAVE_ARCH_GATE_AREA */ 1594#endif /* __HAVE_ARCH_GATE_AREA */
1443 1595
1444int drop_caches_sysctl_handler(struct ctl_table *, int, 1596int drop_caches_sysctl_handler(struct ctl_table *, int,
1445 void __user *, size_t *, loff_t *); 1597 void __user *, size_t *, loff_t *);
1446unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, 1598unsigned long shrink_slab(struct shrink_control *shrink,
1447 unsigned long lru_pages); 1599 unsigned long nr_pages_scanned,
1600 unsigned long lru_pages);
1448 1601
1449#ifndef CONFIG_MMU 1602#ifndef CONFIG_MMU
1450#define randomize_va_space 0 1603#define randomize_va_space 0
@@ -1486,16 +1639,17 @@ extern int sysctl_memory_failure_recovery;
1486extern void shake_page(struct page *p, int access); 1639extern void shake_page(struct page *p, int access);
1487extern atomic_long_t mce_bad_pages; 1640extern atomic_long_t mce_bad_pages;
1488extern int soft_offline_page(struct page *page, int flags); 1641extern int soft_offline_page(struct page *page, int flags);
1489#ifdef CONFIG_MEMORY_FAILURE
1490int is_hwpoison_address(unsigned long addr);
1491#else
1492static inline int is_hwpoison_address(unsigned long addr)
1493{
1494 return 0;
1495}
1496#endif
1497 1642
1498extern void dump_page(struct page *page); 1643extern void dump_page(struct page *page);
1499 1644
1645#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
1646extern void clear_huge_page(struct page *page,
1647 unsigned long addr,
1648 unsigned int pages_per_huge_page);
1649extern void copy_user_huge_page(struct page *dst, struct page *src,
1650 unsigned long addr, struct vm_area_struct *vma,
1651 unsigned int pages_per_huge_page);
1652#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */
1653
1500#endif /* __KERNEL__ */ 1654#endif /* __KERNEL__ */
1501#endif /* _LINUX_MM_H */ 1655#endif /* _LINUX_MM_H */
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 8835b877b8db..8f7d24712dc1 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -1,6 +1,8 @@
1#ifndef LINUX_MM_INLINE_H 1#ifndef LINUX_MM_INLINE_H
2#define LINUX_MM_INLINE_H 2#define LINUX_MM_INLINE_H
3 3
4#include <linux/huge_mm.h>
5
4/** 6/**
5 * page_is_file_cache - should the page be on a file LRU or anon LRU? 7 * page_is_file_cache - should the page be on a file LRU or anon LRU?
6 * @page: the page to test 8 * @page: the page to test
@@ -20,18 +22,25 @@ static inline int page_is_file_cache(struct page *page)
20} 22}
21 23
22static inline void 24static inline void
23add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l) 25__add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l,
26 struct list_head *head)
24{ 27{
25 list_add(&page->lru, &zone->lru[l].list); 28 list_add(&page->lru, head);
26 __inc_zone_state(zone, NR_LRU_BASE + l); 29 __mod_zone_page_state(zone, NR_LRU_BASE + l, hpage_nr_pages(page));
27 mem_cgroup_add_lru_list(page, l); 30 mem_cgroup_add_lru_list(page, l);
28} 31}
29 32
30static inline void 33static inline void
34add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l)
35{
36 __add_page_to_lru_list(zone, page, l, &zone->lru[l].list);
37}
38
39static inline void
31del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l) 40del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
32{ 41{
33 list_del(&page->lru); 42 list_del(&page->lru);
34 __dec_zone_state(zone, NR_LRU_BASE + l); 43 __mod_zone_page_state(zone, NR_LRU_BASE + l, -hpage_nr_pages(page));
35 mem_cgroup_del_lru_list(page, l); 44 mem_cgroup_del_lru_list(page, l);
36} 45}
37 46
@@ -66,7 +75,7 @@ del_page_from_lru(struct zone *zone, struct page *page)
66 l += LRU_ACTIVE; 75 l += LRU_ACTIVE;
67 } 76 }
68 } 77 }
69 __dec_zone_state(zone, NR_LRU_BASE + l); 78 __mod_zone_page_state(zone, NR_LRU_BASE + l, -hpage_nr_pages(page));
70 mem_cgroup_del_lru_list(page, l); 79 mem_cgroup_del_lru_list(page, l);
71} 80}
72 81
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index ee7e258627f9..027935c86c68 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -102,6 +102,8 @@ struct page {
102#endif 102#endif
103}; 103};
104 104
105typedef unsigned long __nocast vm_flags_t;
106
105/* 107/*
106 * A region containing a mapping of a non-memory backed file under NOMMU 108 * A region containing a mapping of a non-memory backed file under NOMMU
107 * conditions. These are held in a global tree and are pinned by the VMAs that 109 * conditions. These are held in a global tree and are pinned by the VMAs that
@@ -109,7 +111,7 @@ struct page {
109 */ 111 */
110struct vm_region { 112struct vm_region {
111 struct rb_node vm_rb; /* link in global region tree */ 113 struct rb_node vm_rb; /* link in global region tree */
112 unsigned long vm_flags; /* VMA vm_flags */ 114 vm_flags_t vm_flags; /* VMA vm_flags */
113 unsigned long vm_start; /* start address of region */ 115 unsigned long vm_start; /* start address of region */
114 unsigned long vm_end; /* region initialised to here */ 116 unsigned long vm_end; /* region initialised to here */
115 unsigned long vm_top; /* region allocated to here */ 117 unsigned long vm_top; /* region allocated to here */
@@ -175,7 +177,6 @@ struct vm_area_struct {
175 units, *not* PAGE_CACHE_SIZE */ 177 units, *not* PAGE_CACHE_SIZE */
176 struct file * vm_file; /* File we map to (can be NULL). */ 178 struct file * vm_file; /* File we map to (can be NULL). */
177 void * vm_private_data; /* was vm_pte (shared mem) */ 179 void * vm_private_data; /* was vm_pte (shared mem) */
178 unsigned long vm_truncate_count;/* truncate_count or restart_addr */
179 180
180#ifndef CONFIG_MMU 181#ifndef CONFIG_MMU
181 struct vm_region *vm_region; /* NOMMU mapping region */ 182 struct vm_region *vm_region; /* NOMMU mapping region */
@@ -205,19 +206,16 @@ enum {
205 206
206#if USE_SPLIT_PTLOCKS && defined(CONFIG_MMU) 207#if USE_SPLIT_PTLOCKS && defined(CONFIG_MMU)
207#define SPLIT_RSS_COUNTING 208#define SPLIT_RSS_COUNTING
208struct mm_rss_stat {
209 atomic_long_t count[NR_MM_COUNTERS];
210};
211/* per-thread cached information, */ 209/* per-thread cached information, */
212struct task_rss_stat { 210struct task_rss_stat {
213 int events; /* for synchronization threshold */ 211 int events; /* for synchronization threshold */
214 int count[NR_MM_COUNTERS]; 212 int count[NR_MM_COUNTERS];
215}; 213};
216#else /* !USE_SPLIT_PTLOCKS */ 214#endif /* USE_SPLIT_PTLOCKS */
215
217struct mm_rss_stat { 216struct mm_rss_stat {
218 unsigned long count[NR_MM_COUNTERS]; 217 atomic_long_t count[NR_MM_COUNTERS];
219}; 218};
220#endif /* !USE_SPLIT_PTLOCKS */
221 219
222struct mm_struct { 220struct mm_struct {
223 struct vm_area_struct * mmap; /* list of VMAs */ 221 struct vm_area_struct * mmap; /* list of VMAs */
@@ -237,8 +235,9 @@ struct mm_struct {
237 atomic_t mm_users; /* How many users with user space? */ 235 atomic_t mm_users; /* How many users with user space? */
238 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */ 236 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
239 int map_count; /* number of VMAs */ 237 int map_count; /* number of VMAs */
240 struct rw_semaphore mmap_sem; 238
241 spinlock_t page_table_lock; /* Protects page tables and some counters */ 239 spinlock_t page_table_lock; /* Protects page tables and some counters */
240 struct rw_semaphore mmap_sem;
242 241
243 struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung 242 struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung
244 * together off init_mm.mmlist, and are protected 243 * together off init_mm.mmlist, and are protected
@@ -265,7 +264,7 @@ struct mm_struct {
265 264
266 struct linux_binfmt *binfmt; 265 struct linux_binfmt *binfmt;
267 266
268 cpumask_t cpu_vm_mask; 267 cpumask_var_t cpu_vm_mask_var;
269 268
270 /* Architecture-specific MM context */ 269 /* Architecture-specific MM context */
271 mm_context_t context; 270 mm_context_t context;
@@ -281,6 +280,9 @@ struct mm_struct {
281 unsigned int token_priority; 280 unsigned int token_priority;
282 unsigned int last_interval; 281 unsigned int last_interval;
283 282
283 /* How many tasks sharing this mm are OOM_DISABLE */
284 atomic_t oom_disable_count;
285
284 unsigned long flags; /* Must use atomic bitops to access the bits */ 286 unsigned long flags; /* Must use atomic bitops to access the bits */
285 287
286 struct core_state *core_state; /* coredumping support */ 288 struct core_state *core_state; /* coredumping support */
@@ -299,20 +301,34 @@ struct mm_struct {
299 * new_owner->mm == mm 301 * new_owner->mm == mm
300 * new_owner->alloc_lock is held 302 * new_owner->alloc_lock is held
301 */ 303 */
302 struct task_struct *owner; 304 struct task_struct __rcu *owner;
303#endif 305#endif
304 306
305#ifdef CONFIG_PROC_FS
306 /* store ref to file /proc/<pid>/exe symlink points to */ 307 /* store ref to file /proc/<pid>/exe symlink points to */
307 struct file *exe_file; 308 struct file *exe_file;
308 unsigned long num_exe_file_vmas; 309 unsigned long num_exe_file_vmas;
309#endif
310#ifdef CONFIG_MMU_NOTIFIER 310#ifdef CONFIG_MMU_NOTIFIER
311 struct mmu_notifier_mm *mmu_notifier_mm; 311 struct mmu_notifier_mm *mmu_notifier_mm;
312#endif 312#endif
313#ifdef CONFIG_TRANSPARENT_HUGEPAGE
314 pgtable_t pmd_huge_pte; /* protected by page_table_lock */
315#endif
316#ifdef CONFIG_CPUMASK_OFFSTACK
317 struct cpumask cpumask_allocation;
318#endif
313}; 319};
314 320
321static inline void mm_init_cpumask(struct mm_struct *mm)
322{
323#ifdef CONFIG_CPUMASK_OFFSTACK
324 mm->cpu_vm_mask_var = &mm->cpumask_allocation;
325#endif
326}
327
315/* Future-safe accessor for struct mm_struct's cpu_vm_mask. */ 328/* Future-safe accessor for struct mm_struct's cpu_vm_mask. */
316#define mm_cpumask(mm) (&(mm)->cpu_vm_mask) 329static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
330{
331 return mm->cpu_vm_mask_var;
332}
317 333
318#endif /* _LINUX_MM_TYPES_H */ 334#endif /* _LINUX_MM_TYPES_H */
diff --git a/include/linux/mmc/Kbuild b/include/linux/mmc/Kbuild
new file mode 100644
index 000000000000..1fb26448faa9
--- /dev/null
+++ b/include/linux/mmc/Kbuild
@@ -0,0 +1 @@
header-y += ioctl.h
diff --git a/include/linux/mmc/boot.h b/include/linux/mmc/boot.h
new file mode 100644
index 000000000000..39d787c229cb
--- /dev/null
+++ b/include/linux/mmc/boot.h
@@ -0,0 +1,7 @@
1#ifndef MMC_BOOT_H
2#define MMC_BOOT_H
3
4enum { MMC_PROGRESS_ENTER, MMC_PROGRESS_INIT,
5 MMC_PROGRESS_LOAD, MMC_PROGRESS_DONE };
6
7#endif
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 6b7525099e56..6ad43554ac05 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -11,6 +11,7 @@
11#define LINUX_MMC_CARD_H 11#define LINUX_MMC_CARD_H
12 12
13#include <linux/mmc/core.h> 13#include <linux/mmc/core.h>
14#include <linux/mod_devicetable.h>
14 15
15struct mmc_cid { 16struct mmc_cid {
16 unsigned int manfid; 17 unsigned int manfid;
@@ -29,6 +30,7 @@ struct mmc_csd {
29 unsigned short cmdclass; 30 unsigned short cmdclass;
30 unsigned short tacc_clks; 31 unsigned short tacc_clks;
31 unsigned int tacc_ns; 32 unsigned int tacc_ns;
33 unsigned int c_size;
32 unsigned int r2w_factor; 34 unsigned int r2w_factor;
33 unsigned int max_dtr; 35 unsigned int max_dtr;
34 unsigned int erase_size; /* In sectors */ 36 unsigned int erase_size; /* In sectors */
@@ -45,21 +47,47 @@ struct mmc_ext_csd {
45 u8 rev; 47 u8 rev;
46 u8 erase_group_def; 48 u8 erase_group_def;
47 u8 sec_feature_support; 49 u8 sec_feature_support;
50 u8 rel_sectors;
51 u8 rel_param;
52 u8 part_config;
53 unsigned int part_time; /* Units: ms */
48 unsigned int sa_timeout; /* Units: 100ns */ 54 unsigned int sa_timeout; /* Units: 100ns */
49 unsigned int hs_max_dtr; 55 unsigned int hs_max_dtr;
50 unsigned int sectors; 56 unsigned int sectors;
57 unsigned int card_type;
51 unsigned int hc_erase_size; /* In sectors */ 58 unsigned int hc_erase_size; /* In sectors */
52 unsigned int hc_erase_timeout; /* In milliseconds */ 59 unsigned int hc_erase_timeout; /* In milliseconds */
53 unsigned int sec_trim_mult; /* Secure trim multiplier */ 60 unsigned int sec_trim_mult; /* Secure trim multiplier */
54 unsigned int sec_erase_mult; /* Secure erase multiplier */ 61 unsigned int sec_erase_mult; /* Secure erase multiplier */
55 unsigned int trim_timeout; /* In milliseconds */ 62 unsigned int trim_timeout; /* In milliseconds */
63 bool enhanced_area_en; /* enable bit */
64 unsigned long long enhanced_area_offset; /* Units: Byte */
65 unsigned int enhanced_area_size; /* Units: KB */
66 unsigned int boot_size; /* in bytes */
67 u8 raw_partition_support; /* 160 */
68 u8 raw_erased_mem_count; /* 181 */
69 u8 raw_ext_csd_structure; /* 194 */
70 u8 raw_card_type; /* 196 */
71 u8 raw_s_a_timeout; /* 217 */
72 u8 raw_hc_erase_gap_size; /* 221 */
73 u8 raw_erase_timeout_mult; /* 223 */
74 u8 raw_hc_erase_grp_size; /* 224 */
75 u8 raw_sec_trim_mult; /* 229 */
76 u8 raw_sec_erase_mult; /* 230 */
77 u8 raw_sec_feature_support;/* 231 */
78 u8 raw_trim_mult; /* 232 */
79 u8 raw_sectors[4]; /* 212 - 4 bytes */
56}; 80};
57 81
58struct sd_scr { 82struct sd_scr {
59 unsigned char sda_vsn; 83 unsigned char sda_vsn;
84 unsigned char sda_spec3;
60 unsigned char bus_widths; 85 unsigned char bus_widths;
61#define SD_SCR_BUS_WIDTH_1 (1<<0) 86#define SD_SCR_BUS_WIDTH_1 (1<<0)
62#define SD_SCR_BUS_WIDTH_4 (1<<2) 87#define SD_SCR_BUS_WIDTH_4 (1<<2)
88 unsigned char cmds;
89#define SD_SCR_CMD20_SUPPORT (1<<0)
90#define SD_SCR_CMD23_SUPPORT (1<<1)
63}; 91};
64 92
65struct sd_ssr { 93struct sd_ssr {
@@ -70,6 +98,39 @@ struct sd_ssr {
70 98
71struct sd_switch_caps { 99struct sd_switch_caps {
72 unsigned int hs_max_dtr; 100 unsigned int hs_max_dtr;
101 unsigned int uhs_max_dtr;
102#define UHS_SDR104_MAX_DTR 208000000
103#define UHS_SDR50_MAX_DTR 100000000
104#define UHS_DDR50_MAX_DTR 50000000
105#define UHS_SDR25_MAX_DTR UHS_DDR50_MAX_DTR
106#define UHS_SDR12_MAX_DTR 25000000
107 unsigned int sd3_bus_mode;
108#define UHS_SDR12_BUS_SPEED 0
109#define UHS_SDR25_BUS_SPEED 1
110#define UHS_SDR50_BUS_SPEED 2
111#define UHS_SDR104_BUS_SPEED 3
112#define UHS_DDR50_BUS_SPEED 4
113
114#define SD_MODE_UHS_SDR12 (1 << UHS_SDR12_BUS_SPEED)
115#define SD_MODE_UHS_SDR25 (1 << UHS_SDR25_BUS_SPEED)
116#define SD_MODE_UHS_SDR50 (1 << UHS_SDR50_BUS_SPEED)
117#define SD_MODE_UHS_SDR104 (1 << UHS_SDR104_BUS_SPEED)
118#define SD_MODE_UHS_DDR50 (1 << UHS_DDR50_BUS_SPEED)
119 unsigned int sd3_drv_type;
120#define SD_DRIVER_TYPE_B 0x01
121#define SD_DRIVER_TYPE_A 0x02
122#define SD_DRIVER_TYPE_C 0x04
123#define SD_DRIVER_TYPE_D 0x08
124 unsigned int sd3_curr_limit;
125#define SD_SET_CURRENT_LIMIT_200 0
126#define SD_SET_CURRENT_LIMIT_400 1
127#define SD_SET_CURRENT_LIMIT_600 2
128#define SD_SET_CURRENT_LIMIT_800 3
129
130#define SD_MAX_CURRENT_200 (1 << SD_SET_CURRENT_LIMIT_200)
131#define SD_MAX_CURRENT_400 (1 << SD_SET_CURRENT_LIMIT_400)
132#define SD_MAX_CURRENT_600 (1 << SD_SET_CURRENT_LIMIT_600)
133#define SD_MAX_CURRENT_800 (1 << SD_SET_CURRENT_LIMIT_800)
73}; 134};
74 135
75struct sdio_cccr { 136struct sdio_cccr {
@@ -113,12 +174,20 @@ struct mmc_card {
113#define MMC_STATE_READONLY (1<<1) /* card is read-only */ 174#define MMC_STATE_READONLY (1<<1) /* card is read-only */
114#define MMC_STATE_HIGHSPEED (1<<2) /* card is in high speed mode */ 175#define MMC_STATE_HIGHSPEED (1<<2) /* card is in high speed mode */
115#define MMC_STATE_BLOCKADDR (1<<3) /* card uses block-addressing */ 176#define MMC_STATE_BLOCKADDR (1<<3) /* card uses block-addressing */
177#define MMC_STATE_HIGHSPEED_DDR (1<<4) /* card is in high speed mode */
178#define MMC_STATE_ULTRAHIGHSPEED (1<<5) /* card is in ultra high speed mode */
179#define MMC_CARD_SDXC (1<<6) /* card is SDXC */
116 unsigned int quirks; /* card quirks */ 180 unsigned int quirks; /* card quirks */
117#define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ 181#define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */
118#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ 182#define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */
119 /* for byte mode */ 183 /* for byte mode */
120#define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */ 184#define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */
121 /* (missing CIA registers) */ 185 /* (missing CIA registers) */
186#define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */
187#define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
188#define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
189#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
190#define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
122 191
123 unsigned int erase_size; /* erase size in sectors */ 192 unsigned int erase_size; /* erase size in sectors */
124 unsigned int erase_shift; /* if erase unit is power 2 */ 193 unsigned int erase_shift; /* if erase unit is power 2 */
@@ -139,13 +208,101 @@ struct mmc_card {
139 struct sdio_cccr cccr; /* common card info */ 208 struct sdio_cccr cccr; /* common card info */
140 struct sdio_cis cis; /* common tuple info */ 209 struct sdio_cis cis; /* common tuple info */
141 struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */ 210 struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */
211 struct sdio_func *sdio_single_irq; /* SDIO function when only one IRQ active */
142 unsigned num_info; /* number of info strings */ 212 unsigned num_info; /* number of info strings */
143 const char **info; /* info strings */ 213 const char **info; /* info strings */
144 struct sdio_func_tuple *tuples; /* unknown common tuples */ 214 struct sdio_func_tuple *tuples; /* unknown common tuples */
145 215
216 unsigned int sd_bus_speed; /* Bus Speed Mode set for the card */
217
146 struct dentry *debugfs_root; 218 struct dentry *debugfs_root;
147}; 219};
148 220
221/*
222 * The world is not perfect and supplies us with broken mmc/sdio devices.
223 * For at least some of these bugs we need a work-around.
224 */
225
226struct mmc_fixup {
227 /* CID-specific fields. */
228 const char *name;
229
230 /* Valid revision range */
231 u64 rev_start, rev_end;
232
233 unsigned int manfid;
234 unsigned short oemid;
235
236 /* SDIO-specfic fields. You can use SDIO_ANY_ID here of course */
237 u16 cis_vendor, cis_device;
238
239 void (*vendor_fixup)(struct mmc_card *card, int data);
240 int data;
241};
242
243#define CID_MANFID_ANY (-1u)
244#define CID_OEMID_ANY ((unsigned short) -1)
245#define CID_NAME_ANY (NULL)
246
247#define END_FIXUP { 0 }
248
249#define _FIXUP_EXT(_name, _manfid, _oemid, _rev_start, _rev_end, \
250 _cis_vendor, _cis_device, \
251 _fixup, _data) \
252 { \
253 .name = (_name), \
254 .manfid = (_manfid), \
255 .oemid = (_oemid), \
256 .rev_start = (_rev_start), \
257 .rev_end = (_rev_end), \
258 .cis_vendor = (_cis_vendor), \
259 .cis_device = (_cis_device), \
260 .vendor_fixup = (_fixup), \
261 .data = (_data), \
262 }
263
264#define MMC_FIXUP_REV(_name, _manfid, _oemid, _rev_start, _rev_end, \
265 _fixup, _data) \
266 _FIXUP_EXT(_name, _manfid, \
267 _oemid, _rev_start, _rev_end, \
268 SDIO_ANY_ID, SDIO_ANY_ID, \
269 _fixup, _data) \
270
271#define MMC_FIXUP(_name, _manfid, _oemid, _fixup, _data) \
272 MMC_FIXUP_REV(_name, _manfid, _oemid, 0, -1ull, _fixup, _data)
273
274#define SDIO_FIXUP(_vendor, _device, _fixup, _data) \
275 _FIXUP_EXT(CID_NAME_ANY, CID_MANFID_ANY, \
276 CID_OEMID_ANY, 0, -1ull, \
277 _vendor, _device, \
278 _fixup, _data) \
279
280#define cid_rev(hwrev, fwrev, year, month) \
281 (((u64) hwrev) << 40 | \
282 ((u64) fwrev) << 32 | \
283 ((u64) year) << 16 | \
284 ((u64) month))
285
286#define cid_rev_card(card) \
287 cid_rev(card->cid.hwrev, \
288 card->cid.fwrev, \
289 card->cid.year, \
290 card->cid.month)
291
292/*
293 * Unconditionally quirk add/remove.
294 */
295
296static inline void __maybe_unused add_quirk(struct mmc_card *card, int data)
297{
298 card->quirks |= data;
299}
300
301static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)
302{
303 card->quirks &= ~data;
304}
305
149#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC) 306#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
150#define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD) 307#define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD)
151#define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO) 308#define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO)
@@ -154,11 +311,51 @@ struct mmc_card {
154#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) 311#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
155#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED) 312#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED)
156#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) 313#define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR)
314#define mmc_card_ddr_mode(c) ((c)->state & MMC_STATE_HIGHSPEED_DDR)
315#define mmc_sd_card_uhs(c) ((c)->state & MMC_STATE_ULTRAHIGHSPEED)
316#define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC)
157 317
158#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) 318#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
159#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) 319#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
160#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) 320#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED)
161#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) 321#define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR)
322#define mmc_card_set_ddr_mode(c) ((c)->state |= MMC_STATE_HIGHSPEED_DDR)
323#define mmc_sd_card_set_uhs(c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED)
324#define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC)
325
326/*
327 * Quirk add/remove for MMC products.
328 */
329
330static inline void __maybe_unused add_quirk_mmc(struct mmc_card *card, int data)
331{
332 if (mmc_card_mmc(card))
333 card->quirks |= data;
334}
335
336static inline void __maybe_unused remove_quirk_mmc(struct mmc_card *card,
337 int data)
338{
339 if (mmc_card_mmc(card))
340 card->quirks &= ~data;
341}
342
343/*
344 * Quirk add/remove for SD products.
345 */
346
347static inline void __maybe_unused add_quirk_sd(struct mmc_card *card, int data)
348{
349 if (mmc_card_sd(card))
350 card->quirks |= data;
351}
352
353static inline void __maybe_unused remove_quirk_sd(struct mmc_card *card,
354 int data)
355{
356 if (mmc_card_sd(card))
357 card->quirks &= ~data;
358}
162 359
163static inline int mmc_card_lenient_fn0(const struct mmc_card *c) 360static inline int mmc_card_lenient_fn0(const struct mmc_card *c)
164{ 361{
@@ -170,9 +367,21 @@ static inline int mmc_blksz_for_byte_mode(const struct mmc_card *c)
170 return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; 367 return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
171} 368}
172 369
370static inline int mmc_card_disable_cd(const struct mmc_card *c)
371{
372 return c->quirks & MMC_QUIRK_DISABLE_CD;
373}
374
375static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c)
376{
377 return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF;
378}
379
173#define mmc_card_name(c) ((c)->cid.prod_name) 380#define mmc_card_name(c) ((c)->cid.prod_name)
174#define mmc_card_id(c) (dev_name(&(c)->dev)) 381#define mmc_card_id(c) (dev_name(&(c)->dev))
175 382
383#define mmc_dev_to_card(d) container_of(d, struct mmc_card, dev)
384
176#define mmc_list_to_card(l) container_of(l, struct mmc_card, node) 385#define mmc_list_to_card(l) container_of(l, struct mmc_card, node)
177#define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev) 386#define mmc_get_drvdata(c) dev_get_drvdata(&(c)->dev)
178#define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d) 387#define mmc_set_drvdata(c,d) dev_set_drvdata(&(c)->dev, d)
@@ -191,4 +400,7 @@ struct mmc_driver {
191extern int mmc_register_driver(struct mmc_driver *); 400extern int mmc_register_driver(struct mmc_driver *);
192extern void mmc_unregister_driver(struct mmc_driver *); 401extern void mmc_unregister_driver(struct mmc_driver *);
193 402
403extern void mmc_fixup_device(struct mmc_card *card,
404 const struct mmc_fixup *table);
405
194#endif 406#endif
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 7429033acb66..b6718e549a51 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -92,7 +92,7 @@ struct mmc_command {
92 * actively failing requests 92 * actively failing requests
93 */ 93 */
94 94
95 unsigned int erase_timeout; /* in milliseconds */ 95 unsigned int cmd_timeout_ms; /* in milliseconds */
96 96
97 struct mmc_data *data; /* data segment associated with cmd */ 97 struct mmc_data *data; /* data segment associated with cmd */
98 struct mmc_request *mrq; /* associated request */ 98 struct mmc_request *mrq; /* associated request */
@@ -120,6 +120,7 @@ struct mmc_data {
120}; 120};
121 121
122struct mmc_request { 122struct mmc_request {
123 struct mmc_command *sbc; /* SET_BLOCK_COUNT for multiblock */
123 struct mmc_command *cmd; 124 struct mmc_command *cmd;
124 struct mmc_data *data; 125 struct mmc_data *data;
125 struct mmc_command *stop; 126 struct mmc_command *stop;
@@ -133,8 +134,10 @@ struct mmc_card;
133 134
134extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *); 135extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
135extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); 136extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
137extern int mmc_app_cmd(struct mmc_host *, struct mmc_card *);
136extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, 138extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
137 struct mmc_command *, int); 139 struct mmc_command *, int);
140extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
138 141
139#define MMC_ERASE_ARG 0x00000000 142#define MMC_ERASE_ARG 0x00000000
140#define MMC_SECURE_ERASE_ARG 0x80000000 143#define MMC_SECURE_ERASE_ARG 0x80000000
@@ -153,11 +156,14 @@ extern int mmc_can_secure_erase_trim(struct mmc_card *card);
153extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, 156extern int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
154 unsigned int nr); 157 unsigned int nr);
155 158
159extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
160
156extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *); 161extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
157extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); 162extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
158 163
159extern int __mmc_claim_host(struct mmc_host *host, atomic_t *abort); 164extern int __mmc_claim_host(struct mmc_host *host, atomic_t *abort);
160extern void mmc_release_host(struct mmc_host *host); 165extern void mmc_release_host(struct mmc_host *host);
166extern void mmc_do_release_host(struct mmc_host *host);
161extern int mmc_try_claim_host(struct mmc_host *host); 167extern int mmc_try_claim_host(struct mmc_host *host);
162 168
163/** 169/**
diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h
new file mode 100644
index 000000000000..bdd7ceeb99e4
--- /dev/null
+++ b/include/linux/mmc/dw_mmc.h
@@ -0,0 +1,222 @@
1/*
2 * Synopsys DesignWare Multimedia Card Interface driver
3 * (Based on NXP driver for lpc 31xx)
4 *
5 * Copyright (C) 2009 NXP Semiconductors
6 * Copyright (C) 2009, 2010 Imagination Technologies Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#ifndef _LINUX_MMC_DW_MMC_H_
15#define _LINUX_MMC_DW_MMC_H_
16
17#define MAX_MCI_SLOTS 2
18
19enum dw_mci_state {
20 STATE_IDLE = 0,
21 STATE_SENDING_CMD,
22 STATE_SENDING_DATA,
23 STATE_DATA_BUSY,
24 STATE_SENDING_STOP,
25 STATE_DATA_ERROR,
26};
27
28enum {
29 EVENT_CMD_COMPLETE = 0,
30 EVENT_XFER_COMPLETE,
31 EVENT_DATA_COMPLETE,
32 EVENT_DATA_ERROR,
33 EVENT_XFER_ERROR
34};
35
36struct mmc_data;
37
38/**
39 * struct dw_mci - MMC controller state shared between all slots
40 * @lock: Spinlock protecting the queue and associated data.
41 * @regs: Pointer to MMIO registers.
42 * @sg: Scatterlist entry currently being processed by PIO code, if any.
43 * @pio_offset: Offset into the current scatterlist entry.
44 * @cur_slot: The slot which is currently using the controller.
45 * @mrq: The request currently being processed on @cur_slot,
46 * or NULL if the controller is idle.
47 * @cmd: The command currently being sent to the card, or NULL.
48 * @data: The data currently being transferred, or NULL if no data
49 * transfer is in progress.
50 * @use_dma: Whether DMA channel is initialized or not.
51 * @sg_dma: Bus address of DMA buffer.
52 * @sg_cpu: Virtual address of DMA buffer.
53 * @dma_ops: Pointer to platform-specific DMA callbacks.
54 * @cmd_status: Snapshot of SR taken upon completion of the current
55 * command. Only valid when EVENT_CMD_COMPLETE is pending.
56 * @data_status: Snapshot of SR taken upon completion of the current
57 * data transfer. Only valid when EVENT_DATA_COMPLETE or
58 * EVENT_DATA_ERROR is pending.
59 * @stop_cmdr: Value to be loaded into CMDR when the stop command is
60 * to be sent.
61 * @dir_status: Direction of current transfer.
62 * @tasklet: Tasklet running the request state machine.
63 * @card_tasklet: Tasklet handling card detect.
64 * @pending_events: Bitmask of events flagged by the interrupt handler
65 * to be processed by the tasklet.
66 * @completed_events: Bitmask of events which the state machine has
67 * processed.
68 * @state: Tasklet state.
69 * @queue: List of slots waiting for access to the controller.
70 * @bus_hz: The rate of @mck in Hz. This forms the basis for MMC bus
71 * rate and timeout calculations.
72 * @current_speed: Configured rate of the controller.
73 * @num_slots: Number of slots available.
74 * @pdev: Platform device associated with the MMC controller.
75 * @pdata: Platform data associated with the MMC controller.
76 * @slot: Slots sharing this MMC controller.
77 * @data_shift: log2 of FIFO item size.
78 * @push_data: Pointer to FIFO push function.
79 * @pull_data: Pointer to FIFO pull function.
80 * @quirks: Set of quirks that apply to specific versions of the IP.
81 *
82 * Locking
83 * =======
84 *
85 * @lock is a softirq-safe spinlock protecting @queue as well as
86 * @cur_slot, @mrq and @state. These must always be updated
87 * at the same time while holding @lock.
88 *
89 * The @mrq field of struct dw_mci_slot is also protected by @lock,
90 * and must always be written at the same time as the slot is added to
91 * @queue.
92 *
93 * @pending_events and @completed_events are accessed using atomic bit
94 * operations, so they don't need any locking.
95 *
96 * None of the fields touched by the interrupt handler need any
97 * locking. However, ordering is important: Before EVENT_DATA_ERROR or
98 * EVENT_DATA_COMPLETE is set in @pending_events, all data-related
99 * interrupts must be disabled and @data_status updated with a
100 * snapshot of SR. Similarly, before EVENT_CMD_COMPLETE is set, the
101 * CMDRDY interrupt must be disabled and @cmd_status updated with a
102 * snapshot of SR, and before EVENT_XFER_COMPLETE can be set, the
103 * bytes_xfered field of @data must be written. This is ensured by
104 * using barriers.
105 */
106struct dw_mci {
107 spinlock_t lock;
108 void __iomem *regs;
109
110 struct scatterlist *sg;
111 unsigned int pio_offset;
112
113 struct dw_mci_slot *cur_slot;
114 struct mmc_request *mrq;
115 struct mmc_command *cmd;
116 struct mmc_data *data;
117
118 /* DMA interface members*/
119 int use_dma;
120
121 dma_addr_t sg_dma;
122 void *sg_cpu;
123 struct dw_mci_dma_ops *dma_ops;
124#ifdef CONFIG_MMC_DW_IDMAC
125 unsigned int ring_size;
126#else
127 struct dw_mci_dma_data *dma_data;
128#endif
129 u32 cmd_status;
130 u32 data_status;
131 u32 stop_cmdr;
132 u32 dir_status;
133 struct tasklet_struct tasklet;
134 struct tasklet_struct card_tasklet;
135 unsigned long pending_events;
136 unsigned long completed_events;
137 enum dw_mci_state state;
138 struct list_head queue;
139
140 u32 bus_hz;
141 u32 current_speed;
142 u32 num_slots;
143 u32 fifoth_val;
144 struct platform_device *pdev;
145 struct dw_mci_board *pdata;
146 struct dw_mci_slot *slot[MAX_MCI_SLOTS];
147
148 /* FIFO push and pull */
149 int data_shift;
150 void (*push_data)(struct dw_mci *host, void *buf, int cnt);
151 void (*pull_data)(struct dw_mci *host, void *buf, int cnt);
152
153 /* Workaround flags */
154 u32 quirks;
155
156 struct regulator *vmmc; /* Power regulator */
157};
158
159/* DMA ops for Internal/External DMAC interface */
160struct dw_mci_dma_ops {
161 /* DMA Ops */
162 int (*init)(struct dw_mci *host);
163 void (*start)(struct dw_mci *host, unsigned int sg_len);
164 void (*complete)(struct dw_mci *host);
165 void (*stop)(struct dw_mci *host);
166 void (*cleanup)(struct dw_mci *host);
167 void (*exit)(struct dw_mci *host);
168};
169
170/* IP Quirks/flags. */
171/* DTO fix for command transmission with IDMAC configured */
172#define DW_MCI_QUIRK_IDMAC_DTO BIT(0)
173/* delay needed between retries on some 2.11a implementations */
174#define DW_MCI_QUIRK_RETRY_DELAY BIT(1)
175/* High Speed Capable - Supports HS cards (up to 50MHz) */
176#define DW_MCI_QUIRK_HIGHSPEED BIT(2)
177/* Unreliable card detection */
178#define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(3)
179
180
181struct dma_pdata;
182
183struct block_settings {
184 unsigned short max_segs; /* see blk_queue_max_segments */
185 unsigned int max_blk_size; /* maximum size of one mmc block */
186 unsigned int max_blk_count; /* maximum number of blocks in one req*/
187 unsigned int max_req_size; /* maximum number of bytes in one req*/
188 unsigned int max_seg_size; /* see blk_queue_max_segment_size */
189};
190
191/* Board platform data */
192struct dw_mci_board {
193 u32 num_slots;
194
195 u32 quirks; /* Workaround / Quirk flags */
196 unsigned int bus_hz; /* Bus speed */
197
198 unsigned int caps; /* Capabilities */
199
200 /* delay in mS before detecting cards after interrupt */
201 u32 detect_delay_ms;
202
203 int (*init)(u32 slot_id, irq_handler_t , void *);
204 int (*get_ro)(u32 slot_id);
205 int (*get_cd)(u32 slot_id);
206 int (*get_ocr)(u32 slot_id);
207 int (*get_bus_wd)(u32 slot_id);
208 /*
209 * Enable power to selected slot and set voltage to desired level.
210 * Voltage levels are specified using MMC_VDD_xxx defines defined
211 * in linux/mmc/host.h file.
212 */
213 void (*setpower)(u32 slot_id, u32 volt);
214 void (*exit)(u32 slot_id);
215 void (*select_slot)(u32 slot_id);
216
217 struct dw_mci_dma_ops *dma_ops;
218 struct dma_pdata *data;
219 struct block_settings *blk_settings;
220};
221
222#endif /* _LINUX_MMC_DW_MMC_H_ */
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 1575b52c3bfa..1ee4424462eb 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -50,6 +50,30 @@ struct mmc_ios {
50#define MMC_TIMING_LEGACY 0 50#define MMC_TIMING_LEGACY 0
51#define MMC_TIMING_MMC_HS 1 51#define MMC_TIMING_MMC_HS 1
52#define MMC_TIMING_SD_HS 2 52#define MMC_TIMING_SD_HS 2
53#define MMC_TIMING_UHS_SDR12 MMC_TIMING_LEGACY
54#define MMC_TIMING_UHS_SDR25 MMC_TIMING_SD_HS
55#define MMC_TIMING_UHS_SDR50 3
56#define MMC_TIMING_UHS_SDR104 4
57#define MMC_TIMING_UHS_DDR50 5
58
59 unsigned char ddr; /* dual data rate used */
60
61#define MMC_SDR_MODE 0
62#define MMC_1_2V_DDR_MODE 1
63#define MMC_1_8V_DDR_MODE 2
64
65 unsigned char signal_voltage; /* signalling voltage (1.8V or 3.3V) */
66
67#define MMC_SIGNAL_VOLTAGE_330 0
68#define MMC_SIGNAL_VOLTAGE_180 1
69#define MMC_SIGNAL_VOLTAGE_120 2
70
71 unsigned char drv_type; /* driver type (A, B, C, D) */
72
73#define MMC_SET_DRIVER_TYPE_B 0
74#define MMC_SET_DRIVER_TYPE_A 1
75#define MMC_SET_DRIVER_TYPE_C 2
76#define MMC_SET_DRIVER_TYPE_D 3
53}; 77};
54 78
55struct mmc_host_ops { 79struct mmc_host_ops {
@@ -111,6 +135,10 @@ struct mmc_host_ops {
111 135
112 /* optional callback for HC quirks */ 136 /* optional callback for HC quirks */
113 void (*init_card)(struct mmc_host *host, struct mmc_card *card); 137 void (*init_card)(struct mmc_host *host, struct mmc_card *card);
138
139 int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
140 int (*execute_tuning)(struct mmc_host *host);
141 void (*enable_preset_value)(struct mmc_host *host, bool enable);
114}; 142};
115 143
116struct mmc_card; 144struct mmc_card;
@@ -123,7 +151,11 @@ struct mmc_host {
123 const struct mmc_host_ops *ops; 151 const struct mmc_host_ops *ops;
124 unsigned int f_min; 152 unsigned int f_min;
125 unsigned int f_max; 153 unsigned int f_max;
154 unsigned int f_init;
126 u32 ocr_avail; 155 u32 ocr_avail;
156 u32 ocr_avail_sdio; /* SDIO-specific OCR */
157 u32 ocr_avail_sd; /* SD-specific OCR */
158 u32 ocr_avail_mmc; /* MMC-specific OCR */
127 struct notifier_block pm_notify; 159 struct notifier_block pm_notify;
128 160
129#define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ 161#define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */
@@ -157,13 +189,44 @@ struct mmc_host {
157#define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */ 189#define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */
158#define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */ 190#define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */
159#define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */ 191#define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */
192#define MMC_CAP_1_8V_DDR (1 << 11) /* can support */
193 /* DDR mode at 1.8V */
194#define MMC_CAP_1_2V_DDR (1 << 12) /* can support */
195 /* DDR mode at 1.2V */
196#define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */
197#define MMC_CAP_BUS_WIDTH_TEST (1 << 14) /* CMD14/CMD19 bus width ok */
198#define MMC_CAP_UHS_SDR12 (1 << 15) /* Host supports UHS SDR12 mode */
199#define MMC_CAP_UHS_SDR25 (1 << 16) /* Host supports UHS SDR25 mode */
200#define MMC_CAP_UHS_SDR50 (1 << 17) /* Host supports UHS SDR50 mode */
201#define MMC_CAP_UHS_SDR104 (1 << 18) /* Host supports UHS SDR104 mode */
202#define MMC_CAP_UHS_DDR50 (1 << 19) /* Host supports UHS DDR50 mode */
203#define MMC_CAP_SET_XPC_330 (1 << 20) /* Host supports >150mA current at 3.3V */
204#define MMC_CAP_SET_XPC_300 (1 << 21) /* Host supports >150mA current at 3.0V */
205#define MMC_CAP_SET_XPC_180 (1 << 22) /* Host supports >150mA current at 1.8V */
206#define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
207#define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
208#define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */
209#define MMC_CAP_MAX_CURRENT_200 (1 << 26) /* Host max current limit is 200mA */
210#define MMC_CAP_MAX_CURRENT_400 (1 << 27) /* Host max current limit is 400mA */
211#define MMC_CAP_MAX_CURRENT_600 (1 << 28) /* Host max current limit is 600mA */
212#define MMC_CAP_MAX_CURRENT_800 (1 << 29) /* Host max current limit is 800mA */
213#define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */
160 214
161 mmc_pm_flag_t pm_caps; /* supported pm features */ 215 mmc_pm_flag_t pm_caps; /* supported pm features */
162 216
217#ifdef CONFIG_MMC_CLKGATE
218 int clk_requests; /* internal reference counter */
219 unsigned int clk_delay; /* number of MCI clk hold cycles */
220 bool clk_gated; /* clock gated */
221 struct work_struct clk_gate_work; /* delayed clock gate */
222 unsigned int clk_old; /* old clock value cache */
223 spinlock_t clk_lock; /* lock for clk fields */
224 struct mutex clk_gate_mutex; /* mutex for clock gating */
225#endif
226
163 /* host specific block data */ 227 /* host specific block data */
164 unsigned int max_seg_size; /* see blk_queue_max_segment_size */ 228 unsigned int max_seg_size; /* see blk_queue_max_segment_size */
165 unsigned short max_hw_segs; /* see blk_queue_max_hw_segments */ 229 unsigned short max_segs; /* see blk_queue_max_segments */
166 unsigned short max_phys_segs; /* see blk_queue_max_phys_segments */
167 unsigned short unused; 230 unsigned short unused;
168 unsigned int max_req_size; /* maximum number of bytes in one req */ 231 unsigned int max_req_size; /* maximum number of bytes in one req */
169 unsigned int max_blk_size; /* maximum size of one mmc block */ 232 unsigned int max_blk_size; /* maximum size of one mmc block */
@@ -212,6 +275,10 @@ struct mmc_host {
212 struct led_trigger *led; /* activity led */ 275 struct led_trigger *led; /* activity led */
213#endif 276#endif
214 277
278#ifdef CONFIG_REGULATOR
279 bool regulator_enabled; /* regulator state */
280#endif
281
215 struct dentry *debugfs_root; 282 struct dentry *debugfs_root;
216 283
217 unsigned long private[0] ____cacheline_aligned; 284 unsigned long private[0] ____cacheline_aligned;
@@ -236,8 +303,8 @@ static inline void *mmc_priv(struct mmc_host *host)
236extern int mmc_suspend_host(struct mmc_host *); 303extern int mmc_suspend_host(struct mmc_host *);
237extern int mmc_resume_host(struct mmc_host *); 304extern int mmc_resume_host(struct mmc_host *);
238 305
239extern void mmc_power_save_host(struct mmc_host *host); 306extern int mmc_power_save_host(struct mmc_host *host);
240extern void mmc_power_restore_host(struct mmc_host *host); 307extern int mmc_power_restore_host(struct mmc_host *host);
241 308
242extern void mmc_detect_change(struct mmc_host *, unsigned long delay); 309extern void mmc_detect_change(struct mmc_host *, unsigned long delay);
243extern void mmc_request_done(struct mmc_host *, struct mmc_request *); 310extern void mmc_request_done(struct mmc_host *, struct mmc_request *);
@@ -250,8 +317,24 @@ static inline void mmc_signal_sdio_irq(struct mmc_host *host)
250 317
251struct regulator; 318struct regulator;
252 319
320#ifdef CONFIG_REGULATOR
253int mmc_regulator_get_ocrmask(struct regulator *supply); 321int mmc_regulator_get_ocrmask(struct regulator *supply);
254int mmc_regulator_set_ocr(struct regulator *supply, unsigned short vdd_bit); 322int mmc_regulator_set_ocr(struct mmc_host *mmc,
323 struct regulator *supply,
324 unsigned short vdd_bit);
325#else
326static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
327{
328 return 0;
329}
330
331static inline int mmc_regulator_set_ocr(struct mmc_host *mmc,
332 struct regulator *supply,
333 unsigned short vdd_bit)
334{
335 return 0;
336}
337#endif
255 338
256int mmc_card_awake(struct mmc_host *host); 339int mmc_card_awake(struct mmc_host *host);
257int mmc_card_sleep(struct mmc_host *host); 340int mmc_card_sleep(struct mmc_host *host);
@@ -268,5 +351,27 @@ static inline void mmc_set_disable_delay(struct mmc_host *host,
268 host->disable_delay = disable_delay; 351 host->disable_delay = disable_delay;
269} 352}
270 353
354/* Module parameter */
355extern int mmc_assume_removable;
356
357static inline int mmc_card_is_removable(struct mmc_host *host)
358{
359 return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable;
360}
361
362static inline int mmc_card_keep_power(struct mmc_host *host)
363{
364 return host->pm_flags & MMC_PM_KEEP_POWER;
365}
366
367static inline int mmc_card_wake_sdio_irq(struct mmc_host *host)
368{
369 return host->pm_flags & MMC_PM_WAKE_SDIO_IRQ;
370}
371
372static inline int mmc_host_cmd23(struct mmc_host *host)
373{
374 return host->caps & MMC_CAP_CMD23;
375}
271#endif 376#endif
272 377
diff --git a/include/linux/mmc/ioctl.h b/include/linux/mmc/ioctl.h
new file mode 100644
index 000000000000..5baf2983a12f
--- /dev/null
+++ b/include/linux/mmc/ioctl.h
@@ -0,0 +1,54 @@
1#ifndef LINUX_MMC_IOCTL_H
2#define LINUX_MMC_IOCTL_H
3struct mmc_ioc_cmd {
4 /* Implies direction of data. true = write, false = read */
5 int write_flag;
6
7 /* Application-specific command. true = precede with CMD55 */
8 int is_acmd;
9
10 __u32 opcode;
11 __u32 arg;
12 __u32 response[4]; /* CMD response */
13 unsigned int flags;
14 unsigned int blksz;
15 unsigned int blocks;
16
17 /*
18 * Sleep at least postsleep_min_us useconds, and at most
19 * postsleep_max_us useconds *after* issuing command. Needed for
20 * some read commands for which cards have no other way of indicating
21 * they're ready for the next command (i.e. there is no equivalent of
22 * a "busy" indicator for read operations).
23 */
24 unsigned int postsleep_min_us;
25 unsigned int postsleep_max_us;
26
27 /*
28 * Override driver-computed timeouts. Note the difference in units!
29 */
30 unsigned int data_timeout_ns;
31 unsigned int cmd_timeout_ms;
32
33 /*
34 * For 64-bit machines, the next member, ``__u64 data_ptr``, wants to
35 * be 8-byte aligned. Make sure this struct is the same size when
36 * built for 32-bit.
37 */
38 __u32 __pad;
39
40 /* DAT buffer */
41 __u64 data_ptr;
42};
43#define mmc_ioc_cmd_set_data(ic, ptr) ic.data_ptr = (__u64)(unsigned long) ptr
44
45#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
46
47/*
48 * Since this ioctl is only meant to enhance (and not replace) normal access
49 * to the mmc bus device, an upper data transfer limit of MMC_IOC_MAX_BYTES
50 * is enforced per ioctl call. For larger data transfers, use the normal
51 * block device operations.
52 */
53#define MMC_IOC_MAX_BYTES (512L * 256)
54#endif /* LINUX_MMC_IOCTL_H */
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index dd11ae51fb68..ac26a685cca8 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -40,7 +40,9 @@
40#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ 40#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
41#define MMC_STOP_TRANSMISSION 12 /* ac R1b */ 41#define MMC_STOP_TRANSMISSION 12 /* ac R1b */
42#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */ 42#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */
43#define MMC_BUS_TEST_R 14 /* adtc R1 */
43#define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */ 44#define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */
45#define MMC_BUS_TEST_W 19 /* adtc R1 */
44#define MMC_SPI_READ_OCR 58 /* spi spi_R3 */ 46#define MMC_SPI_READ_OCR 58 /* spi spi_R3 */
45#define MMC_SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */ 47#define MMC_SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */
46 48
@@ -48,6 +50,7 @@
48#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */ 50#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */
49#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */ 51#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */
50#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */ 52#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */
53#define MMC_SEND_TUNING_BLOCK 19 /* adtc R1 */
51 54
52 /* class 3 */ 55 /* class 3 */
53#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ 56#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
@@ -80,6 +83,12 @@
80#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */ 83#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */
81#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */ 84#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */
82 85
86static inline bool mmc_op_multi(u32 opcode)
87{
88 return opcode == MMC_WRITE_MULTIPLE_BLOCK ||
89 opcode == MMC_READ_MULTIPLE_BLOCK;
90}
91
83/* 92/*
84 * MMC_SWITCH argument format: 93 * MMC_SWITCH argument format:
85 * 94 *
@@ -251,17 +260,25 @@ struct _mmc_csd {
251 * EXT_CSD fields 260 * EXT_CSD fields
252 */ 261 */
253 262
263#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */
264#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */
265#define EXT_CSD_WR_REL_PARAM 166 /* RO */
254#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ 266#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
267#define EXT_CSD_PART_CONFIG 179 /* R/W */
255#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ 268#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */
256#define EXT_CSD_BUS_WIDTH 183 /* R/W */ 269#define EXT_CSD_BUS_WIDTH 183 /* R/W */
257#define EXT_CSD_HS_TIMING 185 /* R/W */ 270#define EXT_CSD_HS_TIMING 185 /* R/W */
258#define EXT_CSD_REV 192 /* RO */ 271#define EXT_CSD_REV 192 /* RO */
259#define EXT_CSD_STRUCTURE 194 /* RO */ 272#define EXT_CSD_STRUCTURE 194 /* RO */
260#define EXT_CSD_CARD_TYPE 196 /* RO */ 273#define EXT_CSD_CARD_TYPE 196 /* RO */
274#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */
261#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ 275#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
262#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ 276#define EXT_CSD_S_A_TIMEOUT 217 /* RO */
277#define EXT_CSD_REL_WR_SEC_C 222 /* RO */
278#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */
263#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ 279#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */
264#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ 280#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
281#define EXT_CSD_BOOT_MULT 226 /* RO */
265#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ 282#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */
266#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ 283#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */
267#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ 284#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
@@ -271,17 +288,31 @@ struct _mmc_csd {
271 * EXT_CSD field definitions 288 * EXT_CSD field definitions
272 */ 289 */
273 290
291#define EXT_CSD_WR_REL_PARAM_EN (1<<2)
292
293#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7)
294#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1)
295#define EXT_CSD_PART_CONFIG_ACC_BOOT1 (0x2)
296
274#define EXT_CSD_CMD_SET_NORMAL (1<<0) 297#define EXT_CSD_CMD_SET_NORMAL (1<<0)
275#define EXT_CSD_CMD_SET_SECURE (1<<1) 298#define EXT_CSD_CMD_SET_SECURE (1<<1)
276#define EXT_CSD_CMD_SET_CPSECURE (1<<2) 299#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
277 300
278#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */ 301#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
279#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */ 302#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
280#define EXT_CSD_CARD_TYPE_MASK 0x3 /* Mask out reserved and DDR bits */ 303#define EXT_CSD_CARD_TYPE_MASK 0xF /* Mask out reserved bits */
304#define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */
305 /* DDR mode @1.8V or 3V I/O */
306#define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */
307 /* DDR mode @1.2V I/O */
308#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
309 | EXT_CSD_CARD_TYPE_DDR_1_2V)
281 310
282#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ 311#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
283#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ 312#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
284#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ 313#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
314#define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */
315#define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */
285 316
286#define EXT_CSD_SEC_ER_EN BIT(0) 317#define EXT_CSD_SEC_ER_EN BIT(0)
287#define EXT_CSD_SEC_BD_BLK_EN BIT(2) 318#define EXT_CSD_SEC_BD_BLK_EN BIT(2)
diff --git a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h
index 3fd85e088cc3..7d35d52c3df3 100644
--- a/include/linux/mmc/sd.h
+++ b/include/linux/mmc/sd.h
@@ -17,6 +17,7 @@
17/* This is basically the same command as for MMC with some quirks. */ 17/* This is basically the same command as for MMC with some quirks. */
18#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */ 18#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */
19#define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */ 19#define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */
20#define SD_SWITCH_VOLTAGE 11 /* ac R1 */
20 21
21 /* class 10 */ 22 /* class 10 */
22#define SD_SWITCH 6 /* adtc [31:0] See below R1 */ 23#define SD_SWITCH 6 /* adtc [31:0] See below R1 */
@@ -32,6 +33,12 @@
32#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ 33#define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */
33#define SD_APP_SEND_SCR 51 /* adtc R1 */ 34#define SD_APP_SEND_SCR 51 /* adtc R1 */
34 35
36/* OCR bit definitions */
37#define SD_OCR_S18R (1 << 24) /* 1.8V switching request */
38#define SD_ROCR_S18A SD_OCR_S18R /* 1.8V switching accepted by card */
39#define SD_OCR_XPC (1 << 28) /* SDXC power control */
40#define SD_OCR_CCS (1 << 30) /* Card Capacity Status */
41
35/* 42/*
36 * SD_SWITCH argument format: 43 * SD_SWITCH argument format:
37 * 44 *
@@ -59,7 +66,7 @@
59 66
60#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */ 67#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */
61#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */ 68#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */
62#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */ 69#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00-3.0X */
63 70
64/* 71/*
65 * SD bus widths 72 * SD bus widths
diff --git a/include/linux/sdhci-pltfm.h b/include/linux/mmc/sdhci-pltfm.h
index 0239bd70241e..548d59d404cb 100644
--- a/include/linux/sdhci-pltfm.h
+++ b/include/linux/mmc/sdhci-pltfm.h
@@ -28,7 +28,7 @@ struct sdhci_host;
28struct sdhci_pltfm_data { 28struct sdhci_pltfm_data {
29 struct sdhci_ops *ops; 29 struct sdhci_ops *ops;
30 unsigned int quirks; 30 unsigned int quirks;
31 int (*init)(struct sdhci_host *host); 31 int (*init)(struct sdhci_host *host, struct sdhci_pltfm_data *pdata);
32 void (*exit)(struct sdhci_host *host); 32 void (*exit)(struct sdhci_host *host);
33}; 33};
34 34
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
new file mode 100644
index 000000000000..6a68c4eb4e44
--- /dev/null
+++ b/include/linux/mmc/sdhci.h
@@ -0,0 +1,165 @@
1/*
2 * linux/include/linux/mmc/sdhci.h - Secure Digital Host Controller Interface
3 *
4 * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 */
11#ifndef __SDHCI_H
12#define __SDHCI_H
13
14#include <linux/scatterlist.h>
15#include <linux/compiler.h>
16#include <linux/types.h>
17#include <linux/io.h>
18#include <linux/mmc/host.h>
19
20struct sdhci_host {
21 /* Data set by hardware interface driver */
22 const char *hw_name; /* Hardware bus name */
23
24 unsigned int quirks; /* Deviations from spec. */
25
26/* Controller doesn't honor resets unless we touch the clock register */
27#define SDHCI_QUIRK_CLOCK_BEFORE_RESET (1<<0)
28/* Controller has bad caps bits, but really supports DMA */
29#define SDHCI_QUIRK_FORCE_DMA (1<<1)
30/* Controller doesn't like to be reset when there is no card inserted. */
31#define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2)
32/* Controller doesn't like clearing the power reg before a change */
33#define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3)
34/* Controller has flaky internal state so reset it on each ios change */
35#define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4)
36/* Controller has an unusable DMA engine */
37#define SDHCI_QUIRK_BROKEN_DMA (1<<5)
38/* Controller has an unusable ADMA engine */
39#define SDHCI_QUIRK_BROKEN_ADMA (1<<6)
40/* Controller can only DMA from 32-bit aligned addresses */
41#define SDHCI_QUIRK_32BIT_DMA_ADDR (1<<7)
42/* Controller can only DMA chunk sizes that are a multiple of 32 bits */
43#define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<8)
44/* Controller can only ADMA chunks that are a multiple of 32 bits */
45#define SDHCI_QUIRK_32BIT_ADMA_SIZE (1<<9)
46/* Controller needs to be reset after each request to stay stable */
47#define SDHCI_QUIRK_RESET_AFTER_REQUEST (1<<10)
48/* Controller needs voltage and power writes to happen separately */
49#define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1<<11)
50/* Controller provides an incorrect timeout value for transfers */
51#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12)
52/* Controller has an issue with buffer bits for small transfers */
53#define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13)
54/* Controller does not provide transfer-complete interrupt when not busy */
55#define SDHCI_QUIRK_NO_BUSY_IRQ (1<<14)
56/* Controller has unreliable card detection */
57#define SDHCI_QUIRK_BROKEN_CARD_DETECTION (1<<15)
58/* Controller reports inverted write-protect state */
59#define SDHCI_QUIRK_INVERTED_WRITE_PROTECT (1<<16)
60/* Controller has nonstandard clock management */
61#define SDHCI_QUIRK_NONSTANDARD_CLOCK (1<<17)
62/* Controller does not like fast PIO transfers */
63#define SDHCI_QUIRK_PIO_NEEDS_DELAY (1<<18)
64/* Controller losing signal/interrupt enable states after reset */
65#define SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET (1<<19)
66/* Controller has to be forced to use block size of 2048 bytes */
67#define SDHCI_QUIRK_FORCE_BLK_SZ_2048 (1<<20)
68/* Controller cannot do multi-block transfers */
69#define SDHCI_QUIRK_NO_MULTIBLOCK (1<<21)
70/* Controller can only handle 1-bit data transfers */
71#define SDHCI_QUIRK_FORCE_1_BIT_DATA (1<<22)
72/* Controller needs 10ms delay between applying power and clock */
73#define SDHCI_QUIRK_DELAY_AFTER_POWER (1<<23)
74/* Controller uses SDCLK instead of TMCLK for data timeouts */
75#define SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK (1<<24)
76/* Controller reports wrong base clock capability */
77#define SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN (1<<25)
78/* Controller cannot support End Attribute in NOP ADMA descriptor */
79#define SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC (1<<26)
80/* Controller is missing device caps. Use caps provided by host */
81#define SDHCI_QUIRK_MISSING_CAPS (1<<27)
82/* Controller uses Auto CMD12 command to stop the transfer */
83#define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 (1<<28)
84/* Controller doesn't have HISPD bit field in HI-SPEED SD card */
85#define SDHCI_QUIRK_NO_HISPD_BIT (1<<29)
86/* Controller treats ADMA descriptors with length 0000h incorrectly */
87#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC (1<<30)
88/* The read-only detection via SDHCI_PRESENT_STATE register is unstable */
89#define SDHCI_QUIRK_UNSTABLE_RO_DETECT (1<<31)
90
91 int irq; /* Device IRQ */
92 void __iomem *ioaddr; /* Mapped address */
93
94 const struct sdhci_ops *ops; /* Low level hw interface */
95
96 struct regulator *vmmc; /* Power regulator */
97
98 /* Internal data */
99 struct mmc_host *mmc; /* MMC structure */
100 u64 dma_mask; /* custom DMA mask */
101
102#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
103 struct led_classdev led; /* LED control */
104 char led_name[32];
105#endif
106
107 spinlock_t lock; /* Mutex */
108
109 int flags; /* Host attributes */
110#define SDHCI_USE_SDMA (1<<0) /* Host is SDMA capable */
111#define SDHCI_USE_ADMA (1<<1) /* Host is ADMA capable */
112#define SDHCI_REQ_USE_DMA (1<<2) /* Use DMA for this req. */
113#define SDHCI_DEVICE_DEAD (1<<3) /* Device unresponsive */
114#define SDHCI_SDR50_NEEDS_TUNING (1<<4) /* SDR50 needs tuning */
115#define SDHCI_NEEDS_RETUNING (1<<5) /* Host needs retuning */
116#define SDHCI_AUTO_CMD12 (1<<6) /* Auto CMD12 support */
117#define SDHCI_AUTO_CMD23 (1<<7) /* Auto CMD23 support */
118
119 unsigned int version; /* SDHCI spec. version */
120
121 unsigned int max_clk; /* Max possible freq (MHz) */
122 unsigned int timeout_clk; /* Timeout freq (KHz) */
123 unsigned int clk_mul; /* Clock Muliplier value */
124
125 unsigned int clock; /* Current clock (MHz) */
126 u8 pwr; /* Current voltage */
127
128 struct mmc_request *mrq; /* Current request */
129 struct mmc_command *cmd; /* Current command */
130 struct mmc_data *data; /* Current data request */
131 unsigned int data_early:1; /* Data finished before cmd */
132
133 struct sg_mapping_iter sg_miter; /* SG state for PIO */
134 unsigned int blocks; /* remaining PIO blocks */
135
136 int sg_count; /* Mapped sg entries */
137
138 u8 *adma_desc; /* ADMA descriptor table */
139 u8 *align_buffer; /* Bounce buffer */
140
141 dma_addr_t adma_addr; /* Mapped ADMA descr. table */
142 dma_addr_t align_addr; /* Mapped bounce buffer */
143
144 struct tasklet_struct card_tasklet; /* Tasklet structures */
145 struct tasklet_struct finish_tasklet;
146
147 struct timer_list timer; /* Timer for timeouts */
148
149 unsigned int caps; /* Alternative capabilities */
150
151 unsigned int ocr_avail_sdio; /* OCR bit masks */
152 unsigned int ocr_avail_sd;
153 unsigned int ocr_avail_mmc;
154
155 wait_queue_head_t buf_ready_int; /* Waitqueue for Buffer Read Ready interrupt */
156 unsigned int tuning_done; /* Condition flag set when CMD19 succeeds */
157
158 unsigned int tuning_count; /* Timer count for re-tuning */
159 unsigned int tuning_mode; /* Re-tuning mode supported by host */
160#define SDHCI_TUNING_MODE_1 0
161 struct timer_list tuning_timer; /* Timer for tuning */
162
163 unsigned long private[0] ____cacheline_aligned;
164};
165#endif /* __SDHCI_H */
diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
index 33b2ea09a4ad..a36ab3bc7b03 100644
--- a/include/linux/mmc/sdio_ids.h
+++ b/include/linux/mmc/sdio_ids.h
@@ -18,6 +18,7 @@
18#define SDIO_CLASS_PHS 0x06 /* PHS standard interface */ 18#define SDIO_CLASS_PHS 0x06 /* PHS standard interface */
19#define SDIO_CLASS_WLAN 0x07 /* WLAN interface */ 19#define SDIO_CLASS_WLAN 0x07 /* WLAN interface */
20#define SDIO_CLASS_ATA 0x08 /* Embedded SDIO-ATA std interface */ 20#define SDIO_CLASS_ATA 0x08 /* Embedded SDIO-ATA std interface */
21#define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */
21 22
22/* 23/*
23 * Vendors and devices. Sort key: vendor first, device next. 24 * Vendors and devices. Sort key: vendor first, device next.
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index d4a2ebbdab4b..9eb9b4b96f55 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -14,8 +14,9 @@
14#ifndef __SH_MMCIF_H__ 14#ifndef __SH_MMCIF_H__
15#define __SH_MMCIF_H__ 15#define __SH_MMCIF_H__
16 16
17#include <linux/platform_device.h>
18#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/platform_device.h>
19#include <linux/sh_dma.h>
19 20
20/* 21/*
21 * MMCIF : CE_CLK_CTRL [19:16] 22 * MMCIF : CE_CLK_CTRL [19:16]
@@ -31,12 +32,19 @@
31 * 1111 : Peripheral clock (sup_pclk set '1') 32 * 1111 : Peripheral clock (sup_pclk set '1')
32 */ 33 */
33 34
35struct sh_mmcif_dma {
36 struct sh_dmae_slave chan_priv_tx;
37 struct sh_dmae_slave chan_priv_rx;
38};
39
34struct sh_mmcif_plat_data { 40struct sh_mmcif_plat_data {
35 void (*set_pwr)(struct platform_device *pdev, int state); 41 void (*set_pwr)(struct platform_device *pdev, int state);
36 void (*down_pwr)(struct platform_device *pdev); 42 void (*down_pwr)(struct platform_device *pdev);
37 u8 sup_pclk; /* 1 :SH7757, 0: SH7724/SH7372 */ 43 int (*get_cd)(struct platform_device *pdef);
38 unsigned long caps; 44 struct sh_mmcif_dma *dma;
39 u32 ocr; 45 u8 sup_pclk; /* 1 :SH7757, 0: SH7724/SH7372 */
46 unsigned long caps;
47 u32 ocr;
40}; 48};
41 49
42#define MMCIF_CE_CMD_SET 0x00000000 50#define MMCIF_CE_CMD_SET 0x00000000
@@ -58,19 +66,45 @@ struct sh_mmcif_plat_data {
58#define MMCIF_CE_HOST_STS2 0x0000004C 66#define MMCIF_CE_HOST_STS2 0x0000004C
59#define MMCIF_CE_VERSION 0x0000007C 67#define MMCIF_CE_VERSION 0x0000007C
60 68
61extern inline u32 sh_mmcif_readl(void __iomem *addr, int reg) 69/* CE_BUF_ACC */
70#define BUF_ACC_DMAWEN (1 << 25)
71#define BUF_ACC_DMAREN (1 << 24)
72#define BUF_ACC_BUSW_32 (0 << 17)
73#define BUF_ACC_BUSW_16 (1 << 17)
74#define BUF_ACC_ATYP (1 << 16)
75
76/* CE_CLK_CTRL */
77#define CLK_ENABLE (1 << 24) /* 1: output mmc clock */
78#define CLK_CLEAR ((1 << 19) | (1 << 18) | (1 << 17) | (1 << 16))
79#define CLK_SUP_PCLK ((1 << 19) | (1 << 18) | (1 << 17) | (1 << 16))
80#define CLKDIV_4 (1<<16) /* mmc clock frequency.
81 * n: bus clock/(2^(n+1)) */
82#define CLKDIV_256 (7<<16) /* mmc clock frequency. (see above) */
83#define SRSPTO_256 ((1 << 13) | (0 << 12)) /* resp timeout */
84#define SRBSYTO_29 ((1 << 11) | (1 << 10) | \
85 (1 << 9) | (1 << 8)) /* resp busy timeout */
86#define SRWDTO_29 ((1 << 7) | (1 << 6) | \
87 (1 << 5) | (1 << 4)) /* read/write timeout */
88#define SCCSTO_29 ((1 << 3) | (1 << 2) | \
89 (1 << 1) | (1 << 0)) /* ccs timeout */
90
91/* CE_VERSION */
92#define SOFT_RST_ON (1 << 31)
93#define SOFT_RST_OFF 0
94
95static inline u32 sh_mmcif_readl(void __iomem *addr, int reg)
62{ 96{
63 return readl(addr + reg); 97 return __raw_readl(addr + reg);
64} 98}
65 99
66extern inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val) 100static inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val)
67{ 101{
68 writel(val, addr + reg); 102 __raw_writel(val, addr + reg);
69} 103}
70 104
71#define SH_MMCIF_BBS 512 /* boot block size */ 105#define SH_MMCIF_BBS 512 /* boot block size */
72 106
73extern inline void sh_mmcif_boot_cmd_send(void __iomem *base, 107static inline void sh_mmcif_boot_cmd_send(void __iomem *base,
74 unsigned long cmd, unsigned long arg) 108 unsigned long cmd, unsigned long arg)
75{ 109{
76 sh_mmcif_writel(base, MMCIF_CE_INT, 0); 110 sh_mmcif_writel(base, MMCIF_CE_INT, 0);
@@ -78,7 +112,7 @@ extern inline void sh_mmcif_boot_cmd_send(void __iomem *base,
78 sh_mmcif_writel(base, MMCIF_CE_CMD_SET, cmd); 112 sh_mmcif_writel(base, MMCIF_CE_CMD_SET, cmd);
79} 113}
80 114
81extern inline int sh_mmcif_boot_cmd_poll(void __iomem *base, unsigned long mask) 115static inline int sh_mmcif_boot_cmd_poll(void __iomem *base, unsigned long mask)
82{ 116{
83 unsigned long tmp; 117 unsigned long tmp;
84 int cnt; 118 int cnt;
@@ -94,14 +128,14 @@ extern inline int sh_mmcif_boot_cmd_poll(void __iomem *base, unsigned long mask)
94 return -1; 128 return -1;
95} 129}
96 130
97extern inline int sh_mmcif_boot_cmd(void __iomem *base, 131static inline int sh_mmcif_boot_cmd(void __iomem *base,
98 unsigned long cmd, unsigned long arg) 132 unsigned long cmd, unsigned long arg)
99{ 133{
100 sh_mmcif_boot_cmd_send(base, cmd, arg); 134 sh_mmcif_boot_cmd_send(base, cmd, arg);
101 return sh_mmcif_boot_cmd_poll(base, 0x00010000); 135 return sh_mmcif_boot_cmd_poll(base, 0x00010000);
102} 136}
103 137
104extern inline int sh_mmcif_boot_do_read_single(void __iomem *base, 138static inline int sh_mmcif_boot_do_read_single(void __iomem *base,
105 unsigned int block_nr, 139 unsigned int block_nr,
106 unsigned long *buf) 140 unsigned long *buf)
107{ 141{
@@ -124,7 +158,7 @@ extern inline int sh_mmcif_boot_do_read_single(void __iomem *base,
124 return 0; 158 return 0;
125} 159}
126 160
127extern inline int sh_mmcif_boot_do_read(void __iomem *base, 161static inline int sh_mmcif_boot_do_read(void __iomem *base,
128 unsigned long first_block, 162 unsigned long first_block,
129 unsigned long nr_blocks, 163 unsigned long nr_blocks,
130 void *buf) 164 void *buf)
@@ -132,6 +166,17 @@ extern inline int sh_mmcif_boot_do_read(void __iomem *base,
132 unsigned long k; 166 unsigned long k;
133 int ret = 0; 167 int ret = 0;
134 168
169 /* In data transfer mode: Set clock to Bus clock/4 (about 20Mhz) */
170 sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL,
171 CLK_ENABLE | CLKDIV_4 | SRSPTO_256 |
172 SRBSYTO_29 | SRWDTO_29 | SCCSTO_29);
173
174 /* CMD9 - Get CSD */
175 sh_mmcif_boot_cmd(base, 0x09806000, 0x00010000);
176
177 /* CMD7 - Select the card */
178 sh_mmcif_boot_cmd(base, 0x07400000, 0x00010000);
179
135 /* CMD16 - Set the block size */ 180 /* CMD16 - Set the block size */
136 sh_mmcif_boot_cmd(base, 0x10400000, SH_MMCIF_BBS); 181 sh_mmcif_boot_cmd(base, 0x10400000, SH_MMCIF_BBS);
137 182
@@ -142,23 +187,22 @@ extern inline int sh_mmcif_boot_do_read(void __iomem *base,
142 return ret; 187 return ret;
143} 188}
144 189
145extern inline void sh_mmcif_boot_init(void __iomem *base) 190static inline void sh_mmcif_boot_init(void __iomem *base)
146{ 191{
147 unsigned long tmp;
148
149 /* reset */ 192 /* reset */
150 tmp = sh_mmcif_readl(base, MMCIF_CE_VERSION); 193 sh_mmcif_writel(base, MMCIF_CE_VERSION, SOFT_RST_ON);
151 sh_mmcif_writel(base, MMCIF_CE_VERSION, tmp | 0x80000000); 194 sh_mmcif_writel(base, MMCIF_CE_VERSION, SOFT_RST_OFF);
152 sh_mmcif_writel(base, MMCIF_CE_VERSION, tmp & ~0x80000000);
153 195
154 /* byte swap */ 196 /* byte swap */
155 sh_mmcif_writel(base, MMCIF_CE_BUF_ACC, 0x00010000); 197 sh_mmcif_writel(base, MMCIF_CE_BUF_ACC, BUF_ACC_ATYP);
156 198
157 /* Set block size in MMCIF hardware */ 199 /* Set block size in MMCIF hardware */
158 sh_mmcif_writel(base, MMCIF_CE_BLOCK_SET, SH_MMCIF_BBS); 200 sh_mmcif_writel(base, MMCIF_CE_BLOCK_SET, SH_MMCIF_BBS);
159 201
160 /* Enable the clock, set it to Bus clock/256 (about 325Khz)*/ 202 /* Enable the clock, set it to Bus clock/256 (about 325Khz). */
161 sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, 0x01072fff); 203 sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL,
204 CLK_ENABLE | CLKDIV_256 | SRSPTO_256 |
205 SRBSYTO_29 | SRWDTO_29 | SCCSTO_29);
162 206
163 /* CMD0 */ 207 /* CMD0 */
164 sh_mmcif_boot_cmd(base, 0x00000040, 0); 208 sh_mmcif_boot_cmd(base, 0x00000040, 0);
@@ -176,25 +220,4 @@ extern inline void sh_mmcif_boot_init(void __iomem *base)
176 sh_mmcif_boot_cmd(base, 0x03400040, 0x00010000); 220 sh_mmcif_boot_cmd(base, 0x03400040, 0x00010000);
177} 221}
178 222
179extern inline void sh_mmcif_boot_slurp(void __iomem *base,
180 unsigned char *buf,
181 unsigned long no_bytes)
182{
183 unsigned long tmp;
184
185 /* In data transfer mode: Set clock to Bus clock/4 (about 20Mhz) */
186 sh_mmcif_writel(base, MMCIF_CE_CLK_CTRL, 0x01012fff);
187
188 /* CMD9 - Get CSD */
189 sh_mmcif_boot_cmd(base, 0x09806000, 0x00010000);
190
191 /* CMD7 - Select the card */
192 sh_mmcif_boot_cmd(base, 0x07400000, 0x00010000);
193
194 tmp = no_bytes / SH_MMCIF_BBS;
195 tmp += (no_bytes % SH_MMCIF_BBS) ? 1 : 0;
196
197 sh_mmcif_boot_do_read(base, 512, tmp, buf);
198}
199
200#endif /* __SH_MMCIF_H__ */ 223#endif /* __SH_MMCIF_H__ */
diff --git a/include/linux/mfd/sh_mobile_sdhi.h b/include/linux/mmc/sh_mobile_sdhi.h
index 49067802a6d7..faf32b6ec185 100644
--- a/include/linux/mfd/sh_mobile_sdhi.h
+++ b/include/linux/mmc/sh_mobile_sdhi.h
@@ -3,12 +3,18 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6struct platform_device;
7struct tmio_mmc_data;
8
6struct sh_mobile_sdhi_info { 9struct sh_mobile_sdhi_info {
7 int dma_slave_tx; 10 int dma_slave_tx;
8 int dma_slave_rx; 11 int dma_slave_rx;
9 unsigned long tmio_flags; 12 unsigned long tmio_flags;
13 unsigned long tmio_caps;
10 u32 tmio_ocr_mask; /* available MMC voltages */ 14 u32 tmio_ocr_mask; /* available MMC voltages */
15 struct tmio_mmc_data *pdata;
11 void (*set_pwr)(struct platform_device *pdev, int state); 16 void (*set_pwr)(struct platform_device *pdev, int state);
17 int (*get_cd)(struct platform_device *pdev);
12}; 18};
13 19
14#endif /* __SH_MOBILE_SDHI_H__ */ 20#endif /* __SH_MOBILE_SDHI_H__ */
diff --git a/include/linux/mmc/tmio.h b/include/linux/mmc/tmio.h
new file mode 100644
index 000000000000..19490b942db0
--- /dev/null
+++ b/include/linux/mmc/tmio.h
@@ -0,0 +1,63 @@
1/*
2 * include/linux/mmc/tmio.h
3 *
4 * Copyright (C) 2007 Ian Molton
5 * Copyright (C) 2004 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Driver for the MMC / SD / SDIO cell found in:
12 *
13 * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
14 */
15#ifndef _LINUX_MMC_TMIO_H_
16#define _LINUX_MMC_TMIO_H_
17
18#define CTL_SD_CMD 0x00
19#define CTL_ARG_REG 0x04
20#define CTL_STOP_INTERNAL_ACTION 0x08
21#define CTL_XFER_BLK_COUNT 0xa
22#define CTL_RESPONSE 0x0c
23#define CTL_STATUS 0x1c
24#define CTL_IRQ_MASK 0x20
25#define CTL_SD_CARD_CLK_CTL 0x24
26#define CTL_SD_XFER_LEN 0x26
27#define CTL_SD_MEM_CARD_OPT 0x28
28#define CTL_SD_ERROR_DETAIL_STATUS 0x2c
29#define CTL_SD_DATA_PORT 0x30
30#define CTL_TRANSACTION_CTL 0x34
31#define CTL_SDIO_STATUS 0x36
32#define CTL_SDIO_IRQ_MASK 0x38
33#define CTL_RESET_SD 0xe0
34#define CTL_SDIO_REGS 0x100
35#define CTL_CLK_AND_WAIT_CTL 0x138
36#define CTL_RESET_SDIO 0x1e0
37
38/* Definitions for values the CTRL_STATUS register can take. */
39#define TMIO_STAT_CMDRESPEND 0x00000001
40#define TMIO_STAT_DATAEND 0x00000004
41#define TMIO_STAT_CARD_REMOVE 0x00000008
42#define TMIO_STAT_CARD_INSERT 0x00000010
43#define TMIO_STAT_SIGSTATE 0x00000020
44#define TMIO_STAT_WRPROTECT 0x00000080
45#define TMIO_STAT_CARD_REMOVE_A 0x00000100
46#define TMIO_STAT_CARD_INSERT_A 0x00000200
47#define TMIO_STAT_SIGSTATE_A 0x00000400
48#define TMIO_STAT_CMD_IDX_ERR 0x00010000
49#define TMIO_STAT_CRCFAIL 0x00020000
50#define TMIO_STAT_STOPBIT_ERR 0x00040000
51#define TMIO_STAT_DATATIMEOUT 0x00080000
52#define TMIO_STAT_RXOVERFLOW 0x00100000
53#define TMIO_STAT_TXUNDERRUN 0x00200000
54#define TMIO_STAT_CMDTIMEOUT 0x00400000
55#define TMIO_STAT_RXRDY 0x01000000
56#define TMIO_STAT_TXRQ 0x02000000
57#define TMIO_STAT_ILL_FUNC 0x20000000
58#define TMIO_STAT_CMD_BUSY 0x40000000
59#define TMIO_STAT_ILL_ACCESS 0x80000000
60
61#define TMIO_BBS 512 /* Boot block size */
62
63#endif /* _LINUX_MMC_TMIO_H_ */
diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
index 4e02ee2b071e..1d1b1e13f79f 100644
--- a/include/linux/mmu_notifier.h
+++ b/include/linux/mmu_notifier.h
@@ -62,6 +62,16 @@ struct mmu_notifier_ops {
62 unsigned long address); 62 unsigned long address);
63 63
64 /* 64 /*
65 * test_young is called to check the young/accessed bitflag in
66 * the secondary pte. This is used to know if the page is
67 * frequently used without actually clearing the flag or tearing
68 * down the secondary mapping on the page.
69 */
70 int (*test_young)(struct mmu_notifier *mn,
71 struct mm_struct *mm,
72 unsigned long address);
73
74 /*
65 * change_pte is called in cases that pte mapping to page is changed: 75 * change_pte is called in cases that pte mapping to page is changed:
66 * for example, when ksm remaps pte to point to a new shared page. 76 * for example, when ksm remaps pte to point to a new shared page.
67 */ 77 */
@@ -140,7 +150,7 @@ struct mmu_notifier_ops {
140 * Therefore notifier chains can only be traversed when either 150 * Therefore notifier chains can only be traversed when either
141 * 151 *
142 * 1. mmap_sem is held. 152 * 1. mmap_sem is held.
143 * 2. One of the reverse map locks is held (i_mmap_lock or anon_vma->lock). 153 * 2. One of the reverse map locks is held (i_mmap_mutex or anon_vma->mutex).
144 * 3. No other concurrent thread can access the list (release) 154 * 3. No other concurrent thread can access the list (release)
145 */ 155 */
146struct mmu_notifier { 156struct mmu_notifier {
@@ -163,6 +173,8 @@ extern void __mmu_notifier_mm_destroy(struct mm_struct *mm);
163extern void __mmu_notifier_release(struct mm_struct *mm); 173extern void __mmu_notifier_release(struct mm_struct *mm);
164extern int __mmu_notifier_clear_flush_young(struct mm_struct *mm, 174extern int __mmu_notifier_clear_flush_young(struct mm_struct *mm,
165 unsigned long address); 175 unsigned long address);
176extern int __mmu_notifier_test_young(struct mm_struct *mm,
177 unsigned long address);
166extern void __mmu_notifier_change_pte(struct mm_struct *mm, 178extern void __mmu_notifier_change_pte(struct mm_struct *mm,
167 unsigned long address, pte_t pte); 179 unsigned long address, pte_t pte);
168extern void __mmu_notifier_invalidate_page(struct mm_struct *mm, 180extern void __mmu_notifier_invalidate_page(struct mm_struct *mm,
@@ -186,6 +198,14 @@ static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
186 return 0; 198 return 0;
187} 199}
188 200
201static inline int mmu_notifier_test_young(struct mm_struct *mm,
202 unsigned long address)
203{
204 if (mm_has_notifiers(mm))
205 return __mmu_notifier_test_young(mm, address);
206 return 0;
207}
208
189static inline void mmu_notifier_change_pte(struct mm_struct *mm, 209static inline void mmu_notifier_change_pte(struct mm_struct *mm,
190 unsigned long address, pte_t pte) 210 unsigned long address, pte_t pte)
191{ 211{
@@ -227,7 +247,7 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
227 247
228/* 248/*
229 * These two macros will sometime replace ptep_clear_flush. 249 * These two macros will sometime replace ptep_clear_flush.
230 * ptep_clear_flush is impleemnted as macro itself, so this also is 250 * ptep_clear_flush is implemented as macro itself, so this also is
231 * implemented as a macro until ptep_clear_flush will converted to an 251 * implemented as a macro until ptep_clear_flush will converted to an
232 * inline function, to diminish the risk of compilation failure. The 252 * inline function, to diminish the risk of compilation failure. The
233 * invalidate_page method over time can be moved outside the PT lock 253 * invalidate_page method over time can be moved outside the PT lock
@@ -243,6 +263,32 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
243 __pte; \ 263 __pte; \
244}) 264})
245 265
266#define pmdp_clear_flush_notify(__vma, __address, __pmdp) \
267({ \
268 pmd_t __pmd; \
269 struct vm_area_struct *___vma = __vma; \
270 unsigned long ___address = __address; \
271 VM_BUG_ON(__address & ~HPAGE_PMD_MASK); \
272 mmu_notifier_invalidate_range_start(___vma->vm_mm, ___address, \
273 (__address)+HPAGE_PMD_SIZE);\
274 __pmd = pmdp_clear_flush(___vma, ___address, __pmdp); \
275 mmu_notifier_invalidate_range_end(___vma->vm_mm, ___address, \
276 (__address)+HPAGE_PMD_SIZE); \
277 __pmd; \
278})
279
280#define pmdp_splitting_flush_notify(__vma, __address, __pmdp) \
281({ \
282 struct vm_area_struct *___vma = __vma; \
283 unsigned long ___address = __address; \
284 VM_BUG_ON(__address & ~HPAGE_PMD_MASK); \
285 mmu_notifier_invalidate_range_start(___vma->vm_mm, ___address, \
286 (__address)+HPAGE_PMD_SIZE);\
287 pmdp_splitting_flush(___vma, ___address, __pmdp); \
288 mmu_notifier_invalidate_range_end(___vma->vm_mm, ___address, \
289 (__address)+HPAGE_PMD_SIZE); \
290})
291
246#define ptep_clear_flush_young_notify(__vma, __address, __ptep) \ 292#define ptep_clear_flush_young_notify(__vma, __address, __ptep) \
247({ \ 293({ \
248 int __young; \ 294 int __young; \
@@ -254,6 +300,17 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
254 __young; \ 300 __young; \
255}) 301})
256 302
303#define pmdp_clear_flush_young_notify(__vma, __address, __pmdp) \
304({ \
305 int __young; \
306 struct vm_area_struct *___vma = __vma; \
307 unsigned long ___address = __address; \
308 __young = pmdp_clear_flush_young(___vma, ___address, __pmdp); \
309 __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \
310 ___address); \
311 __young; \
312})
313
257#define set_pte_at_notify(__mm, __address, __ptep, __pte) \ 314#define set_pte_at_notify(__mm, __address, __ptep, __pte) \
258({ \ 315({ \
259 struct mm_struct *___mm = __mm; \ 316 struct mm_struct *___mm = __mm; \
@@ -276,6 +333,12 @@ static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
276 return 0; 333 return 0;
277} 334}
278 335
336static inline int mmu_notifier_test_young(struct mm_struct *mm,
337 unsigned long address)
338{
339 return 0;
340}
341
279static inline void mmu_notifier_change_pte(struct mm_struct *mm, 342static inline void mmu_notifier_change_pte(struct mm_struct *mm,
280 unsigned long address, pte_t pte) 343 unsigned long address, pte_t pte)
281{ 344{
@@ -305,7 +368,10 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
305} 368}
306 369
307#define ptep_clear_flush_young_notify ptep_clear_flush_young 370#define ptep_clear_flush_young_notify ptep_clear_flush_young
371#define pmdp_clear_flush_young_notify pmdp_clear_flush_young
308#define ptep_clear_flush_notify ptep_clear_flush 372#define ptep_clear_flush_notify ptep_clear_flush
373#define pmdp_clear_flush_notify pmdp_clear_flush
374#define pmdp_splitting_flush_notify pmdp_splitting_flush
309#define set_pte_at_notify set_pte_at 375#define set_pte_at_notify set_pte_at
310 376
311#endif /* CONFIG_MMU_NOTIFIER */ 377#endif /* CONFIG_MMU_NOTIFIER */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 3984c4eb41fd..9f7c3ebcbbad 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -104,6 +104,8 @@ enum zone_stat_item {
104 NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */ 104 NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */
105 NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */ 105 NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */
106 NR_SHMEM, /* shmem pages (included tmpfs/GEM pages) */ 106 NR_SHMEM, /* shmem pages (included tmpfs/GEM pages) */
107 NR_DIRTIED, /* page dirtyings since bootup */
108 NR_WRITTEN, /* page writings since bootup */
107#ifdef CONFIG_NUMA 109#ifdef CONFIG_NUMA
108 NUMA_HIT, /* allocated in intended node */ 110 NUMA_HIT, /* allocated in intended node */
109 NUMA_MISS, /* allocated in non intended node */ 111 NUMA_MISS, /* allocated in non intended node */
@@ -112,6 +114,7 @@ enum zone_stat_item {
112 NUMA_LOCAL, /* allocation from local node */ 114 NUMA_LOCAL, /* allocation from local node */
113 NUMA_OTHER, /* allocation from other node */ 115 NUMA_OTHER, /* allocation from other node */
114#endif 116#endif
117 NR_ANON_TRANSPARENT_HUGEPAGES,
115 NR_VM_ZONE_STAT_ITEMS }; 118 NR_VM_ZONE_STAT_ITEMS };
116 119
117/* 120/*
@@ -270,11 +273,6 @@ struct zone_reclaim_stat {
270 */ 273 */
271 unsigned long recent_rotated[2]; 274 unsigned long recent_rotated[2];
272 unsigned long recent_scanned[2]; 275 unsigned long recent_scanned[2];
273
274 /*
275 * accumulated for batching
276 */
277 unsigned long nr_saved_scan[NR_LRU_LISTS];
278}; 276};
279 277
280struct zone { 278struct zone {
@@ -421,6 +419,9 @@ struct zone {
421typedef enum { 419typedef enum {
422 ZONE_RECLAIM_LOCKED, /* prevents concurrent reclaim */ 420 ZONE_RECLAIM_LOCKED, /* prevents concurrent reclaim */
423 ZONE_OOM_LOCKED, /* zone is in OOM killer zonelist */ 421 ZONE_OOM_LOCKED, /* zone is in OOM killer zonelist */
422 ZONE_CONGESTED, /* zone has many dirty pages backed by
423 * a congested BDI
424 */
424} zone_flags_t; 425} zone_flags_t;
425 426
426static inline void zone_set_flag(struct zone *zone, zone_flags_t flag) 427static inline void zone_set_flag(struct zone *zone, zone_flags_t flag)
@@ -438,6 +439,11 @@ static inline void zone_clear_flag(struct zone *zone, zone_flags_t flag)
438 clear_bit(flag, &zone->flags); 439 clear_bit(flag, &zone->flags);
439} 440}
440 441
442static inline int zone_is_reclaim_congested(const struct zone *zone)
443{
444 return test_bit(ZONE_CONGESTED, &zone->flags);
445}
446
441static inline int zone_is_reclaim_locked(const struct zone *zone) 447static inline int zone_is_reclaim_locked(const struct zone *zone)
442{ 448{
443 return test_bit(ZONE_RECLAIM_LOCKED, &zone->flags); 449 return test_bit(ZONE_RECLAIM_LOCKED, &zone->flags);
@@ -448,12 +454,6 @@ static inline int zone_is_oom_locked(const struct zone *zone)
448 return test_bit(ZONE_OOM_LOCKED, &zone->flags); 454 return test_bit(ZONE_OOM_LOCKED, &zone->flags);
449} 455}
450 456
451#ifdef CONFIG_SMP
452unsigned long zone_nr_free_pages(struct zone *zone);
453#else
454#define zone_nr_free_pages(zone) zone_page_state(zone, NR_FREE_PAGES)
455#endif /* CONFIG_SMP */
456
457/* 457/*
458 * The "priority" of VM scanning is how much of the queues we will scan in one 458 * The "priority" of VM scanning is how much of the queues we will scan in one
459 * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the 459 * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
@@ -467,7 +467,7 @@ unsigned long zone_nr_free_pages(struct zone *zone);
467#ifdef CONFIG_NUMA 467#ifdef CONFIG_NUMA
468 468
469/* 469/*
470 * The NUMA zonelists are doubled becausse we need zonelists that restrict the 470 * The NUMA zonelists are doubled because we need zonelists that restrict the
471 * allocations to a single node for GFP_THISNODE. 471 * allocations to a single node for GFP_THISNODE.
472 * 472 *
473 * [0] : Zonelist with fallback 473 * [0] : Zonelist with fallback
@@ -635,6 +635,7 @@ typedef struct pglist_data {
635 wait_queue_head_t kswapd_wait; 635 wait_queue_head_t kswapd_wait;
636 struct task_struct *kswapd; 636 struct task_struct *kswapd;
637 int kswapd_max_order; 637 int kswapd_max_order;
638 enum zone_type classzone_idx;
638} pg_data_t; 639} pg_data_t;
639 640
640#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages) 641#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)
@@ -646,12 +647,21 @@ typedef struct pglist_data {
646#endif 647#endif
647#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr)) 648#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
648 649
650#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
651
652#define node_end_pfn(nid) ({\
653 pg_data_t *__pgdat = NODE_DATA(nid);\
654 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
655})
656
649#include <linux/memory_hotplug.h> 657#include <linux/memory_hotplug.h>
650 658
651extern struct mutex zonelists_mutex; 659extern struct mutex zonelists_mutex;
652void build_all_zonelists(void *data); 660void build_all_zonelists(void *data);
653void wakeup_kswapd(struct zone *zone, int order); 661void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx);
654int zone_watermark_ok(struct zone *z, int order, unsigned long mark, 662bool zone_watermark_ok(struct zone *z, int order, unsigned long mark,
663 int classzone_idx, int alloc_flags);
664bool zone_watermark_ok_safe(struct zone *z, int order, unsigned long mark,
655 int classzone_idx, int alloc_flags); 665 int classzone_idx, int alloc_flags);
656enum memmap_context { 666enum memmap_context {
657 MEMMAP_EARLY, 667 MEMMAP_EARLY,
@@ -920,9 +930,6 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)
920#define pfn_to_nid(pfn) (0) 930#define pfn_to_nid(pfn) (0)
921#endif 931#endif
922 932
923#define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT)
924#define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT)
925
926#ifdef CONFIG_SPARSEMEM 933#ifdef CONFIG_SPARSEMEM
927 934
928/* 935/*
@@ -948,6 +955,12 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)
948#error Allocator MAX_ORDER exceeds SECTION_SIZE 955#error Allocator MAX_ORDER exceeds SECTION_SIZE
949#endif 956#endif
950 957
958#define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT)
959#define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT)
960
961#define SECTION_ALIGN_UP(pfn) (((pfn) + PAGES_PER_SECTION - 1) & PAGE_SECTION_MASK)
962#define SECTION_ALIGN_DOWN(pfn) ((pfn) & PAGE_SECTION_MASK)
963
951struct page; 964struct page;
952struct page_cgroup; 965struct page_cgroup;
953struct mem_section { 966struct mem_section {
@@ -1045,12 +1058,14 @@ static inline struct mem_section *__pfn_to_section(unsigned long pfn)
1045 return __nr_to_section(pfn_to_section_nr(pfn)); 1058 return __nr_to_section(pfn_to_section_nr(pfn));
1046} 1059}
1047 1060
1061#ifndef CONFIG_HAVE_ARCH_PFN_VALID
1048static inline int pfn_valid(unsigned long pfn) 1062static inline int pfn_valid(unsigned long pfn)
1049{ 1063{
1050 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) 1064 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
1051 return 0; 1065 return 0;
1052 return valid_section(__nr_to_section(pfn_to_section_nr(pfn))); 1066 return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));
1053} 1067}
1068#endif
1054 1069
1055static inline int pfn_present(unsigned long pfn) 1070static inline int pfn_present(unsigned long pfn)
1056{ 1071{
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 48c007dae476..ae28e93fd072 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -382,6 +382,23 @@ struct ssb_device_id {
382#define SSB_ANY_ID 0xFFFF 382#define SSB_ANY_ID 0xFFFF
383#define SSB_ANY_REV 0xFF 383#define SSB_ANY_REV 0xFF
384 384
385/* Broadcom's specific AMBA core, see drivers/bcma/ */
386struct bcma_device_id {
387 __u16 manuf;
388 __u16 id;
389 __u8 rev;
390 __u8 class;
391};
392#define BCMA_CORE(_manuf, _id, _rev, _class) \
393 { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, }
394#define BCMA_CORETABLE_END \
395 { 0, },
396
397#define BCMA_ANY_MANUF 0xFFFF
398#define BCMA_ANY_ID 0xFFFF
399#define BCMA_ANY_REV 0xFF
400#define BCMA_ANY_CLASS 0xFF
401
385struct virtio_device_id { 402struct virtio_device_id {
386 __u32 device; 403 __u32 device;
387 __u32 vendor; 404 __u32 vendor;
diff --git a/include/linux/module.h b/include/linux/module.h
index aace066bad8f..d9ca2d5dc6d0 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -58,6 +58,15 @@ struct module_attribute {
58 void (*free)(struct module *); 58 void (*free)(struct module *);
59}; 59};
60 60
61struct module_version_attribute {
62 struct module_attribute mattr;
63 const char *module_name;
64 const char *version;
65} __attribute__ ((__aligned__(sizeof(void *))));
66
67extern ssize_t __modver_version_show(struct module_attribute *,
68 struct module *, char *);
69
61struct module_kobject 70struct module_kobject
62{ 71{
63 struct kobject kobj; 72 struct kobject kobj;
@@ -161,7 +170,26 @@ extern struct module __this_module;
161 Using this automatically adds a checksum of the .c files and the 170 Using this automatically adds a checksum of the .c files and the
162 local headers in "srcversion". 171 local headers in "srcversion".
163*/ 172*/
173
174#if defined(MODULE) || !defined(CONFIG_SYSFS)
164#define MODULE_VERSION(_version) MODULE_INFO(version, _version) 175#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
176#else
177#define MODULE_VERSION(_version) \
178 static struct module_version_attribute ___modver_attr = { \
179 .mattr = { \
180 .attr = { \
181 .name = "version", \
182 .mode = S_IRUGO, \
183 }, \
184 .show = __modver_version_show, \
185 }, \
186 .module_name = KBUILD_MODNAME, \
187 .version = _version, \
188 }; \
189 static const struct module_version_attribute \
190 __used __attribute__ ((__section__ ("__modver"))) \
191 * __moduleparam_const __modver_attr = &___modver_attr
192#endif
165 193
166/* Optional firmware file (or files) needed by the module 194/* Optional firmware file (or files) needed by the module
167 * format is simply firmware file name. Multiple firmware 195 * format is simply firmware file name. Multiple firmware
@@ -196,7 +224,7 @@ struct module_use {
196 extern void *__crc_##sym __attribute__((weak)); \ 224 extern void *__crc_##sym __attribute__((weak)); \
197 static const unsigned long __kcrctab_##sym \ 225 static const unsigned long __kcrctab_##sym \
198 __used \ 226 __used \
199 __attribute__((section("__kcrctab" sec), unused)) \ 227 __attribute__((section("___kcrctab" sec "+" #sym), unused)) \
200 = (unsigned long) &__crc_##sym; 228 = (unsigned long) &__crc_##sym;
201#else 229#else
202#define __CRC_SYMBOL(sym, sec) 230#define __CRC_SYMBOL(sym, sec)
@@ -211,7 +239,7 @@ struct module_use {
211 = MODULE_SYMBOL_PREFIX #sym; \ 239 = MODULE_SYMBOL_PREFIX #sym; \
212 static const struct kernel_symbol __ksymtab_##sym \ 240 static const struct kernel_symbol __ksymtab_##sym \
213 __used \ 241 __used \
214 __attribute__((section("__ksymtab" sec), unused)) \ 242 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
215 = { (unsigned long)&sym, __kstrtab_##sym } 243 = { (unsigned long)&sym, __kstrtab_##sym }
216 244
217#define EXPORT_SYMBOL(sym) \ 245#define EXPORT_SYMBOL(sym) \
@@ -308,6 +336,9 @@ struct module
308 /* The size of the executable code in each section. */ 336 /* The size of the executable code in each section. */
309 unsigned int init_text_size, core_text_size; 337 unsigned int init_text_size, core_text_size;
310 338
339 /* Size of RO sections of the module (text+rodata) */
340 unsigned int init_ro_size, core_ro_size;
341
311 /* Arch-specific module values */ 342 /* Arch-specific module values */
312 struct mod_arch_specific arch; 343 struct mod_arch_specific arch;
313 344
@@ -337,31 +368,35 @@ struct module
337 struct module_notes_attrs *notes_attrs; 368 struct module_notes_attrs *notes_attrs;
338#endif 369#endif
339 370
371 /* The command line arguments (may be mangled). People like
372 keeping pointers to this stuff */
373 char *args;
374
340#ifdef CONFIG_SMP 375#ifdef CONFIG_SMP
341 /* Per-cpu data. */ 376 /* Per-cpu data. */
342 void __percpu *percpu; 377 void __percpu *percpu;
343 unsigned int percpu_size; 378 unsigned int percpu_size;
344#endif 379#endif
345 380
346 /* The command line arguments (may be mangled). People like
347 keeping pointers to this stuff */
348 char *args;
349#ifdef CONFIG_TRACEPOINTS 381#ifdef CONFIG_TRACEPOINTS
350 struct tracepoint *tracepoints;
351 unsigned int num_tracepoints; 382 unsigned int num_tracepoints;
383 struct tracepoint * const *tracepoints_ptrs;
384#endif
385#ifdef HAVE_JUMP_LABEL
386 struct jump_entry *jump_entries;
387 unsigned int num_jump_entries;
352#endif 388#endif
353
354#ifdef CONFIG_TRACING 389#ifdef CONFIG_TRACING
355 const char **trace_bprintk_fmt_start;
356 unsigned int num_trace_bprintk_fmt; 390 unsigned int num_trace_bprintk_fmt;
391 const char **trace_bprintk_fmt_start;
357#endif 392#endif
358#ifdef CONFIG_EVENT_TRACING 393#ifdef CONFIG_EVENT_TRACING
359 struct ftrace_event_call *trace_events; 394 struct ftrace_event_call **trace_events;
360 unsigned int num_trace_events; 395 unsigned int num_trace_events;
361#endif 396#endif
362#ifdef CONFIG_FTRACE_MCOUNT_RECORD 397#ifdef CONFIG_FTRACE_MCOUNT_RECORD
363 unsigned long *ftrace_callsites;
364 unsigned int num_ftrace_callsites; 398 unsigned int num_ftrace_callsites;
399 unsigned long *ftrace_callsites;
365#endif 400#endif
366 401
367#ifdef CONFIG_MODULE_UNLOAD 402#ifdef CONFIG_MODULE_UNLOAD
@@ -442,8 +477,9 @@ const struct kernel_symbol *find_symbol(const char *name,
442 bool warn); 477 bool warn);
443 478
444/* Walk the exported symbol table */ 479/* Walk the exported symbol table */
445bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner, 480bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
446 unsigned int symnum, void *data), void *data); 481 struct module *owner,
482 void *data), void *data);
447 483
448/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if 484/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
449 symnum out of range. */ 485 symnum out of range. */
@@ -514,7 +550,7 @@ static inline void __module_get(struct module *module)
514#define symbol_put_addr(p) do { } while(0) 550#define symbol_put_addr(p) do { } while(0)
515 551
516#endif /* CONFIG_MODULE_UNLOAD */ 552#endif /* CONFIG_MODULE_UNLOAD */
517int use_module(struct module *a, struct module *b); 553int ref_module(struct module *a, struct module *b);
518 554
519/* This is a #define so the string doesn't get put in every .o file */ 555/* This is a #define so the string doesn't get put in every .o file */
520#define module_name(mod) \ 556#define module_name(mod) \
@@ -669,7 +705,6 @@ static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter)
669{ 705{
670 return 0; 706 return 0;
671} 707}
672
673#endif /* CONFIG_MODULES */ 708#endif /* CONFIG_MODULES */
674 709
675#ifdef CONFIG_SYSFS 710#ifdef CONFIG_SYSFS
@@ -684,6 +719,13 @@ extern int module_sysfs_initialized;
684 719
685#define __MODULE_STRING(x) __stringify(x) 720#define __MODULE_STRING(x) __stringify(x)
686 721
722#ifdef CONFIG_DEBUG_SET_MODULE_RONX
723extern void set_all_modules_text_rw(void);
724extern void set_all_modules_text_ro(void);
725#else
726static inline void set_all_modules_text_rw(void) { }
727static inline void set_all_modules_text_ro(void) { }
728#endif
687 729
688#ifdef CONFIG_GENERIC_BUG 730#ifdef CONFIG_GENERIC_BUG
689void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *, 731void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 9d2f1837b3d8..ddaae98c53f9 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -16,15 +16,17 @@
16/* Chosen so that structs with an unsigned long line up. */ 16/* Chosen so that structs with an unsigned long line up. */
17#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) 17#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
18 18
19#ifdef MODULE
20#define ___module_cat(a,b) __mod_ ## a ## b 19#define ___module_cat(a,b) __mod_ ## a ## b
21#define __module_cat(a,b) ___module_cat(a,b) 20#define __module_cat(a,b) ___module_cat(a,b)
21#ifdef MODULE
22#define __MODULE_INFO(tag, name, info) \ 22#define __MODULE_INFO(tag, name, info) \
23static const char __module_cat(name,__LINE__)[] \ 23static const char __module_cat(name,__LINE__)[] \
24 __used \ 24 __used __attribute__((section(".modinfo"), unused, aligned(1))) \
25 __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info 25 = __stringify(tag) "=" info
26#else /* !MODULE */ 26#else /* !MODULE */
27#define __MODULE_INFO(tag, name, info) 27/* This struct is here for syntactic coherency, it is not used */
28#define __MODULE_INFO(tag, name, info) \
29 struct __module_cat(name,__LINE__) {}
28#endif 30#endif
29#define __MODULE_PARM_TYPE(name, _type) \ 31#define __MODULE_PARM_TYPE(name, _type) \
30 __MODULE_INFO(parmtype, name##type, #name ":" _type) 32 __MODULE_INFO(parmtype, name##type, #name ":" _type)
@@ -65,9 +67,9 @@ struct kparam_string {
65struct kparam_array 67struct kparam_array
66{ 68{
67 unsigned int max; 69 unsigned int max;
70 unsigned int elemsize;
68 unsigned int *num; 71 unsigned int *num;
69 const struct kernel_param_ops *ops; 72 const struct kernel_param_ops *ops;
70 unsigned int elemsize;
71 void *elem; 73 void *elem;
72}; 74};
73 75
@@ -369,8 +371,9 @@ extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
369 */ 371 */
370#define module_param_array_named(name, array, type, nump, perm) \ 372#define module_param_array_named(name, array, type, nump, perm) \
371 static const struct kparam_array __param_arr_##name \ 373 static const struct kparam_array __param_arr_##name \
372 = { ARRAY_SIZE(array), nump, &param_ops_##type, \ 374 = { .max = ARRAY_SIZE(array), .num = nump, \
373 sizeof(array[0]), array }; \ 375 .ops = &param_ops_##type, \
376 .elemsize = sizeof(array[0]), .elem = array }; \
374 __module_param_call(MODULE_PARAM_PREFIX, name, \ 377 __module_param_call(MODULE_PARAM_PREFIX, name, \
375 &param_array_ops, \ 378 &param_array_ops, \
376 .arr = &__param_arr_##name, \ 379 .arr = &__param_arr_##name, \
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 5e7a59408dd4..604f122a2326 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -13,6 +13,7 @@
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/nodemask.h> 14#include <linux/nodemask.h>
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <linux/seqlock.h>
16#include <asm/atomic.h> 17#include <asm/atomic.h>
17 18
18struct super_block; 19struct super_block;
@@ -46,12 +47,24 @@ struct mnt_namespace;
46 47
47#define MNT_INTERNAL 0x4000 48#define MNT_INTERNAL 0x4000
48 49
50struct mnt_pcp {
51 int mnt_count;
52 int mnt_writers;
53};
54
49struct vfsmount { 55struct vfsmount {
50 struct list_head mnt_hash; 56 struct list_head mnt_hash;
51 struct vfsmount *mnt_parent; /* fs we are mounted on */ 57 struct vfsmount *mnt_parent; /* fs we are mounted on */
52 struct dentry *mnt_mountpoint; /* dentry of mountpoint */ 58 struct dentry *mnt_mountpoint; /* dentry of mountpoint */
53 struct dentry *mnt_root; /* root of the mounted tree */ 59 struct dentry *mnt_root; /* root of the mounted tree */
54 struct super_block *mnt_sb; /* pointer to superblock */ 60 struct super_block *mnt_sb; /* pointer to superblock */
61#ifdef CONFIG_SMP
62 struct mnt_pcp __percpu *mnt_pcp;
63 atomic_t mnt_longterm; /* how many of the refs are longterm */
64#else
65 int mnt_count;
66 int mnt_writers;
67#endif
55 struct list_head mnt_mounts; /* list of children, anchored here */ 68 struct list_head mnt_mounts; /* list of children, anchored here */
56 struct list_head mnt_child; /* and going through their mnt_child */ 69 struct list_head mnt_child; /* and going through their mnt_child */
57 int mnt_flags; 70 int mnt_flags;
@@ -70,57 +83,23 @@ struct vfsmount {
70 struct mnt_namespace *mnt_ns; /* containing namespace */ 83 struct mnt_namespace *mnt_ns; /* containing namespace */
71 int mnt_id; /* mount identifier */ 84 int mnt_id; /* mount identifier */
72 int mnt_group_id; /* peer group identifier */ 85 int mnt_group_id; /* peer group identifier */
73 /*
74 * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount
75 * to let these frequently modified fields in a separate cache line
76 * (so that reads of mnt_flags wont ping-pong on SMP machines)
77 */
78 atomic_t mnt_count;
79 int mnt_expiry_mark; /* true if marked for expiry */ 86 int mnt_expiry_mark; /* true if marked for expiry */
80 int mnt_pinned; 87 int mnt_pinned;
81 int mnt_ghosts; 88 int mnt_ghosts;
82#ifdef CONFIG_SMP
83 int __percpu *mnt_writers;
84#else
85 int mnt_writers;
86#endif
87}; 89};
88 90
89static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
90{
91#ifdef CONFIG_SMP
92 return mnt->mnt_writers;
93#else
94 return &mnt->mnt_writers;
95#endif
96}
97
98static inline struct vfsmount *mntget(struct vfsmount *mnt)
99{
100 if (mnt)
101 atomic_inc(&mnt->mnt_count);
102 return mnt;
103}
104
105struct file; /* forward dec */ 91struct file; /* forward dec */
106 92
107extern int mnt_want_write(struct vfsmount *mnt); 93extern int mnt_want_write(struct vfsmount *mnt);
108extern int mnt_want_write_file(struct file *file); 94extern int mnt_want_write_file(struct file *file);
109extern int mnt_clone_write(struct vfsmount *mnt); 95extern int mnt_clone_write(struct vfsmount *mnt);
110extern void mnt_drop_write(struct vfsmount *mnt); 96extern void mnt_drop_write(struct vfsmount *mnt);
111extern void mntput_no_expire(struct vfsmount *mnt); 97extern void mntput(struct vfsmount *mnt);
98extern struct vfsmount *mntget(struct vfsmount *mnt);
112extern void mnt_pin(struct vfsmount *mnt); 99extern void mnt_pin(struct vfsmount *mnt);
113extern void mnt_unpin(struct vfsmount *mnt); 100extern void mnt_unpin(struct vfsmount *mnt);
114extern int __mnt_is_readonly(struct vfsmount *mnt); 101extern int __mnt_is_readonly(struct vfsmount *mnt);
115 102
116static inline void mntput(struct vfsmount *mnt)
117{
118 if (mnt) {
119 mnt->mnt_expiry_mark = 0;
120 mntput_no_expire(mnt);
121 }
122}
123
124extern struct vfsmount *do_kern_mount(const char *fstype, int flags, 103extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
125 const char *name, void *data); 104 const char *name, void *data);
126 105
@@ -129,12 +108,7 @@ extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
129 int flags, const char *name, 108 int flags, const char *name,
130 void *data); 109 void *data);
131 110
132struct nameidata; 111extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
133
134struct path;
135extern int do_add_mount(struct vfsmount *newmnt, struct path *path,
136 int mnt_flags, struct list_head *fslist);
137
138extern void mark_mounts_for_expiry(struct list_head *mounts); 112extern void mark_mounts_for_expiry(struct list_head *mounts);
139 113
140extern dev_t name_to_dev_t(char *name); 114extern dev_t name_to_dev_t(char *name);
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
index fa04b246c9ae..46caaf44339d 100644
--- a/include/linux/mroute.h
+++ b/include/linux/mroute.h
@@ -150,6 +150,7 @@ static inline int ip_mroute_opt(int opt)
150extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); 150extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
151extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); 151extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
152extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); 152extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
153extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
153extern int ip_mr_init(void); 154extern int ip_mr_init(void);
154#else 155#else
155static inline 156static inline
@@ -213,6 +214,7 @@ struct mfc_cache {
213 unsigned char ttls[MAXVIFS]; /* TTL thresholds */ 214 unsigned char ttls[MAXVIFS]; /* TTL thresholds */
214 } res; 215 } res;
215 } mfc_un; 216 } mfc_un;
217 struct rcu_head rcu;
216}; 218};
217 219
218#define MFC_STATIC 1 220#define MFC_STATIC 1
@@ -242,6 +244,7 @@ struct mfc_cache {
242#ifdef __KERNEL__ 244#ifdef __KERNEL__
243struct rtmsg; 245struct rtmsg;
244extern int ipmr_get_route(struct net *net, struct sk_buff *skb, 246extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
247 __be32 saddr, __be32 daddr,
245 struct rtmsg *rtm, int nowait); 248 struct rtmsg *rtm, int nowait);
246#endif 249#endif
247 250
diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h
index 6091ab77f388..a3759cb0ac10 100644
--- a/include/linux/mroute6.h
+++ b/include/linux/mroute6.h
@@ -136,6 +136,7 @@ extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int
136extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); 136extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
137extern int ip6_mr_input(struct sk_buff *skb); 137extern int ip6_mr_input(struct sk_buff *skb);
138extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); 138extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
139extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
139extern int ip6_mr_init(void); 140extern int ip6_mr_init(void);
140extern void ip6_mr_cleanup(void); 141extern void ip6_mr_cleanup(void);
141#else 142#else
@@ -248,7 +249,7 @@ static inline int ip6mr_sk_done(struct sock *sk)
248 * Structure used to communicate from kernel to multicast router. 249 * Structure used to communicate from kernel to multicast router.
249 * We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{} 250 * We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{}
250 * used for IPv4 implementation). This is because this structure will be passed via an 251 * used for IPv4 implementation). This is because this structure will be passed via an
251 * IPv6 raw socket, on wich an application will only receiver the payload i.e the data after 252 * IPv6 raw socket, on which an application will only receiver the payload i.e the data after
252 * the IPv6 header and all the extension headers. (See section 3 of RFC 3542) 253 * the IPv6 header and all the extension headers. (See section 3 of RFC 3542)
253 */ 254 */
254 255
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 91b05c171854..05acced439a3 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -10,12 +10,13 @@ struct msi_msg {
10}; 10};
11 11
12/* Helper functions */ 12/* Helper functions */
13struct irq_desc; 13struct irq_data;
14extern void mask_msi_irq(unsigned int irq); 14struct msi_desc;
15extern void unmask_msi_irq(unsigned int irq); 15extern void mask_msi_irq(struct irq_data *data);
16extern void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg); 16extern void unmask_msi_irq(struct irq_data *data);
17extern void get_cached_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg); 17extern void __read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
18extern void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg); 18extern void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
19extern void __write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
19extern void read_msi_msg(unsigned int irq, struct msi_msg *msg); 20extern void read_msi_msg(unsigned int irq, struct msi_msg *msg);
20extern void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg); 21extern void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
21extern void write_msi_msg(unsigned int irq, struct msi_msg *msg); 22extern void write_msi_msg(unsigned int irq, struct msi_msg *msg);
diff --git a/include/linux/msm_mdp.h b/include/linux/msm_mdp.h
index d11fe0f2f956..fe722c1fb61d 100644
--- a/include/linux/msm_mdp.h
+++ b/include/linux/msm_mdp.h
@@ -32,6 +32,7 @@ enum {
32 MDP_Y_CBCR_H2V1, /* Y and CrCb, pseduo planar w/ Cr is in MSB */ 32 MDP_Y_CBCR_H2V1, /* Y and CrCb, pseduo planar w/ Cr is in MSB */
33 MDP_RGBA_8888, /* ARGB 888 */ 33 MDP_RGBA_8888, /* ARGB 888 */
34 MDP_BGRA_8888, /* ABGR 888 */ 34 MDP_BGRA_8888, /* ABGR 888 */
35 MDP_RGBX_8888, /* RGBX 888 */
35 MDP_IMGTYPE_LIMIT /* Non valid image type after this enum */ 36 MDP_IMGTYPE_LIMIT /* Non valid image type after this enum */
36}; 37};
37 38
diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h
index 7fa20beb2ab9..57cc0e63714f 100644
--- a/include/linux/mtd/bbm.h
+++ b/include/linux/mtd/bbm.h
@@ -84,7 +84,7 @@ struct nand_bbt_descr {
84#define NAND_BBT_PERCHIP 0x00000080 84#define NAND_BBT_PERCHIP 0x00000080
85/* bbt has a version counter at offset veroffs */ 85/* bbt has a version counter at offset veroffs */
86#define NAND_BBT_VERSION 0x00000100 86#define NAND_BBT_VERSION 0x00000100
87/* Create a bbt if none axists */ 87/* Create a bbt if none exists */
88#define NAND_BBT_CREATE 0x00000200 88#define NAND_BBT_CREATE 0x00000200
89/* Search good / bad pattern through all pages of a block */ 89/* Search good / bad pattern through all pages of a block */
90#define NAND_BBT_SCANALLPAGES 0x00000400 90#define NAND_BBT_SCANALLPAGES 0x00000400
@@ -102,6 +102,8 @@ struct nand_bbt_descr {
102#define NAND_BBT_SCANBYTE1AND6 0x00100000 102#define NAND_BBT_SCANBYTE1AND6 0x00100000
103/* The nand_bbt_descr was created dynamicaly and must be freed */ 103/* The nand_bbt_descr was created dynamicaly and must be freed */
104#define NAND_BBT_DYNAMICSTRUCT 0x00200000 104#define NAND_BBT_DYNAMICSTRUCT 0x00200000
105/* The bad block table does not OOB for marker */
106#define NAND_BBT_NO_OOB 0x00400000
105 107
106/* The maximum number of blocks to scan for a bbt */ 108/* The maximum number of blocks to scan for a bbt */
107#define NAND_BBT_SCAN_MAXBLOCKS 4 109#define NAND_BBT_SCAN_MAXBLOCKS 4
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 26529ebd59cc..1bbd9f289245 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -36,6 +36,7 @@ struct mtd_blktrans_dev {
36 struct mtd_info *mtd; 36 struct mtd_info *mtd;
37 struct mutex lock; 37 struct mutex lock;
38 int devnum; 38 int devnum;
39 bool bg_stop;
39 unsigned long size; 40 unsigned long size;
40 int readonly; 41 int readonly;
41 int open; 42 int open;
@@ -62,6 +63,7 @@ struct mtd_blktrans_ops {
62 unsigned long block, char *buffer); 63 unsigned long block, char *buffer);
63 int (*discard)(struct mtd_blktrans_dev *dev, 64 int (*discard)(struct mtd_blktrans_dev *dev,
64 unsigned long block, unsigned nr_blocks); 65 unsigned long block, unsigned nr_blocks);
66 void (*background)(struct mtd_blktrans_dev *dev);
65 67
66 /* Block layer ioctls */ 68 /* Block layer ioctls */
67 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); 69 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
@@ -85,6 +87,7 @@ extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
85extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr); 87extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
86extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); 88extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
87extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); 89extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev);
90extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev);
88 91
89 92
90#endif /* __MTD_TRANS_H__ */ 93#endif /* __MTD_TRANS_H__ */
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
index d2118b0eac9a..d24925492972 100644
--- a/include/linux/mtd/cfi.h
+++ b/include/linux/mtd/cfi.h
@@ -289,6 +289,7 @@ struct cfi_private {
289 must be of the same type. */ 289 must be of the same type. */
290 int mfr, id; 290 int mfr, id;
291 int numchips; 291 int numchips;
292 map_word sector_erase_cmd;
292 unsigned long chipshift; /* Because they're of the same type */ 293 unsigned long chipshift; /* Because they're of the same type */
293 const char *im_name; /* inter_module name for cmdset_setup */ 294 const char *im_name; /* inter_module name for cmdset_setup */
294 struct flchip chips[0]; /* per-chip data structure for each chip */ 295 struct flchip chips[0]; /* per-chip data structure for each chip */
@@ -307,7 +308,7 @@ static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs,
307 308
308 addr = (cmd_ofs * type) * interleave; 309 addr = (cmd_ofs * type) * interleave;
309 310
310 /* Modify the unlock address if we are in compatiblity mode. 311 /* Modify the unlock address if we are in compatibility mode.
311 * For 16bit devices on 8 bit busses 312 * For 16bit devices on 8 bit busses
312 * and 32bit devices on 16 bit busses 313 * and 32bit devices on 16 bit busses
313 * set the low bit of the alternating bit sequence of the address. 314 * set the low bit of the alternating bit sequence of the address.
@@ -526,8 +527,7 @@ struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t s
526struct cfi_fixup { 527struct cfi_fixup {
527 uint16_t mfr; 528 uint16_t mfr;
528 uint16_t id; 529 uint16_t id;
529 void (*fixup)(struct mtd_info *mtd, void* param); 530 void (*fixup)(struct mtd_info *mtd);
530 void* param;
531}; 531};
532 532
533#define CFI_MFR_ANY 0xFFFF 533#define CFI_MFR_ANY 0xFFFF
@@ -535,6 +535,7 @@ struct cfi_fixup {
535#define CFI_MFR_CONTINUATION 0x007F 535#define CFI_MFR_CONTINUATION 0x007F
536 536
537#define CFI_MFR_AMD 0x0001 537#define CFI_MFR_AMD 0x0001
538#define CFI_MFR_AMIC 0x0037
538#define CFI_MFR_ATMEL 0x001F 539#define CFI_MFR_ATMEL 0x001F
539#define CFI_MFR_EON 0x001C 540#define CFI_MFR_EON 0x001C
540#define CFI_MFR_FUJITSU 0x0004 541#define CFI_MFR_FUJITSU 0x0004
diff --git a/include/linux/mtd/fsmc.h b/include/linux/mtd/fsmc.h
new file mode 100644
index 000000000000..6987995ad3cf
--- /dev/null
+++ b/include/linux/mtd/fsmc.h
@@ -0,0 +1,163 @@
1/*
2 * incude/mtd/fsmc.h
3 *
4 * ST Microelectronics
5 * Flexible Static Memory Controller (FSMC)
6 * platform data interface and header file
7 *
8 * Copyright © 2010 ST Microelectronics
9 * Vipin Kumar <vipin.kumar@st.com>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 */
15
16#ifndef __MTD_FSMC_H
17#define __MTD_FSMC_H
18
19#include <linux/io.h>
20#include <linux/platform_device.h>
21#include <linux/mtd/physmap.h>
22#include <linux/types.h>
23#include <linux/mtd/partitions.h>
24#include <asm/param.h>
25
26#define FSMC_NAND_BW8 1
27#define FSMC_NAND_BW16 2
28
29/*
30 * The placement of the Command Latch Enable (CLE) and
31 * Address Latch Enable (ALE) is twisted around in the
32 * SPEAR310 implementation.
33 */
34#if defined(CONFIG_MACH_SPEAR310)
35#define PLAT_NAND_CLE (1 << 17)
36#define PLAT_NAND_ALE (1 << 16)
37#else
38#define PLAT_NAND_CLE (1 << 16)
39#define PLAT_NAND_ALE (1 << 17)
40#endif
41
42#define FSMC_MAX_NOR_BANKS 4
43#define FSMC_MAX_NAND_BANKS 4
44
45#define FSMC_FLASH_WIDTH8 1
46#define FSMC_FLASH_WIDTH16 2
47
48struct fsmc_nor_bank_regs {
49 uint32_t ctrl;
50 uint32_t ctrl_tim;
51};
52
53/* ctrl register definitions */
54#define BANK_ENABLE (1 << 0)
55#define MUXED (1 << 1)
56#define NOR_DEV (2 << 2)
57#define WIDTH_8 (0 << 4)
58#define WIDTH_16 (1 << 4)
59#define RSTPWRDWN (1 << 6)
60#define WPROT (1 << 7)
61#define WRT_ENABLE (1 << 12)
62#define WAIT_ENB (1 << 13)
63
64/* ctrl_tim register definitions */
65
66struct fsmc_nand_bank_regs {
67 uint32_t pc;
68 uint32_t sts;
69 uint32_t comm;
70 uint32_t attrib;
71 uint32_t ioata;
72 uint32_t ecc1;
73 uint32_t ecc2;
74 uint32_t ecc3;
75};
76
77#define FSMC_NOR_REG_SIZE 0x40
78
79struct fsmc_regs {
80 struct fsmc_nor_bank_regs nor_bank_regs[FSMC_MAX_NOR_BANKS];
81 uint8_t reserved_1[0x40 - 0x20];
82 struct fsmc_nand_bank_regs bank_regs[FSMC_MAX_NAND_BANKS];
83 uint8_t reserved_2[0xfe0 - 0xc0];
84 uint32_t peripid0; /* 0xfe0 */
85 uint32_t peripid1; /* 0xfe4 */
86 uint32_t peripid2; /* 0xfe8 */
87 uint32_t peripid3; /* 0xfec */
88 uint32_t pcellid0; /* 0xff0 */
89 uint32_t pcellid1; /* 0xff4 */
90 uint32_t pcellid2; /* 0xff8 */
91 uint32_t pcellid3; /* 0xffc */
92};
93
94#define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ)
95
96/* pc register definitions */
97#define FSMC_RESET (1 << 0)
98#define FSMC_WAITON (1 << 1)
99#define FSMC_ENABLE (1 << 2)
100#define FSMC_DEVTYPE_NAND (1 << 3)
101#define FSMC_DEVWID_8 (0 << 4)
102#define FSMC_DEVWID_16 (1 << 4)
103#define FSMC_ECCEN (1 << 6)
104#define FSMC_ECCPLEN_512 (0 << 7)
105#define FSMC_ECCPLEN_256 (1 << 7)
106#define FSMC_TCLR_1 (1 << 9)
107#define FSMC_TAR_1 (1 << 13)
108
109/* sts register definitions */
110#define FSMC_CODE_RDY (1 << 15)
111
112/* comm register definitions */
113#define FSMC_TSET_0 (0 << 0)
114#define FSMC_TWAIT_6 (6 << 8)
115#define FSMC_THOLD_4 (4 << 16)
116#define FSMC_THIZ_1 (1 << 24)
117
118/*
119 * There are 13 bytes of ecc for every 512 byte block in FSMC version 8
120 * and it has to be read consecutively and immediately after the 512
121 * byte data block for hardware to generate the error bit offsets
122 * Managing the ecc bytes in the following way is easier. This way is
123 * similar to oobfree structure maintained already in u-boot nand driver
124 */
125#define MAX_ECCPLACE_ENTRIES 32
126
127struct fsmc_nand_eccplace {
128 uint8_t offset;
129 uint8_t length;
130};
131
132struct fsmc_eccplace {
133 struct fsmc_nand_eccplace eccplace[MAX_ECCPLACE_ENTRIES];
134};
135
136/**
137 * fsmc_nand_platform_data - platform specific NAND controller config
138 * @partitions: partition table for the platform, use a default fallback
139 * if this is NULL
140 * @nr_partitions: the number of partitions in the previous entry
141 * @options: different options for the driver
142 * @width: bus width
143 * @bank: default bank
144 * @select_bank: callback to select a certain bank, this is
145 * platform-specific. If the controller only supports one bank
146 * this may be set to NULL
147 */
148struct fsmc_nand_platform_data {
149 struct mtd_partition *partitions;
150 unsigned int nr_partitions;
151 unsigned int options;
152 unsigned int width;
153 unsigned int bank;
154 void (*select_bank)(uint32_t bank, uint32_t busw);
155};
156
157extern int __init fsmc_nor_init(struct platform_device *pdev,
158 unsigned long base, uint32_t bank, uint32_t width);
159extern void __init fsmc_init_board_info(struct platform_device *pdev,
160 struct mtd_partition *partitions, unsigned int nr_partitions,
161 unsigned int width);
162
163#endif /* __MTD_FSMC_H */
diff --git a/include/linux/mtd/inftl.h b/include/linux/mtd/inftl.h
index 64ee53ce95a9..02cd5f9b79b8 100644
--- a/include/linux/mtd/inftl.h
+++ b/include/linux/mtd/inftl.h
@@ -37,14 +37,14 @@ struct INFTLrecord {
37 __u16 firstEUN; 37 __u16 firstEUN;
38 __u16 lastEUN; 38 __u16 lastEUN;
39 __u16 numfreeEUNs; 39 __u16 numfreeEUNs;
40 __u16 LastFreeEUN; /* To speed up finding a free EUN */ 40 __u16 LastFreeEUN; /* To speed up finding a free EUN */
41 int head,sect,cyl; 41 int head,sect,cyl;
42 __u16 *PUtable; /* Physical Unit Table */ 42 __u16 *PUtable; /* Physical Unit Table */
43 __u16 *VUtable; /* Virtual Unit Table */ 43 __u16 *VUtable; /* Virtual Unit Table */
44 unsigned int nb_blocks; /* number of physical blocks */ 44 unsigned int nb_blocks; /* number of physical blocks */
45 unsigned int nb_boot_blocks; /* number of blocks used by the bios */ 45 unsigned int nb_boot_blocks; /* number of blocks used by the bios */
46 struct erase_info instr; 46 struct erase_info instr;
47 struct nand_ecclayout oobinfo; 47 struct nand_ecclayout oobinfo;
48}; 48};
49 49
50int INFTL_mount(struct INFTLrecord *s); 50int INFTL_mount(struct INFTLrecord *s);
diff --git a/include/linux/mtd/latch-addr-flash.h b/include/linux/mtd/latch-addr-flash.h
new file mode 100644
index 000000000000..e94b8e128074
--- /dev/null
+++ b/include/linux/mtd/latch-addr-flash.h
@@ -0,0 +1,29 @@
1/*
2 * Interface for NOR flash driver whose high address lines are latched
3 *
4 * Copyright © 2008 MontaVista Software, Inc. <source@mvista.com>
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10#ifndef __LATCH_ADDR_FLASH__
11#define __LATCH_ADDR_FLASH__
12
13struct map_info;
14struct mtd_partition;
15
16struct latch_addr_flash_data {
17 unsigned int width;
18 unsigned int size;
19
20 int (*init)(void *data, int cs);
21 void (*done)(void *data);
22 void (*set_window)(unsigned long offset, void *data);
23 void *data;
24
25 unsigned int nr_parts;
26 struct mtd_partition *parts;
27};
28
29#endif
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 8485e42a9b09..2541fb848daa 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -110,6 +110,21 @@ struct mtd_oob_ops {
110 uint8_t *oobbuf; 110 uint8_t *oobbuf;
111}; 111};
112 112
113#define MTD_MAX_OOBFREE_ENTRIES_LARGE 32
114#define MTD_MAX_ECCPOS_ENTRIES_LARGE 448
115/*
116 * Internal ECC layout control structure. For historical reasons, there is a
117 * similar, smaller struct nand_ecclayout_user (in mtd-abi.h) that is retained
118 * for export to user-space via the ECCGETLAYOUT ioctl.
119 * nand_ecclayout should be expandable in the future simply by the above macros.
120 */
121struct nand_ecclayout {
122 __u32 eccbytes;
123 __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE];
124 __u32 oobavail;
125 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
126};
127
113struct mtd_info { 128struct mtd_info {
114 u_char type; 129 u_char type;
115 uint32_t flags; 130 uint32_t flags;
@@ -129,6 +144,17 @@ struct mtd_info {
129 */ 144 */
130 uint32_t writesize; 145 uint32_t writesize;
131 146
147 /*
148 * Size of the write buffer used by the MTD. MTD devices having a write
149 * buffer can write multiple writesize chunks at a time. E.g. while
150 * writing 4 * writesize bytes to a device with 2 * writesize bytes
151 * buffer the MTD driver can (but doesn't have to) do 2 writesize
152 * operations, but not 4. Currently, all NANDs have writebufsize
153 * equivalent to writesize (NAND page size). Some NOR flashes do have
154 * writebufsize greater than writesize.
155 */
156 uint32_t writebufsize;
157
132 uint32_t oobsize; // Amount of OOB data per block (e.g. 16) 158 uint32_t oobsize; // Amount of OOB data per block (e.g. 16)
133 uint32_t oobavail; // Available OOB bytes per block 159 uint32_t oobavail; // Available OOB bytes per block
134 160
@@ -296,9 +322,12 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
296 322
297 /* Kernel-side ioctl definitions */ 323 /* Kernel-side ioctl definitions */
298 324
299extern int add_mtd_device(struct mtd_info *mtd); 325struct mtd_partition;
300extern int del_mtd_device (struct mtd_info *mtd);
301 326
327extern int mtd_device_register(struct mtd_info *master,
328 const struct mtd_partition *parts,
329 int nr_parts);
330extern int mtd_device_unregister(struct mtd_info *master);
302extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num); 331extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
303extern int __get_mtd_device(struct mtd_info *mtd); 332extern int __get_mtd_device(struct mtd_info *mtd);
304extern void __put_mtd_device(struct mtd_info *mtd); 333extern void __put_mtd_device(struct mtd_info *mtd);
@@ -322,15 +351,9 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
322int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs, 351int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs,
323 unsigned long count, loff_t from, size_t *retlen); 352 unsigned long count, loff_t from, size_t *retlen);
324 353
325#ifdef CONFIG_MTD_PARTITIONS 354void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
355
326void mtd_erase_callback(struct erase_info *instr); 356void mtd_erase_callback(struct erase_info *instr);
327#else
328static inline void mtd_erase_callback(struct erase_info *instr)
329{
330 if (instr->callback)
331 instr->callback(instr);
332}
333#endif
334 357
335/* 358/*
336 * Debugging macro and defines 359 * Debugging macro and defines
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 102e12c58cb3..c2b9ac4fbc4a 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -27,15 +27,17 @@
27struct mtd_info; 27struct mtd_info;
28struct nand_flash_dev; 28struct nand_flash_dev;
29/* Scan and identify a NAND device */ 29/* Scan and identify a NAND device */
30extern int nand_scan (struct mtd_info *mtd, int max_chips); 30extern int nand_scan(struct mtd_info *mtd, int max_chips);
31/* Separate phases of nand_scan(), allowing board driver to intervene 31/*
32 * and override command or ECC setup according to flash type */ 32 * Separate phases of nand_scan(), allowing board driver to intervene
33 * and override command or ECC setup according to flash type.
34 */
33extern int nand_scan_ident(struct mtd_info *mtd, int max_chips, 35extern int nand_scan_ident(struct mtd_info *mtd, int max_chips,
34 struct nand_flash_dev *table); 36 struct nand_flash_dev *table);
35extern int nand_scan_tail(struct mtd_info *mtd); 37extern int nand_scan_tail(struct mtd_info *mtd);
36 38
37/* Free resources held by the NAND device */ 39/* Free resources held by the NAND device */
38extern void nand_release (struct mtd_info *mtd); 40extern void nand_release(struct mtd_info *mtd);
39 41
40/* Internal helper for board drivers which need to override command function */ 42/* Internal helper for board drivers which need to override command function */
41extern void nand_wait_ready(struct mtd_info *mtd); 43extern void nand_wait_ready(struct mtd_info *mtd);
@@ -49,12 +51,13 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
49/* The maximum number of NAND chips in an array */ 51/* The maximum number of NAND chips in an array */
50#define NAND_MAX_CHIPS 8 52#define NAND_MAX_CHIPS 8
51 53
52/* This constant declares the max. oobsize / page, which 54/*
55 * This constant declares the max. oobsize / page, which
53 * is supported now. If you add a chip with bigger oobsize/page 56 * is supported now. If you add a chip with bigger oobsize/page
54 * adjust this accordingly. 57 * adjust this accordingly.
55 */ 58 */
56#define NAND_MAX_OOBSIZE 256 59#define NAND_MAX_OOBSIZE 576
57#define NAND_MAX_PAGESIZE 4096 60#define NAND_MAX_PAGESIZE 8192
58 61
59/* 62/*
60 * Constants for hardware specific CLE/ALE/NCE function 63 * Constants for hardware specific CLE/ALE/NCE function
@@ -88,6 +91,7 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
88#define NAND_CMD_RNDIN 0x85 91#define NAND_CMD_RNDIN 0x85
89#define NAND_CMD_READID 0x90 92#define NAND_CMD_READID 0x90
90#define NAND_CMD_ERASE2 0xd0 93#define NAND_CMD_ERASE2 0xd0
94#define NAND_CMD_PARAM 0xec
91#define NAND_CMD_RESET 0xff 95#define NAND_CMD_RESET 0xff
92 96
93#define NAND_CMD_LOCK 0x2a 97#define NAND_CMD_LOCK 0x2a
@@ -136,6 +140,7 @@ typedef enum {
136 NAND_ECC_HW, 140 NAND_ECC_HW,
137 NAND_ECC_HW_SYNDROME, 141 NAND_ECC_HW_SYNDROME,
138 NAND_ECC_HW_OOB_FIRST, 142 NAND_ECC_HW_OOB_FIRST,
143 NAND_ECC_SOFT_BCH,
139} nand_ecc_modes_t; 144} nand_ecc_modes_t;
140 145
141/* 146/*
@@ -152,9 +157,10 @@ typedef enum {
152#define NAND_GET_DEVICE 0x80 157#define NAND_GET_DEVICE 0x80
153 158
154 159
155/* Option constants for bizarre disfunctionality and real 160/*
156* features 161 * Option constants for bizarre disfunctionality and real
157*/ 162 * features.
163 */
158/* Chip can not auto increment pages */ 164/* Chip can not auto increment pages */
159#define NAND_NO_AUTOINCR 0x00000001 165#define NAND_NO_AUTOINCR 0x00000001
160/* Buswitdh is 16 bit */ 166/* Buswitdh is 16 bit */
@@ -165,19 +171,27 @@ typedef enum {
165#define NAND_CACHEPRG 0x00000008 171#define NAND_CACHEPRG 0x00000008
166/* Chip has copy back function */ 172/* Chip has copy back function */
167#define NAND_COPYBACK 0x00000010 173#define NAND_COPYBACK 0x00000010
168/* AND Chip which has 4 banks and a confusing page / block 174/*
169 * assignment. See Renesas datasheet for further information */ 175 * AND Chip which has 4 banks and a confusing page / block
176 * assignment. See Renesas datasheet for further information.
177 */
170#define NAND_IS_AND 0x00000020 178#define NAND_IS_AND 0x00000020
171/* Chip has a array of 4 pages which can be read without 179/*
172 * additional ready /busy waits */ 180 * Chip has a array of 4 pages which can be read without
181 * additional ready /busy waits.
182 */
173#define NAND_4PAGE_ARRAY 0x00000040 183#define NAND_4PAGE_ARRAY 0x00000040
174/* Chip requires that BBT is periodically rewritten to prevent 184/*
185 * Chip requires that BBT is periodically rewritten to prevent
175 * bits from adjacent blocks from 'leaking' in altering data. 186 * bits from adjacent blocks from 'leaking' in altering data.
176 * This happens with the Renesas AG-AND chips, possibly others. */ 187 * This happens with the Renesas AG-AND chips, possibly others.
188 */
177#define BBT_AUTO_REFRESH 0x00000080 189#define BBT_AUTO_REFRESH 0x00000080
178/* Chip does not require ready check on read. True 190/*
191 * Chip does not require ready check on read. True
179 * for all large page devices, as they do not support 192 * for all large page devices, as they do not support
180 * autoincrement.*/ 193 * autoincrement.
194 */
181#define NAND_NO_READRDY 0x00000100 195#define NAND_NO_READRDY 0x00000100
182/* Chip does not allow subpage writes */ 196/* Chip does not allow subpage writes */
183#define NAND_NO_SUBPAGE_WRITE 0x00000200 197#define NAND_NO_SUBPAGE_WRITE 0x00000200
@@ -205,16 +219,27 @@ typedef enum {
205#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) 219#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR)
206 220
207/* Non chip related options */ 221/* Non chip related options */
208/* Use a flash based bad block table. This option is passed to the 222/*
209 * default bad block table function. */ 223 * Use a flash based bad block table. OOB identifier is saved in OOB area.
224 * This option is passed to the default bad block table function.
225 */
210#define NAND_USE_FLASH_BBT 0x00010000 226#define NAND_USE_FLASH_BBT 0x00010000
211/* This option skips the bbt scan during initialization. */ 227/* This option skips the bbt scan during initialization. */
212#define NAND_SKIP_BBTSCAN 0x00020000 228#define NAND_SKIP_BBTSCAN 0x00020000
213/* This option is defined if the board driver allocates its own buffers 229/*
214 (e.g. because it needs them DMA-coherent */ 230 * This option is defined if the board driver allocates its own buffers
231 * (e.g. because it needs them DMA-coherent).
232 */
215#define NAND_OWN_BUFFERS 0x00040000 233#define NAND_OWN_BUFFERS 0x00040000
216/* Chip may not exist, so silence any errors in scan */ 234/* Chip may not exist, so silence any errors in scan */
217#define NAND_SCAN_SILENT_NODEV 0x00080000 235#define NAND_SCAN_SILENT_NODEV 0x00080000
236/*
237 * If passed additionally to NAND_USE_FLASH_BBT then BBT code will not touch
238 * the OOB area.
239 */
240#define NAND_USE_FLASH_BBT_NO_OOB 0x00800000
241/* Create an empty BBT with no vendor information if the BBT is available */
242#define NAND_CREATE_EMPTY_BBT 0x01000000
218 243
219/* Options set by nand scan */ 244/* Options set by nand scan */
220/* Nand scan has allocated controller struct */ 245/* Nand scan has allocated controller struct */
@@ -227,15 +252,80 @@ typedef enum {
227/* Keep gcc happy */ 252/* Keep gcc happy */
228struct nand_chip; 253struct nand_chip;
229 254
255struct nand_onfi_params {
256 /* rev info and features block */
257 /* 'O' 'N' 'F' 'I' */
258 u8 sig[4];
259 __le16 revision;
260 __le16 features;
261 __le16 opt_cmd;
262 u8 reserved[22];
263
264 /* manufacturer information block */
265 char manufacturer[12];
266 char model[20];
267 u8 jedec_id;
268 __le16 date_code;
269 u8 reserved2[13];
270
271 /* memory organization block */
272 __le32 byte_per_page;
273 __le16 spare_bytes_per_page;
274 __le32 data_bytes_per_ppage;
275 __le16 spare_bytes_per_ppage;
276 __le32 pages_per_block;
277 __le32 blocks_per_lun;
278 u8 lun_count;
279 u8 addr_cycles;
280 u8 bits_per_cell;
281 __le16 bb_per_lun;
282 __le16 block_endurance;
283 u8 guaranteed_good_blocks;
284 __le16 guaranteed_block_endurance;
285 u8 programs_per_page;
286 u8 ppage_attr;
287 u8 ecc_bits;
288 u8 interleaved_bits;
289 u8 interleaved_ops;
290 u8 reserved3[13];
291
292 /* electrical parameter block */
293 u8 io_pin_capacitance_max;
294 __le16 async_timing_mode;
295 __le16 program_cache_timing_mode;
296 __le16 t_prog;
297 __le16 t_bers;
298 __le16 t_r;
299 __le16 t_ccs;
300 __le16 src_sync_timing_mode;
301 __le16 src_ssync_features;
302 __le16 clk_pin_capacitance_typ;
303 __le16 io_pin_capacitance_typ;
304 __le16 input_pin_capacitance_typ;
305 u8 input_pin_capacitance_max;
306 u8 driver_strenght_support;
307 __le16 t_int_r;
308 __le16 t_ald;
309 u8 reserved4[7];
310
311 /* vendor */
312 u8 reserved5[90];
313
314 __le16 crc;
315} __attribute__((packed));
316
317#define ONFI_CRC_BASE 0x4F4E
318
230/** 319/**
231 * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independent devices 320 * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independent devices
232 * @lock: protection lock 321 * @lock: protection lock
233 * @active: the mtd device which holds the controller currently 322 * @active: the mtd device which holds the controller currently
234 * @wq: wait queue to sleep on if a NAND operation is in progress 323 * @wq: wait queue to sleep on if a NAND operation is in
235 * used instead of the per chip wait queue when a hw controller is available 324 * progress used instead of the per chip wait queue
325 * when a hw controller is available.
236 */ 326 */
237struct nand_hw_control { 327struct nand_hw_control {
238 spinlock_t lock; 328 spinlock_t lock;
239 struct nand_chip *active; 329 struct nand_chip *active;
240 wait_queue_head_t wq; 330 wait_queue_head_t wq;
241}; 331};
@@ -250,57 +340,50 @@ struct nand_hw_control {
250 * @prepad: padding information for syndrome based ecc generators 340 * @prepad: padding information for syndrome based ecc generators
251 * @postpad: padding information for syndrome based ecc generators 341 * @postpad: padding information for syndrome based ecc generators
252 * @layout: ECC layout control struct pointer 342 * @layout: ECC layout control struct pointer
343 * @priv: pointer to private ecc control data
253 * @hwctl: function to control hardware ecc generator. Must only 344 * @hwctl: function to control hardware ecc generator. Must only
254 * be provided if an hardware ECC is available 345 * be provided if an hardware ECC is available
255 * @calculate: function for ecc calculation or readback from ecc hardware 346 * @calculate: function for ecc calculation or readback from ecc hardware
256 * @correct: function for ecc correction, matching to ecc generator (sw/hw) 347 * @correct: function for ecc correction, matching to ecc generator (sw/hw)
257 * @read_page_raw: function to read a raw page without ECC 348 * @read_page_raw: function to read a raw page without ECC
258 * @write_page_raw: function to write a raw page without ECC 349 * @write_page_raw: function to write a raw page without ECC
259 * @read_page: function to read a page according to the ecc generator requirements 350 * @read_page: function to read a page according to the ecc generator
351 * requirements.
260 * @read_subpage: function to read parts of the page covered by ECC. 352 * @read_subpage: function to read parts of the page covered by ECC.
261 * @write_page: function to write a page according to the ecc generator requirements 353 * @write_page: function to write a page according to the ecc generator
354 * requirements.
262 * @read_oob: function to read chip OOB data 355 * @read_oob: function to read chip OOB data
263 * @write_oob: function to write chip OOB data 356 * @write_oob: function to write chip OOB data
264 */ 357 */
265struct nand_ecc_ctrl { 358struct nand_ecc_ctrl {
266 nand_ecc_modes_t mode; 359 nand_ecc_modes_t mode;
267 int steps; 360 int steps;
268 int size; 361 int size;
269 int bytes; 362 int bytes;
270 int total; 363 int total;
271 int prepad; 364 int prepad;
272 int postpad; 365 int postpad;
273 struct nand_ecclayout *layout; 366 struct nand_ecclayout *layout;
274 void (*hwctl)(struct mtd_info *mtd, int mode); 367 void *priv;
275 int (*calculate)(struct mtd_info *mtd, 368 void (*hwctl)(struct mtd_info *mtd, int mode);
276 const uint8_t *dat, 369 int (*calculate)(struct mtd_info *mtd, const uint8_t *dat,
277 uint8_t *ecc_code); 370 uint8_t *ecc_code);
278 int (*correct)(struct mtd_info *mtd, uint8_t *dat, 371 int (*correct)(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc,
279 uint8_t *read_ecc, 372 uint8_t *calc_ecc);
280 uint8_t *calc_ecc); 373 int (*read_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
281 int (*read_page_raw)(struct mtd_info *mtd, 374 uint8_t *buf, int page);
282 struct nand_chip *chip, 375 void (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
283 uint8_t *buf, int page); 376 const uint8_t *buf);
284 void (*write_page_raw)(struct mtd_info *mtd, 377 int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip,
285 struct nand_chip *chip, 378 uint8_t *buf, int page);
286 const uint8_t *buf); 379 int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
287 int (*read_page)(struct mtd_info *mtd, 380 uint32_t offs, uint32_t len, uint8_t *buf);
288 struct nand_chip *chip, 381 void (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
289 uint8_t *buf, int page); 382 const uint8_t *buf);
290 int (*read_subpage)(struct mtd_info *mtd, 383 int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page,
291 struct nand_chip *chip, 384 int sndcmd);
292 uint32_t offs, uint32_t len, 385 int (*write_oob)(struct mtd_info *mtd, struct nand_chip *chip,
293 uint8_t *buf); 386 int page);
294 void (*write_page)(struct mtd_info *mtd,
295 struct nand_chip *chip,
296 const uint8_t *buf);
297 int (*read_oob)(struct mtd_info *mtd,
298 struct nand_chip *chip,
299 int page,
300 int sndcmd);
301 int (*write_oob)(struct mtd_info *mtd,
302 struct nand_chip *chip,
303 int page);
304}; 387};
305 388
306/** 389/**
@@ -320,102 +403,134 @@ struct nand_buffers {
320 403
321/** 404/**
322 * struct nand_chip - NAND Private Flash Chip Data 405 * struct nand_chip - NAND Private Flash Chip Data
323 * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the flash device 406 * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the
324 * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the flash device 407 * flash device
408 * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the
409 * flash device.
325 * @read_byte: [REPLACEABLE] read one byte from the chip 410 * @read_byte: [REPLACEABLE] read one byte from the chip
326 * @read_word: [REPLACEABLE] read one word from the chip 411 * @read_word: [REPLACEABLE] read one word from the chip
327 * @write_buf: [REPLACEABLE] write data from the buffer to the chip 412 * @write_buf: [REPLACEABLE] write data from the buffer to the chip
328 * @read_buf: [REPLACEABLE] read data from the chip into the buffer 413 * @read_buf: [REPLACEABLE] read data from the chip into the buffer
329 * @verify_buf: [REPLACEABLE] verify buffer contents against the chip data 414 * @verify_buf: [REPLACEABLE] verify buffer contents against the chip
415 * data.
330 * @select_chip: [REPLACEABLE] select chip nr 416 * @select_chip: [REPLACEABLE] select chip nr
331 * @block_bad: [REPLACEABLE] check, if the block is bad 417 * @block_bad: [REPLACEABLE] check, if the block is bad
332 * @block_markbad: [REPLACEABLE] mark the block bad 418 * @block_markbad: [REPLACEABLE] mark the block bad
333 * @cmd_ctrl: [BOARDSPECIFIC] hardwarespecific funtion for controlling 419 * @cmd_ctrl: [BOARDSPECIFIC] hardwarespecific function for controlling
334 * ALE/CLE/nCE. Also used to write command and address 420 * ALE/CLE/nCE. Also used to write command and address
335 * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing device ready/busy line 421 * @init_size: [BOARDSPECIFIC] hardwarespecific function for setting
336 * If set to NULL no access to ready/busy is available and the ready/busy information 422 * mtd->oobsize, mtd->writesize and so on.
337 * is read from the chip status register 423 * @id_data contains the 8 bytes values of NAND_CMD_READID.
338 * @cmdfunc: [REPLACEABLE] hardwarespecific function for writing commands to the chip 424 * Return with the bus width.
339 * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on ready 425 * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing
426 * device ready/busy line. If set to NULL no access to
427 * ready/busy is available and the ready/busy information
428 * is read from the chip status register.
429 * @cmdfunc: [REPLACEABLE] hardwarespecific function for writing
430 * commands to the chip.
431 * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on
432 * ready.
340 * @ecc: [BOARDSPECIFIC] ecc control ctructure 433 * @ecc: [BOARDSPECIFIC] ecc control ctructure
341 * @buffers: buffer structure for read/write 434 * @buffers: buffer structure for read/write
342 * @hwcontrol: platform-specific hardware control structure 435 * @hwcontrol: platform-specific hardware control structure
343 * @ops: oob operation operands 436 * @ops: oob operation operands
344 * @erase_cmd: [INTERN] erase command write function, selectable due to AND support 437 * @erase_cmd: [INTERN] erase command write function, selectable due
438 * to AND support.
345 * @scan_bbt: [REPLACEABLE] function to scan bad block table 439 * @scan_bbt: [REPLACEABLE] function to scan bad block table
346 * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR) 440 * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transferring
441 * data from array to read regs (tR).
347 * @state: [INTERN] the current state of the NAND device 442 * @state: [INTERN] the current state of the NAND device
348 * @oob_poi: poison value buffer 443 * @oob_poi: poison value buffer
349 * @page_shift: [INTERN] number of address bits in a page (column address bits) 444 * @page_shift: [INTERN] number of address bits in a page (column
445 * address bits).
350 * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock 446 * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock
351 * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry 447 * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry
352 * @chip_shift: [INTERN] number of address bits in one chip 448 * @chip_shift: [INTERN] number of address bits in one chip
353 * @options: [BOARDSPECIFIC] various chip options. They can partly be set to inform nand_scan about 449 * @options: [BOARDSPECIFIC] various chip options. They can partly
354 * special functionality. See the defines for further explanation 450 * be set to inform nand_scan about special functionality.
355 * @badblockpos: [INTERN] position of the bad block marker in the oob area 451 * See the defines for further explanation.
452 * @badblockpos: [INTERN] position of the bad block marker in the oob
453 * area.
454 * @badblockbits: [INTERN] number of bits to left-shift the bad block
455 * number
356 * @cellinfo: [INTERN] MLC/multichip data from chip ident 456 * @cellinfo: [INTERN] MLC/multichip data from chip ident
357 * @numchips: [INTERN] number of physical chips 457 * @numchips: [INTERN] number of physical chips
358 * @chipsize: [INTERN] the size of one chip for multichip arrays 458 * @chipsize: [INTERN] the size of one chip for multichip arrays
359 * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 459 * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1
360 * @pagebuf: [INTERN] holds the pagenumber which is currently in data_buf 460 * @pagebuf: [INTERN] holds the pagenumber which is currently in
461 * data_buf.
361 * @subpagesize: [INTERN] holds the subpagesize 462 * @subpagesize: [INTERN] holds the subpagesize
463 * @onfi_version: [INTERN] holds the chip ONFI version (BCD encoded),
464 * non 0 if ONFI supported.
465 * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is
466 * supported, 0 otherwise.
362 * @ecclayout: [REPLACEABLE] the default ecc placement scheme 467 * @ecclayout: [REPLACEABLE] the default ecc placement scheme
363 * @bbt: [INTERN] bad block table pointer 468 * @bbt: [INTERN] bad block table pointer
364 * @bbt_td: [REPLACEABLE] bad block table descriptor for flash lookup 469 * @bbt_td: [REPLACEABLE] bad block table descriptor for flash
470 * lookup.
365 * @bbt_md: [REPLACEABLE] bad block table mirror descriptor 471 * @bbt_md: [REPLACEABLE] bad block table mirror descriptor
366 * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial bad block scan 472 * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial
367 * @controller: [REPLACEABLE] a pointer to a hardware controller structure 473 * bad block scan.
368 * which is shared among multiple independend devices 474 * @controller: [REPLACEABLE] a pointer to a hardware controller
475 * structure which is shared among multiple independend
476 * devices.
369 * @priv: [OPTIONAL] pointer to private chip date 477 * @priv: [OPTIONAL] pointer to private chip date
370 * @errstat: [OPTIONAL] hardware specific function to perform additional error status checks 478 * @errstat: [OPTIONAL] hardware specific function to perform
371 * (determine if errors are correctable) 479 * additional error status checks (determine if errors are
480 * correctable).
372 * @write_page: [REPLACEABLE] High-level page write function 481 * @write_page: [REPLACEABLE] High-level page write function
373 */ 482 */
374 483
375struct nand_chip { 484struct nand_chip {
376 void __iomem *IO_ADDR_R; 485 void __iomem *IO_ADDR_R;
377 void __iomem *IO_ADDR_W; 486 void __iomem *IO_ADDR_W;
378 487
379 uint8_t (*read_byte)(struct mtd_info *mtd); 488 uint8_t (*read_byte)(struct mtd_info *mtd);
380 u16 (*read_word)(struct mtd_info *mtd); 489 u16 (*read_word)(struct mtd_info *mtd);
381 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); 490 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len);
382 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); 491 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len);
383 int (*verify_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); 492 int (*verify_buf)(struct mtd_info *mtd, const uint8_t *buf, int len);
384 void (*select_chip)(struct mtd_info *mtd, int chip); 493 void (*select_chip)(struct mtd_info *mtd, int chip);
385 int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); 494 int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip);
386 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); 495 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
387 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, 496 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl);
388 unsigned int ctrl); 497 int (*init_size)(struct mtd_info *mtd, struct nand_chip *this,
389 int (*dev_ready)(struct mtd_info *mtd); 498 u8 *id_data);
390 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); 499 int (*dev_ready)(struct mtd_info *mtd);
391 int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this); 500 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column,
392 void (*erase_cmd)(struct mtd_info *mtd, int page); 501 int page_addr);
393 int (*scan_bbt)(struct mtd_info *mtd); 502 int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
394 int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page); 503 void (*erase_cmd)(struct mtd_info *mtd, int page);
395 int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, 504 int (*scan_bbt)(struct mtd_info *mtd);
396 const uint8_t *buf, int page, int cached, int raw); 505 int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state,
397 506 int status, int page);
398 int chip_delay; 507 int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
399 unsigned int options; 508 const uint8_t *buf, int page, int cached, int raw);
400 509
401 int page_shift; 510 int chip_delay;
402 int phys_erase_shift; 511 unsigned int options;
403 int bbt_erase_shift; 512
404 int chip_shift; 513 int page_shift;
405 int numchips; 514 int phys_erase_shift;
406 uint64_t chipsize; 515 int bbt_erase_shift;
407 int pagemask; 516 int chip_shift;
408 int pagebuf; 517 int numchips;
409 int subpagesize; 518 uint64_t chipsize;
410 uint8_t cellinfo; 519 int pagemask;
411 int badblockpos; 520 int pagebuf;
412 int badblockbits; 521 int subpagesize;
413 522 uint8_t cellinfo;
414 flstate_t state; 523 int badblockpos;
415 524 int badblockbits;
416 uint8_t *oob_poi; 525
417 struct nand_hw_control *controller; 526 int onfi_version;
418 struct nand_ecclayout *ecclayout; 527 struct nand_onfi_params onfi_params;
528
529 flstate_t state;
530
531 uint8_t *oob_poi;
532 struct nand_hw_control *controller;
533 struct nand_ecclayout *ecclayout;
419 534
420 struct nand_ecc_ctrl ecc; 535 struct nand_ecc_ctrl ecc;
421 struct nand_buffers *buffers; 536 struct nand_buffers *buffers;
@@ -423,13 +538,13 @@ struct nand_chip {
423 538
424 struct mtd_oob_ops ops; 539 struct mtd_oob_ops ops;
425 540
426 uint8_t *bbt; 541 uint8_t *bbt;
427 struct nand_bbt_descr *bbt_td; 542 struct nand_bbt_descr *bbt_td;
428 struct nand_bbt_descr *bbt_md; 543 struct nand_bbt_descr *bbt_md;
429 544
430 struct nand_bbt_descr *badblock_pattern; 545 struct nand_bbt_descr *badblock_pattern;
431 546
432 void *priv; 547 void *priv;
433}; 548};
434 549
435/* 550/*
@@ -473,7 +588,7 @@ struct nand_flash_dev {
473*/ 588*/
474struct nand_manufacturers { 589struct nand_manufacturers {
475 int id; 590 int id;
476 char * name; 591 char *name;
477}; 592};
478 593
479extern struct nand_flash_dev nand_flash_ids[]; 594extern struct nand_flash_dev nand_flash_ids[];
@@ -486,7 +601,7 @@ extern int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt);
486extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, 601extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
487 int allowbbt); 602 int allowbbt);
488extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, 603extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
489 size_t * retlen, uint8_t * buf); 604 size_t *retlen, uint8_t *buf);
490 605
491/** 606/**
492 * struct platform_nand_chip - chip level device structure 607 * struct platform_nand_chip - chip level device structure
@@ -502,17 +617,16 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
502 * @priv: hardware controller specific settings 617 * @priv: hardware controller specific settings
503 */ 618 */
504struct platform_nand_chip { 619struct platform_nand_chip {
505 int nr_chips; 620 int nr_chips;
506 int chip_offset; 621 int chip_offset;
507 int nr_partitions; 622 int nr_partitions;
508 struct mtd_partition *partitions; 623 struct mtd_partition *partitions;
509 struct nand_ecclayout *ecclayout; 624 struct nand_ecclayout *ecclayout;
510 int chip_delay; 625 int chip_delay;
511 unsigned int options; 626 unsigned int options;
512 const char **part_probe_types; 627 const char **part_probe_types;
513 void (*set_parts)(uint64_t size, 628 void (*set_parts)(uint64_t size, struct platform_nand_chip *chip);
514 struct platform_nand_chip *chip); 629 void *priv;
515 void *priv;
516}; 630};
517 631
518/* Keep gcc happy */ 632/* Keep gcc happy */
@@ -534,18 +648,15 @@ struct platform_device;
534 * All fields are optional and depend on the hardware driver requirements 648 * All fields are optional and depend on the hardware driver requirements
535 */ 649 */
536struct platform_nand_ctrl { 650struct platform_nand_ctrl {
537 int (*probe)(struct platform_device *pdev); 651 int (*probe)(struct platform_device *pdev);
538 void (*remove)(struct platform_device *pdev); 652 void (*remove)(struct platform_device *pdev);
539 void (*hwcontrol)(struct mtd_info *mtd, int cmd); 653 void (*hwcontrol)(struct mtd_info *mtd, int cmd);
540 int (*dev_ready)(struct mtd_info *mtd); 654 int (*dev_ready)(struct mtd_info *mtd);
541 void (*select_chip)(struct mtd_info *mtd, int chip); 655 void (*select_chip)(struct mtd_info *mtd, int chip);
542 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, 656 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl);
543 unsigned int ctrl); 657 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len);
544 void (*write_buf)(struct mtd_info *mtd, 658 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len);
545 const uint8_t *buf, int len); 659 void *priv;
546 void (*read_buf)(struct mtd_info *mtd,
547 uint8_t *buf, int len);
548 void *priv;
549}; 660};
550 661
551/** 662/**
@@ -554,8 +665,8 @@ struct platform_nand_ctrl {
554 * @ctrl: controller level device structure 665 * @ctrl: controller level device structure
555 */ 666 */
556struct platform_nand_data { 667struct platform_nand_data {
557 struct platform_nand_chip chip; 668 struct platform_nand_chip chip;
558 struct platform_nand_ctrl ctrl; 669 struct platform_nand_ctrl ctrl;
559}; 670};
560 671
561/* Some helpers to access the data structures */ 672/* Some helpers to access the data structures */
diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h
new file mode 100644
index 000000000000..74acf5367556
--- /dev/null
+++ b/include/linux/mtd/nand_bch.h
@@ -0,0 +1,72 @@
1/*
2 * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This file is the header for the NAND BCH ECC implementation.
9 */
10
11#ifndef __MTD_NAND_BCH_H__
12#define __MTD_NAND_BCH_H__
13
14struct mtd_info;
15struct nand_bch_control;
16
17#if defined(CONFIG_MTD_NAND_ECC_BCH)
18
19static inline int mtd_nand_has_bch(void) { return 1; }
20
21/*
22 * Calculate BCH ecc code
23 */
24int nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
25 u_char *ecc_code);
26
27/*
28 * Detect and correct bit errors
29 */
30int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc,
31 u_char *calc_ecc);
32/*
33 * Initialize BCH encoder/decoder
34 */
35struct nand_bch_control *
36nand_bch_init(struct mtd_info *mtd, unsigned int eccsize,
37 unsigned int eccbytes, struct nand_ecclayout **ecclayout);
38/*
39 * Release BCH encoder/decoder resources
40 */
41void nand_bch_free(struct nand_bch_control *nbc);
42
43#else /* !CONFIG_MTD_NAND_ECC_BCH */
44
45static inline int mtd_nand_has_bch(void) { return 0; }
46
47static inline int
48nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
49 u_char *ecc_code)
50{
51 return -1;
52}
53
54static inline int
55nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf,
56 unsigned char *read_ecc, unsigned char *calc_ecc)
57{
58 return -1;
59}
60
61static inline struct nand_bch_control *
62nand_bch_init(struct mtd_info *mtd, unsigned int eccsize,
63 unsigned int eccbytes, struct nand_ecclayout **ecclayout)
64{
65 return NULL;
66}
67
68static inline void nand_bch_free(struct nand_bch_control *nbc) {}
69
70#endif /* CONFIG_MTD_NAND_ECC_BCH */
71
72#endif /* __MTD_NAND_BCH_H__ */
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h
index 0c8815bfae1c..52b6f187bf49 100644
--- a/include/linux/mtd/onenand.h
+++ b/include/linux/mtd/onenand.h
@@ -118,6 +118,8 @@ struct onenand_chip {
118 int (*chip_probe)(struct mtd_info *mtd); 118 int (*chip_probe)(struct mtd_info *mtd);
119 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); 119 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
120 int (*scan_bbt)(struct mtd_info *mtd); 120 int (*scan_bbt)(struct mtd_info *mtd);
121 int (*enable)(struct mtd_info *mtd);
122 int (*disable)(struct mtd_info *mtd);
121 123
122 struct completion complete; 124 struct completion complete;
123 int irq; 125 int irq;
@@ -137,6 +139,14 @@ struct onenand_chip {
137 void *bbm; 139 void *bbm;
138 140
139 void *priv; 141 void *priv;
142
143 /*
144 * Shows that the current operation is composed
145 * of sequence of commands. For example, cache program.
146 * Such command status OnGo bit is checked at the end of
147 * sequence.
148 */
149 unsigned int ongoing;
140}; 150};
141 151
142/* 152/*
@@ -171,6 +181,9 @@ struct onenand_chip {
171#define ONENAND_IS_2PLANE(this) (0) 181#define ONENAND_IS_2PLANE(this) (0)
172#endif 182#endif
173 183
184#define ONENAND_IS_CACHE_PROGRAM(this) \
185 (this->options & ONENAND_HAS_CACHE_PROGRAM)
186
174/* Check byte access in OneNAND */ 187/* Check byte access in OneNAND */
175#define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) 188#define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1)
176 189
@@ -181,9 +194,11 @@ struct onenand_chip {
181#define ONENAND_HAS_UNLOCK_ALL (0x0002) 194#define ONENAND_HAS_UNLOCK_ALL (0x0002)
182#define ONENAND_HAS_2PLANE (0x0004) 195#define ONENAND_HAS_2PLANE (0x0004)
183#define ONENAND_HAS_4KB_PAGE (0x0008) 196#define ONENAND_HAS_4KB_PAGE (0x0008)
197#define ONENAND_HAS_CACHE_PROGRAM (0x0010)
184#define ONENAND_SKIP_UNLOCK_CHECK (0x0100) 198#define ONENAND_SKIP_UNLOCK_CHECK (0x0100)
185#define ONENAND_PAGEBUF_ALLOC (0x1000) 199#define ONENAND_PAGEBUF_ALLOC (0x1000)
186#define ONENAND_OOBBUF_ALLOC (0x2000) 200#define ONENAND_OOBBUF_ALLOC (0x2000)
201#define ONENAND_SKIP_INITIAL_UNLOCKING (0x4000)
187 202
188#define ONENAND_IS_4KB_PAGE(this) \ 203#define ONENAND_IS_4KB_PAGE(this) \
189 (this->options & ONENAND_HAS_4KB_PAGE) 204 (this->options & ONENAND_HAS_4KB_PAGE)
diff --git a/include/linux/mtd/onenand_regs.h b/include/linux/mtd/onenand_regs.h
index cd6f3b431195..d60130f88eed 100644
--- a/include/linux/mtd/onenand_regs.h
+++ b/include/linux/mtd/onenand_regs.h
@@ -168,6 +168,7 @@
168#define ONENAND_SYS_CFG1_INT (1 << 6) 168#define ONENAND_SYS_CFG1_INT (1 << 6)
169#define ONENAND_SYS_CFG1_IOBE (1 << 5) 169#define ONENAND_SYS_CFG1_IOBE (1 << 5)
170#define ONENAND_SYS_CFG1_RDY_CONF (1 << 4) 170#define ONENAND_SYS_CFG1_RDY_CONF (1 << 4)
171#define ONENAND_SYS_CFG1_VHF (1 << 3)
171#define ONENAND_SYS_CFG1_HF (1 << 2) 172#define ONENAND_SYS_CFG1_HF (1 << 2)
172#define ONENAND_SYS_CFG1_SYNC_WRITE (1 << 1) 173#define ONENAND_SYS_CFG1_SYNC_WRITE (1 << 1)
173 174
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 274b6196091d..3a6f0372fc96 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -16,7 +16,7 @@
16 * Partition definition structure: 16 * Partition definition structure:
17 * 17 *
18 * An array of struct partition is passed along with a MTD object to 18 * An array of struct partition is passed along with a MTD object to
19 * add_mtd_partitions() to create them. 19 * mtd_device_register() to create them.
20 * 20 *
21 * For each partition, these fields are available: 21 * For each partition, these fields are available:
22 * name: string that will be used to label the partition's MTD device. 22 * name: string that will be used to label the partition's MTD device.
@@ -39,7 +39,7 @@ struct mtd_partition {
39 uint64_t size; /* partition size */ 39 uint64_t size; /* partition size */
40 uint64_t offset; /* offset within the master MTD space */ 40 uint64_t offset; /* offset within the master MTD space */
41 uint32_t mask_flags; /* master MTD flags to mask out for this partition */ 41 uint32_t mask_flags; /* master MTD flags to mask out for this partition */
42 struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only)*/ 42 struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */
43}; 43};
44 44
45#define MTDPART_OFS_NXTBLK (-2) 45#define MTDPART_OFS_NXTBLK (-2)
@@ -49,9 +49,6 @@ struct mtd_partition {
49 49
50struct mtd_info; 50struct mtd_info;
51 51
52int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
53int del_mtd_partitions(struct mtd_info *);
54
55/* 52/*
56 * Functions dealing with the various ways of partitioning the space 53 * Functions dealing with the various ways of partitioning the space
57 */ 54 */
@@ -73,14 +70,17 @@ extern int parse_mtd_partitions(struct mtd_info *master, const char **types,
73struct device; 70struct device;
74struct device_node; 71struct device_node;
75 72
73#ifdef CONFIG_MTD_OF_PARTS
76int __devinit of_mtd_parse_partitions(struct device *dev, 74int __devinit of_mtd_parse_partitions(struct device *dev,
77 struct device_node *node, 75 struct device_node *node,
78 struct mtd_partition **pparts); 76 struct mtd_partition **pparts);
79
80#ifdef CONFIG_MTD_PARTITIONS
81static inline int mtd_has_partitions(void) { return 1; }
82#else 77#else
83static inline int mtd_has_partitions(void) { return 0; } 78static inline int of_mtd_parse_partitions(struct device *dev,
79 struct device_node *node,
80 struct mtd_partition **pparts)
81{
82 return 0;
83}
84#endif 84#endif
85 85
86#ifdef CONFIG_MTD_CMDLINE_PARTS 86#ifdef CONFIG_MTD_CMDLINE_PARTS
@@ -89,4 +89,9 @@ static inline int mtd_has_cmdlinepart(void) { return 1; }
89static inline int mtd_has_cmdlinepart(void) { return 0; } 89static inline int mtd_has_cmdlinepart(void) { return 0; }
90#endif 90#endif
91 91
92int mtd_is_partition(struct mtd_info *mtd);
93int mtd_add_partition(struct mtd_info *master, char *name,
94 long long offset, long long length);
95int mtd_del_partition(struct mtd_info *master, int partno);
96
92#endif 97#endif
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h
index bcfd9f777454..e5f21d293c70 100644
--- a/include/linux/mtd/physmap.h
+++ b/include/linux/mtd/physmap.h
@@ -19,10 +19,13 @@
19#include <linux/mtd/partitions.h> 19#include <linux/mtd/partitions.h>
20 20
21struct map_info; 21struct map_info;
22struct platform_device;
22 23
23struct physmap_flash_data { 24struct physmap_flash_data {
24 unsigned int width; 25 unsigned int width;
25 void (*set_vpp)(struct map_info *, int); 26 int (*init)(struct platform_device *);
27 void (*exit)(struct platform_device *);
28 void (*set_vpp)(struct platform_device *, int);
26 unsigned int nr_parts; 29 unsigned int nr_parts;
27 unsigned int pfow_base; 30 unsigned int pfow_base;
28 char *probe_type; 31 char *probe_type;
@@ -35,8 +38,6 @@ struct physmap_flash_data {
35void physmap_configure(unsigned long addr, unsigned long size, 38void physmap_configure(unsigned long addr, unsigned long size,
36 int bankwidth, void (*set_vpp)(struct map_info *, int) ); 39 int bankwidth, void (*set_vpp)(struct map_info *, int) );
37 40
38#ifdef CONFIG_MTD_PARTITIONS
39
40/* 41/*
41 * Machines that wish to do flash partition may want to call this function in 42 * Machines that wish to do flash partition may want to call this function in
42 * their setup routine. 43 * their setup routine.
@@ -48,6 +49,4 @@ void physmap_configure(unsigned long addr, unsigned long size,
48 */ 49 */
49void physmap_set_partitions(struct mtd_partition *parts, int num_parts); 50void physmap_set_partitions(struct mtd_partition *parts, int num_parts);
50 51
51#endif /* defined(CONFIG_MTD_PARTITIONS) */
52
53#endif /* __LINUX_MTD_PHYSMAP__ */ 52#endif /* __LINUX_MTD_PHYSMAP__ */
diff --git a/include/linux/mtd/super.h b/include/linux/mtd/super.h
index 4016dd6fe336..f456230f9330 100644
--- a/include/linux/mtd/super.h
+++ b/include/linux/mtd/super.h
@@ -18,10 +18,9 @@
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/mount.h> 19#include <linux/mount.h>
20 20
21extern int get_sb_mtd(struct file_system_type *fs_type, int flags, 21extern struct dentry *mount_mtd(struct file_system_type *fs_type, int flags,
22 const char *dev_name, void *data, 22 const char *dev_name, void *data,
23 int (*fill_super)(struct super_block *, void *, int), 23 int (*fill_super)(struct super_block *, void *, int));
24 struct vfsmount *mnt);
25extern void kill_mtd_super(struct super_block *sb); 24extern void kill_mtd_super(struct super_block *sb);
26 25
27 26
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h
index b31bd9e9bca3..15da0e99f48a 100644
--- a/include/linux/mtd/ubi.h
+++ b/include/linux/mtd/ubi.h
@@ -21,7 +21,7 @@
21#ifndef __LINUX_UBI_H__ 21#ifndef __LINUX_UBI_H__
22#define __LINUX_UBI_H__ 22#define __LINUX_UBI_H__
23 23
24#include <asm/ioctl.h> 24#include <linux/ioctl.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <mtd/ubi-user.h> 26#include <mtd/ubi-user.h>
27 27
@@ -87,7 +87,7 @@ enum {
87 * physical eraseblock size and on how much bytes UBI headers consume. But 87 * physical eraseblock size and on how much bytes UBI headers consume. But
88 * because of the volume alignment (@alignment), the usable size of logical 88 * because of the volume alignment (@alignment), the usable size of logical
89 * eraseblocks if a volume may be less. The following equation is true: 89 * eraseblocks if a volume may be less. The following equation is true:
90 * @usable_leb_size = LEB size - (LEB size mod @alignment), 90 * @usable_leb_size = LEB size - (LEB size mod @alignment),
91 * where LEB size is the logical eraseblock size defined by the UBI device. 91 * where LEB size is the logical eraseblock size defined by the UBI device.
92 * 92 *
93 * The alignment is multiple to the minimal flash input/output unit size or %1 93 * The alignment is multiple to the minimal flash input/output unit size or %1
@@ -116,18 +116,40 @@ struct ubi_volume_info {
116 * struct ubi_device_info - UBI device description data structure. 116 * struct ubi_device_info - UBI device description data structure.
117 * @ubi_num: ubi device number 117 * @ubi_num: ubi device number
118 * @leb_size: logical eraseblock size on this UBI device 118 * @leb_size: logical eraseblock size on this UBI device
119 * @leb_start: starting offset of logical eraseblocks within physical
120 * eraseblocks
119 * @min_io_size: minimal I/O unit size 121 * @min_io_size: minimal I/O unit size
122 * @max_write_size: maximum amount of bytes the underlying flash can write at a
123 * time (MTD write buffer size)
120 * @ro_mode: if this device is in read-only mode 124 * @ro_mode: if this device is in read-only mode
121 * @cdev: UBI character device major and minor numbers 125 * @cdev: UBI character device major and minor numbers
122 * 126 *
123 * Note, @leb_size is the logical eraseblock size offered by the UBI device. 127 * Note, @leb_size is the logical eraseblock size offered by the UBI device.
124 * Volumes of this UBI device may have smaller logical eraseblock size if their 128 * Volumes of this UBI device may have smaller logical eraseblock size if their
125 * alignment is not equivalent to %1. 129 * alignment is not equivalent to %1.
130 *
131 * The @max_write_size field describes flash write maximum write unit. For
132 * example, NOR flash allows for changing individual bytes, so @min_io_size is
133 * %1. However, it does not mean than NOR flash has to write data byte-by-byte.
134 * Instead, CFI NOR flashes have a write-buffer of, e.g., 64 bytes, and when
135 * writing large chunks of data, they write 64-bytes at a time. Obviously, this
136 * improves write throughput.
137 *
138 * Also, the MTD device may have N interleaved (striped) flash chips
139 * underneath, in which case @min_io_size can be physical min. I/O size of
140 * single flash chip, while @max_write_size can be N * @min_io_size.
141 *
142 * The @max_write_size field is always greater or equivalent to @min_io_size.
143 * E.g., some NOR flashes may have (@min_io_size = 1, @max_write_size = 64). In
144 * contrast, NAND flashes usually have @min_io_size = @max_write_size = NAND
145 * page size.
126 */ 146 */
127struct ubi_device_info { 147struct ubi_device_info {
128 int ubi_num; 148 int ubi_num;
129 int leb_size; 149 int leb_size;
150 int leb_start;
130 int min_io_size; 151 int min_io_size;
152 int max_write_size;
131 int ro_mode; 153 int ro_mode;
132 dev_t cdev; 154 dev_t cdev;
133}; 155};
diff --git a/include/linux/mtd/xip.h b/include/linux/mtd/xip.h
index 36efcba15ecd..abed4dec5c2f 100644
--- a/include/linux/mtd/xip.h
+++ b/include/linux/mtd/xip.h
@@ -51,7 +51,7 @@
51 * return in usecs the elapsed timebetween now and the reference x as 51 * return in usecs the elapsed timebetween now and the reference x as
52 * returned by xip_currtime(). 52 * returned by xip_currtime().
53 * 53 *
54 * note 1: convertion to usec can be approximated, as long as the 54 * note 1: conversion to usec can be approximated, as long as the
55 * returned value is <= the real elapsed time. 55 * returned value is <= the real elapsed time.
56 * note 2: this should be able to cope with a few seconds without 56 * note 2: this should be able to cope with a few seconds without
57 * overflowing. 57 * overflowing.
diff --git a/include/linux/mtio.h b/include/linux/mtio.h
index ef01d6aa5934..8f825756c459 100644
--- a/include/linux/mtio.h
+++ b/include/linux/mtio.h
@@ -63,6 +63,7 @@ struct mtop {
63#define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */ 63#define MTCOMPRESSION 32/* control compression with SCSI mode page 15 */
64#define MTSETPART 33 /* Change the active tape partition */ 64#define MTSETPART 33 /* Change the active tape partition */
65#define MTMKPART 34 /* Format the tape with one or two partitions */ 65#define MTMKPART 34 /* Format the tape with one or two partitions */
66#define MTWEOFI 35 /* write an end-of-file record (mark) in immediate mode */
66 67
67/* structure for MTIOCGET - mag tape get status command */ 68/* structure for MTIOCGET - mag tape get status command */
68 69
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index f363bc8fdc74..a940fe435aca 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -51,7 +51,7 @@ struct mutex {
51 spinlock_t wait_lock; 51 spinlock_t wait_lock;
52 struct list_head wait_list; 52 struct list_head wait_list;
53#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) 53#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP)
54 struct thread_info *owner; 54 struct task_struct *owner;
55#endif 55#endif
56#ifdef CONFIG_DEBUG_MUTEXES 56#ifdef CONFIG_DEBUG_MUTEXES
57 const char *name; 57 const char *name;
@@ -132,6 +132,7 @@ static inline int mutex_is_locked(struct mutex *lock)
132 */ 132 */
133#ifdef CONFIG_DEBUG_LOCK_ALLOC 133#ifdef CONFIG_DEBUG_LOCK_ALLOC
134extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); 134extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
135extern void _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map *nest_lock);
135extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock, 136extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock,
136 unsigned int subclass); 137 unsigned int subclass);
137extern int __must_check mutex_lock_killable_nested(struct mutex *lock, 138extern int __must_check mutex_lock_killable_nested(struct mutex *lock,
@@ -140,6 +141,13 @@ extern int __must_check mutex_lock_killable_nested(struct mutex *lock,
140#define mutex_lock(lock) mutex_lock_nested(lock, 0) 141#define mutex_lock(lock) mutex_lock_nested(lock, 0)
141#define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0) 142#define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0)
142#define mutex_lock_killable(lock) mutex_lock_killable_nested(lock, 0) 143#define mutex_lock_killable(lock) mutex_lock_killable_nested(lock, 0)
144
145#define mutex_lock_nest_lock(lock, nest_lock) \
146do { \
147 typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
148 _mutex_lock_nest_lock(lock, &(nest_lock)->dep_map); \
149} while (0)
150
143#else 151#else
144extern void mutex_lock(struct mutex *lock); 152extern void mutex_lock(struct mutex *lock);
145extern int __must_check mutex_lock_interruptible(struct mutex *lock); 153extern int __must_check mutex_lock_interruptible(struct mutex *lock);
@@ -148,6 +156,7 @@ extern int __must_check mutex_lock_killable(struct mutex *lock);
148# define mutex_lock_nested(lock, subclass) mutex_lock(lock) 156# define mutex_lock_nested(lock, subclass) mutex_lock(lock)
149# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock) 157# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock)
150# define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock) 158# define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock)
159# define mutex_lock_nest_lock(lock, nest_lock) mutex_lock(lock)
151#endif 160#endif
152 161
153/* 162/*
@@ -160,4 +169,8 @@ extern int mutex_trylock(struct mutex *lock);
160extern void mutex_unlock(struct mutex *lock); 169extern void mutex_unlock(struct mutex *lock);
161extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock); 170extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);
162 171
172#ifndef CONFIG_HAVE_ARCH_MUTEX_CPU_RELAX
173#define arch_mutex_cpu_relax() cpu_relax()
174#endif
175
163#endif 176#endif
diff --git a/include/linux/mxm-wmi.h b/include/linux/mxm-wmi.h
new file mode 100644
index 000000000000..617a2950523c
--- /dev/null
+++ b/include/linux/mxm-wmi.h
@@ -0,0 +1,33 @@
1/*
2 * MXM WMI driver
3 *
4 * Copyright(C) 2010 Red Hat.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef MXM_WMI_H
22#define MXM_WMI_H
23
24/* discrete adapters */
25#define MXM_MXDS_ADAPTER_0 0x0
26#define MXM_MXDS_ADAPTER_1 0x0
27/* integrated adapter */
28#define MXM_MXDS_ADAPTER_IGD 0x10
29int mxm_wmi_call_mxds(int adapter);
30int mxm_wmi_call_mxmx(int adapter);
31bool mxm_wmi_supported(void);
32
33#endif
diff --git a/include/linux/n_r3964.h b/include/linux/n_r3964.h
index de24af79ebd3..54b8e0d8d916 100644
--- a/include/linux/n_r3964.h
+++ b/include/linux/n_r3964.h
@@ -4,7 +4,6 @@
4 * Copyright by 4 * Copyright by
5 * Philips Automation Projects 5 * Philips Automation Projects
6 * Kassel (Germany) 6 * Kassel (Germany)
7 * http://www.pap-philips.de
8 * ----------------------------------------------------------- 7 * -----------------------------------------------------------
9 * This software may be used and distributed according to the terms of 8 * This software may be used and distributed according to the terms of
10 * the GNU General Public License, incorporated herein by reference. 9 * the GNU General Public License, incorporated herein by reference.
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 05b441d93642..eba45ea10298 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -19,7 +19,9 @@ struct nameidata {
19 struct path path; 19 struct path path;
20 struct qstr last; 20 struct qstr last;
21 struct path root; 21 struct path root;
22 struct inode *inode; /* path.dentry.d_inode */
22 unsigned int flags; 23 unsigned int flags;
24 unsigned seq;
23 int last_type; 25 int last_type;
24 unsigned depth; 26 unsigned depth;
25 char *saved_names[MAX_NESTED_LINKS + 1]; 27 char *saved_names[MAX_NESTED_LINKS + 1];
@@ -41,14 +43,17 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
41 * - require a directory 43 * - require a directory
42 * - ending slashes ok even for nonexistent files 44 * - ending slashes ok even for nonexistent files
43 * - internal "there are more path components" flag 45 * - internal "there are more path components" flag
44 * - locked when lookup done with dcache_lock held
45 * - dentry cache is untrusted; force a real lookup 46 * - dentry cache is untrusted; force a real lookup
47 * - suppress terminal automount
46 */ 48 */
47#define LOOKUP_FOLLOW 1 49#define LOOKUP_FOLLOW 0x0001
48#define LOOKUP_DIRECTORY 2 50#define LOOKUP_DIRECTORY 0x0002
49#define LOOKUP_CONTINUE 4 51#define LOOKUP_CONTINUE 0x0004
50#define LOOKUP_PARENT 16 52
51#define LOOKUP_REVAL 64 53#define LOOKUP_PARENT 0x0010
54#define LOOKUP_REVAL 0x0020
55#define LOOKUP_RCU 0x0040
56#define LOOKUP_NO_AUTOMOUNT 0x0080
52/* 57/*
53 * Intent data 58 * Intent data
54 */ 59 */
@@ -57,6 +62,10 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
57#define LOOKUP_EXCL 0x0400 62#define LOOKUP_EXCL 0x0400
58#define LOOKUP_RENAME_TARGET 0x0800 63#define LOOKUP_RENAME_TARGET 0x0800
59 64
65#define LOOKUP_JUMPED 0x1000
66#define LOOKUP_ROOT 0x2000
67#define LOOKUP_EMPTY 0x4000
68
60extern int user_path_at(int, const char __user *, unsigned, struct path *); 69extern int user_path_at(int, const char __user *, unsigned, struct path *);
61 70
62#define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path) 71#define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path)
@@ -66,7 +75,7 @@ extern int user_path_at(int, const char __user *, unsigned, struct path *);
66 75
67extern int kern_path(const char *, unsigned, struct path *); 76extern int kern_path(const char *, unsigned, struct path *);
68 77
69extern int path_lookup(const char *, unsigned, struct nameidata *); 78extern int kern_path_parent(const char *, struct nameidata *);
70extern int vfs_path_lookup(struct dentry *, struct vfsmount *, 79extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
71 const char *, unsigned int, struct nameidata *); 80 const char *, unsigned int, struct nameidata *);
72 81
@@ -75,6 +84,7 @@ extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry
75 84
76extern struct dentry *lookup_one_len(const char *, struct dentry *, int); 85extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
77 86
87extern int follow_down_one(struct path *);
78extern int follow_down(struct path *); 88extern int follow_down(struct path *);
79extern int follow_up(struct path *); 89extern int follow_up(struct path *);
80 90
diff --git a/include/linux/ncp_fs.h b/include/linux/ncp_fs.h
index 4522aed00906..e13eefef0653 100644
--- a/include/linux/ncp_fs.h
+++ b/include/linux/ncp_fs.h
@@ -143,132 +143,4 @@ struct ncp_nls_ioctl
143#define NCP_MAXPATHLEN 255 143#define NCP_MAXPATHLEN 255
144#define NCP_MAXNAMELEN 14 144#define NCP_MAXNAMELEN 14
145 145
146#ifdef __KERNEL__
147
148#include <linux/ncp_fs_i.h>
149#include <linux/ncp_fs_sb.h>
150
151/* define because it is easy to change PRINTK to {*}PRINTK */
152#define PRINTK(format, args...) printk(KERN_DEBUG format , ## args)
153
154#undef NCPFS_PARANOIA
155#ifdef NCPFS_PARANOIA
156#define PPRINTK(format, args...) PRINTK(format , ## args)
157#else
158#define PPRINTK(format, args...)
159#endif
160
161#ifndef DEBUG_NCP
162#define DEBUG_NCP 0
163#endif
164#if DEBUG_NCP > 0
165#define DPRINTK(format, args...) PRINTK(format , ## args)
166#else
167#define DPRINTK(format, args...)
168#endif
169#if DEBUG_NCP > 1
170#define DDPRINTK(format, args...) PRINTK(format , ## args)
171#else
172#define DDPRINTK(format, args...)
173#endif
174
175#define NCP_MAX_RPC_TIMEOUT (6*HZ)
176
177
178struct ncp_entry_info {
179 struct nw_info_struct i;
180 ino_t ino;
181 int opened;
182 int access;
183 unsigned int volume;
184 __u8 file_handle[6];
185};
186
187static inline struct ncp_server *NCP_SBP(struct super_block *sb)
188{
189 return sb->s_fs_info;
190}
191
192#define NCP_SERVER(inode) NCP_SBP((inode)->i_sb)
193static inline struct ncp_inode_info *NCP_FINFO(struct inode *inode)
194{
195 return container_of(inode, struct ncp_inode_info, vfs_inode);
196}
197
198/* linux/fs/ncpfs/inode.c */
199int ncp_notify_change(struct dentry *, struct iattr *);
200struct inode *ncp_iget(struct super_block *, struct ncp_entry_info *);
201void ncp_update_inode(struct inode *, struct ncp_entry_info *);
202void ncp_update_inode2(struct inode *, struct ncp_entry_info *);
203
204/* linux/fs/ncpfs/dir.c */
205extern const struct inode_operations ncp_dir_inode_operations;
206extern const struct file_operations ncp_dir_operations;
207extern const struct dentry_operations ncp_root_dentry_operations;
208int ncp_conn_logged_in(struct super_block *);
209int ncp_date_dos2unix(__le16 time, __le16 date);
210void ncp_date_unix2dos(int unix_date, __le16 * time, __le16 * date);
211
212/* linux/fs/ncpfs/ioctl.c */
213long ncp_ioctl(struct file *, unsigned int, unsigned long);
214long ncp_compat_ioctl(struct file *, unsigned int, unsigned long);
215
216/* linux/fs/ncpfs/sock.c */
217int ncp_request2(struct ncp_server *server, int function,
218 void* reply, int max_reply_size);
219static inline int ncp_request(struct ncp_server *server, int function) {
220 return ncp_request2(server, function, server->packet, server->packet_size);
221}
222int ncp_connect(struct ncp_server *server);
223int ncp_disconnect(struct ncp_server *server);
224void ncp_lock_server(struct ncp_server *server);
225void ncp_unlock_server(struct ncp_server *server);
226
227/* linux/fs/ncpfs/symlink.c */
228#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
229extern const struct address_space_operations ncp_symlink_aops;
230int ncp_symlink(struct inode*, struct dentry*, const char*);
231#endif
232
233/* linux/fs/ncpfs/file.c */
234extern const struct inode_operations ncp_file_inode_operations;
235extern const struct file_operations ncp_file_operations;
236int ncp_make_open(struct inode *, int);
237
238/* linux/fs/ncpfs/mmap.c */
239int ncp_mmap(struct file *, struct vm_area_struct *);
240
241/* linux/fs/ncpfs/ncplib_kernel.c */
242int ncp_make_closed(struct inode *);
243
244#define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber])
245
246static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator)
247{
248#ifdef CONFIG_NCPFS_SMALLDOS
249 int ns = ncp_namespace(i);
250
251 if ((ns == NW_NS_DOS)
252#ifdef CONFIG_NCPFS_OS2_NS
253 || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
254#endif /* CONFIG_NCPFS_OS2_NS */
255 )
256 return 0;
257#endif /* CONFIG_NCPFS_SMALLDOS */
258 return 1;
259}
260
261#define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS)
262
263static inline int ncp_case_sensitive(struct inode *i)
264{
265#ifdef CONFIG_NCPFS_NFS_NS
266 return ncp_namespace(i) == NW_NS_NFS;
267#else
268 return 0;
269#endif /* CONFIG_NCPFS_NFS_NS */
270}
271
272#endif /* __KERNEL__ */
273
274#endif /* _LINUX_NCP_FS_H */ 146#endif /* _LINUX_NCP_FS_H */
diff --git a/include/linux/ncp_fs_i.h b/include/linux/ncp_fs_i.h
deleted file mode 100644
index 4b0bec477846..000000000000
--- a/include/linux/ncp_fs_i.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * ncp_fs_i.h
3 *
4 * Copyright (C) 1995 Volker Lendecke
5 *
6 */
7
8#ifndef _LINUX_NCP_FS_I
9#define _LINUX_NCP_FS_I
10
11/*
12 * This is the ncpfs part of the inode structure. This must contain
13 * all the information we need to work with an inode after creation.
14 */
15struct ncp_inode_info {
16 __le32 dirEntNum;
17 __le32 DosDirNum;
18 __u8 volNumber;
19 __le32 nwattr;
20 struct mutex open_mutex;
21 atomic_t opened;
22 int access;
23 int flags;
24#define NCPI_KLUDGE_SYMLINK 0x0001
25 __u8 file_handle[6];
26 struct inode vfs_inode;
27};
28
29#endif /* _LINUX_NCP_FS_I */
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
deleted file mode 100644
index 8da05bc098ca..000000000000
--- a/include/linux/ncp_fs_sb.h
+++ /dev/null
@@ -1,162 +0,0 @@
1/*
2 * ncp_fs_sb.h
3 *
4 * Copyright (C) 1995, 1996 by Volker Lendecke
5 *
6 */
7
8#ifndef _NCP_FS_SB
9#define _NCP_FS_SB
10
11#include <linux/types.h>
12#include <linux/ncp_mount.h>
13#include <linux/net.h>
14#include <linux/mutex.h>
15#include <linux/backing-dev.h>
16
17#ifdef __KERNEL__
18
19#include <linux/workqueue.h>
20
21#define NCP_DEFAULT_OPTIONS 0 /* 2 for packet signatures */
22
23struct sock;
24
25struct ncp_server {
26
27 struct ncp_mount_data_kernel m; /* Nearly all of the mount data is of
28 interest for us later, so we store
29 it completely. */
30
31 __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2];
32
33 struct file *ncp_filp; /* File pointer to ncp socket */
34 struct socket *ncp_sock;/* ncp socket */
35 struct file *info_filp;
36 struct socket *info_sock;
37
38 u8 sequence;
39 u8 task;
40 u16 connection; /* Remote connection number */
41
42 u8 completion; /* Status message from server */
43 u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
44 requests allowed anymore.
45 Bit 0 = 1 ==> Server is down. */
46
47 int buffer_size; /* Negotiated bufsize */
48
49 int reply_size; /* Size of last reply */
50
51 int packet_size;
52 unsigned char *packet; /* Here we prepare requests and
53 receive replies */
54 unsigned char *txbuf; /* Storage for current request */
55 unsigned char *rxbuf; /* Storage for reply to current request */
56
57 int lock; /* To prevent mismatch in protocols. */
58 struct mutex mutex;
59
60 int current_size; /* for packet preparation */
61 int has_subfunction;
62 int ncp_reply_size;
63
64 int root_setuped;
65
66 /* info for packet signing */
67 int sign_wanted; /* 1=Server needs signed packets */
68 int sign_active; /* 0=don't do signing, 1=do */
69 char sign_root[8]; /* generated from password and encr. key */
70 char sign_last[16];
71
72 /* Authentication info: NDS or BINDERY, username */
73 struct {
74 int auth_type;
75 size_t object_name_len;
76 void* object_name;
77 int object_type;
78 } auth;
79 /* Password info */
80 struct {
81 size_t len;
82 void* data;
83 } priv;
84
85 /* nls info: codepage for volume and charset for I/O */
86 struct nls_table *nls_vol;
87 struct nls_table *nls_io;
88
89 /* maximum age in jiffies */
90 int dentry_ttl;
91
92 /* miscellaneous */
93 unsigned int flags;
94
95 spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
96
97 void (*data_ready)(struct sock* sk, int len);
98 void (*error_report)(struct sock* sk);
99 void (*write_space)(struct sock* sk); /* STREAM mode only */
100 struct {
101 struct work_struct tq; /* STREAM/DGRAM: data/error ready */
102 struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
103 struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
104
105 unsigned int state; /* STREAM only: receiver state */
106 struct {
107 __u32 magic __packed;
108 __u32 len __packed;
109 __u16 type __packed;
110 __u16 p1 __packed;
111 __u16 p2 __packed;
112 __u16 p3 __packed;
113 __u16 type2 __packed;
114 } buf; /* STREAM only: temporary buffer */
115 unsigned char* ptr; /* STREAM only: pointer to data */
116 size_t len; /* STREAM only: length of data to receive */
117 } rcv;
118 struct {
119 struct list_head requests; /* STREAM only: queued requests */
120 struct work_struct tq; /* STREAM only: transmitter ready */
121 struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
122 } tx;
123 struct timer_list timeout_tm; /* DGRAM only: timeout timer */
124 struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */
125 int timeout_last; /* DGRAM only: current timeout length */
126 int timeout_retries; /* DGRAM only: retries left */
127 struct {
128 size_t len;
129 __u8 data[128];
130 } unexpected_packet;
131 struct backing_dev_info bdi;
132};
133
134extern void ncp_tcp_rcv_proc(struct work_struct *work);
135extern void ncp_tcp_tx_proc(struct work_struct *work);
136extern void ncpdgram_rcv_proc(struct work_struct *work);
137extern void ncpdgram_timeout_proc(struct work_struct *work);
138extern void ncpdgram_timeout_call(unsigned long server);
139extern void ncp_tcp_data_ready(struct sock* sk, int len);
140extern void ncp_tcp_write_space(struct sock* sk);
141extern void ncp_tcp_error_report(struct sock* sk);
142
143#define NCP_FLAG_UTF8 1
144
145#define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag))
146#define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag))
147#define NCP_IS_FLAG(server, flag) ((server)->flags & (flag))
148
149static inline int ncp_conn_valid(struct ncp_server *server)
150{
151 return ((server->conn_status & 0x11) == 0);
152}
153
154static inline void ncp_invalidate_conn(struct ncp_server *server)
155{
156 server->conn_status |= 0x01;
157}
158
159#endif /* __KERNEL__ */
160
161#endif
162
diff --git a/include/linux/ncp_mount.h b/include/linux/ncp_mount.h
index a2b549eb1eca..dfcbea2d889f 100644
--- a/include/linux/ncp_mount.h
+++ b/include/linux/ncp_mount.h
@@ -68,26 +68,4 @@ struct ncp_mount_data_v4 {
68 68
69#define NCP_MOUNT_VERSION_V5 (5) /* Text only */ 69#define NCP_MOUNT_VERSION_V5 (5) /* Text only */
70 70
71#ifdef __KERNEL__
72
73struct ncp_mount_data_kernel {
74 unsigned long flags; /* NCP_MOUNT_* flags */
75 unsigned int int_flags; /* internal flags */
76#define NCP_IMOUNT_LOGGEDIN_POSSIBLE 0x0001
77 __kernel_uid32_t mounted_uid; /* Who may umount() this filesystem? */
78 struct pid *wdog_pid; /* Who cares for our watchdog packets? */
79 unsigned int ncp_fd; /* The socket to the ncp port */
80 unsigned int time_out; /* How long should I wait after
81 sending a NCP request? */
82 unsigned int retry_count; /* And how often should I retry? */
83 unsigned char mounted_vol[NCP_VOLNAME_LEN + 1];
84 __kernel_uid32_t uid;
85 __kernel_gid32_t gid;
86 __kernel_mode_t file_mode;
87 __kernel_mode_t dir_mode;
88 int info_fd;
89};
90
91#endif /* __KERNEL__ */
92
93#endif 71#endif
diff --git a/include/linux/net.h b/include/linux/net.h
index dee0b11a8759..b29923006b11 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -42,6 +42,7 @@
42#define SYS_RECVMSG 17 /* sys_recvmsg(2) */ 42#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
43#define SYS_ACCEPT4 18 /* sys_accept4(2) */ 43#define SYS_ACCEPT4 18 /* sys_accept4(2) */
44#define SYS_RECVMMSG 19 /* sys_recvmmsg(2) */ 44#define SYS_RECVMMSG 19 /* sys_recvmmsg(2) */
45#define SYS_SENDMMSG 20 /* sys_sendmmsg(2) */
45 46
46typedef enum { 47typedef enum {
47 SS_FREE = 0, /* not allocated */ 48 SS_FREE = 0, /* not allocated */
@@ -118,6 +119,7 @@ enum sock_shutdown_cmd {
118}; 119};
119 120
120struct socket_wq { 121struct socket_wq {
122 /* Note: wait MUST be first field of socket_wq */
121 wait_queue_head_t wait; 123 wait_queue_head_t wait;
122 struct fasync_struct *fasync_list; 124 struct fasync_struct *fasync_list;
123 struct rcu_head rcu; 125 struct rcu_head rcu;
@@ -142,7 +144,7 @@ struct socket {
142 144
143 unsigned long flags; 145 unsigned long flags;
144 146
145 struct socket_wq *wq; 147 struct socket_wq __rcu *wq;
146 148
147 struct file *file; 149 struct file *file;
148 struct sock *sk; 150 struct sock *sk;
@@ -229,6 +231,8 @@ enum {
229extern int sock_wake_async(struct socket *sk, int how, int band); 231extern int sock_wake_async(struct socket *sk, int how, int band);
230extern int sock_register(const struct net_proto_family *fam); 232extern int sock_register(const struct net_proto_family *fam);
231extern void sock_unregister(int family); 233extern void sock_unregister(int family);
234extern int __sock_create(struct net *net, int family, int type, int proto,
235 struct socket **res, int kern);
232extern int sock_create(int family, int type, int proto, 236extern int sock_create(int family, int type, int proto,
233 struct socket **res); 237 struct socket **res);
234extern int sock_create_kern(int family, int type, int proto, 238extern int sock_create_kern(int family, int type, int proto,
@@ -285,11 +289,5 @@ extern int kernel_sock_shutdown(struct socket *sock,
285 MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \ 289 MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
286 "-type-" __stringify(type)) 290 "-type-" __stringify(type))
287 291
288#ifdef CONFIG_SYSCTL
289#include <linux/sysctl.h>
290#include <linux/ratelimit.h>
291extern struct ratelimit_state net_ratelimit_state;
292#endif
293
294#endif /* __KERNEL__ */ 292#endif /* __KERNEL__ */
295#endif /* _LINUX_NET_H */ 293#endif /* _LINUX_NET_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 46c36ffe20ee..9e19477991ad 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -138,6 +138,9 @@ static inline bool dev_xmit_complete(int rc)
138 138
139#define MAX_ADDR_LEN 32 /* Largest hardware address length */ 139#define MAX_ADDR_LEN 32 /* Largest hardware address length */
140 140
141/* Initial net device group. All devices belong to group 0 by default. */
142#define INIT_NETDEV_GROUP 0
143
141#ifdef __KERNEL__ 144#ifdef __KERNEL__
142/* 145/*
143 * Compute the worst case header length according to the protocols 146 * Compute the worst case header length according to the protocols
@@ -228,9 +231,9 @@ struct netdev_hw_addr {
228#define NETDEV_HW_ADDR_T_SLAVE 3 231#define NETDEV_HW_ADDR_T_SLAVE 3
229#define NETDEV_HW_ADDR_T_UNICAST 4 232#define NETDEV_HW_ADDR_T_UNICAST 4
230#define NETDEV_HW_ADDR_T_MULTICAST 5 233#define NETDEV_HW_ADDR_T_MULTICAST 5
231 int refcount;
232 bool synced; 234 bool synced;
233 bool global_use; 235 bool global_use;
236 int refcount;
234 struct rcu_head rcu_head; 237 struct rcu_head rcu_head;
235}; 238};
236 239
@@ -281,6 +284,12 @@ struct hh_cache {
281 unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; 284 unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
282}; 285};
283 286
287static inline void hh_cache_put(struct hh_cache *hh)
288{
289 if (atomic_dec_and_test(&hh->hh_refcnt))
290 kfree(hh);
291}
292
284/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much. 293/* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much.
285 * Alternative is: 294 * Alternative is:
286 * dev->hard_header_len ? (dev->hard_header_len + 295 * dev->hard_header_len ? (dev->hard_header_len +
@@ -381,7 +390,55 @@ enum gro_result {
381}; 390};
382typedef enum gro_result gro_result_t; 391typedef enum gro_result gro_result_t;
383 392
384typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); 393/*
394 * enum rx_handler_result - Possible return values for rx_handlers.
395 * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it
396 * further.
397 * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in
398 * case skb->dev was changed by rx_handler.
399 * @RX_HANDLER_EXACT: Force exact delivery, no wildcard.
400 * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called.
401 *
402 * rx_handlers are functions called from inside __netif_receive_skb(), to do
403 * special processing of the skb, prior to delivery to protocol handlers.
404 *
405 * Currently, a net_device can only have a single rx_handler registered. Trying
406 * to register a second rx_handler will return -EBUSY.
407 *
408 * To register a rx_handler on a net_device, use netdev_rx_handler_register().
409 * To unregister a rx_handler on a net_device, use
410 * netdev_rx_handler_unregister().
411 *
412 * Upon return, rx_handler is expected to tell __netif_receive_skb() what to
413 * do with the skb.
414 *
415 * If the rx_handler consumed to skb in some way, it should return
416 * RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for
417 * the skb to be delivered in some other ways.
418 *
419 * If the rx_handler changed skb->dev, to divert the skb to another
420 * net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the
421 * new device will be called if it exists.
422 *
423 * If the rx_handler consider the skb should be ignored, it should return
424 * RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that
425 * are registred on exact device (ptype->dev == skb->dev).
426 *
427 * If the rx_handler didn't changed skb->dev, but want the skb to be normally
428 * delivered, it should return RX_HANDLER_PASS.
429 *
430 * A device without a registered rx_handler will behave as if rx_handler
431 * returned RX_HANDLER_PASS.
432 */
433
434enum rx_handler_result {
435 RX_HANDLER_CONSUMED,
436 RX_HANDLER_ANOTHER,
437 RX_HANDLER_EXACT,
438 RX_HANDLER_PASS,
439};
440typedef enum rx_handler_result rx_handler_result_t;
441typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
385 442
386extern void __napi_schedule(struct napi_struct *n); 443extern void __napi_schedule(struct napi_struct *n);
387 444
@@ -487,6 +544,8 @@ static inline void napi_synchronize(const struct napi_struct *n)
487enum netdev_queue_state_t { 544enum netdev_queue_state_t {
488 __QUEUE_STATE_XOFF, 545 __QUEUE_STATE_XOFF,
489 __QUEUE_STATE_FROZEN, 546 __QUEUE_STATE_FROZEN,
547#define QUEUE_STATE_XOFF_OR_FROZEN ((1 << __QUEUE_STATE_XOFF) | \
548 (1 << __QUEUE_STATE_FROZEN))
490}; 549};
491 550
492struct netdev_queue { 551struct netdev_queue {
@@ -497,6 +556,12 @@ struct netdev_queue {
497 struct Qdisc *qdisc; 556 struct Qdisc *qdisc;
498 unsigned long state; 557 unsigned long state;
499 struct Qdisc *qdisc_sleeping; 558 struct Qdisc *qdisc_sleeping;
559#ifdef CONFIG_RPS
560 struct kobject kobj;
561#endif
562#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
563 int numa_node;
564#endif
500/* 565/*
501 * write mostly part 566 * write mostly part
502 */ 567 */
@@ -506,11 +571,24 @@ struct netdev_queue {
506 * please use this field instead of dev->trans_start 571 * please use this field instead of dev->trans_start
507 */ 572 */
508 unsigned long trans_start; 573 unsigned long trans_start;
509 u64 tx_bytes;
510 u64 tx_packets;
511 u64 tx_dropped;
512} ____cacheline_aligned_in_smp; 574} ____cacheline_aligned_in_smp;
513 575
576static inline int netdev_queue_numa_node_read(const struct netdev_queue *q)
577{
578#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
579 return q->numa_node;
580#else
581 return NUMA_NO_NODE;
582#endif
583}
584
585static inline void netdev_queue_numa_node_write(struct netdev_queue *q, int node)
586{
587#if defined(CONFIG_XPS) && defined(CONFIG_NUMA)
588 q->numa_node = node;
589#endif
590}
591
514#ifdef CONFIG_RPS 592#ifdef CONFIG_RPS
515/* 593/*
516 * This structure holds an RPS map which can be of variable length. The 594 * This structure holds an RPS map which can be of variable length. The
@@ -524,14 +602,16 @@ struct rps_map {
524#define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) 602#define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16)))
525 603
526/* 604/*
527 * The rps_dev_flow structure contains the mapping of a flow to a CPU and the 605 * The rps_dev_flow structure contains the mapping of a flow to a CPU, the
528 * tail pointer for that CPU's input queue at the time of last enqueue. 606 * tail pointer for that CPU's input queue at the time of last enqueue, and
607 * a hardware filter index.
529 */ 608 */
530struct rps_dev_flow { 609struct rps_dev_flow {
531 u16 cpu; 610 u16 cpu;
532 u16 fill; 611 u16 filter;
533 unsigned int last_qtail; 612 unsigned int last_qtail;
534}; 613};
614#define RPS_NO_FILTER 0xffff
535 615
536/* 616/*
537 * The rps_dev_flow_table structure contains a table of flow mappings. 617 * The rps_dev_flow_table structure contains a table of flow mappings.
@@ -579,18 +659,56 @@ static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table,
579 table->ents[hash & table->mask] = RPS_NO_CPU; 659 table->ents[hash & table->mask] = RPS_NO_CPU;
580} 660}
581 661
582extern struct rps_sock_flow_table *rps_sock_flow_table; 662extern struct rps_sock_flow_table __rcu *rps_sock_flow_table;
663
664#ifdef CONFIG_RFS_ACCEL
665extern bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index,
666 u32 flow_id, u16 filter_id);
667#endif
583 668
584/* This structure contains an instance of an RX queue. */ 669/* This structure contains an instance of an RX queue. */
585struct netdev_rx_queue { 670struct netdev_rx_queue {
586 struct rps_map *rps_map; 671 struct rps_map __rcu *rps_map;
587 struct rps_dev_flow_table *rps_flow_table; 672 struct rps_dev_flow_table __rcu *rps_flow_table;
588 struct kobject kobj; 673 struct kobject kobj;
589 struct netdev_rx_queue *first; 674 struct net_device *dev;
590 atomic_t count;
591} ____cacheline_aligned_in_smp; 675} ____cacheline_aligned_in_smp;
592#endif /* CONFIG_RPS */ 676#endif /* CONFIG_RPS */
593 677
678#ifdef CONFIG_XPS
679/*
680 * This structure holds an XPS map which can be of variable length. The
681 * map is an array of queues.
682 */
683struct xps_map {
684 unsigned int len;
685 unsigned int alloc_len;
686 struct rcu_head rcu;
687 u16 queues[0];
688};
689#define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + (_num * sizeof(u16)))
690#define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES - sizeof(struct xps_map)) \
691 / sizeof(u16))
692
693/*
694 * This structure holds all XPS maps for device. Maps are indexed by CPU.
695 */
696struct xps_dev_maps {
697 struct rcu_head rcu;
698 struct xps_map __rcu *cpu_map[0];
699};
700#define XPS_DEV_MAPS_SIZE (sizeof(struct xps_dev_maps) + \
701 (nr_cpu_ids * sizeof(struct xps_map *)))
702#endif /* CONFIG_XPS */
703
704#define TC_MAX_QUEUE 16
705#define TC_BITMASK 15
706/* HW offloaded queuing disciplines txq count and offset maps */
707struct netdev_tc_txq {
708 u16 count;
709 u16 offset;
710};
711
594/* 712/*
595 * This structure defines the management hooks for network devices. 713 * This structure defines the management hooks for network devices.
596 * The following hooks can be defined; unless noted otherwise, they are 714 * The following hooks can be defined; unless noted otherwise, they are
@@ -677,7 +795,7 @@ struct netdev_rx_queue {
677 * neither operation. 795 * neither operation.
678 * 796 *
679 * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); 797 * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp);
680 * If device support VLAN receive accleration 798 * If device support VLAN receive acceleration
681 * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called 799 * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called
682 * when vlan groups for the device changes. Note: grp is NULL 800 * when vlan groups for the device changes. Note: grp is NULL
683 * if no vlan's groups are being used. 801 * if no vlan's groups are being used.
@@ -701,6 +819,74 @@ struct netdev_rx_queue {
701 * int (*ndo_set_vf_port)(struct net_device *dev, int vf, 819 * int (*ndo_set_vf_port)(struct net_device *dev, int vf,
702 * struct nlattr *port[]); 820 * struct nlattr *port[]);
703 * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); 821 * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb);
822 * int (*ndo_setup_tc)(struct net_device *dev, u8 tc)
823 * Called to setup 'tc' number of traffic classes in the net device. This
824 * is always called from the stack with the rtnl lock held and netif tx
825 * queues stopped. This allows the netdevice to perform queue management
826 * safely.
827 *
828 * Fiber Channel over Ethernet (FCoE) offload functions.
829 * int (*ndo_fcoe_enable)(struct net_device *dev);
830 * Called when the FCoE protocol stack wants to start using LLD for FCoE
831 * so the underlying device can perform whatever needed configuration or
832 * initialization to support acceleration of FCoE traffic.
833 *
834 * int (*ndo_fcoe_disable)(struct net_device *dev);
835 * Called when the FCoE protocol stack wants to stop using LLD for FCoE
836 * so the underlying device can perform whatever needed clean-ups to
837 * stop supporting acceleration of FCoE traffic.
838 *
839 * int (*ndo_fcoe_ddp_setup)(struct net_device *dev, u16 xid,
840 * struct scatterlist *sgl, unsigned int sgc);
841 * Called when the FCoE Initiator wants to initialize an I/O that
842 * is a possible candidate for Direct Data Placement (DDP). The LLD can
843 * perform necessary setup and returns 1 to indicate the device is set up
844 * successfully to perform DDP on this I/O, otherwise this returns 0.
845 *
846 * int (*ndo_fcoe_ddp_done)(struct net_device *dev, u16 xid);
847 * Called when the FCoE Initiator/Target is done with the DDPed I/O as
848 * indicated by the FC exchange id 'xid', so the underlying device can
849 * clean up and reuse resources for later DDP requests.
850 *
851 * int (*ndo_fcoe_ddp_target)(struct net_device *dev, u16 xid,
852 * struct scatterlist *sgl, unsigned int sgc);
853 * Called when the FCoE Target wants to initialize an I/O that
854 * is a possible candidate for Direct Data Placement (DDP). The LLD can
855 * perform necessary setup and returns 1 to indicate the device is set up
856 * successfully to perform DDP on this I/O, otherwise this returns 0.
857 *
858 * int (*ndo_fcoe_get_wwn)(struct net_device *dev, u64 *wwn, int type);
859 * Called when the underlying device wants to override default World Wide
860 * Name (WWN) generation mechanism in FCoE protocol stack to pass its own
861 * World Wide Port Name (WWPN) or World Wide Node Name (WWNN) to the FCoE
862 * protocol stack to use.
863 *
864 * RFS acceleration.
865 * int (*ndo_rx_flow_steer)(struct net_device *dev, const struct sk_buff *skb,
866 * u16 rxq_index, u32 flow_id);
867 * Set hardware filter for RFS. rxq_index is the target queue index;
868 * flow_id is a flow ID to be passed to rps_may_expire_flow() later.
869 * Return the filter ID on success, or a negative error code.
870 *
871 * Slave management functions (for bridge, bonding, etc). User should
872 * call netdev_set_master() to set dev->master properly.
873 * int (*ndo_add_slave)(struct net_device *dev, struct net_device *slave_dev);
874 * Called to make another netdev an underling.
875 *
876 * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev);
877 * Called to release previously enslaved netdev.
878 *
879 * Feature/offload setting functions.
880 * u32 (*ndo_fix_features)(struct net_device *dev, u32 features);
881 * Adjusts the requested feature flags according to device-specific
882 * constraints, and returns the resulting flags. Must not modify
883 * the device state.
884 *
885 * int (*ndo_set_features)(struct net_device *dev, u32 features);
886 * Called to update device configuration to new features. Passed
887 * feature set might be less than what was returned by ndo_fix_features()).
888 * Must return >0 or -errno if it changed dev->features itself.
889 *
704 */ 890 */
705#define HAVE_NET_DEVICE_OPS 891#define HAVE_NET_DEVICE_OPS
706struct net_device_ops { 892struct net_device_ops {
@@ -759,6 +945,7 @@ struct net_device_ops {
759 struct nlattr *port[]); 945 struct nlattr *port[]);
760 int (*ndo_get_vf_port)(struct net_device *dev, 946 int (*ndo_get_vf_port)(struct net_device *dev,
761 int vf, struct sk_buff *skb); 947 int vf, struct sk_buff *skb);
948 int (*ndo_setup_tc)(struct net_device *dev, u8 tc);
762#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) 949#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
763 int (*ndo_fcoe_enable)(struct net_device *dev); 950 int (*ndo_fcoe_enable)(struct net_device *dev);
764 int (*ndo_fcoe_disable)(struct net_device *dev); 951 int (*ndo_fcoe_disable)(struct net_device *dev);
@@ -768,11 +955,29 @@ struct net_device_ops {
768 unsigned int sgc); 955 unsigned int sgc);
769 int (*ndo_fcoe_ddp_done)(struct net_device *dev, 956 int (*ndo_fcoe_ddp_done)(struct net_device *dev,
770 u16 xid); 957 u16 xid);
958 int (*ndo_fcoe_ddp_target)(struct net_device *dev,
959 u16 xid,
960 struct scatterlist *sgl,
961 unsigned int sgc);
771#define NETDEV_FCOE_WWNN 0 962#define NETDEV_FCOE_WWNN 0
772#define NETDEV_FCOE_WWPN 1 963#define NETDEV_FCOE_WWPN 1
773 int (*ndo_fcoe_get_wwn)(struct net_device *dev, 964 int (*ndo_fcoe_get_wwn)(struct net_device *dev,
774 u64 *wwn, int type); 965 u64 *wwn, int type);
775#endif 966#endif
967#ifdef CONFIG_RFS_ACCEL
968 int (*ndo_rx_flow_steer)(struct net_device *dev,
969 const struct sk_buff *skb,
970 u16 rxq_index,
971 u32 flow_id);
972#endif
973 int (*ndo_add_slave)(struct net_device *dev,
974 struct net_device *slave_dev);
975 int (*ndo_del_slave)(struct net_device *dev,
976 struct net_device *slave_dev);
977 u32 (*ndo_fix_features)(struct net_device *dev,
978 u32 features);
979 int (*ndo_set_features)(struct net_device *dev,
980 u32 features);
776}; 981};
777 982
778/* 983/*
@@ -815,17 +1020,24 @@ struct net_device {
815 * part of the usual set specified in Space.c. 1020 * part of the usual set specified in Space.c.
816 */ 1021 */
817 1022
818 unsigned char if_port; /* Selectable AUI, TP,..*/
819 unsigned char dma; /* DMA channel */
820
821 unsigned long state; 1023 unsigned long state;
822 1024
823 struct list_head dev_list; 1025 struct list_head dev_list;
824 struct list_head napi_list; 1026 struct list_head napi_list;
825 struct list_head unreg_list; 1027 struct list_head unreg_list;
826 1028
827 /* Net device features */ 1029 /* currently active device features */
828 unsigned long features; 1030 u32 features;
1031 /* user-changeable features */
1032 u32 hw_features;
1033 /* user-requested features */
1034 u32 wanted_features;
1035 /* mask of features inheritable by VLAN devices */
1036 u32 vlan_features;
1037
1038 /* Net device feature bits; if you change something,
1039 * also update netdev_features_strings[] in ethtool.c */
1040
829#define NETIF_F_SG 1 /* Scatter/gather IO. */ 1041#define NETIF_F_SG 1 /* Scatter/gather IO. */
830#define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */ 1042#define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */
831#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ 1043#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
@@ -850,6 +1062,9 @@ struct net_device {
850#define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/ 1062#define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/
851#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */ 1063#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */
852#define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */ 1064#define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */
1065#define NETIF_F_RXCSUM (1 << 29) /* Receive checksumming offload */
1066#define NETIF_F_NOCACHE_COPY (1 << 30) /* Use no-cache copyfromuser */
1067#define NETIF_F_LOOPBACK (1 << 31) /* Enable loopback */
853 1068
854 /* Segmentation offload features */ 1069 /* Segmentation offload features */
855#define NETIF_F_GSO_SHIFT 16 1070#define NETIF_F_GSO_SHIFT 16
@@ -861,6 +1076,12 @@ struct net_device {
861#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT) 1076#define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
862#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) 1077#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
863 1078
1079 /* Features valid for ethtool to change */
1080 /* = all defined minus driver/device-class-related */
1081#define NETIF_F_NEVER_CHANGE (NETIF_F_VLAN_CHALLENGED | \
1082 NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
1083#define NETIF_F_ETHTOOL_BITS (0xff3fffff & ~NETIF_F_NEVER_CHANGE)
1084
864 /* List of features with software fallbacks. */ 1085 /* List of features with software fallbacks. */
865#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ 1086#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \
866 NETIF_F_TSO6 | NETIF_F_UFO) 1087 NETIF_F_TSO6 | NETIF_F_UFO)
@@ -871,19 +1092,35 @@ struct net_device {
871#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM) 1092#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
872#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) 1093#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
873 1094
1095#define NETIF_F_ALL_TSO (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
1096
1097#define NETIF_F_ALL_FCOE (NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
1098 NETIF_F_FSO)
1099
874 /* 1100 /*
875 * If one device supports one of these features, then enable them 1101 * If one device supports one of these features, then enable them
876 * for all in netdev_increment_features. 1102 * for all in netdev_increment_features.
877 */ 1103 */
878#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ 1104#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
879 NETIF_F_SG | NETIF_F_HIGHDMA | \ 1105 NETIF_F_SG | NETIF_F_HIGHDMA | \
880 NETIF_F_FRAGLIST) 1106 NETIF_F_FRAGLIST | NETIF_F_VLAN_CHALLENGED)
1107 /*
1108 * If one device doesn't support one of these features, then disable it
1109 * for all in netdev_increment_features.
1110 */
1111#define NETIF_F_ALL_FOR_ALL (NETIF_F_NOCACHE_COPY | NETIF_F_FSO)
1112
1113 /* changeable features with no special hardware requirements */
1114#define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO)
881 1115
882 /* Interface index. Unique device identifier */ 1116 /* Interface index. Unique device identifier */
883 int ifindex; 1117 int ifindex;
884 int iflink; 1118 int iflink;
885 1119
886 struct net_device_stats stats; 1120 struct net_device_stats stats;
1121 atomic_long_t rx_dropped; /* dropped packets by core network
1122 * Do not use this in drivers.
1123 */
887 1124
888#ifdef CONFIG_WIRELESS_EXT 1125#ifdef CONFIG_WIRELESS_EXT
889 /* List of functions to handle Wireless Extensions (instead of ioctl). 1126 /* List of functions to handle Wireless Extensions (instead of ioctl).
@@ -900,13 +1137,16 @@ struct net_device {
900 const struct header_ops *header_ops; 1137 const struct header_ops *header_ops;
901 1138
902 unsigned int flags; /* interface flags (a la BSD) */ 1139 unsigned int flags; /* interface flags (a la BSD) */
1140 unsigned int priv_flags; /* Like 'flags' but invisible to userspace. */
903 unsigned short gflags; 1141 unsigned short gflags;
904 unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */
905 unsigned short padded; /* How much padding added by alloc_netdev() */ 1142 unsigned short padded; /* How much padding added by alloc_netdev() */
906 1143
907 unsigned char operstate; /* RFC2863 operstate */ 1144 unsigned char operstate; /* RFC2863 operstate */
908 unsigned char link_mode; /* mapping policy to operstate */ 1145 unsigned char link_mode; /* mapping policy to operstate */
909 1146
1147 unsigned char if_port; /* Selectable AUI, TP,..*/
1148 unsigned char dma; /* DMA channel */
1149
910 unsigned int mtu; /* interface MTU value */ 1150 unsigned int mtu; /* interface MTU value */
911 unsigned short type; /* interface hardware type */ 1151 unsigned short type; /* interface hardware type */
912 unsigned short hard_header_len; /* hardware hdr length */ 1152 unsigned short hard_header_len; /* hardware hdr length */
@@ -918,10 +1158,6 @@ struct net_device {
918 unsigned short needed_headroom; 1158 unsigned short needed_headroom;
919 unsigned short needed_tailroom; 1159 unsigned short needed_tailroom;
920 1160
921 struct net_device *master; /* Pointer to master device of a group,
922 * which this device is member of.
923 */
924
925 /* Interface address info. */ 1161 /* Interface address info. */
926 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 1162 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
927 unsigned char addr_assign_type; /* hw address assignment type */ 1163 unsigned char addr_assign_type; /* hw address assignment type */
@@ -937,23 +1173,37 @@ struct net_device {
937 1173
938 1174
939 /* Protocol specific pointers */ 1175 /* Protocol specific pointers */
940 1176
1177#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
1178 struct vlan_group __rcu *vlgrp; /* VLAN group */
1179#endif
941#ifdef CONFIG_NET_DSA 1180#ifdef CONFIG_NET_DSA
942 void *dsa_ptr; /* dsa specific data */ 1181 void *dsa_ptr; /* dsa specific data */
943#endif 1182#endif
944 void *atalk_ptr; /* AppleTalk link */ 1183 void *atalk_ptr; /* AppleTalk link */
945 void *ip_ptr; /* IPv4 specific data */ 1184 struct in_device __rcu *ip_ptr; /* IPv4 specific data */
946 void *dn_ptr; /* DECnet specific data */ 1185 struct dn_dev __rcu *dn_ptr; /* DECnet specific data */
947 void *ip6_ptr; /* IPv6 specific data */ 1186 struct inet6_dev __rcu *ip6_ptr; /* IPv6 specific data */
948 void *ec_ptr; /* Econet specific data */ 1187 void *ec_ptr; /* Econet specific data */
949 void *ax25_ptr; /* AX.25 specific data */ 1188 void *ax25_ptr; /* AX.25 specific data */
950 struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data, 1189 struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data,
951 assign before registering */ 1190 assign before registering */
952 1191
953/* 1192/*
954 * Cache line mostly used on receive path (including eth_type_trans()) 1193 * Cache lines mostly used on receive path (including eth_type_trans())
955 */ 1194 */
956 unsigned long last_rx; /* Time of last Rx */ 1195 unsigned long last_rx; /* Time of last Rx
1196 * This should not be set in
1197 * drivers, unless really needed,
1198 * because network stack (bonding)
1199 * use it if/when necessary, to
1200 * avoid dirtying this cache line.
1201 */
1202
1203 struct net_device *master; /* Pointer to master device of a group,
1204 * which this device is member of.
1205 */
1206
957 /* Interface address info used in eth_type_trans() */ 1207 /* Interface address info used in eth_type_trans() */
958 unsigned char *dev_addr; /* hw address, (before bcast 1208 unsigned char *dev_addr; /* hw address, (before bcast
959 because most packets are 1209 because most packets are
@@ -969,14 +1219,28 @@ struct net_device {
969 1219
970 struct netdev_rx_queue *_rx; 1220 struct netdev_rx_queue *_rx;
971 1221
972 /* Number of RX queues allocated at alloc_netdev_mq() time */ 1222 /* Number of RX queues allocated at register_netdev() time */
973 unsigned int num_rx_queues; 1223 unsigned int num_rx_queues;
1224
1225 /* Number of RX queues currently active in device */
1226 unsigned int real_num_rx_queues;
1227
1228#ifdef CONFIG_RFS_ACCEL
1229 /* CPU reverse-mapping for RX completion interrupts, indexed
1230 * by RX queue number. Assigned by driver. This must only be
1231 * set if the ndo_rx_flow_steer operation is defined. */
1232 struct cpu_rmap *rx_cpu_rmap;
1233#endif
974#endif 1234#endif
975 1235
976 struct netdev_queue rx_queue; 1236 rx_handler_func_t __rcu *rx_handler;
977 rx_handler_func_t *rx_handler; 1237 void __rcu *rx_handler_data;
978 void *rx_handler_data; 1238
1239 struct netdev_queue __rcu *ingress_queue;
979 1240
1241/*
1242 * Cache lines mostly used on transmit path
1243 */
980 struct netdev_queue *_tx ____cacheline_aligned_in_smp; 1244 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
981 1245
982 /* Number of TX queues allocated at alloc_netdev_mq() time */ 1246 /* Number of TX queues allocated at alloc_netdev_mq() time */
@@ -990,9 +1254,11 @@ struct net_device {
990 1254
991 unsigned long tx_queue_len; /* Max frames per queue allowed */ 1255 unsigned long tx_queue_len; /* Max frames per queue allowed */
992 spinlock_t tx_global_lock; 1256 spinlock_t tx_global_lock;
993/* 1257
994 * One part is mostly used on xmit path (device) 1258#ifdef CONFIG_XPS
995 */ 1259 struct xps_dev_maps __rcu *xps_maps;
1260#endif
1261
996 /* These may be needed for future network-power-down code. */ 1262 /* These may be needed for future network-power-down code. */
997 1263
998 /* 1264 /*
@@ -1005,7 +1271,7 @@ struct net_device {
1005 struct timer_list watchdog_timer; 1271 struct timer_list watchdog_timer;
1006 1272
1007 /* Number of references to this device */ 1273 /* Number of references to this device */
1008 atomic_t refcnt ____cacheline_aligned_in_smp; 1274 int __percpu *pcpu_refcnt;
1009 1275
1010 /* delayed register/unregister */ 1276 /* delayed register/unregister */
1011 struct list_head todo_list; 1277 struct list_head todo_list;
@@ -1021,7 +1287,9 @@ struct net_device {
1021 NETREG_UNREGISTERED, /* completed unregister todo */ 1287 NETREG_UNREGISTERED, /* completed unregister todo */
1022 NETREG_RELEASED, /* called free_netdev */ 1288 NETREG_RELEASED, /* called free_netdev */
1023 NETREG_DUMMY, /* dummy device for NAPI poll */ 1289 NETREG_DUMMY, /* dummy device for NAPI poll */
1024 } reg_state:16; 1290 } reg_state:8;
1291
1292 bool dismantle; /* device is going do be freed */
1025 1293
1026 enum { 1294 enum {
1027 RTNL_LINK_INITIALIZED, 1295 RTNL_LINK_INITIALIZED,
@@ -1041,10 +1309,14 @@ struct net_device {
1041#endif 1309#endif
1042 1310
1043 /* mid-layer private */ 1311 /* mid-layer private */
1044 void *ml_priv; 1312 union {
1045 1313 void *ml_priv;
1314 struct pcpu_lstats __percpu *lstats; /* loopback stats */
1315 struct pcpu_tstats __percpu *tstats; /* tunnel stats */
1316 struct pcpu_dstats __percpu *dstats; /* dummy stats */
1317 };
1046 /* GARP */ 1318 /* GARP */
1047 struct garp_port *garp_port; 1319 struct garp_port __rcu *garp_port;
1048 1320
1049 /* class/net/name entry */ 1321 /* class/net/name entry */
1050 struct device dev; 1322 struct device dev;
@@ -1054,9 +1326,6 @@ struct net_device {
1054 /* rtnetlink link ops */ 1326 /* rtnetlink link ops */
1055 const struct rtnl_link_ops *rtnl_link_ops; 1327 const struct rtnl_link_ops *rtnl_link_ops;
1056 1328
1057 /* VLAN feature mask */
1058 unsigned long vlan_features;
1059
1060 /* for setting kernel sock attribute on TCP connection setup */ 1329 /* for setting kernel sock attribute on TCP connection setup */
1061#define GSO_MAX_SIZE 65536 1330#define GSO_MAX_SIZE 65536
1062 unsigned int gso_max_size; 1331 unsigned int gso_max_size;
@@ -1065,6 +1334,9 @@ struct net_device {
1065 /* Data Center Bridging netlink ops */ 1334 /* Data Center Bridging netlink ops */
1066 const struct dcbnl_rtnl_ops *dcbnl_ops; 1335 const struct dcbnl_rtnl_ops *dcbnl_ops;
1067#endif 1336#endif
1337 u8 num_tc;
1338 struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
1339 u8 prio_tc_map[TC_BITMASK + 1];
1068 1340
1069#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) 1341#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
1070 /* max exchange id for FCoE LRO by ddp */ 1342 /* max exchange id for FCoE LRO by ddp */
@@ -1075,12 +1347,66 @@ struct net_device {
1075 1347
1076 /* phy device may attach itself for hardware timestamping */ 1348 /* phy device may attach itself for hardware timestamping */
1077 struct phy_device *phydev; 1349 struct phy_device *phydev;
1350
1351 /* group the device belongs to */
1352 int group;
1078}; 1353};
1079#define to_net_dev(d) container_of(d, struct net_device, dev) 1354#define to_net_dev(d) container_of(d, struct net_device, dev)
1080 1355
1081#define NETDEV_ALIGN 32 1356#define NETDEV_ALIGN 32
1082 1357
1083static inline 1358static inline
1359int netdev_get_prio_tc_map(const struct net_device *dev, u32 prio)
1360{
1361 return dev->prio_tc_map[prio & TC_BITMASK];
1362}
1363
1364static inline
1365int netdev_set_prio_tc_map(struct net_device *dev, u8 prio, u8 tc)
1366{
1367 if (tc >= dev->num_tc)
1368 return -EINVAL;
1369
1370 dev->prio_tc_map[prio & TC_BITMASK] = tc & TC_BITMASK;
1371 return 0;
1372}
1373
1374static inline
1375void netdev_reset_tc(struct net_device *dev)
1376{
1377 dev->num_tc = 0;
1378 memset(dev->tc_to_txq, 0, sizeof(dev->tc_to_txq));
1379 memset(dev->prio_tc_map, 0, sizeof(dev->prio_tc_map));
1380}
1381
1382static inline
1383int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 offset)
1384{
1385 if (tc >= dev->num_tc)
1386 return -EINVAL;
1387
1388 dev->tc_to_txq[tc].count = count;
1389 dev->tc_to_txq[tc].offset = offset;
1390 return 0;
1391}
1392
1393static inline
1394int netdev_set_num_tc(struct net_device *dev, u8 num_tc)
1395{
1396 if (num_tc > TC_MAX_QUEUE)
1397 return -EINVAL;
1398
1399 dev->num_tc = num_tc;
1400 return 0;
1401}
1402
1403static inline
1404int netdev_get_num_tc(struct net_device *dev)
1405{
1406 return dev->num_tc;
1407}
1408
1409static inline
1084struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev, 1410struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
1085 unsigned int index) 1411 unsigned int index)
1086{ 1412{
@@ -1222,7 +1548,7 @@ struct packet_type {
1222 struct packet_type *, 1548 struct packet_type *,
1223 struct net_device *); 1549 struct net_device *);
1224 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 1550 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
1225 int features); 1551 u32 features);
1226 int (*gso_send_check)(struct sk_buff *skb); 1552 int (*gso_send_check)(struct sk_buff *skb);
1227 struct sk_buff **(*gro_receive)(struct sk_buff **head, 1553 struct sk_buff **(*gro_receive)(struct sk_buff **head,
1228 struct sk_buff *skb); 1554 struct sk_buff *skb);
@@ -1267,7 +1593,7 @@ static inline struct net_device *next_net_device_rcu(struct net_device *dev)
1267 struct net *net; 1593 struct net *net;
1268 1594
1269 net = dev_net(dev); 1595 net = dev_net(dev);
1270 lh = rcu_dereference(dev->dev_list.next); 1596 lh = rcu_dereference(list_next_rcu(&dev->dev_list));
1271 return lh == &net->dev_base_head ? NULL : net_device_entry(lh); 1597 return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
1272} 1598}
1273 1599
@@ -1277,9 +1603,17 @@ static inline struct net_device *first_net_device(struct net *net)
1277 net_device_entry(net->dev_base_head.next); 1603 net_device_entry(net->dev_base_head.next);
1278} 1604}
1279 1605
1606static inline struct net_device *first_net_device_rcu(struct net *net)
1607{
1608 struct list_head *lh = rcu_dereference(list_next_rcu(&net->dev_base_head));
1609
1610 return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
1611}
1612
1280extern int netdev_boot_setup_check(struct net_device *dev); 1613extern int netdev_boot_setup_check(struct net_device *dev);
1281extern unsigned long netdev_boot_base(const char *prefix, int unit); 1614extern unsigned long netdev_boot_base(const char *prefix, int unit);
1282extern struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *hwaddr); 1615extern struct net_device *dev_getbyhwaddr_rcu(struct net *net, unsigned short type,
1616 const char *hwaddr);
1283extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type); 1617extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type);
1284extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type); 1618extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type);
1285extern void dev_add_pack(struct packet_type *pt); 1619extern void dev_add_pack(struct packet_type *pt);
@@ -1305,6 +1639,7 @@ static inline void unregister_netdevice(struct net_device *dev)
1305 unregister_netdevice_queue(dev, NULL); 1639 unregister_netdevice_queue(dev, NULL);
1306} 1640}
1307 1641
1642extern int netdev_refcnt_read(const struct net_device *dev);
1308extern void free_netdev(struct net_device *dev); 1643extern void free_netdev(struct net_device *dev);
1309extern void synchronize_net(void); 1644extern void synchronize_net(void);
1310extern int register_netdevice_notifier(struct notifier_block *nb); 1645extern int register_netdevice_notifier(struct notifier_block *nb);
@@ -1525,6 +1860,10 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev)
1525 1860
1526static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue) 1861static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
1527{ 1862{
1863 if (WARN_ON(!dev_queue)) {
1864 pr_info("netif_stop_queue() cannot be called before register_netdev()\n");
1865 return;
1866 }
1528 set_bit(__QUEUE_STATE_XOFF, &dev_queue->state); 1867 set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1529} 1868}
1530 1869
@@ -1566,9 +1905,9 @@ static inline int netif_queue_stopped(const struct net_device *dev)
1566 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); 1905 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
1567} 1906}
1568 1907
1569static inline int netif_tx_queue_frozen(const struct netdev_queue *dev_queue) 1908static inline int netif_tx_queue_frozen_or_stopped(const struct netdev_queue *dev_queue)
1570{ 1909{
1571 return test_bit(__QUEUE_STATE_FROZEN, &dev_queue->state); 1910 return dev_queue->state & QUEUE_STATE_XOFF_OR_FROZEN;
1572} 1911}
1573 1912
1574/** 1913/**
@@ -1659,6 +1998,16 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1659 __netif_schedule(txq->qdisc); 1998 __netif_schedule(txq->qdisc);
1660} 1999}
1661 2000
2001/*
2002 * Returns a Tx hash for the given packet when dev->real_num_tx_queues is used
2003 * as a distribution range limit for the returned value.
2004 */
2005static inline u16 skb_tx_hash(const struct net_device *dev,
2006 const struct sk_buff *skb)
2007{
2008 return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
2009}
2010
1662/** 2011/**
1663 * netif_is_multiqueue - test if device has multiple transmit queues 2012 * netif_is_multiqueue - test if device has multiple transmit queues
1664 * @dev: network device 2013 * @dev: network device
@@ -1667,11 +2016,34 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1667 */ 2016 */
1668static inline int netif_is_multiqueue(const struct net_device *dev) 2017static inline int netif_is_multiqueue(const struct net_device *dev)
1669{ 2018{
1670 return (dev->num_tx_queues > 1); 2019 return dev->num_tx_queues > 1;
2020}
2021
2022extern int netif_set_real_num_tx_queues(struct net_device *dev,
2023 unsigned int txq);
2024
2025#ifdef CONFIG_RPS
2026extern int netif_set_real_num_rx_queues(struct net_device *dev,
2027 unsigned int rxq);
2028#else
2029static inline int netif_set_real_num_rx_queues(struct net_device *dev,
2030 unsigned int rxq)
2031{
2032 return 0;
1671} 2033}
2034#endif
1672 2035
1673extern void netif_set_real_num_tx_queues(struct net_device *dev, 2036static inline int netif_copy_real_num_queues(struct net_device *to_dev,
1674 unsigned int txq); 2037 const struct net_device *from_dev)
2038{
2039 netif_set_real_num_tx_queues(to_dev, from_dev->real_num_tx_queues);
2040#ifdef CONFIG_RPS
2041 return netif_set_real_num_rx_queues(to_dev,
2042 from_dev->real_num_rx_queues);
2043#else
2044 return 0;
2045#endif
2046}
1675 2047
1676/* Use this variant when it is known for sure that it 2048/* Use this variant when it is known for sure that it
1677 * is executing from hardware interrupt context or with hardware interrupts 2049 * is executing from hardware interrupt context or with hardware interrupts
@@ -1695,8 +2067,7 @@ extern gro_result_t dev_gro_receive(struct napi_struct *napi,
1695extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); 2067extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb);
1696extern gro_result_t napi_gro_receive(struct napi_struct *napi, 2068extern gro_result_t napi_gro_receive(struct napi_struct *napi,
1697 struct sk_buff *skb); 2069 struct sk_buff *skb);
1698extern void napi_reuse_skb(struct napi_struct *napi, 2070extern void napi_gro_flush(struct napi_struct *napi);
1699 struct sk_buff *skb);
1700extern struct sk_buff * napi_get_frags(struct napi_struct *napi); 2071extern struct sk_buff * napi_get_frags(struct napi_struct *napi);
1701extern gro_result_t napi_frags_finish(struct napi_struct *napi, 2072extern gro_result_t napi_frags_finish(struct napi_struct *napi,
1702 struct sk_buff *skb, 2073 struct sk_buff *skb,
@@ -1715,7 +2086,6 @@ extern int netdev_rx_handler_register(struct net_device *dev,
1715 void *rx_handler_data); 2086 void *rx_handler_data);
1716extern void netdev_rx_handler_unregister(struct net_device *dev); 2087extern void netdev_rx_handler_unregister(struct net_device *dev);
1717 2088
1718extern void netif_nit_deliver(struct sk_buff *skb);
1719extern int dev_valid_name(const char *name); 2089extern int dev_valid_name(const char *name);
1720extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); 2090extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
1721extern int dev_ethtool(struct net *net, struct ifreq *); 2091extern int dev_ethtool(struct net *net, struct ifreq *);
@@ -1728,6 +2098,7 @@ extern int dev_set_alias(struct net_device *, const char *, size_t);
1728extern int dev_change_net_namespace(struct net_device *, 2098extern int dev_change_net_namespace(struct net_device *,
1729 struct net *, const char *); 2099 struct net *, const char *);
1730extern int dev_set_mtu(struct net_device *, int); 2100extern int dev_set_mtu(struct net_device *, int);
2101extern void dev_set_group(struct net_device *, int);
1731extern int dev_set_mac_address(struct net_device *, 2102extern int dev_set_mac_address(struct net_device *,
1732 struct sockaddr *); 2103 struct sockaddr *);
1733extern int dev_hard_start_xmit(struct sk_buff *skb, 2104extern int dev_hard_start_xmit(struct sk_buff *skb,
@@ -1749,7 +2120,7 @@ extern void netdev_run_todo(void);
1749 */ 2120 */
1750static inline void dev_put(struct net_device *dev) 2121static inline void dev_put(struct net_device *dev)
1751{ 2122{
1752 atomic_dec(&dev->refcnt); 2123 irqsafe_cpu_dec(*dev->pcpu_refcnt);
1753} 2124}
1754 2125
1755/** 2126/**
@@ -1760,7 +2131,7 @@ static inline void dev_put(struct net_device *dev)
1760 */ 2131 */
1761static inline void dev_hold(struct net_device *dev) 2132static inline void dev_hold(struct net_device *dev)
1762{ 2133{
1763 atomic_inc(&dev->refcnt); 2134 irqsafe_cpu_inc(*dev->pcpu_refcnt);
1764} 2135}
1765 2136
1766/* Carrier loss detection, dial on demand. The functions netif_carrier_on 2137/* Carrier loss detection, dial on demand. The functions netif_carrier_on
@@ -2072,11 +2443,15 @@ static inline void netif_addr_unlock_bh(struct net_device *dev)
2072extern void ether_setup(struct net_device *dev); 2443extern void ether_setup(struct net_device *dev);
2073 2444
2074/* Support for loadable net-drivers */ 2445/* Support for loadable net-drivers */
2075extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, 2446extern struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
2076 void (*setup)(struct net_device *), 2447 void (*setup)(struct net_device *),
2077 unsigned int queue_count); 2448 unsigned int txqs, unsigned int rxqs);
2078#define alloc_netdev(sizeof_priv, name, setup) \ 2449#define alloc_netdev(sizeof_priv, name, setup) \
2079 alloc_netdev_mq(sizeof_priv, name, setup, 1) 2450 alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1)
2451
2452#define alloc_netdev_mq(sizeof_priv, name, setup, count) \
2453 alloc_netdev_mqs(sizeof_priv, name, setup, count, count)
2454
2080extern int register_netdev(struct net_device *dev); 2455extern int register_netdev(struct net_device *dev);
2081extern void unregister_netdev(struct net_device *dev); 2456extern void unregister_netdev(struct net_device *dev);
2082 2457
@@ -2142,15 +2517,16 @@ extern void dev_load(struct net *net, const char *name);
2142extern void dev_mcast_init(void); 2517extern void dev_mcast_init(void);
2143extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, 2518extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
2144 struct rtnl_link_stats64 *storage); 2519 struct rtnl_link_stats64 *storage);
2145extern void dev_txq_stats_fold(const struct net_device *dev,
2146 struct rtnl_link_stats64 *stats);
2147 2520
2148extern int netdev_max_backlog; 2521extern int netdev_max_backlog;
2149extern int netdev_tstamp_prequeue; 2522extern int netdev_tstamp_prequeue;
2150extern int weight_p; 2523extern int weight_p;
2524extern int bpf_jit_enable;
2151extern int netdev_set_master(struct net_device *dev, struct net_device *master); 2525extern int netdev_set_master(struct net_device *dev, struct net_device *master);
2526extern int netdev_set_bond_master(struct net_device *dev,
2527 struct net_device *master);
2152extern int skb_checksum_help(struct sk_buff *skb); 2528extern int skb_checksum_help(struct sk_buff *skb);
2153extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features); 2529extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features);
2154#ifdef CONFIG_BUG 2530#ifdef CONFIG_BUG
2155extern void netdev_rx_csum_fault(struct net_device *dev); 2531extern void netdev_rx_csum_fault(struct net_device *dev);
2156#else 2532#else
@@ -2171,33 +2547,42 @@ extern void dev_seq_stop(struct seq_file *seq, void *v);
2171extern int netdev_class_create_file(struct class_attribute *class_attr); 2547extern int netdev_class_create_file(struct class_attribute *class_attr);
2172extern void netdev_class_remove_file(struct class_attribute *class_attr); 2548extern void netdev_class_remove_file(struct class_attribute *class_attr);
2173 2549
2174extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len); 2550extern struct kobj_ns_type_operations net_ns_type_operations;
2551
2552extern const char *netdev_drivername(const struct net_device *dev);
2175 2553
2176extern void linkwatch_run_queue(void); 2554extern void linkwatch_run_queue(void);
2177 2555
2178unsigned long netdev_increment_features(unsigned long all, unsigned long one, 2556static inline u32 netdev_get_wanted_features(struct net_device *dev)
2179 unsigned long mask); 2557{
2180unsigned long netdev_fix_features(unsigned long features, const char *name); 2558 return (dev->features & ~dev->hw_features) | dev->wanted_features;
2559}
2560u32 netdev_increment_features(u32 all, u32 one, u32 mask);
2561u32 netdev_fix_features(struct net_device *dev, u32 features);
2562int __netdev_update_features(struct net_device *dev);
2563void netdev_update_features(struct net_device *dev);
2564void netdev_change_features(struct net_device *dev);
2181 2565
2182void netif_stacked_transfer_operstate(const struct net_device *rootdev, 2566void netif_stacked_transfer_operstate(const struct net_device *rootdev,
2183 struct net_device *dev); 2567 struct net_device *dev);
2184 2568
2185static inline int net_gso_ok(int features, int gso_type) 2569u32 netif_skb_features(struct sk_buff *skb);
2570
2571static inline int net_gso_ok(u32 features, int gso_type)
2186{ 2572{
2187 int feature = gso_type << NETIF_F_GSO_SHIFT; 2573 int feature = gso_type << NETIF_F_GSO_SHIFT;
2188 return (features & feature) == feature; 2574 return (features & feature) == feature;
2189} 2575}
2190 2576
2191static inline int skb_gso_ok(struct sk_buff *skb, int features) 2577static inline int skb_gso_ok(struct sk_buff *skb, u32 features)
2192{ 2578{
2193 return net_gso_ok(features, skb_shinfo(skb)->gso_type) && 2579 return net_gso_ok(features, skb_shinfo(skb)->gso_type) &&
2194 (!skb_has_frags(skb) || (features & NETIF_F_FRAGLIST)); 2580 (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST));
2195} 2581}
2196 2582
2197static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb) 2583static inline int netif_needs_gso(struct sk_buff *skb, int features)
2198{ 2584{
2199 return skb_is_gso(skb) && 2585 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
2200 (!skb_gso_ok(skb, dev->features) ||
2201 unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); 2586 unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
2202} 2587}
2203 2588
@@ -2207,29 +2592,20 @@ static inline void netif_set_gso_max_size(struct net_device *dev,
2207 dev->gso_max_size = size; 2592 dev->gso_max_size = size;
2208} 2593}
2209 2594
2210extern int __skb_bond_should_drop(struct sk_buff *skb, 2595static inline int netif_is_bond_slave(struct net_device *dev)
2211 struct net_device *master);
2212
2213static inline int skb_bond_should_drop(struct sk_buff *skb,
2214 struct net_device *master)
2215{ 2596{
2216 if (master) 2597 return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
2217 return __skb_bond_should_drop(skb, master);
2218 return 0;
2219} 2598}
2220 2599
2221extern struct pernet_operations __net_initdata loopback_net_ops; 2600extern struct pernet_operations __net_initdata loopback_net_ops;
2222 2601
2223static inline int dev_ethtool_get_settings(struct net_device *dev, 2602int dev_ethtool_get_settings(struct net_device *dev,
2224 struct ethtool_cmd *cmd) 2603 struct ethtool_cmd *cmd);
2225{
2226 if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings)
2227 return -EOPNOTSUPP;
2228 return dev->ethtool_ops->get_settings(dev, cmd);
2229}
2230 2604
2231static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev) 2605static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev)
2232{ 2606{
2607 if (dev->features & NETIF_F_RXCSUM)
2608 return 1;
2233 if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum) 2609 if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum)
2234 return 0; 2610 return 0;
2235 return dev->ethtool_ops->get_rx_csum(dev); 2611 return dev->ethtool_ops->get_rx_csum(dev);
@@ -2271,6 +2647,9 @@ extern int netdev_notice(const struct net_device *dev, const char *format, ...)
2271extern int netdev_info(const struct net_device *dev, const char *format, ...) 2647extern int netdev_info(const struct net_device *dev, const char *format, ...)
2272 __attribute__ ((format (printf, 2, 3))); 2648 __attribute__ ((format (printf, 2, 3)));
2273 2649
2650#define MODULE_ALIAS_NETDEV(device) \
2651 MODULE_ALIAS("netdev-" device)
2652
2274#if defined(DEBUG) 2653#if defined(DEBUG)
2275#define netdev_dbg(__dev, format, args...) \ 2654#define netdev_dbg(__dev, format, args...) \
2276 netdev_printk(KERN_DEBUG, __dev, format, ##args) 2655 netdev_printk(KERN_DEBUG, __dev, format, ##args)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 89341c32631a..857f5026ced6 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -13,6 +13,7 @@
13#endif 13#endif
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/compiler.h> 15#include <linux/compiler.h>
16#include <linux/sysctl.h>
16 17
17/* Responses from hook functions. */ 18/* Responses from hook functions. */
18#define NF_DROP 0 19#define NF_DROP 0
@@ -24,14 +25,20 @@
24#define NF_MAX_VERDICT NF_STOP 25#define NF_MAX_VERDICT NF_STOP
25 26
26/* we overload the higher bits for encoding auxiliary data such as the queue 27/* we overload the higher bits for encoding auxiliary data such as the queue
27 * number. Not nice, but better than additional function arguments. */ 28 * number or errno values. Not nice, but better than additional function
28#define NF_VERDICT_MASK 0x0000ffff 29 * arguments. */
29#define NF_VERDICT_BITS 16 30#define NF_VERDICT_MASK 0x000000ff
31
32/* extra verdict flags have mask 0x0000ff00 */
33#define NF_VERDICT_FLAG_QUEUE_BYPASS 0x00008000
30 34
35/* queue number (NF_QUEUE) or errno (NF_DROP) */
31#define NF_VERDICT_QMASK 0xffff0000 36#define NF_VERDICT_QMASK 0xffff0000
32#define NF_VERDICT_QBITS 16 37#define NF_VERDICT_QBITS 16
33 38
34#define NF_QUEUE_NR(x) ((((x) << NF_VERDICT_BITS) & NF_VERDICT_QMASK) | NF_QUEUE) 39#define NF_QUEUE_NR(x) ((((x) << 16) & NF_VERDICT_QMASK) | NF_QUEUE)
40
41#define NF_DROP_ERR(x) (((-x) << 16) | NF_DROP)
35 42
36/* only for userspace compatibility */ 43/* only for userspace compatibility */
37#ifndef __KERNEL__ 44#ifndef __KERNEL__
@@ -39,6 +46,9 @@
39 <= 0x2000 is used for protocol-flags. */ 46 <= 0x2000 is used for protocol-flags. */
40#define NFC_UNKNOWN 0x4000 47#define NFC_UNKNOWN 0x4000
41#define NFC_ALTERED 0x8000 48#define NFC_ALTERED 0x8000
49
50/* NF_VERDICT_BITS should be 8 now, but userspace might break if this changes */
51#define NF_VERDICT_BITS 16
42#endif 52#endif
43 53
44enum nf_inet_hooks { 54enum nf_inet_hooks {
@@ -70,6 +80,10 @@ union nf_inet_addr {
70 80
71#ifdef __KERNEL__ 81#ifdef __KERNEL__
72#ifdef CONFIG_NETFILTER 82#ifdef CONFIG_NETFILTER
83static inline int NF_DROP_GETERR(int verdict)
84{
85 return -(verdict >> NF_VERDICT_QBITS);
86}
73 87
74static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1, 88static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1,
75 const union nf_inet_addr *a2) 89 const union nf_inet_addr *a2)
@@ -215,7 +229,7 @@ NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sk_buff *skb,
215 int ret; 229 int ret;
216 230
217 if (!cond || 231 if (!cond ||
218 (ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, INT_MIN) == 1)) 232 ((ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, INT_MIN)) == 1))
219 ret = okfn(skb); 233 ret = okfn(skb);
220 return ret; 234 return ret;
221} 235}
@@ -257,7 +271,8 @@ struct nf_afinfo {
257 unsigned int dataoff, 271 unsigned int dataoff,
258 unsigned int len, 272 unsigned int len,
259 u_int8_t protocol); 273 u_int8_t protocol);
260 int (*route)(struct dst_entry **dst, struct flowi *fl); 274 int (*route)(struct net *net, struct dst_entry **dst,
275 struct flowi *fl, bool strict);
261 void (*saveroute)(const struct sk_buff *skb, 276 void (*saveroute)(const struct sk_buff *skb,
262 struct nf_queue_entry *entry); 277 struct nf_queue_entry *entry);
263 int (*reroute)(struct sk_buff *skb, 278 int (*reroute)(struct sk_buff *skb,
@@ -265,7 +280,7 @@ struct nf_afinfo {
265 int route_key_size; 280 int route_key_size;
266}; 281};
267 282
268extern const struct nf_afinfo *nf_afinfo[NFPROTO_NUMPROTO]; 283extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
269static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family) 284static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
270{ 285{
271 return rcu_dereference(nf_afinfo[family]); 286 return rcu_dereference(nf_afinfo[family]);
@@ -355,9 +370,9 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
355#endif /*CONFIG_NETFILTER*/ 370#endif /*CONFIG_NETFILTER*/
356 371
357#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 372#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
358extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *); 373extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *) __rcu;
359extern void nf_ct_attach(struct sk_buff *, struct sk_buff *); 374extern void nf_ct_attach(struct sk_buff *, struct sk_buff *);
360extern void (*nf_ct_destroy)(struct nf_conntrack *); 375extern void (*nf_ct_destroy)(struct nf_conntrack *) __rcu;
361#else 376#else
362static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} 377static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
363#endif 378#endif
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild
index 9d40effe7ca7..a1b410c76fc3 100644
--- a/include/linux/netfilter/Kbuild
+++ b/include/linux/netfilter/Kbuild
@@ -1,3 +1,5 @@
1header-y += ipset/
2
1header-y += nf_conntrack_common.h 3header-y += nf_conntrack_common.h
2header-y += nf_conntrack_ftp.h 4header-y += nf_conntrack_ftp.h
3header-y += nf_conntrack_sctp.h 5header-y += nf_conntrack_sctp.h
@@ -9,6 +11,7 @@ header-y += nfnetlink_conntrack.h
9header-y += nfnetlink_log.h 11header-y += nfnetlink_log.h
10header-y += nfnetlink_queue.h 12header-y += nfnetlink_queue.h
11header-y += x_tables.h 13header-y += x_tables.h
14header-y += xt_AUDIT.h
12header-y += xt_CHECKSUM.h 15header-y += xt_CHECKSUM.h
13header-y += xt_CLASSIFY.h 16header-y += xt_CLASSIFY.h
14header-y += xt_CONNMARK.h 17header-y += xt_CONNMARK.h
@@ -26,6 +29,7 @@ header-y += xt_TCPMSS.h
26header-y += xt_TCPOPTSTRIP.h 29header-y += xt_TCPOPTSTRIP.h
27header-y += xt_TEE.h 30header-y += xt_TEE.h
28header-y += xt_TPROXY.h 31header-y += xt_TPROXY.h
32header-y += xt_addrtype.h
29header-y += xt_cluster.h 33header-y += xt_cluster.h
30header-y += xt_comment.h 34header-y += xt_comment.h
31header-y += xt_connbytes.h 35header-y += xt_connbytes.h
@@ -34,6 +38,7 @@ header-y += xt_connmark.h
34header-y += xt_conntrack.h 38header-y += xt_conntrack.h
35header-y += xt_cpu.h 39header-y += xt_cpu.h
36header-y += xt_dccp.h 40header-y += xt_dccp.h
41header-y += xt_devgroup.h
37header-y += xt_dscp.h 42header-y += xt_dscp.h
38header-y += xt_esp.h 43header-y += xt_esp.h
39header-y += xt_hashlimit.h 44header-y += xt_hashlimit.h
@@ -54,7 +59,9 @@ header-y += xt_quota.h
54header-y += xt_rateest.h 59header-y += xt_rateest.h
55header-y += xt_realm.h 60header-y += xt_realm.h
56header-y += xt_recent.h 61header-y += xt_recent.h
62header-y += xt_set.h
57header-y += xt_sctp.h 63header-y += xt_sctp.h
64header-y += xt_socket.h
58header-y += xt_state.h 65header-y += xt_state.h
59header-y += xt_statistic.h 66header-y += xt_statistic.h
60header-y += xt_string.h 67header-y += xt_string.h
diff --git a/include/linux/netfilter/ipset/Kbuild b/include/linux/netfilter/ipset/Kbuild
new file mode 100644
index 000000000000..601fe71d34d5
--- /dev/null
+++ b/include/linux/netfilter/ipset/Kbuild
@@ -0,0 +1,4 @@
1header-y += ip_set.h
2header-y += ip_set_bitmap.h
3header-y += ip_set_hash.h
4header-y += ip_set_list.h
diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
new file mode 100644
index 000000000000..5a262e3ae715
--- /dev/null
+++ b/include/linux/netfilter/ipset/ip_set.h
@@ -0,0 +1,452 @@
1#ifndef _IP_SET_H
2#define _IP_SET_H
3
4/* Copyright (C) 2000-2002 Joakim Axelsson <gozem@linux.nu>
5 * Patrick Schaaf <bof@bof.de>
6 * Martin Josefsson <gandalf@wlug.westbo.se>
7 * Copyright (C) 2003-2011 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14/* The protocol version */
15#define IPSET_PROTOCOL 6
16
17/* The max length of strings including NUL: set and type identifiers */
18#define IPSET_MAXNAMELEN 32
19
20/* Message types and commands */
21enum ipset_cmd {
22 IPSET_CMD_NONE,
23 IPSET_CMD_PROTOCOL, /* 1: Return protocol version */
24 IPSET_CMD_CREATE, /* 2: Create a new (empty) set */
25 IPSET_CMD_DESTROY, /* 3: Destroy a (empty) set */
26 IPSET_CMD_FLUSH, /* 4: Remove all elements from a set */
27 IPSET_CMD_RENAME, /* 5: Rename a set */
28 IPSET_CMD_SWAP, /* 6: Swap two sets */
29 IPSET_CMD_LIST, /* 7: List sets */
30 IPSET_CMD_SAVE, /* 8: Save sets */
31 IPSET_CMD_ADD, /* 9: Add an element to a set */
32 IPSET_CMD_DEL, /* 10: Delete an element from a set */
33 IPSET_CMD_TEST, /* 11: Test an element in a set */
34 IPSET_CMD_HEADER, /* 12: Get set header data only */
35 IPSET_CMD_TYPE, /* 13: Get set type */
36 IPSET_MSG_MAX, /* Netlink message commands */
37
38 /* Commands in userspace: */
39 IPSET_CMD_RESTORE = IPSET_MSG_MAX, /* 14: Enter restore mode */
40 IPSET_CMD_HELP, /* 15: Get help */
41 IPSET_CMD_VERSION, /* 16: Get program version */
42 IPSET_CMD_QUIT, /* 17: Quit from interactive mode */
43
44 IPSET_CMD_MAX,
45
46 IPSET_CMD_COMMIT = IPSET_CMD_MAX, /* 18: Commit buffered commands */
47};
48
49/* Attributes at command level */
50enum {
51 IPSET_ATTR_UNSPEC,
52 IPSET_ATTR_PROTOCOL, /* 1: Protocol version */
53 IPSET_ATTR_SETNAME, /* 2: Name of the set */
54 IPSET_ATTR_TYPENAME, /* 3: Typename */
55 IPSET_ATTR_SETNAME2 = IPSET_ATTR_TYPENAME, /* Setname at rename/swap */
56 IPSET_ATTR_REVISION, /* 4: Settype revision */
57 IPSET_ATTR_FAMILY, /* 5: Settype family */
58 IPSET_ATTR_FLAGS, /* 6: Flags at command level */
59 IPSET_ATTR_DATA, /* 7: Nested attributes */
60 IPSET_ATTR_ADT, /* 8: Multiple data containers */
61 IPSET_ATTR_LINENO, /* 9: Restore lineno */
62 IPSET_ATTR_PROTOCOL_MIN, /* 10: Minimal supported version number */
63 IPSET_ATTR_REVISION_MIN = IPSET_ATTR_PROTOCOL_MIN, /* type rev min */
64 __IPSET_ATTR_CMD_MAX,
65};
66#define IPSET_ATTR_CMD_MAX (__IPSET_ATTR_CMD_MAX - 1)
67
68/* CADT specific attributes */
69enum {
70 IPSET_ATTR_IP = IPSET_ATTR_UNSPEC + 1,
71 IPSET_ATTR_IP_FROM = IPSET_ATTR_IP,
72 IPSET_ATTR_IP_TO, /* 2 */
73 IPSET_ATTR_CIDR, /* 3 */
74 IPSET_ATTR_PORT, /* 4 */
75 IPSET_ATTR_PORT_FROM = IPSET_ATTR_PORT,
76 IPSET_ATTR_PORT_TO, /* 5 */
77 IPSET_ATTR_TIMEOUT, /* 6 */
78 IPSET_ATTR_PROTO, /* 7 */
79 IPSET_ATTR_CADT_FLAGS, /* 8 */
80 IPSET_ATTR_CADT_LINENO = IPSET_ATTR_LINENO, /* 9 */
81 /* Reserve empty slots */
82 IPSET_ATTR_CADT_MAX = 16,
83 /* Create-only specific attributes */
84 IPSET_ATTR_GC,
85 IPSET_ATTR_HASHSIZE,
86 IPSET_ATTR_MAXELEM,
87 IPSET_ATTR_NETMASK,
88 IPSET_ATTR_PROBES,
89 IPSET_ATTR_RESIZE,
90 IPSET_ATTR_SIZE,
91 /* Kernel-only */
92 IPSET_ATTR_ELEMENTS,
93 IPSET_ATTR_REFERENCES,
94 IPSET_ATTR_MEMSIZE,
95
96 __IPSET_ATTR_CREATE_MAX,
97};
98#define IPSET_ATTR_CREATE_MAX (__IPSET_ATTR_CREATE_MAX - 1)
99
100/* ADT specific attributes */
101enum {
102 IPSET_ATTR_ETHER = IPSET_ATTR_CADT_MAX + 1,
103 IPSET_ATTR_NAME,
104 IPSET_ATTR_NAMEREF,
105 IPSET_ATTR_IP2,
106 IPSET_ATTR_CIDR2,
107 __IPSET_ATTR_ADT_MAX,
108};
109#define IPSET_ATTR_ADT_MAX (__IPSET_ATTR_ADT_MAX - 1)
110
111/* IP specific attributes */
112enum {
113 IPSET_ATTR_IPADDR_IPV4 = IPSET_ATTR_UNSPEC + 1,
114 IPSET_ATTR_IPADDR_IPV6,
115 __IPSET_ATTR_IPADDR_MAX,
116};
117#define IPSET_ATTR_IPADDR_MAX (__IPSET_ATTR_IPADDR_MAX - 1)
118
119/* Error codes */
120enum ipset_errno {
121 IPSET_ERR_PRIVATE = 4096,
122 IPSET_ERR_PROTOCOL,
123 IPSET_ERR_FIND_TYPE,
124 IPSET_ERR_MAX_SETS,
125 IPSET_ERR_BUSY,
126 IPSET_ERR_EXIST_SETNAME2,
127 IPSET_ERR_TYPE_MISMATCH,
128 IPSET_ERR_EXIST,
129 IPSET_ERR_INVALID_CIDR,
130 IPSET_ERR_INVALID_NETMASK,
131 IPSET_ERR_INVALID_FAMILY,
132 IPSET_ERR_TIMEOUT,
133 IPSET_ERR_REFERENCED,
134 IPSET_ERR_IPADDR_IPV4,
135 IPSET_ERR_IPADDR_IPV6,
136
137 /* Type specific error codes */
138 IPSET_ERR_TYPE_SPECIFIC = 4352,
139};
140
141/* Flags at command level */
142enum ipset_cmd_flags {
143 IPSET_FLAG_BIT_EXIST = 0,
144 IPSET_FLAG_EXIST = (1 << IPSET_FLAG_BIT_EXIST),
145};
146
147/* Flags at CADT attribute level */
148enum ipset_cadt_flags {
149 IPSET_FLAG_BIT_BEFORE = 0,
150 IPSET_FLAG_BEFORE = (1 << IPSET_FLAG_BIT_BEFORE),
151};
152
153/* Commands with settype-specific attributes */
154enum ipset_adt {
155 IPSET_ADD,
156 IPSET_DEL,
157 IPSET_TEST,
158 IPSET_ADT_MAX,
159 IPSET_CREATE = IPSET_ADT_MAX,
160 IPSET_CADT_MAX,
161};
162
163#ifdef __KERNEL__
164#include <linux/ip.h>
165#include <linux/ipv6.h>
166#include <linux/netlink.h>
167#include <linux/netfilter.h>
168#include <linux/vmalloc.h>
169#include <net/netlink.h>
170
171/* Sets are identified by an index in kernel space. Tweak with ip_set_id_t
172 * and IPSET_INVALID_ID if you want to increase the max number of sets.
173 */
174typedef u16 ip_set_id_t;
175
176#define IPSET_INVALID_ID 65535
177
178enum ip_set_dim {
179 IPSET_DIM_ZERO = 0,
180 IPSET_DIM_ONE,
181 IPSET_DIM_TWO,
182 IPSET_DIM_THREE,
183 /* Max dimension in elements.
184 * If changed, new revision of iptables match/target is required.
185 */
186 IPSET_DIM_MAX = 6,
187};
188
189/* Option flags for kernel operations */
190enum ip_set_kopt {
191 IPSET_INV_MATCH = (1 << IPSET_DIM_ZERO),
192 IPSET_DIM_ONE_SRC = (1 << IPSET_DIM_ONE),
193 IPSET_DIM_TWO_SRC = (1 << IPSET_DIM_TWO),
194 IPSET_DIM_THREE_SRC = (1 << IPSET_DIM_THREE),
195};
196
197/* Set features */
198enum ip_set_feature {
199 IPSET_TYPE_IP_FLAG = 0,
200 IPSET_TYPE_IP = (1 << IPSET_TYPE_IP_FLAG),
201 IPSET_TYPE_PORT_FLAG = 1,
202 IPSET_TYPE_PORT = (1 << IPSET_TYPE_PORT_FLAG),
203 IPSET_TYPE_MAC_FLAG = 2,
204 IPSET_TYPE_MAC = (1 << IPSET_TYPE_MAC_FLAG),
205 IPSET_TYPE_IP2_FLAG = 3,
206 IPSET_TYPE_IP2 = (1 << IPSET_TYPE_IP2_FLAG),
207 IPSET_TYPE_NAME_FLAG = 4,
208 IPSET_TYPE_NAME = (1 << IPSET_TYPE_NAME_FLAG),
209 /* Strictly speaking not a feature, but a flag for dumping:
210 * this settype must be dumped last */
211 IPSET_DUMP_LAST_FLAG = 7,
212 IPSET_DUMP_LAST = (1 << IPSET_DUMP_LAST_FLAG),
213};
214
215struct ip_set;
216
217typedef int (*ipset_adtfn)(struct ip_set *set, void *value, u32 timeout);
218
219/* Set type, variant-specific part */
220struct ip_set_type_variant {
221 /* Kernelspace: test/add/del entries
222 * returns negative error code,
223 * zero for no match/success to add/delete
224 * positive for matching element */
225 int (*kadt)(struct ip_set *set, const struct sk_buff * skb,
226 enum ipset_adt adt, u8 pf, u8 dim, u8 flags);
227
228 /* Userspace: test/add/del entries
229 * returns negative error code,
230 * zero for no match/success to add/delete
231 * positive for matching element */
232 int (*uadt)(struct ip_set *set, struct nlattr *tb[],
233 enum ipset_adt adt, u32 *lineno, u32 flags);
234
235 /* Low level add/del/test functions */
236 ipset_adtfn adt[IPSET_ADT_MAX];
237
238 /* When adding entries and set is full, try to resize the set */
239 int (*resize)(struct ip_set *set, bool retried);
240 /* Destroy the set */
241 void (*destroy)(struct ip_set *set);
242 /* Flush the elements */
243 void (*flush)(struct ip_set *set);
244 /* Expire entries before listing */
245 void (*expire)(struct ip_set *set);
246 /* List set header data */
247 int (*head)(struct ip_set *set, struct sk_buff *skb);
248 /* List elements */
249 int (*list)(const struct ip_set *set, struct sk_buff *skb,
250 struct netlink_callback *cb);
251
252 /* Return true if "b" set is the same as "a"
253 * according to the create set parameters */
254 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
255};
256
257/* The core set type structure */
258struct ip_set_type {
259 struct list_head list;
260
261 /* Typename */
262 char name[IPSET_MAXNAMELEN];
263 /* Protocol version */
264 u8 protocol;
265 /* Set features to control swapping */
266 u8 features;
267 /* Set type dimension */
268 u8 dimension;
269 /* Supported family: may be AF_UNSPEC for both AF_INET/AF_INET6 */
270 u8 family;
271 /* Type revision */
272 u8 revision;
273
274 /* Create set */
275 int (*create)(struct ip_set *set, struct nlattr *tb[], u32 flags);
276
277 /* Attribute policies */
278 const struct nla_policy create_policy[IPSET_ATTR_CREATE_MAX + 1];
279 const struct nla_policy adt_policy[IPSET_ATTR_ADT_MAX + 1];
280
281 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
282 struct module *me;
283};
284
285/* register and unregister set type */
286extern int ip_set_type_register(struct ip_set_type *set_type);
287extern void ip_set_type_unregister(struct ip_set_type *set_type);
288
289/* A generic IP set */
290struct ip_set {
291 /* The name of the set */
292 char name[IPSET_MAXNAMELEN];
293 /* Lock protecting the set data */
294 rwlock_t lock;
295 /* References to the set */
296 u32 ref;
297 /* The core set type */
298 struct ip_set_type *type;
299 /* The type variant doing the real job */
300 const struct ip_set_type_variant *variant;
301 /* The actual INET family of the set */
302 u8 family;
303 /* The type specific data */
304 void *data;
305};
306
307/* register and unregister set references */
308extern ip_set_id_t ip_set_get_byname(const char *name, struct ip_set **set);
309extern void ip_set_put_byindex(ip_set_id_t index);
310extern const char * ip_set_name_byindex(ip_set_id_t index);
311extern ip_set_id_t ip_set_nfnl_get(const char *name);
312extern ip_set_id_t ip_set_nfnl_get_byindex(ip_set_id_t index);
313extern void ip_set_nfnl_put(ip_set_id_t index);
314
315/* API for iptables set match, and SET target */
316extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb,
317 u8 family, u8 dim, u8 flags);
318extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb,
319 u8 family, u8 dim, u8 flags);
320extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb,
321 u8 family, u8 dim, u8 flags);
322
323/* Utility functions */
324extern void * ip_set_alloc(size_t size);
325extern void ip_set_free(void *members);
326extern int ip_set_get_ipaddr4(struct nlattr *nla, __be32 *ipaddr);
327extern int ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr);
328
329static inline int
330ip_set_get_hostipaddr4(struct nlattr *nla, u32 *ipaddr)
331{
332 __be32 ip;
333 int ret = ip_set_get_ipaddr4(nla, &ip);
334
335 if (ret)
336 return ret;
337 *ipaddr = ntohl(ip);
338 return 0;
339}
340
341/* Ignore IPSET_ERR_EXIST errors if asked to do so? */
342static inline bool
343ip_set_eexist(int ret, u32 flags)
344{
345 return ret == -IPSET_ERR_EXIST && (flags & IPSET_FLAG_EXIST);
346}
347
348/* Check the NLA_F_NET_BYTEORDER flag */
349static inline bool
350ip_set_attr_netorder(struct nlattr *tb[], int type)
351{
352 return tb[type] && (tb[type]->nla_type & NLA_F_NET_BYTEORDER);
353}
354
355static inline bool
356ip_set_optattr_netorder(struct nlattr *tb[], int type)
357{
358 return !tb[type] || (tb[type]->nla_type & NLA_F_NET_BYTEORDER);
359}
360
361/* Useful converters */
362static inline u32
363ip_set_get_h32(const struct nlattr *attr)
364{
365 return ntohl(nla_get_be32(attr));
366}
367
368static inline u16
369ip_set_get_h16(const struct nlattr *attr)
370{
371 return ntohs(nla_get_be16(attr));
372}
373
374#define ipset_nest_start(skb, attr) nla_nest_start(skb, attr | NLA_F_NESTED)
375#define ipset_nest_end(skb, start) nla_nest_end(skb, start)
376
377#define NLA_PUT_IPADDR4(skb, type, ipaddr) \
378do { \
379 struct nlattr *__nested = ipset_nest_start(skb, type); \
380 \
381 if (!__nested) \
382 goto nla_put_failure; \
383 NLA_PUT_NET32(skb, IPSET_ATTR_IPADDR_IPV4, ipaddr); \
384 ipset_nest_end(skb, __nested); \
385} while (0)
386
387#define NLA_PUT_IPADDR6(skb, type, ipaddrptr) \
388do { \
389 struct nlattr *__nested = ipset_nest_start(skb, type); \
390 \
391 if (!__nested) \
392 goto nla_put_failure; \
393 NLA_PUT(skb, IPSET_ATTR_IPADDR_IPV6, \
394 sizeof(struct in6_addr), ipaddrptr); \
395 ipset_nest_end(skb, __nested); \
396} while (0)
397
398/* Get address from skbuff */
399static inline __be32
400ip4addr(const struct sk_buff *skb, bool src)
401{
402 return src ? ip_hdr(skb)->saddr : ip_hdr(skb)->daddr;
403}
404
405static inline void
406ip4addrptr(const struct sk_buff *skb, bool src, __be32 *addr)
407{
408 *addr = src ? ip_hdr(skb)->saddr : ip_hdr(skb)->daddr;
409}
410
411static inline void
412ip6addrptr(const struct sk_buff *skb, bool src, struct in6_addr *addr)
413{
414 memcpy(addr, src ? &ipv6_hdr(skb)->saddr : &ipv6_hdr(skb)->daddr,
415 sizeof(*addr));
416}
417
418/* Calculate the bytes required to store the inclusive range of a-b */
419static inline int
420bitmap_bytes(u32 a, u32 b)
421{
422 return 4 * ((((b - a + 8) / 8) + 3) / 4);
423}
424
425/* Interface to iptables/ip6tables */
426
427#define SO_IP_SET 83
428
429union ip_set_name_index {
430 char name[IPSET_MAXNAMELEN];
431 ip_set_id_t index;
432};
433
434#define IP_SET_OP_GET_BYNAME 0x00000006 /* Get set index by name */
435struct ip_set_req_get_set {
436 unsigned op;
437 unsigned version;
438 union ip_set_name_index set;
439};
440
441#define IP_SET_OP_GET_BYINDEX 0x00000007 /* Get set name by index */
442/* Uses ip_set_req_get_set */
443
444#define IP_SET_OP_VERSION 0x00000100 /* Ask kernel version */
445struct ip_set_req_version {
446 unsigned op;
447 unsigned version;
448};
449
450#endif /* __KERNEL__ */
451
452#endif /*_IP_SET_H */
diff --git a/include/linux/netfilter/ipset/ip_set_ahash.h b/include/linux/netfilter/ipset/ip_set_ahash.h
new file mode 100644
index 000000000000..ac3c822eb39a
--- /dev/null
+++ b/include/linux/netfilter/ipset/ip_set_ahash.h
@@ -0,0 +1,1073 @@
1#ifndef _IP_SET_AHASH_H
2#define _IP_SET_AHASH_H
3
4#include <linux/rcupdate.h>
5#include <linux/jhash.h>
6#include <linux/netfilter/ipset/ip_set_timeout.h>
7
8/* Hashing which uses arrays to resolve clashing. The hash table is resized
9 * (doubled) when searching becomes too long.
10 * Internally jhash is used with the assumption that the size of the
11 * stored data is a multiple of sizeof(u32). If storage supports timeout,
12 * the timeout field must be the last one in the data structure - that field
13 * is ignored when computing the hash key.
14 *
15 * Readers and resizing
16 *
17 * Resizing can be triggered by userspace command only, and those
18 * are serialized by the nfnl mutex. During resizing the set is
19 * read-locked, so the only possible concurrent operations are
20 * the kernel side readers. Those must be protected by proper RCU locking.
21 */
22
23/* Number of elements to store in an initial array block */
24#define AHASH_INIT_SIZE 4
25/* Max number of elements to store in an array block */
26#define AHASH_MAX_SIZE (3*4)
27
28/* A hash bucket */
29struct hbucket {
30 void *value; /* the array of the values */
31 u8 size; /* size of the array */
32 u8 pos; /* position of the first free entry */
33};
34
35/* The hash table: the table size stored here in order to make resizing easy */
36struct htable {
37 u8 htable_bits; /* size of hash table == 2^htable_bits */
38 struct hbucket bucket[0]; /* hashtable buckets */
39};
40
41#define hbucket(h, i) &((h)->bucket[i])
42
43/* Book-keeping of the prefixes added to the set */
44struct ip_set_hash_nets {
45 u8 cidr; /* the different cidr values in the set */
46 u32 nets; /* number of elements per cidr */
47};
48
49/* The generic ip_set hash structure */
50struct ip_set_hash {
51 struct htable *table; /* the hash table */
52 u32 maxelem; /* max elements in the hash */
53 u32 elements; /* current element (vs timeout) */
54 u32 initval; /* random jhash init value */
55 u32 timeout; /* timeout value, if enabled */
56 struct timer_list gc; /* garbage collection when timeout enabled */
57#ifdef IP_SET_HASH_WITH_NETMASK
58 u8 netmask; /* netmask value for subnets to store */
59#endif
60#ifdef IP_SET_HASH_WITH_NETS
61 struct ip_set_hash_nets nets[0]; /* book-keeping of prefixes */
62#endif
63};
64
65/* Compute htable_bits from the user input parameter hashsize */
66static u8
67htable_bits(u32 hashsize)
68{
69 /* Assume that hashsize == 2^htable_bits */
70 u8 bits = fls(hashsize - 1);
71 if (jhash_size(bits) != hashsize)
72 /* Round up to the first 2^n value */
73 bits = fls(hashsize);
74
75 return bits;
76}
77
78#ifdef IP_SET_HASH_WITH_NETS
79
80#define SET_HOST_MASK(family) (family == AF_INET ? 32 : 128)
81
82/* Network cidr size book keeping when the hash stores different
83 * sized networks */
84static void
85add_cidr(struct ip_set_hash *h, u8 cidr, u8 host_mask)
86{
87 u8 i;
88
89 ++h->nets[cidr-1].nets;
90
91 pr_debug("add_cidr added %u: %u\n", cidr, h->nets[cidr-1].nets);
92
93 if (h->nets[cidr-1].nets > 1)
94 return;
95
96 /* New cidr size */
97 for (i = 0; i < host_mask && h->nets[i].cidr; i++) {
98 /* Add in increasing prefix order, so larger cidr first */
99 if (h->nets[i].cidr < cidr)
100 swap(h->nets[i].cidr, cidr);
101 }
102 if (i < host_mask)
103 h->nets[i].cidr = cidr;
104}
105
106static void
107del_cidr(struct ip_set_hash *h, u8 cidr, u8 host_mask)
108{
109 u8 i;
110
111 --h->nets[cidr-1].nets;
112
113 pr_debug("del_cidr deleted %u: %u\n", cidr, h->nets[cidr-1].nets);
114
115 if (h->nets[cidr-1].nets != 0)
116 return;
117
118 /* All entries with this cidr size deleted, so cleanup h->cidr[] */
119 for (i = 0; i < host_mask - 1 && h->nets[i].cidr; i++) {
120 if (h->nets[i].cidr == cidr)
121 h->nets[i].cidr = cidr = h->nets[i+1].cidr;
122 }
123 h->nets[i - 1].cidr = 0;
124}
125#endif
126
127/* Destroy the hashtable part of the set */
128static void
129ahash_destroy(struct htable *t)
130{
131 struct hbucket *n;
132 u32 i;
133
134 for (i = 0; i < jhash_size(t->htable_bits); i++) {
135 n = hbucket(t, i);
136 if (n->size)
137 /* FIXME: use slab cache */
138 kfree(n->value);
139 }
140
141 ip_set_free(t);
142}
143
144/* Calculate the actual memory size of the set data */
145static size_t
146ahash_memsize(const struct ip_set_hash *h, size_t dsize, u8 host_mask)
147{
148 u32 i;
149 struct htable *t = h->table;
150 size_t memsize = sizeof(*h)
151 + sizeof(*t)
152#ifdef IP_SET_HASH_WITH_NETS
153 + sizeof(struct ip_set_hash_nets) * host_mask
154#endif
155 + jhash_size(t->htable_bits) * sizeof(struct hbucket);
156
157 for (i = 0; i < jhash_size(t->htable_bits); i++)
158 memsize += t->bucket[i].size * dsize;
159
160 return memsize;
161}
162
163/* Flush a hash type of set: destroy all elements */
164static void
165ip_set_hash_flush(struct ip_set *set)
166{
167 struct ip_set_hash *h = set->data;
168 struct htable *t = h->table;
169 struct hbucket *n;
170 u32 i;
171
172 for (i = 0; i < jhash_size(t->htable_bits); i++) {
173 n = hbucket(t, i);
174 if (n->size) {
175 n->size = n->pos = 0;
176 /* FIXME: use slab cache */
177 kfree(n->value);
178 }
179 }
180#ifdef IP_SET_HASH_WITH_NETS
181 memset(h->nets, 0, sizeof(struct ip_set_hash_nets)
182 * SET_HOST_MASK(set->family));
183#endif
184 h->elements = 0;
185}
186
187/* Destroy a hash type of set */
188static void
189ip_set_hash_destroy(struct ip_set *set)
190{
191 struct ip_set_hash *h = set->data;
192
193 if (with_timeout(h->timeout))
194 del_timer_sync(&h->gc);
195
196 ahash_destroy(h->table);
197 kfree(h);
198
199 set->data = NULL;
200}
201
202#define HKEY(data, initval, htable_bits) \
203(jhash2((u32 *)(data), sizeof(struct type_pf_elem)/sizeof(u32), initval) \
204 & jhash_mask(htable_bits))
205
206#endif /* _IP_SET_AHASH_H */
207
208#define CONCAT(a, b, c) a##b##c
209#define TOKEN(a, b, c) CONCAT(a, b, c)
210
211/* Type/family dependent function prototypes */
212
213#define type_pf_data_equal TOKEN(TYPE, PF, _data_equal)
214#define type_pf_data_isnull TOKEN(TYPE, PF, _data_isnull)
215#define type_pf_data_copy TOKEN(TYPE, PF, _data_copy)
216#define type_pf_data_zero_out TOKEN(TYPE, PF, _data_zero_out)
217#define type_pf_data_netmask TOKEN(TYPE, PF, _data_netmask)
218#define type_pf_data_list TOKEN(TYPE, PF, _data_list)
219#define type_pf_data_tlist TOKEN(TYPE, PF, _data_tlist)
220
221#define type_pf_elem TOKEN(TYPE, PF, _elem)
222#define type_pf_telem TOKEN(TYPE, PF, _telem)
223#define type_pf_data_timeout TOKEN(TYPE, PF, _data_timeout)
224#define type_pf_data_expired TOKEN(TYPE, PF, _data_expired)
225#define type_pf_data_timeout_set TOKEN(TYPE, PF, _data_timeout_set)
226
227#define type_pf_elem_add TOKEN(TYPE, PF, _elem_add)
228#define type_pf_add TOKEN(TYPE, PF, _add)
229#define type_pf_del TOKEN(TYPE, PF, _del)
230#define type_pf_test_cidrs TOKEN(TYPE, PF, _test_cidrs)
231#define type_pf_test TOKEN(TYPE, PF, _test)
232
233#define type_pf_elem_tadd TOKEN(TYPE, PF, _elem_tadd)
234#define type_pf_del_telem TOKEN(TYPE, PF, _ahash_del_telem)
235#define type_pf_expire TOKEN(TYPE, PF, _expire)
236#define type_pf_tadd TOKEN(TYPE, PF, _tadd)
237#define type_pf_tdel TOKEN(TYPE, PF, _tdel)
238#define type_pf_ttest_cidrs TOKEN(TYPE, PF, _ahash_ttest_cidrs)
239#define type_pf_ttest TOKEN(TYPE, PF, _ahash_ttest)
240
241#define type_pf_resize TOKEN(TYPE, PF, _resize)
242#define type_pf_tresize TOKEN(TYPE, PF, _tresize)
243#define type_pf_flush ip_set_hash_flush
244#define type_pf_destroy ip_set_hash_destroy
245#define type_pf_head TOKEN(TYPE, PF, _head)
246#define type_pf_list TOKEN(TYPE, PF, _list)
247#define type_pf_tlist TOKEN(TYPE, PF, _tlist)
248#define type_pf_same_set TOKEN(TYPE, PF, _same_set)
249#define type_pf_kadt TOKEN(TYPE, PF, _kadt)
250#define type_pf_uadt TOKEN(TYPE, PF, _uadt)
251#define type_pf_gc TOKEN(TYPE, PF, _gc)
252#define type_pf_gc_init TOKEN(TYPE, PF, _gc_init)
253#define type_pf_variant TOKEN(TYPE, PF, _variant)
254#define type_pf_tvariant TOKEN(TYPE, PF, _tvariant)
255
256/* Flavour without timeout */
257
258/* Get the ith element from the array block n */
259#define ahash_data(n, i) \
260 ((struct type_pf_elem *)((n)->value) + (i))
261
262/* Add an element to the hash table when resizing the set:
263 * we spare the maintenance of the internal counters. */
264static int
265type_pf_elem_add(struct hbucket *n, const struct type_pf_elem *value)
266{
267 if (n->pos >= n->size) {
268 void *tmp;
269
270 if (n->size >= AHASH_MAX_SIZE)
271 /* Trigger rehashing */
272 return -EAGAIN;
273
274 tmp = kzalloc((n->size + AHASH_INIT_SIZE)
275 * sizeof(struct type_pf_elem),
276 GFP_ATOMIC);
277 if (!tmp)
278 return -ENOMEM;
279 if (n->size) {
280 memcpy(tmp, n->value,
281 sizeof(struct type_pf_elem) * n->size);
282 kfree(n->value);
283 }
284 n->value = tmp;
285 n->size += AHASH_INIT_SIZE;
286 }
287 type_pf_data_copy(ahash_data(n, n->pos++), value);
288 return 0;
289}
290
291/* Resize a hash: create a new hash table with doubling the hashsize
292 * and inserting the elements to it. Repeat until we succeed or
293 * fail due to memory pressures. */
294static int
295type_pf_resize(struct ip_set *set, bool retried)
296{
297 struct ip_set_hash *h = set->data;
298 struct htable *t, *orig = h->table;
299 u8 htable_bits = orig->htable_bits;
300 const struct type_pf_elem *data;
301 struct hbucket *n, *m;
302 u32 i, j;
303 int ret;
304
305retry:
306 ret = 0;
307 htable_bits++;
308 pr_debug("attempt to resize set %s from %u to %u, t %p\n",
309 set->name, orig->htable_bits, htable_bits, orig);
310 if (!htable_bits)
311 /* In case we have plenty of memory :-) */
312 return -IPSET_ERR_HASH_FULL;
313 t = ip_set_alloc(sizeof(*t)
314 + jhash_size(htable_bits) * sizeof(struct hbucket));
315 if (!t)
316 return -ENOMEM;
317 t->htable_bits = htable_bits;
318
319 read_lock_bh(&set->lock);
320 for (i = 0; i < jhash_size(orig->htable_bits); i++) {
321 n = hbucket(orig, i);
322 for (j = 0; j < n->pos; j++) {
323 data = ahash_data(n, j);
324 m = hbucket(t, HKEY(data, h->initval, htable_bits));
325 ret = type_pf_elem_add(m, data);
326 if (ret < 0) {
327 read_unlock_bh(&set->lock);
328 ahash_destroy(t);
329 if (ret == -EAGAIN)
330 goto retry;
331 return ret;
332 }
333 }
334 }
335
336 rcu_assign_pointer(h->table, t);
337 read_unlock_bh(&set->lock);
338
339 /* Give time to other readers of the set */
340 synchronize_rcu_bh();
341
342 pr_debug("set %s resized from %u (%p) to %u (%p)\n", set->name,
343 orig->htable_bits, orig, t->htable_bits, t);
344 ahash_destroy(orig);
345
346 return 0;
347}
348
349/* Add an element to a hash and update the internal counters when succeeded,
350 * otherwise report the proper error code. */
351static int
352type_pf_add(struct ip_set *set, void *value, u32 timeout)
353{
354 struct ip_set_hash *h = set->data;
355 struct htable *t;
356 const struct type_pf_elem *d = value;
357 struct hbucket *n;
358 int i, ret = 0;
359 u32 key;
360
361 if (h->elements >= h->maxelem)
362 return -IPSET_ERR_HASH_FULL;
363
364 rcu_read_lock_bh();
365 t = rcu_dereference_bh(h->table);
366 key = HKEY(value, h->initval, t->htable_bits);
367 n = hbucket(t, key);
368 for (i = 0; i < n->pos; i++)
369 if (type_pf_data_equal(ahash_data(n, i), d)) {
370 ret = -IPSET_ERR_EXIST;
371 goto out;
372 }
373
374 ret = type_pf_elem_add(n, value);
375 if (ret != 0)
376 goto out;
377
378#ifdef IP_SET_HASH_WITH_NETS
379 add_cidr(h, d->cidr, HOST_MASK);
380#endif
381 h->elements++;
382out:
383 rcu_read_unlock_bh();
384 return ret;
385}
386
387/* Delete an element from the hash: swap it with the last element
388 * and free up space if possible.
389 */
390static int
391type_pf_del(struct ip_set *set, void *value, u32 timeout)
392{
393 struct ip_set_hash *h = set->data;
394 struct htable *t = h->table;
395 const struct type_pf_elem *d = value;
396 struct hbucket *n;
397 int i;
398 struct type_pf_elem *data;
399 u32 key;
400
401 key = HKEY(value, h->initval, t->htable_bits);
402 n = hbucket(t, key);
403 for (i = 0; i < n->pos; i++) {
404 data = ahash_data(n, i);
405 if (!type_pf_data_equal(data, d))
406 continue;
407 if (i != n->pos - 1)
408 /* Not last one */
409 type_pf_data_copy(data, ahash_data(n, n->pos - 1));
410
411 n->pos--;
412 h->elements--;
413#ifdef IP_SET_HASH_WITH_NETS
414 del_cidr(h, d->cidr, HOST_MASK);
415#endif
416 if (n->pos + AHASH_INIT_SIZE < n->size) {
417 void *tmp = kzalloc((n->size - AHASH_INIT_SIZE)
418 * sizeof(struct type_pf_elem),
419 GFP_ATOMIC);
420 if (!tmp)
421 return 0;
422 n->size -= AHASH_INIT_SIZE;
423 memcpy(tmp, n->value,
424 n->size * sizeof(struct type_pf_elem));
425 kfree(n->value);
426 n->value = tmp;
427 }
428 return 0;
429 }
430
431 return -IPSET_ERR_EXIST;
432}
433
434#ifdef IP_SET_HASH_WITH_NETS
435
436/* Special test function which takes into account the different network
437 * sizes added to the set */
438static int
439type_pf_test_cidrs(struct ip_set *set, struct type_pf_elem *d, u32 timeout)
440{
441 struct ip_set_hash *h = set->data;
442 struct htable *t = h->table;
443 struct hbucket *n;
444 const struct type_pf_elem *data;
445 int i, j = 0;
446 u32 key;
447 u8 host_mask = SET_HOST_MASK(set->family);
448
449 pr_debug("test by nets\n");
450 for (; j < host_mask && h->nets[j].cidr; j++) {
451 type_pf_data_netmask(d, h->nets[j].cidr);
452 key = HKEY(d, h->initval, t->htable_bits);
453 n = hbucket(t, key);
454 for (i = 0; i < n->pos; i++) {
455 data = ahash_data(n, i);
456 if (type_pf_data_equal(data, d))
457 return 1;
458 }
459 }
460 return 0;
461}
462#endif
463
464/* Test whether the element is added to the set */
465static int
466type_pf_test(struct ip_set *set, void *value, u32 timeout)
467{
468 struct ip_set_hash *h = set->data;
469 struct htable *t = h->table;
470 struct type_pf_elem *d = value;
471 struct hbucket *n;
472 const struct type_pf_elem *data;
473 int i;
474 u32 key;
475
476#ifdef IP_SET_HASH_WITH_NETS
477 /* If we test an IP address and not a network address,
478 * try all possible network sizes */
479 if (d->cidr == SET_HOST_MASK(set->family))
480 return type_pf_test_cidrs(set, d, timeout);
481#endif
482
483 key = HKEY(d, h->initval, t->htable_bits);
484 n = hbucket(t, key);
485 for (i = 0; i < n->pos; i++) {
486 data = ahash_data(n, i);
487 if (type_pf_data_equal(data, d))
488 return 1;
489 }
490 return 0;
491}
492
493/* Reply a HEADER request: fill out the header part of the set */
494static int
495type_pf_head(struct ip_set *set, struct sk_buff *skb)
496{
497 const struct ip_set_hash *h = set->data;
498 struct nlattr *nested;
499 size_t memsize;
500
501 read_lock_bh(&set->lock);
502 memsize = ahash_memsize(h, with_timeout(h->timeout)
503 ? sizeof(struct type_pf_telem)
504 : sizeof(struct type_pf_elem),
505 set->family == AF_INET ? 32 : 128);
506 read_unlock_bh(&set->lock);
507
508 nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
509 if (!nested)
510 goto nla_put_failure;
511 NLA_PUT_NET32(skb, IPSET_ATTR_HASHSIZE,
512 htonl(jhash_size(h->table->htable_bits)));
513 NLA_PUT_NET32(skb, IPSET_ATTR_MAXELEM, htonl(h->maxelem));
514#ifdef IP_SET_HASH_WITH_NETMASK
515 if (h->netmask != HOST_MASK)
516 NLA_PUT_U8(skb, IPSET_ATTR_NETMASK, h->netmask);
517#endif
518 NLA_PUT_NET32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1));
519 NLA_PUT_NET32(skb, IPSET_ATTR_MEMSIZE, htonl(memsize));
520 if (with_timeout(h->timeout))
521 NLA_PUT_NET32(skb, IPSET_ATTR_TIMEOUT, htonl(h->timeout));
522 ipset_nest_end(skb, nested);
523
524 return 0;
525nla_put_failure:
526 return -EMSGSIZE;
527}
528
529/* Reply a LIST/SAVE request: dump the elements of the specified set */
530static int
531type_pf_list(const struct ip_set *set,
532 struct sk_buff *skb, struct netlink_callback *cb)
533{
534 const struct ip_set_hash *h = set->data;
535 const struct htable *t = h->table;
536 struct nlattr *atd, *nested;
537 const struct hbucket *n;
538 const struct type_pf_elem *data;
539 u32 first = cb->args[2];
540 /* We assume that one hash bucket fills into one page */
541 void *incomplete;
542 int i;
543
544 atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
545 if (!atd)
546 return -EMSGSIZE;
547 pr_debug("list hash set %s\n", set->name);
548 for (; cb->args[2] < jhash_size(t->htable_bits); cb->args[2]++) {
549 incomplete = skb_tail_pointer(skb);
550 n = hbucket(t, cb->args[2]);
551 pr_debug("cb->args[2]: %lu, t %p n %p\n", cb->args[2], t, n);
552 for (i = 0; i < n->pos; i++) {
553 data = ahash_data(n, i);
554 pr_debug("list hash %lu hbucket %p i %u, data %p\n",
555 cb->args[2], n, i, data);
556 nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
557 if (!nested) {
558 if (cb->args[2] == first) {
559 nla_nest_cancel(skb, atd);
560 return -EMSGSIZE;
561 } else
562 goto nla_put_failure;
563 }
564 if (type_pf_data_list(skb, data))
565 goto nla_put_failure;
566 ipset_nest_end(skb, nested);
567 }
568 }
569 ipset_nest_end(skb, atd);
570 /* Set listing finished */
571 cb->args[2] = 0;
572
573 return 0;
574
575nla_put_failure:
576 nlmsg_trim(skb, incomplete);
577 ipset_nest_end(skb, atd);
578 if (unlikely(first == cb->args[2])) {
579 pr_warning("Can't list set %s: one bucket does not fit into "
580 "a message. Please report it!\n", set->name);
581 cb->args[2] = 0;
582 return -EMSGSIZE;
583 }
584 return 0;
585}
586
587static int
588type_pf_kadt(struct ip_set *set, const struct sk_buff * skb,
589 enum ipset_adt adt, u8 pf, u8 dim, u8 flags);
590static int
591type_pf_uadt(struct ip_set *set, struct nlattr *tb[],
592 enum ipset_adt adt, u32 *lineno, u32 flags);
593
594static const struct ip_set_type_variant type_pf_variant = {
595 .kadt = type_pf_kadt,
596 .uadt = type_pf_uadt,
597 .adt = {
598 [IPSET_ADD] = type_pf_add,
599 [IPSET_DEL] = type_pf_del,
600 [IPSET_TEST] = type_pf_test,
601 },
602 .destroy = type_pf_destroy,
603 .flush = type_pf_flush,
604 .head = type_pf_head,
605 .list = type_pf_list,
606 .resize = type_pf_resize,
607 .same_set = type_pf_same_set,
608};
609
610/* Flavour with timeout support */
611
612#define ahash_tdata(n, i) \
613 (struct type_pf_elem *)((struct type_pf_telem *)((n)->value) + (i))
614
615static inline u32
616type_pf_data_timeout(const struct type_pf_elem *data)
617{
618 const struct type_pf_telem *tdata =
619 (const struct type_pf_telem *) data;
620
621 return tdata->timeout;
622}
623
624static inline bool
625type_pf_data_expired(const struct type_pf_elem *data)
626{
627 const struct type_pf_telem *tdata =
628 (const struct type_pf_telem *) data;
629
630 return ip_set_timeout_expired(tdata->timeout);
631}
632
633static inline void
634type_pf_data_timeout_set(struct type_pf_elem *data, u32 timeout)
635{
636 struct type_pf_telem *tdata = (struct type_pf_telem *) data;
637
638 tdata->timeout = ip_set_timeout_set(timeout);
639}
640
641static int
642type_pf_elem_tadd(struct hbucket *n, const struct type_pf_elem *value,
643 u32 timeout)
644{
645 struct type_pf_elem *data;
646
647 if (n->pos >= n->size) {
648 void *tmp;
649
650 if (n->size >= AHASH_MAX_SIZE)
651 /* Trigger rehashing */
652 return -EAGAIN;
653
654 tmp = kzalloc((n->size + AHASH_INIT_SIZE)
655 * sizeof(struct type_pf_telem),
656 GFP_ATOMIC);
657 if (!tmp)
658 return -ENOMEM;
659 if (n->size) {
660 memcpy(tmp, n->value,
661 sizeof(struct type_pf_telem) * n->size);
662 kfree(n->value);
663 }
664 n->value = tmp;
665 n->size += AHASH_INIT_SIZE;
666 }
667 data = ahash_tdata(n, n->pos++);
668 type_pf_data_copy(data, value);
669 type_pf_data_timeout_set(data, timeout);
670 return 0;
671}
672
673/* Delete expired elements from the hashtable */
674static void
675type_pf_expire(struct ip_set_hash *h)
676{
677 struct htable *t = h->table;
678 struct hbucket *n;
679 struct type_pf_elem *data;
680 u32 i;
681 int j;
682
683 for (i = 0; i < jhash_size(t->htable_bits); i++) {
684 n = hbucket(t, i);
685 for (j = 0; j < n->pos; j++) {
686 data = ahash_tdata(n, j);
687 if (type_pf_data_expired(data)) {
688 pr_debug("expired %u/%u\n", i, j);
689#ifdef IP_SET_HASH_WITH_NETS
690 del_cidr(h, data->cidr, HOST_MASK);
691#endif
692 if (j != n->pos - 1)
693 /* Not last one */
694 type_pf_data_copy(data,
695 ahash_tdata(n, n->pos - 1));
696 n->pos--;
697 h->elements--;
698 }
699 }
700 if (n->pos + AHASH_INIT_SIZE < n->size) {
701 void *tmp = kzalloc((n->size - AHASH_INIT_SIZE)
702 * sizeof(struct type_pf_telem),
703 GFP_ATOMIC);
704 if (!tmp)
705 /* Still try to delete expired elements */
706 continue;
707 n->size -= AHASH_INIT_SIZE;
708 memcpy(tmp, n->value,
709 n->size * sizeof(struct type_pf_telem));
710 kfree(n->value);
711 n->value = tmp;
712 }
713 }
714}
715
716static int
717type_pf_tresize(struct ip_set *set, bool retried)
718{
719 struct ip_set_hash *h = set->data;
720 struct htable *t, *orig = h->table;
721 u8 htable_bits = orig->htable_bits;
722 const struct type_pf_elem *data;
723 struct hbucket *n, *m;
724 u32 i, j;
725 int ret;
726
727 /* Try to cleanup once */
728 if (!retried) {
729 i = h->elements;
730 write_lock_bh(&set->lock);
731 type_pf_expire(set->data);
732 write_unlock_bh(&set->lock);
733 if (h->elements < i)
734 return 0;
735 }
736
737retry:
738 ret = 0;
739 htable_bits++;
740 if (!htable_bits)
741 /* In case we have plenty of memory :-) */
742 return -IPSET_ERR_HASH_FULL;
743 t = ip_set_alloc(sizeof(*t)
744 + jhash_size(htable_bits) * sizeof(struct hbucket));
745 if (!t)
746 return -ENOMEM;
747 t->htable_bits = htable_bits;
748
749 read_lock_bh(&set->lock);
750 for (i = 0; i < jhash_size(orig->htable_bits); i++) {
751 n = hbucket(orig, i);
752 for (j = 0; j < n->pos; j++) {
753 data = ahash_tdata(n, j);
754 m = hbucket(t, HKEY(data, h->initval, htable_bits));
755 ret = type_pf_elem_tadd(m, data,
756 type_pf_data_timeout(data));
757 if (ret < 0) {
758 read_unlock_bh(&set->lock);
759 ahash_destroy(t);
760 if (ret == -EAGAIN)
761 goto retry;
762 return ret;
763 }
764 }
765 }
766
767 rcu_assign_pointer(h->table, t);
768 read_unlock_bh(&set->lock);
769
770 /* Give time to other readers of the set */
771 synchronize_rcu_bh();
772
773 ahash_destroy(orig);
774
775 return 0;
776}
777
778static int
779type_pf_tadd(struct ip_set *set, void *value, u32 timeout)
780{
781 struct ip_set_hash *h = set->data;
782 struct htable *t = h->table;
783 const struct type_pf_elem *d = value;
784 struct hbucket *n;
785 struct type_pf_elem *data;
786 int ret = 0, i, j = AHASH_MAX_SIZE + 1;
787 u32 key;
788
789 if (h->elements >= h->maxelem)
790 /* FIXME: when set is full, we slow down here */
791 type_pf_expire(h);
792 if (h->elements >= h->maxelem)
793 return -IPSET_ERR_HASH_FULL;
794
795 rcu_read_lock_bh();
796 t = rcu_dereference_bh(h->table);
797 key = HKEY(d, h->initval, t->htable_bits);
798 n = hbucket(t, key);
799 for (i = 0; i < n->pos; i++) {
800 data = ahash_tdata(n, i);
801 if (type_pf_data_equal(data, d)) {
802 if (type_pf_data_expired(data))
803 j = i;
804 else {
805 ret = -IPSET_ERR_EXIST;
806 goto out;
807 }
808 } else if (j == AHASH_MAX_SIZE + 1 &&
809 type_pf_data_expired(data))
810 j = i;
811 }
812 if (j != AHASH_MAX_SIZE + 1) {
813 data = ahash_tdata(n, j);
814#ifdef IP_SET_HASH_WITH_NETS
815 del_cidr(h, data->cidr, HOST_MASK);
816 add_cidr(h, d->cidr, HOST_MASK);
817#endif
818 type_pf_data_copy(data, d);
819 type_pf_data_timeout_set(data, timeout);
820 goto out;
821 }
822 ret = type_pf_elem_tadd(n, d, timeout);
823 if (ret != 0)
824 goto out;
825
826#ifdef IP_SET_HASH_WITH_NETS
827 add_cidr(h, d->cidr, HOST_MASK);
828#endif
829 h->elements++;
830out:
831 rcu_read_unlock_bh();
832 return ret;
833}
834
835static int
836type_pf_tdel(struct ip_set *set, void *value, u32 timeout)
837{
838 struct ip_set_hash *h = set->data;
839 struct htable *t = h->table;
840 const struct type_pf_elem *d = value;
841 struct hbucket *n;
842 int i;
843 struct type_pf_elem *data;
844 u32 key;
845
846 key = HKEY(value, h->initval, t->htable_bits);
847 n = hbucket(t, key);
848 for (i = 0; i < n->pos; i++) {
849 data = ahash_tdata(n, i);
850 if (!type_pf_data_equal(data, d))
851 continue;
852 if (type_pf_data_expired(data))
853 return -IPSET_ERR_EXIST;
854 if (i != n->pos - 1)
855 /* Not last one */
856 type_pf_data_copy(data, ahash_tdata(n, n->pos - 1));
857
858 n->pos--;
859 h->elements--;
860#ifdef IP_SET_HASH_WITH_NETS
861 del_cidr(h, d->cidr, HOST_MASK);
862#endif
863 if (n->pos + AHASH_INIT_SIZE < n->size) {
864 void *tmp = kzalloc((n->size - AHASH_INIT_SIZE)
865 * sizeof(struct type_pf_telem),
866 GFP_ATOMIC);
867 if (!tmp)
868 return 0;
869 n->size -= AHASH_INIT_SIZE;
870 memcpy(tmp, n->value,
871 n->size * sizeof(struct type_pf_telem));
872 kfree(n->value);
873 n->value = tmp;
874 }
875 return 0;
876 }
877
878 return -IPSET_ERR_EXIST;
879}
880
881#ifdef IP_SET_HASH_WITH_NETS
882static int
883type_pf_ttest_cidrs(struct ip_set *set, struct type_pf_elem *d, u32 timeout)
884{
885 struct ip_set_hash *h = set->data;
886 struct htable *t = h->table;
887 struct type_pf_elem *data;
888 struct hbucket *n;
889 int i, j = 0;
890 u32 key;
891 u8 host_mask = SET_HOST_MASK(set->family);
892
893 for (; j < host_mask && h->nets[j].cidr; j++) {
894 type_pf_data_netmask(d, h->nets[j].cidr);
895 key = HKEY(d, h->initval, t->htable_bits);
896 n = hbucket(t, key);
897 for (i = 0; i < n->pos; i++) {
898 data = ahash_tdata(n, i);
899 if (type_pf_data_equal(data, d))
900 return !type_pf_data_expired(data);
901 }
902 }
903 return 0;
904}
905#endif
906
907static int
908type_pf_ttest(struct ip_set *set, void *value, u32 timeout)
909{
910 struct ip_set_hash *h = set->data;
911 struct htable *t = h->table;
912 struct type_pf_elem *data, *d = value;
913 struct hbucket *n;
914 int i;
915 u32 key;
916
917#ifdef IP_SET_HASH_WITH_NETS
918 if (d->cidr == SET_HOST_MASK(set->family))
919 return type_pf_ttest_cidrs(set, d, timeout);
920#endif
921 key = HKEY(d, h->initval, t->htable_bits);
922 n = hbucket(t, key);
923 for (i = 0; i < n->pos; i++) {
924 data = ahash_tdata(n, i);
925 if (type_pf_data_equal(data, d))
926 return !type_pf_data_expired(data);
927 }
928 return 0;
929}
930
931static int
932type_pf_tlist(const struct ip_set *set,
933 struct sk_buff *skb, struct netlink_callback *cb)
934{
935 const struct ip_set_hash *h = set->data;
936 const struct htable *t = h->table;
937 struct nlattr *atd, *nested;
938 const struct hbucket *n;
939 const struct type_pf_elem *data;
940 u32 first = cb->args[2];
941 /* We assume that one hash bucket fills into one page */
942 void *incomplete;
943 int i;
944
945 atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
946 if (!atd)
947 return -EMSGSIZE;
948 for (; cb->args[2] < jhash_size(t->htable_bits); cb->args[2]++) {
949 incomplete = skb_tail_pointer(skb);
950 n = hbucket(t, cb->args[2]);
951 for (i = 0; i < n->pos; i++) {
952 data = ahash_tdata(n, i);
953 pr_debug("list %p %u\n", n, i);
954 if (type_pf_data_expired(data))
955 continue;
956 pr_debug("do list %p %u\n", n, i);
957 nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
958 if (!nested) {
959 if (cb->args[2] == first) {
960 nla_nest_cancel(skb, atd);
961 return -EMSGSIZE;
962 } else
963 goto nla_put_failure;
964 }
965 if (type_pf_data_tlist(skb, data))
966 goto nla_put_failure;
967 ipset_nest_end(skb, nested);
968 }
969 }
970 ipset_nest_end(skb, atd);
971 /* Set listing finished */
972 cb->args[2] = 0;
973
974 return 0;
975
976nla_put_failure:
977 nlmsg_trim(skb, incomplete);
978 ipset_nest_end(skb, atd);
979 if (unlikely(first == cb->args[2])) {
980 pr_warning("Can't list set %s: one bucket does not fit into "
981 "a message. Please report it!\n", set->name);
982 cb->args[2] = 0;
983 return -EMSGSIZE;
984 }
985 return 0;
986}
987
988static const struct ip_set_type_variant type_pf_tvariant = {
989 .kadt = type_pf_kadt,
990 .uadt = type_pf_uadt,
991 .adt = {
992 [IPSET_ADD] = type_pf_tadd,
993 [IPSET_DEL] = type_pf_tdel,
994 [IPSET_TEST] = type_pf_ttest,
995 },
996 .destroy = type_pf_destroy,
997 .flush = type_pf_flush,
998 .head = type_pf_head,
999 .list = type_pf_tlist,
1000 .resize = type_pf_tresize,
1001 .same_set = type_pf_same_set,
1002};
1003
1004static void
1005type_pf_gc(unsigned long ul_set)
1006{
1007 struct ip_set *set = (struct ip_set *) ul_set;
1008 struct ip_set_hash *h = set->data;
1009
1010 pr_debug("called\n");
1011 write_lock_bh(&set->lock);
1012 type_pf_expire(h);
1013 write_unlock_bh(&set->lock);
1014
1015 h->gc.expires = jiffies + IPSET_GC_PERIOD(h->timeout) * HZ;
1016 add_timer(&h->gc);
1017}
1018
1019static void
1020type_pf_gc_init(struct ip_set *set)
1021{
1022 struct ip_set_hash *h = set->data;
1023
1024 init_timer(&h->gc);
1025 h->gc.data = (unsigned long) set;
1026 h->gc.function = type_pf_gc;
1027 h->gc.expires = jiffies + IPSET_GC_PERIOD(h->timeout) * HZ;
1028 add_timer(&h->gc);
1029 pr_debug("gc initialized, run in every %u\n",
1030 IPSET_GC_PERIOD(h->timeout));
1031}
1032
1033#undef type_pf_data_equal
1034#undef type_pf_data_isnull
1035#undef type_pf_data_copy
1036#undef type_pf_data_zero_out
1037#undef type_pf_data_list
1038#undef type_pf_data_tlist
1039
1040#undef type_pf_elem
1041#undef type_pf_telem
1042#undef type_pf_data_timeout
1043#undef type_pf_data_expired
1044#undef type_pf_data_netmask
1045#undef type_pf_data_timeout_set
1046
1047#undef type_pf_elem_add
1048#undef type_pf_add
1049#undef type_pf_del
1050#undef type_pf_test_cidrs
1051#undef type_pf_test
1052
1053#undef type_pf_elem_tadd
1054#undef type_pf_expire
1055#undef type_pf_tadd
1056#undef type_pf_tdel
1057#undef type_pf_ttest_cidrs
1058#undef type_pf_ttest
1059
1060#undef type_pf_resize
1061#undef type_pf_tresize
1062#undef type_pf_flush
1063#undef type_pf_destroy
1064#undef type_pf_head
1065#undef type_pf_list
1066#undef type_pf_tlist
1067#undef type_pf_same_set
1068#undef type_pf_kadt
1069#undef type_pf_uadt
1070#undef type_pf_gc
1071#undef type_pf_gc_init
1072#undef type_pf_variant
1073#undef type_pf_tvariant
diff --git a/include/linux/netfilter/ipset/ip_set_bitmap.h b/include/linux/netfilter/ipset/ip_set_bitmap.h
new file mode 100644
index 000000000000..61a9e8746c83
--- /dev/null
+++ b/include/linux/netfilter/ipset/ip_set_bitmap.h
@@ -0,0 +1,31 @@
1#ifndef __IP_SET_BITMAP_H
2#define __IP_SET_BITMAP_H
3
4/* Bitmap type specific error codes */
5enum {
6 /* The element is out of the range of the set */
7 IPSET_ERR_BITMAP_RANGE = IPSET_ERR_TYPE_SPECIFIC,
8 /* The range exceeds the size limit of the set type */
9 IPSET_ERR_BITMAP_RANGE_SIZE,
10};
11
12#ifdef __KERNEL__
13#define IPSET_BITMAP_MAX_RANGE 0x0000FFFF
14
15/* Common functions */
16
17static inline u32
18range_to_mask(u32 from, u32 to, u8 *bits)
19{
20 u32 mask = 0xFFFFFFFE;
21
22 *bits = 32;
23 while (--(*bits) > 0 && mask && (to & mask) != from)
24 mask <<= 1;
25
26 return mask;
27}
28
29#endif /* __KERNEL__ */
30
31#endif /* __IP_SET_BITMAP_H */
diff --git a/include/linux/netfilter/ipset/ip_set_getport.h b/include/linux/netfilter/ipset/ip_set_getport.h
new file mode 100644
index 000000000000..90d09300e954
--- /dev/null
+++ b/include/linux/netfilter/ipset/ip_set_getport.h
@@ -0,0 +1,33 @@
1#ifndef _IP_SET_GETPORT_H
2#define _IP_SET_GETPORT_H
3
4extern bool ip_set_get_ip4_port(const struct sk_buff *skb, bool src,
5 __be16 *port, u8 *proto);
6
7#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
8extern bool ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
9 __be16 *port, u8 *proto);
10#else
11static inline bool ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
12 __be16 *port, u8 *proto)
13{
14 return false;
15}
16#endif
17
18extern bool ip_set_get_ip_port(const struct sk_buff *skb, u8 pf, bool src,
19 __be16 *port);
20
21static inline bool ip_set_proto_with_ports(u8 proto)
22{
23 switch (proto) {
24 case IPPROTO_TCP:
25 case IPPROTO_SCTP:
26 case IPPROTO_UDP:
27 case IPPROTO_UDPLITE:
28 return true;
29 }
30 return false;
31}
32
33#endif /*_IP_SET_GETPORT_H*/
diff --git a/include/linux/netfilter/ipset/ip_set_hash.h b/include/linux/netfilter/ipset/ip_set_hash.h
new file mode 100644
index 000000000000..b86f15c04524
--- /dev/null
+++ b/include/linux/netfilter/ipset/ip_set_hash.h
@@ -0,0 +1,26 @@
1#ifndef __IP_SET_HASH_H
2#define __IP_SET_HASH_H
3
4/* Hash type specific error codes */
5enum {
6 /* Hash is full */
7 IPSET_ERR_HASH_FULL = IPSET_ERR_TYPE_SPECIFIC,
8 /* Null-valued element */
9 IPSET_ERR_HASH_ELEM,
10 /* Invalid protocol */
11 IPSET_ERR_INVALID_PROTO,
12 /* Protocol missing but must be specified */
13 IPSET_ERR_MISSING_PROTO,
14};
15
16#ifdef __KERNEL__
17
18#define IPSET_DEFAULT_HASHSIZE 1024
19#define IPSET_MIMINAL_HASHSIZE 64
20#define IPSET_DEFAULT_MAXELEM 65536
21#define IPSET_DEFAULT_PROBES 4
22#define IPSET_DEFAULT_RESIZE 100
23
24#endif /* __KERNEL__ */
25
26#endif /* __IP_SET_HASH_H */
diff --git a/include/linux/netfilter/ipset/ip_set_list.h b/include/linux/netfilter/ipset/ip_set_list.h
new file mode 100644
index 000000000000..40a63f302613
--- /dev/null
+++ b/include/linux/netfilter/ipset/ip_set_list.h
@@ -0,0 +1,27 @@
1#ifndef __IP_SET_LIST_H
2#define __IP_SET_LIST_H
3
4/* List type specific error codes */
5enum {
6 /* Set name to be added/deleted/tested does not exist. */
7 IPSET_ERR_NAME = IPSET_ERR_TYPE_SPECIFIC,
8 /* list:set type is not permitted to add */
9 IPSET_ERR_LOOP,
10 /* Missing reference set */
11 IPSET_ERR_BEFORE,
12 /* Reference set does not exist */
13 IPSET_ERR_NAMEREF,
14 /* Set is full */
15 IPSET_ERR_LIST_FULL,
16 /* Reference set is not added to the set */
17 IPSET_ERR_REF_EXIST,
18};
19
20#ifdef __KERNEL__
21
22#define IP_SET_LIST_DEFAULT_SIZE 8
23#define IP_SET_LIST_MIN_SIZE 4
24
25#endif /* __KERNEL__ */
26
27#endif /* __IP_SET_LIST_H */
diff --git a/include/linux/netfilter/ipset/ip_set_timeout.h b/include/linux/netfilter/ipset/ip_set_timeout.h
new file mode 100644
index 000000000000..bcdd40ad39ed
--- /dev/null
+++ b/include/linux/netfilter/ipset/ip_set_timeout.h
@@ -0,0 +1,129 @@
1#ifndef _IP_SET_TIMEOUT_H
2#define _IP_SET_TIMEOUT_H
3
4/* Copyright (C) 2003-2011 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifdef __KERNEL__
12
13/* How often should the gc be run by default */
14#define IPSET_GC_TIME (3 * 60)
15
16/* Timeout period depending on the timeout value of the given set */
17#define IPSET_GC_PERIOD(timeout) \
18 ((timeout/3) ? min_t(u32, (timeout)/3, IPSET_GC_TIME) : 1)
19
20/* Set is defined without timeout support: timeout value may be 0 */
21#define IPSET_NO_TIMEOUT UINT_MAX
22
23#define with_timeout(timeout) ((timeout) != IPSET_NO_TIMEOUT)
24
25static inline unsigned int
26ip_set_timeout_uget(struct nlattr *tb)
27{
28 unsigned int timeout = ip_set_get_h32(tb);
29
30 /* Userspace supplied TIMEOUT parameter: adjust crazy size */
31 return timeout == IPSET_NO_TIMEOUT ? IPSET_NO_TIMEOUT - 1 : timeout;
32}
33
34#ifdef IP_SET_BITMAP_TIMEOUT
35
36/* Bitmap specific timeout constants and macros for the entries */
37
38/* Bitmap entry is unset */
39#define IPSET_ELEM_UNSET 0
40/* Bitmap entry is set with no timeout value */
41#define IPSET_ELEM_PERMANENT (UINT_MAX/2)
42
43static inline bool
44ip_set_timeout_test(unsigned long timeout)
45{
46 return timeout != IPSET_ELEM_UNSET &&
47 (timeout == IPSET_ELEM_PERMANENT ||
48 time_is_after_jiffies(timeout));
49}
50
51static inline bool
52ip_set_timeout_expired(unsigned long timeout)
53{
54 return timeout != IPSET_ELEM_UNSET &&
55 timeout != IPSET_ELEM_PERMANENT &&
56 time_is_before_jiffies(timeout);
57}
58
59static inline unsigned long
60ip_set_timeout_set(u32 timeout)
61{
62 unsigned long t;
63
64 if (!timeout)
65 return IPSET_ELEM_PERMANENT;
66
67 t = msecs_to_jiffies(timeout * 1000) + jiffies;
68 if (t == IPSET_ELEM_UNSET || t == IPSET_ELEM_PERMANENT)
69 /* Bingo! */
70 t++;
71
72 return t;
73}
74
75static inline u32
76ip_set_timeout_get(unsigned long timeout)
77{
78 return timeout == IPSET_ELEM_PERMANENT ? 0 :
79 jiffies_to_msecs(timeout - jiffies)/1000;
80}
81
82#else
83
84/* Hash specific timeout constants and macros for the entries */
85
86/* Hash entry is set with no timeout value */
87#define IPSET_ELEM_PERMANENT 0
88
89static inline bool
90ip_set_timeout_test(unsigned long timeout)
91{
92 return timeout == IPSET_ELEM_PERMANENT ||
93 time_is_after_jiffies(timeout);
94}
95
96static inline bool
97ip_set_timeout_expired(unsigned long timeout)
98{
99 return timeout != IPSET_ELEM_PERMANENT &&
100 time_is_before_jiffies(timeout);
101}
102
103static inline unsigned long
104ip_set_timeout_set(u32 timeout)
105{
106 unsigned long t;
107
108 if (!timeout)
109 return IPSET_ELEM_PERMANENT;
110
111 t = msecs_to_jiffies(timeout * 1000) + jiffies;
112 if (t == IPSET_ELEM_PERMANENT)
113 /* Bingo! :-) */
114 t++;
115
116 return t;
117}
118
119static inline u32
120ip_set_timeout_get(unsigned long timeout)
121{
122 return timeout == IPSET_ELEM_PERMANENT ? 0 :
123 jiffies_to_msecs(timeout - jiffies)/1000;
124}
125#endif /* ! IP_SET_BITMAP_TIMEOUT */
126
127#endif /* __KERNEL__ */
128
129#endif /* _IP_SET_TIMEOUT_H */
diff --git a/include/linux/netfilter/ipset/pfxlen.h b/include/linux/netfilter/ipset/pfxlen.h
new file mode 100644
index 000000000000..0e1fb50da562
--- /dev/null
+++ b/include/linux/netfilter/ipset/pfxlen.h
@@ -0,0 +1,35 @@
1#ifndef _PFXLEN_H
2#define _PFXLEN_H
3
4#include <asm/byteorder.h>
5#include <linux/netfilter.h>
6
7/* Prefixlen maps, by Jan Engelhardt */
8extern const union nf_inet_addr ip_set_netmask_map[];
9extern const union nf_inet_addr ip_set_hostmask_map[];
10
11static inline __be32
12ip_set_netmask(u8 pfxlen)
13{
14 return ip_set_netmask_map[pfxlen].ip;
15}
16
17static inline const __be32 *
18ip_set_netmask6(u8 pfxlen)
19{
20 return &ip_set_netmask_map[pfxlen].ip6[0];
21}
22
23static inline u32
24ip_set_hostmask(u8 pfxlen)
25{
26 return (__force u32) ip_set_hostmask_map[pfxlen].ip;
27}
28
29static inline const __be32 *
30ip_set_hostmask6(u8 pfxlen)
31{
32 return &ip_set_hostmask_map[pfxlen].ip6[0];
33}
34
35#endif /*_PFXLEN_H */
diff --git a/include/linux/netfilter/nf_conntrack_common.h b/include/linux/netfilter/nf_conntrack_common.h
index 1afd18c855ec..0d3dd66322ec 100644
--- a/include/linux/netfilter/nf_conntrack_common.h
+++ b/include/linux/netfilter/nf_conntrack_common.h
@@ -18,6 +18,9 @@ enum ip_conntrack_info {
18 /* >= this indicates reply direction */ 18 /* >= this indicates reply direction */
19 IP_CT_IS_REPLY, 19 IP_CT_IS_REPLY,
20 20
21 IP_CT_ESTABLISHED_REPLY = IP_CT_ESTABLISHED + IP_CT_IS_REPLY,
22 IP_CT_RELATED_REPLY = IP_CT_RELATED + IP_CT_IS_REPLY,
23 IP_CT_NEW_REPLY = IP_CT_NEW + IP_CT_IS_REPLY,
21 /* Number of distinct IP_CT types (no NEW in reply dirn). */ 24 /* Number of distinct IP_CT types (no NEW in reply dirn). */
22 IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1 25 IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1
23}; 26};
@@ -98,8 +101,14 @@ enum ip_conntrack_events {
98 101
99enum ip_conntrack_expect_events { 102enum ip_conntrack_expect_events {
100 IPEXP_NEW, /* new expectation */ 103 IPEXP_NEW, /* new expectation */
104 IPEXP_DESTROY, /* destroyed expectation */
101}; 105};
102 106
107/* expectation flags */
108#define NF_CT_EXPECT_PERMANENT 0x1
109#define NF_CT_EXPECT_INACTIVE 0x2
110#define NF_CT_EXPECT_USERSPACE 0x4
111
103#ifdef __KERNEL__ 112#ifdef __KERNEL__
104struct ip_conntrack_stat { 113struct ip_conntrack_stat {
105 unsigned int searched; 114 unsigned int searched;
diff --git a/include/linux/netfilter/nf_conntrack_proto_gre.h b/include/linux/netfilter/nf_conntrack_proto_gre.h
index 2a10efda17fb..6a0664c0c451 100644
--- a/include/linux/netfilter/nf_conntrack_proto_gre.h
+++ b/include/linux/netfilter/nf_conntrack_proto_gre.h
@@ -60,7 +60,7 @@ struct gre_hdr_pptp {
60 __be16 payload_len; /* size of ppp payload, not inc. gre header */ 60 __be16 payload_len; /* size of ppp payload, not inc. gre header */
61 __be16 call_id; /* peer's call_id for this session */ 61 __be16 call_id; /* peer's call_id for this session */
62 __be32 seq; /* sequence number. Present if S==1 */ 62 __be32 seq; /* sequence number. Present if S==1 */
63 __be32 ack; /* seq number of highest packet recieved by */ 63 __be32 ack; /* seq number of highest packet received by */
64 /* sender in this session */ 64 /* sender in this session */
65}; 65};
66 66
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h
index ff8cfbcf3b81..0ce91d56a5f2 100644
--- a/include/linux/netfilter/nf_conntrack_sip.h
+++ b/include/linux/netfilter/nf_conntrack_sip.h
@@ -89,6 +89,7 @@ enum sip_header_types {
89 SIP_HDR_VIA_TCP, 89 SIP_HDR_VIA_TCP,
90 SIP_HDR_EXPIRES, 90 SIP_HDR_EXPIRES,
91 SIP_HDR_CONTENT_LENGTH, 91 SIP_HDR_CONTENT_LENGTH,
92 SIP_HDR_CALL_ID,
92}; 93};
93 94
94enum sdp_header_types { 95enum sdp_header_types {
diff --git a/include/linux/netfilter/nf_conntrack_snmp.h b/include/linux/netfilter/nf_conntrack_snmp.h
new file mode 100644
index 000000000000..064bc63a5346
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_snmp.h
@@ -0,0 +1,9 @@
1#ifndef _NF_CONNTRACK_SNMP_H
2#define _NF_CONNTRACK_SNMP_H
3
4extern int (*nf_nat_snmp_hook)(struct sk_buff *skb,
5 unsigned int protoff,
6 struct nf_conn *ct,
7 enum ip_conntrack_info ctinfo);
8
9#endif /* _NF_CONNTRACK_SNMP_H */
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 361d6b5630ee..2b11fc1a86be 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -47,7 +47,8 @@ struct nfgenmsg {
47#define NFNL_SUBSYS_QUEUE 3 47#define NFNL_SUBSYS_QUEUE 3
48#define NFNL_SUBSYS_ULOG 4 48#define NFNL_SUBSYS_ULOG 4
49#define NFNL_SUBSYS_OSF 5 49#define NFNL_SUBSYS_OSF 5
50#define NFNL_SUBSYS_COUNT 6 50#define NFNL_SUBSYS_IPSET 6
51#define NFNL_SUBSYS_COUNT 7
51 52
52#ifdef __KERNEL__ 53#ifdef __KERNEL__
53 54
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h
index 9ed534c991b9..debf1aefd753 100644
--- a/include/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/linux/netfilter/nfnetlink_conntrack.h
@@ -39,8 +39,10 @@ enum ctattr_type {
39 CTA_TUPLE_MASTER, 39 CTA_TUPLE_MASTER,
40 CTA_NAT_SEQ_ADJ_ORIG, 40 CTA_NAT_SEQ_ADJ_ORIG,
41 CTA_NAT_SEQ_ADJ_REPLY, 41 CTA_NAT_SEQ_ADJ_REPLY,
42 CTA_SECMARK, 42 CTA_SECMARK, /* obsolete */
43 CTA_ZONE, 43 CTA_ZONE,
44 CTA_SECCTX,
45 CTA_TIMESTAMP,
44 __CTA_MAX 46 __CTA_MAX
45}; 47};
46#define CTA_MAX (__CTA_MAX - 1) 48#define CTA_MAX (__CTA_MAX - 1)
@@ -126,6 +128,14 @@ enum ctattr_counters {
126}; 128};
127#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1) 129#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1)
128 130
131enum ctattr_tstamp {
132 CTA_TIMESTAMP_UNSPEC,
133 CTA_TIMESTAMP_START,
134 CTA_TIMESTAMP_STOP,
135 __CTA_TIMESTAMP_MAX
136};
137#define CTA_TIMESTAMP_MAX (__CTA_TIMESTAMP_MAX - 1)
138
129enum ctattr_nat { 139enum ctattr_nat {
130 CTA_NAT_UNSPEC, 140 CTA_NAT_UNSPEC,
131 CTA_NAT_MINIP, 141 CTA_NAT_MINIP,
@@ -161,6 +171,7 @@ enum ctattr_expect {
161 CTA_EXPECT_ID, 171 CTA_EXPECT_ID,
162 CTA_EXPECT_HELP_NAME, 172 CTA_EXPECT_HELP_NAME,
163 CTA_EXPECT_ZONE, 173 CTA_EXPECT_ZONE,
174 CTA_EXPECT_FLAGS,
164 __CTA_EXPECT_MAX 175 __CTA_EXPECT_MAX
165}; 176};
166#define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1) 177#define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1)
@@ -172,4 +183,11 @@ enum ctattr_help {
172}; 183};
173#define CTA_HELP_MAX (__CTA_HELP_MAX - 1) 184#define CTA_HELP_MAX (__CTA_HELP_MAX - 1)
174 185
186enum ctattr_secctx {
187 CTA_SECCTX_UNSPEC,
188 CTA_SECCTX_NAME,
189 __CTA_SECCTX_MAX
190};
191#define CTA_SECCTX_MAX (__CTA_SECCTX_MAX - 1)
192
175#endif /* _IPCONNTRACK_NETLINK_H */ 193#endif /* _IPCONNTRACK_NETLINK_H */
diff --git a/include/linux/netfilter/nfnetlink_log.h b/include/linux/netfilter/nfnetlink_log.h
index ea9b8d380527..90c2c9575bac 100644
--- a/include/linux/netfilter/nfnetlink_log.h
+++ b/include/linux/netfilter/nfnetlink_log.h
@@ -28,8 +28,8 @@ struct nfulnl_msg_packet_hw {
28}; 28};
29 29
30struct nfulnl_msg_packet_timestamp { 30struct nfulnl_msg_packet_timestamp {
31 aligned_be64 sec; 31 __aligned_be64 sec;
32 aligned_be64 usec; 32 __aligned_be64 usec;
33}; 33};
34 34
35enum nfulnl_attr_type { 35enum nfulnl_attr_type {
diff --git a/include/linux/netfilter/nfnetlink_queue.h b/include/linux/netfilter/nfnetlink_queue.h
index 2455fe5f4e01..af94e0014ebd 100644
--- a/include/linux/netfilter/nfnetlink_queue.h
+++ b/include/linux/netfilter/nfnetlink_queue.h
@@ -25,8 +25,8 @@ struct nfqnl_msg_packet_hw {
25}; 25};
26 26
27struct nfqnl_msg_packet_timestamp { 27struct nfqnl_msg_packet_timestamp {
28 aligned_be64 sec; 28 __aligned_be64 sec;
29 aligned_be64 usec; 29 __aligned_be64 usec;
30}; 30};
31 31
32enum nfqnl_attr_type { 32enum nfqnl_attr_type {
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 24e5d01d27d0..32cddf78b13e 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -66,6 +66,11 @@ struct xt_standard_target {
66 int verdict; 66 int verdict;
67}; 67};
68 68
69struct xt_error_target {
70 struct xt_entry_target target;
71 char errorname[XT_FUNCTION_MAXNAMELEN];
72};
73
69/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision 74/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
70 * kernel supports, if >= revision. */ 75 * kernel supports, if >= revision. */
71struct xt_get_revision { 76struct xt_get_revision {
@@ -451,72 +456,60 @@ extern void xt_proto_fini(struct net *net, u_int8_t af);
451extern struct xt_table_info *xt_alloc_table_info(unsigned int size); 456extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
452extern void xt_free_table_info(struct xt_table_info *info); 457extern void xt_free_table_info(struct xt_table_info *info);
453 458
454/* 459/**
455 * Per-CPU spinlock associated with per-cpu table entries, and 460 * xt_recseq - recursive seqcount for netfilter use
456 * with a counter for the "reading" side that allows a recursive 461 *
457 * reader to avoid taking the lock and deadlocking. 462 * Packet processing changes the seqcount only if no recursion happened
458 * 463 * get_counters() can use read_seqcount_begin()/read_seqcount_retry(),
459 * "reading" is used by ip/arp/ip6 tables rule processing which runs per-cpu. 464 * because we use the normal seqcount convention :
460 * It needs to ensure that the rules are not being changed while the packet 465 * Low order bit set to 1 if a writer is active.
461 * is being processed. In some cases, the read lock will be acquired
462 * twice on the same CPU; this is okay because of the count.
463 *
464 * "writing" is used when reading counters.
465 * During replace any readers that are using the old tables have to complete
466 * before freeing the old table. This is handled by the write locking
467 * necessary for reading the counters.
468 */ 466 */
469struct xt_info_lock { 467DECLARE_PER_CPU(seqcount_t, xt_recseq);
470 spinlock_t lock;
471 unsigned char readers;
472};
473DECLARE_PER_CPU(struct xt_info_lock, xt_info_locks);
474 468
475/* 469/**
476 * Note: we need to ensure that preemption is disabled before acquiring 470 * xt_write_recseq_begin - start of a write section
477 * the per-cpu-variable, so we do it as a two step process rather than
478 * using "spin_lock_bh()".
479 *
480 * We _also_ need to disable bottom half processing before updating our
481 * nesting count, to make sure that the only kind of re-entrancy is this
482 * code being called by itself: since the count+lock is not an atomic
483 * operation, we can allow no races.
484 * 471 *
485 * _Only_ that special combination of being per-cpu and never getting 472 * Begin packet processing : all readers must wait the end
486 * re-entered asynchronously means that the count is safe. 473 * 1) Must be called with preemption disabled
474 * 2) softirqs must be disabled too (or we should use irqsafe_cpu_add())
475 * Returns :
476 * 1 if no recursion on this cpu
477 * 0 if recursion detected
487 */ 478 */
488static inline void xt_info_rdlock_bh(void) 479static inline unsigned int xt_write_recseq_begin(void)
489{ 480{
490 struct xt_info_lock *lock; 481 unsigned int addend;
491 482
492 local_bh_disable(); 483 /*
493 lock = &__get_cpu_var(xt_info_locks); 484 * Low order bit of sequence is set if we already
494 if (likely(!lock->readers++)) 485 * called xt_write_recseq_begin().
495 spin_lock(&lock->lock); 486 */
496} 487 addend = (__this_cpu_read(xt_recseq.sequence) + 1) & 1;
497 488
498static inline void xt_info_rdunlock_bh(void) 489 /*
499{ 490 * This is kind of a write_seqcount_begin(), but addend is 0 or 1
500 struct xt_info_lock *lock = &__get_cpu_var(xt_info_locks); 491 * We dont check addend value to avoid a test and conditional jump,
492 * since addend is most likely 1
493 */
494 __this_cpu_add(xt_recseq.sequence, addend);
495 smp_wmb();
501 496
502 if (likely(!--lock->readers)) 497 return addend;
503 spin_unlock(&lock->lock);
504 local_bh_enable();
505} 498}
506 499
507/* 500/**
508 * The "writer" side needs to get exclusive access to the lock, 501 * xt_write_recseq_end - end of a write section
509 * regardless of readers. This must be called with bottom half 502 * @addend: return value from previous xt_write_recseq_begin()
510 * processing (and thus also preemption) disabled. 503 *
504 * End packet processing : all readers can proceed
505 * 1) Must be called with preemption disabled
506 * 2) softirqs must be disabled too (or we should use irqsafe_cpu_add())
511 */ 507 */
512static inline void xt_info_wrlock(unsigned int cpu) 508static inline void xt_write_recseq_end(unsigned int addend)
513{
514 spin_lock(&per_cpu(xt_info_locks, cpu).lock);
515}
516
517static inline void xt_info_wrunlock(unsigned int cpu)
518{ 509{
519 spin_unlock(&per_cpu(xt_info_locks, cpu).lock); 510 /* this is kind of a write_seqcount_end(), but addend is 0 or 1 */
511 smp_wmb();
512 __this_cpu_add(xt_recseq.sequence, addend);
520} 513}
521 514
522/* 515/*
@@ -606,8 +599,9 @@ struct _compat_xt_align {
606extern void xt_compat_lock(u_int8_t af); 599extern void xt_compat_lock(u_int8_t af);
607extern void xt_compat_unlock(u_int8_t af); 600extern void xt_compat_unlock(u_int8_t af);
608 601
609extern int xt_compat_add_offset(u_int8_t af, unsigned int offset, short delta); 602extern int xt_compat_add_offset(u_int8_t af, unsigned int offset, int delta);
610extern void xt_compat_flush_offsets(u_int8_t af); 603extern void xt_compat_flush_offsets(u_int8_t af);
604extern void xt_compat_init_offsets(u_int8_t af, unsigned int number);
611extern int xt_compat_calc_jump(u_int8_t af, unsigned int offset); 605extern int xt_compat_calc_jump(u_int8_t af, unsigned int offset);
612 606
613extern int xt_compat_match_offset(const struct xt_match *match); 607extern int xt_compat_match_offset(const struct xt_match *match);
diff --git a/include/linux/netfilter/xt_AUDIT.h b/include/linux/netfilter/xt_AUDIT.h
new file mode 100644
index 000000000000..38751d2ea52b
--- /dev/null
+++ b/include/linux/netfilter/xt_AUDIT.h
@@ -0,0 +1,30 @@
1/*
2 * Header file for iptables xt_AUDIT target
3 *
4 * (C) 2010-2011 Thomas Graf <tgraf@redhat.com>
5 * (C) 2010-2011 Red Hat, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _XT_AUDIT_TARGET_H
13#define _XT_AUDIT_TARGET_H
14
15#include <linux/types.h>
16
17enum {
18 XT_AUDIT_TYPE_ACCEPT = 0,
19 XT_AUDIT_TYPE_DROP,
20 XT_AUDIT_TYPE_REJECT,
21 __XT_AUDIT_TYPE_MAX,
22};
23
24#define XT_AUDIT_TYPE_MAX (__XT_AUDIT_TYPE_MAX - 1)
25
26struct xt_audit_info {
27 __u8 type; /* XT_AUDIT_TYPE_* */
28};
29
30#endif /* _XT_AUDIT_TARGET_H */
diff --git a/include/linux/netfilter/xt_CT.h b/include/linux/netfilter/xt_CT.h
index 1b564106891d..b56e76811c04 100644
--- a/include/linux/netfilter/xt_CT.h
+++ b/include/linux/netfilter/xt_CT.h
@@ -1,14 +1,16 @@
1#ifndef _XT_CT_H 1#ifndef _XT_CT_H
2#define _XT_CT_H 2#define _XT_CT_H
3 3
4#include <linux/types.h>
5
4#define XT_CT_NOTRACK 0x1 6#define XT_CT_NOTRACK 0x1
5 7
6struct xt_ct_target_info { 8struct xt_ct_target_info {
7 u_int16_t flags; 9 __u16 flags;
8 u_int16_t zone; 10 __u16 zone;
9 u_int32_t ct_events; 11 __u32 ct_events;
10 u_int32_t exp_events; 12 __u32 exp_events;
11 char helper[16]; 13 char helper[16];
12 14
13 /* Used internally by the kernel */ 15 /* Used internally by the kernel */
14 struct nf_conn *ct __attribute__((aligned(8))); 16 struct nf_conn *ct __attribute__((aligned(8)));
diff --git a/include/linux/netfilter/xt_NFQUEUE.h b/include/linux/netfilter/xt_NFQUEUE.h
index 2584f4a777de..9eafdbbb401c 100644
--- a/include/linux/netfilter/xt_NFQUEUE.h
+++ b/include/linux/netfilter/xt_NFQUEUE.h
@@ -20,4 +20,10 @@ struct xt_NFQ_info_v1 {
20 __u16 queues_total; 20 __u16 queues_total;
21}; 21};
22 22
23struct xt_NFQ_info_v2 {
24 __u16 queuenum;
25 __u16 queues_total;
26 __u16 bypass;
27};
28
23#endif /* _XT_NFQ_TARGET_H */ 29#endif /* _XT_NFQ_TARGET_H */
diff --git a/include/linux/netfilter/xt_SECMARK.h b/include/linux/netfilter/xt_SECMARK.h
index 6fcd3448b186..989092bd6274 100644
--- a/include/linux/netfilter/xt_SECMARK.h
+++ b/include/linux/netfilter/xt_SECMARK.h
@@ -11,18 +11,12 @@
11 * packets are being marked for. 11 * packets are being marked for.
12 */ 12 */
13#define SECMARK_MODE_SEL 0x01 /* SELinux */ 13#define SECMARK_MODE_SEL 0x01 /* SELinux */
14#define SECMARK_SELCTX_MAX 256 14#define SECMARK_SECCTX_MAX 256
15
16struct xt_secmark_target_selinux_info {
17 __u32 selsid;
18 char selctx[SECMARK_SELCTX_MAX];
19};
20 15
21struct xt_secmark_target_info { 16struct xt_secmark_target_info {
22 __u8 mode; 17 __u8 mode;
23 union { 18 __u32 secid;
24 struct xt_secmark_target_selinux_info sel; 19 char secctx[SECMARK_SECCTX_MAX];
25 } u;
26}; 20};
27 21
28#endif /*_XT_SECMARK_H_target */ 22#endif /*_XT_SECMARK_H_target */
diff --git a/include/linux/netfilter/xt_TCPOPTSTRIP.h b/include/linux/netfilter/xt_TCPOPTSTRIP.h
index 2db543214ff5..7157318499c2 100644
--- a/include/linux/netfilter/xt_TCPOPTSTRIP.h
+++ b/include/linux/netfilter/xt_TCPOPTSTRIP.h
@@ -1,13 +1,15 @@
1#ifndef _XT_TCPOPTSTRIP_H 1#ifndef _XT_TCPOPTSTRIP_H
2#define _XT_TCPOPTSTRIP_H 2#define _XT_TCPOPTSTRIP_H
3 3
4#include <linux/types.h>
5
4#define tcpoptstrip_set_bit(bmap, idx) \ 6#define tcpoptstrip_set_bit(bmap, idx) \
5 (bmap[(idx) >> 5] |= 1U << (idx & 31)) 7 (bmap[(idx) >> 5] |= 1U << (idx & 31))
6#define tcpoptstrip_test_bit(bmap, idx) \ 8#define tcpoptstrip_test_bit(bmap, idx) \
7 (((1U << (idx & 31)) & bmap[(idx) >> 5]) != 0) 9 (((1U << (idx & 31)) & bmap[(idx) >> 5]) != 0)
8 10
9struct xt_tcpoptstrip_target_info { 11struct xt_tcpoptstrip_target_info {
10 u_int32_t strip_bmap[8]; 12 __u32 strip_bmap[8];
11}; 13};
12 14
13#endif /* _XT_TCPOPTSTRIP_H */ 15#endif /* _XT_TCPOPTSTRIP_H */
diff --git a/include/linux/netfilter/xt_TPROXY.h b/include/linux/netfilter/xt_TPROXY.h
index 152e8f97132b..902043c2073f 100644
--- a/include/linux/netfilter/xt_TPROXY.h
+++ b/include/linux/netfilter/xt_TPROXY.h
@@ -1,14 +1,23 @@
1#ifndef _XT_TPROXY_H_target 1#ifndef _XT_TPROXY_H
2#define _XT_TPROXY_H_target 2#define _XT_TPROXY_H
3
4#include <linux/types.h>
3 5
4/* TPROXY target is capable of marking the packet to perform 6/* TPROXY target is capable of marking the packet to perform
5 * redirection. We can get rid of that whenever we get support for 7 * redirection. We can get rid of that whenever we get support for
6 * mutliple targets in the same rule. */ 8 * mutliple targets in the same rule. */
7struct xt_tproxy_target_info { 9struct xt_tproxy_target_info {
8 u_int32_t mark_mask; 10 __u32 mark_mask;
9 u_int32_t mark_value; 11 __u32 mark_value;
10 __be32 laddr; 12 __be32 laddr;
11 __be16 lport; 13 __be16 lport;
12}; 14};
13 15
14#endif /* _XT_TPROXY_H_target */ 16struct xt_tproxy_target_info_v1 {
17 __u32 mark_mask;
18 __u32 mark_value;
19 union nf_inet_addr laddr;
20 __be16 lport;
21};
22
23#endif /* _XT_TPROXY_H */
diff --git a/include/linux/netfilter/xt_addrtype.h b/include/linux/netfilter/xt_addrtype.h
new file mode 100644
index 000000000000..b156baa9d55e
--- /dev/null
+++ b/include/linux/netfilter/xt_addrtype.h
@@ -0,0 +1,44 @@
1#ifndef _XT_ADDRTYPE_H
2#define _XT_ADDRTYPE_H
3
4#include <linux/types.h>
5
6enum {
7 XT_ADDRTYPE_INVERT_SOURCE = 0x0001,
8 XT_ADDRTYPE_INVERT_DEST = 0x0002,
9 XT_ADDRTYPE_LIMIT_IFACE_IN = 0x0004,
10 XT_ADDRTYPE_LIMIT_IFACE_OUT = 0x0008,
11};
12
13
14/* rtn_type enum values from rtnetlink.h, but shifted */
15enum {
16 XT_ADDRTYPE_UNSPEC = 1 << 0,
17 XT_ADDRTYPE_UNICAST = 1 << 1, /* 1 << RTN_UNICAST */
18 XT_ADDRTYPE_LOCAL = 1 << 2, /* 1 << RTN_LOCAL, etc */
19 XT_ADDRTYPE_BROADCAST = 1 << 3,
20 XT_ADDRTYPE_ANYCAST = 1 << 4,
21 XT_ADDRTYPE_MULTICAST = 1 << 5,
22 XT_ADDRTYPE_BLACKHOLE = 1 << 6,
23 XT_ADDRTYPE_UNREACHABLE = 1 << 7,
24 XT_ADDRTYPE_PROHIBIT = 1 << 8,
25 XT_ADDRTYPE_THROW = 1 << 9,
26 XT_ADDRTYPE_NAT = 1 << 10,
27 XT_ADDRTYPE_XRESOLVE = 1 << 11,
28};
29
30struct xt_addrtype_info_v1 {
31 __u16 source; /* source-type mask */
32 __u16 dest; /* dest-type mask */
33 __u32 flags;
34};
35
36/* revision 0 */
37struct xt_addrtype_info {
38 __u16 source; /* source-type mask */
39 __u16 dest; /* dest-type mask */
40 __u32 invert_source;
41 __u32 invert_dest;
42};
43
44#endif
diff --git a/include/linux/netfilter/xt_cluster.h b/include/linux/netfilter/xt_cluster.h
index 886682656f09..9b883c8fbf54 100644
--- a/include/linux/netfilter/xt_cluster.h
+++ b/include/linux/netfilter/xt_cluster.h
@@ -1,15 +1,17 @@
1#ifndef _XT_CLUSTER_MATCH_H 1#ifndef _XT_CLUSTER_MATCH_H
2#define _XT_CLUSTER_MATCH_H 2#define _XT_CLUSTER_MATCH_H
3 3
4#include <linux/types.h>
5
4enum xt_cluster_flags { 6enum xt_cluster_flags {
5 XT_CLUSTER_F_INV = (1 << 0) 7 XT_CLUSTER_F_INV = (1 << 0)
6}; 8};
7 9
8struct xt_cluster_match_info { 10struct xt_cluster_match_info {
9 u_int32_t total_nodes; 11 __u32 total_nodes;
10 u_int32_t node_mask; 12 __u32 node_mask;
11 u_int32_t hash_seed; 13 __u32 hash_seed;
12 u_int32_t flags; 14 __u32 flags;
13}; 15};
14 16
15#define XT_CLUSTER_NODES_MAX 32 17#define XT_CLUSTER_NODES_MAX 32
diff --git a/include/linux/netfilter/xt_comment.h b/include/linux/netfilter/xt_comment.h
index eacfedc6b5d0..0ea5e79f5bd7 100644
--- a/include/linux/netfilter/xt_comment.h
+++ b/include/linux/netfilter/xt_comment.h
@@ -4,7 +4,7 @@
4#define XT_MAX_COMMENT_LEN 256 4#define XT_MAX_COMMENT_LEN 256
5 5
6struct xt_comment_info { 6struct xt_comment_info {
7 unsigned char comment[XT_MAX_COMMENT_LEN]; 7 char comment[XT_MAX_COMMENT_LEN];
8}; 8};
9 9
10#endif /* XT_COMMENT_H */ 10#endif /* XT_COMMENT_H */
diff --git a/include/linux/netfilter/xt_connbytes.h b/include/linux/netfilter/xt_connbytes.h
index 92fcbb0d193e..f1d6c15bd9e3 100644
--- a/include/linux/netfilter/xt_connbytes.h
+++ b/include/linux/netfilter/xt_connbytes.h
@@ -17,8 +17,8 @@ enum xt_connbytes_direction {
17 17
18struct xt_connbytes_info { 18struct xt_connbytes_info {
19 struct { 19 struct {
20 aligned_u64 from; /* count to be matched */ 20 __aligned_u64 from; /* count to be matched */
21 aligned_u64 to; /* count to be matched */ 21 __aligned_u64 to; /* count to be matched */
22 } count; 22 } count;
23 __u8 what; /* ipt_connbytes_what */ 23 __u8 what; /* ipt_connbytes_what */
24 __u8 direction; /* ipt_connbytes_direction */ 24 __u8 direction; /* ipt_connbytes_direction */
diff --git a/include/linux/netfilter/xt_connlimit.h b/include/linux/netfilter/xt_connlimit.h
index 7e3284bcbd2b..0ca66e97acbc 100644
--- a/include/linux/netfilter/xt_connlimit.h
+++ b/include/linux/netfilter/xt_connlimit.h
@@ -1,8 +1,15 @@
1#ifndef _XT_CONNLIMIT_H 1#ifndef _XT_CONNLIMIT_H
2#define _XT_CONNLIMIT_H 2#define _XT_CONNLIMIT_H
3 3
4#include <linux/types.h>
5
4struct xt_connlimit_data; 6struct xt_connlimit_data;
5 7
8enum {
9 XT_CONNLIMIT_INVERT = 1 << 0,
10 XT_CONNLIMIT_DADDR = 1 << 1,
11};
12
6struct xt_connlimit_info { 13struct xt_connlimit_info {
7 union { 14 union {
8 union nf_inet_addr mask; 15 union nf_inet_addr mask;
@@ -13,7 +20,14 @@ struct xt_connlimit_info {
13 }; 20 };
14#endif 21#endif
15 }; 22 };
16 unsigned int limit, inverse; 23 unsigned int limit;
24 union {
25 /* revision 0 */
26 unsigned int inverse;
27
28 /* revision 1 */
29 __u32 flags;
30 };
17 31
18 /* Used internally by the kernel */ 32 /* Used internally by the kernel */
19 struct xt_connlimit_data *data __attribute__((aligned(8))); 33 struct xt_connlimit_data *data __attribute__((aligned(8)));
diff --git a/include/linux/netfilter/xt_conntrack.h b/include/linux/netfilter/xt_conntrack.h
index 54f47a2f6152..74b904d8f99c 100644
--- a/include/linux/netfilter/xt_conntrack.h
+++ b/include/linux/netfilter/xt_conntrack.h
@@ -58,4 +58,19 @@ struct xt_conntrack_mtinfo2 {
58 __u16 state_mask, status_mask; 58 __u16 state_mask, status_mask;
59}; 59};
60 60
61struct xt_conntrack_mtinfo3 {
62 union nf_inet_addr origsrc_addr, origsrc_mask;
63 union nf_inet_addr origdst_addr, origdst_mask;
64 union nf_inet_addr replsrc_addr, replsrc_mask;
65 union nf_inet_addr repldst_addr, repldst_mask;
66 __u32 expires_min, expires_max;
67 __u16 l4proto;
68 __u16 origsrc_port, origdst_port;
69 __u16 replsrc_port, repldst_port;
70 __u16 match_flags, invert_flags;
71 __u16 state_mask, status_mask;
72 __u16 origsrc_port_high, origdst_port_high;
73 __u16 replsrc_port_high, repldst_port_high;
74};
75
61#endif /*_XT_CONNTRACK_H*/ 76#endif /*_XT_CONNTRACK_H*/
diff --git a/include/linux/netfilter/xt_devgroup.h b/include/linux/netfilter/xt_devgroup.h
new file mode 100644
index 000000000000..1babde0ec900
--- /dev/null
+++ b/include/linux/netfilter/xt_devgroup.h
@@ -0,0 +1,21 @@
1#ifndef _XT_DEVGROUP_H
2#define _XT_DEVGROUP_H
3
4#include <linux/types.h>
5
6enum xt_devgroup_flags {
7 XT_DEVGROUP_MATCH_SRC = 0x1,
8 XT_DEVGROUP_INVERT_SRC = 0x2,
9 XT_DEVGROUP_MATCH_DST = 0x4,
10 XT_DEVGROUP_INVERT_DST = 0x8,
11};
12
13struct xt_devgroup_info {
14 __u32 flags;
15 __u32 src_group;
16 __u32 src_mask;
17 __u32 dst_group;
18 __u32 dst_mask;
19};
20
21#endif /* _XT_DEVGROUP_H */
diff --git a/include/linux/netfilter/xt_quota.h b/include/linux/netfilter/xt_quota.h
index b0d28c659ab7..9314723f39ca 100644
--- a/include/linux/netfilter/xt_quota.h
+++ b/include/linux/netfilter/xt_quota.h
@@ -1,6 +1,8 @@
1#ifndef _XT_QUOTA_H 1#ifndef _XT_QUOTA_H
2#define _XT_QUOTA_H 2#define _XT_QUOTA_H
3 3
4#include <linux/types.h>
5
4enum xt_quota_flags { 6enum xt_quota_flags {
5 XT_QUOTA_INVERT = 0x1, 7 XT_QUOTA_INVERT = 0x1,
6}; 8};
@@ -9,9 +11,9 @@ enum xt_quota_flags {
9struct xt_quota_priv; 11struct xt_quota_priv;
10 12
11struct xt_quota_info { 13struct xt_quota_info {
12 u_int32_t flags; 14 __u32 flags;
13 u_int32_t pad; 15 __u32 pad;
14 aligned_u64 quota; 16 __aligned_u64 quota;
15 17
16 /* Used internally by the kernel */ 18 /* Used internally by the kernel */
17 struct xt_quota_priv *master; 19 struct xt_quota_priv *master;
diff --git a/include/linux/netfilter/xt_set.h b/include/linux/netfilter/xt_set.h
new file mode 100644
index 000000000000..081f1ded2842
--- /dev/null
+++ b/include/linux/netfilter/xt_set.h
@@ -0,0 +1,56 @@
1#ifndef _XT_SET_H
2#define _XT_SET_H
3
4#include <linux/types.h>
5#include <linux/netfilter/ipset/ip_set.h>
6
7/* Revision 0 interface: backward compatible with netfilter/iptables */
8
9/*
10 * Option flags for kernel operations (xt_set_info_v0)
11 */
12#define IPSET_SRC 0x01 /* Source match/add */
13#define IPSET_DST 0x02 /* Destination match/add */
14#define IPSET_MATCH_INV 0x04 /* Inverse matching */
15
16struct xt_set_info_v0 {
17 ip_set_id_t index;
18 union {
19 __u32 flags[IPSET_DIM_MAX + 1];
20 struct {
21 __u32 __flags[IPSET_DIM_MAX];
22 __u8 dim;
23 __u8 flags;
24 } compat;
25 } u;
26};
27
28/* match and target infos */
29struct xt_set_info_match_v0 {
30 struct xt_set_info_v0 match_set;
31};
32
33struct xt_set_info_target_v0 {
34 struct xt_set_info_v0 add_set;
35 struct xt_set_info_v0 del_set;
36};
37
38/* Revision 1: current interface to netfilter/iptables */
39
40struct xt_set_info {
41 ip_set_id_t index;
42 __u8 dim;
43 __u8 flags;
44};
45
46/* match and target infos */
47struct xt_set_info_match {
48 struct xt_set_info match_set;
49};
50
51struct xt_set_info_target {
52 struct xt_set_info add_set;
53 struct xt_set_info del_set;
54};
55
56#endif /*_XT_SET_H*/
diff --git a/include/linux/netfilter/xt_socket.h b/include/linux/netfilter/xt_socket.h
index 6f475b8ff34b..26d7217bd4f1 100644
--- a/include/linux/netfilter/xt_socket.h
+++ b/include/linux/netfilter/xt_socket.h
@@ -1,6 +1,8 @@
1#ifndef _XT_SOCKET_H 1#ifndef _XT_SOCKET_H
2#define _XT_SOCKET_H 2#define _XT_SOCKET_H
3 3
4#include <linux/types.h>
5
4enum { 6enum {
5 XT_SOCKET_TRANSPARENT = 1 << 0, 7 XT_SOCKET_TRANSPARENT = 1 << 0,
6}; 8};
diff --git a/include/linux/netfilter/xt_time.h b/include/linux/netfilter/xt_time.h
index 14b6df412c9f..7c37fac576c4 100644
--- a/include/linux/netfilter/xt_time.h
+++ b/include/linux/netfilter/xt_time.h
@@ -1,14 +1,16 @@
1#ifndef _XT_TIME_H 1#ifndef _XT_TIME_H
2#define _XT_TIME_H 1 2#define _XT_TIME_H 1
3 3
4#include <linux/types.h>
5
4struct xt_time_info { 6struct xt_time_info {
5 u_int32_t date_start; 7 __u32 date_start;
6 u_int32_t date_stop; 8 __u32 date_stop;
7 u_int32_t daytime_start; 9 __u32 daytime_start;
8 u_int32_t daytime_stop; 10 __u32 daytime_stop;
9 u_int32_t monthdays_match; 11 __u32 monthdays_match;
10 u_int8_t weekdays_match; 12 __u8 weekdays_match;
11 u_int8_t flags; 13 __u8 flags;
12}; 14};
13 15
14enum { 16enum {
diff --git a/include/linux/netfilter/xt_u32.h b/include/linux/netfilter/xt_u32.h
index 9947f56cdbdd..04d1bfea03c2 100644
--- a/include/linux/netfilter/xt_u32.h
+++ b/include/linux/netfilter/xt_u32.h
@@ -1,6 +1,8 @@
1#ifndef _XT_U32_H 1#ifndef _XT_U32_H
2#define _XT_U32_H 1 2#define _XT_U32_H 1
3 3
4#include <linux/types.h>
5
4enum xt_u32_ops { 6enum xt_u32_ops {
5 XT_U32_AND, 7 XT_U32_AND,
6 XT_U32_LEFTSH, 8 XT_U32_LEFTSH,
@@ -9,13 +11,13 @@ enum xt_u32_ops {
9}; 11};
10 12
11struct xt_u32_location_element { 13struct xt_u32_location_element {
12 u_int32_t number; 14 __u32 number;
13 u_int8_t nextop; 15 __u8 nextop;
14}; 16};
15 17
16struct xt_u32_value_element { 18struct xt_u32_value_element {
17 u_int32_t min; 19 __u32 min;
18 u_int32_t max; 20 __u32 max;
19}; 21};
20 22
21/* 23/*
@@ -27,14 +29,14 @@ struct xt_u32_value_element {
27struct xt_u32_test { 29struct xt_u32_test {
28 struct xt_u32_location_element location[XT_U32_MAXSIZE+1]; 30 struct xt_u32_location_element location[XT_U32_MAXSIZE+1];
29 struct xt_u32_value_element value[XT_U32_MAXSIZE+1]; 31 struct xt_u32_value_element value[XT_U32_MAXSIZE+1];
30 u_int8_t nnums; 32 __u8 nnums;
31 u_int8_t nvalues; 33 __u8 nvalues;
32}; 34};
33 35
34struct xt_u32 { 36struct xt_u32 {
35 struct xt_u32_test tests[XT_U32_MAXSIZE+1]; 37 struct xt_u32_test tests[XT_U32_MAXSIZE+1];
36 u_int8_t ntests; 38 __u8 ntests;
37 u_int8_t invert; 39 __u8 invert;
38}; 40};
39 41
40#endif /* _XT_U32_H */ 42#endif /* _XT_U32_H */
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index e9948c0560f6..adbf4bff87ed 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -21,8 +21,21 @@
21 21
22#include <linux/netfilter/x_tables.h> 22#include <linux/netfilter/x_tables.h>
23 23
24#ifndef __KERNEL__
24#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN 25#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
25#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN 26#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
27#define arpt_entry_target xt_entry_target
28#define arpt_standard_target xt_standard_target
29#define arpt_error_target xt_error_target
30#define ARPT_CONTINUE XT_CONTINUE
31#define ARPT_RETURN XT_RETURN
32#define arpt_counters_info xt_counters_info
33#define arpt_counters xt_counters
34#define ARPT_STANDARD_TARGET XT_STANDARD_TARGET
35#define ARPT_ERROR_TARGET XT_ERROR_TARGET
36#define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
37 XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args)
38#endif
26 39
27#define ARPT_DEV_ADDR_LEN_MAX 16 40#define ARPT_DEV_ADDR_LEN_MAX 16
28 41
@@ -63,9 +76,6 @@ struct arpt_arp {
63 u_int16_t invflags; 76 u_int16_t invflags;
64}; 77};
65 78
66#define arpt_entry_target xt_entry_target
67#define arpt_standard_target xt_standard_target
68
69/* Values for "flag" field in struct arpt_ip (general arp structure). 79/* Values for "flag" field in struct arpt_ip (general arp structure).
70 * No flags defined yet. 80 * No flags defined yet.
71 */ 81 */
@@ -125,16 +135,10 @@ struct arpt_entry
125#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3) 135#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)
126#define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET) 136#define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET)
127 137
128/* CONTINUE verdict for targets */
129#define ARPT_CONTINUE XT_CONTINUE
130
131/* For standard target */
132#define ARPT_RETURN XT_RETURN
133
134/* The argument to ARPT_SO_GET_INFO */ 138/* The argument to ARPT_SO_GET_INFO */
135struct arpt_getinfo { 139struct arpt_getinfo {
136 /* Which table: caller fills this in. */ 140 /* Which table: caller fills this in. */
137 char name[ARPT_TABLE_MAXNAMELEN]; 141 char name[XT_TABLE_MAXNAMELEN];
138 142
139 /* Kernel fills these in. */ 143 /* Kernel fills these in. */
140 /* Which hook entry points are valid: bitmask */ 144 /* Which hook entry points are valid: bitmask */
@@ -156,7 +160,7 @@ struct arpt_getinfo {
156/* The argument to ARPT_SO_SET_REPLACE. */ 160/* The argument to ARPT_SO_SET_REPLACE. */
157struct arpt_replace { 161struct arpt_replace {
158 /* Which table. */ 162 /* Which table. */
159 char name[ARPT_TABLE_MAXNAMELEN]; 163 char name[XT_TABLE_MAXNAMELEN];
160 164
161 /* Which hook entry points are valid: bitmask. You can't 165 /* Which hook entry points are valid: bitmask. You can't
162 change this. */ 166 change this. */
@@ -184,14 +188,10 @@ struct arpt_replace {
184 struct arpt_entry entries[0]; 188 struct arpt_entry entries[0];
185}; 189};
186 190
187/* The argument to ARPT_SO_ADD_COUNTERS. */
188#define arpt_counters_info xt_counters_info
189#define arpt_counters xt_counters
190
191/* The argument to ARPT_SO_GET_ENTRIES. */ 191/* The argument to ARPT_SO_GET_ENTRIES. */
192struct arpt_get_entries { 192struct arpt_get_entries {
193 /* Which table: user fills this in. */ 193 /* Which table: user fills this in. */
194 char name[ARPT_TABLE_MAXNAMELEN]; 194 char name[XT_TABLE_MAXNAMELEN];
195 195
196 /* User fills this in: total entry size. */ 196 /* User fills this in: total entry size. */
197 unsigned int size; 197 unsigned int size;
@@ -200,23 +200,12 @@ struct arpt_get_entries {
200 struct arpt_entry entrytable[0]; 200 struct arpt_entry entrytable[0];
201}; 201};
202 202
203/* Standard return verdict, or do jump. */
204#define ARPT_STANDARD_TARGET XT_STANDARD_TARGET
205/* Error verdict. */
206#define ARPT_ERROR_TARGET XT_ERROR_TARGET
207
208/* Helper functions */ 203/* Helper functions */
209static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e) 204static __inline__ struct xt_entry_target *arpt_get_target(struct arpt_entry *e)
210{ 205{
211 return (void *)e + e->target_offset; 206 return (void *)e + e->target_offset;
212} 207}
213 208
214#ifndef __KERNEL__
215/* fn returns 0 to continue iteration */
216#define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
217 XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args)
218#endif
219
220/* 209/*
221 * Main firewall chains definitions and global var's definitions. 210 * Main firewall chains definitions and global var's definitions.
222 */ 211 */
@@ -225,17 +214,12 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e
225/* Standard entry. */ 214/* Standard entry. */
226struct arpt_standard { 215struct arpt_standard {
227 struct arpt_entry entry; 216 struct arpt_entry entry;
228 struct arpt_standard_target target; 217 struct xt_standard_target target;
229};
230
231struct arpt_error_target {
232 struct arpt_entry_target target;
233 char errorname[ARPT_FUNCTION_MAXNAMELEN];
234}; 218};
235 219
236struct arpt_error { 220struct arpt_error {
237 struct arpt_entry entry; 221 struct arpt_entry entry;
238 struct arpt_error_target target; 222 struct xt_error_target target;
239}; 223};
240 224
241#define ARPT_ENTRY_INIT(__size) \ 225#define ARPT_ENTRY_INIT(__size) \
@@ -247,16 +231,16 @@ struct arpt_error {
247#define ARPT_STANDARD_INIT(__verdict) \ 231#define ARPT_STANDARD_INIT(__verdict) \
248{ \ 232{ \
249 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \ 233 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \
250 .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \ 234 .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \
251 sizeof(struct arpt_standard_target)), \ 235 sizeof(struct xt_standard_target)), \
252 .target.verdict = -(__verdict) - 1, \ 236 .target.verdict = -(__verdict) - 1, \
253} 237}
254 238
255#define ARPT_ERROR_INIT \ 239#define ARPT_ERROR_INIT \
256{ \ 240{ \
257 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \ 241 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \
258 .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \ 242 .target = XT_TARGET_INIT(XT_ERROR_TARGET, \
259 sizeof(struct arpt_error_target)), \ 243 sizeof(struct xt_error_target)), \
260 .target.errorname = "ERROR", \ 244 .target.errorname = "ERROR", \
261} 245}
262 246
@@ -271,8 +255,6 @@ extern unsigned int arpt_do_table(struct sk_buff *skb,
271 const struct net_device *out, 255 const struct net_device *out,
272 struct xt_table *table); 256 struct xt_table *table);
273 257
274#define ARPT_ALIGN(s) XT_ALIGN(s)
275
276#ifdef CONFIG_COMPAT 258#ifdef CONFIG_COMPAT
277#include <net/compat.h> 259#include <net/compat.h>
278 260
@@ -285,14 +267,12 @@ struct compat_arpt_entry {
285 unsigned char elems[0]; 267 unsigned char elems[0];
286}; 268};
287 269
288static inline struct arpt_entry_target * 270static inline struct xt_entry_target *
289compat_arpt_get_target(struct compat_arpt_entry *e) 271compat_arpt_get_target(struct compat_arpt_entry *e)
290{ 272{
291 return (void *)e + e->target_offset; 273 return (void *)e + e->target_offset;
292} 274}
293 275
294#define COMPAT_ARPT_ALIGN(s) COMPAT_XT_ALIGN(s)
295
296#endif /* CONFIG_COMPAT */ 276#endif /* CONFIG_COMPAT */
297#endif /*__KERNEL__*/ 277#endif /*__KERNEL__*/
298#endif /* _ARPTABLES_H */ 278#endif /* _ARPTABLES_H */
diff --git a/include/linux/netfilter_bridge/Kbuild b/include/linux/netfilter_bridge/Kbuild
index d4d78672873e..e48f1a3f5a4a 100644
--- a/include/linux/netfilter_bridge/Kbuild
+++ b/include/linux/netfilter_bridge/Kbuild
@@ -3,11 +3,13 @@ header-y += ebt_among.h
3header-y += ebt_arp.h 3header-y += ebt_arp.h
4header-y += ebt_arpreply.h 4header-y += ebt_arpreply.h
5header-y += ebt_ip.h 5header-y += ebt_ip.h
6header-y += ebt_ip6.h
6header-y += ebt_limit.h 7header-y += ebt_limit.h
7header-y += ebt_log.h 8header-y += ebt_log.h
8header-y += ebt_mark_m.h 9header-y += ebt_mark_m.h
9header-y += ebt_mark_t.h 10header-y += ebt_mark_t.h
10header-y += ebt_nat.h 11header-y += ebt_nat.h
12header-y += ebt_nflog.h
11header-y += ebt_pkttype.h 13header-y += ebt_pkttype.h
12header-y += ebt_redirect.h 14header-y += ebt_redirect.h
13header-y += ebt_stp.h 15header-y += ebt_stp.h
diff --git a/include/linux/netfilter_bridge/ebt_802_3.h b/include/linux/netfilter_bridge/ebt_802_3.h
index c73ef0b18bdc..be5be1577a56 100644
--- a/include/linux/netfilter_bridge/ebt_802_3.h
+++ b/include/linux/netfilter_bridge/ebt_802_3.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_802_3_H 1#ifndef __LINUX_BRIDGE_EBT_802_3_H
2#define __LINUX_BRIDGE_EBT_802_3_H 2#define __LINUX_BRIDGE_EBT_802_3_H
3 3
4#include <linux/types.h>
5
4#define EBT_802_3_SAP 0x01 6#define EBT_802_3_SAP 0x01
5#define EBT_802_3_TYPE 0x02 7#define EBT_802_3_TYPE 0x02
6 8
@@ -24,24 +26,24 @@
24 26
25/* ui has one byte ctrl, ni has two */ 27/* ui has one byte ctrl, ni has two */
26struct hdr_ui { 28struct hdr_ui {
27 uint8_t dsap; 29 __u8 dsap;
28 uint8_t ssap; 30 __u8 ssap;
29 uint8_t ctrl; 31 __u8 ctrl;
30 uint8_t orig[3]; 32 __u8 orig[3];
31 __be16 type; 33 __be16 type;
32}; 34};
33 35
34struct hdr_ni { 36struct hdr_ni {
35 uint8_t dsap; 37 __u8 dsap;
36 uint8_t ssap; 38 __u8 ssap;
37 __be16 ctrl; 39 __be16 ctrl;
38 uint8_t orig[3]; 40 __u8 orig[3];
39 __be16 type; 41 __be16 type;
40}; 42};
41 43
42struct ebt_802_3_hdr { 44struct ebt_802_3_hdr {
43 uint8_t daddr[6]; 45 __u8 daddr[6];
44 uint8_t saddr[6]; 46 __u8 saddr[6];
45 __be16 len; 47 __be16 len;
46 union { 48 union {
47 struct hdr_ui ui; 49 struct hdr_ui ui;
@@ -59,10 +61,10 @@ static inline struct ebt_802_3_hdr *ebt_802_3_hdr(const struct sk_buff *skb)
59#endif 61#endif
60 62
61struct ebt_802_3_info { 63struct ebt_802_3_info {
62 uint8_t sap; 64 __u8 sap;
63 __be16 type; 65 __be16 type;
64 uint8_t bitmask; 66 __u8 bitmask;
65 uint8_t invflags; 67 __u8 invflags;
66}; 68};
67 69
68#endif 70#endif
diff --git a/include/linux/netfilter_bridge/ebt_among.h b/include/linux/netfilter_bridge/ebt_among.h
index 0009558609a7..bd4e3ad0b706 100644
--- a/include/linux/netfilter_bridge/ebt_among.h
+++ b/include/linux/netfilter_bridge/ebt_among.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_AMONG_H 1#ifndef __LINUX_BRIDGE_EBT_AMONG_H
2#define __LINUX_BRIDGE_EBT_AMONG_H 2#define __LINUX_BRIDGE_EBT_AMONG_H
3 3
4#include <linux/types.h>
5
4#define EBT_AMONG_DST 0x01 6#define EBT_AMONG_DST 0x01
5#define EBT_AMONG_SRC 0x02 7#define EBT_AMONG_SRC 0x02
6 8
@@ -30,7 +32,7 @@
30 */ 32 */
31 33
32struct ebt_mac_wormhash_tuple { 34struct ebt_mac_wormhash_tuple {
33 uint32_t cmp[2]; 35 __u32 cmp[2];
34 __be32 ip; 36 __be32 ip;
35}; 37};
36 38
diff --git a/include/linux/netfilter_bridge/ebt_arp.h b/include/linux/netfilter_bridge/ebt_arp.h
index cbf4843b6b0f..522f3e427f49 100644
--- a/include/linux/netfilter_bridge/ebt_arp.h
+++ b/include/linux/netfilter_bridge/ebt_arp.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_ARP_H 1#ifndef __LINUX_BRIDGE_EBT_ARP_H
2#define __LINUX_BRIDGE_EBT_ARP_H 2#define __LINUX_BRIDGE_EBT_ARP_H
3 3
4#include <linux/types.h>
5
4#define EBT_ARP_OPCODE 0x01 6#define EBT_ARP_OPCODE 0x01
5#define EBT_ARP_HTYPE 0x02 7#define EBT_ARP_HTYPE 0x02
6#define EBT_ARP_PTYPE 0x04 8#define EBT_ARP_PTYPE 0x04
@@ -27,8 +29,8 @@ struct ebt_arp_info
27 unsigned char smmsk[ETH_ALEN]; 29 unsigned char smmsk[ETH_ALEN];
28 unsigned char dmaddr[ETH_ALEN]; 30 unsigned char dmaddr[ETH_ALEN];
29 unsigned char dmmsk[ETH_ALEN]; 31 unsigned char dmmsk[ETH_ALEN];
30 uint8_t bitmask; 32 __u8 bitmask;
31 uint8_t invflags; 33 __u8 invflags;
32}; 34};
33 35
34#endif 36#endif
diff --git a/include/linux/netfilter_bridge/ebt_ip.h b/include/linux/netfilter_bridge/ebt_ip.h
index 6a708fb92241..c4bbc41b0ea4 100644
--- a/include/linux/netfilter_bridge/ebt_ip.h
+++ b/include/linux/netfilter_bridge/ebt_ip.h
@@ -15,6 +15,8 @@
15#ifndef __LINUX_BRIDGE_EBT_IP_H 15#ifndef __LINUX_BRIDGE_EBT_IP_H
16#define __LINUX_BRIDGE_EBT_IP_H 16#define __LINUX_BRIDGE_EBT_IP_H
17 17
18#include <linux/types.h>
19
18#define EBT_IP_SOURCE 0x01 20#define EBT_IP_SOURCE 0x01
19#define EBT_IP_DEST 0x02 21#define EBT_IP_DEST 0x02
20#define EBT_IP_TOS 0x04 22#define EBT_IP_TOS 0x04
@@ -31,12 +33,12 @@ struct ebt_ip_info {
31 __be32 daddr; 33 __be32 daddr;
32 __be32 smsk; 34 __be32 smsk;
33 __be32 dmsk; 35 __be32 dmsk;
34 uint8_t tos; 36 __u8 tos;
35 uint8_t protocol; 37 __u8 protocol;
36 uint8_t bitmask; 38 __u8 bitmask;
37 uint8_t invflags; 39 __u8 invflags;
38 uint16_t sport[2]; 40 __u16 sport[2];
39 uint16_t dport[2]; 41 __u16 dport[2];
40}; 42};
41 43
42#endif 44#endif
diff --git a/include/linux/netfilter_bridge/ebt_ip6.h b/include/linux/netfilter_bridge/ebt_ip6.h
index e5de98701519..42b889682721 100644
--- a/include/linux/netfilter_bridge/ebt_ip6.h
+++ b/include/linux/netfilter_bridge/ebt_ip6.h
@@ -12,14 +12,19 @@
12#ifndef __LINUX_BRIDGE_EBT_IP6_H 12#ifndef __LINUX_BRIDGE_EBT_IP6_H
13#define __LINUX_BRIDGE_EBT_IP6_H 13#define __LINUX_BRIDGE_EBT_IP6_H
14 14
15#include <linux/types.h>
16
15#define EBT_IP6_SOURCE 0x01 17#define EBT_IP6_SOURCE 0x01
16#define EBT_IP6_DEST 0x02 18#define EBT_IP6_DEST 0x02
17#define EBT_IP6_TCLASS 0x04 19#define EBT_IP6_TCLASS 0x04
18#define EBT_IP6_PROTO 0x08 20#define EBT_IP6_PROTO 0x08
19#define EBT_IP6_SPORT 0x10 21#define EBT_IP6_SPORT 0x10
20#define EBT_IP6_DPORT 0x20 22#define EBT_IP6_DPORT 0x20
23#define EBT_IP6_ICMP6 0x40
24
21#define EBT_IP6_MASK (EBT_IP6_SOURCE | EBT_IP6_DEST | EBT_IP6_TCLASS |\ 25#define EBT_IP6_MASK (EBT_IP6_SOURCE | EBT_IP6_DEST | EBT_IP6_TCLASS |\
22 EBT_IP6_PROTO | EBT_IP6_SPORT | EBT_IP6_DPORT) 26 EBT_IP6_PROTO | EBT_IP6_SPORT | EBT_IP6_DPORT | \
27 EBT_IP6_ICMP6)
23#define EBT_IP6_MATCH "ip6" 28#define EBT_IP6_MATCH "ip6"
24 29
25/* the same values are used for the invflags */ 30/* the same values are used for the invflags */
@@ -28,12 +33,18 @@ struct ebt_ip6_info {
28 struct in6_addr daddr; 33 struct in6_addr daddr;
29 struct in6_addr smsk; 34 struct in6_addr smsk;
30 struct in6_addr dmsk; 35 struct in6_addr dmsk;
31 uint8_t tclass; 36 __u8 tclass;
32 uint8_t protocol; 37 __u8 protocol;
33 uint8_t bitmask; 38 __u8 bitmask;
34 uint8_t invflags; 39 __u8 invflags;
35 uint16_t sport[2]; 40 union {
36 uint16_t dport[2]; 41 __u16 sport[2];
42 __u8 icmpv6_type[2];
43 };
44 union {
45 __u16 dport[2];
46 __u8 icmpv6_code[2];
47 };
37}; 48};
38 49
39#endif 50#endif
diff --git a/include/linux/netfilter_bridge/ebt_limit.h b/include/linux/netfilter_bridge/ebt_limit.h
index 4bf76b751676..66d80b30ba0e 100644
--- a/include/linux/netfilter_bridge/ebt_limit.h
+++ b/include/linux/netfilter_bridge/ebt_limit.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_LIMIT_H 1#ifndef __LINUX_BRIDGE_EBT_LIMIT_H
2#define __LINUX_BRIDGE_EBT_LIMIT_H 2#define __LINUX_BRIDGE_EBT_LIMIT_H
3 3
4#include <linux/types.h>
5
4#define EBT_LIMIT_MATCH "limit" 6#define EBT_LIMIT_MATCH "limit"
5 7
6/* timings are in milliseconds. */ 8/* timings are in milliseconds. */
@@ -10,13 +12,13 @@
10 seconds, or one every 59 hours. */ 12 seconds, or one every 59 hours. */
11 13
12struct ebt_limit_info { 14struct ebt_limit_info {
13 u_int32_t avg; /* Average secs between packets * scale */ 15 __u32 avg; /* Average secs between packets * scale */
14 u_int32_t burst; /* Period multiplier for upper limit. */ 16 __u32 burst; /* Period multiplier for upper limit. */
15 17
16 /* Used internally by the kernel */ 18 /* Used internally by the kernel */
17 unsigned long prev; 19 unsigned long prev;
18 u_int32_t credit; 20 __u32 credit;
19 u_int32_t credit_cap, cost; 21 __u32 credit_cap, cost;
20}; 22};
21 23
22#endif 24#endif
diff --git a/include/linux/netfilter_bridge/ebt_log.h b/include/linux/netfilter_bridge/ebt_log.h
index cc2cdfb764bc..7e7f1d1fe494 100644
--- a/include/linux/netfilter_bridge/ebt_log.h
+++ b/include/linux/netfilter_bridge/ebt_log.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_LOG_H 1#ifndef __LINUX_BRIDGE_EBT_LOG_H
2#define __LINUX_BRIDGE_EBT_LOG_H 2#define __LINUX_BRIDGE_EBT_LOG_H
3 3
4#include <linux/types.h>
5
4#define EBT_LOG_IP 0x01 /* if the frame is made by ip, log the ip information */ 6#define EBT_LOG_IP 0x01 /* if the frame is made by ip, log the ip information */
5#define EBT_LOG_ARP 0x02 7#define EBT_LOG_ARP 0x02
6#define EBT_LOG_NFLOG 0x04 8#define EBT_LOG_NFLOG 0x04
@@ -10,9 +12,9 @@
10#define EBT_LOG_WATCHER "log" 12#define EBT_LOG_WATCHER "log"
11 13
12struct ebt_log_info { 14struct ebt_log_info {
13 uint8_t loglevel; 15 __u8 loglevel;
14 uint8_t prefix[EBT_LOG_PREFIX_SIZE]; 16 __u8 prefix[EBT_LOG_PREFIX_SIZE];
15 uint32_t bitmask; 17 __u32 bitmask;
16}; 18};
17 19
18#endif 20#endif
diff --git a/include/linux/netfilter_bridge/ebt_mark_m.h b/include/linux/netfilter_bridge/ebt_mark_m.h
index 9ceb10ec0ed6..410f9e5a71d4 100644
--- a/include/linux/netfilter_bridge/ebt_mark_m.h
+++ b/include/linux/netfilter_bridge/ebt_mark_m.h
@@ -1,13 +1,15 @@
1#ifndef __LINUX_BRIDGE_EBT_MARK_M_H 1#ifndef __LINUX_BRIDGE_EBT_MARK_M_H
2#define __LINUX_BRIDGE_EBT_MARK_M_H 2#define __LINUX_BRIDGE_EBT_MARK_M_H
3 3
4#include <linux/types.h>
5
4#define EBT_MARK_AND 0x01 6#define EBT_MARK_AND 0x01
5#define EBT_MARK_OR 0x02 7#define EBT_MARK_OR 0x02
6#define EBT_MARK_MASK (EBT_MARK_AND | EBT_MARK_OR) 8#define EBT_MARK_MASK (EBT_MARK_AND | EBT_MARK_OR)
7struct ebt_mark_m_info { 9struct ebt_mark_m_info {
8 unsigned long mark, mask; 10 unsigned long mark, mask;
9 uint8_t invert; 11 __u8 invert;
10 uint8_t bitmask; 12 __u8 bitmask;
11}; 13};
12#define EBT_MARK_MATCH "mark_m" 14#define EBT_MARK_MATCH "mark_m"
13 15
diff --git a/include/linux/netfilter_bridge/ebt_nflog.h b/include/linux/netfilter_bridge/ebt_nflog.h
index 052817849b83..df829fce9125 100644
--- a/include/linux/netfilter_bridge/ebt_nflog.h
+++ b/include/linux/netfilter_bridge/ebt_nflog.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_NFLOG_H 1#ifndef __LINUX_BRIDGE_EBT_NFLOG_H
2#define __LINUX_BRIDGE_EBT_NFLOG_H 2#define __LINUX_BRIDGE_EBT_NFLOG_H
3 3
4#include <linux/types.h>
5
4#define EBT_NFLOG_MASK 0x0 6#define EBT_NFLOG_MASK 0x0
5 7
6#define EBT_NFLOG_PREFIX_SIZE 64 8#define EBT_NFLOG_PREFIX_SIZE 64
@@ -10,11 +12,11 @@
10#define EBT_NFLOG_DEFAULT_THRESHOLD 1 12#define EBT_NFLOG_DEFAULT_THRESHOLD 1
11 13
12struct ebt_nflog_info { 14struct ebt_nflog_info {
13 u_int32_t len; 15 __u32 len;
14 u_int16_t group; 16 __u16 group;
15 u_int16_t threshold; 17 __u16 threshold;
16 u_int16_t flags; 18 __u16 flags;
17 u_int16_t pad; 19 __u16 pad;
18 char prefix[EBT_NFLOG_PREFIX_SIZE]; 20 char prefix[EBT_NFLOG_PREFIX_SIZE];
19}; 21};
20 22
diff --git a/include/linux/netfilter_bridge/ebt_pkttype.h b/include/linux/netfilter_bridge/ebt_pkttype.h
index 51a799840931..c241badcd036 100644
--- a/include/linux/netfilter_bridge/ebt_pkttype.h
+++ b/include/linux/netfilter_bridge/ebt_pkttype.h
@@ -1,9 +1,11 @@
1#ifndef __LINUX_BRIDGE_EBT_PKTTYPE_H 1#ifndef __LINUX_BRIDGE_EBT_PKTTYPE_H
2#define __LINUX_BRIDGE_EBT_PKTTYPE_H 2#define __LINUX_BRIDGE_EBT_PKTTYPE_H
3 3
4#include <linux/types.h>
5
4struct ebt_pkttype_info { 6struct ebt_pkttype_info {
5 uint8_t pkt_type; 7 __u8 pkt_type;
6 uint8_t invert; 8 __u8 invert;
7}; 9};
8#define EBT_PKTTYPE_MATCH "pkttype" 10#define EBT_PKTTYPE_MATCH "pkttype"
9 11
diff --git a/include/linux/netfilter_bridge/ebt_stp.h b/include/linux/netfilter_bridge/ebt_stp.h
index e503a0aa2728..1025b9f5fb7d 100644
--- a/include/linux/netfilter_bridge/ebt_stp.h
+++ b/include/linux/netfilter_bridge/ebt_stp.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_STP_H 1#ifndef __LINUX_BRIDGE_EBT_STP_H
2#define __LINUX_BRIDGE_EBT_STP_H 2#define __LINUX_BRIDGE_EBT_STP_H
3 3
4#include <linux/types.h>
5
4#define EBT_STP_TYPE 0x0001 6#define EBT_STP_TYPE 0x0001
5 7
6#define EBT_STP_FLAGS 0x0002 8#define EBT_STP_FLAGS 0x0002
@@ -21,24 +23,24 @@
21#define EBT_STP_MATCH "stp" 23#define EBT_STP_MATCH "stp"
22 24
23struct ebt_stp_config_info { 25struct ebt_stp_config_info {
24 uint8_t flags; 26 __u8 flags;
25 uint16_t root_priol, root_priou; 27 __u16 root_priol, root_priou;
26 char root_addr[6], root_addrmsk[6]; 28 char root_addr[6], root_addrmsk[6];
27 uint32_t root_costl, root_costu; 29 __u32 root_costl, root_costu;
28 uint16_t sender_priol, sender_priou; 30 __u16 sender_priol, sender_priou;
29 char sender_addr[6], sender_addrmsk[6]; 31 char sender_addr[6], sender_addrmsk[6];
30 uint16_t portl, portu; 32 __u16 portl, portu;
31 uint16_t msg_agel, msg_ageu; 33 __u16 msg_agel, msg_ageu;
32 uint16_t max_agel, max_ageu; 34 __u16 max_agel, max_ageu;
33 uint16_t hello_timel, hello_timeu; 35 __u16 hello_timel, hello_timeu;
34 uint16_t forward_delayl, forward_delayu; 36 __u16 forward_delayl, forward_delayu;
35}; 37};
36 38
37struct ebt_stp_info { 39struct ebt_stp_info {
38 uint8_t type; 40 __u8 type;
39 struct ebt_stp_config_info config; 41 struct ebt_stp_config_info config;
40 uint16_t bitmask; 42 __u16 bitmask;
41 uint16_t invflags; 43 __u16 invflags;
42}; 44};
43 45
44#endif 46#endif
diff --git a/include/linux/netfilter_bridge/ebt_ulog.h b/include/linux/netfilter_bridge/ebt_ulog.h
index b677e2671541..89a6becb5269 100644
--- a/include/linux/netfilter_bridge/ebt_ulog.h
+++ b/include/linux/netfilter_bridge/ebt_ulog.h
@@ -1,6 +1,8 @@
1#ifndef _EBT_ULOG_H 1#ifndef _EBT_ULOG_H
2#define _EBT_ULOG_H 2#define _EBT_ULOG_H
3 3
4#include <linux/types.h>
5
4#define EBT_ULOG_DEFAULT_NLGROUP 0 6#define EBT_ULOG_DEFAULT_NLGROUP 0
5#define EBT_ULOG_DEFAULT_QTHRESHOLD 1 7#define EBT_ULOG_DEFAULT_QTHRESHOLD 1
6#define EBT_ULOG_MAXNLGROUPS 32 /* hardcoded netlink max */ 8#define EBT_ULOG_MAXNLGROUPS 32 /* hardcoded netlink max */
@@ -10,7 +12,7 @@
10#define EBT_ULOG_VERSION 1 12#define EBT_ULOG_VERSION 1
11 13
12struct ebt_ulog_info { 14struct ebt_ulog_info {
13 uint32_t nlgroup; 15 __u32 nlgroup;
14 unsigned int cprange; 16 unsigned int cprange;
15 unsigned int qthreshold; 17 unsigned int qthreshold;
16 char prefix[EBT_ULOG_PREFIX_LEN]; 18 char prefix[EBT_ULOG_PREFIX_LEN];
diff --git a/include/linux/netfilter_bridge/ebt_vlan.h b/include/linux/netfilter_bridge/ebt_vlan.h
index 1d98be4031e7..967d1d5cf98d 100644
--- a/include/linux/netfilter_bridge/ebt_vlan.h
+++ b/include/linux/netfilter_bridge/ebt_vlan.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_BRIDGE_EBT_VLAN_H 1#ifndef __LINUX_BRIDGE_EBT_VLAN_H
2#define __LINUX_BRIDGE_EBT_VLAN_H 2#define __LINUX_BRIDGE_EBT_VLAN_H
3 3
4#include <linux/types.h>
5
4#define EBT_VLAN_ID 0x01 6#define EBT_VLAN_ID 0x01
5#define EBT_VLAN_PRIO 0x02 7#define EBT_VLAN_PRIO 0x02
6#define EBT_VLAN_ENCAP 0x04 8#define EBT_VLAN_ENCAP 0x04
@@ -8,12 +10,12 @@
8#define EBT_VLAN_MATCH "vlan" 10#define EBT_VLAN_MATCH "vlan"
9 11
10struct ebt_vlan_info { 12struct ebt_vlan_info {
11 uint16_t id; /* VLAN ID {1-4095} */ 13 __u16 id; /* VLAN ID {1-4095} */
12 uint8_t prio; /* VLAN User Priority {0-7} */ 14 __u8 prio; /* VLAN User Priority {0-7} */
13 __be16 encap; /* VLAN Encapsulated frame code {0-65535} */ 15 __be16 encap; /* VLAN Encapsulated frame code {0-65535} */
14 uint8_t bitmask; /* Args bitmask bit 1=1 - ID arg, 16 __u8 bitmask; /* Args bitmask bit 1=1 - ID arg,
15 bit 2=1 User-Priority arg, bit 3=1 encap*/ 17 bit 2=1 User-Priority arg, bit 3=1 encap*/
16 uint8_t invflags; /* Inverse bitmask bit 1=1 - inversed ID arg, 18 __u8 invflags; /* Inverse bitmask bit 1=1 - inversed ID arg,
17 bit 2=1 - inversed Pirority arg */ 19 bit 2=1 - inversed Pirority arg */
18}; 20};
19 21
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 1c6f0c5f530e..8797ed16feb2 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -92,7 +92,7 @@ struct ebt_entries {
92 92
93/* This is a hack to make a difference between an ebt_entry struct and an 93/* This is a hack to make a difference between an ebt_entry struct and an
94 * ebt_entries struct when traversing the entries from start to end. 94 * ebt_entries struct when traversing the entries from start to end.
95 * Using this simplifies the code alot, while still being able to use 95 * Using this simplifies the code a lot, while still being able to use
96 * ebt_entries. 96 * ebt_entries.
97 * Contrary, iptables doesn't use something like ebt_entries and therefore uses 97 * Contrary, iptables doesn't use something like ebt_entries and therefore uses
98 * different techniques for naming the policy and such. So, iptables doesn't 98 * different techniques for naming the policy and such. So, iptables doesn't
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index 704a7b6e8169..64a5d95c58e8 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -27,12 +27,49 @@
27 27
28#include <linux/netfilter/x_tables.h> 28#include <linux/netfilter/x_tables.h>
29 29
30#ifndef __KERNEL__
30#define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN 31#define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
31#define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN 32#define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
32#define ipt_match xt_match 33#define ipt_match xt_match
33#define ipt_target xt_target 34#define ipt_target xt_target
34#define ipt_table xt_table 35#define ipt_table xt_table
35#define ipt_get_revision xt_get_revision 36#define ipt_get_revision xt_get_revision
37#define ipt_entry_match xt_entry_match
38#define ipt_entry_target xt_entry_target
39#define ipt_standard_target xt_standard_target
40#define ipt_error_target xt_error_target
41#define ipt_counters xt_counters
42#define IPT_CONTINUE XT_CONTINUE
43#define IPT_RETURN XT_RETURN
44
45/* This group is older than old (iptables < v1.4.0-rc1~89) */
46#include <linux/netfilter/xt_tcpudp.h>
47#define ipt_udp xt_udp
48#define ipt_tcp xt_tcp
49#define IPT_TCP_INV_SRCPT XT_TCP_INV_SRCPT
50#define IPT_TCP_INV_DSTPT XT_TCP_INV_DSTPT
51#define IPT_TCP_INV_FLAGS XT_TCP_INV_FLAGS
52#define IPT_TCP_INV_OPTION XT_TCP_INV_OPTION
53#define IPT_TCP_INV_MASK XT_TCP_INV_MASK
54#define IPT_UDP_INV_SRCPT XT_UDP_INV_SRCPT
55#define IPT_UDP_INV_DSTPT XT_UDP_INV_DSTPT
56#define IPT_UDP_INV_MASK XT_UDP_INV_MASK
57
58/* The argument to IPT_SO_ADD_COUNTERS. */
59#define ipt_counters_info xt_counters_info
60/* Standard return verdict, or do jump. */
61#define IPT_STANDARD_TARGET XT_STANDARD_TARGET
62/* Error verdict. */
63#define IPT_ERROR_TARGET XT_ERROR_TARGET
64
65/* fn returns 0 to continue iteration */
66#define IPT_MATCH_ITERATE(e, fn, args...) \
67 XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args)
68
69/* fn returns 0 to continue iteration */
70#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \
71 XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args)
72#endif
36 73
37/* Yes, Virginia, you have to zero the padding. */ 74/* Yes, Virginia, you have to zero the padding. */
38struct ipt_ip { 75struct ipt_ip {
@@ -52,12 +89,6 @@ struct ipt_ip {
52 u_int8_t invflags; 89 u_int8_t invflags;
53}; 90};
54 91
55#define ipt_entry_match xt_entry_match
56#define ipt_entry_target xt_entry_target
57#define ipt_standard_target xt_standard_target
58
59#define ipt_counters xt_counters
60
61/* Values for "flag" field in struct ipt_ip (general ip structure). */ 92/* Values for "flag" field in struct ipt_ip (general ip structure). */
62#define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */ 93#define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */
63#define IPT_F_GOTO 0x02 /* Set if jump is a goto */ 94#define IPT_F_GOTO 0x02 /* Set if jump is a goto */
@@ -116,23 +147,6 @@ struct ipt_entry {
116#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3) 147#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
117#define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET 148#define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET
118 149
119#define IPT_CONTINUE XT_CONTINUE
120#define IPT_RETURN XT_RETURN
121
122#include <linux/netfilter/xt_tcpudp.h>
123#define ipt_udp xt_udp
124#define ipt_tcp xt_tcp
125
126#define IPT_TCP_INV_SRCPT XT_TCP_INV_SRCPT
127#define IPT_TCP_INV_DSTPT XT_TCP_INV_DSTPT
128#define IPT_TCP_INV_FLAGS XT_TCP_INV_FLAGS
129#define IPT_TCP_INV_OPTION XT_TCP_INV_OPTION
130#define IPT_TCP_INV_MASK XT_TCP_INV_MASK
131
132#define IPT_UDP_INV_SRCPT XT_UDP_INV_SRCPT
133#define IPT_UDP_INV_DSTPT XT_UDP_INV_DSTPT
134#define IPT_UDP_INV_MASK XT_UDP_INV_MASK
135
136/* ICMP matching stuff */ 150/* ICMP matching stuff */
137struct ipt_icmp { 151struct ipt_icmp {
138 u_int8_t type; /* type to match */ 152 u_int8_t type; /* type to match */
@@ -146,7 +160,7 @@ struct ipt_icmp {
146/* The argument to IPT_SO_GET_INFO */ 160/* The argument to IPT_SO_GET_INFO */
147struct ipt_getinfo { 161struct ipt_getinfo {
148 /* Which table: caller fills this in. */ 162 /* Which table: caller fills this in. */
149 char name[IPT_TABLE_MAXNAMELEN]; 163 char name[XT_TABLE_MAXNAMELEN];
150 164
151 /* Kernel fills these in. */ 165 /* Kernel fills these in. */
152 /* Which hook entry points are valid: bitmask */ 166 /* Which hook entry points are valid: bitmask */
@@ -168,7 +182,7 @@ struct ipt_getinfo {
168/* The argument to IPT_SO_SET_REPLACE. */ 182/* The argument to IPT_SO_SET_REPLACE. */
169struct ipt_replace { 183struct ipt_replace {
170 /* Which table. */ 184 /* Which table. */
171 char name[IPT_TABLE_MAXNAMELEN]; 185 char name[XT_TABLE_MAXNAMELEN];
172 186
173 /* Which hook entry points are valid: bitmask. You can't 187 /* Which hook entry points are valid: bitmask. You can't
174 change this. */ 188 change this. */
@@ -196,13 +210,10 @@ struct ipt_replace {
196 struct ipt_entry entries[0]; 210 struct ipt_entry entries[0];
197}; 211};
198 212
199/* The argument to IPT_SO_ADD_COUNTERS. */
200#define ipt_counters_info xt_counters_info
201
202/* The argument to IPT_SO_GET_ENTRIES. */ 213/* The argument to IPT_SO_GET_ENTRIES. */
203struct ipt_get_entries { 214struct ipt_get_entries {
204 /* Which table: user fills this in. */ 215 /* Which table: user fills this in. */
205 char name[IPT_TABLE_MAXNAMELEN]; 216 char name[XT_TABLE_MAXNAMELEN];
206 217
207 /* User fills this in: total entry size. */ 218 /* User fills this in: total entry size. */
208 unsigned int size; 219 unsigned int size;
@@ -211,28 +222,13 @@ struct ipt_get_entries {
211 struct ipt_entry entrytable[0]; 222 struct ipt_entry entrytable[0];
212}; 223};
213 224
214/* Standard return verdict, or do jump. */
215#define IPT_STANDARD_TARGET XT_STANDARD_TARGET
216/* Error verdict. */
217#define IPT_ERROR_TARGET XT_ERROR_TARGET
218
219/* Helper functions */ 225/* Helper functions */
220static __inline__ struct ipt_entry_target * 226static __inline__ struct xt_entry_target *
221ipt_get_target(struct ipt_entry *e) 227ipt_get_target(struct ipt_entry *e)
222{ 228{
223 return (void *)e + e->target_offset; 229 return (void *)e + e->target_offset;
224} 230}
225 231
226#ifndef __KERNEL__
227/* fn returns 0 to continue iteration */
228#define IPT_MATCH_ITERATE(e, fn, args...) \
229 XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args)
230
231/* fn returns 0 to continue iteration */
232#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \
233 XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args)
234#endif
235
236/* 232/*
237 * Main firewall chains definitions and global var's definitions. 233 * Main firewall chains definitions and global var's definitions.
238 */ 234 */
@@ -249,17 +245,12 @@ extern void ipt_unregister_table(struct net *net, struct xt_table *table);
249/* Standard entry. */ 245/* Standard entry. */
250struct ipt_standard { 246struct ipt_standard {
251 struct ipt_entry entry; 247 struct ipt_entry entry;
252 struct ipt_standard_target target; 248 struct xt_standard_target target;
253};
254
255struct ipt_error_target {
256 struct ipt_entry_target target;
257 char errorname[IPT_FUNCTION_MAXNAMELEN];
258}; 249};
259 250
260struct ipt_error { 251struct ipt_error {
261 struct ipt_entry entry; 252 struct ipt_entry entry;
262 struct ipt_error_target target; 253 struct xt_error_target target;
263}; 254};
264 255
265#define IPT_ENTRY_INIT(__size) \ 256#define IPT_ENTRY_INIT(__size) \
@@ -271,7 +262,7 @@ struct ipt_error {
271#define IPT_STANDARD_INIT(__verdict) \ 262#define IPT_STANDARD_INIT(__verdict) \
272{ \ 263{ \
273 .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \ 264 .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \
274 .target = XT_TARGET_INIT(IPT_STANDARD_TARGET, \ 265 .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \
275 sizeof(struct xt_standard_target)), \ 266 sizeof(struct xt_standard_target)), \
276 .target.verdict = -(__verdict) - 1, \ 267 .target.verdict = -(__verdict) - 1, \
277} 268}
@@ -279,8 +270,8 @@ struct ipt_error {
279#define IPT_ERROR_INIT \ 270#define IPT_ERROR_INIT \
280{ \ 271{ \
281 .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \ 272 .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \
282 .target = XT_TARGET_INIT(IPT_ERROR_TARGET, \ 273 .target = XT_TARGET_INIT(XT_ERROR_TARGET, \
283 sizeof(struct ipt_error_target)), \ 274 sizeof(struct xt_error_target)), \
284 .target.errorname = "ERROR", \ 275 .target.errorname = "ERROR", \
285} 276}
286 277
@@ -291,8 +282,6 @@ extern unsigned int ipt_do_table(struct sk_buff *skb,
291 const struct net_device *out, 282 const struct net_device *out,
292 struct xt_table *table); 283 struct xt_table *table);
293 284
294#define IPT_ALIGN(s) XT_ALIGN(s)
295
296#ifdef CONFIG_COMPAT 285#ifdef CONFIG_COMPAT
297#include <net/compat.h> 286#include <net/compat.h>
298 287
@@ -307,14 +296,12 @@ struct compat_ipt_entry {
307}; 296};
308 297
309/* Helper functions */ 298/* Helper functions */
310static inline struct ipt_entry_target * 299static inline struct xt_entry_target *
311compat_ipt_get_target(struct compat_ipt_entry *e) 300compat_ipt_get_target(struct compat_ipt_entry *e)
312{ 301{
313 return (void *)e + e->target_offset; 302 return (void *)e + e->target_offset;
314} 303}
315 304
316#define COMPAT_IPT_ALIGN(s) COMPAT_XT_ALIGN(s)
317
318#endif /* CONFIG_COMPAT */ 305#endif /* CONFIG_COMPAT */
319#endif /*__KERNEL__*/ 306#endif /*__KERNEL__*/
320#endif /* _IPTABLES_H */ 307#endif /* _IPTABLES_H */
diff --git a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
index e5a3687c8a72..c6a204c97047 100644
--- a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
+++ b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
@@ -1,6 +1,8 @@
1#ifndef _IPT_CLUSTERIP_H_target 1#ifndef _IPT_CLUSTERIP_H_target
2#define _IPT_CLUSTERIP_H_target 2#define _IPT_CLUSTERIP_H_target
3 3
4#include <linux/types.h>
5
4enum clusterip_hashmode { 6enum clusterip_hashmode {
5 CLUSTERIP_HASHMODE_SIP = 0, 7 CLUSTERIP_HASHMODE_SIP = 0,
6 CLUSTERIP_HASHMODE_SIP_SPT, 8 CLUSTERIP_HASHMODE_SIP_SPT,
@@ -17,15 +19,15 @@ struct clusterip_config;
17 19
18struct ipt_clusterip_tgt_info { 20struct ipt_clusterip_tgt_info {
19 21
20 u_int32_t flags; 22 __u32 flags;
21 23
22 /* only relevant for new ones */ 24 /* only relevant for new ones */
23 u_int8_t clustermac[6]; 25 __u8 clustermac[6];
24 u_int16_t num_total_nodes; 26 __u16 num_total_nodes;
25 u_int16_t num_local_nodes; 27 __u16 num_local_nodes;
26 u_int16_t local_nodes[CLUSTERIP_MAX_NODES]; 28 __u16 local_nodes[CLUSTERIP_MAX_NODES];
27 u_int32_t hash_mode; 29 __u32 hash_mode;
28 u_int32_t hash_initval; 30 __u32 hash_initval;
29 31
30 /* Used internally by the kernel */ 32 /* Used internally by the kernel */
31 struct clusterip_config *config; 33 struct clusterip_config *config;
diff --git a/include/linux/netfilter_ipv4/ipt_ECN.h b/include/linux/netfilter_ipv4/ipt_ECN.h
index 7ca45918ab8e..bb88d5315a4d 100644
--- a/include/linux/netfilter_ipv4/ipt_ECN.h
+++ b/include/linux/netfilter_ipv4/ipt_ECN.h
@@ -8,6 +8,8 @@
8*/ 8*/
9#ifndef _IPT_ECN_TARGET_H 9#ifndef _IPT_ECN_TARGET_H
10#define _IPT_ECN_TARGET_H 10#define _IPT_ECN_TARGET_H
11
12#include <linux/types.h>
11#include <linux/netfilter/xt_DSCP.h> 13#include <linux/netfilter/xt_DSCP.h>
12 14
13#define IPT_ECN_IP_MASK (~XT_DSCP_MASK) 15#define IPT_ECN_IP_MASK (~XT_DSCP_MASK)
@@ -19,11 +21,11 @@
19#define IPT_ECN_OP_MASK 0xce 21#define IPT_ECN_OP_MASK 0xce
20 22
21struct ipt_ECN_info { 23struct ipt_ECN_info {
22 u_int8_t operation; /* bitset of operations */ 24 __u8 operation; /* bitset of operations */
23 u_int8_t ip_ect; /* ECT codepoint of IPv4 header, pre-shifted */ 25 __u8 ip_ect; /* ECT codepoint of IPv4 header, pre-shifted */
24 union { 26 union {
25 struct { 27 struct {
26 u_int8_t ece:1, cwr:1; /* TCP ECT bits */ 28 __u8 ece:1, cwr:1; /* TCP ECT bits */
27 } tcp; 29 } tcp;
28 } proto; 30 } proto;
29}; 31};
diff --git a/include/linux/netfilter_ipv4/ipt_SAME.h b/include/linux/netfilter_ipv4/ipt_SAME.h
index 2529660c5b38..5bca78267afd 100644
--- a/include/linux/netfilter_ipv4/ipt_SAME.h
+++ b/include/linux/netfilter_ipv4/ipt_SAME.h
@@ -1,15 +1,17 @@
1#ifndef _IPT_SAME_H 1#ifndef _IPT_SAME_H
2#define _IPT_SAME_H 2#define _IPT_SAME_H
3 3
4#include <linux/types.h>
5
4#define IPT_SAME_MAX_RANGE 10 6#define IPT_SAME_MAX_RANGE 10
5 7
6#define IPT_SAME_NODST 0x01 8#define IPT_SAME_NODST 0x01
7 9
8struct ipt_same_info { 10struct ipt_same_info {
9 unsigned char info; 11 unsigned char info;
10 u_int32_t rangesize; 12 __u32 rangesize;
11 u_int32_t ipnum; 13 __u32 ipnum;
12 u_int32_t *iparray; 14 __u32 *iparray;
13 15
14 /* hangs off end. */ 16 /* hangs off end. */
15 struct nf_nat_range range[IPT_SAME_MAX_RANGE]; 17 struct nf_nat_range range[IPT_SAME_MAX_RANGE];
diff --git a/include/linux/netfilter_ipv4/ipt_TTL.h b/include/linux/netfilter_ipv4/ipt_TTL.h
index ee6611edc112..f6ac169d92f9 100644
--- a/include/linux/netfilter_ipv4/ipt_TTL.h
+++ b/include/linux/netfilter_ipv4/ipt_TTL.h
@@ -4,6 +4,8 @@
4#ifndef _IPT_TTL_H 4#ifndef _IPT_TTL_H
5#define _IPT_TTL_H 5#define _IPT_TTL_H
6 6
7#include <linux/types.h>
8
7enum { 9enum {
8 IPT_TTL_SET = 0, 10 IPT_TTL_SET = 0,
9 IPT_TTL_INC, 11 IPT_TTL_INC,
@@ -13,8 +15,8 @@ enum {
13#define IPT_TTL_MAXMODE IPT_TTL_DEC 15#define IPT_TTL_MAXMODE IPT_TTL_DEC
14 16
15struct ipt_TTL_info { 17struct ipt_TTL_info {
16 u_int8_t mode; 18 __u8 mode;
17 u_int8_t ttl; 19 __u8 ttl;
18}; 20};
19 21
20 22
diff --git a/include/linux/netfilter_ipv4/ipt_addrtype.h b/include/linux/netfilter_ipv4/ipt_addrtype.h
index 446de6aef983..0da42237c8da 100644
--- a/include/linux/netfilter_ipv4/ipt_addrtype.h
+++ b/include/linux/netfilter_ipv4/ipt_addrtype.h
@@ -1,6 +1,8 @@
1#ifndef _IPT_ADDRTYPE_H 1#ifndef _IPT_ADDRTYPE_H
2#define _IPT_ADDRTYPE_H 2#define _IPT_ADDRTYPE_H
3 3
4#include <linux/types.h>
5
4enum { 6enum {
5 IPT_ADDRTYPE_INVERT_SOURCE = 0x0001, 7 IPT_ADDRTYPE_INVERT_SOURCE = 0x0001,
6 IPT_ADDRTYPE_INVERT_DEST = 0x0002, 8 IPT_ADDRTYPE_INVERT_DEST = 0x0002,
@@ -9,17 +11,17 @@ enum {
9}; 11};
10 12
11struct ipt_addrtype_info_v1 { 13struct ipt_addrtype_info_v1 {
12 u_int16_t source; /* source-type mask */ 14 __u16 source; /* source-type mask */
13 u_int16_t dest; /* dest-type mask */ 15 __u16 dest; /* dest-type mask */
14 u_int32_t flags; 16 __u32 flags;
15}; 17};
16 18
17/* revision 0 */ 19/* revision 0 */
18struct ipt_addrtype_info { 20struct ipt_addrtype_info {
19 u_int16_t source; /* source-type mask */ 21 __u16 source; /* source-type mask */
20 u_int16_t dest; /* dest-type mask */ 22 __u16 dest; /* dest-type mask */
21 u_int32_t invert_source; 23 __u32 invert_source;
22 u_int32_t invert_dest; 24 __u32 invert_dest;
23}; 25};
24 26
25#endif 27#endif
diff --git a/include/linux/netfilter_ipv4/ipt_ah.h b/include/linux/netfilter_ipv4/ipt_ah.h
index 2e555b4d05e3..4e02bb0119e3 100644
--- a/include/linux/netfilter_ipv4/ipt_ah.h
+++ b/include/linux/netfilter_ipv4/ipt_ah.h
@@ -1,9 +1,11 @@
1#ifndef _IPT_AH_H 1#ifndef _IPT_AH_H
2#define _IPT_AH_H 2#define _IPT_AH_H
3 3
4#include <linux/types.h>
5
4struct ipt_ah { 6struct ipt_ah {
5 u_int32_t spis[2]; /* Security Parameter Index */ 7 __u32 spis[2]; /* Security Parameter Index */
6 u_int8_t invflags; /* Inverse flags */ 8 __u8 invflags; /* Inverse flags */
7}; 9};
8 10
9 11
diff --git a/include/linux/netfilter_ipv4/ipt_ecn.h b/include/linux/netfilter_ipv4/ipt_ecn.h
index 9945baa4ccd7..eabf95fb7d3e 100644
--- a/include/linux/netfilter_ipv4/ipt_ecn.h
+++ b/include/linux/netfilter_ipv4/ipt_ecn.h
@@ -8,6 +8,8 @@
8*/ 8*/
9#ifndef _IPT_ECN_H 9#ifndef _IPT_ECN_H
10#define _IPT_ECN_H 10#define _IPT_ECN_H
11
12#include <linux/types.h>
11#include <linux/netfilter/xt_dscp.h> 13#include <linux/netfilter/xt_dscp.h>
12 14
13#define IPT_ECN_IP_MASK (~XT_DSCP_MASK) 15#define IPT_ECN_IP_MASK (~XT_DSCP_MASK)
@@ -20,12 +22,12 @@
20 22
21/* match info */ 23/* match info */
22struct ipt_ecn_info { 24struct ipt_ecn_info {
23 u_int8_t operation; 25 __u8 operation;
24 u_int8_t invert; 26 __u8 invert;
25 u_int8_t ip_ect; 27 __u8 ip_ect;
26 union { 28 union {
27 struct { 29 struct {
28 u_int8_t ect; 30 __u8 ect;
29 } tcp; 31 } tcp;
30 } proto; 32 } proto;
31}; 33};
diff --git a/include/linux/netfilter_ipv4/ipt_ttl.h b/include/linux/netfilter_ipv4/ipt_ttl.h
index ee24fd86a3aa..37bee4442486 100644
--- a/include/linux/netfilter_ipv4/ipt_ttl.h
+++ b/include/linux/netfilter_ipv4/ipt_ttl.h
@@ -4,6 +4,8 @@
4#ifndef _IPT_TTL_H 4#ifndef _IPT_TTL_H
5#define _IPT_TTL_H 5#define _IPT_TTL_H
6 6
7#include <linux/types.h>
8
7enum { 9enum {
8 IPT_TTL_EQ = 0, /* equals */ 10 IPT_TTL_EQ = 0, /* equals */
9 IPT_TTL_NE, /* not equals */ 11 IPT_TTL_NE, /* not equals */
@@ -13,8 +15,8 @@ enum {
13 15
14 16
15struct ipt_ttl_info { 17struct ipt_ttl_info {
16 u_int8_t mode; 18 __u8 mode;
17 u_int8_t ttl; 19 __u8 ttl;
18}; 20};
19 21
20 22
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 18442ff19c07..c9784f7a9c1f 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -27,13 +27,42 @@
27 27
28#include <linux/netfilter/x_tables.h> 28#include <linux/netfilter/x_tables.h>
29 29
30#ifndef __KERNEL__
30#define IP6T_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN 31#define IP6T_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
31#define IP6T_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN 32#define IP6T_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
32
33#define ip6t_match xt_match 33#define ip6t_match xt_match
34#define ip6t_target xt_target 34#define ip6t_target xt_target
35#define ip6t_table xt_table 35#define ip6t_table xt_table
36#define ip6t_get_revision xt_get_revision 36#define ip6t_get_revision xt_get_revision
37#define ip6t_entry_match xt_entry_match
38#define ip6t_entry_target xt_entry_target
39#define ip6t_standard_target xt_standard_target
40#define ip6t_error_target xt_error_target
41#define ip6t_counters xt_counters
42#define IP6T_CONTINUE XT_CONTINUE
43#define IP6T_RETURN XT_RETURN
44
45/* Pre-iptables-1.4.0 */
46#include <linux/netfilter/xt_tcpudp.h>
47#define ip6t_tcp xt_tcp
48#define ip6t_udp xt_udp
49#define IP6T_TCP_INV_SRCPT XT_TCP_INV_SRCPT
50#define IP6T_TCP_INV_DSTPT XT_TCP_INV_DSTPT
51#define IP6T_TCP_INV_FLAGS XT_TCP_INV_FLAGS
52#define IP6T_TCP_INV_OPTION XT_TCP_INV_OPTION
53#define IP6T_TCP_INV_MASK XT_TCP_INV_MASK
54#define IP6T_UDP_INV_SRCPT XT_UDP_INV_SRCPT
55#define IP6T_UDP_INV_DSTPT XT_UDP_INV_DSTPT
56#define IP6T_UDP_INV_MASK XT_UDP_INV_MASK
57
58#define ip6t_counters_info xt_counters_info
59#define IP6T_STANDARD_TARGET XT_STANDARD_TARGET
60#define IP6T_ERROR_TARGET XT_ERROR_TARGET
61#define IP6T_MATCH_ITERATE(e, fn, args...) \
62 XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args)
63#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \
64 XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args)
65#endif
37 66
38/* Yes, Virginia, you have to zero the padding. */ 67/* Yes, Virginia, you have to zero the padding. */
39struct ip6t_ip6 { 68struct ip6t_ip6 {
@@ -62,12 +91,6 @@ struct ip6t_ip6 {
62 u_int8_t invflags; 91 u_int8_t invflags;
63}; 92};
64 93
65#define ip6t_entry_match xt_entry_match
66#define ip6t_entry_target xt_entry_target
67#define ip6t_standard_target xt_standard_target
68
69#define ip6t_counters xt_counters
70
71/* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */ 94/* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */
72#define IP6T_F_PROTO 0x01 /* Set if rule cares about upper 95#define IP6T_F_PROTO 0x01 /* Set if rule cares about upper
73 protocols */ 96 protocols */
@@ -112,17 +135,12 @@ struct ip6t_entry {
112/* Standard entry */ 135/* Standard entry */
113struct ip6t_standard { 136struct ip6t_standard {
114 struct ip6t_entry entry; 137 struct ip6t_entry entry;
115 struct ip6t_standard_target target; 138 struct xt_standard_target target;
116};
117
118struct ip6t_error_target {
119 struct ip6t_entry_target target;
120 char errorname[IP6T_FUNCTION_MAXNAMELEN];
121}; 139};
122 140
123struct ip6t_error { 141struct ip6t_error {
124 struct ip6t_entry entry; 142 struct ip6t_entry entry;
125 struct ip6t_error_target target; 143 struct xt_error_target target;
126}; 144};
127 145
128#define IP6T_ENTRY_INIT(__size) \ 146#define IP6T_ENTRY_INIT(__size) \
@@ -134,16 +152,16 @@ struct ip6t_error {
134#define IP6T_STANDARD_INIT(__verdict) \ 152#define IP6T_STANDARD_INIT(__verdict) \
135{ \ 153{ \
136 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \ 154 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \
137 .target = XT_TARGET_INIT(IP6T_STANDARD_TARGET, \ 155 .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \
138 sizeof(struct ip6t_standard_target)), \ 156 sizeof(struct xt_standard_target)), \
139 .target.verdict = -(__verdict) - 1, \ 157 .target.verdict = -(__verdict) - 1, \
140} 158}
141 159
142#define IP6T_ERROR_INIT \ 160#define IP6T_ERROR_INIT \
143{ \ 161{ \
144 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \ 162 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \
145 .target = XT_TARGET_INIT(IP6T_ERROR_TARGET, \ 163 .target = XT_TARGET_INIT(XT_ERROR_TARGET, \
146 sizeof(struct ip6t_error_target)), \ 164 sizeof(struct xt_error_target)), \
147 .target.errorname = "ERROR", \ 165 .target.errorname = "ERROR", \
148} 166}
149 167
@@ -166,30 +184,6 @@ struct ip6t_error {
166#define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5) 184#define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5)
167#define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET 185#define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET
168 186
169/* CONTINUE verdict for targets */
170#define IP6T_CONTINUE XT_CONTINUE
171
172/* For standard target */
173#define IP6T_RETURN XT_RETURN
174
175/* TCP/UDP matching stuff */
176#include <linux/netfilter/xt_tcpudp.h>
177
178#define ip6t_tcp xt_tcp
179#define ip6t_udp xt_udp
180
181/* Values for "inv" field in struct ipt_tcp. */
182#define IP6T_TCP_INV_SRCPT XT_TCP_INV_SRCPT
183#define IP6T_TCP_INV_DSTPT XT_TCP_INV_DSTPT
184#define IP6T_TCP_INV_FLAGS XT_TCP_INV_FLAGS
185#define IP6T_TCP_INV_OPTION XT_TCP_INV_OPTION
186#define IP6T_TCP_INV_MASK XT_TCP_INV_MASK
187
188/* Values for "invflags" field in struct ipt_udp. */
189#define IP6T_UDP_INV_SRCPT XT_UDP_INV_SRCPT
190#define IP6T_UDP_INV_DSTPT XT_UDP_INV_DSTPT
191#define IP6T_UDP_INV_MASK XT_UDP_INV_MASK
192
193/* ICMP matching stuff */ 187/* ICMP matching stuff */
194struct ip6t_icmp { 188struct ip6t_icmp {
195 u_int8_t type; /* type to match */ 189 u_int8_t type; /* type to match */
@@ -203,7 +197,7 @@ struct ip6t_icmp {
203/* The argument to IP6T_SO_GET_INFO */ 197/* The argument to IP6T_SO_GET_INFO */
204struct ip6t_getinfo { 198struct ip6t_getinfo {
205 /* Which table: caller fills this in. */ 199 /* Which table: caller fills this in. */
206 char name[IP6T_TABLE_MAXNAMELEN]; 200 char name[XT_TABLE_MAXNAMELEN];
207 201
208 /* Kernel fills these in. */ 202 /* Kernel fills these in. */
209 /* Which hook entry points are valid: bitmask */ 203 /* Which hook entry points are valid: bitmask */
@@ -225,7 +219,7 @@ struct ip6t_getinfo {
225/* The argument to IP6T_SO_SET_REPLACE. */ 219/* The argument to IP6T_SO_SET_REPLACE. */
226struct ip6t_replace { 220struct ip6t_replace {
227 /* Which table. */ 221 /* Which table. */
228 char name[IP6T_TABLE_MAXNAMELEN]; 222 char name[XT_TABLE_MAXNAMELEN];
229 223
230 /* Which hook entry points are valid: bitmask. You can't 224 /* Which hook entry points are valid: bitmask. You can't
231 change this. */ 225 change this. */
@@ -253,13 +247,10 @@ struct ip6t_replace {
253 struct ip6t_entry entries[0]; 247 struct ip6t_entry entries[0];
254}; 248};
255 249
256/* The argument to IP6T_SO_ADD_COUNTERS. */
257#define ip6t_counters_info xt_counters_info
258
259/* The argument to IP6T_SO_GET_ENTRIES. */ 250/* The argument to IP6T_SO_GET_ENTRIES. */
260struct ip6t_get_entries { 251struct ip6t_get_entries {
261 /* Which table: user fills this in. */ 252 /* Which table: user fills this in. */
262 char name[IP6T_TABLE_MAXNAMELEN]; 253 char name[XT_TABLE_MAXNAMELEN];
263 254
264 /* User fills this in: total entry size. */ 255 /* User fills this in: total entry size. */
265 unsigned int size; 256 unsigned int size;
@@ -268,28 +259,13 @@ struct ip6t_get_entries {
268 struct ip6t_entry entrytable[0]; 259 struct ip6t_entry entrytable[0];
269}; 260};
270 261
271/* Standard return verdict, or do jump. */
272#define IP6T_STANDARD_TARGET XT_STANDARD_TARGET
273/* Error verdict. */
274#define IP6T_ERROR_TARGET XT_ERROR_TARGET
275
276/* Helper functions */ 262/* Helper functions */
277static __inline__ struct ip6t_entry_target * 263static __inline__ struct xt_entry_target *
278ip6t_get_target(struct ip6t_entry *e) 264ip6t_get_target(struct ip6t_entry *e)
279{ 265{
280 return (void *)e + e->target_offset; 266 return (void *)e + e->target_offset;
281} 267}
282 268
283#ifndef __KERNEL__
284/* fn returns 0 to continue iteration */
285#define IP6T_MATCH_ITERATE(e, fn, args...) \
286 XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args)
287
288/* fn returns 0 to continue iteration */
289#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \
290 XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args)
291#endif
292
293/* 269/*
294 * Main firewall chains definitions and global var's definitions. 270 * Main firewall chains definitions and global var's definitions.
295 */ 271 */
@@ -316,8 +292,6 @@ extern int ip6t_ext_hdr(u8 nexthdr);
316extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, 292extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
317 int target, unsigned short *fragoff); 293 int target, unsigned short *fragoff);
318 294
319#define IP6T_ALIGN(s) XT_ALIGN(s)
320
321#ifdef CONFIG_COMPAT 295#ifdef CONFIG_COMPAT
322#include <net/compat.h> 296#include <net/compat.h>
323 297
@@ -331,14 +305,12 @@ struct compat_ip6t_entry {
331 unsigned char elems[0]; 305 unsigned char elems[0];
332}; 306};
333 307
334static inline struct ip6t_entry_target * 308static inline struct xt_entry_target *
335compat_ip6t_get_target(struct compat_ip6t_entry *e) 309compat_ip6t_get_target(struct compat_ip6t_entry *e)
336{ 310{
337 return (void *)e + e->target_offset; 311 return (void *)e + e->target_offset;
338} 312}
339 313
340#define COMPAT_IP6T_ALIGN(s) COMPAT_XT_ALIGN(s)
341
342#endif /* CONFIG_COMPAT */ 314#endif /* CONFIG_COMPAT */
343#endif /*__KERNEL__*/ 315#endif /*__KERNEL__*/
344#endif /* _IP6_TABLES_H */ 316#endif /* _IP6_TABLES_H */
diff --git a/include/linux/netfilter_ipv6/ip6t_HL.h b/include/linux/netfilter_ipv6/ip6t_HL.h
index afb7813d45ab..ebd8ead1bb63 100644
--- a/include/linux/netfilter_ipv6/ip6t_HL.h
+++ b/include/linux/netfilter_ipv6/ip6t_HL.h
@@ -5,6 +5,8 @@
5#ifndef _IP6T_HL_H 5#ifndef _IP6T_HL_H
6#define _IP6T_HL_H 6#define _IP6T_HL_H
7 7
8#include <linux/types.h>
9
8enum { 10enum {
9 IP6T_HL_SET = 0, 11 IP6T_HL_SET = 0,
10 IP6T_HL_INC, 12 IP6T_HL_INC,
@@ -14,8 +16,8 @@ enum {
14#define IP6T_HL_MAXMODE IP6T_HL_DEC 16#define IP6T_HL_MAXMODE IP6T_HL_DEC
15 17
16struct ip6t_HL_info { 18struct ip6t_HL_info {
17 u_int8_t mode; 19 __u8 mode;
18 u_int8_t hop_limit; 20 __u8 hop_limit;
19}; 21};
20 22
21 23
diff --git a/include/linux/netfilter_ipv6/ip6t_REJECT.h b/include/linux/netfilter_ipv6/ip6t_REJECT.h
index 6be6504162bb..205ed62e4605 100644
--- a/include/linux/netfilter_ipv6/ip6t_REJECT.h
+++ b/include/linux/netfilter_ipv6/ip6t_REJECT.h
@@ -1,6 +1,8 @@
1#ifndef _IP6T_REJECT_H 1#ifndef _IP6T_REJECT_H
2#define _IP6T_REJECT_H 2#define _IP6T_REJECT_H
3 3
4#include <linux/types.h>
5
4enum ip6t_reject_with { 6enum ip6t_reject_with {
5 IP6T_ICMP6_NO_ROUTE, 7 IP6T_ICMP6_NO_ROUTE,
6 IP6T_ICMP6_ADM_PROHIBITED, 8 IP6T_ICMP6_ADM_PROHIBITED,
@@ -12,7 +14,7 @@ enum ip6t_reject_with {
12}; 14};
13 15
14struct ip6t_reject_info { 16struct ip6t_reject_info {
15 u_int32_t with; /* reject type */ 17 __u32 with; /* reject type */
16}; 18};
17 19
18#endif /*_IP6T_REJECT_H*/ 20#endif /*_IP6T_REJECT_H*/
diff --git a/include/linux/netfilter_ipv6/ip6t_ah.h b/include/linux/netfilter_ipv6/ip6t_ah.h
index 17a745cfb2c7..5da2b65cb3ad 100644
--- a/include/linux/netfilter_ipv6/ip6t_ah.h
+++ b/include/linux/netfilter_ipv6/ip6t_ah.h
@@ -1,11 +1,13 @@
1#ifndef _IP6T_AH_H 1#ifndef _IP6T_AH_H
2#define _IP6T_AH_H 2#define _IP6T_AH_H
3 3
4#include <linux/types.h>
5
4struct ip6t_ah { 6struct ip6t_ah {
5 u_int32_t spis[2]; /* Security Parameter Index */ 7 __u32 spis[2]; /* Security Parameter Index */
6 u_int32_t hdrlen; /* Header Length */ 8 __u32 hdrlen; /* Header Length */
7 u_int8_t hdrres; /* Test of the Reserved Filed */ 9 __u8 hdrres; /* Test of the Reserved Filed */
8 u_int8_t invflags; /* Inverse flags */ 10 __u8 invflags; /* Inverse flags */
9}; 11};
10 12
11#define IP6T_AH_SPI 0x01 13#define IP6T_AH_SPI 0x01
diff --git a/include/linux/netfilter_ipv6/ip6t_frag.h b/include/linux/netfilter_ipv6/ip6t_frag.h
index 3724d0850920..b47f61b9e082 100644
--- a/include/linux/netfilter_ipv6/ip6t_frag.h
+++ b/include/linux/netfilter_ipv6/ip6t_frag.h
@@ -1,11 +1,13 @@
1#ifndef _IP6T_FRAG_H 1#ifndef _IP6T_FRAG_H
2#define _IP6T_FRAG_H 2#define _IP6T_FRAG_H
3 3
4#include <linux/types.h>
5
4struct ip6t_frag { 6struct ip6t_frag {
5 u_int32_t ids[2]; /* Security Parameter Index */ 7 __u32 ids[2]; /* Security Parameter Index */
6 u_int32_t hdrlen; /* Header Length */ 8 __u32 hdrlen; /* Header Length */
7 u_int8_t flags; /* */ 9 __u8 flags; /* */
8 u_int8_t invflags; /* Inverse flags */ 10 __u8 invflags; /* Inverse flags */
9}; 11};
10 12
11#define IP6T_FRAG_IDS 0x01 13#define IP6T_FRAG_IDS 0x01
diff --git a/include/linux/netfilter_ipv6/ip6t_hl.h b/include/linux/netfilter_ipv6/ip6t_hl.h
index 5ef91b8319a8..6e76dbc6c19a 100644
--- a/include/linux/netfilter_ipv6/ip6t_hl.h
+++ b/include/linux/netfilter_ipv6/ip6t_hl.h
@@ -5,6 +5,8 @@
5#ifndef _IP6T_HL_H 5#ifndef _IP6T_HL_H
6#define _IP6T_HL_H 6#define _IP6T_HL_H
7 7
8#include <linux/types.h>
9
8enum { 10enum {
9 IP6T_HL_EQ = 0, /* equals */ 11 IP6T_HL_EQ = 0, /* equals */
10 IP6T_HL_NE, /* not equals */ 12 IP6T_HL_NE, /* not equals */
@@ -14,8 +16,8 @@ enum {
14 16
15 17
16struct ip6t_hl_info { 18struct ip6t_hl_info {
17 u_int8_t mode; 19 __u8 mode;
18 u_int8_t hop_limit; 20 __u8 hop_limit;
19}; 21};
20 22
21 23
diff --git a/include/linux/netfilter_ipv6/ip6t_ipv6header.h b/include/linux/netfilter_ipv6/ip6t_ipv6header.h
index 01dfd445596a..efae3a20c214 100644
--- a/include/linux/netfilter_ipv6/ip6t_ipv6header.h
+++ b/include/linux/netfilter_ipv6/ip6t_ipv6header.h
@@ -8,10 +8,12 @@ on whether they contain certain headers */
8#ifndef __IPV6HEADER_H 8#ifndef __IPV6HEADER_H
9#define __IPV6HEADER_H 9#define __IPV6HEADER_H
10 10
11#include <linux/types.h>
12
11struct ip6t_ipv6header_info { 13struct ip6t_ipv6header_info {
12 u_int8_t matchflags; 14 __u8 matchflags;
13 u_int8_t invflags; 15 __u8 invflags;
14 u_int8_t modeflag; 16 __u8 modeflag;
15}; 17};
16 18
17#define MASK_HOPOPTS 128 19#define MASK_HOPOPTS 128
diff --git a/include/linux/netfilter_ipv6/ip6t_mh.h b/include/linux/netfilter_ipv6/ip6t_mh.h
index 18549bca2d1f..a7729a5025cd 100644
--- a/include/linux/netfilter_ipv6/ip6t_mh.h
+++ b/include/linux/netfilter_ipv6/ip6t_mh.h
@@ -1,10 +1,12 @@
1#ifndef _IP6T_MH_H 1#ifndef _IP6T_MH_H
2#define _IP6T_MH_H 2#define _IP6T_MH_H
3 3
4#include <linux/types.h>
5
4/* MH matching stuff */ 6/* MH matching stuff */
5struct ip6t_mh { 7struct ip6t_mh {
6 u_int8_t types[2]; /* MH type range */ 8 __u8 types[2]; /* MH type range */
7 u_int8_t invflags; /* Inverse flags */ 9 __u8 invflags; /* Inverse flags */
8}; 10};
9 11
10/* Values for "invflags" field in struct ip6t_mh. */ 12/* Values for "invflags" field in struct ip6t_mh. */
diff --git a/include/linux/netfilter_ipv6/ip6t_opts.h b/include/linux/netfilter_ipv6/ip6t_opts.h
index 62d89bcd9f9c..17d419a811fd 100644
--- a/include/linux/netfilter_ipv6/ip6t_opts.h
+++ b/include/linux/netfilter_ipv6/ip6t_opts.h
@@ -1,14 +1,16 @@
1#ifndef _IP6T_OPTS_H 1#ifndef _IP6T_OPTS_H
2#define _IP6T_OPTS_H 2#define _IP6T_OPTS_H
3 3
4#include <linux/types.h>
5
4#define IP6T_OPTS_OPTSNR 16 6#define IP6T_OPTS_OPTSNR 16
5 7
6struct ip6t_opts { 8struct ip6t_opts {
7 u_int32_t hdrlen; /* Header Length */ 9 __u32 hdrlen; /* Header Length */
8 u_int8_t flags; /* */ 10 __u8 flags; /* */
9 u_int8_t invflags; /* Inverse flags */ 11 __u8 invflags; /* Inverse flags */
10 u_int16_t opts[IP6T_OPTS_OPTSNR]; /* opts */ 12 __u16 opts[IP6T_OPTS_OPTSNR]; /* opts */
11 u_int8_t optsnr; /* Nr of OPts */ 13 __u8 optsnr; /* Nr of OPts */
12}; 14};
13 15
14#define IP6T_OPTS_LEN 0x01 16#define IP6T_OPTS_LEN 0x01
diff --git a/include/linux/netfilter_ipv6/ip6t_rt.h b/include/linux/netfilter_ipv6/ip6t_rt.h
index ab91bfd2cd00..7605a5ff81cd 100644
--- a/include/linux/netfilter_ipv6/ip6t_rt.h
+++ b/include/linux/netfilter_ipv6/ip6t_rt.h
@@ -1,18 +1,19 @@
1#ifndef _IP6T_RT_H 1#ifndef _IP6T_RT_H
2#define _IP6T_RT_H 2#define _IP6T_RT_H
3 3
4#include <linux/types.h>
4/*#include <linux/in6.h>*/ 5/*#include <linux/in6.h>*/
5 6
6#define IP6T_RT_HOPS 16 7#define IP6T_RT_HOPS 16
7 8
8struct ip6t_rt { 9struct ip6t_rt {
9 u_int32_t rt_type; /* Routing Type */ 10 __u32 rt_type; /* Routing Type */
10 u_int32_t segsleft[2]; /* Segments Left */ 11 __u32 segsleft[2]; /* Segments Left */
11 u_int32_t hdrlen; /* Header Length */ 12 __u32 hdrlen; /* Header Length */
12 u_int8_t flags; /* */ 13 __u8 flags; /* */
13 u_int8_t invflags; /* Inverse flags */ 14 __u8 invflags; /* Inverse flags */
14 struct in6_addr addrs[IP6T_RT_HOPS]; /* Hops */ 15 struct in6_addr addrs[IP6T_RT_HOPS]; /* Hops */
15 u_int8_t addrnr; /* Nr of Addresses */ 16 __u8 addrnr; /* Nr of Addresses */
16}; 17};
17 18
18#define IP6T_RT_TYP 0x01 19#define IP6T_RT_TYP 0x01
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 123566912d73..a9dd89552f9c 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -24,6 +24,7 @@
24/* leave room for NETLINK_DM (DM Events) */ 24/* leave room for NETLINK_DM (DM Events) */
25#define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */ 25#define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */
26#define NETLINK_ECRYPTFS 19 26#define NETLINK_ECRYPTFS 19
27#define NETLINK_RDMA 20
27 28
28#define MAX_LINKS 32 29#define MAX_LINKS 32
29 30
@@ -70,7 +71,7 @@ struct nlmsghdr {
70 Check NLM_F_EXCL 71 Check NLM_F_EXCL
71 */ 72 */
72 73
73#define NLMSG_ALIGNTO 4 74#define NLMSG_ALIGNTO 4U
74#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) ) 75#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
75#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) 76#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
76#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN)) 77#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
@@ -160,10 +161,6 @@ struct netlink_skb_parms {
160 struct ucred creds; /* Skb credentials */ 161 struct ucred creds; /* Skb credentials */
161 __u32 pid; 162 __u32 pid;
162 __u32 dst_group; 163 __u32 dst_group;
163 kernel_cap_t eff_cap;
164 __u32 loginuid; /* Login (audit) uid */
165 __u32 sessionid; /* Session id (audit) */
166 __u32 sid; /* SELinux security id */
167}; 164};
168 165
169#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb)) 166#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 50d8009be86c..79358bb712c6 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -14,7 +14,6 @@
14 14
15struct netpoll { 15struct netpoll {
16 struct net_device *dev; 16 struct net_device *dev;
17 struct net_device *real_dev;
18 char dev_name[IFNAMSIZ]; 17 char dev_name[IFNAMSIZ];
19 const char *name; 18 const char *name;
20 void (*rx_hook)(struct netpoll *, int, char *, int); 19 void (*rx_hook)(struct netpoll *, int, char *, int);
@@ -53,7 +52,13 @@ void netpoll_set_trap(int trap);
53void __netpoll_cleanup(struct netpoll *np); 52void __netpoll_cleanup(struct netpoll *np);
54void netpoll_cleanup(struct netpoll *np); 53void netpoll_cleanup(struct netpoll *np);
55int __netpoll_rx(struct sk_buff *skb); 54int __netpoll_rx(struct sk_buff *skb);
56void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); 55void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
56 struct net_device *dev);
57static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
58{
59 netpoll_send_skb_on_dev(np, skb, np->dev);
60}
61
57 62
58 63
59#ifdef CONFIG_NETPOLL 64#ifdef CONFIG_NETPOLL
diff --git a/include/linux/nfc/pn544.h b/include/linux/nfc/pn544.h
new file mode 100644
index 000000000000..7ab8521f2347
--- /dev/null
+++ b/include/linux/nfc/pn544.h
@@ -0,0 +1,97 @@
1/*
2 * Driver include for the PN544 NFC chip.
3 *
4 * Copyright (C) Nokia Corporation
5 *
6 * Author: Jari Vanhala <ext-jari.vanhala@nokia.com>
7 * Contact: Matti Aaltoenn <matti.j.aaltonen@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef _PN544_H_
24#define _PN544_H_
25
26#include <linux/i2c.h>
27
28#define PN544_DRIVER_NAME "pn544"
29#define PN544_MAXWINDOW_SIZE 7
30#define PN544_WINDOW_SIZE 4
31#define PN544_RETRIES 10
32#define PN544_MAX_I2C_TRANSFER 0x0400
33#define PN544_MSG_MAX_SIZE 0x21 /* at normal HCI mode */
34
35/* ioctl */
36#define PN544_CHAR_BASE 'P'
37#define PN544_IOR(num, dtype) _IOR(PN544_CHAR_BASE, num, dtype)
38#define PN544_IOW(num, dtype) _IOW(PN544_CHAR_BASE, num, dtype)
39#define PN544_GET_FW_MODE PN544_IOW(1, unsigned int)
40#define PN544_SET_FW_MODE PN544_IOW(2, unsigned int)
41#define PN544_GET_DEBUG PN544_IOW(3, unsigned int)
42#define PN544_SET_DEBUG PN544_IOW(4, unsigned int)
43
44/* Timing restrictions (ms) */
45#define PN544_RESETVEN_TIME 30 /* 7 */
46#define PN544_PVDDVEN_TIME 0
47#define PN544_VBATVEN_TIME 0
48#define PN544_GPIO4VEN_TIME 0
49#define PN544_WAKEUP_ACK 5
50#define PN544_WAKEUP_GUARD (PN544_WAKEUP_ACK + 1)
51#define PN544_INACTIVITY_TIME 1000
52#define PN544_INTERFRAME_DELAY 200 /* us */
53#define PN544_BAUDRATE_CHANGE 150 /* us */
54
55/* Debug bits */
56#define PN544_DEBUG_BUF 0x01
57#define PN544_DEBUG_READ 0x02
58#define PN544_DEBUG_WRITE 0x04
59#define PN544_DEBUG_IRQ 0x08
60#define PN544_DEBUG_CALLS 0x10
61#define PN544_DEBUG_MODE 0x20
62
63/* Normal (HCI) mode */
64#define PN544_LLC_HCI_OVERHEAD 3 /* header + crc (to length) */
65#define PN544_LLC_MIN_SIZE (1 + PN544_LLC_HCI_OVERHEAD) /* length + */
66#define PN544_LLC_MAX_DATA (PN544_MSG_MAX_SIZE - 2)
67#define PN544_LLC_MAX_HCI_SIZE (PN544_LLC_MAX_DATA - 2)
68
69struct pn544_llc_packet {
70 unsigned char length; /* of rest of packet */
71 unsigned char header;
72 unsigned char data[PN544_LLC_MAX_DATA]; /* includes crc-ccitt */
73};
74
75/* Firmware upgrade mode */
76#define PN544_FW_HEADER_SIZE 3
77/* max fw transfer is 1024bytes, but I2C limits it to 0xC0 */
78#define PN544_MAX_FW_DATA (PN544_MAX_I2C_TRANSFER - PN544_FW_HEADER_SIZE)
79
80struct pn544_fw_packet {
81 unsigned char command; /* status in answer */
82 unsigned char length[2]; /* big-endian order (msf) */
83 unsigned char data[PN544_MAX_FW_DATA];
84};
85
86#ifdef __KERNEL__
87/* board config */
88struct pn544_nfc_platform_data {
89 int (*request_resources) (struct i2c_client *client);
90 void (*free_resources) (void);
91 void (*enable) (int fw);
92 int (*test) (void);
93 void (*disable) (void);
94};
95#endif /* __KERNEL__ */
96
97#endif /* _PN544_H_ */
diff --git a/include/linux/nfs3.h b/include/linux/nfs3.h
index ac33806ec7f9..6ccfe3b641e1 100644
--- a/include/linux/nfs3.h
+++ b/include/linux/nfs3.h
@@ -11,6 +11,9 @@
11#define NFS3_MAXGROUPS 16 11#define NFS3_MAXGROUPS 16
12#define NFS3_FHSIZE 64 12#define NFS3_FHSIZE 64
13#define NFS3_COOKIESIZE 4 13#define NFS3_COOKIESIZE 4
14#define NFS3_CREATEVERFSIZE 8
15#define NFS3_COOKIEVERFSIZE 8
16#define NFS3_WRITEVERFSIZE 8
14#define NFS3_FIFO_DEV (-1) 17#define NFS3_FIFO_DEV (-1)
15#define NFS3MODE_FMT 0170000 18#define NFS3MODE_FMT 0170000
16#define NFS3MODE_DIR 0040000 19#define NFS3MODE_DIR 0040000
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
index 07e40c625972..504b289ba680 100644
--- a/include/linux/nfs4.h
+++ b/include/linux/nfs4.h
@@ -17,7 +17,9 @@
17 17
18#define NFS4_BITMAP_SIZE 2 18#define NFS4_BITMAP_SIZE 2
19#define NFS4_VERIFIER_SIZE 8 19#define NFS4_VERIFIER_SIZE 8
20#define NFS4_STATEID_SIZE 16 20#define NFS4_STATEID_SEQID_SIZE 4
21#define NFS4_STATEID_OTHER_SIZE 12
22#define NFS4_STATEID_SIZE (NFS4_STATEID_SEQID_SIZE + NFS4_STATEID_OTHER_SIZE)
21#define NFS4_FHSIZE 128 23#define NFS4_FHSIZE 128
22#define NFS4_MAXPATHLEN PATH_MAX 24#define NFS4_MAXPATHLEN PATH_MAX
23#define NFS4_MAXNAMLEN NAME_MAX 25#define NFS4_MAXNAMLEN NAME_MAX
@@ -61,6 +63,12 @@
61#define NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL 0x10000 63#define NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL 0x10000
62#define NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED 0x20000 64#define NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED 0x20000
63 65
66#define NFS4_CDFC4_FORE 0x1
67#define NFS4_CDFC4_BACK 0x2
68#define NFS4_CDFC4_BOTH 0x3
69#define NFS4_CDFC4_FORE_OR_BOTH 0x3
70#define NFS4_CDFC4_BACK_OR_BOTH 0x7
71
64#define NFS4_SET_TO_SERVER_TIME 0 72#define NFS4_SET_TO_SERVER_TIME 0
65#define NFS4_SET_TO_CLIENT_TIME 1 73#define NFS4_SET_TO_CLIENT_TIME 1
66 74
@@ -106,9 +114,13 @@
106 114
107#define EXCHGID4_FLAG_SUPP_MOVED_REFER 0x00000001 115#define EXCHGID4_FLAG_SUPP_MOVED_REFER 0x00000001
108#define EXCHGID4_FLAG_SUPP_MOVED_MIGR 0x00000002 116#define EXCHGID4_FLAG_SUPP_MOVED_MIGR 0x00000002
117#define EXCHGID4_FLAG_BIND_PRINC_STATEID 0x00000100
118
109#define EXCHGID4_FLAG_USE_NON_PNFS 0x00010000 119#define EXCHGID4_FLAG_USE_NON_PNFS 0x00010000
110#define EXCHGID4_FLAG_USE_PNFS_MDS 0x00020000 120#define EXCHGID4_FLAG_USE_PNFS_MDS 0x00020000
111#define EXCHGID4_FLAG_USE_PNFS_DS 0x00040000 121#define EXCHGID4_FLAG_USE_PNFS_DS 0x00040000
122#define EXCHGID4_FLAG_MASK_PNFS 0x00070000
123
112#define EXCHGID4_FLAG_UPD_CONFIRMED_REC_A 0x40000000 124#define EXCHGID4_FLAG_UPD_CONFIRMED_REC_A 0x40000000
113#define EXCHGID4_FLAG_CONFIRMED_R 0x80000000 125#define EXCHGID4_FLAG_CONFIRMED_R 0x80000000
114/* 126/*
@@ -116,8 +128,8 @@
116 * they're set in the argument or response, have separate 128 * they're set in the argument or response, have separate
117 * invalid flag masks for arg (_A) and resp (_R). 129 * invalid flag masks for arg (_A) and resp (_R).
118 */ 130 */
119#define EXCHGID4_FLAG_MASK_A 0x40070003 131#define EXCHGID4_FLAG_MASK_A 0x40070103
120#define EXCHGID4_FLAG_MASK_R 0x80070003 132#define EXCHGID4_FLAG_MASK_R 0x80070103
121 133
122#define SEQ4_STATUS_CB_PATH_DOWN 0x00000001 134#define SEQ4_STATUS_CB_PATH_DOWN 0x00000001
123#define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING 0x00000002 135#define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING 0x00000002
@@ -131,6 +143,9 @@
131#define SEQ4_STATUS_CB_PATH_DOWN_SESSION 0x00000200 143#define SEQ4_STATUS_CB_PATH_DOWN_SESSION 0x00000200
132#define SEQ4_STATUS_BACKCHANNEL_FAULT 0x00000400 144#define SEQ4_STATUS_BACKCHANNEL_FAULT 0x00000400
133 145
146#define NFS4_SECINFO_STYLE4_CURRENT_FH 0
147#define NFS4_SECINFO_STYLE4_PARENT 1
148
134#define NFS4_MAX_UINT64 (~(u64)0) 149#define NFS4_MAX_UINT64 (~(u64)0)
135 150
136/* An NFS4 sessions server must support at least NFS4_MAX_OPS operations. 151/* An NFS4 sessions server must support at least NFS4_MAX_OPS operations.
@@ -167,7 +182,16 @@ struct nfs4_acl {
167}; 182};
168 183
169typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier; 184typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
170typedef struct { char data[NFS4_STATEID_SIZE]; } nfs4_stateid; 185
186struct nfs41_stateid {
187 __be32 seqid;
188 char other[NFS4_STATEID_OTHER_SIZE];
189} __attribute__ ((packed));
190
191typedef union {
192 char data[NFS4_STATEID_SIZE];
193 struct nfs41_stateid stateid;
194} nfs4_stateid;
171 195
172enum nfs_opnum4 { 196enum nfs_opnum4 {
173 OP_ACCESS = 3, 197 OP_ACCESS = 3,
@@ -335,7 +359,7 @@ enum nfsstat4 {
335 /* Error 10073 is unused. */ 359 /* Error 10073 is unused. */
336 NFS4ERR_CLIENTID_BUSY = 10074, /* clientid has state */ 360 NFS4ERR_CLIENTID_BUSY = 10074, /* clientid has state */
337 NFS4ERR_PNFS_IO_HOLE = 10075, /* IO to _SPARSE file hole */ 361 NFS4ERR_PNFS_IO_HOLE = 10075, /* IO to _SPARSE file hole */
338 NFS4ERR_SEQ_FALSE_RETRY = 10076, /* retry not origional */ 362 NFS4ERR_SEQ_FALSE_RETRY = 10076, /* retry not original */
339 NFS4ERR_BAD_HIGH_SLOT = 10077, /* sequence arg bad */ 363 NFS4ERR_BAD_HIGH_SLOT = 10077, /* sequence arg bad */
340 NFS4ERR_DEADSESSION = 10078, /* persistent session dead */ 364 NFS4ERR_DEADSESSION = 10078, /* persistent session dead */
341 NFS4ERR_ENCR_ALG_UNSUPP = 10079, /* SSV alg mismatch */ 365 NFS4ERR_ENCR_ALG_UNSUPP = 10079, /* SSV alg mismatch */
@@ -471,6 +495,8 @@ enum lock_type4 {
471#define FATTR4_WORD1_TIME_MODIFY (1UL << 21) 495#define FATTR4_WORD1_TIME_MODIFY (1UL << 21)
472#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22) 496#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22)
473#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23) 497#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23)
498#define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30)
499#define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)
474 500
475#define NFSPROC4_NULL 0 501#define NFSPROC4_NULL 0
476#define NFSPROC4_COMPOUND 1 502#define NFSPROC4_COMPOUND 1
@@ -524,6 +550,7 @@ enum {
524 NFSPROC4_CLNT_SETACL, 550 NFSPROC4_CLNT_SETACL,
525 NFSPROC4_CLNT_FS_LOCATIONS, 551 NFSPROC4_CLNT_FS_LOCATIONS,
526 NFSPROC4_CLNT_RELEASE_LOCKOWNER, 552 NFSPROC4_CLNT_RELEASE_LOCKOWNER,
553 NFSPROC4_CLNT_SECINFO,
527 554
528 /* nfs41 */ 555 /* nfs41 */
529 NFSPROC4_CLNT_EXCHANGE_ID, 556 NFSPROC4_CLNT_EXCHANGE_ID,
@@ -532,6 +559,10 @@ enum {
532 NFSPROC4_CLNT_SEQUENCE, 559 NFSPROC4_CLNT_SEQUENCE,
533 NFSPROC4_CLNT_GET_LEASE_TIME, 560 NFSPROC4_CLNT_GET_LEASE_TIME,
534 NFSPROC4_CLNT_RECLAIM_COMPLETE, 561 NFSPROC4_CLNT_RECLAIM_COMPLETE,
562 NFSPROC4_CLNT_LAYOUTGET,
563 NFSPROC4_CLNT_GETDEVICEINFO,
564 NFSPROC4_CLNT_LAYOUTCOMMIT,
565 NFSPROC4_CLNT_LAYOUTRETURN,
535}; 566};
536 567
537/* nfs41 types */ 568/* nfs41 types */
@@ -540,9 +571,11 @@ struct nfs4_sessionid {
540}; 571};
541 572
542/* Create Session Flags */ 573/* Create Session Flags */
543#define SESSION4_PERSIST 0x001 574#define SESSION4_PERSIST 0x001
544#define SESSION4_BACK_CHAN 0x002 575#define SESSION4_BACK_CHAN 0x002
545#define SESSION4_RDMA 0x004 576#define SESSION4_RDMA 0x004
577
578#define SESSION4_FLAG_MASK_A 0x007
546 579
547enum state_protect_how4 { 580enum state_protect_how4 {
548 SP4_NONE = 0, 581 SP4_NONE = 0,
@@ -550,6 +583,49 @@ enum state_protect_how4 {
550 SP4_SSV = 2 583 SP4_SSV = 2
551}; 584};
552 585
586enum pnfs_layouttype {
587 LAYOUT_NFSV4_1_FILES = 1,
588 LAYOUT_OSD2_OBJECTS = 2,
589 LAYOUT_BLOCK_VOLUME = 3,
590};
591
592/* used for both layout return and recall */
593enum pnfs_layoutreturn_type {
594 RETURN_FILE = 1,
595 RETURN_FSID = 2,
596 RETURN_ALL = 3
597};
598
599enum pnfs_iomode {
600 IOMODE_READ = 1,
601 IOMODE_RW = 2,
602 IOMODE_ANY = 3,
603};
604
605enum pnfs_notify_deviceid_type4 {
606 NOTIFY_DEVICEID4_CHANGE = 1 << 1,
607 NOTIFY_DEVICEID4_DELETE = 1 << 2,
608};
609
610#define NFL4_UFLG_MASK 0x0000003F
611#define NFL4_UFLG_DENSE 0x00000001
612#define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002
613#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0
614
615/* Encoded in the loh_body field of type layouthint4 */
616enum filelayout_hint_care4 {
617 NFLH4_CARE_DENSE = NFL4_UFLG_DENSE,
618 NFLH4_CARE_COMMIT_THRU_MDS = NFL4_UFLG_COMMIT_THRU_MDS,
619 NFLH4_CARE_STRIPE_UNIT_SIZE = 0x00000040,
620 NFLH4_CARE_STRIPE_COUNT = 0x00000080
621};
622
623#define NFS4_DEVICEID4_SIZE 16
624
625struct nfs4_deviceid {
626 char data[NFS4_DEVICEID4_SIZE];
627};
628
553#endif 629#endif
554#endif 630#endif
555 631
diff --git a/include/linux/nfs4_acl.h b/include/linux/nfs4_acl.h
deleted file mode 100644
index c9c05a78e9bb..000000000000
--- a/include/linux/nfs4_acl.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * include/linux/nfs4_acl.c
3 *
4 * Common NFSv4 ACL handling definitions.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Marius Aamodt Eriksen <marius@umich.edu>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef LINUX_NFS4_ACL_H
38#define LINUX_NFS4_ACL_H
39
40#include <linux/posix_acl.h>
41
42/* Maximum ACL we'll accept from client; chosen (somewhat arbitrarily) to
43 * fit in a page: */
44#define NFS4_ACL_MAX 170
45
46struct nfs4_acl *nfs4_acl_new(int);
47int nfs4_acl_get_whotype(char *, u32);
48int nfs4_acl_write_who(int who, char *p);
49int nfs4_acl_permission(struct nfs4_acl *acl, uid_t owner, gid_t group,
50 uid_t who, u32 mask);
51
52#define NFS4_ACL_TYPE_DEFAULT 0x01
53#define NFS4_ACL_DIR 0x02
54#define NFS4_ACL_OWNER 0x04
55
56struct nfs4_acl *nfs4_acl_posix_to_nfsv4(struct posix_acl *,
57 struct posix_acl *, unsigned int flags);
58int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *, struct posix_acl **,
59 struct posix_acl **, unsigned int flags);
60
61#endif /* LINUX_NFS4_ACL_H */
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 508f8cf6da37..1b93b9c60e55 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -33,6 +33,8 @@
33#define FLUSH_STABLE 4 /* commit to stable storage */ 33#define FLUSH_STABLE 4 /* commit to stable storage */
34#define FLUSH_LOWPRI 8 /* low priority background flush */ 34#define FLUSH_LOWPRI 8 /* low priority background flush */
35#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */ 35#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */
36#define FLUSH_COND_STABLE 32 /* conditional stable write - only stable
37 * if everything fits in one RPC */
36 38
37#ifdef __KERNEL__ 39#ifdef __KERNEL__
38 40
@@ -93,8 +95,13 @@ struct nfs_open_context {
93 int error; 95 int error;
94 96
95 struct list_head list; 97 struct list_head list;
98};
96 99
100struct nfs_open_dir_context {
101 struct rpc_cred *cred;
97 __u64 dir_cookie; 102 __u64 dir_cookie;
103 __u64 dup_cookie;
104 int duped;
98}; 105};
99 106
100/* 107/*
@@ -185,9 +192,13 @@ struct nfs_inode {
185 struct nfs4_cached_acl *nfs4_acl; 192 struct nfs4_cached_acl *nfs4_acl;
186 /* NFSv4 state */ 193 /* NFSv4 state */
187 struct list_head open_states; 194 struct list_head open_states;
188 struct nfs_delegation *delegation; 195 struct nfs_delegation __rcu *delegation;
189 fmode_t delegation_state; 196 fmode_t delegation_state;
190 struct rw_semaphore rwsem; 197 struct rw_semaphore rwsem;
198
199 /* pNFS layout information */
200 struct pnfs_layout_hdr *layout;
201 atomic_t commits_outstanding;
191#endif /* CONFIG_NFS_V4*/ 202#endif /* CONFIG_NFS_V4*/
192#ifdef CONFIG_NFS_FSCACHE 203#ifdef CONFIG_NFS_FSCACHE
193 struct fscache_cookie *fscache; 204 struct fscache_cookie *fscache;
@@ -212,11 +223,12 @@ struct nfs_inode {
212#define NFS_INO_ADVISE_RDPLUS (0) /* advise readdirplus */ 223#define NFS_INO_ADVISE_RDPLUS (0) /* advise readdirplus */
213#define NFS_INO_STALE (1) /* possible stale inode */ 224#define NFS_INO_STALE (1) /* possible stale inode */
214#define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */ 225#define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */
215#define NFS_INO_MOUNTPOINT (3) /* inode is remote mountpoint */
216#define NFS_INO_FLUSHING (4) /* inode is flushing out data */ 226#define NFS_INO_FLUSHING (4) /* inode is flushing out data */
217#define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */ 227#define NFS_INO_FSCACHE (5) /* inode can be cached by FS-Cache */
218#define NFS_INO_FSCACHE_LOCK (6) /* FS-Cache cookie management lock */ 228#define NFS_INO_FSCACHE_LOCK (6) /* FS-Cache cookie management lock */
219#define NFS_INO_COMMIT (7) /* inode is committing unstable writes */ 229#define NFS_INO_COMMIT (7) /* inode is committing unstable writes */
230#define NFS_INO_PNFS_COMMIT (8) /* use pnfs code for commit */
231#define NFS_INO_LAYOUTCOMMIT (9) /* layoutcommit required */
220 232
221static inline struct nfs_inode *NFS_I(const struct inode *inode) 233static inline struct nfs_inode *NFS_I(const struct inode *inode)
222{ 234{
@@ -348,7 +360,7 @@ extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
348extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr); 360extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
349extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr); 361extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
350extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 362extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
351extern int nfs_permission(struct inode *, int); 363extern int nfs_permission(struct inode *, int, unsigned int);
352extern int nfs_open(struct inode *, struct file *); 364extern int nfs_open(struct inode *, struct file *);
353extern int nfs_release(struct inode *, struct file *); 365extern int nfs_release(struct inode *, struct file *);
354extern int nfs_attribute_timeout(struct inode *inode); 366extern int nfs_attribute_timeout(struct inode *inode);
@@ -360,10 +372,13 @@ extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr);
360extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); 372extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
361extern void put_nfs_open_context(struct nfs_open_context *ctx); 373extern void put_nfs_open_context(struct nfs_open_context *ctx);
362extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode); 374extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode);
375extern struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cred *cred, fmode_t f_mode);
376extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
363extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx); 377extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx);
364extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx); 378extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);
365extern u64 nfs_compat_user_ino64(u64 fileid); 379extern u64 nfs_compat_user_ino64(u64 fileid);
366extern void nfs_fattr_init(struct nfs_fattr *fattr); 380extern void nfs_fattr_init(struct nfs_fattr *fattr);
381extern unsigned long nfs_inc_attr_generation_counter(void);
367 382
368extern struct nfs_fattr *nfs_alloc_fattr(void); 383extern struct nfs_fattr *nfs_alloc_fattr(void);
369 384
@@ -379,9 +394,12 @@ static inline void nfs_free_fhandle(const struct nfs_fh *fh)
379 kfree(fh); 394 kfree(fh);
380} 395}
381 396
397/*
398 * linux/fs/nfs/nfsroot.c
399 */
400extern int nfs_root_data(char **root_device, char **root_data); /*__init*/
382/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ 401/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
383extern __be32 root_nfs_parse_addr(char *name); /*__init*/ 402extern __be32 root_nfs_parse_addr(char *name); /*__init*/
384extern unsigned long nfs_inc_attr_generation_counter(void);
385 403
386/* 404/*
387 * linux/fs/nfs/file.c 405 * linux/fs/nfs/file.c
@@ -392,6 +410,7 @@ extern const struct inode_operations nfs3_file_inode_operations;
392#endif /* CONFIG_NFS_V3 */ 410#endif /* CONFIG_NFS_V3 */
393extern const struct file_operations nfs_file_operations; 411extern const struct file_operations nfs_file_operations;
394extern const struct address_space_operations nfs_file_aops; 412extern const struct address_space_operations nfs_file_aops;
413extern const struct address_space_operations nfs_dir_aops;
395 414
396static inline struct nfs_open_context *nfs_file_open_context(struct file *filp) 415static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
397{ 416{
@@ -479,10 +498,10 @@ extern void nfs_release_automount_timer(void);
479/* 498/*
480 * linux/fs/nfs/unlink.c 499 * linux/fs/nfs/unlink.c
481 */ 500 */
482extern int nfs_async_unlink(struct inode *dir, struct dentry *dentry);
483extern void nfs_complete_unlink(struct dentry *dentry, struct inode *); 501extern void nfs_complete_unlink(struct dentry *dentry, struct inode *);
484extern void nfs_block_sillyrename(struct dentry *dentry); 502extern void nfs_block_sillyrename(struct dentry *dentry);
485extern void nfs_unblock_sillyrename(struct dentry *dentry); 503extern void nfs_unblock_sillyrename(struct dentry *dentry);
504extern int nfs_sillyrename(struct inode *dir, struct dentry *dentry);
486 505
487/* 506/*
488 * linux/fs/nfs/write.c 507 * linux/fs/nfs/write.c
@@ -492,7 +511,7 @@ extern int nfs_writepage(struct page *page, struct writeback_control *wbc);
492extern int nfs_writepages(struct address_space *, struct writeback_control *); 511extern int nfs_writepages(struct address_space *, struct writeback_control *);
493extern int nfs_flush_incompatible(struct file *file, struct page *page); 512extern int nfs_flush_incompatible(struct file *file, struct page *page);
494extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int); 513extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
495extern int nfs_writeback_done(struct rpc_task *, struct nfs_write_data *); 514extern void nfs_writeback_done(struct rpc_task *, struct nfs_write_data *);
496 515
497/* 516/*
498 * Try to write back everything synchronously (but check the 517 * Try to write back everything synchronously (but check the
@@ -584,16 +603,6 @@ nfs_fileid_to_ino_t(u64 fileid)
584 return ino; 603 return ino;
585} 604}
586 605
587/* NFS root */
588
589extern void * nfs_root_data(void);
590
591#define nfs_wait_event(clnt, wq, condition) \
592({ \
593 int __retval = wait_event_killable(wq, condition); \
594 __retval; \
595})
596
597#define NFS_JUKEBOX_RETRY_TIME (5 * HZ) 606#define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
598 607
599#endif /* __KERNEL__ */ 608#endif /* __KERNEL__ */
@@ -613,6 +622,8 @@ extern void * nfs_root_data(void);
613#define NFSDBG_CLIENT 0x0200 622#define NFSDBG_CLIENT 0x0200
614#define NFSDBG_MOUNT 0x0400 623#define NFSDBG_MOUNT 0x0400
615#define NFSDBG_FSCACHE 0x0800 624#define NFSDBG_FSCACHE 0x0800
625#define NFSDBG_PNFS 0x1000
626#define NFSDBG_PNFS_LD 0x2000
616#define NFSDBG_ALL 0xFFFF 627#define NFSDBG_ALL 0xFFFF
617 628
618#ifdef __KERNEL__ 629#ifdef __KERNEL__
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index c82ee7cd6288..87694ca86914 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -30,6 +30,8 @@ struct nfs_client {
30#define NFS_CS_CALLBACK 1 /* - callback started */ 30#define NFS_CS_CALLBACK 1 /* - callback started */
31#define NFS_CS_IDMAP 2 /* - idmap started */ 31#define NFS_CS_IDMAP 2 /* - idmap started */
32#define NFS_CS_RENEWD 3 /* - renewd started */ 32#define NFS_CS_RENEWD 3 /* - renewd started */
33#define NFS_CS_STOP_RENEW 4 /* no more state to renew */
34#define NFS_CS_CHECK_LEASE_TIME 5 /* need to check lease time */
33 struct sockaddr_storage cl_addr; /* server identifier */ 35 struct sockaddr_storage cl_addr; /* server identifier */
34 size_t cl_addrlen; 36 size_t cl_addrlen;
35 char * cl_hostname; /* hostname of server */ 37 char * cl_hostname; /* hostname of server */
@@ -45,13 +47,9 @@ struct nfs_client {
45 47
46#ifdef CONFIG_NFS_V4 48#ifdef CONFIG_NFS_V4
47 u64 cl_clientid; /* constant */ 49 u64 cl_clientid; /* constant */
50 nfs4_verifier cl_confirm; /* Clientid verifier */
48 unsigned long cl_state; 51 unsigned long cl_state;
49 52
50 struct rb_root cl_openowner_id;
51 struct rb_root cl_lockowner_id;
52
53 struct list_head cl_delegations;
54 struct rb_root cl_state_owners;
55 spinlock_t cl_lock; 53 spinlock_t cl_lock;
56 54
57 unsigned long cl_lease_time; 55 unsigned long cl_lease_time;
@@ -71,18 +69,16 @@ struct nfs_client {
71 */ 69 */
72 char cl_ipaddr[48]; 70 char cl_ipaddr[48];
73 unsigned char cl_id_uniquifier; 71 unsigned char cl_id_uniquifier;
72 u32 cl_cb_ident; /* v4.0 callback identifier */
74 const struct nfs4_minor_version_ops *cl_mvops; 73 const struct nfs4_minor_version_ops *cl_mvops;
75#endif /* CONFIG_NFS_V4 */
76 74
77#ifdef CONFIG_NFS_V4_1
78 /* clientid returned from EXCHANGE_ID, used by session operations */
79 u64 cl_ex_clid;
80 /* The sequence id to use for the next CREATE_SESSION */ 75 /* The sequence id to use for the next CREATE_SESSION */
81 u32 cl_seqid; 76 u32 cl_seqid;
82 /* The flags used for obtaining the clientid during EXCHANGE_ID */ 77 /* The flags used for obtaining the clientid during EXCHANGE_ID */
83 u32 cl_exchange_flags; 78 u32 cl_exchange_flags;
84 struct nfs4_session *cl_session; /* sharred session */ 79 struct nfs4_session *cl_session; /* sharred session */
85#endif /* CONFIG_NFS_V4_1 */ 80 struct list_head cl_layouts;
81#endif /* CONFIG_NFS_V4 */
86 82
87#ifdef CONFIG_NFS_FSCACHE 83#ifdef CONFIG_NFS_FSCACHE
88 struct fscache_cookie *fscache; /* client index cache cookie */ 84 struct fscache_cookie *fscache; /* client index cache cookie */
@@ -124,6 +120,7 @@ struct nfs_server {
124 120
125 struct nfs_fsid fsid; 121 struct nfs_fsid fsid;
126 __u64 maxfilesize; /* maximum file size */ 122 __u64 maxfilesize; /* maximum file size */
123 struct timespec time_delta; /* smallest time granularity */
127 unsigned long mount_time; /* when this fs was mounted */ 124 unsigned long mount_time; /* when this fs was mounted */
128 dev_t s_dev; /* superblock dev numbers */ 125 dev_t s_dev; /* superblock dev numbers */
129 126
@@ -144,7 +141,15 @@ struct nfs_server {
144 u32 acl_bitmask; /* V4 bitmask representing the ACEs 141 u32 acl_bitmask; /* V4 bitmask representing the ACEs
145 that are supported on this 142 that are supported on this
146 filesystem */ 143 filesystem */
144 struct pnfs_layoutdriver_type *pnfs_curr_ld; /* Active layout driver */
145 struct rpc_wait_queue roc_rpcwaitq;
146
147 /* the following fields are protected by nfs_client->cl_lock */
148 struct rb_root state_owners;
149 struct rb_root openowner_id;
150 struct rb_root lockowner_id;
147#endif 151#endif
152 struct list_head delegations;
148 void (*destroy)(struct nfs_server *); 153 void (*destroy)(struct nfs_server *);
149 154
150 atomic_t active; /* Keep trace of any activity to this server */ 155 atomic_t active; /* Keep trace of any activity to this server */
@@ -173,12 +178,13 @@ struct nfs_server {
173#define NFS_CAP_CTIME (1U << 12) 178#define NFS_CAP_CTIME (1U << 12)
174#define NFS_CAP_MTIME (1U << 13) 179#define NFS_CAP_MTIME (1U << 13)
175#define NFS_CAP_POSIX_LOCK (1U << 14) 180#define NFS_CAP_POSIX_LOCK (1U << 14)
181#define NFS_CAP_UIDGID_NOMAP (1U << 15)
176 182
177 183
178/* maximum number of slots to use */ 184/* maximum number of slots to use */
179#define NFS4_MAX_SLOT_TABLE RPC_MAX_SLOT_TABLE 185#define NFS4_MAX_SLOT_TABLE RPC_MAX_SLOT_TABLE
180 186
181#if defined(CONFIG_NFS_V4_1) 187#if defined(CONFIG_NFS_V4)
182 188
183/* Sessions */ 189/* Sessions */
184#define SLOT_TABLE_SZ (NFS4_MAX_SLOT_TABLE/(8*sizeof(long))) 190#define SLOT_TABLE_SZ (NFS4_MAX_SLOT_TABLE/(8*sizeof(long)))
@@ -192,6 +198,7 @@ struct nfs4_slot_table {
192 * op for dynamic resizing */ 198 * op for dynamic resizing */
193 int target_max_slots; /* Set by CB_RECALL_SLOT as 199 int target_max_slots; /* Set by CB_RECALL_SLOT as
194 * the new max_slots */ 200 * the new max_slots */
201 struct completion complete;
195}; 202};
196 203
197static inline int slot_idx(struct nfs4_slot_table *tbl, struct nfs4_slot *sp) 204static inline int slot_idx(struct nfs4_slot_table *tbl, struct nfs4_slot *sp)
@@ -208,7 +215,6 @@ struct nfs4_session {
208 unsigned long session_state; 215 unsigned long session_state;
209 u32 hash_alg; 216 u32 hash_alg;
210 u32 ssv_len; 217 u32 ssv_len;
211 struct completion complete;
212 218
213 /* The fore and back channel */ 219 /* The fore and back channel */
214 struct nfs4_channel_attrs fc_attrs; 220 struct nfs4_channel_attrs fc_attrs;
@@ -218,5 +224,5 @@ struct nfs4_session {
218 struct nfs_client *clp; 224 struct nfs_client *clp;
219}; 225};
220 226
221#endif /* CONFIG_NFS_V4_1 */ 227#endif /* CONFIG_NFS_V4 */
222#endif 228#endif
diff --git a/include/linux/nfs_idmap.h b/include/linux/nfs_idmap.h
index 91a1c24e0cbf..ae7d6a380dae 100644
--- a/include/linux/nfs_idmap.h
+++ b/include/linux/nfs_idmap.h
@@ -65,14 +65,42 @@ struct idmap_msg {
65 65
66/* Forward declaration to make this header independent of others */ 66/* Forward declaration to make this header independent of others */
67struct nfs_client; 67struct nfs_client;
68struct nfs_server;
69
70#ifdef CONFIG_NFS_USE_NEW_IDMAPPER
71
72int nfs_idmap_init(void);
73void nfs_idmap_quit(void);
74
75static inline int nfs_idmap_new(struct nfs_client *clp)
76{
77 return 0;
78}
79
80static inline void nfs_idmap_delete(struct nfs_client *clp)
81{
82}
83
84#else /* CONFIG_NFS_USE_NEW_IDMAPPER not set */
85
86static inline int nfs_idmap_init(void)
87{
88 return 0;
89}
90
91static inline void nfs_idmap_quit(void)
92{
93}
68 94
69int nfs_idmap_new(struct nfs_client *); 95int nfs_idmap_new(struct nfs_client *);
70void nfs_idmap_delete(struct nfs_client *); 96void nfs_idmap_delete(struct nfs_client *);
71 97
72int nfs_map_name_to_uid(struct nfs_client *, const char *, size_t, __u32 *); 98#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
73int nfs_map_group_to_gid(struct nfs_client *, const char *, size_t, __u32 *); 99
74int nfs_map_uid_to_name(struct nfs_client *, __u32, char *); 100int nfs_map_name_to_uid(const struct nfs_server *, const char *, size_t, __u32 *);
75int nfs_map_gid_to_group(struct nfs_client *, __u32, char *); 101int nfs_map_group_to_gid(const struct nfs_server *, const char *, size_t, __u32 *);
102int nfs_map_uid_to_name(const struct nfs_server *, __u32, char *, size_t);
103int nfs_map_gid_to_group(const struct nfs_server *, __u32, char *, size_t);
76 104
77extern unsigned int nfs_idmap_cache_timeout; 105extern unsigned int nfs_idmap_cache_timeout;
78#endif /* __KERNEL__ */ 106#endif /* __KERNEL__ */
diff --git a/include/linux/nfs_iostat.h b/include/linux/nfs_iostat.h
index 68b10f5f8907..8866bb3502ee 100644
--- a/include/linux/nfs_iostat.h
+++ b/include/linux/nfs_iostat.h
@@ -113,6 +113,8 @@ enum nfs_stat_eventcounters {
113 NFSIOS_SHORTREAD, 113 NFSIOS_SHORTREAD,
114 NFSIOS_SHORTWRITE, 114 NFSIOS_SHORTWRITE,
115 NFSIOS_DELAY, 115 NFSIOS_DELAY,
116 NFSIOS_PNFS_READ,
117 NFSIOS_PNFS_WRITE,
116 __NFSIOS_COUNTSMAX, 118 __NFSIOS_COUNTSMAX,
117}; 119};
118 120
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index 5d59ae861aa6..576bddd72e04 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -71,4 +71,7 @@ struct nfs_mount_data {
71#define NFS_MOUNT_NORESVPORT 0x40000 71#define NFS_MOUNT_NORESVPORT 0x40000
72#define NFS_MOUNT_LEGACY_INTERFACE 0x80000 72#define NFS_MOUNT_LEGACY_INTERFACE 0x80000
73 73
74#define NFS_MOUNT_LOCAL_FLOCK 0x100000
75#define NFS_MOUNT_LOCAL_FCNTL 0x200000
76
74#endif 77#endif
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index f8b60e7f4c44..25311b3bedf8 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -29,14 +29,19 @@
29 */ 29 */
30enum { 30enum {
31 PG_BUSY = 0, 31 PG_BUSY = 0,
32 PG_MAPPED,
32 PG_CLEAN, 33 PG_CLEAN,
33 PG_NEED_COMMIT, 34 PG_NEED_COMMIT,
34 PG_NEED_RESCHED, 35 PG_NEED_RESCHED,
36 PG_PNFS_COMMIT,
35}; 37};
36 38
37struct nfs_inode; 39struct nfs_inode;
38struct nfs_page { 40struct nfs_page {
39 struct list_head wb_list; /* Defines state of page: */ 41 union {
42 struct list_head wb_list; /* Defines state of page: */
43 struct pnfs_layout_segment *wb_commit_lseg; /* Used when PG_PNFS_COMMIT set */
44 };
40 struct page *wb_page; /* page to read in/write out */ 45 struct page *wb_page; /* page to read in/write out */
41 struct nfs_open_context *wb_context; /* File state context info */ 46 struct nfs_open_context *wb_context; /* File state context info */
42 struct nfs_lock_context *wb_lock_context; /* lock context info */ 47 struct nfs_lock_context *wb_lock_context; /* lock context info */
@@ -56,11 +61,14 @@ struct nfs_pageio_descriptor {
56 size_t pg_count; 61 size_t pg_count;
57 size_t pg_bsize; 62 size_t pg_bsize;
58 unsigned int pg_base; 63 unsigned int pg_base;
64 char pg_moreio;
59 65
60 struct inode *pg_inode; 66 struct inode *pg_inode;
61 int (*pg_doio)(struct inode *, struct list_head *, unsigned int, size_t, int); 67 int (*pg_doio)(struct nfs_pageio_descriptor *);
62 int pg_ioflags; 68 int pg_ioflags;
63 int pg_error; 69 int pg_error;
70 struct pnfs_layout_segment *pg_lseg;
71 bool (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
64}; 72};
65 73
66#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags)) 74#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
@@ -70,7 +78,6 @@ extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
70 struct page *page, 78 struct page *page,
71 unsigned int offset, 79 unsigned int offset,
72 unsigned int count); 80 unsigned int count);
73extern void nfs_clear_request(struct nfs_page *req);
74extern void nfs_release_request(struct nfs_page *req); 81extern void nfs_release_request(struct nfs_page *req);
75 82
76 83
@@ -78,13 +85,16 @@ extern int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *dst,
78 pgoff_t idx_start, unsigned int npages, int tag); 85 pgoff_t idx_start, unsigned int npages, int tag);
79extern void nfs_pageio_init(struct nfs_pageio_descriptor *desc, 86extern void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
80 struct inode *inode, 87 struct inode *inode,
81 int (*doio)(struct inode *, struct list_head *, unsigned int, size_t, int), 88 int (*doio)(struct nfs_pageio_descriptor *desc),
82 size_t bsize, 89 size_t bsize,
83 int how); 90 int how);
84extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *, 91extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *,
85 struct nfs_page *); 92 struct nfs_page *);
86extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc); 93extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc);
87extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t); 94extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t);
95extern bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
96 struct nfs_page *prev,
97 struct nfs_page *req);
88extern int nfs_wait_on_request(struct nfs_page *); 98extern int nfs_wait_on_request(struct nfs_page *);
89extern void nfs_unlock_request(struct nfs_page *req); 99extern void nfs_unlock_request(struct nfs_page *req);
90extern int nfs_set_page_tag_locked(struct nfs_page *req); 100extern int nfs_set_page_tag_locked(struct nfs_page *req);
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index fc461926c412..00848d86ffb2 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/nfsacl.h> 4#include <linux/nfsacl.h>
5#include <linux/nfs3.h> 5#include <linux/nfs3.h>
6#include <linux/sunrpc/gss_api.h>
6 7
7/* 8/*
8 * To change the maximum rsize and wsize supported by the NFS client, adjust 9 * To change the maximum rsize and wsize supported by the NFS client, adjust
@@ -14,6 +15,9 @@
14#define NFS_DEF_FILE_IO_SIZE (4096U) 15#define NFS_DEF_FILE_IO_SIZE (4096U)
15#define NFS_MIN_FILE_IO_SIZE (1024U) 16#define NFS_MIN_FILE_IO_SIZE (1024U)
16 17
18/* Forward declaration for NFS v3 */
19struct nfs4_secinfo_flavors;
20
17struct nfs_fsid { 21struct nfs_fsid {
18 uint64_t major; 22 uint64_t major;
19 uint64_t minor; 23 uint64_t minor;
@@ -46,6 +50,7 @@ struct nfs_fattr {
46 } du; 50 } du;
47 struct nfs_fsid fsid; 51 struct nfs_fsid fsid;
48 __u64 fileid; 52 __u64 fileid;
53 __u64 mounted_on_fileid;
49 struct timespec atime; 54 struct timespec atime;
50 struct timespec mtime; 55 struct timespec mtime;
51 struct timespec ctime; 56 struct timespec ctime;
@@ -78,6 +83,8 @@ struct nfs_fattr {
78#define NFS_ATTR_FATTR_CHANGE (1U << 17) 83#define NFS_ATTR_FATTR_CHANGE (1U << 17)
79#define NFS_ATTR_FATTR_PRECHANGE (1U << 18) 84#define NFS_ATTR_FATTR_PRECHANGE (1U << 18)
80#define NFS_ATTR_FATTR_V4_REFERRAL (1U << 19) /* NFSv4 referral */ 85#define NFS_ATTR_FATTR_V4_REFERRAL (1U << 19) /* NFSv4 referral */
86#define NFS_ATTR_FATTR_MOUNTPOINT (1U << 20) /* Treat as mountpoint */
87#define NFS_ATTR_FATTR_MOUNTED_ON_FILEID (1U << 21)
81 88
82#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ 89#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
83 | NFS_ATTR_FATTR_MODE \ 90 | NFS_ATTR_FATTR_MODE \
@@ -112,7 +119,9 @@ struct nfs_fsinfo {
112 __u32 wtmult; /* writes should be multiple of this */ 119 __u32 wtmult; /* writes should be multiple of this */
113 __u32 dtpref; /* pref. readdir transfer size */ 120 __u32 dtpref; /* pref. readdir transfer size */
114 __u64 maxfilesize; 121 __u64 maxfilesize;
122 struct timespec time_delta; /* server time granularity */
115 __u32 lease_time; /* in seconds */ 123 __u32 lease_time; /* in seconds */
124 __u32 layouttype; /* supported pnfs layout driver */
116}; 125};
117 126
118struct nfs_fsstat { 127struct nfs_fsstat {
@@ -149,7 +158,6 @@ struct nfs_seqid;
149 158
150/* nfs41 sessions channel attributes */ 159/* nfs41 sessions channel attributes */
151struct nfs4_channel_attrs { 160struct nfs4_channel_attrs {
152 u32 headerpadsz;
153 u32 max_rqst_sz; 161 u32 max_rqst_sz;
154 u32 max_resp_sz; 162 u32 max_resp_sz;
155 u32 max_resp_sz_cached; 163 u32 max_resp_sz_cached;
@@ -170,7 +178,7 @@ struct nfs4_sequence_args {
170 178
171struct nfs4_sequence_res { 179struct nfs4_sequence_res {
172 struct nfs4_session *sr_session; 180 struct nfs4_session *sr_session;
173 u8 sr_slotid; /* slot used to send request */ 181 struct nfs4_slot *sr_slot; /* slot used to send request */
174 int sr_status; /* sequence operation status */ 182 int sr_status; /* sequence operation status */
175 unsigned long sr_renewal_time; 183 unsigned long sr_renewal_time;
176 u32 sr_status_flags; 184 u32 sr_status_flags;
@@ -185,6 +193,102 @@ struct nfs4_get_lease_time_res {
185 struct nfs4_sequence_res lr_seq_res; 193 struct nfs4_sequence_res lr_seq_res;
186}; 194};
187 195
196#define PNFS_LAYOUT_MAXSIZE 4096
197
198struct nfs4_layoutdriver_data {
199 struct page **pages;
200 __u32 pglen;
201 __u32 len;
202};
203
204struct pnfs_layout_range {
205 u32 iomode;
206 u64 offset;
207 u64 length;
208};
209
210struct nfs4_layoutget_args {
211 __u32 type;
212 struct pnfs_layout_range range;
213 __u64 minlength;
214 __u32 maxcount;
215 struct inode *inode;
216 struct nfs_open_context *ctx;
217 struct nfs4_sequence_args seq_args;
218 nfs4_stateid stateid;
219 struct nfs4_layoutdriver_data layout;
220};
221
222struct nfs4_layoutget_res {
223 __u32 return_on_close;
224 struct pnfs_layout_range range;
225 __u32 type;
226 nfs4_stateid stateid;
227 struct nfs4_sequence_res seq_res;
228 struct nfs4_layoutdriver_data *layoutp;
229};
230
231struct nfs4_layoutget {
232 struct nfs4_layoutget_args args;
233 struct nfs4_layoutget_res res;
234 struct pnfs_layout_segment **lsegpp;
235 gfp_t gfp_flags;
236};
237
238struct nfs4_getdeviceinfo_args {
239 struct pnfs_device *pdev;
240 struct nfs4_sequence_args seq_args;
241};
242
243struct nfs4_getdeviceinfo_res {
244 struct pnfs_device *pdev;
245 struct nfs4_sequence_res seq_res;
246};
247
248struct nfs4_layoutcommit_args {
249 nfs4_stateid stateid;
250 __u64 lastbytewritten;
251 struct inode *inode;
252 const u32 *bitmask;
253 struct nfs4_sequence_args seq_args;
254};
255
256struct nfs4_layoutcommit_res {
257 struct nfs_fattr *fattr;
258 const struct nfs_server *server;
259 struct nfs4_sequence_res seq_res;
260};
261
262struct nfs4_layoutcommit_data {
263 struct rpc_task task;
264 struct nfs_fattr fattr;
265 struct pnfs_layout_segment *lseg;
266 struct rpc_cred *cred;
267 struct nfs4_layoutcommit_args args;
268 struct nfs4_layoutcommit_res res;
269};
270
271struct nfs4_layoutreturn_args {
272 __u32 layout_type;
273 struct inode *inode;
274 nfs4_stateid stateid;
275 struct nfs4_sequence_args seq_args;
276};
277
278struct nfs4_layoutreturn_res {
279 struct nfs4_sequence_res seq_res;
280 u32 lrs_present;
281 nfs4_stateid stateid;
282};
283
284struct nfs4_layoutreturn {
285 struct nfs4_layoutreturn_args args;
286 struct nfs4_layoutreturn_res res;
287 struct rpc_cred *cred;
288 struct nfs_client *clp;
289 int rpc_status;
290};
291
188/* 292/*
189 * Arguments to the open call. 293 * Arguments to the open call.
190 */ 294 */
@@ -266,6 +370,7 @@ struct nfs_closeres {
266struct nfs_lowner { 370struct nfs_lowner {
267 __u64 clientid; 371 __u64 clientid;
268 __u64 id; 372 __u64 id;
373 dev_t s_dev;
269}; 374};
270 375
271struct nfs_lock_args { 376struct nfs_lock_args {
@@ -400,6 +505,27 @@ struct nfs_removeres {
400}; 505};
401 506
402/* 507/*
508 * Common arguments to the rename call
509 */
510struct nfs_renameargs {
511 const struct nfs_fh *old_dir;
512 const struct nfs_fh *new_dir;
513 const struct qstr *old_name;
514 const struct qstr *new_name;
515 const u32 *bitmask;
516 struct nfs4_sequence_args seq_args;
517};
518
519struct nfs_renameres {
520 const struct nfs_server *server;
521 struct nfs4_change_info old_cinfo;
522 struct nfs_fattr *old_fattr;
523 struct nfs4_change_info new_cinfo;
524 struct nfs_fattr *new_fattr;
525 struct nfs4_sequence_res seq_res;
526};
527
528/*
403 * Argument struct for decode_entry function 529 * Argument struct for decode_entry function
404 */ 530 */
405struct nfs_entry { 531struct nfs_entry {
@@ -411,6 +537,8 @@ struct nfs_entry {
411 int eof; 537 int eof;
412 struct nfs_fh * fh; 538 struct nfs_fh * fh;
413 struct nfs_fattr * fattr; 539 struct nfs_fattr * fattr;
540 unsigned char d_type;
541 struct nfs_server * server;
414}; 542};
415 543
416/* 544/*
@@ -434,15 +562,6 @@ struct nfs_createargs {
434 struct iattr * sattr; 562 struct iattr * sattr;
435}; 563};
436 564
437struct nfs_renameargs {
438 struct nfs_fh * fromfh;
439 const char * fromname;
440 unsigned int fromlen;
441 struct nfs_fh * tofh;
442 const char * toname;
443 unsigned int tolen;
444};
445
446struct nfs_setattrargs { 565struct nfs_setattrargs {
447 struct nfs_fh * fh; 566 struct nfs_fh * fh;
448 nfs4_stateid stateid; 567 nfs4_stateid stateid;
@@ -586,15 +705,6 @@ struct nfs3_mknodargs {
586 dev_t rdev; 705 dev_t rdev;
587}; 706};
588 707
589struct nfs3_renameargs {
590 struct nfs_fh * fromfh;
591 const char * fromname;
592 unsigned int fromlen;
593 struct nfs_fh * tofh;
594 const char * toname;
595 unsigned int tolen;
596};
597
598struct nfs3_linkargs { 708struct nfs3_linkargs {
599 struct nfs_fh * fromfh; 709 struct nfs_fh * fromfh;
600 struct nfs_fh * tofh; 710 struct nfs_fh * tofh;
@@ -629,11 +739,6 @@ struct nfs3_readlinkargs {
629 struct page ** pages; 739 struct page ** pages;
630}; 740};
631 741
632struct nfs3_renameres {
633 struct nfs_fattr * fromattr;
634 struct nfs_fattr * toattr;
635};
636
637struct nfs3_linkres { 742struct nfs3_linkres {
638 struct nfs_fattr * dir_attr; 743 struct nfs_fattr * dir_attr;
639 struct nfs_fattr * fattr; 744 struct nfs_fattr * fattr;
@@ -780,6 +885,7 @@ struct nfs4_readdir_arg {
780 struct page ** pages; /* zero-copy data */ 885 struct page ** pages; /* zero-copy data */
781 unsigned int pgbase; /* zero-copy data */ 886 unsigned int pgbase; /* zero-copy data */
782 const u32 * bitmask; 887 const u32 * bitmask;
888 int plus;
783 struct nfs4_sequence_args seq_args; 889 struct nfs4_sequence_args seq_args;
784}; 890};
785 891
@@ -801,24 +907,6 @@ struct nfs4_readlink_res {
801 struct nfs4_sequence_res seq_res; 907 struct nfs4_sequence_res seq_res;
802}; 908};
803 909
804struct nfs4_rename_arg {
805 const struct nfs_fh * old_dir;
806 const struct nfs_fh * new_dir;
807 const struct qstr * old_name;
808 const struct qstr * new_name;
809 const u32 * bitmask;
810 struct nfs4_sequence_args seq_args;
811};
812
813struct nfs4_rename_res {
814 const struct nfs_server * server;
815 struct nfs4_change_info old_cinfo;
816 struct nfs_fattr * old_fattr;
817 struct nfs4_change_info new_cinfo;
818 struct nfs_fattr * new_fattr;
819 struct nfs4_sequence_res seq_res;
820};
821
822#define NFS4_SETCLIENTID_NAMELEN (127) 910#define NFS4_SETCLIENTID_NAMELEN (127)
823struct nfs4_setclientid { 911struct nfs4_setclientid {
824 const nfs4_verifier * sc_verifier; 912 const nfs4_verifier * sc_verifier;
@@ -901,6 +989,38 @@ struct nfs4_fs_locations_res {
901 struct nfs4_sequence_res seq_res; 989 struct nfs4_sequence_res seq_res;
902}; 990};
903 991
992struct nfs4_secinfo_oid {
993 unsigned int len;
994 char data[GSS_OID_MAX_LEN];
995};
996
997struct nfs4_secinfo_gss {
998 struct nfs4_secinfo_oid sec_oid4;
999 unsigned int qop4;
1000 unsigned int service;
1001};
1002
1003struct nfs4_secinfo_flavor {
1004 unsigned int flavor;
1005 struct nfs4_secinfo_gss gss;
1006};
1007
1008struct nfs4_secinfo_flavors {
1009 unsigned int num_flavors;
1010 struct nfs4_secinfo_flavor flavors[0];
1011};
1012
1013struct nfs4_secinfo_arg {
1014 const struct nfs_fh *dir_fh;
1015 const struct qstr *name;
1016 struct nfs4_sequence_args seq_args;
1017};
1018
1019struct nfs4_secinfo_res {
1020 struct nfs4_secinfo_flavors *flavors;
1021 struct nfs4_sequence_res seq_res;
1022};
1023
904#endif /* CONFIG_NFS_V4 */ 1024#endif /* CONFIG_NFS_V4 */
905 1025
906struct nfstime4 { 1026struct nfstime4 {
@@ -981,9 +1101,13 @@ struct nfs_read_data {
981 unsigned int npages; /* Max length of pagevec */ 1101 unsigned int npages; /* Max length of pagevec */
982 struct nfs_readargs args; 1102 struct nfs_readargs args;
983 struct nfs_readres res; 1103 struct nfs_readres res;
984#ifdef CONFIG_NFS_V4
985 unsigned long timestamp; /* For lease renewal */ 1104 unsigned long timestamp; /* For lease renewal */
986#endif 1105 struct pnfs_layout_segment *lseg;
1106 struct nfs_client *ds_clp; /* pNFS data server */
1107 const struct rpc_call_ops *mds_ops;
1108 int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data);
1109 __u64 mds_offset;
1110 int pnfs_error;
987 struct page *page_array[NFS_PAGEVEC_SIZE]; 1111 struct page *page_array[NFS_PAGEVEC_SIZE];
988}; 1112};
989 1113
@@ -1000,13 +1124,22 @@ struct nfs_write_data {
1000 unsigned int npages; /* Max length of pagevec */ 1124 unsigned int npages; /* Max length of pagevec */
1001 struct nfs_writeargs args; /* argument struct */ 1125 struct nfs_writeargs args; /* argument struct */
1002 struct nfs_writeres res; /* result struct */ 1126 struct nfs_writeres res; /* result struct */
1127 struct pnfs_layout_segment *lseg;
1128 struct nfs_client *ds_clp; /* pNFS data server */
1129 int ds_commit_index;
1130 const struct rpc_call_ops *mds_ops;
1131 int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
1003#ifdef CONFIG_NFS_V4 1132#ifdef CONFIG_NFS_V4
1004 unsigned long timestamp; /* For lease renewal */ 1133 unsigned long timestamp; /* For lease renewal */
1005#endif 1134#endif
1135 __u64 mds_offset; /* Filelayout dense stripe */
1136 int pnfs_error;
1006 struct page *page_array[NFS_PAGEVEC_SIZE]; 1137 struct page *page_array[NFS_PAGEVEC_SIZE];
1007}; 1138};
1008 1139
1009struct nfs_access_entry; 1140struct nfs_access_entry;
1141struct nfs_client;
1142struct rpc_timeout;
1010 1143
1011/* 1144/*
1012 * RPC procedure vector for NFSv2/NFSv3 demuxing 1145 * RPC procedure vector for NFSv2/NFSv3 demuxing
@@ -1026,25 +1159,27 @@ struct nfs_rpc_ops {
1026 struct nfs_fattr *); 1159 struct nfs_fattr *);
1027 int (*setattr) (struct dentry *, struct nfs_fattr *, 1160 int (*setattr) (struct dentry *, struct nfs_fattr *,
1028 struct iattr *); 1161 struct iattr *);
1029 int (*lookup) (struct inode *, struct qstr *, 1162 int (*lookup) (struct rpc_clnt *clnt, struct inode *, struct qstr *,
1030 struct nfs_fh *, struct nfs_fattr *); 1163 struct nfs_fh *, struct nfs_fattr *);
1031 int (*access) (struct inode *, struct nfs_access_entry *); 1164 int (*access) (struct inode *, struct nfs_access_entry *);
1032 int (*readlink)(struct inode *, struct page *, unsigned int, 1165 int (*readlink)(struct inode *, struct page *, unsigned int,
1033 unsigned int); 1166 unsigned int);
1034 int (*create) (struct inode *, struct dentry *, 1167 int (*create) (struct inode *, struct dentry *,
1035 struct iattr *, int, struct nameidata *); 1168 struct iattr *, int, struct nfs_open_context *);
1036 int (*remove) (struct inode *, struct qstr *); 1169 int (*remove) (struct inode *, struct qstr *);
1037 void (*unlink_setup) (struct rpc_message *, struct inode *dir); 1170 void (*unlink_setup) (struct rpc_message *, struct inode *dir);
1038 int (*unlink_done) (struct rpc_task *, struct inode *); 1171 int (*unlink_done) (struct rpc_task *, struct inode *);
1039 int (*rename) (struct inode *, struct qstr *, 1172 int (*rename) (struct inode *, struct qstr *,
1040 struct inode *, struct qstr *); 1173 struct inode *, struct qstr *);
1174 void (*rename_setup) (struct rpc_message *msg, struct inode *dir);
1175 int (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
1041 int (*link) (struct inode *, struct inode *, struct qstr *); 1176 int (*link) (struct inode *, struct inode *, struct qstr *);
1042 int (*symlink) (struct inode *, struct dentry *, struct page *, 1177 int (*symlink) (struct inode *, struct dentry *, struct page *,
1043 unsigned int, struct iattr *); 1178 unsigned int, struct iattr *);
1044 int (*mkdir) (struct inode *, struct dentry *, struct iattr *); 1179 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
1045 int (*rmdir) (struct inode *, struct qstr *); 1180 int (*rmdir) (struct inode *, struct qstr *);
1046 int (*readdir) (struct dentry *, struct rpc_cred *, 1181 int (*readdir) (struct dentry *, struct rpc_cred *,
1047 u64, struct page *, unsigned int, int); 1182 u64, struct page **, unsigned int, int);
1048 int (*mknod) (struct inode *, struct dentry *, struct iattr *, 1183 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
1049 dev_t); 1184 dev_t);
1050 int (*statfs) (struct nfs_server *, struct nfs_fh *, 1185 int (*statfs) (struct nfs_server *, struct nfs_fh *,
@@ -1054,7 +1189,7 @@ struct nfs_rpc_ops {
1054 int (*pathconf) (struct nfs_server *, struct nfs_fh *, 1189 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
1055 struct nfs_pathconf *); 1190 struct nfs_pathconf *);
1056 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); 1191 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1057 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus); 1192 int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int);
1058 void (*read_setup) (struct nfs_read_data *, struct rpc_message *); 1193 void (*read_setup) (struct nfs_read_data *, struct rpc_message *);
1059 int (*read_done) (struct rpc_task *, struct nfs_read_data *); 1194 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
1060 void (*write_setup) (struct nfs_write_data *, struct rpc_message *); 1195 void (*write_setup) (struct nfs_write_data *, struct rpc_message *);
@@ -1065,6 +1200,13 @@ struct nfs_rpc_ops {
1065 int (*lock_check_bounds)(const struct file_lock *); 1200 int (*lock_check_bounds)(const struct file_lock *);
1066 void (*clear_acl_cache)(struct inode *); 1201 void (*clear_acl_cache)(struct inode *);
1067 void (*close_context)(struct nfs_open_context *ctx, int); 1202 void (*close_context)(struct nfs_open_context *ctx, int);
1203 struct inode * (*open_context) (struct inode *dir,
1204 struct nfs_open_context *ctx,
1205 int open_flags,
1206 struct iattr *iattr);
1207 int (*init_client) (struct nfs_client *, const struct rpc_timeout *,
1208 const char *, rpc_authflavor_t, int);
1209 int (*secinfo)(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
1068}; 1210};
1069 1211
1070/* 1212/*
diff --git a/include/linux/nfsacl.h b/include/linux/nfsacl.h
index f321b578edeb..fabcb1e5c460 100644
--- a/include/linux/nfsacl.h
+++ b/include/linux/nfsacl.h
@@ -51,10 +51,10 @@ nfsacl_size(struct posix_acl *acl_access, struct posix_acl *acl_default)
51 return w; 51 return w;
52} 52}
53 53
54extern unsigned int 54extern int
55nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode, 55nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
56 struct posix_acl *acl, int encode_entries, int typeflag); 56 struct posix_acl *acl, int encode_entries, int typeflag);
57extern unsigned int 57extern int
58nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt, 58nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
59 struct posix_acl **pacl); 59 struct posix_acl **pacl);
60 60
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index 8ae78a61eea4..84058ec69390 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -35,7 +35,7 @@
35#define NFSEXP_NOHIDE 0x0200 35#define NFSEXP_NOHIDE 0x0200
36#define NFSEXP_NOSUBTREECHECK 0x0400 36#define NFSEXP_NOSUBTREECHECK 0x0400
37#define NFSEXP_NOAUTHNLM 0x0800 /* Don't authenticate NLM requests - just trust */ 37#define NFSEXP_NOAUTHNLM 0x0800 /* Don't authenticate NLM requests - just trust */
38#define NFSEXP_MSNFS 0x1000 /* do silly things that MS clients expect */ 38#define NFSEXP_MSNFS 0x1000 /* do silly things that MS clients expect; no longer supported */
39#define NFSEXP_FSID 0x2000 39#define NFSEXP_FSID 0x2000
40#define NFSEXP_CROSSMOUNT 0x4000 40#define NFSEXP_CROSSMOUNT 0x4000
41#define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */ 41#define NFSEXP_NOACL 0x8000 /* reserved for possible ACL related use */
@@ -80,7 +80,7 @@ struct nfsd4_fs_locations {
80 80
81/* 81/*
82 * We keep an array of pseudoflavors with the export, in order from most 82 * We keep an array of pseudoflavors with the export, in order from most
83 * to least preferred. For the forseeable future, we don't expect more 83 * to least preferred. For the foreseeable future, we don't expect more
84 * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3, 84 * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3,
85 * spkm3i, and spkm3p (and using all 8 at once should be rare). 85 * spkm3i, and spkm3p (and using all 8 at once should be rare).
86 */ 86 */
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
index 80d55bbc5365..f76d80ccec10 100644
--- a/include/linux/nfsd/nfsfh.h
+++ b/include/linux/nfsd/nfsfh.h
@@ -49,7 +49,7 @@ struct nfs_fhbase_old {
49 * 49 *
50 * The auth_type field specifies how the filehandle can be authenticated 50 * The auth_type field specifies how the filehandle can be authenticated
51 * This might allow a file to be confirmed to be in a writable part of a 51 * This might allow a file to be confirmed to be in a writable part of a
52 * filetree without checking the path from it upto the root. 52 * filetree without checking the path from it up to the root.
53 * Current values: 53 * Current values:
54 * 0 - No authentication. fb_auth is 0 bytes long 54 * 0 - No authentication. fb_auth is 0 bytes long
55 * Possible future values: 55 * Possible future values:
diff --git a/include/linux/nfsd_idmap.h b/include/linux/nfsd_idmap.h
deleted file mode 100644
index d4a2ac18bd4c..000000000000
--- a/include/linux/nfsd_idmap.h
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * include/linux/nfsd_idmap.h
3 *
4 * Mapping of UID to name and vice versa.
5 *
6 * Copyright (c) 2002, 2003 The Regents of the University of
7 * Michigan. All rights reserved.
8> *
9 * Marius Aamodt Eriksen <marius@umich.edu>
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef LINUX_NFSD_IDMAP_H
38#define LINUX_NFSD_IDMAP_H
39
40#include <linux/in.h>
41#include <linux/sunrpc/svc.h>
42
43/* XXX from linux/nfs_idmap.h */
44#define IDMAP_NAMESZ 128
45
46#ifdef CONFIG_NFSD_V4
47int nfsd_idmap_init(void);
48void nfsd_idmap_shutdown(void);
49#else
50static inline int nfsd_idmap_init(void)
51{
52 return 0;
53}
54static inline void nfsd_idmap_shutdown(void)
55{
56}
57#endif
58
59int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *);
60int nfsd_map_name_to_gid(struct svc_rqst *, const char *, size_t, __u32 *);
61int nfsd_map_uid_to_name(struct svc_rqst *, __u32, char *);
62int nfsd_map_gid_to_name(struct svc_rqst *, __u32, char *);
63
64#endif /* LINUX_NFSD_IDMAP_H */
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h
index f5487b6f91ed..7454ad7451b4 100644
--- a/include/linux/nilfs2_fs.h
+++ b/include/linux/nilfs2_fs.h
@@ -4,16 +4,16 @@
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU Lesser General Public License as published
8 * the Free Software Foundation; either version 2 of the License, or 8 * by the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version. 9 * (at your option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * 19 *
@@ -40,26 +40,7 @@
40 40
41#include <linux/types.h> 41#include <linux/types.h>
42#include <linux/ioctl.h> 42#include <linux/ioctl.h>
43 43#include <linux/magic.h>
44/*
45 * Inode flags stored in nilfs_inode and on-memory nilfs inode
46 *
47 * We define these flags based on ext2-fs because of the
48 * compatibility reason; to avoid problems in chattr(1)
49 */
50#define NILFS_SECRM_FL 0x00000001 /* Secure deletion */
51#define NILFS_UNRM_FL 0x00000002 /* Undelete */
52#define NILFS_SYNC_FL 0x00000008 /* Synchronous updates */
53#define NILFS_IMMUTABLE_FL 0x00000010 /* Immutable file */
54#define NILFS_APPEND_FL 0x00000020 /* writes to file may only append */
55#define NILFS_NODUMP_FL 0x00000040 /* do not dump file */
56#define NILFS_NOATIME_FL 0x00000080 /* do not update atime */
57/* Reserved for compression usage... */
58#define NILFS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
59#define NILFS_DIRSYNC_FL 0x00010000 /* dirsync behaviour */
60
61#define NILFS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
62#define NILFS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
63 44
64 45
65#define NILFS_INODE_BMAP_SIZE 7 46#define NILFS_INODE_BMAP_SIZE 7
@@ -126,7 +107,7 @@ struct nilfs_super_root {
126#define NILFS_SR_DAT_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 0) 107#define NILFS_SR_DAT_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 0)
127#define NILFS_SR_CPFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 1) 108#define NILFS_SR_CPFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 1)
128#define NILFS_SR_SUFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 2) 109#define NILFS_SR_SUFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 2)
129#define NILFS_SR_BYTES (sizeof(struct nilfs_super_root)) 110#define NILFS_SR_BYTES(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 3)
130 111
131/* 112/*
132 * Maximal mount counts 113 * Maximal mount counts
@@ -147,7 +128,6 @@ struct nilfs_super_root {
147#define NILFS_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ 128#define NILFS_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
148#define NILFS_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ 129#define NILFS_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
149#define NILFS_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ 130#define NILFS_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
150#define NILFS_MOUNT_SNAPSHOT 0x0080 /* Snapshot flag */
151#define NILFS_MOUNT_BARRIER 0x1000 /* Use block barriers */ 131#define NILFS_MOUNT_BARRIER 0x1000 /* Use block barriers */
152#define NILFS_MOUNT_STRICT_ORDER 0x2000 /* Apply strict in-order 132#define NILFS_MOUNT_STRICT_ORDER 0x2000 /* Apply strict in-order
153 semantics also for data */ 133 semantics also for data */
@@ -229,6 +209,7 @@ struct nilfs_super_block {
229 */ 209 */
230#define NILFS_CURRENT_REV 2 /* current major revision */ 210#define NILFS_CURRENT_REV 2 /* current major revision */
231#define NILFS_MINOR_REV 0 /* minor revision */ 211#define NILFS_MINOR_REV 0 /* minor revision */
212#define NILFS_MIN_SUPP_REV 2 /* minimum supported revision */
232 213
233/* 214/*
234 * Feature set definitions 215 * Feature set definitions
@@ -236,8 +217,10 @@ struct nilfs_super_block {
236 * If there is a bit set in the incompatible feature set that the kernel 217 * If there is a bit set in the incompatible feature set that the kernel
237 * doesn't know about, it should refuse to mount the filesystem. 218 * doesn't know about, it should refuse to mount the filesystem.
238 */ 219 */
220#define NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT 0x00000001ULL
221
239#define NILFS_FEATURE_COMPAT_SUPP 0ULL 222#define NILFS_FEATURE_COMPAT_SUPP 0ULL
240#define NILFS_FEATURE_COMPAT_RO_SUPP 0ULL 223#define NILFS_FEATURE_COMPAT_RO_SUPP NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT
241#define NILFS_FEATURE_INCOMPAT_SUPP 0ULL 224#define NILFS_FEATURE_INCOMPAT_SUPP 0ULL
242 225
243/* 226/*
@@ -260,7 +243,6 @@ struct nilfs_super_block {
260#define NILFS_USER_INO 11 /* Fisrt user's file inode number */ 243#define NILFS_USER_INO 11 /* Fisrt user's file inode number */
261 244
262#define NILFS_SB_OFFSET_BYTES 1024 /* byte offset of nilfs superblock */ 245#define NILFS_SB_OFFSET_BYTES 1024 /* byte offset of nilfs superblock */
263#define NILFS_SUPER_MAGIC 0x3434 /* NILFS filesystem magic number */
264 246
265#define NILFS_SEG_MIN_BLOCKS 16 /* Minimum number of blocks in 247#define NILFS_SEG_MIN_BLOCKS 16 /* Minimum number of blocks in
266 a full segment */ 248 a full segment */
@@ -270,6 +252,14 @@ struct nilfs_super_block {
270 segments */ 252 segments */
271 253
272/* 254/*
255 * We call DAT, cpfile, and sufile root metadata files. Inodes of
256 * these files are written in super root block instead of ifile, and
257 * garbage collector doesn't keep any past versions of these files.
258 */
259#define NILFS_ROOT_METADATA_FILE(ino) \
260 ((ino) >= NILFS_DAT_INO && (ino) <= NILFS_SUFILE_INO)
261
262/*
273 * bytes offset of secondary super block 263 * bytes offset of secondary super block
274 */ 264 */
275#define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12) 265#define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12)
@@ -338,17 +328,21 @@ static inline unsigned nilfs_rec_len_from_disk(__le16 dlen)
338{ 328{
339 unsigned len = le16_to_cpu(dlen); 329 unsigned len = le16_to_cpu(dlen);
340 330
331#if !defined(__KERNEL__) || (PAGE_CACHE_SIZE >= 65536)
341 if (len == NILFS_MAX_REC_LEN) 332 if (len == NILFS_MAX_REC_LEN)
342 return 1 << 16; 333 return 1 << 16;
334#endif
343 return len; 335 return len;
344} 336}
345 337
346static inline __le16 nilfs_rec_len_to_disk(unsigned len) 338static inline __le16 nilfs_rec_len_to_disk(unsigned len)
347{ 339{
340#if !defined(__KERNEL__) || (PAGE_CACHE_SIZE >= 65536)
348 if (len == (1 << 16)) 341 if (len == (1 << 16))
349 return cpu_to_le16(NILFS_MAX_REC_LEN); 342 return cpu_to_le16(NILFS_MAX_REC_LEN);
350 else if (len > (1 << 16)) 343 else if (len > (1 << 16))
351 BUG(); 344 BUG();
345#endif
352 return cpu_to_le16(len); 346 return cpu_to_le16(len);
353} 347}
354 348
@@ -517,7 +511,7 @@ struct nilfs_checkpoint {
517 __le64 cp_create; 511 __le64 cp_create;
518 __le64 cp_nblk_inc; 512 __le64 cp_nblk_inc;
519 __le64 cp_inodes_count; 513 __le64 cp_inodes_count;
520 __le64 cp_blocks_count; /* Reserved (might be deleted) */ 514 __le64 cp_blocks_count;
521 515
522 /* Do not change the byte offset of ifile inode. 516 /* Do not change the byte offset of ifile inode.
523 To keep the compatibility of the disk format, 517 To keep the compatibility of the disk format,
@@ -851,5 +845,7 @@ struct nilfs_bdesc {
851 _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64) 845 _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64)
852#define NILFS_IOCTL_RESIZE \ 846#define NILFS_IOCTL_RESIZE \
853 _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64) 847 _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64)
848#define NILFS_IOCTL_SET_ALLOC_RANGE \
849 _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2])
854 850
855#endif /* _LINUX_NILFS_FS_H */ 851#endif /* _LINUX_NILFS_FS_H */
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 2c8701687336..c7ccaae15af6 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -40,6 +40,76 @@
40 */ 40 */
41 41
42/** 42/**
43 * DOC: Frame transmission/registration support
44 *
45 * Frame transmission and registration support exists to allow userspace
46 * management entities such as wpa_supplicant react to management frames
47 * that are not being handled by the kernel. This includes, for example,
48 * certain classes of action frames that cannot be handled in the kernel
49 * for various reasons.
50 *
51 * Frame registration is done on a per-interface basis and registrations
52 * cannot be removed other than by closing the socket. It is possible to
53 * specify a registration filter to register, for example, only for a
54 * certain type of action frame. In particular with action frames, those
55 * that userspace registers for will not be returned as unhandled by the
56 * driver, so that the registered application has to take responsibility
57 * for doing that.
58 *
59 * The type of frame that can be registered for is also dependent on the
60 * driver and interface type. The frame types are advertised in wiphy
61 * attributes so applications know what to expect.
62 *
63 * NOTE: When an interface changes type while registrations are active,
64 * these registrations are ignored until the interface type is
65 * changed again. This means that changing the interface type can
66 * lead to a situation that couldn't otherwise be produced, but
67 * any such registrations will be dormant in the sense that they
68 * will not be serviced, i.e. they will not receive any frames.
69 *
70 * Frame transmission allows userspace to send for example the required
71 * responses to action frames. It is subject to some sanity checking,
72 * but many frames can be transmitted. When a frame was transmitted, its
73 * status is indicated to the sending socket.
74 *
75 * For more technical details, see the corresponding command descriptions
76 * below.
77 */
78
79/**
80 * DOC: Virtual interface / concurrency capabilities
81 *
82 * Some devices are able to operate with virtual MACs, they can have
83 * more than one virtual interface. The capability handling for this
84 * is a bit complex though, as there may be a number of restrictions
85 * on the types of concurrency that are supported.
86 *
87 * To start with, each device supports the interface types listed in
88 * the %NL80211_ATTR_SUPPORTED_IFTYPES attribute, but by listing the
89 * types there no concurrency is implied.
90 *
91 * Once concurrency is desired, more attributes must be observed:
92 * To start with, since some interface types are purely managed in
93 * software, like the AP-VLAN type in mac80211 for example, there's
94 * an additional list of these, they can be added at any time and
95 * are only restricted by some semantic restrictions (e.g. AP-VLAN
96 * cannot be added without a corresponding AP interface). This list
97 * is exported in the %NL80211_ATTR_SOFTWARE_IFTYPES attribute.
98 *
99 * Further, the list of supported combinations is exported. This is
100 * in the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute. Basically,
101 * it exports a list of "groups", and at any point in time the
102 * interfaces that are currently active must fall into any one of
103 * the advertised groups. Within each group, there are restrictions
104 * on the number of interfaces of different types that are supported
105 * and also the number of different channels, along with potentially
106 * some other restrictions. See &enum nl80211_if_combination_attrs.
107 *
108 * All together, these attributes define the concurrency of virtual
109 * interfaces that a given device supports.
110 */
111
112/**
43 * enum nl80211_commands - supported nl80211 commands 113 * enum nl80211_commands - supported nl80211 commands
44 * 114 *
45 * @NL80211_CMD_UNSPEC: unspecified command to catch errors 115 * @NL80211_CMD_UNSPEC: unspecified command to catch errors
@@ -111,6 +181,10 @@
111 * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to 181 * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
112 * destination %NL80211_ATTR_MAC on the interface identified by 182 * destination %NL80211_ATTR_MAC on the interface identified by
113 * %NL80211_ATTR_IFINDEX. 183 * %NL80211_ATTR_IFINDEX.
184 * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by
185 * %NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.
186 * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by
187 * %NL80211_ATTR_MAC.
114 * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the 188 * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
115 * the interface identified by %NL80211_ATTR_IFINDEX. 189 * the interface identified by %NL80211_ATTR_IFINDEX.
116 * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC 190 * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
@@ -135,10 +209,10 @@
135 * to the specified ISO/IEC 3166-1 alpha2 country code. The core will 209 * to the specified ISO/IEC 3166-1 alpha2 country code. The core will
136 * store this as a valid request and then query userspace for it. 210 * store this as a valid request and then query userspace for it.
137 * 211 *
138 * @NL80211_CMD_GET_MESH_PARAMS: Get mesh networking properties for the 212 * @NL80211_CMD_GET_MESH_CONFIG: Get mesh networking properties for the
139 * interface identified by %NL80211_ATTR_IFINDEX 213 * interface identified by %NL80211_ATTR_IFINDEX
140 * 214 *
141 * @NL80211_CMD_SET_MESH_PARAMS: Set mesh networking properties for the 215 * @NL80211_CMD_SET_MESH_CONFIG: Set mesh networking properties for the
142 * interface identified by %NL80211_ATTR_IFINDEX 216 * interface identified by %NL80211_ATTR_IFINDEX
143 * 217 *
144 * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The 218 * @NL80211_CMD_SET_MGMT_EXTRA_IE: Set extra IEs for management frames. The
@@ -162,6 +236,28 @@
162 * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons, 236 * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
163 * partial scan results may be available 237 * partial scan results may be available
164 * 238 *
239 * @NL80211_CMD_START_SCHED_SCAN: start a scheduled scan at certain
240 * intervals, as specified by %NL80211_ATTR_SCHED_SCAN_INTERVAL.
241 * Like with normal scans, if SSIDs (%NL80211_ATTR_SCAN_SSIDS)
242 * are passed, they are used in the probe requests. For
243 * broadcast, a broadcast SSID must be passed (ie. an empty
244 * string). If no SSID is passed, no probe requests are sent and
245 * a passive scan is performed. %NL80211_ATTR_SCAN_FREQUENCIES,
246 * if passed, define which channels should be scanned; if not
247 * passed, all channels allowed for the current regulatory domain
248 * are used. Extra IEs can also be passed from the userspace by
249 * using the %NL80211_ATTR_IE attribute.
250 * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan
251 * @NL80211_CMD_SCHED_SCAN_RESULTS: indicates that there are scheduled scan
252 * results available.
253 * @NL80211_CMD_SCHED_SCAN_STOPPED: indicates that the scheduled scan has
254 * stopped. The driver may issue this event at any time during a
255 * scheduled scan. One reason for stopping the scan is if the hardware
256 * does not support starting an association or a normal scan while running
257 * a scheduled scan. This event is also sent when the
258 * %NL80211_CMD_STOP_SCHED_SCAN command is received or when the interface
259 * is brought down while a scheduled scan was running.
260 *
165 * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation 261 * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation
166 * or noise level 262 * or noise level
167 * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to 263 * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to
@@ -258,7 +354,9 @@
258 * auth and assoc steps. For this, you need to specify the SSID in a 354 * auth and assoc steps. For this, you need to specify the SSID in a
259 * %NL80211_ATTR_SSID attribute, and can optionally specify the association 355 * %NL80211_ATTR_SSID attribute, and can optionally specify the association
260 * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_MAC, 356 * IEs in %NL80211_ATTR_IE, %NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_MAC,
261 * %NL80211_ATTR_WIPHY_FREQ and %NL80211_ATTR_CONTROL_PORT. 357 * %NL80211_ATTR_WIPHY_FREQ, %NL80211_ATTR_CONTROL_PORT,
358 * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE and
359 * %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT.
262 * It is also sent as an event, with the BSSID and response IEs when the 360 * It is also sent as an event, with the BSSID and response IEs when the
263 * connection is established or failed to be established. This can be 361 * connection is established or failed to be established. This can be
264 * determined by the STATUS_CODE attribute. 362 * determined by the STATUS_CODE attribute.
@@ -276,8 +374,8 @@
276 * channel for the specified amount of time. This can be used to do 374 * channel for the specified amount of time. This can be used to do
277 * off-channel operations like transmit a Public Action frame and wait for 375 * off-channel operations like transmit a Public Action frame and wait for
278 * a response while being associated to an AP on another channel. 376 * a response while being associated to an AP on another channel.
279 * %NL80211_ATTR_WIPHY or %NL80211_ATTR_IFINDEX is used to specify which 377 * %NL80211_ATTR_IFINDEX is used to specify which interface (and thus
280 * radio is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the 378 * radio) is used. %NL80211_ATTR_WIPHY_FREQ is used to specify the
281 * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be 379 * frequency for the operation and %NL80211_ATTR_WIPHY_CHANNEL_TYPE may be
282 * optionally used to specify additional channel parameters. 380 * optionally used to specify additional channel parameters.
283 * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds 381 * %NL80211_ATTR_DURATION is used to specify the duration in milliseconds
@@ -301,30 +399,42 @@
301 * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface 399 * rate selection. %NL80211_ATTR_IFINDEX is used to specify the interface
302 * and @NL80211_ATTR_TX_RATES the set of allowed rates. 400 * and @NL80211_ATTR_TX_RATES the set of allowed rates.
303 * 401 *
304 * @NL80211_CMD_REGISTER_ACTION: Register for receiving certain action frames 402 * @NL80211_CMD_REGISTER_FRAME: Register for receiving certain mgmt frames
305 * (via @NL80211_CMD_ACTION) for processing in userspace. This command 403 * (via @NL80211_CMD_FRAME) for processing in userspace. This command
306 * requires an interface index and a match attribute containing the first 404 * requires an interface index, a frame type attribute (optional for
307 * few bytes of the frame that should match, e.g. a single byte for only 405 * backward compatibility reasons, if not given assumes action frames)
308 * a category match or four bytes for vendor frames including the OUI. 406 * and a match attribute containing the first few bytes of the frame
309 * The registration cannot be dropped, but is removed automatically 407 * that should match, e.g. a single byte for only a category match or
310 * when the netlink socket is closed. Multiple registrations can be made. 408 * four bytes for vendor frames including the OUI. The registration
311 * @NL80211_CMD_ACTION: Action frame TX request and RX notification. This 409 * cannot be dropped, but is removed automatically when the netlink
312 * command is used both as a request to transmit an Action frame and as an 410 * socket is closed. Multiple registrations can be made.
313 * event indicating reception of an Action frame that was not processed in 411 * @NL80211_CMD_REGISTER_ACTION: Alias for @NL80211_CMD_REGISTER_FRAME for
412 * backward compatibility
413 * @NL80211_CMD_FRAME: Management frame TX request and RX notification. This
414 * command is used both as a request to transmit a management frame and
415 * as an event indicating reception of a frame that was not processed in
314 * kernel code, but is for us (i.e., which may need to be processed in a 416 * kernel code, but is for us (i.e., which may need to be processed in a
315 * user space application). %NL80211_ATTR_FRAME is used to specify the 417 * user space application). %NL80211_ATTR_FRAME is used to specify the
316 * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and 418 * frame contents (including header). %NL80211_ATTR_WIPHY_FREQ (and
317 * optionally %NL80211_ATTR_WIPHY_CHANNEL_TYPE) is used to indicate on 419 * optionally %NL80211_ATTR_WIPHY_CHANNEL_TYPE) is used to indicate on
318 * which channel the frame is to be transmitted or was received. This 420 * which channel the frame is to be transmitted or was received. If this
319 * channel has to be the current channel (remain-on-channel or the 421 * channel is not the current channel (remain-on-channel or the
320 * operational channel). When called, this operation returns a cookie 422 * operational channel) the device will switch to the given channel and
321 * (%NL80211_ATTR_COOKIE) that will be included with the TX status event 423 * transmit the frame, optionally waiting for a response for the time
322 * pertaining to the TX request. 424 * specified using %NL80211_ATTR_DURATION. When called, this operation
323 * @NL80211_CMD_ACTION_TX_STATUS: Report TX status of an Action frame 425 * returns a cookie (%NL80211_ATTR_COOKIE) that will be included with the
324 * transmitted with %NL80211_CMD_ACTION. %NL80211_ATTR_COOKIE identifies 426 * TX status event pertaining to the TX request.
427 * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
428 * command may be used with the corresponding cookie to cancel the wait
429 * time if it is known that it is no longer necessary.
430 * @NL80211_CMD_ACTION: Alias for @NL80211_CMD_FRAME for backward compatibility.
431 * @NL80211_CMD_FRAME_TX_STATUS: Report TX status of a management frame
432 * transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
325 * the TX command and %NL80211_ATTR_FRAME includes the contents of the 433 * the TX command and %NL80211_ATTR_FRAME includes the contents of the
326 * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged 434 * frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
327 * the frame. 435 * the frame.
436 * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
437 * backward compatibility.
328 * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command 438 * @NL80211_CMD_SET_CQM: Connection quality monitor configuration. This command
329 * is used to configure connection quality monitoring notification trigger 439 * is used to configure connection quality monitoring notification trigger
330 * levels. 440 * levels.
@@ -341,11 +451,43 @@
341 * of any other interfaces, and other interfaces will again take 451 * of any other interfaces, and other interfaces will again take
342 * precedence when they are used. 452 * precedence when they are used.
343 * 453 *
454 * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface.
455 *
456 * @NL80211_CMD_JOIN_MESH: Join a mesh. The mesh ID must be given, and initial
457 * mesh config parameters may be given.
458 * @NL80211_CMD_LEAVE_MESH: Leave the mesh network -- no special arguments, the
459 * network is determined by the network interface.
460 *
461 * @NL80211_CMD_UNPROT_DEAUTHENTICATE: Unprotected deauthentication frame
462 * notification. This event is used to indicate that an unprotected
463 * deauthentication frame was dropped when MFP is in use.
464 * @NL80211_CMD_UNPROT_DISASSOCIATE: Unprotected disassociation frame
465 * notification. This event is used to indicate that an unprotected
466 * disassociation frame was dropped when MFP is in use.
467 *
468 * @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a
469 * beacon or probe response from a compatible mesh peer. This is only
470 * sent while no station information (sta_info) exists for the new peer
471 * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH is set. On
472 * reception of this notification, userspace may decide to create a new
473 * station (@NL80211_CMD_NEW_STATION). To stop this notification from
474 * reoccurring, the userspace authentication daemon may want to create the
475 * new station with the AUTHENTICATED flag unset and maybe change it later
476 * depending on the authentication result.
477 *
478 * @NL80211_CMD_GET_WOWLAN: get Wake-on-Wireless-LAN (WoWLAN) settings.
479 * @NL80211_CMD_SET_WOWLAN: set Wake-on-Wireless-LAN (WoWLAN) settings.
480 * Since wireless is more complex than wired ethernet, it supports
481 * various triggers. These triggers can be configured through this
482 * command with the %NL80211_ATTR_WOWLAN_TRIGGERS attribute. For
483 * more background information, see
484 * http://wireless.kernel.org/en/users/Documentation/WoWLAN.
485 *
344 * @NL80211_CMD_MAX: highest used command number 486 * @NL80211_CMD_MAX: highest used command number
345 * @__NL80211_CMD_AFTER_LAST: internal use 487 * @__NL80211_CMD_AFTER_LAST: internal use
346 */ 488 */
347enum nl80211_commands { 489enum nl80211_commands {
348/* don't change the order or add anything inbetween, this is ABI! */ 490/* don't change the order or add anything between, this is ABI! */
349 NL80211_CMD_UNSPEC, 491 NL80211_CMD_UNSPEC,
350 492
351 NL80211_CMD_GET_WIPHY, /* can dump */ 493 NL80211_CMD_GET_WIPHY, /* can dump */
@@ -383,8 +525,8 @@ enum nl80211_commands {
383 NL80211_CMD_SET_REG, 525 NL80211_CMD_SET_REG,
384 NL80211_CMD_REQ_SET_REG, 526 NL80211_CMD_REQ_SET_REG,
385 527
386 NL80211_CMD_GET_MESH_PARAMS, 528 NL80211_CMD_GET_MESH_CONFIG,
387 NL80211_CMD_SET_MESH_PARAMS, 529 NL80211_CMD_SET_MESH_CONFIG,
388 530
389 NL80211_CMD_SET_MGMT_EXTRA_IE /* reserved; not used */, 531 NL80211_CMD_SET_MGMT_EXTRA_IE /* reserved; not used */,
390 532
@@ -429,9 +571,12 @@ enum nl80211_commands {
429 571
430 NL80211_CMD_SET_TX_BITRATE_MASK, 572 NL80211_CMD_SET_TX_BITRATE_MASK,
431 573
432 NL80211_CMD_REGISTER_ACTION, 574 NL80211_CMD_REGISTER_FRAME,
433 NL80211_CMD_ACTION, 575 NL80211_CMD_REGISTER_ACTION = NL80211_CMD_REGISTER_FRAME,
434 NL80211_CMD_ACTION_TX_STATUS, 576 NL80211_CMD_FRAME,
577 NL80211_CMD_ACTION = NL80211_CMD_FRAME,
578 NL80211_CMD_FRAME_TX_STATUS,
579 NL80211_CMD_ACTION_TX_STATUS = NL80211_CMD_FRAME_TX_STATUS,
435 580
436 NL80211_CMD_SET_POWER_SAVE, 581 NL80211_CMD_SET_POWER_SAVE,
437 NL80211_CMD_GET_POWER_SAVE, 582 NL80211_CMD_GET_POWER_SAVE,
@@ -440,6 +585,25 @@ enum nl80211_commands {
440 NL80211_CMD_NOTIFY_CQM, 585 NL80211_CMD_NOTIFY_CQM,
441 586
442 NL80211_CMD_SET_CHANNEL, 587 NL80211_CMD_SET_CHANNEL,
588 NL80211_CMD_SET_WDS_PEER,
589
590 NL80211_CMD_FRAME_WAIT_CANCEL,
591
592 NL80211_CMD_JOIN_MESH,
593 NL80211_CMD_LEAVE_MESH,
594
595 NL80211_CMD_UNPROT_DEAUTHENTICATE,
596 NL80211_CMD_UNPROT_DISASSOCIATE,
597
598 NL80211_CMD_NEW_PEER_CANDIDATE,
599
600 NL80211_CMD_GET_WOWLAN,
601 NL80211_CMD_SET_WOWLAN,
602
603 NL80211_CMD_START_SCHED_SCAN,
604 NL80211_CMD_STOP_SCHED_SCAN,
605 NL80211_CMD_SCHED_SCAN_RESULTS,
606 NL80211_CMD_SCHED_SCAN_STOPPED,
443 607
444 /* add new commands above here */ 608 /* add new commands above here */
445 609
@@ -461,6 +625,11 @@ enum nl80211_commands {
461#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE 625#define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
462#define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT 626#define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
463 627
628/* source-level API compatibility */
629#define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG
630#define NL80211_CMD_SET_MESH_PARAMS NL80211_CMD_SET_MESH_CONFIG
631#define NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE NL80211_MESH_SETUP_IE
632
464/** 633/**
465 * enum nl80211_attrs - nl80211 netlink attributes 634 * enum nl80211_attrs - nl80211 netlink attributes
466 * 635 *
@@ -531,7 +700,7 @@ enum nl80211_commands {
531 * consisting of a nested array. 700 * consisting of a nested array.
532 * 701 *
533 * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes). 702 * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
534 * @NL80211_ATTR_PLINK_ACTION: action to perform on the mesh peer link. 703 * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link.
535 * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path. 704 * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
536 * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path 705 * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
537 * info given for %NL80211_CMD_GET_MPATH, nested attribute described at 706 * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
@@ -639,6 +808,15 @@ enum nl80211_commands {
639 * request, the driver will assume that the port is unauthorized until 808 * request, the driver will assume that the port is unauthorized until
640 * authorized by user space. Otherwise, port is marked authorized by 809 * authorized by user space. Otherwise, port is marked authorized by
641 * default in station mode. 810 * default in station mode.
811 * @NL80211_ATTR_CONTROL_PORT_ETHERTYPE: A 16-bit value indicating the
812 * ethertype that will be used for key negotiation. It can be
813 * specified with the associate and connect commands. If it is not
814 * specified, the value defaults to 0x888E (PAE, 802.1X). This
815 * attribute is also used as a flag in the wiphy information to
816 * indicate that protocols other than PAE are supported.
817 * @NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT: When included along with
818 * %NL80211_ATTR_CONTROL_PORT_ETHERTYPE, indicates that the custom
819 * ethertype frames used for key negotiation must not be encrypted.
642 * 820 *
643 * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver. 821 * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.
644 * We recommend using nested, driver-specific attributes within this. 822 * We recommend using nested, driver-specific attributes within this.
@@ -697,6 +875,9 @@ enum nl80211_commands {
697 * cache, a wiphy attribute. 875 * cache, a wiphy attribute.
698 * 876 *
699 * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32. 877 * @NL80211_ATTR_DURATION: Duration of an operation in milliseconds, u32.
878 * @NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION: Device attribute that
879 * specifies the maximum duration that can be requested with the
880 * remain-on-channel operation, in milliseconds, u32.
700 * 881 *
701 * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects. 882 * @NL80211_ATTR_COOKIE: Generic 64-bit cookie to identify objects.
702 * 883 *
@@ -708,7 +889,16 @@ enum nl80211_commands {
708 * is used with %NL80211_CMD_SET_TX_BITRATE_MASK. 889 * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
709 * 890 *
710 * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain 891 * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
711 * at least one byte, currently used with @NL80211_CMD_REGISTER_ACTION. 892 * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
893 * @NL80211_ATTR_FRAME_TYPE: A u16 indicating the frame type/subtype for the
894 * @NL80211_CMD_REGISTER_FRAME command.
895 * @NL80211_ATTR_TX_FRAME_TYPES: wiphy capability attribute, which is a
896 * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
897 * information about which frame types can be transmitted with
898 * %NL80211_CMD_FRAME.
899 * @NL80211_ATTR_RX_FRAME_TYPES: wiphy capability attribute, which is a
900 * nested attribute of %NL80211_ATTR_FRAME_TYPE attributes, containing
901 * information about which frame types can be registered for RX.
712 * 902 *
713 * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was 903 * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was
714 * acknowledged by the recipient. 904 * acknowledged by the recipient.
@@ -731,11 +921,86 @@ enum nl80211_commands {
731 * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING 921 * This is used in association with @NL80211_ATTR_WIPHY_TX_POWER_SETTING
732 * for non-automatic settings. 922 * for non-automatic settings.
733 * 923 *
924 * @NL80211_ATTR_SUPPORT_IBSS_RSN: The device supports IBSS RSN, which mostly
925 * means support for per-station GTKs.
926 *
927 * @NL80211_ATTR_WIPHY_ANTENNA_TX: Bitmap of allowed antennas for transmitting.
928 * This can be used to mask out antennas which are not attached or should
929 * not be used for transmitting. If an antenna is not selected in this
930 * bitmap the hardware is not allowed to transmit on this antenna.
931 *
932 * Each bit represents one antenna, starting with antenna 1 at the first
933 * bit. Depending on which antennas are selected in the bitmap, 802.11n
934 * drivers can derive which chainmasks to use (if all antennas belonging to
935 * a particular chain are disabled this chain should be disabled) and if
936 * a chain has diversity antennas wether diversity should be used or not.
937 * HT capabilities (STBC, TX Beamforming, Antenna selection) can be
938 * derived from the available chains after applying the antenna mask.
939 * Non-802.11n drivers can derive wether to use diversity or not.
940 * Drivers may reject configurations or RX/TX mask combinations they cannot
941 * support by returning -EINVAL.
942 *
943 * @NL80211_ATTR_WIPHY_ANTENNA_RX: Bitmap of allowed antennas for receiving.
944 * This can be used to mask out antennas which are not attached or should
945 * not be used for receiving. If an antenna is not selected in this bitmap
946 * the hardware should not be configured to receive on this antenna.
947 * For a more detailed description see @NL80211_ATTR_WIPHY_ANTENNA_TX.
948 *
949 * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX: Bitmap of antennas which are available
950 * for configuration as TX antennas via the above parameters.
951 *
952 * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX: Bitmap of antennas which are available
953 * for configuration as RX antennas via the above parameters.
954 *
955 * @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
956 *
957 * @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
958 * transmitted on another channel when the channel given doesn't match
959 * the current channel. If the current channel doesn't match and this
960 * flag isn't set, the frame will be rejected. This is also used as an
961 * nl80211 capability flag.
962 *
963 * @NL80211_ATTR_BSS_HTOPMODE: HT operation mode (u16)
964 *
965 * @NL80211_ATTR_KEY_DEFAULT_TYPES: A nested attribute containing flags
966 * attributes, specifying what a key should be set as default as.
967 * See &enum nl80211_key_default_types.
968 *
969 * @NL80211_ATTR_MESH_SETUP: Optional mesh setup parameters. These cannot be
970 * changed once the mesh is active.
971 * @NL80211_ATTR_MESH_CONFIG: Mesh configuration parameters, a nested attribute
972 * containing attributes from &enum nl80211_meshconf_params.
973 * @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver
974 * allows auth frames in a mesh to be passed to userspace for processing via
975 * the @NL80211_MESH_SETUP_USERSPACE_AUTH flag.
976 * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as
977 * defined in &enum nl80211_plink_state. Used when userspace is
978 * driving the peer link management state machine.
979 * @NL80211_MESH_SETUP_USERSPACE_AMPE must be enabled.
980 *
981 * @NL80211_ATTR_WOWLAN_SUPPORTED: indicates, as part of the wiphy capabilities,
982 * the supported WoWLAN triggers
983 * @NL80211_ATTR_WOWLAN_TRIGGERS: used by %NL80211_CMD_SET_WOWLAN to
984 * indicate which WoW triggers should be enabled. This is also
985 * used by %NL80211_CMD_GET_WOWLAN to get the currently enabled WoWLAN
986 * triggers.
987
988 * @NL80211_ATTR_SCHED_SCAN_INTERVAL: Interval between scheduled scan
989 * cycles, in msecs.
990 *
991 * @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
992 * interface combinations. In each nested item, it contains attributes
993 * defined in &enum nl80211_if_combination_attrs.
994 * @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
995 * %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
996 * are managed in software: interfaces of these types aren't subject to
997 * any restrictions in their number or combinations.
998 *
734 * @NL80211_ATTR_MAX: highest attribute number currently defined 999 * @NL80211_ATTR_MAX: highest attribute number currently defined
735 * @__NL80211_ATTR_AFTER_LAST: internal use 1000 * @__NL80211_ATTR_AFTER_LAST: internal use
736 */ 1001 */
737enum nl80211_attrs { 1002enum nl80211_attrs {
738/* don't change the order or add anything inbetween, this is ABI! */ 1003/* don't change the order or add anything between, this is ABI! */
739 NL80211_ATTR_UNSPEC, 1004 NL80211_ATTR_UNSPEC,
740 1005
741 NL80211_ATTR_WIPHY, 1006 NL80211_ATTR_WIPHY,
@@ -785,7 +1050,7 @@ enum nl80211_attrs {
785 NL80211_ATTR_REG_ALPHA2, 1050 NL80211_ATTR_REG_ALPHA2,
786 NL80211_ATTR_REG_RULES, 1051 NL80211_ATTR_REG_RULES,
787 1052
788 NL80211_ATTR_MESH_PARAMS, 1053 NL80211_ATTR_MESH_CONFIG,
789 1054
790 NL80211_ATTR_BSS_BASIC_RATES, 1055 NL80211_ATTR_BSS_BASIC_RATES,
791 1056
@@ -891,6 +1156,44 @@ enum nl80211_attrs {
891 NL80211_ATTR_WIPHY_TX_POWER_SETTING, 1156 NL80211_ATTR_WIPHY_TX_POWER_SETTING,
892 NL80211_ATTR_WIPHY_TX_POWER_LEVEL, 1157 NL80211_ATTR_WIPHY_TX_POWER_LEVEL,
893 1158
1159 NL80211_ATTR_TX_FRAME_TYPES,
1160 NL80211_ATTR_RX_FRAME_TYPES,
1161 NL80211_ATTR_FRAME_TYPE,
1162
1163 NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
1164 NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT,
1165
1166 NL80211_ATTR_SUPPORT_IBSS_RSN,
1167
1168 NL80211_ATTR_WIPHY_ANTENNA_TX,
1169 NL80211_ATTR_WIPHY_ANTENNA_RX,
1170
1171 NL80211_ATTR_MCAST_RATE,
1172
1173 NL80211_ATTR_OFFCHANNEL_TX_OK,
1174
1175 NL80211_ATTR_BSS_HT_OPMODE,
1176
1177 NL80211_ATTR_KEY_DEFAULT_TYPES,
1178
1179 NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
1180
1181 NL80211_ATTR_MESH_SETUP,
1182
1183 NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
1184 NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
1185
1186 NL80211_ATTR_SUPPORT_MESH_AUTH,
1187 NL80211_ATTR_STA_PLINK_STATE,
1188
1189 NL80211_ATTR_WOWLAN_TRIGGERS,
1190 NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED,
1191
1192 NL80211_ATTR_SCHED_SCAN_INTERVAL,
1193
1194 NL80211_ATTR_INTERFACE_COMBINATIONS,
1195 NL80211_ATTR_SOFTWARE_IFTYPES,
1196
894 /* add attributes here, update the policy in nl80211.c */ 1197 /* add attributes here, update the policy in nl80211.c */
895 1198
896 __NL80211_ATTR_AFTER_LAST, 1199 __NL80211_ATTR_AFTER_LAST,
@@ -899,6 +1202,7 @@ enum nl80211_attrs {
899 1202
900/* source-level API compatibility */ 1203/* source-level API compatibility */
901#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION 1204#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
1205#define NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG
902 1206
903/* 1207/*
904 * Allow user space programs to use #ifdef on new attributes by defining them 1208 * Allow user space programs to use #ifdef on new attributes by defining them
@@ -942,12 +1246,16 @@ enum nl80211_attrs {
942 * @NL80211_IFTYPE_ADHOC: independent BSS member 1246 * @NL80211_IFTYPE_ADHOC: independent BSS member
943 * @NL80211_IFTYPE_STATION: managed BSS member 1247 * @NL80211_IFTYPE_STATION: managed BSS member
944 * @NL80211_IFTYPE_AP: access point 1248 * @NL80211_IFTYPE_AP: access point
945 * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points 1249 * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points; VLAN interfaces
1250 * are a bit special in that they must always be tied to a pre-existing
1251 * AP type interface.
946 * @NL80211_IFTYPE_WDS: wireless distribution interface 1252 * @NL80211_IFTYPE_WDS: wireless distribution interface
947 * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames 1253 * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
948 * @NL80211_IFTYPE_MESH_POINT: mesh point 1254 * @NL80211_IFTYPE_MESH_POINT: mesh point
1255 * @NL80211_IFTYPE_P2P_CLIENT: P2P client
1256 * @NL80211_IFTYPE_P2P_GO: P2P group owner
949 * @NL80211_IFTYPE_MAX: highest interface type number currently defined 1257 * @NL80211_IFTYPE_MAX: highest interface type number currently defined
950 * @__NL80211_IFTYPE_AFTER_LAST: internal use 1258 * @NUM_NL80211_IFTYPES: number of defined interface types
951 * 1259 *
952 * These values are used with the %NL80211_ATTR_IFTYPE 1260 * These values are used with the %NL80211_ATTR_IFTYPE
953 * to set the type of an interface. 1261 * to set the type of an interface.
@@ -962,10 +1270,12 @@ enum nl80211_iftype {
962 NL80211_IFTYPE_WDS, 1270 NL80211_IFTYPE_WDS,
963 NL80211_IFTYPE_MONITOR, 1271 NL80211_IFTYPE_MONITOR,
964 NL80211_IFTYPE_MESH_POINT, 1272 NL80211_IFTYPE_MESH_POINT,
1273 NL80211_IFTYPE_P2P_CLIENT,
1274 NL80211_IFTYPE_P2P_GO,
965 1275
966 /* keep last */ 1276 /* keep last */
967 __NL80211_IFTYPE_AFTER_LAST, 1277 NUM_NL80211_IFTYPES,
968 NL80211_IFTYPE_MAX = __NL80211_IFTYPE_AFTER_LAST - 1 1278 NL80211_IFTYPE_MAX = NUM_NL80211_IFTYPES - 1
969}; 1279};
970 1280
971/** 1281/**
@@ -974,11 +1284,15 @@ enum nl80211_iftype {
974 * Station flags. When a station is added to an AP interface, it is 1284 * Station flags. When a station is added to an AP interface, it is
975 * assumed to be already associated (and hence authenticated.) 1285 * assumed to be already associated (and hence authenticated.)
976 * 1286 *
1287 * @__NL80211_STA_FLAG_INVALID: attribute number 0 is reserved
977 * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X) 1288 * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
978 * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames 1289 * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
979 * with short barker preamble 1290 * with short barker preamble
980 * @NL80211_STA_FLAG_WME: station is WME/QoS capable 1291 * @NL80211_STA_FLAG_WME: station is WME/QoS capable
981 * @NL80211_STA_FLAG_MFP: station uses management frame protection 1292 * @NL80211_STA_FLAG_MFP: station uses management frame protection
1293 * @NL80211_STA_FLAG_AUTHENTICATED: station is authenticated
1294 * @NL80211_STA_FLAG_MAX: highest station flag number currently defined
1295 * @__NL80211_STA_FLAG_AFTER_LAST: internal use
982 */ 1296 */
983enum nl80211_sta_flags { 1297enum nl80211_sta_flags {
984 __NL80211_STA_FLAG_INVALID, 1298 __NL80211_STA_FLAG_INVALID,
@@ -986,6 +1300,7 @@ enum nl80211_sta_flags {
986 NL80211_STA_FLAG_SHORT_PREAMBLE, 1300 NL80211_STA_FLAG_SHORT_PREAMBLE,
987 NL80211_STA_FLAG_WME, 1301 NL80211_STA_FLAG_WME,
988 NL80211_STA_FLAG_MFP, 1302 NL80211_STA_FLAG_MFP,
1303 NL80211_STA_FLAG_AUTHENTICATED,
989 1304
990 /* keep last */ 1305 /* keep last */
991 __NL80211_STA_FLAG_AFTER_LAST, 1306 __NL80211_STA_FLAG_AFTER_LAST,
@@ -1031,6 +1346,36 @@ enum nl80211_rate_info {
1031}; 1346};
1032 1347
1033/** 1348/**
1349 * enum nl80211_sta_bss_param - BSS information collected by STA
1350 *
1351 * These attribute types are used with %NL80211_STA_INFO_BSS_PARAM
1352 * when getting information about the bitrate of a station.
1353 *
1354 * @__NL80211_STA_BSS_PARAM_INVALID: attribute number 0 is reserved
1355 * @NL80211_STA_BSS_PARAM_CTS_PROT: whether CTS protection is enabled (flag)
1356 * @NL80211_STA_BSS_PARAM_SHORT_PREAMBLE: whether short preamble is enabled
1357 * (flag)
1358 * @NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME: whether short slot time is enabled
1359 * (flag)
1360 * @NL80211_STA_BSS_PARAM_DTIM_PERIOD: DTIM period for beaconing (u8)
1361 * @NL80211_STA_BSS_PARAM_BEACON_INTERVAL: Beacon interval (u16)
1362 * @NL80211_STA_BSS_PARAM_MAX: highest sta_bss_param number currently defined
1363 * @__NL80211_STA_BSS_PARAM_AFTER_LAST: internal use
1364 */
1365enum nl80211_sta_bss_param {
1366 __NL80211_STA_BSS_PARAM_INVALID,
1367 NL80211_STA_BSS_PARAM_CTS_PROT,
1368 NL80211_STA_BSS_PARAM_SHORT_PREAMBLE,
1369 NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME,
1370 NL80211_STA_BSS_PARAM_DTIM_PERIOD,
1371 NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
1372
1373 /* keep last */
1374 __NL80211_STA_BSS_PARAM_AFTER_LAST,
1375 NL80211_STA_BSS_PARAM_MAX = __NL80211_STA_BSS_PARAM_AFTER_LAST - 1
1376};
1377
1378/**
1034 * enum nl80211_sta_info - station information 1379 * enum nl80211_sta_info - station information
1035 * 1380 *
1036 * These attribute types are used with %NL80211_ATTR_STA_INFO 1381 * These attribute types are used with %NL80211_ATTR_STA_INFO
@@ -1040,14 +1385,26 @@ enum nl80211_rate_info {
1040 * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs) 1385 * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
1041 * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station) 1386 * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
1042 * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station) 1387 * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
1043 * @__NL80211_STA_INFO_AFTER_LAST: internal
1044 * @NL80211_STA_INFO_MAX: highest possible station info attribute
1045 * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm) 1388 * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)
1046 * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute 1389 * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute
1047 * containing info as possible, see &enum nl80211_sta_info_txrate. 1390 * containing info as possible, see &enum nl80211_rate_info
1048 * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station) 1391 * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station)
1049 * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this 1392 * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this
1050 * station) 1393 * station)
1394 * @NL80211_STA_INFO_TX_RETRIES: total retries (u32, to this station)
1395 * @NL80211_STA_INFO_TX_FAILED: total failed packets (u32, to this station)
1396 * @NL80211_STA_INFO_SIGNAL_AVG: signal strength average (u8, dBm)
1397 * @NL80211_STA_INFO_LLID: the station's mesh LLID
1398 * @NL80211_STA_INFO_PLID: the station's mesh PLID
1399 * @NL80211_STA_INFO_PLINK_STATE: peer link state for the station
1400 * (see %enum nl80211_plink_state)
1401 * @NL80211_STA_INFO_RX_BITRATE: last unicast data frame rx rate, nested
1402 * attribute, like NL80211_STA_INFO_TX_BITRATE.
1403 * @NL80211_STA_INFO_BSS_PARAM: current station's view of BSS, nested attribute
1404 * containing info as possible, see &enum nl80211_sta_bss_param
1405 * @NL80211_STA_INFO_CONNECTED_TIME: time since the station is last connected
1406 * @__NL80211_STA_INFO_AFTER_LAST: internal
1407 * @NL80211_STA_INFO_MAX: highest possible station info attribute
1051 */ 1408 */
1052enum nl80211_sta_info { 1409enum nl80211_sta_info {
1053 __NL80211_STA_INFO_INVALID, 1410 __NL80211_STA_INFO_INVALID,
@@ -1061,6 +1418,12 @@ enum nl80211_sta_info {
1061 NL80211_STA_INFO_TX_BITRATE, 1418 NL80211_STA_INFO_TX_BITRATE,
1062 NL80211_STA_INFO_RX_PACKETS, 1419 NL80211_STA_INFO_RX_PACKETS,
1063 NL80211_STA_INFO_TX_PACKETS, 1420 NL80211_STA_INFO_TX_PACKETS,
1421 NL80211_STA_INFO_TX_RETRIES,
1422 NL80211_STA_INFO_TX_FAILED,
1423 NL80211_STA_INFO_SIGNAL_AVG,
1424 NL80211_STA_INFO_RX_BITRATE,
1425 NL80211_STA_INFO_BSS_PARAM,
1426 NL80211_STA_INFO_CONNECTED_TIME,
1064 1427
1065 /* keep last */ 1428 /* keep last */
1066 __NL80211_STA_INFO_AFTER_LAST, 1429 __NL80211_STA_INFO_AFTER_LAST,
@@ -1091,14 +1454,17 @@ enum nl80211_mpath_flags {
1091 * information about a mesh path. 1454 * information about a mesh path.
1092 * 1455 *
1093 * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved 1456 * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
1094 * @NL80211_ATTR_MPATH_FRAME_QLEN: number of queued frames for this destination 1457 * @NL80211_MPATH_INFO_FRAME_QLEN: number of queued frames for this destination
1095 * @NL80211_ATTR_MPATH_SN: destination sequence number 1458 * @NL80211_MPATH_INFO_SN: destination sequence number
1096 * @NL80211_ATTR_MPATH_METRIC: metric (cost) of this mesh path 1459 * @NL80211_MPATH_INFO_METRIC: metric (cost) of this mesh path
1097 * @NL80211_ATTR_MPATH_EXPTIME: expiration time for the path, in msec from now 1460 * @NL80211_MPATH_INFO_EXPTIME: expiration time for the path, in msec from now
1098 * @NL80211_ATTR_MPATH_FLAGS: mesh path flags, enumerated in 1461 * @NL80211_MPATH_INFO_FLAGS: mesh path flags, enumerated in
1099 * &enum nl80211_mpath_flags; 1462 * &enum nl80211_mpath_flags;
1100 * @NL80211_ATTR_MPATH_DISCOVERY_TIMEOUT: total path discovery timeout, in msec 1463 * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
1101 * @NL80211_ATTR_MPATH_DISCOVERY_RETRIES: mesh path discovery retries 1464 * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries
1465 * @NL80211_MPATH_INFO_MAX: highest mesh path information attribute number
1466 * currently defind
1467 * @__NL80211_MPATH_INFO_AFTER_LAST: internal use
1102 */ 1468 */
1103enum nl80211_mpath_info { 1469enum nl80211_mpath_info {
1104 __NL80211_MPATH_INFO_INVALID, 1470 __NL80211_MPATH_INFO_INVALID,
@@ -1127,6 +1493,8 @@ enum nl80211_mpath_info {
1127 * @NL80211_BAND_ATTR_HT_CAPA: HT capabilities, as in the HT information IE 1493 * @NL80211_BAND_ATTR_HT_CAPA: HT capabilities, as in the HT information IE
1128 * @NL80211_BAND_ATTR_HT_AMPDU_FACTOR: A-MPDU factor, as in 11n 1494 * @NL80211_BAND_ATTR_HT_AMPDU_FACTOR: A-MPDU factor, as in 11n
1129 * @NL80211_BAND_ATTR_HT_AMPDU_DENSITY: A-MPDU density, as in 11n 1495 * @NL80211_BAND_ATTR_HT_AMPDU_DENSITY: A-MPDU density, as in 11n
1496 * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined
1497 * @__NL80211_BAND_ATTR_AFTER_LAST: internal use
1130 */ 1498 */
1131enum nl80211_band_attr { 1499enum nl80211_band_attr {
1132 __NL80211_BAND_ATTR_INVALID, 1500 __NL80211_BAND_ATTR_INVALID,
@@ -1147,6 +1515,7 @@ enum nl80211_band_attr {
1147 1515
1148/** 1516/**
1149 * enum nl80211_frequency_attr - frequency attributes 1517 * enum nl80211_frequency_attr - frequency attributes
1518 * @__NL80211_FREQUENCY_ATTR_INVALID: attribute number 0 is reserved
1150 * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz 1519 * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
1151 * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current 1520 * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
1152 * regulatory domain. 1521 * regulatory domain.
@@ -1158,6 +1527,9 @@ enum nl80211_band_attr {
1158 * on this channel in current regulatory domain. 1527 * on this channel in current regulatory domain.
1159 * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm 1528 * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
1160 * (100 * dBm). 1529 * (100 * dBm).
1530 * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
1531 * currently defined
1532 * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
1161 */ 1533 */
1162enum nl80211_frequency_attr { 1534enum nl80211_frequency_attr {
1163 __NL80211_FREQUENCY_ATTR_INVALID, 1535 __NL80211_FREQUENCY_ATTR_INVALID,
@@ -1177,9 +1549,13 @@ enum nl80211_frequency_attr {
1177 1549
1178/** 1550/**
1179 * enum nl80211_bitrate_attr - bitrate attributes 1551 * enum nl80211_bitrate_attr - bitrate attributes
1552 * @__NL80211_BITRATE_ATTR_INVALID: attribute number 0 is reserved
1180 * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps 1553 * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
1181 * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported 1554 * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
1182 * in 2.4 GHz band. 1555 * in 2.4 GHz band.
1556 * @NL80211_BITRATE_ATTR_MAX: highest bitrate attribute number
1557 * currently defined
1558 * @__NL80211_BITRATE_ATTR_AFTER_LAST: internal use
1183 */ 1559 */
1184enum nl80211_bitrate_attr { 1560enum nl80211_bitrate_attr {
1185 __NL80211_BITRATE_ATTR_INVALID, 1561 __NL80211_BITRATE_ATTR_INVALID,
@@ -1201,7 +1577,11 @@ enum nl80211_bitrate_attr {
1201 * wireless core it thinks its knows the regulatory domain we should be in. 1577 * wireless core it thinks its knows the regulatory domain we should be in.
1202 * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an 1578 * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an
1203 * 802.11 country information element with regulatory information it 1579 * 802.11 country information element with regulatory information it
1204 * thinks we should consider. 1580 * thinks we should consider. cfg80211 only processes the country
1581 * code from the IE, and relies on the regulatory domain information
1582 * structure passed by userspace (CRDA) from our wireless-regdb.
1583 * If a channel is enabled but the country code indicates it should
1584 * be disabled we disable the channel and re-enable it upon disassociation.
1205 */ 1585 */
1206enum nl80211_reg_initiator { 1586enum nl80211_reg_initiator {
1207 NL80211_REGDOM_SET_BY_CORE, 1587 NL80211_REGDOM_SET_BY_CORE,
@@ -1235,6 +1615,7 @@ enum nl80211_reg_type {
1235 1615
1236/** 1616/**
1237 * enum nl80211_reg_rule_attr - regulatory rule attributes 1617 * enum nl80211_reg_rule_attr - regulatory rule attributes
1618 * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved
1238 * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional 1619 * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
1239 * considerations for a given frequency range. These are the 1620 * considerations for a given frequency range. These are the
1240 * &enum nl80211_reg_rule_flags. 1621 * &enum nl80211_reg_rule_flags.
@@ -1251,6 +1632,9 @@ enum nl80211_reg_type {
1251 * If you don't have one then don't send this. 1632 * If you don't have one then don't send this.
1252 * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for 1633 * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
1253 * a given frequency range. The value is in mBm (100 * dBm). 1634 * a given frequency range. The value is in mBm (100 * dBm).
1635 * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number
1636 * currently defined
1637 * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use
1254 */ 1638 */
1255enum nl80211_reg_rule_attr { 1639enum nl80211_reg_rule_attr {
1256 __NL80211_REG_RULE_ATTR_INVALID, 1640 __NL80211_REG_RULE_ATTR_INVALID,
@@ -1302,11 +1686,31 @@ enum nl80211_reg_rule_flags {
1302 * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved 1686 * @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved
1303 * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel 1687 * @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel
1304 * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm) 1688 * @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm)
1689 * @NL80211_SURVEY_INFO_IN_USE: channel is currently being used
1690 * @NL80211_SURVEY_INFO_CHANNEL_TIME: amount of time (in ms) that the radio
1691 * spent on this channel
1692 * @NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY: amount of the time the primary
1693 * channel was sensed busy (either due to activity or energy detect)
1694 * @NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: amount of time the extension
1695 * channel was sensed busy
1696 * @NL80211_SURVEY_INFO_CHANNEL_TIME_RX: amount of time the radio spent
1697 * receiving data
1698 * @NL80211_SURVEY_INFO_CHANNEL_TIME_TX: amount of time the radio spent
1699 * transmitting data
1700 * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
1701 * currently defined
1702 * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
1305 */ 1703 */
1306enum nl80211_survey_info { 1704enum nl80211_survey_info {
1307 __NL80211_SURVEY_INFO_INVALID, 1705 __NL80211_SURVEY_INFO_INVALID,
1308 NL80211_SURVEY_INFO_FREQUENCY, 1706 NL80211_SURVEY_INFO_FREQUENCY,
1309 NL80211_SURVEY_INFO_NOISE, 1707 NL80211_SURVEY_INFO_NOISE,
1708 NL80211_SURVEY_INFO_IN_USE,
1709 NL80211_SURVEY_INFO_CHANNEL_TIME,
1710 NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
1711 NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
1712 NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
1713 NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
1310 1714
1311 /* keep last */ 1715 /* keep last */
1312 __NL80211_SURVEY_INFO_AFTER_LAST, 1716 __NL80211_SURVEY_INFO_AFTER_LAST,
@@ -1346,14 +1750,15 @@ enum nl80211_mntr_flags {
1346/** 1750/**
1347 * enum nl80211_meshconf_params - mesh configuration parameters 1751 * enum nl80211_meshconf_params - mesh configuration parameters
1348 * 1752 *
1349 * Mesh configuration parameters 1753 * Mesh configuration parameters. These can be changed while the mesh is
1754 * active.
1350 * 1755 *
1351 * @__NL80211_MESHCONF_INVALID: internal use 1756 * @__NL80211_MESHCONF_INVALID: internal use
1352 * 1757 *
1353 * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in 1758 * @NL80211_MESHCONF_RETRY_TIMEOUT: specifies the initial retry timeout in
1354 * millisecond units, used by the Peer Link Open message 1759 * millisecond units, used by the Peer Link Open message
1355 * 1760 *
1356 * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the inital confirm timeout, in 1761 * @NL80211_MESHCONF_CONFIRM_TIMEOUT: specifies the initial confirm timeout, in
1357 * millisecond units, used by the peer link management to close a peer link 1762 * millisecond units, used by the peer link management to close a peer link
1358 * 1763 *
1359 * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in 1764 * @NL80211_MESHCONF_HOLDING_TIMEOUT: specifies the holding timeout, in
@@ -1393,7 +1798,10 @@ enum nl80211_mntr_flags {
1393 * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs) 1798 * @NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME: The interval of time (in TUs)
1394 * that it takes for an HWMP information element to propagate across the mesh 1799 * that it takes for an HWMP information element to propagate across the mesh
1395 * 1800 *
1396 * @NL80211_MESHCONF_ROOTMODE: whether root mode is enabled or not 1801 * @NL80211_MESHCONF_HWMP_ROOTMODE: whether root mode is enabled or not
1802 *
1803 * @NL80211_MESHCONF_ELEMENT_TTL: specifies the value of TTL field set at a
1804 * source mesh point for path selection elements.
1397 * 1805 *
1398 * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute 1806 * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
1399 * 1807 *
@@ -1415,6 +1823,7 @@ enum nl80211_meshconf_params {
1415 NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, 1823 NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
1416 NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, 1824 NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1417 NL80211_MESHCONF_HWMP_ROOTMODE, 1825 NL80211_MESHCONF_HWMP_ROOTMODE,
1826 NL80211_MESHCONF_ELEMENT_TTL,
1418 1827
1419 /* keep last */ 1828 /* keep last */
1420 __NL80211_MESHCONF_ATTR_AFTER_LAST, 1829 __NL80211_MESHCONF_ATTR_AFTER_LAST,
@@ -1422,6 +1831,54 @@ enum nl80211_meshconf_params {
1422}; 1831};
1423 1832
1424/** 1833/**
1834 * enum nl80211_mesh_setup_params - mesh setup parameters
1835 *
1836 * Mesh setup parameters. These are used to start/join a mesh and cannot be
1837 * changed while the mesh is active.
1838 *
1839 * @__NL80211_MESH_SETUP_INVALID: Internal use
1840 *
1841 * @NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL: Enable this option to use a
1842 * vendor specific path selection algorithm or disable it to use the default
1843 * HWMP.
1844 *
1845 * @NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC: Enable this option to use a
1846 * vendor specific path metric or disable it to use the default Airtime
1847 * metric.
1848 *
1849 * @NL80211_MESH_SETUP_IE: Information elements for this mesh, for instance, a
1850 * robust security network ie, or a vendor specific information element that
1851 * vendors will use to identify the path selection methods and metrics in use.
1852 *
1853 * @NL80211_MESH_SETUP_USERSPACE_AUTH: Enable this option if an authentication
1854 * daemon will be authenticating mesh candidates.
1855 *
1856 * @NL80211_MESH_SETUP_USERSPACE_AMPE: Enable this option if an authentication
1857 * daemon will be securing peer link frames. AMPE is a secured version of Mesh
1858 * Peering Management (MPM) and is implemented with the assistance of a
1859 * userspace daemon. When this flag is set, the kernel will send peer
1860 * management frames to a userspace daemon that will implement AMPE
1861 * functionality (security capabilities selection, key confirmation, and key
1862 * management). When the flag is unset (default), the kernel can autonomously
1863 * complete (unsecured) mesh peering without the need of a userspace daemon.
1864 *
1865 * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number
1866 * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use
1867 */
1868enum nl80211_mesh_setup_params {
1869 __NL80211_MESH_SETUP_INVALID,
1870 NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL,
1871 NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC,
1872 NL80211_MESH_SETUP_IE,
1873 NL80211_MESH_SETUP_USERSPACE_AUTH,
1874 NL80211_MESH_SETUP_USERSPACE_AMPE,
1875
1876 /* keep last */
1877 __NL80211_MESH_SETUP_ATTR_AFTER_LAST,
1878 NL80211_MESH_SETUP_ATTR_MAX = __NL80211_MESH_SETUP_ATTR_AFTER_LAST - 1
1879};
1880
1881/**
1425 * enum nl80211_txq_attr - TX queue parameter attributes 1882 * enum nl80211_txq_attr - TX queue parameter attributes
1426 * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved 1883 * @__NL80211_TXQ_ATTR_INVALID: Attribute number 0 is reserved
1427 * @NL80211_TXQ_ATTR_QUEUE: TX queue identifier (NL80211_TXQ_Q_*) 1884 * @NL80211_TXQ_ATTR_QUEUE: TX queue identifier (NL80211_TXQ_Q_*)
@@ -1466,6 +1923,7 @@ enum nl80211_channel_type {
1466 * enum nl80211_bss - netlink attributes for a BSS 1923 * enum nl80211_bss - netlink attributes for a BSS
1467 * 1924 *
1468 * @__NL80211_BSS_INVALID: invalid 1925 * @__NL80211_BSS_INVALID: invalid
1926 * @NL80211_BSS_BSSID: BSSID of the BSS (6 octets)
1469 * @NL80211_BSS_FREQUENCY: frequency in MHz (u32) 1927 * @NL80211_BSS_FREQUENCY: frequency in MHz (u32)
1470 * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64) 1928 * @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64)
1471 * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16) 1929 * @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16)
@@ -1509,6 +1967,12 @@ enum nl80211_bss {
1509 1967
1510/** 1968/**
1511 * enum nl80211_bss_status - BSS "status" 1969 * enum nl80211_bss_status - BSS "status"
1970 * @NL80211_BSS_STATUS_AUTHENTICATED: Authenticated with this BSS.
1971 * @NL80211_BSS_STATUS_ASSOCIATED: Associated with this BSS.
1972 * @NL80211_BSS_STATUS_IBSS_JOINED: Joined to this IBSS.
1973 *
1974 * The BSS status is a BSS attribute in scan dumps, which
1975 * indicates the status the interface has wrt. this BSS.
1512 */ 1976 */
1513enum nl80211_bss_status { 1977enum nl80211_bss_status {
1514 NL80211_BSS_STATUS_AUTHENTICATED, 1978 NL80211_BSS_STATUS_AUTHENTICATED,
@@ -1546,11 +2010,14 @@ enum nl80211_auth_type {
1546 * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key 2010 * @NL80211_KEYTYPE_GROUP: Group (broadcast/multicast) key
1547 * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key 2011 * @NL80211_KEYTYPE_PAIRWISE: Pairwise (unicast/individual) key
1548 * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS) 2012 * @NL80211_KEYTYPE_PEERKEY: PeerKey (DLS)
2013 * @NUM_NL80211_KEYTYPES: number of defined key types
1549 */ 2014 */
1550enum nl80211_key_type { 2015enum nl80211_key_type {
1551 NL80211_KEYTYPE_GROUP, 2016 NL80211_KEYTYPE_GROUP,
1552 NL80211_KEYTYPE_PAIRWISE, 2017 NL80211_KEYTYPE_PAIRWISE,
1553 NL80211_KEYTYPE_PEERKEY, 2018 NL80211_KEYTYPE_PEERKEY,
2019
2020 NUM_NL80211_KEYTYPES
1554}; 2021};
1555 2022
1556/** 2023/**
@@ -1569,6 +2036,23 @@ enum nl80211_wpa_versions {
1569}; 2036};
1570 2037
1571/** 2038/**
2039 * enum nl80211_key_default_types - key default types
2040 * @__NL80211_KEY_DEFAULT_TYPE_INVALID: invalid
2041 * @NL80211_KEY_DEFAULT_TYPE_UNICAST: key should be used as default
2042 * unicast key
2043 * @NL80211_KEY_DEFAULT_TYPE_MULTICAST: key should be used as default
2044 * multicast key
2045 * @NUM_NL80211_KEY_DEFAULT_TYPES: number of default types
2046 */
2047enum nl80211_key_default_types {
2048 __NL80211_KEY_DEFAULT_TYPE_INVALID,
2049 NL80211_KEY_DEFAULT_TYPE_UNICAST,
2050 NL80211_KEY_DEFAULT_TYPE_MULTICAST,
2051
2052 NUM_NL80211_KEY_DEFAULT_TYPES
2053};
2054
2055/**
1572 * enum nl80211_key_attributes - key attributes 2056 * enum nl80211_key_attributes - key attributes
1573 * @__NL80211_KEY_INVALID: invalid 2057 * @__NL80211_KEY_INVALID: invalid
1574 * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of 2058 * @NL80211_KEY_DATA: (temporal) key data; for TKIP this consists of
@@ -1581,6 +2065,12 @@ enum nl80211_wpa_versions {
1581 * CCMP keys, each six bytes in little endian 2065 * CCMP keys, each six bytes in little endian
1582 * @NL80211_KEY_DEFAULT: flag indicating default key 2066 * @NL80211_KEY_DEFAULT: flag indicating default key
1583 * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key 2067 * @NL80211_KEY_DEFAULT_MGMT: flag indicating default management key
2068 * @NL80211_KEY_TYPE: the key type from enum nl80211_key_type, if not
2069 * specified the default depends on whether a MAC address was
2070 * given with the command using the key or not (u32)
2071 * @NL80211_KEY_DEFAULT_TYPES: A nested attribute containing flags
2072 * attributes, specifying what a key should be set as default as.
2073 * See &enum nl80211_key_default_types.
1584 * @__NL80211_KEY_AFTER_LAST: internal 2074 * @__NL80211_KEY_AFTER_LAST: internal
1585 * @NL80211_KEY_MAX: highest key attribute 2075 * @NL80211_KEY_MAX: highest key attribute
1586 */ 2076 */
@@ -1592,6 +2082,8 @@ enum nl80211_key_attributes {
1592 NL80211_KEY_SEQ, 2082 NL80211_KEY_SEQ,
1593 NL80211_KEY_DEFAULT, 2083 NL80211_KEY_DEFAULT,
1594 NL80211_KEY_DEFAULT_MGMT, 2084 NL80211_KEY_DEFAULT_MGMT,
2085 NL80211_KEY_TYPE,
2086 NL80211_KEY_DEFAULT_TYPES,
1595 2087
1596 /* keep last */ 2088 /* keep last */
1597 __NL80211_KEY_AFTER_LAST, 2089 __NL80211_KEY_AFTER_LAST,
@@ -1619,8 +2111,8 @@ enum nl80211_tx_rate_attributes {
1619 2111
1620/** 2112/**
1621 * enum nl80211_band - Frequency band 2113 * enum nl80211_band - Frequency band
1622 * @NL80211_BAND_2GHZ - 2.4 GHz ISM band 2114 * @NL80211_BAND_2GHZ: 2.4 GHz ISM band
1623 * @NL80211_BAND_5GHZ - around 5 GHz band (4.9 - 5.7 GHz) 2115 * @NL80211_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz)
1624 */ 2116 */
1625enum nl80211_band { 2117enum nl80211_band {
1626 NL80211_BAND_2GHZ, 2118 NL80211_BAND_2GHZ,
@@ -1642,6 +2134,8 @@ enum nl80211_ps_state {
1642 * the minimum amount the RSSI level must change after an event before a 2134 * the minimum amount the RSSI level must change after an event before a
1643 * new event may be issued (to reduce effects of RSSI oscillation). 2135 * new event may be issued (to reduce effects of RSSI oscillation).
1644 * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event 2136 * @NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT: RSSI threshold event
2137 * @NL80211_ATTR_CQM_PKT_LOSS_EVENT: a u32 value indicating that this many
2138 * consecutive packets were not acknowledged by the peer
1645 * @__NL80211_ATTR_CQM_AFTER_LAST: internal 2139 * @__NL80211_ATTR_CQM_AFTER_LAST: internal
1646 * @NL80211_ATTR_CQM_MAX: highest key attribute 2140 * @NL80211_ATTR_CQM_MAX: highest key attribute
1647 */ 2141 */
@@ -1650,6 +2144,7 @@ enum nl80211_attr_cqm {
1650 NL80211_ATTR_CQM_RSSI_THOLD, 2144 NL80211_ATTR_CQM_RSSI_THOLD,
1651 NL80211_ATTR_CQM_RSSI_HYST, 2145 NL80211_ATTR_CQM_RSSI_HYST,
1652 NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT, 2146 NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
2147 NL80211_ATTR_CQM_PKT_LOSS_EVENT,
1653 2148
1654 /* keep last */ 2149 /* keep last */
1655 __NL80211_ATTR_CQM_AFTER_LAST, 2150 __NL80211_ATTR_CQM_AFTER_LAST,
@@ -1658,9 +2153,9 @@ enum nl80211_attr_cqm {
1658 2153
1659/** 2154/**
1660 * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event 2155 * enum nl80211_cqm_rssi_threshold_event - RSSI threshold event
1661 * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW - The RSSI level is lower than the 2156 * @NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
1662 * configured threshold 2157 * configured threshold
1663 * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH - The RSSI is higher than the 2158 * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
1664 * configured threshold 2159 * configured threshold
1665 */ 2160 */
1666enum nl80211_cqm_rssi_threshold_event { 2161enum nl80211_cqm_rssi_threshold_event {
@@ -1681,4 +2176,189 @@ enum nl80211_tx_power_setting {
1681 NL80211_TX_POWER_FIXED, 2176 NL80211_TX_POWER_FIXED,
1682}; 2177};
1683 2178
2179/**
2180 * enum nl80211_wowlan_packet_pattern_attr - WoWLAN packet pattern attribute
2181 * @__NL80211_WOWLAN_PKTPAT_INVALID: invalid number for nested attribute
2182 * @NL80211_WOWLAN_PKTPAT_PATTERN: the pattern, values where the mask has
2183 * a zero bit are ignored
2184 * @NL80211_WOWLAN_PKTPAT_MASK: pattern mask, must be long enough to have
2185 * a bit for each byte in the pattern. The lowest-order bit corresponds
2186 * to the first byte of the pattern, but the bytes of the pattern are
2187 * in a little-endian-like format, i.e. the 9th byte of the pattern
2188 * corresponds to the lowest-order bit in the second byte of the mask.
2189 * For example: The match 00:xx:00:00:xx:00:00:00:00:xx:xx:xx (where
2190 * xx indicates "don't care") would be represented by a pattern of
2191 * twelve zero bytes, and a mask of "0xed,0x07".
2192 * Note that the pattern matching is done as though frames were not
2193 * 802.11 frames but 802.3 frames, i.e. the frame is fully unpacked
2194 * first (including SNAP header unpacking) and then matched.
2195 * @NUM_NL80211_WOWLAN_PKTPAT: number of attributes
2196 * @MAX_NL80211_WOWLAN_PKTPAT: max attribute number
2197 */
2198enum nl80211_wowlan_packet_pattern_attr {
2199 __NL80211_WOWLAN_PKTPAT_INVALID,
2200 NL80211_WOWLAN_PKTPAT_MASK,
2201 NL80211_WOWLAN_PKTPAT_PATTERN,
2202
2203 NUM_NL80211_WOWLAN_PKTPAT,
2204 MAX_NL80211_WOWLAN_PKTPAT = NUM_NL80211_WOWLAN_PKTPAT - 1,
2205};
2206
2207/**
2208 * struct nl80211_wowlan_pattern_support - pattern support information
2209 * @max_patterns: maximum number of patterns supported
2210 * @min_pattern_len: minimum length of each pattern
2211 * @max_pattern_len: maximum length of each pattern
2212 *
2213 * This struct is carried in %NL80211_WOWLAN_TRIG_PKT_PATTERN when
2214 * that is part of %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED in the
2215 * capability information given by the kernel to userspace.
2216 */
2217struct nl80211_wowlan_pattern_support {
2218 __u32 max_patterns;
2219 __u32 min_pattern_len;
2220 __u32 max_pattern_len;
2221} __attribute__((packed));
2222
2223/**
2224 * enum nl80211_wowlan_triggers - WoWLAN trigger definitions
2225 * @__NL80211_WOWLAN_TRIG_INVALID: invalid number for nested attributes
2226 * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put
2227 * the chip into a special state -- works best with chips that have
2228 * support for low-power operation already (flag)
2229 * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect
2230 * is detected is implementation-specific (flag)
2231 * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed
2232 * by 16 repetitions of MAC addr, anywhere in payload) (flag)
2233 * @NL80211_WOWLAN_TRIG_PKT_PATTERN: wake up on the specified packet patterns
2234 * which are passed in an array of nested attributes, each nested attribute
2235 * defining a with attributes from &struct nl80211_wowlan_trig_pkt_pattern.
2236 * Each pattern defines a wakeup packet. The matching is done on the MSDU,
2237 * i.e. as though the packet was an 802.3 packet, so the pattern matching
2238 * is done after the packet is converted to the MSDU.
2239 *
2240 * In %NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED, it is a binary attribute
2241 * carrying a &struct nl80211_wowlan_pattern_support.
2242 * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers
2243 * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number
2244 */
2245enum nl80211_wowlan_triggers {
2246 __NL80211_WOWLAN_TRIG_INVALID,
2247 NL80211_WOWLAN_TRIG_ANY,
2248 NL80211_WOWLAN_TRIG_DISCONNECT,
2249 NL80211_WOWLAN_TRIG_MAGIC_PKT,
2250 NL80211_WOWLAN_TRIG_PKT_PATTERN,
2251
2252 /* keep last */
2253 NUM_NL80211_WOWLAN_TRIG,
2254 MAX_NL80211_WOWLAN_TRIG = NUM_NL80211_WOWLAN_TRIG - 1
2255};
2256
2257/**
2258 * enum nl80211_iface_limit_attrs - limit attributes
2259 * @NL80211_IFACE_LIMIT_UNSPEC: (reserved)
2260 * @NL80211_IFACE_LIMIT_MAX: maximum number of interfaces that
2261 * can be chosen from this set of interface types (u32)
2262 * @NL80211_IFACE_LIMIT_TYPES: nested attribute containing a
2263 * flag attribute for each interface type in this set
2264 * @NUM_NL80211_IFACE_LIMIT: number of attributes
2265 * @MAX_NL80211_IFACE_LIMIT: highest attribute number
2266 */
2267enum nl80211_iface_limit_attrs {
2268 NL80211_IFACE_LIMIT_UNSPEC,
2269 NL80211_IFACE_LIMIT_MAX,
2270 NL80211_IFACE_LIMIT_TYPES,
2271
2272 /* keep last */
2273 NUM_NL80211_IFACE_LIMIT,
2274 MAX_NL80211_IFACE_LIMIT = NUM_NL80211_IFACE_LIMIT - 1
2275};
2276
2277/**
2278 * enum nl80211_if_combination_attrs -- interface combination attributes
2279 *
2280 * @NL80211_IFACE_COMB_UNSPEC: (reserved)
2281 * @NL80211_IFACE_COMB_LIMITS: Nested attributes containing the limits
2282 * for given interface types, see &enum nl80211_iface_limit_attrs.
2283 * @NL80211_IFACE_COMB_MAXNUM: u32 attribute giving the total number of
2284 * interfaces that can be created in this group. This number doesn't
2285 * apply to interfaces purely managed in software, which are listed
2286 * in a separate attribute %NL80211_ATTR_INTERFACES_SOFTWARE.
2287 * @NL80211_IFACE_COMB_STA_AP_BI_MATCH: flag attribute specifying that
2288 * beacon intervals within this group must be all the same even for
2289 * infrastructure and AP/GO combinations, i.e. the GO(s) must adopt
2290 * the infrastructure network's beacon interval.
2291 * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
2292 * different channels may be used within this group.
2293 * @NUM_NL80211_IFACE_COMB: number of attributes
2294 * @MAX_NL80211_IFACE_COMB: highest attribute number
2295 *
2296 * Examples:
2297 * limits = [ #{STA} <= 1, #{AP} <= 1 ], matching BI, channels = 1, max = 2
2298 * => allows an AP and a STA that must match BIs
2299 *
2300 * numbers = [ #{AP, P2P-GO} <= 8 ], channels = 1, max = 8
2301 * => allows 8 of AP/GO
2302 *
2303 * numbers = [ #{STA} <= 2 ], channels = 2, max = 2
2304 * => allows two STAs on different channels
2305 *
2306 * numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
2307 * => allows a STA plus three P2P interfaces
2308 *
2309 * The list of these four possiblities could completely be contained
2310 * within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate
2311 * that any of these groups must match.
2312 *
2313 * "Combinations" of just a single interface will not be listed here,
2314 * a single interface of any valid interface type is assumed to always
2315 * be possible by itself. This means that implicitly, for each valid
2316 * interface type, the following group always exists:
2317 * numbers = [ #{<type>} <= 1 ], channels = 1, max = 1
2318 */
2319enum nl80211_if_combination_attrs {
2320 NL80211_IFACE_COMB_UNSPEC,
2321 NL80211_IFACE_COMB_LIMITS,
2322 NL80211_IFACE_COMB_MAXNUM,
2323 NL80211_IFACE_COMB_STA_AP_BI_MATCH,
2324 NL80211_IFACE_COMB_NUM_CHANNELS,
2325
2326 /* keep last */
2327 NUM_NL80211_IFACE_COMB,
2328 MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1
2329};
2330
2331
2332/**
2333 * enum nl80211_plink_state - state of a mesh peer link finite state machine
2334 *
2335 * @NL80211_PLINK_LISTEN: initial state, considered the implicit
2336 * state of non existant mesh peer links
2337 * @NL80211_PLINK_OPN_SNT: mesh plink open frame has been sent to
2338 * this mesh peer
2339 * @NL80211_PLINK_OPN_RCVD: mesh plink open frame has been received
2340 * from this mesh peer
2341 * @NL80211_PLINK_CNF_RCVD: mesh plink confirm frame has been
2342 * received from this mesh peer
2343 * @NL80211_PLINK_ESTAB: mesh peer link is established
2344 * @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled
2345 * @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh
2346 * plink are discarded
2347 * @NUM_NL80211_PLINK_STATES: number of peer link states
2348 * @MAX_NL80211_PLINK_STATES: highest numerical value of plink states
2349 */
2350enum nl80211_plink_state {
2351 NL80211_PLINK_LISTEN,
2352 NL80211_PLINK_OPN_SNT,
2353 NL80211_PLINK_OPN_RCVD,
2354 NL80211_PLINK_CNF_RCVD,
2355 NL80211_PLINK_ESTAB,
2356 NL80211_PLINK_HOLDING,
2357 NL80211_PLINK_BLOCKED,
2358
2359 /* keep last */
2360 NUM_NL80211_PLINK_STATES,
2361 MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
2362};
2363
1684#endif /* __LINUX_NL80211_H */ 2364#endif /* __LINUX_NL80211_H */
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 06aab5eee134..2d304efc89df 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -14,22 +14,14 @@
14 * may be used to reset the timeout - for code which intentionally 14 * may be used to reset the timeout - for code which intentionally
15 * disables interrupts for a long time. This call is stateless. 15 * disables interrupts for a long time. This call is stateless.
16 */ 16 */
17#ifdef ARCH_HAS_NMI_WATCHDOG 17#if defined(ARCH_HAS_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
18#include <asm/nmi.h> 18#include <asm/nmi.h>
19extern void touch_nmi_watchdog(void); 19extern void touch_nmi_watchdog(void);
20extern void acpi_nmi_disable(void);
21extern void acpi_nmi_enable(void);
22#else 20#else
23#ifndef CONFIG_HARDLOCKUP_DETECTOR
24static inline void touch_nmi_watchdog(void) 21static inline void touch_nmi_watchdog(void)
25{ 22{
26 touch_softlockup_watchdog(); 23 touch_softlockup_watchdog();
27} 24}
28#else
29extern void touch_nmi_watchdog(void);
30#endif
31static inline void acpi_nmi_disable(void) { }
32static inline void acpi_nmi_enable(void) { }
33#endif 25#endif
34 26
35/* 27/*
@@ -53,11 +45,12 @@ static inline bool trigger_all_cpu_backtrace(void)
53 45
54#ifdef CONFIG_LOCKUP_DETECTOR 46#ifdef CONFIG_LOCKUP_DETECTOR
55int hw_nmi_is_cpu_stuck(struct pt_regs *); 47int hw_nmi_is_cpu_stuck(struct pt_regs *);
56u64 hw_nmi_get_sample_period(void); 48u64 hw_nmi_get_sample_period(int watchdog_thresh);
57extern int watchdog_enabled; 49extern int watchdog_enabled;
50extern int watchdog_thresh;
58struct ctl_table; 51struct ctl_table;
59extern int proc_dowatchdog_enabled(struct ctl_table *, int , 52extern int proc_dowatchdog(struct ctl_table *, int ,
60 void __user *, size_t *, loff_t *); 53 void __user *, size_t *, loff_t *);
61#endif 54#endif
62 55
63#endif 56#endif
diff --git a/include/linux/node.h b/include/linux/node.h
index 06292dac3eab..92370e22343c 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -10,11 +10,6 @@
10 * 10 *
11 * Nodes are exported via driverfs in the class/node/devices/ 11 * Nodes are exported via driverfs in the class/node/devices/
12 * directory. 12 * directory.
13 *
14 * Per-node interfaces can be implemented using a struct device_interface.
15 * See the following for how to do this:
16 * - drivers/base/intf.c
17 * - Documentation/driver-model/interface.txt
18 */ 13 */
19#ifndef _LINUX_NODE_H_ 14#ifndef _LINUX_NODE_H_
20#define _LINUX_NODE_H_ 15#define _LINUX_NODE_H_
@@ -44,7 +39,8 @@ extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
44extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); 39extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
45extern int register_mem_sect_under_node(struct memory_block *mem_blk, 40extern int register_mem_sect_under_node(struct memory_block *mem_blk,
46 int nid); 41 int nid);
47extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk); 42extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
43 unsigned long phys_index);
48 44
49#ifdef CONFIG_HUGETLBFS 45#ifdef CONFIG_HUGETLBFS
50extern void register_hugetlbfs_with_node(node_registration_func_t doregister, 46extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
@@ -72,7 +68,8 @@ static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
72{ 68{
73 return 0; 69 return 0;
74} 70}
75static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk) 71static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
72 unsigned long phys_index)
76{ 73{
77 return 0; 74 return 0;
78} 75}
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index b2f1a4d83550..c0688b0168b3 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -49,28 +49,28 @@
49 49
50struct notifier_block { 50struct notifier_block {
51 int (*notifier_call)(struct notifier_block *, unsigned long, void *); 51 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
52 struct notifier_block *next; 52 struct notifier_block __rcu *next;
53 int priority; 53 int priority;
54}; 54};
55 55
56struct atomic_notifier_head { 56struct atomic_notifier_head {
57 spinlock_t lock; 57 spinlock_t lock;
58 struct notifier_block *head; 58 struct notifier_block __rcu *head;
59}; 59};
60 60
61struct blocking_notifier_head { 61struct blocking_notifier_head {
62 struct rw_semaphore rwsem; 62 struct rw_semaphore rwsem;
63 struct notifier_block *head; 63 struct notifier_block __rcu *head;
64}; 64};
65 65
66struct raw_notifier_head { 66struct raw_notifier_head {
67 struct notifier_block *head; 67 struct notifier_block __rcu *head;
68}; 68};
69 69
70struct srcu_notifier_head { 70struct srcu_notifier_head {
71 struct mutex mutex; 71 struct mutex mutex;
72 struct srcu_struct srcu; 72 struct srcu_struct srcu;
73 struct notifier_block *head; 73 struct notifier_block __rcu *head;
74}; 74};
75 75
76#define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \ 76#define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \
@@ -209,8 +209,9 @@ static inline int notifier_to_errno(int ret)
209#define NETDEV_POST_TYPE_CHANGE 0x000F 209#define NETDEV_POST_TYPE_CHANGE 0x000F
210#define NETDEV_POST_INIT 0x0010 210#define NETDEV_POST_INIT 0x0010
211#define NETDEV_UNREGISTER_BATCH 0x0011 211#define NETDEV_UNREGISTER_BATCH 0x0011
212#define NETDEV_BONDING_DESLAVE 0x0012 212#define NETDEV_RELEASE 0x0012
213#define NETDEV_NOTIFY_PEERS 0x0013 213#define NETDEV_NOTIFY_PEERS 0x0013
214#define NETDEV_JOIN 0x0014
214 215
215#define SYS_DOWN 0x0001 /* Notify of system down */ 216#define SYS_DOWN 0x0001 /* Notify of system down */
216#define SYS_RESTART SYS_DOWN 217#define SYS_RESTART SYS_DOWN
@@ -237,7 +238,7 @@ static inline int notifier_to_errno(int ret)
237 * enabling interrupts. Must not sleep, 238 * enabling interrupts. Must not sleep,
238 * must not fail */ 239 * must not fail */
239 240
240/* Used for CPU hotplug events occuring while tasks are frozen due to a suspend 241/* Used for CPU hotplug events occurring while tasks are frozen due to a suspend
241 * operation in progress 242 * operation in progress
242 */ 243 */
243#define CPU_TASKS_FROZEN 0x0010 244#define CPU_TASKS_FROZEN 0x0010
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
index 7b370c7cfeff..50d20aba57d3 100644
--- a/include/linux/nsproxy.h
+++ b/include/linux/nsproxy.h
@@ -81,13 +81,4 @@ static inline void get_nsproxy(struct nsproxy *ns)
81 atomic_inc(&ns->count); 81 atomic_inc(&ns->count);
82} 82}
83 83
84#ifdef CONFIG_CGROUP_NS
85int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid);
86#else
87static inline int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid)
88{
89 return 0;
90}
91#endif
92
93#endif 84#endif
diff --git a/include/linux/of.h b/include/linux/of.h
index cad7cf0ab278..bfc0ed1b0ced 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -23,8 +23,6 @@
23 23
24#include <asm/byteorder.h> 24#include <asm/byteorder.h>
25 25
26#ifdef CONFIG_OF
27
28typedef u32 phandle; 26typedef u32 phandle;
29typedef u32 ihandle; 27typedef u32 ihandle;
30 28
@@ -65,11 +63,18 @@ struct device_node {
65#endif 63#endif
66}; 64};
67 65
66#ifdef CONFIG_OF
67
68/* Pointer for first entry in chain of all nodes. */ 68/* Pointer for first entry in chain of all nodes. */
69extern struct device_node *allnodes; 69extern struct device_node *allnodes;
70extern struct device_node *of_chosen; 70extern struct device_node *of_chosen;
71extern rwlock_t devtree_lock; 71extern rwlock_t devtree_lock;
72 72
73static inline bool of_have_populated_dt(void)
74{
75 return allnodes != NULL;
76}
77
73static inline bool of_node_is_root(const struct device_node *node) 78static inline bool of_node_is_root(const struct device_node *node)
74{ 79{
75 return node && (node->parent == NULL); 80 return node && (node->parent == NULL);
@@ -103,7 +108,7 @@ extern void of_node_put(struct device_node *node);
103#endif 108#endif
104 109
105/* 110/*
106 * OF address retreival & translation 111 * OF address retrieval & translation
107 */ 112 */
108 113
109/* Helper to read a big number; size is in cells (not bytes) */ 114/* Helper to read a big number; size is in cells (not bytes) */
@@ -222,5 +227,12 @@ extern void of_attach_node(struct device_node *);
222extern void of_detach_node(struct device_node *); 227extern void of_detach_node(struct device_node *);
223#endif 228#endif
224 229
230#else
231
232static inline bool of_have_populated_dt(void)
233{
234 return false;
235}
236
225#endif /* CONFIG_OF */ 237#endif /* CONFIG_OF */
226#endif /* _LINUX_OF_H */ 238#endif /* _LINUX_OF_H */
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 8aea06f0564c..2feda6ee6140 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -3,7 +3,7 @@
3#include <linux/ioport.h> 3#include <linux/ioport.h>
4#include <linux/of.h> 4#include <linux/of.h>
5 5
6extern u64 of_translate_address(struct device_node *np, const u32 *addr); 6extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
7extern int of_address_to_resource(struct device_node *dev, int index, 7extern int of_address_to_resource(struct device_node *dev, int index,
8 struct resource *r); 8 struct resource *r);
9extern void __iomem *of_iomap(struct device_node *device, int index); 9extern void __iomem *of_iomap(struct device_node *device, int index);
@@ -21,7 +21,7 @@ static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
21#endif 21#endif
22 22
23#ifdef CONFIG_PCI 23#ifdef CONFIG_PCI
24extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, 24extern const __be32 *of_get_pci_address(struct device_node *dev, int bar_no,
25 u64 *size, unsigned int *flags); 25 u64 *size, unsigned int *flags);
26extern int of_pci_address_to_resource(struct device_node *dev, int bar, 26extern int of_pci_address_to_resource(struct device_node *dev, int bar,
27 struct resource *r); 27 struct resource *r);
@@ -32,7 +32,7 @@ static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
32 return -ENOSYS; 32 return -ENOSYS;
33} 33}
34 34
35static inline const u32 *of_get_pci_address(struct device_node *dev, 35static inline const __be32 *of_get_pci_address(struct device_node *dev,
36 int bar_no, u64 *size, unsigned int *flags) 36 int bar_no, u64 *size, unsigned int *flags)
37{ 37{
38 return NULL; 38 return NULL;
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 835f85ecd2de..ae5638480ef2 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -18,7 +18,7 @@ extern void of_device_make_bus_id(struct device *dev);
18 * @drv: the device_driver structure to test 18 * @drv: the device_driver structure to test
19 * @dev: the device structure to match against 19 * @dev: the device structure to match against
20 */ 20 */
21static inline int of_driver_match_device(const struct device *dev, 21static inline int of_driver_match_device(struct device *dev,
22 const struct device_driver *drv) 22 const struct device_driver *drv)
23{ 23{
24 return of_match_device(drv->of_match_table, dev) != NULL; 24 return of_match_device(drv->of_match_table, dev) != NULL;
@@ -27,20 +27,19 @@ static inline int of_driver_match_device(const struct device *dev,
27extern struct platform_device *of_dev_get(struct platform_device *dev); 27extern struct platform_device *of_dev_get(struct platform_device *dev);
28extern void of_dev_put(struct platform_device *dev); 28extern void of_dev_put(struct platform_device *dev);
29 29
30extern int of_device_add(struct platform_device *pdev);
30extern int of_device_register(struct platform_device *ofdev); 31extern int of_device_register(struct platform_device *ofdev);
31extern void of_device_unregister(struct platform_device *ofdev); 32extern void of_device_unregister(struct platform_device *ofdev);
32extern void of_release_dev(struct device *dev);
33
34static inline void of_device_free(struct platform_device *dev)
35{
36 of_release_dev(&dev->dev);
37}
38 33
39extern ssize_t of_device_get_modalias(struct device *dev, 34extern ssize_t of_device_get_modalias(struct device *dev,
40 char *str, ssize_t len); 35 char *str, ssize_t len);
41 36
42extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env); 37extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
43 38
39static inline void of_device_node_put(struct device *dev)
40{
41 of_node_put(dev->of_node);
42}
44 43
45#else /* CONFIG_OF_DEVICE */ 44#else /* CONFIG_OF_DEVICE */
46 45
@@ -56,6 +55,13 @@ static inline int of_device_uevent(struct device *dev,
56 return -ENODEV; 55 return -ENODEV;
57} 56}
58 57
58static inline void of_device_node_put(struct device *dev) { }
59
60static inline const struct of_device_id *of_match_device(
61 const struct of_device_id *matches, const struct device *dev)
62{
63 return NULL;
64}
59#endif /* CONFIG_OF_DEVICE */ 65#endif /* CONFIG_OF_DEVICE */
60 66
61#endif /* _LINUX_OF_DEVICE_H */ 67#endif /* _LINUX_OF_DEVICE_H */
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 71e1a916d3fa..c84d900fbbb3 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -58,6 +58,23 @@ struct boot_param_header {
58}; 58};
59 59
60#if defined(CONFIG_OF_FLATTREE) 60#if defined(CONFIG_OF_FLATTREE)
61
62struct device_node;
63
64/* For scanning an arbitrary device-tree at any time */
65extern char *of_fdt_get_string(struct boot_param_header *blob, u32 offset);
66extern void *of_fdt_get_property(struct boot_param_header *blob,
67 unsigned long node,
68 const char *name,
69 unsigned long *size);
70extern int of_fdt_is_compatible(struct boot_param_header *blob,
71 unsigned long node,
72 const char *compat);
73extern int of_fdt_match(struct boot_param_header *blob, unsigned long node,
74 const char **compat);
75extern void of_fdt_unflatten_tree(unsigned long *blob,
76 struct device_node **mynodes);
77
61/* TBD: Temporary export of fdt globals - remove when code fully merged */ 78/* TBD: Temporary export of fdt globals - remove when code fully merged */
62extern int __initdata dt_root_addr_cells; 79extern int __initdata dt_root_addr_cells;
63extern int __initdata dt_root_size_cells; 80extern int __initdata dt_root_size_cells;
@@ -71,15 +88,16 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
71extern void *of_get_flat_dt_prop(unsigned long node, const char *name, 88extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
72 unsigned long *size); 89 unsigned long *size);
73extern int of_flat_dt_is_compatible(unsigned long node, const char *name); 90extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
91extern int of_flat_dt_match(unsigned long node, const char **matches);
74extern unsigned long of_get_flat_dt_root(void); 92extern unsigned long of_get_flat_dt_root(void);
75extern void early_init_dt_scan_chosen_arch(unsigned long node); 93
76extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, 94extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
77 int depth, void *data); 95 int depth, void *data);
78extern void early_init_dt_check_for_initrd(unsigned long node); 96extern void early_init_dt_check_for_initrd(unsigned long node);
79extern int early_init_dt_scan_memory(unsigned long node, const char *uname, 97extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
80 int depth, void *data); 98 int depth, void *data);
81extern void early_init_dt_add_memory_arch(u64 base, u64 size); 99extern void early_init_dt_add_memory_arch(u64 base, u64 size);
82extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align); 100extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align);
83extern u64 dt_mem_next_cell(int s, __be32 **cellp); 101extern u64 dt_mem_next_cell(int s, __be32 **cellp);
84 102
85/* 103/*
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 5929781c104d..e6955f5d1f08 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -5,6 +5,7 @@
5struct of_irq; 5struct of_irq;
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/errno.h> 7#include <linux/errno.h>
8#include <linux/irq.h>
8#include <linux/ioport.h> 9#include <linux/ioport.h>
9#include <linux/of.h> 10#include <linux/of.h>
10 11
@@ -64,6 +65,10 @@ extern unsigned int irq_create_of_mapping(struct device_node *controller,
64 unsigned int intsize); 65 unsigned int intsize);
65extern int of_irq_to_resource(struct device_node *dev, int index, 66extern int of_irq_to_resource(struct device_node *dev, int index,
66 struct resource *r); 67 struct resource *r);
68extern int of_irq_count(struct device_node *dev);
69extern int of_irq_to_resource_table(struct device_node *dev,
70 struct resource *res, int nr_irqs);
71extern struct device_node *of_irq_find_parent(struct device_node *child);
67 72
68#endif /* CONFIG_OF_IRQ */ 73#endif /* CONFIG_OF_IRQ */
69#endif /* CONFIG_OF */ 74#endif /* CONFIG_OF */
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
new file mode 100644
index 000000000000..e913081fb52a
--- /dev/null
+++ b/include/linux/of_net.h
@@ -0,0 +1,15 @@
1/*
2 * OF helpers for network devices.
3 *
4 * This file is released under the GPLv2
5 */
6
7#ifndef __LINUX_OF_NET_H
8#define __LINUX_OF_NET_H
9
10#ifdef CONFIG_OF_NET
11#include <linux/of.h>
12extern const void *of_get_mac_address(struct device_node *np);
13#endif
14
15#endif /* __LINUX_OF_NET_H */
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h
new file mode 100644
index 000000000000..85a27b650d76
--- /dev/null
+++ b/include/linux/of_pci.h
@@ -0,0 +1,9 @@
1#ifndef __OF_PCI_H
2#define __OF_PCI_H
3
4#include <linux/pci.h>
5
6struct pci_dev;
7struct of_irq;
8int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
9#endif
diff --git a/include/linux/of_pdt.h b/include/linux/of_pdt.h
new file mode 100644
index 000000000000..c65a18a0cfdf
--- /dev/null
+++ b/include/linux/of_pdt.h
@@ -0,0 +1,45 @@
1/*
2 * Definitions for building a device tree by calling into the
3 * Open Firmware PROM.
4 *
5 * Copyright (C) 2010 Andres Salomon <dilinger@queued.net>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef _LINUX_OF_PDT_H
14#define _LINUX_OF_PDT_H
15
16/* overridable operations for calling into the PROM */
17struct of_pdt_ops {
18 /*
19 * buf should be 32 bytes; return 0 on success.
20 * If prev is NULL, the first property will be returned.
21 */
22 int (*nextprop)(phandle node, char *prev, char *buf);
23
24 /* for both functions, return proplen on success; -1 on error */
25 int (*getproplen)(phandle node, const char *prop);
26 int (*getproperty)(phandle node, const char *prop, char *buf,
27 int bufsize);
28
29 /* phandles are 0 if no child or sibling exists */
30 phandle (*getchild)(phandle parent);
31 phandle (*getsibling)(phandle node);
32
33 /* return 0 on success; fill in 'len' with number of bytes in path */
34 int (*pkg2path)(phandle node, char *buf, const int buflen, int *len);
35};
36
37extern void *prom_early_alloc(unsigned long size);
38
39/* for building the device tree */
40extern void of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops);
41
42extern void (*of_pdt_build_more)(struct device_node *dp,
43 struct device_node ***nextp);
44
45#endif /* _LINUX_OF_PDT_H */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index a68716ad38ce..fb51ae38cea7 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -23,13 +23,7 @@
23 * of_platform_driver - Legacy of-aware driver for platform devices. 23 * of_platform_driver - Legacy of-aware driver for platform devices.
24 * 24 *
25 * An of_platform_driver driver is attached to a basic platform_device on 25 * An of_platform_driver driver is attached to a basic platform_device on
26 * ether the "platform bus" (platform_bus_type), or the ibm ebus 26 * the ibm ebus (ibmebus_bus_type).
27 * (ibmebus_bus_type).
28 *
29 * of_platform_driver is being phased out when used with the platform_bus_type,
30 * and regular platform_drivers should be used instead. When the transition
31 * is complete, only ibmebus will be using this structure, and the
32 * platform_driver member of this structure will be removed.
33 */ 27 */
34struct of_platform_driver 28struct of_platform_driver
35{ 29{
@@ -42,35 +36,22 @@ struct of_platform_driver
42 int (*shutdown)(struct platform_device* dev); 36 int (*shutdown)(struct platform_device* dev);
43 37
44 struct device_driver driver; 38 struct device_driver driver;
45 struct platform_driver platform_driver;
46}; 39};
47#define to_of_platform_driver(drv) \ 40#define to_of_platform_driver(drv) \
48 container_of(drv,struct of_platform_driver, driver) 41 container_of(drv,struct of_platform_driver, driver)
49 42
50extern int of_register_driver(struct of_platform_driver *drv,
51 struct bus_type *bus);
52extern void of_unregister_driver(struct of_platform_driver *drv);
53
54/* Platform drivers register/unregister */ 43/* Platform drivers register/unregister */
55extern int of_register_platform_driver(struct of_platform_driver *drv);
56extern void of_unregister_platform_driver(struct of_platform_driver *drv);
57
58extern struct platform_device *of_device_alloc(struct device_node *np, 44extern struct platform_device *of_device_alloc(struct device_node *np,
59 const char *bus_id, 45 const char *bus_id,
60 struct device *parent); 46 struct device *parent);
61extern struct platform_device *of_find_device_by_node(struct device_node *np); 47extern struct platform_device *of_find_device_by_node(struct device_node *np);
62 48
63extern int of_bus_type_init(struct bus_type *bus, const char *name);
64
65#if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */ 49#if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */
66/* Platform devices and busses creation */ 50/* Platform devices and busses creation */
67extern struct platform_device *of_platform_device_create(struct device_node *np, 51extern struct platform_device *of_platform_device_create(struct device_node *np,
68 const char *bus_id, 52 const char *bus_id,
69 struct device *parent); 53 struct device *parent);
70 54
71/* pseudo "matches" value to not do deep probe */
72#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
73
74extern int of_platform_bus_probe(struct device_node *root, 55extern int of_platform_bus_probe(struct device_node *root,
75 const struct of_device_id *matches, 56 const struct of_device_id *matches,
76 struct device *parent); 57 struct device *parent);
diff --git a/include/linux/omap3isp.h b/include/linux/omap3isp.h
new file mode 100644
index 000000000000..b6111f8cd49a
--- /dev/null
+++ b/include/linux/omap3isp.h
@@ -0,0 +1,646 @@
1/*
2 * omap3isp.h
3 *
4 * TI OMAP3 ISP - User-space API
5 *
6 * Copyright (C) 2010 Nokia Corporation
7 * Copyright (C) 2009 Texas Instruments, Inc.
8 *
9 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 * Sakari Ailus <sakari.ailus@iki.fi>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 * 02110-1301 USA
25 */
26
27#ifndef OMAP3_ISP_USER_H
28#define OMAP3_ISP_USER_H
29
30#include <linux/types.h>
31
32/*
33 * Private IOCTLs
34 *
35 * VIDIOC_OMAP3ISP_CCDC_CFG: Set CCDC configuration
36 * VIDIOC_OMAP3ISP_PRV_CFG: Set preview engine configuration
37 * VIDIOC_OMAP3ISP_AEWB_CFG: Set AEWB module configuration
38 * VIDIOC_OMAP3ISP_HIST_CFG: Set histogram module configuration
39 * VIDIOC_OMAP3ISP_AF_CFG: Set auto-focus module configuration
40 * VIDIOC_OMAP3ISP_STAT_REQ: Read statistics (AEWB/AF/histogram) data
41 * VIDIOC_OMAP3ISP_STAT_EN: Enable/disable a statistics module
42 */
43
44#define VIDIOC_OMAP3ISP_CCDC_CFG \
45 _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct omap3isp_ccdc_update_config)
46#define VIDIOC_OMAP3ISP_PRV_CFG \
47 _IOWR('V', BASE_VIDIOC_PRIVATE + 2, struct omap3isp_prev_update_config)
48#define VIDIOC_OMAP3ISP_AEWB_CFG \
49 _IOWR('V', BASE_VIDIOC_PRIVATE + 3, struct omap3isp_h3a_aewb_config)
50#define VIDIOC_OMAP3ISP_HIST_CFG \
51 _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct omap3isp_hist_config)
52#define VIDIOC_OMAP3ISP_AF_CFG \
53 _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct omap3isp_h3a_af_config)
54#define VIDIOC_OMAP3ISP_STAT_REQ \
55 _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct omap3isp_stat_data)
56#define VIDIOC_OMAP3ISP_STAT_EN \
57 _IOWR('V', BASE_VIDIOC_PRIVATE + 7, unsigned long)
58
59/*
60 * Events
61 *
62 * V4L2_EVENT_OMAP3ISP_AEWB: AEWB statistics data ready
63 * V4L2_EVENT_OMAP3ISP_AF: AF statistics data ready
64 * V4L2_EVENT_OMAP3ISP_HIST: Histogram statistics data ready
65 * V4L2_EVENT_OMAP3ISP_HS_VS: Horizontal/vertical synchronization detected
66 */
67
68#define V4L2_EVENT_OMAP3ISP_CLASS (V4L2_EVENT_PRIVATE_START | 0x100)
69#define V4L2_EVENT_OMAP3ISP_AEWB (V4L2_EVENT_OMAP3ISP_CLASS | 0x1)
70#define V4L2_EVENT_OMAP3ISP_AF (V4L2_EVENT_OMAP3ISP_CLASS | 0x2)
71#define V4L2_EVENT_OMAP3ISP_HIST (V4L2_EVENT_OMAP3ISP_CLASS | 0x3)
72#define V4L2_EVENT_OMAP3ISP_HS_VS (V4L2_EVENT_OMAP3ISP_CLASS | 0x4)
73
74struct omap3isp_stat_event_status {
75 __u32 frame_number;
76 __u16 config_counter;
77 __u8 buf_err;
78};
79
80/* AE/AWB related structures and flags*/
81
82/* H3A Range Constants */
83#define OMAP3ISP_AEWB_MAX_SATURATION_LIM 1023
84#define OMAP3ISP_AEWB_MIN_WIN_H 2
85#define OMAP3ISP_AEWB_MAX_WIN_H 256
86#define OMAP3ISP_AEWB_MIN_WIN_W 6
87#define OMAP3ISP_AEWB_MAX_WIN_W 256
88#define OMAP3ISP_AEWB_MIN_WINVC 1
89#define OMAP3ISP_AEWB_MIN_WINHC 1
90#define OMAP3ISP_AEWB_MAX_WINVC 128
91#define OMAP3ISP_AEWB_MAX_WINHC 36
92#define OMAP3ISP_AEWB_MAX_WINSTART 4095
93#define OMAP3ISP_AEWB_MIN_SUB_INC 2
94#define OMAP3ISP_AEWB_MAX_SUB_INC 32
95#define OMAP3ISP_AEWB_MAX_BUF_SIZE 83600
96
97#define OMAP3ISP_AF_IIRSH_MIN 0
98#define OMAP3ISP_AF_IIRSH_MAX 4095
99#define OMAP3ISP_AF_PAXEL_HORIZONTAL_COUNT_MIN 1
100#define OMAP3ISP_AF_PAXEL_HORIZONTAL_COUNT_MAX 36
101#define OMAP3ISP_AF_PAXEL_VERTICAL_COUNT_MIN 1
102#define OMAP3ISP_AF_PAXEL_VERTICAL_COUNT_MAX 128
103#define OMAP3ISP_AF_PAXEL_INCREMENT_MIN 2
104#define OMAP3ISP_AF_PAXEL_INCREMENT_MAX 32
105#define OMAP3ISP_AF_PAXEL_HEIGHT_MIN 2
106#define OMAP3ISP_AF_PAXEL_HEIGHT_MAX 256
107#define OMAP3ISP_AF_PAXEL_WIDTH_MIN 16
108#define OMAP3ISP_AF_PAXEL_WIDTH_MAX 256
109#define OMAP3ISP_AF_PAXEL_HZSTART_MIN 1
110#define OMAP3ISP_AF_PAXEL_HZSTART_MAX 4095
111#define OMAP3ISP_AF_PAXEL_VTSTART_MIN 0
112#define OMAP3ISP_AF_PAXEL_VTSTART_MAX 4095
113#define OMAP3ISP_AF_THRESHOLD_MAX 255
114#define OMAP3ISP_AF_COEF_MAX 4095
115#define OMAP3ISP_AF_PAXEL_SIZE 48
116#define OMAP3ISP_AF_MAX_BUF_SIZE 221184
117
118/**
119 * struct omap3isp_h3a_aewb_config - AE AWB configuration reset values
120 * saturation_limit: Saturation limit.
121 * @win_height: Window Height. Range 2 - 256, even values only.
122 * @win_width: Window Width. Range 6 - 256, even values only.
123 * @ver_win_count: Vertical Window Count. Range 1 - 128.
124 * @hor_win_count: Horizontal Window Count. Range 1 - 36.
125 * @ver_win_start: Vertical Window Start. Range 0 - 4095.
126 * @hor_win_start: Horizontal Window Start. Range 0 - 4095.
127 * @blk_ver_win_start: Black Vertical Windows Start. Range 0 - 4095.
128 * @blk_win_height: Black Window Height. Range 2 - 256, even values only.
129 * @subsample_ver_inc: Subsample Vertical points increment Range 2 - 32, even
130 * values only.
131 * @subsample_hor_inc: Subsample Horizontal points increment Range 2 - 32, even
132 * values only.
133 * @alaw_enable: AEW ALAW EN flag.
134 */
135struct omap3isp_h3a_aewb_config {
136 /*
137 * Common fields.
138 * They should be the first ones and must be in the same order as in
139 * ispstat_generic_config struct.
140 */
141 __u32 buf_size;
142 __u16 config_counter;
143
144 /* Private fields */
145 __u16 saturation_limit;
146 __u16 win_height;
147 __u16 win_width;
148 __u16 ver_win_count;
149 __u16 hor_win_count;
150 __u16 ver_win_start;
151 __u16 hor_win_start;
152 __u16 blk_ver_win_start;
153 __u16 blk_win_height;
154 __u16 subsample_ver_inc;
155 __u16 subsample_hor_inc;
156 __u8 alaw_enable;
157};
158
159/**
160 * struct omap3isp_stat_data - Statistic data sent to or received from user
161 * @ts: Timestamp of returned framestats.
162 * @buf: Pointer to pass to user.
163 * @frame_number: Frame number of requested stats.
164 * @cur_frame: Current frame number being processed.
165 * @config_counter: Number of the configuration associated with the data.
166 */
167struct omap3isp_stat_data {
168 struct timeval ts;
169 void __user *buf;
170 __u32 buf_size;
171 __u16 frame_number;
172 __u16 cur_frame;
173 __u16 config_counter;
174};
175
176
177/* Histogram related structs */
178
179/* Flags for number of bins */
180#define OMAP3ISP_HIST_BINS_32 0
181#define OMAP3ISP_HIST_BINS_64 1
182#define OMAP3ISP_HIST_BINS_128 2
183#define OMAP3ISP_HIST_BINS_256 3
184
185/* Number of bins * 4 colors * 4-bytes word */
186#define OMAP3ISP_HIST_MEM_SIZE_BINS(n) ((1 << ((n)+5))*4*4)
187
188#define OMAP3ISP_HIST_MEM_SIZE 1024
189#define OMAP3ISP_HIST_MIN_REGIONS 1
190#define OMAP3ISP_HIST_MAX_REGIONS 4
191#define OMAP3ISP_HIST_MAX_WB_GAIN 255
192#define OMAP3ISP_HIST_MIN_WB_GAIN 0
193#define OMAP3ISP_HIST_MAX_BIT_WIDTH 14
194#define OMAP3ISP_HIST_MIN_BIT_WIDTH 8
195#define OMAP3ISP_HIST_MAX_WG 4
196#define OMAP3ISP_HIST_MAX_BUF_SIZE 4096
197
198/* Source */
199#define OMAP3ISP_HIST_SOURCE_CCDC 0
200#define OMAP3ISP_HIST_SOURCE_MEM 1
201
202/* CFA pattern */
203#define OMAP3ISP_HIST_CFA_BAYER 0
204#define OMAP3ISP_HIST_CFA_FOVEONX3 1
205
206struct omap3isp_hist_region {
207 __u16 h_start;
208 __u16 h_end;
209 __u16 v_start;
210 __u16 v_end;
211};
212
213struct omap3isp_hist_config {
214 /*
215 * Common fields.
216 * They should be the first ones and must be in the same order as in
217 * ispstat_generic_config struct.
218 */
219 __u32 buf_size;
220 __u16 config_counter;
221
222 __u8 num_acc_frames; /* Num of image frames to be processed and
223 accumulated for each histogram frame */
224 __u16 hist_bins; /* number of bins: 32, 64, 128, or 256 */
225 __u8 cfa; /* BAYER or FOVEON X3 */
226 __u8 wg[OMAP3ISP_HIST_MAX_WG]; /* White Balance Gain */
227 __u8 num_regions; /* number of regions to be configured */
228 struct omap3isp_hist_region region[OMAP3ISP_HIST_MAX_REGIONS];
229};
230
231/* Auto Focus related structs */
232
233#define OMAP3ISP_AF_NUM_COEF 11
234
235enum omap3isp_h3a_af_fvmode {
236 OMAP3ISP_AF_MODE_SUMMED = 0,
237 OMAP3ISP_AF_MODE_PEAK = 1
238};
239
240/* Red, Green, and blue pixel location in the AF windows */
241enum omap3isp_h3a_af_rgbpos {
242 OMAP3ISP_AF_GR_GB_BAYER = 0, /* GR and GB as Bayer pattern */
243 OMAP3ISP_AF_RG_GB_BAYER = 1, /* RG and GB as Bayer pattern */
244 OMAP3ISP_AF_GR_BG_BAYER = 2, /* GR and BG as Bayer pattern */
245 OMAP3ISP_AF_RG_BG_BAYER = 3, /* RG and BG as Bayer pattern */
246 OMAP3ISP_AF_GG_RB_CUSTOM = 4, /* GG and RB as custom pattern */
247 OMAP3ISP_AF_RB_GG_CUSTOM = 5 /* RB and GG as custom pattern */
248};
249
250/* Contains the information regarding the Horizontal Median Filter */
251struct omap3isp_h3a_af_hmf {
252 __u8 enable; /* Status of Horizontal Median Filter */
253 __u8 threshold; /* Threshold Value for Horizontal Median Filter */
254};
255
256/* Contains the information regarding the IIR Filters */
257struct omap3isp_h3a_af_iir {
258 __u16 h_start; /* IIR horizontal start */
259 __u16 coeff_set0[OMAP3ISP_AF_NUM_COEF]; /* Filter coefficient, set 0 */
260 __u16 coeff_set1[OMAP3ISP_AF_NUM_COEF]; /* Filter coefficient, set 1 */
261};
262
263/* Contains the information regarding the Paxels Structure in AF Engine */
264struct omap3isp_h3a_af_paxel {
265 __u16 h_start; /* Horizontal Start Position */
266 __u16 v_start; /* Vertical Start Position */
267 __u8 width; /* Width of the Paxel */
268 __u8 height; /* Height of the Paxel */
269 __u8 h_cnt; /* Horizontal Count */
270 __u8 v_cnt; /* vertical Count */
271 __u8 line_inc; /* Line Increment */
272};
273
274/* Contains the parameters required for hardware set up of AF Engine */
275struct omap3isp_h3a_af_config {
276 /*
277 * Common fields.
278 * They should be the first ones and must be in the same order as in
279 * ispstat_generic_config struct.
280 */
281 __u32 buf_size;
282 __u16 config_counter;
283
284 struct omap3isp_h3a_af_hmf hmf; /* HMF configurations */
285 struct omap3isp_h3a_af_iir iir; /* IIR filter configurations */
286 struct omap3isp_h3a_af_paxel paxel; /* Paxel parameters */
287 enum omap3isp_h3a_af_rgbpos rgb_pos; /* RGB Positions */
288 enum omap3isp_h3a_af_fvmode fvmode; /* Accumulator mode */
289 __u8 alaw_enable; /* AF ALAW status */
290};
291
292/* ISP CCDC structs */
293
294/* Abstraction layer CCDC configurations */
295#define OMAP3ISP_CCDC_ALAW (1 << 0)
296#define OMAP3ISP_CCDC_LPF (1 << 1)
297#define OMAP3ISP_CCDC_BLCLAMP (1 << 2)
298#define OMAP3ISP_CCDC_BCOMP (1 << 3)
299#define OMAP3ISP_CCDC_FPC (1 << 4)
300#define OMAP3ISP_CCDC_CULL (1 << 5)
301#define OMAP3ISP_CCDC_CONFIG_LSC (1 << 7)
302#define OMAP3ISP_CCDC_TBL_LSC (1 << 8)
303
304#define OMAP3ISP_RGB_MAX 3
305
306/* Enumeration constants for Alaw input width */
307enum omap3isp_alaw_ipwidth {
308 OMAP3ISP_ALAW_BIT12_3 = 0x3,
309 OMAP3ISP_ALAW_BIT11_2 = 0x4,
310 OMAP3ISP_ALAW_BIT10_1 = 0x5,
311 OMAP3ISP_ALAW_BIT9_0 = 0x6
312};
313
314/**
315 * struct omap3isp_ccdc_lsc_config - LSC configuration
316 * @offset: Table Offset of the gain table.
317 * @gain_mode_n: Vertical dimension of a paxel in LSC configuration.
318 * @gain_mode_m: Horizontal dimension of a paxel in LSC configuration.
319 * @gain_format: Gain table format.
320 * @fmtsph: Start pixel horizontal from start of the HS sync pulse.
321 * @fmtlnh: Number of pixels in horizontal direction to use for the data
322 * reformatter.
323 * @fmtslv: Start line from start of VS sync pulse for the data reformatter.
324 * @fmtlnv: Number of lines in vertical direction for the data reformatter.
325 * @initial_x: X position, in pixels, of the first active pixel in reference
326 * to the first active paxel. Must be an even number.
327 * @initial_y: Y position, in pixels, of the first active pixel in reference
328 * to the first active paxel. Must be an even number.
329 * @size: Size of LSC gain table. Filled when loaded from userspace.
330 */
331struct omap3isp_ccdc_lsc_config {
332 __u16 offset;
333 __u8 gain_mode_n;
334 __u8 gain_mode_m;
335 __u8 gain_format;
336 __u16 fmtsph;
337 __u16 fmtlnh;
338 __u16 fmtslv;
339 __u16 fmtlnv;
340 __u8 initial_x;
341 __u8 initial_y;
342 __u32 size;
343};
344
345/**
346 * struct omap3isp_ccdc_bclamp - Optical & Digital black clamp subtract
347 * @obgain: Optical black average gain.
348 * @obstpixel: Start Pixel w.r.t. HS pulse in Optical black sample.
349 * @oblines: Optical Black Sample lines.
350 * @oblen: Optical Black Sample Length.
351 * @dcsubval: Digital Black Clamp subtract value.
352 */
353struct omap3isp_ccdc_bclamp {
354 __u8 obgain;
355 __u8 obstpixel;
356 __u8 oblines;
357 __u8 oblen;
358 __u16 dcsubval;
359};
360
361/**
362 * struct omap3isp_ccdc_fpc - Faulty Pixels Correction
363 * @fpnum: Number of faulty pixels to be corrected in the frame.
364 * @fpcaddr: Memory address of the FPC Table
365 */
366struct omap3isp_ccdc_fpc {
367 __u16 fpnum;
368 __u32 fpcaddr;
369};
370
371/**
372 * struct omap3isp_ccdc_blcomp - Black Level Compensation parameters
373 * @b_mg: B/Mg pixels. 2's complement. -128 to +127.
374 * @gb_g: Gb/G pixels. 2's complement. -128 to +127.
375 * @gr_cy: Gr/Cy pixels. 2's complement. -128 to +127.
376 * @r_ye: R/Ye pixels. 2's complement. -128 to +127.
377 */
378struct omap3isp_ccdc_blcomp {
379 __u8 b_mg;
380 __u8 gb_g;
381 __u8 gr_cy;
382 __u8 r_ye;
383};
384
385/**
386 * omap3isp_ccdc_culling - Culling parameters
387 * @v_pattern: Vertical culling pattern.
388 * @h_odd: Horizontal Culling pattern for odd lines.
389 * @h_even: Horizontal Culling pattern for even lines.
390 */
391struct omap3isp_ccdc_culling {
392 __u8 v_pattern;
393 __u16 h_odd;
394 __u16 h_even;
395};
396
397/**
398 * omap3isp_ccdc_update_config - CCDC configuration
399 * @update: Specifies which CCDC registers should be updated.
400 * @flag: Specifies which CCDC functions should be enabled.
401 * @alawip: Enable/Disable A-Law compression.
402 * @bclamp: Black clamp control register.
403 * @blcomp: Black level compensation value for RGrGbB Pixels. 2's complement.
404 * @fpc: Number of faulty pixels corrected in the frame, address of FPC table.
405 * @cull: Cull control register.
406 * @lsc: Pointer to LSC gain table.
407 */
408struct omap3isp_ccdc_update_config {
409 __u16 update;
410 __u16 flag;
411 enum omap3isp_alaw_ipwidth alawip;
412 struct omap3isp_ccdc_bclamp __user *bclamp;
413 struct omap3isp_ccdc_blcomp __user *blcomp;
414 struct omap3isp_ccdc_fpc __user *fpc;
415 struct omap3isp_ccdc_lsc_config __user *lsc_cfg;
416 struct omap3isp_ccdc_culling __user *cull;
417 __u8 __user *lsc;
418};
419
420/* Preview configurations */
421#define OMAP3ISP_PREV_LUMAENH (1 << 0)
422#define OMAP3ISP_PREV_INVALAW (1 << 1)
423#define OMAP3ISP_PREV_HRZ_MED (1 << 2)
424#define OMAP3ISP_PREV_CFA (1 << 3)
425#define OMAP3ISP_PREV_CHROMA_SUPP (1 << 4)
426#define OMAP3ISP_PREV_WB (1 << 5)
427#define OMAP3ISP_PREV_BLKADJ (1 << 6)
428#define OMAP3ISP_PREV_RGB2RGB (1 << 7)
429#define OMAP3ISP_PREV_COLOR_CONV (1 << 8)
430#define OMAP3ISP_PREV_YC_LIMIT (1 << 9)
431#define OMAP3ISP_PREV_DEFECT_COR (1 << 10)
432#define OMAP3ISP_PREV_GAMMABYPASS (1 << 11)
433#define OMAP3ISP_PREV_DRK_FRM_CAPTURE (1 << 12)
434#define OMAP3ISP_PREV_DRK_FRM_SUBTRACT (1 << 13)
435#define OMAP3ISP_PREV_LENS_SHADING (1 << 14)
436#define OMAP3ISP_PREV_NF (1 << 15)
437#define OMAP3ISP_PREV_GAMMA (1 << 16)
438
439#define OMAP3ISP_PREV_NF_TBL_SIZE 64
440#define OMAP3ISP_PREV_CFA_TBL_SIZE 576
441#define OMAP3ISP_PREV_GAMMA_TBL_SIZE 1024
442#define OMAP3ISP_PREV_YENH_TBL_SIZE 128
443
444#define OMAP3ISP_PREV_DETECT_CORRECT_CHANNELS 4
445
446/**
447 * struct omap3isp_prev_hmed - Horizontal Median Filter
448 * @odddist: Distance between consecutive pixels of same color in the odd line.
449 * @evendist: Distance between consecutive pixels of same color in the even
450 * line.
451 * @thres: Horizontal median filter threshold.
452 */
453struct omap3isp_prev_hmed {
454 __u8 odddist;
455 __u8 evendist;
456 __u8 thres;
457};
458
459/*
460 * Enumeration for CFA Formats supported by preview
461 */
462enum omap3isp_cfa_fmt {
463 OMAP3ISP_CFAFMT_BAYER,
464 OMAP3ISP_CFAFMT_SONYVGA,
465 OMAP3ISP_CFAFMT_RGBFOVEON,
466 OMAP3ISP_CFAFMT_DNSPL,
467 OMAP3ISP_CFAFMT_HONEYCOMB,
468 OMAP3ISP_CFAFMT_RRGGBBFOVEON
469};
470
471/**
472 * struct omap3isp_prev_cfa - CFA Interpolation
473 * @format: CFA Format Enum value supported by preview.
474 * @gradthrs_vert: CFA Gradient Threshold - Vertical.
475 * @gradthrs_horz: CFA Gradient Threshold - Horizontal.
476 * @table: Pointer to the CFA table.
477 */
478struct omap3isp_prev_cfa {
479 enum omap3isp_cfa_fmt format;
480 __u8 gradthrs_vert;
481 __u8 gradthrs_horz;
482 __u32 table[OMAP3ISP_PREV_CFA_TBL_SIZE];
483};
484
485/**
486 * struct omap3isp_prev_csup - Chrominance Suppression
487 * @gain: Gain.
488 * @thres: Threshold.
489 * @hypf_en: Flag to enable/disable the High Pass Filter.
490 */
491struct omap3isp_prev_csup {
492 __u8 gain;
493 __u8 thres;
494 __u8 hypf_en;
495};
496
497/**
498 * struct omap3isp_prev_wbal - White Balance
499 * @dgain: Digital gain (U10Q8).
500 * @coef3: White balance gain - COEF 3 (U8Q5).
501 * @coef2: White balance gain - COEF 2 (U8Q5).
502 * @coef1: White balance gain - COEF 1 (U8Q5).
503 * @coef0: White balance gain - COEF 0 (U8Q5).
504 */
505struct omap3isp_prev_wbal {
506 __u16 dgain;
507 __u8 coef3;
508 __u8 coef2;
509 __u8 coef1;
510 __u8 coef0;
511};
512
513/**
514 * struct omap3isp_prev_blkadj - Black Level Adjustment
515 * @red: Black level offset adjustment for Red in 2's complement format
516 * @green: Black level offset adjustment for Green in 2's complement format
517 * @blue: Black level offset adjustment for Blue in 2's complement format
518 */
519struct omap3isp_prev_blkadj {
520 /*Black level offset adjustment for Red in 2's complement format */
521 __u8 red;
522 /*Black level offset adjustment for Green in 2's complement format */
523 __u8 green;
524 /* Black level offset adjustment for Blue in 2's complement format */
525 __u8 blue;
526};
527
528/**
529 * struct omap3isp_prev_rgbtorgb - RGB to RGB Blending
530 * @matrix: Blending values(S12Q8 format)
531 * [RR] [GR] [BR]
532 * [RG] [GG] [BG]
533 * [RB] [GB] [BB]
534 * @offset: Blending offset value for R,G,B in 2's complement integer format.
535 */
536struct omap3isp_prev_rgbtorgb {
537 __u16 matrix[OMAP3ISP_RGB_MAX][OMAP3ISP_RGB_MAX];
538 __u16 offset[OMAP3ISP_RGB_MAX];
539};
540
541/**
542 * struct omap3isp_prev_csc - Color Space Conversion from RGB-YCbYCr
543 * @matrix: Color space conversion coefficients(S10Q8)
544 * [CSCRY] [CSCGY] [CSCBY]
545 * [CSCRCB] [CSCGCB] [CSCBCB]
546 * [CSCRCR] [CSCGCR] [CSCBCR]
547 * @offset: CSC offset values for Y offset, CB offset and CR offset respectively
548 */
549struct omap3isp_prev_csc {
550 __u16 matrix[OMAP3ISP_RGB_MAX][OMAP3ISP_RGB_MAX];
551 __s16 offset[OMAP3ISP_RGB_MAX];
552};
553
554/**
555 * struct omap3isp_prev_yclimit - Y, C Value Limit
556 * @minC: Minimum C value
557 * @maxC: Maximum C value
558 * @minY: Minimum Y value
559 * @maxY: Maximum Y value
560 */
561struct omap3isp_prev_yclimit {
562 __u8 minC;
563 __u8 maxC;
564 __u8 minY;
565 __u8 maxY;
566};
567
568/**
569 * struct omap3isp_prev_dcor - Defect correction
570 * @couplet_mode_en: Flag to enable or disable the couplet dc Correction in NF
571 * @detect_correct: Thresholds for correction bit 0:10 detect 16:25 correct
572 */
573struct omap3isp_prev_dcor {
574 __u8 couplet_mode_en;
575 __u32 detect_correct[OMAP3ISP_PREV_DETECT_CORRECT_CHANNELS];
576};
577
578/**
579 * struct omap3isp_prev_nf - Noise Filter
580 * @spread: Spread value to be used in Noise Filter
581 * @table: Pointer to the Noise Filter table
582 */
583struct omap3isp_prev_nf {
584 __u8 spread;
585 __u32 table[OMAP3ISP_PREV_NF_TBL_SIZE];
586};
587
588/**
589 * struct omap3isp_prev_gtables - Gamma correction tables
590 * @red: Array for red gamma table.
591 * @green: Array for green gamma table.
592 * @blue: Array for blue gamma table.
593 */
594struct omap3isp_prev_gtables {
595 __u32 red[OMAP3ISP_PREV_GAMMA_TBL_SIZE];
596 __u32 green[OMAP3ISP_PREV_GAMMA_TBL_SIZE];
597 __u32 blue[OMAP3ISP_PREV_GAMMA_TBL_SIZE];
598};
599
600/**
601 * struct omap3isp_prev_luma - Luma enhancement
602 * @table: Array for luma enhancement table.
603 */
604struct omap3isp_prev_luma {
605 __u32 table[OMAP3ISP_PREV_YENH_TBL_SIZE];
606};
607
608/**
609 * struct omap3isp_prev_update_config - Preview engine configuration (user)
610 * @update: Specifies which ISP Preview registers should be updated.
611 * @flag: Specifies which ISP Preview functions should be enabled.
612 * @shading_shift: 3bit value of shift used in shading compensation.
613 * @luma: Pointer to luma enhancement structure.
614 * @hmed: Pointer to structure containing the odd and even distance.
615 * between the pixels in the image along with the filter threshold.
616 * @cfa: Pointer to structure containing the CFA interpolation table, CFA.
617 * format in the image, vertical and horizontal gradient threshold.
618 * @csup: Pointer to Structure for Chrominance Suppression coefficients.
619 * @wbal: Pointer to structure for White Balance.
620 * @blkadj: Pointer to structure for Black Adjustment.
621 * @rgb2rgb: Pointer to structure for RGB to RGB Blending.
622 * @csc: Pointer to structure for Color Space Conversion from RGB-YCbYCr.
623 * @yclimit: Pointer to structure for Y, C Value Limit.
624 * @dcor: Pointer to structure for defect correction.
625 * @nf: Pointer to structure for Noise Filter
626 * @gamma: Pointer to gamma structure.
627 */
628struct omap3isp_prev_update_config {
629 __u32 update;
630 __u32 flag;
631 __u32 shading_shift;
632 struct omap3isp_prev_luma __user *luma;
633 struct omap3isp_prev_hmed __user *hmed;
634 struct omap3isp_prev_cfa __user *cfa;
635 struct omap3isp_prev_csup __user *csup;
636 struct omap3isp_prev_wbal __user *wbal;
637 struct omap3isp_prev_blkadj __user *blkadj;
638 struct omap3isp_prev_rgbtorgb __user *rgb2rgb;
639 struct omap3isp_prev_csc __user *csc;
640 struct omap3isp_prev_yclimit __user *yclimit;
641 struct omap3isp_prev_dcor __user *dcor;
642 struct omap3isp_prev_nf __user *nf;
643 struct omap3isp_prev_gtables __user *gamma;
644};
645
646#endif /* OMAP3_ISP_USER_H */
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 5e3aa8311c5e..4952fb874ad3 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -40,6 +40,8 @@ enum oom_constraint {
40 CONSTRAINT_MEMCG, 40 CONSTRAINT_MEMCG,
41}; 41};
42 42
43extern int test_set_oom_score_adj(int new_val);
44
43extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem, 45extern unsigned int oom_badness(struct task_struct *p, struct mem_cgroup *mem,
44 const nodemask_t *nodemask, unsigned long totalpages); 46 const nodemask_t *nodemask, unsigned long totalpages);
45extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags); 47extern int try_set_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
diff --git a/include/linux/opp.h b/include/linux/opp.h
new file mode 100644
index 000000000000..5449945d589f
--- /dev/null
+++ b/include/linux/opp.h
@@ -0,0 +1,105 @@
1/*
2 * Generic OPP Interface
3 *
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5 * Nishanth Menon
6 * Romit Dasgupta
7 * Kevin Hilman
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __LINUX_OPP_H__
15#define __LINUX_OPP_H__
16
17#include <linux/err.h>
18#include <linux/cpufreq.h>
19
20struct opp;
21
22#if defined(CONFIG_PM_OPP)
23
24unsigned long opp_get_voltage(struct opp *opp);
25
26unsigned long opp_get_freq(struct opp *opp);
27
28int opp_get_opp_count(struct device *dev);
29
30struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
31 bool available);
32
33struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
34
35struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
36
37int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
38
39int opp_enable(struct device *dev, unsigned long freq);
40
41int opp_disable(struct device *dev, unsigned long freq);
42
43#else
44static inline unsigned long opp_get_voltage(struct opp *opp)
45{
46 return 0;
47}
48
49static inline unsigned long opp_get_freq(struct opp *opp)
50{
51 return 0;
52}
53
54static inline int opp_get_opp_count(struct device *dev)
55{
56 return 0;
57}
58
59static inline struct opp *opp_find_freq_exact(struct device *dev,
60 unsigned long freq, bool available)
61{
62 return ERR_PTR(-EINVAL);
63}
64
65static inline struct opp *opp_find_freq_floor(struct device *dev,
66 unsigned long *freq)
67{
68 return ERR_PTR(-EINVAL);
69}
70
71static inline struct opp *opp_find_freq_ceil(struct device *dev,
72 unsigned long *freq)
73{
74 return ERR_PTR(-EINVAL);
75}
76
77static inline int opp_add(struct device *dev, unsigned long freq,
78 unsigned long u_volt)
79{
80 return -EINVAL;
81}
82
83static inline int opp_enable(struct device *dev, unsigned long freq)
84{
85 return 0;
86}
87
88static inline int opp_disable(struct device *dev, unsigned long freq)
89{
90 return 0;
91}
92#endif /* CONFIG_PM */
93
94#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
95int opp_init_cpufreq_table(struct device *dev,
96 struct cpufreq_frequency_table **table);
97#else
98static inline int opp_init_cpufreq_table(struct device *dev,
99 struct cpufreq_frequency_table **table)
100{
101 return -EINVAL;
102}
103#endif /* CONFIG_CPU_FREQ */
104
105#endif /* __LINUX_OPP_H__ */
diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
index 5171639ecf0f..7f5cfd3b37dd 100644
--- a/include/linux/oprofile.h
+++ b/include/linux/oprofile.h
@@ -15,6 +15,9 @@
15 15
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/init.h>
19#include <linux/errno.h>
20#include <linux/printk.h>
18#include <asm/atomic.h> 21#include <asm/atomic.h>
19 22
20/* Each escaped entry is prefixed by ESCAPE_CODE 23/* Each escaped entry is prefixed by ESCAPE_CODE
@@ -103,6 +106,13 @@ void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
103void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, 106void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
104 unsigned long event, int is_kernel); 107 unsigned long event, int is_kernel);
105 108
109/**
110 * Add an hardware sample.
111 */
112void oprofile_add_ext_hw_sample(unsigned long pc, struct pt_regs * const regs,
113 unsigned long event, int is_kernel,
114 struct task_struct *task);
115
106/* Use this instead when the PC value is not from the regs. Doesn't 116/* Use this instead when the PC value is not from the regs. Doesn't
107 * backtrace. */ 117 * backtrace. */
108void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event); 118void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
@@ -185,4 +195,17 @@ int oprofile_add_data(struct op_entry *entry, unsigned long val);
185int oprofile_add_data64(struct op_entry *entry, u64 val); 195int oprofile_add_data64(struct op_entry *entry, u64 val);
186int oprofile_write_commit(struct op_entry *entry); 196int oprofile_write_commit(struct op_entry *entry);
187 197
198#ifdef CONFIG_HW_PERF_EVENTS
199int __init oprofile_perf_init(struct oprofile_operations *ops);
200void oprofile_perf_exit(void);
201char *op_name_from_perf_id(void);
202#else
203static inline int __init oprofile_perf_init(struct oprofile_operations *ops)
204{
205 pr_info("oprofile: hardware counters not available\n");
206 return -ENODEV;
207}
208static inline void oprofile_perf_exit(void) { }
209#endif /* CONFIG_HW_PERF_EVENTS */
210
188#endif /* OPROFILE_H */ 211#endif /* OPROFILE_H */
diff --git a/include/linux/padata.h b/include/linux/padata.h
index bdcd1e9eacea..4633b2f726b6 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -127,8 +127,8 @@ struct padata_cpumask {
127 */ 127 */
128struct parallel_data { 128struct parallel_data {
129 struct padata_instance *pinst; 129 struct padata_instance *pinst;
130 struct padata_parallel_queue *pqueue; 130 struct padata_parallel_queue __percpu *pqueue;
131 struct padata_serial_queue *squeue; 131 struct padata_serial_queue __percpu *squeue;
132 atomic_t seq_nr; 132 atomic_t seq_nr;
133 atomic_t reorder_objects; 133 atomic_t reorder_objects;
134 atomic_t refcnt; 134 atomic_t refcnt;
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 6fa317801e1c..6081493db68f 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -48,9 +48,6 @@
48 * struct page (these bits with information) are always mapped into kernel 48 * struct page (these bits with information) are always mapped into kernel
49 * address space... 49 * address space...
50 * 50 *
51 * PG_buddy is set to indicate that the page is free and in the buddy system
52 * (see mm/page_alloc.c).
53 *
54 * PG_hwpoison indicates that a page got corrupted in hardware and contains 51 * PG_hwpoison indicates that a page got corrupted in hardware and contains
55 * data with incorrect ECC bits that triggered a machine check. Accessing is 52 * data with incorrect ECC bits that triggered a machine check. Accessing is
56 * not safe since it may cause another machine check. Don't touch! 53 * not safe since it may cause another machine check. Don't touch!
@@ -96,7 +93,6 @@ enum pageflags {
96 PG_swapcache, /* Swap page: swp_entry_t in private */ 93 PG_swapcache, /* Swap page: swp_entry_t in private */
97 PG_mappedtodisk, /* Has blocks allocated on-disk */ 94 PG_mappedtodisk, /* Has blocks allocated on-disk */
98 PG_reclaim, /* To be reclaimed asap */ 95 PG_reclaim, /* To be reclaimed asap */
99 PG_buddy, /* Page is free, on buddy lists */
100 PG_swapbacked, /* Page is backed by RAM/swap */ 96 PG_swapbacked, /* Page is backed by RAM/swap */
101 PG_unevictable, /* Page is "unevictable" */ 97 PG_unevictable, /* Page is "unevictable" */
102#ifdef CONFIG_MMU 98#ifdef CONFIG_MMU
@@ -108,6 +104,9 @@ enum pageflags {
108#ifdef CONFIG_MEMORY_FAILURE 104#ifdef CONFIG_MEMORY_FAILURE
109 PG_hwpoison, /* hardware poisoned page. Don't touch */ 105 PG_hwpoison, /* hardware poisoned page. Don't touch */
110#endif 106#endif
107#ifdef CONFIG_TRANSPARENT_HUGEPAGE
108 PG_compound_lock,
109#endif
111 __NR_PAGEFLAGS, 110 __NR_PAGEFLAGS,
112 111
113 /* Filesystems */ 112 /* Filesystems */
@@ -197,8 +196,8 @@ static inline int __TestClearPage##uname(struct page *page) { return 0; }
197 196
198struct page; /* forward declaration */ 197struct page; /* forward declaration */
199 198
200TESTPAGEFLAG(Locked, locked) TESTSETFLAG(Locked, locked) 199TESTPAGEFLAG(Locked, locked)
201PAGEFLAG(Error, error) 200PAGEFLAG(Error, error) TESTCLEARFLAG(Error, error)
202PAGEFLAG(Referenced, referenced) TESTCLEARFLAG(Referenced, referenced) 201PAGEFLAG(Referenced, referenced) TESTCLEARFLAG(Referenced, referenced)
203PAGEFLAG(Dirty, dirty) TESTSCFLAG(Dirty, dirty) __CLEARPAGEFLAG(Dirty, dirty) 202PAGEFLAG(Dirty, dirty) TESTSCFLAG(Dirty, dirty) __CLEARPAGEFLAG(Dirty, dirty)
204PAGEFLAG(LRU, lru) __CLEARPAGEFLAG(LRU, lru) 203PAGEFLAG(LRU, lru) __CLEARPAGEFLAG(LRU, lru)
@@ -230,7 +229,6 @@ PAGEFLAG(OwnerPriv1, owner_priv_1) TESTCLEARFLAG(OwnerPriv1, owner_priv_1)
230 * risky: they bypass page accounting. 229 * risky: they bypass page accounting.
231 */ 230 */
232TESTPAGEFLAG(Writeback, writeback) TESTSCFLAG(Writeback, writeback) 231TESTPAGEFLAG(Writeback, writeback) TESTSCFLAG(Writeback, writeback)
233__PAGEFLAG(Buddy, buddy)
234PAGEFLAG(MappedToDisk, mappedtodisk) 232PAGEFLAG(MappedToDisk, mappedtodisk)
235 233
236/* PG_readahead is only used for file reads; PG_reclaim is only for writes */ 234/* PG_readahead is only used for file reads; PG_reclaim is only for writes */
@@ -310,7 +308,7 @@ static inline void SetPageUptodate(struct page *page)
310{ 308{
311#ifdef CONFIG_S390 309#ifdef CONFIG_S390
312 if (!test_and_set_bit(PG_uptodate, &page->flags)) 310 if (!test_and_set_bit(PG_uptodate, &page->flags))
313 page_clear_dirty(page); 311 page_set_storage_key(page_to_phys(page), PAGE_DEFAULT_KEY, 0);
314#else 312#else
315 /* 313 /*
316 * Memory barrier must be issued before setting the PG_uptodate bit, 314 * Memory barrier must be issued before setting the PG_uptodate bit,
@@ -344,7 +342,7 @@ static inline void set_page_writeback(struct page *page)
344 * tests can be used in performance sensitive paths. PageCompound is 342 * tests can be used in performance sensitive paths. PageCompound is
345 * generally not used in hot code paths. 343 * generally not used in hot code paths.
346 */ 344 */
347__PAGEFLAG(Head, head) 345__PAGEFLAG(Head, head) CLEARPAGEFLAG(Head, head)
348__PAGEFLAG(Tail, tail) 346__PAGEFLAG(Tail, tail)
349 347
350static inline int PageCompound(struct page *page) 348static inline int PageCompound(struct page *page)
@@ -352,6 +350,13 @@ static inline int PageCompound(struct page *page)
352 return page->flags & ((1L << PG_head) | (1L << PG_tail)); 350 return page->flags & ((1L << PG_head) | (1L << PG_tail));
353 351
354} 352}
353#ifdef CONFIG_TRANSPARENT_HUGEPAGE
354static inline void ClearPageCompound(struct page *page)
355{
356 BUG_ON(!PageHead(page));
357 ClearPageHead(page);
358}
359#endif
355#else 360#else
356/* 361/*
357 * Reduce page flag use as much as possible by overlapping 362 * Reduce page flag use as much as possible by overlapping
@@ -389,14 +394,61 @@ static inline void __ClearPageTail(struct page *page)
389 page->flags &= ~PG_head_tail_mask; 394 page->flags &= ~PG_head_tail_mask;
390} 395}
391 396
397#ifdef CONFIG_TRANSPARENT_HUGEPAGE
398static inline void ClearPageCompound(struct page *page)
399{
400 BUG_ON((page->flags & PG_head_tail_mask) != (1 << PG_compound));
401 clear_bit(PG_compound, &page->flags);
402}
403#endif
404
392#endif /* !PAGEFLAGS_EXTENDED */ 405#endif /* !PAGEFLAGS_EXTENDED */
393 406
407#ifdef CONFIG_TRANSPARENT_HUGEPAGE
408/*
409 * PageHuge() only returns true for hugetlbfs pages, but not for
410 * normal or transparent huge pages.
411 *
412 * PageTransHuge() returns true for both transparent huge and
413 * hugetlbfs pages, but not normal pages. PageTransHuge() can only be
414 * called only in the core VM paths where hugetlbfs pages can't exist.
415 */
416static inline int PageTransHuge(struct page *page)
417{
418 VM_BUG_ON(PageTail(page));
419 return PageHead(page);
420}
421
422static inline int PageTransCompound(struct page *page)
423{
424 return PageCompound(page);
425}
426
427#else
428
429static inline int PageTransHuge(struct page *page)
430{
431 return 0;
432}
433
434static inline int PageTransCompound(struct page *page)
435{
436 return 0;
437}
438#endif
439
394#ifdef CONFIG_MMU 440#ifdef CONFIG_MMU
395#define __PG_MLOCKED (1 << PG_mlocked) 441#define __PG_MLOCKED (1 << PG_mlocked)
396#else 442#else
397#define __PG_MLOCKED 0 443#define __PG_MLOCKED 0
398#endif 444#endif
399 445
446#ifdef CONFIG_TRANSPARENT_HUGEPAGE
447#define __PG_COMPOUND_LOCK (1 << PG_compound_lock)
448#else
449#define __PG_COMPOUND_LOCK 0
450#endif
451
400/* 452/*
401 * Flags checked when a page is freed. Pages being freed should not have 453 * Flags checked when a page is freed. Pages being freed should not have
402 * these flags set. It they are, there is a problem. 454 * these flags set. It they are, there is a problem.
@@ -404,9 +456,10 @@ static inline void __ClearPageTail(struct page *page)
404#define PAGE_FLAGS_CHECK_AT_FREE \ 456#define PAGE_FLAGS_CHECK_AT_FREE \
405 (1 << PG_lru | 1 << PG_locked | \ 457 (1 << PG_lru | 1 << PG_locked | \
406 1 << PG_private | 1 << PG_private_2 | \ 458 1 << PG_private | 1 << PG_private_2 | \
407 1 << PG_buddy | 1 << PG_writeback | 1 << PG_reserved | \ 459 1 << PG_writeback | 1 << PG_reserved | \
408 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \ 460 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \
409 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON) 461 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON | \
462 __PG_COMPOUND_LOCK)
410 463
411/* 464/*
412 * Flags checked when a page is prepped for return by the page allocator. 465 * Flags checked when a page is prepped for return by the page allocator.
diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h
index 5bb13b3db84d..961ecc7d30bc 100644
--- a/include/linux/page_cgroup.h
+++ b/include/linux/page_cgroup.h
@@ -1,8 +1,26 @@
1#ifndef __LINUX_PAGE_CGROUP_H 1#ifndef __LINUX_PAGE_CGROUP_H
2#define __LINUX_PAGE_CGROUP_H 2#define __LINUX_PAGE_CGROUP_H
3 3
4enum {
5 /* flags for mem_cgroup */
6 PCG_LOCK, /* Lock for pc->mem_cgroup and following bits. */
7 PCG_CACHE, /* charged as cache */
8 PCG_USED, /* this object is in use. */
9 PCG_MIGRATION, /* under page migration */
10 /* flags for mem_cgroup and file and I/O status */
11 PCG_MOVE_LOCK, /* For race between move_account v.s. following bits */
12 PCG_FILE_MAPPED, /* page is accounted as "mapped" */
13 /* No lock in page_cgroup */
14 PCG_ACCT_LRU, /* page has been accounted for (under lru_lock) */
15 __NR_PCG_FLAGS,
16};
17
18#ifndef __GENERATING_BOUNDS_H
19#include <generated/bounds.h>
20
4#ifdef CONFIG_CGROUP_MEM_RES_CTLR 21#ifdef CONFIG_CGROUP_MEM_RES_CTLR
5#include <linux/bit_spinlock.h> 22#include <linux/bit_spinlock.h>
23
6/* 24/*
7 * Page Cgroup can be considered as an extended mem_map. 25 * Page Cgroup can be considered as an extended mem_map.
8 * A page_cgroup page is associated with every page descriptor. The 26 * A page_cgroup page is associated with every page descriptor. The
@@ -13,7 +31,6 @@
13struct page_cgroup { 31struct page_cgroup {
14 unsigned long flags; 32 unsigned long flags;
15 struct mem_cgroup *mem_cgroup; 33 struct mem_cgroup *mem_cgroup;
16 struct page *page;
17 struct list_head lru; /* per cgroup LRU list */ 34 struct list_head lru; /* per cgroup LRU list */
18}; 35};
19 36
@@ -32,16 +49,7 @@ static inline void __init page_cgroup_init(void)
32#endif 49#endif
33 50
34struct page_cgroup *lookup_page_cgroup(struct page *page); 51struct page_cgroup *lookup_page_cgroup(struct page *page);
35 52struct page *lookup_cgroup_page(struct page_cgroup *pc);
36enum {
37 /* flags for mem_cgroup */
38 PCG_LOCK, /* page cgroup is locked */
39 PCG_CACHE, /* charged as cache */
40 PCG_USED, /* this object is in use. */
41 PCG_ACCT_LRU, /* page has been accounted for */
42 PCG_FILE_MAPPED, /* page is accounted as "mapped" */
43 PCG_MIGRATION, /* under page migration */
44};
45 53
46#define TESTPCGFLAG(uname, lname) \ 54#define TESTPCGFLAG(uname, lname) \
47static inline int PageCgroup##uname(struct page_cgroup *pc) \ 55static inline int PageCgroup##uname(struct page_cgroup *pc) \
@@ -59,8 +67,6 @@ static inline void ClearPageCgroup##uname(struct page_cgroup *pc) \
59static inline int TestClearPageCgroup##uname(struct page_cgroup *pc) \ 67static inline int TestClearPageCgroup##uname(struct page_cgroup *pc) \
60 { return test_and_clear_bit(PCG_##lname, &pc->flags); } 68 { return test_and_clear_bit(PCG_##lname, &pc->flags); }
61 69
62TESTPCGFLAG(Locked, LOCK)
63
64/* Cache flag is set only once (at allocation) */ 70/* Cache flag is set only once (at allocation) */
65TESTPCGFLAG(Cache, CACHE) 71TESTPCGFLAG(Cache, CACHE)
66CLEARPCGFLAG(Cache, CACHE) 72CLEARPCGFLAG(Cache, CACHE)
@@ -84,24 +90,69 @@ SETPCGFLAG(Migration, MIGRATION)
84CLEARPCGFLAG(Migration, MIGRATION) 90CLEARPCGFLAG(Migration, MIGRATION)
85TESTPCGFLAG(Migration, MIGRATION) 91TESTPCGFLAG(Migration, MIGRATION)
86 92
87static inline int page_cgroup_nid(struct page_cgroup *pc) 93static inline void lock_page_cgroup(struct page_cgroup *pc)
88{ 94{
89 return page_to_nid(pc->page); 95 /*
96 * Don't take this lock in IRQ context.
97 * This lock is for pc->mem_cgroup, USED, CACHE, MIGRATION
98 */
99 bit_spin_lock(PCG_LOCK, &pc->flags);
90} 100}
91 101
92static inline enum zone_type page_cgroup_zid(struct page_cgroup *pc) 102static inline void unlock_page_cgroup(struct page_cgroup *pc)
93{ 103{
94 return page_zonenum(pc->page); 104 bit_spin_unlock(PCG_LOCK, &pc->flags);
95} 105}
96 106
97static inline void lock_page_cgroup(struct page_cgroup *pc) 107static inline void move_lock_page_cgroup(struct page_cgroup *pc,
108 unsigned long *flags)
98{ 109{
99 bit_spin_lock(PCG_LOCK, &pc->flags); 110 /*
111 * We know updates to pc->flags of page cache's stats are from both of
112 * usual context or IRQ context. Disable IRQ to avoid deadlock.
113 */
114 local_irq_save(*flags);
115 bit_spin_lock(PCG_MOVE_LOCK, &pc->flags);
100} 116}
101 117
102static inline void unlock_page_cgroup(struct page_cgroup *pc) 118static inline void move_unlock_page_cgroup(struct page_cgroup *pc,
119 unsigned long *flags)
103{ 120{
104 bit_spin_unlock(PCG_LOCK, &pc->flags); 121 bit_spin_unlock(PCG_MOVE_LOCK, &pc->flags);
122 local_irq_restore(*flags);
123}
124
125#ifdef CONFIG_SPARSEMEM
126#define PCG_ARRAYID_WIDTH SECTIONS_SHIFT
127#else
128#define PCG_ARRAYID_WIDTH NODES_SHIFT
129#endif
130
131#if (PCG_ARRAYID_WIDTH > BITS_PER_LONG - NR_PCG_FLAGS)
132#error Not enough space left in pc->flags to store page_cgroup array IDs
133#endif
134
135/* pc->flags: ARRAY-ID | FLAGS */
136
137#define PCG_ARRAYID_MASK ((1UL << PCG_ARRAYID_WIDTH) - 1)
138
139#define PCG_ARRAYID_OFFSET (BITS_PER_LONG - PCG_ARRAYID_WIDTH)
140/*
141 * Zero the shift count for non-existent fields, to prevent compiler
142 * warnings and ensure references are optimized away.
143 */
144#define PCG_ARRAYID_SHIFT (PCG_ARRAYID_OFFSET * (PCG_ARRAYID_WIDTH != 0))
145
146static inline void set_page_cgroup_array_id(struct page_cgroup *pc,
147 unsigned long id)
148{
149 pc->flags &= ~(PCG_ARRAYID_MASK << PCG_ARRAYID_SHIFT);
150 pc->flags |= (id & PCG_ARRAYID_MASK) << PCG_ARRAYID_SHIFT;
151}
152
153static inline unsigned long page_cgroup_array_id(struct page_cgroup *pc)
154{
155 return (pc->flags >> PCG_ARRAYID_SHIFT) & PCG_ARRAYID_MASK;
105} 156}
106 157
107#else /* CONFIG_CGROUP_MEM_RES_CTLR */ 158#else /* CONFIG_CGROUP_MEM_RES_CTLR */
@@ -124,7 +175,7 @@ static inline void __init page_cgroup_init_flatmem(void)
124{ 175{
125} 176}
126 177
127#endif 178#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
128 179
129#include <linux/swap.h> 180#include <linux/swap.h>
130 181
@@ -160,5 +211,8 @@ static inline void swap_cgroup_swapoff(int type)
160 return; 211 return;
161} 212}
162 213
163#endif 214#endif /* CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
164#endif 215
216#endif /* !__GENERATING_BOUNDS_H */
217
218#endif /* __LINUX_PAGE_CGROUP_H */
diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
index e8c06122be36..19ef95d293ae 100644
--- a/include/linux/pageblock-flags.h
+++ b/include/linux/pageblock-flags.h
@@ -67,7 +67,8 @@ void set_pageblock_flags_group(struct page *page, unsigned long flags,
67 67
68#define get_pageblock_flags(page) \ 68#define get_pageblock_flags(page) \
69 get_pageblock_flags_group(page, 0, NR_PAGEBLOCK_BITS-1) 69 get_pageblock_flags_group(page, 0, NR_PAGEBLOCK_BITS-1)
70#define set_pageblock_flags(page) \ 70#define set_pageblock_flags(page, flags) \
71 set_pageblock_flags_group(page, 0, NR_PAGEBLOCK_BITS-1) 71 set_pageblock_flags_group(page, flags, \
72 0, NR_PAGEBLOCK_BITS-1)
72 73
73#endif /* PAGEBLOCK_FLAGS_H */ 74#endif /* PAGEBLOCK_FLAGS_H */
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index e12cdc6d79ee..716875e53520 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -48,7 +48,7 @@ static inline void mapping_clear_unevictable(struct address_space *mapping)
48 48
49static inline int mapping_unevictable(struct address_space *mapping) 49static inline int mapping_unevictable(struct address_space *mapping)
50{ 50{
51 if (likely(mapping)) 51 if (mapping)
52 return test_bit(AS_UNEVICTABLE, &mapping->flags); 52 return test_bit(AS_UNEVICTABLE, &mapping->flags);
53 return !!mapping; 53 return !!mapping;
54} 54}
@@ -219,6 +219,12 @@ static inline struct page *page_cache_alloc_cold(struct address_space *x)
219 return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD); 219 return __page_cache_alloc(mapping_gfp_mask(x)|__GFP_COLD);
220} 220}
221 221
222static inline struct page *page_cache_alloc_readahead(struct address_space *x)
223{
224 return __page_cache_alloc(mapping_gfp_mask(x) |
225 __GFP_COLD | __GFP_NORETRY | __GFP_NOWARN);
226}
227
222typedef int filler_t(void *, struct page *); 228typedef int filler_t(void *, struct page *);
223 229
224extern struct page * find_get_page(struct address_space *mapping, 230extern struct page * find_get_page(struct address_space *mapping,
@@ -298,7 +304,8 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
298 304
299extern void __lock_page(struct page *page); 305extern void __lock_page(struct page *page);
300extern int __lock_page_killable(struct page *page); 306extern int __lock_page_killable(struct page *page);
301extern void __lock_page_nosync(struct page *page); 307extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
308 unsigned int flags);
302extern void unlock_page(struct page *page); 309extern void unlock_page(struct page *page);
303 310
304static inline void __set_page_locked(struct page *page) 311static inline void __set_page_locked(struct page *page)
@@ -340,22 +347,31 @@ static inline int lock_page_killable(struct page *page)
340} 347}
341 348
342/* 349/*
343 * lock_page_nosync should only be used if we can't pin the page's inode. 350 * lock_page_or_retry - Lock the page, unless this would block and the
344 * Doesn't play quite so well with block device plugging. 351 * caller indicated that it can handle a retry.
345 */ 352 */
346static inline void lock_page_nosync(struct page *page) 353static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm,
354 unsigned int flags)
347{ 355{
348 might_sleep(); 356 might_sleep();
349 if (!trylock_page(page)) 357 return trylock_page(page) || __lock_page_or_retry(page, mm, flags);
350 __lock_page_nosync(page);
351} 358}
352 359
353/* 360/*
354 * This is exported only for wait_on_page_locked/wait_on_page_writeback. 361 * This is exported only for wait_on_page_locked/wait_on_page_writeback.
355 * Never use this directly! 362 * Never use this directly!
356 */ 363 */
357extern void wait_on_page_bit(struct page *page, int bit_nr); 364extern void wait_on_page_bit(struct page *page, int bit_nr);
358 365
366extern int wait_on_page_bit_killable(struct page *page, int bit_nr);
367
368static inline int wait_on_page_locked_killable(struct page *page)
369{
370 if (PageLocked(page))
371 return wait_on_page_bit_killable(page, PG_locked);
372 return 0;
373}
374
359/* 375/*
360 * Wait for a page to be unlocked. 376 * Wait for a page to be unlocked.
361 * 377 *
@@ -442,8 +458,9 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
442 pgoff_t index, gfp_t gfp_mask); 458 pgoff_t index, gfp_t gfp_mask);
443int add_to_page_cache_lru(struct page *page, struct address_space *mapping, 459int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
444 pgoff_t index, gfp_t gfp_mask); 460 pgoff_t index, gfp_t gfp_mask);
445extern void remove_from_page_cache(struct page *page); 461extern void delete_from_page_cache(struct page *page);
446extern void __remove_from_page_cache(struct page *page); 462extern void __delete_from_page_cache(struct page *page);
463int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask);
447 464
448/* 465/*
449 * Like add_to_page_cache_locked, but used to add newly allocated pages: 466 * Like add_to_page_cache_locked, but used to add newly allocated pages:
diff --git a/include/linux/pata_arasan_cf_data.h b/include/linux/pata_arasan_cf_data.h
new file mode 100644
index 000000000000..a6ee9aa898bb
--- /dev/null
+++ b/include/linux/pata_arasan_cf_data.h
@@ -0,0 +1,49 @@
1/*
2 * include/linux/pata_arasan_cf_data.h
3 *
4 * Arasan Compact Flash host controller platform data header file
5 *
6 * Copyright (C) 2011 ST Microelectronics
7 * Viresh Kumar <viresh.kumar@st.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#ifndef _PATA_ARASAN_CF_DATA_H
15#define _PATA_ARASAN_CF_DATA_H
16
17#include <linux/platform_device.h>
18
19struct arasan_cf_pdata {
20 u8 cf_if_clk;
21 #define CF_IF_CLK_100M (0x0)
22 #define CF_IF_CLK_75M (0x1)
23 #define CF_IF_CLK_66M (0x2)
24 #define CF_IF_CLK_50M (0x3)
25 #define CF_IF_CLK_40M (0x4)
26 #define CF_IF_CLK_33M (0x5)
27 #define CF_IF_CLK_25M (0x6)
28 #define CF_IF_CLK_125M (0x7)
29 #define CF_IF_CLK_150M (0x8)
30 #define CF_IF_CLK_166M (0x9)
31 #define CF_IF_CLK_200M (0xA)
32 /*
33 * Platform specific incapabilities of CF controller is handled via
34 * quirks
35 */
36 u32 quirk;
37 #define CF_BROKEN_PIO (1)
38 #define CF_BROKEN_MWDMA (1 << 1)
39 #define CF_BROKEN_UDMA (1 << 2)
40 /* This is platform specific data for the DMA controller */
41 void *dma_priv;
42};
43
44static inline void
45set_arasan_cf_pdata(struct platform_device *pdev, struct arasan_cf_pdata *data)
46{
47 pdev->dev.platform_data = data;
48}
49#endif /* _PATA_ARASAN_CF_DATA_H */
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index c8b6473c5f42..44623500f419 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -35,9 +35,12 @@ static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus)
35 return acpi_get_pci_rootbridge_handle(pci_domain_nr(pbus), 35 return acpi_get_pci_rootbridge_handle(pci_domain_nr(pbus),
36 pbus->number); 36 pbus->number);
37} 37}
38#endif
39
40#ifdef CONFIG_ACPI_APEI
41extern bool aer_acpi_firmware_first(void);
38#else 42#else
39static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev) 43static inline bool aer_acpi_firmware_first(void) { return false; }
40{ return NULL; }
41#endif 44#endif
42 45
43#endif /* _PCI_ACPI_H_ */ 46#endif /* _PCI_ACPI_H_ */
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
index 91ba0b338b47..7cea7b6c1413 100644
--- a/include/linux/pci-aspm.h
+++ b/include/linux/pci-aspm.h
@@ -26,7 +26,10 @@
26extern void pcie_aspm_init_link_state(struct pci_dev *pdev); 26extern void pcie_aspm_init_link_state(struct pci_dev *pdev);
27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev); 27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev);
28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev); 28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev);
29extern void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
29extern void pci_disable_link_state(struct pci_dev *pdev, int state); 30extern void pci_disable_link_state(struct pci_dev *pdev, int state);
31extern void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
32extern void pcie_clear_aspm(void);
30extern void pcie_no_aspm(void); 33extern void pcie_no_aspm(void);
31#else 34#else
32static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) 35static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
@@ -38,10 +41,15 @@ static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev)
38static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) 41static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev)
39{ 42{
40} 43}
44static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
45{
46}
41static inline void pci_disable_link_state(struct pci_dev *pdev, int state) 47static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
42{ 48{
43} 49}
44 50static inline void pcie_clear_aspm(void)
51{
52}
45static inline void pcie_no_aspm(void) 53static inline void pcie_no_aspm(void)
46{ 54{
47} 55}
diff --git a/include/linux/pci-ats.h b/include/linux/pci-ats.h
new file mode 100644
index 000000000000..655824fa4c76
--- /dev/null
+++ b/include/linux/pci-ats.h
@@ -0,0 +1,52 @@
1#ifndef LINUX_PCI_ATS_H
2#define LINUX_PCI_ATS_H
3
4/* Address Translation Service */
5struct pci_ats {
6 int pos; /* capability position */
7 int stu; /* Smallest Translation Unit */
8 int qdep; /* Invalidate Queue Depth */
9 int ref_cnt; /* Physical Function reference count */
10 unsigned int is_enabled:1; /* Enable bit is set */
11};
12
13#ifdef CONFIG_PCI_IOV
14
15extern int pci_enable_ats(struct pci_dev *dev, int ps);
16extern void pci_disable_ats(struct pci_dev *dev);
17extern int pci_ats_queue_depth(struct pci_dev *dev);
18/**
19 * pci_ats_enabled - query the ATS status
20 * @dev: the PCI device
21 *
22 * Returns 1 if ATS capability is enabled, or 0 if not.
23 */
24static inline int pci_ats_enabled(struct pci_dev *dev)
25{
26 return dev->ats && dev->ats->is_enabled;
27}
28
29#else /* CONFIG_PCI_IOV */
30
31static inline int pci_enable_ats(struct pci_dev *dev, int ps)
32{
33 return -ENODEV;
34}
35
36static inline void pci_disable_ats(struct pci_dev *dev)
37{
38}
39
40static inline int pci_ats_queue_depth(struct pci_dev *dev)
41{
42 return -ENODEV;
43}
44
45static inline int pci_ats_enabled(struct pci_dev *dev)
46{
47 return 0;
48}
49
50#endif /* CONFIG_PCI_IOV */
51
52#endif /* LINUX_PCI_ATS_H*/
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c8d95e369ff4..c446b5ca2d38 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -214,12 +214,17 @@ enum pci_bus_speed {
214 PCI_SPEED_UNKNOWN = 0xff, 214 PCI_SPEED_UNKNOWN = 0xff,
215}; 215};
216 216
217struct pci_cap_saved_state { 217struct pci_cap_saved_data {
218 struct hlist_node next;
219 char cap_nr; 218 char cap_nr;
219 unsigned int size;
220 u32 data[0]; 220 u32 data[0];
221}; 221};
222 222
223struct pci_cap_saved_state {
224 struct hlist_node next;
225 struct pci_cap_saved_data cap;
226};
227
223struct pcie_link_state; 228struct pcie_link_state;
224struct pci_vpd; 229struct pci_vpd;
225struct pci_sriov; 230struct pci_sriov;
@@ -366,7 +371,7 @@ static inline struct pci_cap_saved_state *pci_find_saved_cap(
366 struct hlist_node *pos; 371 struct hlist_node *pos;
367 372
368 hlist_for_each_entry(tmp, pos, &pci_dev->saved_cap_space, next) { 373 hlist_for_each_entry(tmp, pos, &pci_dev->saved_cap_space, next) {
369 if (tmp->cap_nr == cap) 374 if (tmp->cap.cap_nr == cap)
370 return tmp; 375 return tmp;
371 } 376 }
372 return NULL; 377 return NULL;
@@ -541,7 +546,7 @@ struct pci_error_handlers {
541struct module; 546struct module;
542struct pci_driver { 547struct pci_driver {
543 struct list_head node; 548 struct list_head node;
544 char *name; 549 const char *name;
545 const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */ 550 const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */
546 int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ 551 int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
547 void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 552 void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
@@ -806,7 +811,11 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size);
806 811
807/* Power management related routines */ 812/* Power management related routines */
808int pci_save_state(struct pci_dev *dev); 813int pci_save_state(struct pci_dev *dev);
809int pci_restore_state(struct pci_dev *dev); 814void pci_restore_state(struct pci_dev *dev);
815struct pci_saved_state *pci_store_saved_state(struct pci_dev *dev);
816int pci_load_saved_state(struct pci_dev *dev, struct pci_saved_state *state);
817int pci_load_and_free_saved_state(struct pci_dev *dev,
818 struct pci_saved_state **state);
810int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state); 819int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state);
811int pci_set_power_state(struct pci_dev *dev, pci_power_t state); 820int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
812pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); 821pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
@@ -819,6 +828,8 @@ pci_power_t pci_target_state(struct pci_dev *dev);
819int pci_prepare_to_sleep(struct pci_dev *dev); 828int pci_prepare_to_sleep(struct pci_dev *dev);
820int pci_back_from_sleep(struct pci_dev *dev); 829int pci_back_from_sleep(struct pci_dev *dev);
821bool pci_dev_run_wake(struct pci_dev *dev); 830bool pci_dev_run_wake(struct pci_dev *dev);
831bool pci_check_pme_status(struct pci_dev *dev);
832void pci_pme_wakeup_bus(struct pci_bus *bus);
822 833
823static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, 834static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
824 bool enable) 835 bool enable)
@@ -826,6 +837,23 @@ static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
826 return __pci_enable_wake(dev, state, false, enable); 837 return __pci_enable_wake(dev, state, false, enable);
827} 838}
828 839
840#define PCI_EXP_IDO_REQUEST (1<<0)
841#define PCI_EXP_IDO_COMPLETION (1<<1)
842void pci_enable_ido(struct pci_dev *dev, unsigned long type);
843void pci_disable_ido(struct pci_dev *dev, unsigned long type);
844
845enum pci_obff_signal_type {
846 PCI_EXP_OBFF_SIGNAL_L0,
847 PCI_EXP_OBFF_SIGNAL_ALWAYS,
848};
849int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type);
850void pci_disable_obff(struct pci_dev *dev);
851
852bool pci_ltr_supported(struct pci_dev *dev);
853int pci_enable_ltr(struct pci_dev *dev);
854void pci_disable_ltr(struct pci_dev *dev);
855int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns);
856
829/* For use by arch with custom probe code */ 857/* For use by arch with custom probe code */
830void set_pcie_port_type(struct pci_dev *pdev); 858void set_pcie_port_type(struct pci_dev *pdev);
831void set_pcie_hotplug_bridge(struct pci_dev *pdev); 859void set_pcie_hotplug_bridge(struct pci_dev *pdev);
@@ -913,8 +941,11 @@ int pci_cfg_space_size_ext(struct pci_dev *dev);
913int pci_cfg_space_size(struct pci_dev *dev); 941int pci_cfg_space_size(struct pci_dev *dev);
914unsigned char pci_bus_max_busnr(struct pci_bus *bus); 942unsigned char pci_bus_max_busnr(struct pci_bus *bus);
915 943
944#define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0)
945#define PCI_VGA_STATE_CHANGE_DECODES (1 << 1)
946
916int pci_set_vga_state(struct pci_dev *pdev, bool decode, 947int pci_set_vga_state(struct pci_dev *pdev, bool decode,
917 unsigned int command_bits, bool change_bridge); 948 unsigned int command_bits, u32 flags);
918/* kmem_cache style wrapper around pci_alloc_consistent() */ 949/* kmem_cache style wrapper around pci_alloc_consistent() */
919 950
920#include <linux/pci-dma.h> 951#include <linux/pci-dma.h>
@@ -991,13 +1022,28 @@ extern void pci_restore_msi_state(struct pci_dev *dev);
991extern int pci_msi_enabled(void); 1022extern int pci_msi_enabled(void);
992#endif 1023#endif
993 1024
1025#ifdef CONFIG_PCIEPORTBUS
1026extern bool pcie_ports_disabled;
1027extern bool pcie_ports_auto;
1028#else
1029#define pcie_ports_disabled true
1030#define pcie_ports_auto false
1031#endif
1032
994#ifndef CONFIG_PCIEASPM 1033#ifndef CONFIG_PCIEASPM
995static inline int pcie_aspm_enabled(void) 1034static inline int pcie_aspm_enabled(void) { return 0; }
996{ 1035static inline bool pcie_aspm_support_enabled(void) { return false; }
997 return 0;
998}
999#else 1036#else
1000extern int pcie_aspm_enabled(void); 1037extern int pcie_aspm_enabled(void);
1038extern bool pcie_aspm_support_enabled(void);
1039#endif
1040
1041#ifdef CONFIG_PCIEAER
1042void pci_no_aer(void);
1043bool pci_aer_available(void);
1044#else
1045static inline void pci_no_aer(void) { }
1046static inline bool pci_aer_available(void) { return false; }
1001#endif 1047#endif
1002 1048
1003#ifndef CONFIG_PCIE_ECRC 1049#ifndef CONFIG_PCIE_ECRC
@@ -1044,7 +1090,7 @@ static inline int pci_proc_domain(struct pci_bus *bus)
1044 1090
1045/* some architectures require additional setup to direct VGA traffic */ 1091/* some architectures require additional setup to direct VGA traffic */
1046typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, 1092typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode,
1047 unsigned int command_bits, bool change_bridge); 1093 unsigned int command_bits, u32 flags);
1048extern void pci_register_set_vga_state(arch_set_vga_state_t func); 1094extern void pci_register_set_vga_state(arch_set_vga_state_t func);
1049 1095
1050#else /* CONFIG_PCI is not enabled */ 1096#else /* CONFIG_PCI is not enabled */
@@ -1165,12 +1211,15 @@ static inline int pci_save_state(struct pci_dev *dev)
1165 return 0; 1211 return 0;
1166} 1212}
1167 1213
1168static inline int pci_restore_state(struct pci_dev *dev) 1214static inline void pci_restore_state(struct pci_dev *dev)
1215{ }
1216
1217static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
1169{ 1218{
1170 return 0; 1219 return 0;
1171} 1220}
1172 1221
1173static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) 1222static inline int pci_wake_from_d3(struct pci_dev *dev, bool enable)
1174{ 1223{
1175 return 0; 1224 return 0;
1176} 1225}
@@ -1187,6 +1236,23 @@ static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
1187 return 0; 1236 return 0;
1188} 1237}
1189 1238
1239static inline void pci_enable_ido(struct pci_dev *dev, unsigned long type)
1240{
1241}
1242
1243static inline void pci_disable_ido(struct pci_dev *dev, unsigned long type)
1244{
1245}
1246
1247static inline int pci_enable_obff(struct pci_dev *dev, unsigned long type)
1248{
1249 return 0;
1250}
1251
1252static inline void pci_disable_obff(struct pci_dev *dev)
1253{
1254}
1255
1190static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) 1256static inline int pci_request_regions(struct pci_dev *dev, const char *res_name)
1191{ 1257{
1192 return -EIO; 1258 return -EIO;
@@ -1463,6 +1529,7 @@ void pci_request_acs(void);
1463#define PCI_VPD_RO_KEYWORD_PARTNO "PN" 1529#define PCI_VPD_RO_KEYWORD_PARTNO "PN"
1464#define PCI_VPD_RO_KEYWORD_MFR_ID "MN" 1530#define PCI_VPD_RO_KEYWORD_MFR_ID "MN"
1465#define PCI_VPD_RO_KEYWORD_VENDOR0 "V0" 1531#define PCI_VPD_RO_KEYWORD_VENDOR0 "V0"
1532#define PCI_VPD_RO_KEYWORD_CHKSUM "RV"
1466 1533
1467/** 1534/**
1468 * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length 1535 * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 570fddeb0388..f8910e155566 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -517,6 +517,9 @@
517#define PCI_DEVICE_ID_AMD_11H_NB_DRAM 0x1302 517#define PCI_DEVICE_ID_AMD_11H_NB_DRAM 0x1302
518#define PCI_DEVICE_ID_AMD_11H_NB_MISC 0x1303 518#define PCI_DEVICE_ID_AMD_11H_NB_MISC 0x1303
519#define PCI_DEVICE_ID_AMD_11H_NB_LINK 0x1304 519#define PCI_DEVICE_ID_AMD_11H_NB_LINK 0x1304
520#define PCI_DEVICE_ID_AMD_15H_NB_F3 0x1603
521#define PCI_DEVICE_ID_AMD_15H_NB_F4 0x1604
522#define PCI_DEVICE_ID_AMD_CNB17H_F3 0x1703
520#define PCI_DEVICE_ID_AMD_LANCE 0x2000 523#define PCI_DEVICE_ID_AMD_LANCE 0x2000
521#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001 524#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
522#define PCI_DEVICE_ID_AMD_SCSI 0x2020 525#define PCI_DEVICE_ID_AMD_SCSI 0x2020
@@ -605,6 +608,8 @@
605#define PCI_DEVICE_ID_MATROX_G550 0x2527 608#define PCI_DEVICE_ID_MATROX_G550 0x2527
606#define PCI_DEVICE_ID_MATROX_VIA 0x4536 609#define PCI_DEVICE_ID_MATROX_VIA 0x4536
607 610
611#define PCI_VENDOR_ID_MOBILITY_ELECTRONICS 0x14f2
612
608#define PCI_VENDOR_ID_CT 0x102c 613#define PCI_VENDOR_ID_CT 0x102c
609#define PCI_DEVICE_ID_CT_69000 0x00c0 614#define PCI_DEVICE_ID_CT_69000 0x00c0
610#define PCI_DEVICE_ID_CT_65545 0x00d8 615#define PCI_DEVICE_ID_CT_65545 0x00d8
@@ -742,6 +747,7 @@
742#define PCI_DEVICE_ID_HP_CISSC 0x3230 747#define PCI_DEVICE_ID_HP_CISSC 0x3230
743#define PCI_DEVICE_ID_HP_CISSD 0x3238 748#define PCI_DEVICE_ID_HP_CISSD 0x3238
744#define PCI_DEVICE_ID_HP_CISSE 0x323a 749#define PCI_DEVICE_ID_HP_CISSE 0x323a
750#define PCI_DEVICE_ID_HP_CISSF 0x323b
745#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 751#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031
746 752
747#define PCI_VENDOR_ID_PCTECH 0x1042 753#define PCI_VENDOR_ID_PCTECH 0x1042
@@ -765,6 +771,8 @@
765#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000 771#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000
766#define PCI_DEVICE_ID_ELSA_QS3000 0x3000 772#define PCI_DEVICE_ID_ELSA_QS3000 0x3000
767 773
774#define PCI_VENDOR_ID_STMICRO 0x104A
775
768#define PCI_VENDOR_ID_BUSLOGIC 0x104B 776#define PCI_VENDOR_ID_BUSLOGIC 0x104B
769#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140 777#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140
770#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040 778#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040
@@ -818,7 +826,7 @@
818 826
819#define PCI_VENDOR_ID_ANIGMA 0x1051 827#define PCI_VENDOR_ID_ANIGMA 0x1051
820#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100 828#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100
821 829
822#define PCI_VENDOR_ID_EFAR 0x1055 830#define PCI_VENDOR_ID_EFAR 0x1055
823#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130 831#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130
824#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463 832#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463
@@ -1249,6 +1257,8 @@
1249#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_2 0x0348 1257#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO5700_2 0x0348
1250#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO1000 0x034C 1258#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_GO1000 0x034C
1251#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E 1259#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E
1260#define PCI_DEVICE_ID_NVIDIA_MCP55_BRIDGE_V0 0x0360
1261#define PCI_DEVICE_ID_NVIDIA_MCP55_BRIDGE_V4 0x0364
1252#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 1262#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373
1253#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA 0x03E7 1263#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA 0x03E7
1254#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SMBUS 0x03EB 1264#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SMBUS 0x03EB
@@ -1449,7 +1459,7 @@
1449 1459
1450#define PCI_VENDOR_ID_ZIATECH 0x1138 1460#define PCI_VENDOR_ID_ZIATECH 0x1138
1451#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550 1461#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550
1452 1462
1453 1463
1454#define PCI_VENDOR_ID_SYSKONNECT 0x1148 1464#define PCI_VENDOR_ID_SYSKONNECT 0x1148
1455#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200 1465#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200
@@ -1527,6 +1537,7 @@
1527#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476 1537#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
1528#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478 1538#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
1529#define PCI_DEVICE_ID_RICOH_R5C822 0x0822 1539#define PCI_DEVICE_ID_RICOH_R5C822 0x0822
1540#define PCI_DEVICE_ID_RICOH_R5CE823 0xe823
1530#define PCI_DEVICE_ID_RICOH_R5C832 0x0832 1541#define PCI_DEVICE_ID_RICOH_R5C832 0x0832
1531#define PCI_DEVICE_ID_RICOH_R5C843 0x0843 1542#define PCI_DEVICE_ID_RICOH_R5C843 0x0843
1532 1543
@@ -1603,8 +1614,8 @@
1603#define PCI_DEVICE_ID_RP8OCTA 0x0005 1614#define PCI_DEVICE_ID_RP8OCTA 0x0005
1604#define PCI_DEVICE_ID_RP8J 0x0006 1615#define PCI_DEVICE_ID_RP8J 0x0006
1605#define PCI_DEVICE_ID_RP4J 0x0007 1616#define PCI_DEVICE_ID_RP4J 0x0007
1606#define PCI_DEVICE_ID_RP8SNI 0x0008 1617#define PCI_DEVICE_ID_RP8SNI 0x0008
1607#define PCI_DEVICE_ID_RP16SNI 0x0009 1618#define PCI_DEVICE_ID_RP16SNI 0x0009
1608#define PCI_DEVICE_ID_RPP4 0x000A 1619#define PCI_DEVICE_ID_RPP4 0x000A
1609#define PCI_DEVICE_ID_RPP8 0x000B 1620#define PCI_DEVICE_ID_RPP8 0x000B
1610#define PCI_DEVICE_ID_RP4M 0x000D 1621#define PCI_DEVICE_ID_RP4M 0x000D
@@ -1614,9 +1625,9 @@
1614#define PCI_DEVICE_ID_URP8INTF 0x0802 1625#define PCI_DEVICE_ID_URP8INTF 0x0802
1615#define PCI_DEVICE_ID_URP16INTF 0x0803 1626#define PCI_DEVICE_ID_URP16INTF 0x0803
1616#define PCI_DEVICE_ID_URP8OCTA 0x0805 1627#define PCI_DEVICE_ID_URP8OCTA 0x0805
1617#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C 1628#define PCI_DEVICE_ID_UPCI_RM3_8PORT 0x080C
1618#define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D 1629#define PCI_DEVICE_ID_UPCI_RM3_4PORT 0x080D
1619#define PCI_DEVICE_ID_CRP16INTF 0x0903 1630#define PCI_DEVICE_ID_CRP16INTF 0x0903
1620 1631
1621#define PCI_VENDOR_ID_CYCLADES 0x120e 1632#define PCI_VENDOR_ID_CYCLADES 0x120e
1622#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100 1633#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100
@@ -1644,6 +1655,11 @@
1644#define PCI_DEVICE_ID_O2_6836 0x6836 1655#define PCI_DEVICE_ID_O2_6836 0x6836
1645#define PCI_DEVICE_ID_O2_6812 0x6872 1656#define PCI_DEVICE_ID_O2_6812 0x6872
1646#define PCI_DEVICE_ID_O2_6933 0x6933 1657#define PCI_DEVICE_ID_O2_6933 0x6933
1658#define PCI_DEVICE_ID_O2_8120 0x8120
1659#define PCI_DEVICE_ID_O2_8220 0x8220
1660#define PCI_DEVICE_ID_O2_8221 0x8221
1661#define PCI_DEVICE_ID_O2_8320 0x8320
1662#define PCI_DEVICE_ID_O2_8321 0x8321
1647 1663
1648#define PCI_VENDOR_ID_3DFX 0x121a 1664#define PCI_VENDOR_ID_3DFX 0x121a
1649#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001 1665#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001
@@ -2041,6 +2057,7 @@
2041#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 2057#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182
2042#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150 2058#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150
2043 2059
2060#define PCI_VENDOR_ID_BCM_GVC 0x14a4
2044#define PCI_VENDOR_ID_BROADCOM 0x14e4 2061#define PCI_VENDOR_ID_BROADCOM 0x14e4
2045#define PCI_DEVICE_ID_TIGON3_5752 0x1600 2062#define PCI_DEVICE_ID_TIGON3_5752 0x1600
2046#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 2063#define PCI_DEVICE_ID_TIGON3_5752M 0x1601
@@ -2065,6 +2082,8 @@
2065#define PCI_DEVICE_ID_TIGON3_5723 0x165b 2082#define PCI_DEVICE_ID_TIGON3_5723 0x165b
2066#define PCI_DEVICE_ID_TIGON3_5705M 0x165d 2083#define PCI_DEVICE_ID_TIGON3_5705M 0x165d
2067#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e 2084#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e
2085#define PCI_DEVICE_ID_NX2_57712 0x1662
2086#define PCI_DEVICE_ID_NX2_57712E 0x1663
2068#define PCI_DEVICE_ID_TIGON3_5714 0x1668 2087#define PCI_DEVICE_ID_TIGON3_5714 0x1668
2069#define PCI_DEVICE_ID_TIGON3_5714S 0x1669 2088#define PCI_DEVICE_ID_TIGON3_5714S 0x1669
2070#define PCI_DEVICE_ID_TIGON3_5780 0x166a 2089#define PCI_DEVICE_ID_TIGON3_5780 0x166a
@@ -2142,7 +2161,7 @@
2142#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000 2161#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000
2143 2162
2144#define PCI_VENDOR_ID_ZOLTRIX 0x15b0 2163#define PCI_VENDOR_ID_ZOLTRIX 0x15b0
2145#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0 2164#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0
2146 2165
2147#define PCI_VENDOR_ID_MELLANOX 0x15b3 2166#define PCI_VENDOR_ID_MELLANOX 0x15b3
2148#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 2167#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44
@@ -2192,6 +2211,9 @@
2192#define PCI_VENDOR_ID_ARIMA 0x161f 2211#define PCI_VENDOR_ID_ARIMA 0x161f
2193 2212
2194#define PCI_VENDOR_ID_BROCADE 0x1657 2213#define PCI_VENDOR_ID_BROCADE 0x1657
2214#define PCI_DEVICE_ID_BROCADE_CT 0x0014
2215#define PCI_DEVICE_ID_BROCADE_FC_8G1P 0x0017
2216#define PCI_DEVICE_ID_BROCADE_CT_FC 0x0021
2195 2217
2196#define PCI_VENDOR_ID_SIBYTE 0x166d 2218#define PCI_VENDOR_ID_SIBYTE 0x166d
2197#define PCI_DEVICE_ID_BCM1250_PCI 0x0001 2219#define PCI_DEVICE_ID_BCM1250_PCI 0x0001
@@ -2263,6 +2285,13 @@
2263 2285
2264#define PCI_VENDOR_ID_SILAN 0x1904 2286#define PCI_VENDOR_ID_SILAN 0x1904
2265 2287
2288#define PCI_VENDOR_ID_RENESAS 0x1912
2289#define PCI_DEVICE_ID_RENESAS_SH7781 0x0001
2290#define PCI_DEVICE_ID_RENESAS_SH7780 0x0002
2291#define PCI_DEVICE_ID_RENESAS_SH7763 0x0004
2292#define PCI_DEVICE_ID_RENESAS_SH7785 0x0007
2293#define PCI_DEVICE_ID_RENESAS_SH7786 0x0010
2294
2266#define PCI_VENDOR_ID_TDI 0x192E 2295#define PCI_VENDOR_ID_TDI 0x192E
2267#define PCI_DEVICE_ID_TDI_EHCI 0x0101 2296#define PCI_DEVICE_ID_TDI_EHCI 0x0101
2268 2297
@@ -2315,6 +2344,14 @@
2315#define PCI_DEVICE_ID_P4080 0x0401 2344#define PCI_DEVICE_ID_P4080 0x0401
2316#define PCI_DEVICE_ID_P4040E 0x0408 2345#define PCI_DEVICE_ID_P4040E 0x0408
2317#define PCI_DEVICE_ID_P4040 0x0409 2346#define PCI_DEVICE_ID_P4040 0x0409
2347#define PCI_DEVICE_ID_P2040E 0x0410
2348#define PCI_DEVICE_ID_P2040 0x0411
2349#define PCI_DEVICE_ID_P3041E 0x041E
2350#define PCI_DEVICE_ID_P3041 0x041F
2351#define PCI_DEVICE_ID_P5020E 0x0420
2352#define PCI_DEVICE_ID_P5020 0x0421
2353#define PCI_DEVICE_ID_P5010E 0x0428
2354#define PCI_DEVICE_ID_P5010 0x0429
2318#define PCI_DEVICE_ID_MPC8641 0x7010 2355#define PCI_DEVICE_ID_MPC8641 0x7010
2319#define PCI_DEVICE_ID_MPC8641D 0x7011 2356#define PCI_DEVICE_ID_MPC8641D 0x7011
2320#define PCI_DEVICE_ID_MPC8610 0x7018 2357#define PCI_DEVICE_ID_MPC8610 0x7018
@@ -2338,6 +2375,10 @@
2338#define PCI_DEVICE_ID_JMICRON_JMB38X_SD 0x2381 2375#define PCI_DEVICE_ID_JMICRON_JMB38X_SD 0x2381
2339#define PCI_DEVICE_ID_JMICRON_JMB38X_MMC 0x2382 2376#define PCI_DEVICE_ID_JMICRON_JMB38X_MMC 0x2382
2340#define PCI_DEVICE_ID_JMICRON_JMB38X_MS 0x2383 2377#define PCI_DEVICE_ID_JMICRON_JMB38X_MS 0x2383
2378#define PCI_DEVICE_ID_JMICRON_JMB385_MS 0x2388
2379#define PCI_DEVICE_ID_JMICRON_JMB388_SD 0x2391
2380#define PCI_DEVICE_ID_JMICRON_JMB388_ESD 0x2392
2381#define PCI_DEVICE_ID_JMICRON_JMB390_MS 0x2393
2341 2382
2342#define PCI_VENDOR_ID_KORENIX 0x1982 2383#define PCI_VENDOR_ID_KORENIX 0x1982
2343#define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600 2384#define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600
@@ -2410,6 +2451,14 @@
2410#define PCI_DEVICE_ID_INTEL_82375 0x0482 2451#define PCI_DEVICE_ID_INTEL_82375 0x0482
2411#define PCI_DEVICE_ID_INTEL_82424 0x0483 2452#define PCI_DEVICE_ID_INTEL_82424 0x0483
2412#define PCI_DEVICE_ID_INTEL_82378 0x0484 2453#define PCI_DEVICE_ID_INTEL_82378 0x0484
2454#define PCI_DEVICE_ID_INTEL_MRST_SD0 0x0807
2455#define PCI_DEVICE_ID_INTEL_MRST_SD1 0x0808
2456#define PCI_DEVICE_ID_INTEL_MFD_SD 0x0820
2457#define PCI_DEVICE_ID_INTEL_MFD_SDIO1 0x0821
2458#define PCI_DEVICE_ID_INTEL_MFD_SDIO2 0x0822
2459#define PCI_DEVICE_ID_INTEL_MFD_EMMC0 0x0823
2460#define PCI_DEVICE_ID_INTEL_MFD_EMMC1 0x0824
2461#define PCI_DEVICE_ID_INTEL_MRST_SD2 0x084F
2413#define PCI_DEVICE_ID_INTEL_I960 0x0960 2462#define PCI_DEVICE_ID_INTEL_I960 0x0960
2414#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 2463#define PCI_DEVICE_ID_INTEL_I960RM 0x0962
2415#define PCI_DEVICE_ID_INTEL_8257X_SOL 0x1062 2464#define PCI_DEVICE_ID_INTEL_8257X_SOL 0x1062
@@ -2418,7 +2467,7 @@
2418#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130 2467#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130
2419#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 2468#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132
2420#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 2469#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
2421#define PCI_DEVICE_ID_INTEL_7505_0 0x2550 2470#define PCI_DEVICE_ID_INTEL_7505_0 0x2550
2422#define PCI_DEVICE_ID_INTEL_7205_0 0x255d 2471#define PCI_DEVICE_ID_INTEL_7205_0 0x255d
2423#define PCI_DEVICE_ID_INTEL_82437 0x122d 2472#define PCI_DEVICE_ID_INTEL_82437 0x122d
2424#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e 2473#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e
@@ -2431,9 +2480,15 @@
2431#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 2480#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21
2432#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 2481#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30
2433#define PCI_DEVICE_ID_INTEL_IOAT 0x1a38 2482#define PCI_DEVICE_ID_INTEL_IOAT 0x1a38
2434#define PCI_DEVICE_ID_INTEL_CPT_SMBUS 0x1c22 2483#define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MIN 0x1c41
2435#define PCI_DEVICE_ID_INTEL_CPT_LPC_MIN 0x1c41 2484#define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MAX 0x1c5f
2436#define PCI_DEVICE_ID_INTEL_CPT_LPC_MAX 0x1c5f 2485#define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_0 0x1d40
2486#define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_1 0x1d41
2487#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI 0x1e31
2488#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MIN 0x1e40
2489#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MAX 0x1e5f
2490#define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MIN 0x2310
2491#define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MAX 0x231f
2437#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 2492#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410
2438#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 2493#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411
2439#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 2494#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413
@@ -2621,6 +2676,9 @@
2621#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599 2676#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599
2622#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a 2677#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a
2623#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e 2678#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e
2679#define PCI_DEVICE_ID_INTEL_I7300_MCH_ERR 0x360c
2680#define PCI_DEVICE_ID_INTEL_I7300_MCH_FB0 0x360f
2681#define PCI_DEVICE_ID_INTEL_I7300_MCH_FB1 0x3610
2624#define PCI_DEVICE_ID_INTEL_IOAT_CNB 0x360b 2682#define PCI_DEVICE_ID_INTEL_IOAT_CNB 0x360b
2625#define PCI_DEVICE_ID_INTEL_FBD_CNB 0x360c 2683#define PCI_DEVICE_ID_INTEL_FBD_CNB 0x360c
2626#define PCI_DEVICE_ID_INTEL_IOAT_JSF0 0x3710 2684#define PCI_DEVICE_ID_INTEL_IOAT_JSF0 0x3710
@@ -2639,9 +2697,8 @@
2639#define PCI_DEVICE_ID_INTEL_ICH10_3 0x3a1a 2697#define PCI_DEVICE_ID_INTEL_ICH10_3 0x3a1a
2640#define PCI_DEVICE_ID_INTEL_ICH10_4 0x3a30 2698#define PCI_DEVICE_ID_INTEL_ICH10_4 0x3a30
2641#define PCI_DEVICE_ID_INTEL_ICH10_5 0x3a60 2699#define PCI_DEVICE_ID_INTEL_ICH10_5 0x3a60
2642#define PCI_DEVICE_ID_INTEL_PCH_LPC_MIN 0x3b00 2700#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MIN 0x3b00
2643#define PCI_DEVICE_ID_INTEL_PCH_LPC_MAX 0x3b1f 2701#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MAX 0x3b1f
2644#define PCI_DEVICE_ID_INTEL_PCH_SMBUS 0x3b30
2645#define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f 2702#define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f
2646#define PCI_DEVICE_ID_INTEL_5100_16 0x65f0 2703#define PCI_DEVICE_ID_INTEL_5100_16 0x65f0
2647#define PCI_DEVICE_ID_INTEL_5100_21 0x65f5 2704#define PCI_DEVICE_ID_INTEL_5100_21 0x65f5
@@ -2650,8 +2707,8 @@
2650#define PCI_DEVICE_ID_INTEL_5400_FBD0 0x4035 2707#define PCI_DEVICE_ID_INTEL_5400_FBD0 0x4035
2651#define PCI_DEVICE_ID_INTEL_5400_FBD1 0x4036 2708#define PCI_DEVICE_ID_INTEL_5400_FBD1 0x4036
2652#define PCI_DEVICE_ID_INTEL_IOAT_SCNB 0x65ff 2709#define PCI_DEVICE_ID_INTEL_IOAT_SCNB 0x65ff
2653#define PCI_DEVICE_ID_INTEL_TOLAPAI_0 0x5031 2710#define PCI_DEVICE_ID_INTEL_EP80579_0 0x5031
2654#define PCI_DEVICE_ID_INTEL_TOLAPAI_1 0x5032 2711#define PCI_DEVICE_ID_INTEL_EP80579_1 0x5032
2655#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000 2712#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000
2656#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010 2713#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010
2657#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 2714#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020
@@ -2682,6 +2739,7 @@
2682#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 2739#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
2683#define PCI_DEVICE_ID_INTEL_SCH_LPC 0x8119 2740#define PCI_DEVICE_ID_INTEL_SCH_LPC 0x8119
2684#define PCI_DEVICE_ID_INTEL_SCH_IDE 0x811a 2741#define PCI_DEVICE_ID_INTEL_SCH_IDE 0x811a
2742#define PCI_DEVICE_ID_INTEL_ITC_LPC 0x8186
2685#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 2743#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
2686#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 2744#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
2687#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca 2745#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index 455b9ccdfca7..e8840964aca1 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -223,7 +223,7 @@
223#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ 223#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
224#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */ 224#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
225#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ 225#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
226#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */ 226#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxiliary power support mask */
227#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ 227#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
228#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ 228#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
229#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ 229#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
@@ -300,12 +300,22 @@
300#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ 300#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
301#define PCI_MSI_MASK_64 16 /* Mask bits register for 64-bit devices */ 301#define PCI_MSI_MASK_64 16 /* Mask bits register for 64-bit devices */
302 302
303/* MSI-X registers (these are at offset PCI_MSIX_FLAGS) */ 303/* MSI-X registers */
304#define PCI_MSIX_FLAGS 2 304#define PCI_MSIX_FLAGS 2
305#define PCI_MSIX_FLAGS_QSIZE 0x7FF 305#define PCI_MSIX_FLAGS_QSIZE 0x7FF
306#define PCI_MSIX_FLAGS_ENABLE (1 << 15) 306#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
307#define PCI_MSIX_FLAGS_MASKALL (1 << 14) 307#define PCI_MSIX_FLAGS_MASKALL (1 << 14)
308#define PCI_MSIX_FLAGS_BIRMASK (7 << 0) 308#define PCI_MSIX_TABLE 4
309#define PCI_MSIX_PBA 8
310#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
311
312/* MSI-X entry's format */
313#define PCI_MSIX_ENTRY_SIZE 16
314#define PCI_MSIX_ENTRY_LOWER_ADDR 0
315#define PCI_MSIX_ENTRY_UPPER_ADDR 4
316#define PCI_MSIX_ENTRY_DATA 8
317#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
318#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
309 319
310/* CompactPCI Hotswap Register */ 320/* CompactPCI Hotswap Register */
311 321
@@ -425,7 +435,7 @@
425#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */ 435#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */
426#define PCI_EXP_LNKCAP_L1EL 0x00038000 /* L1 Exit Latency */ 436#define PCI_EXP_LNKCAP_L1EL 0x00038000 /* L1 Exit Latency */
427#define PCI_EXP_LNKCAP_CLKPM 0x00040000 /* L1 Clock Power Management */ 437#define PCI_EXP_LNKCAP_CLKPM 0x00040000 /* L1 Clock Power Management */
428#define PCI_EXP_LNKCAP_SDERC 0x00080000 /* Suprise Down Error Reporting Capable */ 438#define PCI_EXP_LNKCAP_SDERC 0x00080000 /* Surprise Down Error Reporting Capable */
429#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */ 439#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */
430#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */ 440#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */
431#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */ 441#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */
@@ -494,10 +504,22 @@
494#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ 504#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
495#define PCI_EXP_RTCAP 30 /* Root Capabilities */ 505#define PCI_EXP_RTCAP 30 /* Root Capabilities */
496#define PCI_EXP_RTSTA 32 /* Root Status */ 506#define PCI_EXP_RTSTA 32 /* Root Status */
507#define PCI_EXP_RTSTA_PME 0x10000 /* PME status */
508#define PCI_EXP_RTSTA_PENDING 0x20000 /* PME pending */
497#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */ 509#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
498#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */ 510#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */
511#define PCI_EXP_DEVCAP2_LTR 0x800 /* Latency tolerance reporting */
512#define PCI_EXP_OBFF_MASK 0xc0000 /* OBFF support mechanism */
513#define PCI_EXP_OBFF_MSG 0x40000 /* New message signaling */
514#define PCI_EXP_OBFF_WAKE 0x80000 /* Re-use WAKE# for OBFF */
499#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */ 515#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
500#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */ 516#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */
517#define PCI_EXP_IDO_REQ_EN 0x100 /* ID-based ordering request enable */
518#define PCI_EXP_IDO_CMP_EN 0x200 /* ID-based ordering completion enable */
519#define PCI_EXP_LTR_EN 0x400 /* Latency tolerance reporting */
520#define PCI_EXP_OBFF_MSGA_EN 0x2000 /* OBFF enable with Message type A */
521#define PCI_EXP_OBFF_MSGB_EN 0x4000 /* OBFF enable with Message type B */
522#define PCI_EXP_OBFF_WAKE_EN 0x6000 /* OBFF using WAKE# signaling */
501#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */ 523#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
502#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */ 524#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */
503 525
@@ -515,6 +537,7 @@
515#define PCI_EXT_CAP_ID_ARI 14 537#define PCI_EXT_CAP_ID_ARI 14
516#define PCI_EXT_CAP_ID_ATS 15 538#define PCI_EXT_CAP_ID_ATS 15
517#define PCI_EXT_CAP_ID_SRIOV 16 539#define PCI_EXT_CAP_ID_SRIOV 16
540#define PCI_EXT_CAP_ID_LTR 24
518 541
519/* Advanced Error Reporting */ 542/* Advanced Error Reporting */
520#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ 543#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */
@@ -671,6 +694,12 @@
671#define PCI_SRIOV_VFM_MO 0x2 /* Active.MigrateOut */ 694#define PCI_SRIOV_VFM_MO 0x2 /* Active.MigrateOut */
672#define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */ 695#define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */
673 696
697#define PCI_LTR_MAX_SNOOP_LAT 0x4
698#define PCI_LTR_MAX_NOSNOOP_LAT 0x6
699#define PCI_LTR_VALUE_MASK 0x000003ff
700#define PCI_LTR_SCALE_MASK 0x00001c00
701#define PCI_LTR_SCALE_SHIFT 10
702
674/* Access Control Service */ 703/* Access Control Service */
675#define PCI_ACS_CAP 0x04 /* ACS Capability Register */ 704#define PCI_ACS_CAP 0x04 /* ACS Capability Register */
676#define PCI_ACS_SV 0x01 /* Source Validation */ 705#define PCI_ACS_SV 0x01 /* Source Validation */
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index ce2dc655cd1d..27ef6b190ea6 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -139,6 +139,15 @@
139 __aligned(PAGE_SIZE) 139 __aligned(PAGE_SIZE)
140 140
141/* 141/*
142 * Declaration/definition used for per-CPU variables that must be read mostly.
143 */
144#define DECLARE_PER_CPU_READ_MOSTLY(type, name) \
145 DECLARE_PER_CPU_SECTION(type, name, "..readmostly")
146
147#define DEFINE_PER_CPU_READ_MOSTLY(type, name) \
148 DEFINE_PER_CPU_SECTION(type, name, "..readmostly")
149
150/*
142 * Intermodule exports for per-CPU variables. sparse forgets about 151 * Intermodule exports for per-CPU variables. sparse forgets about
143 * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to 152 * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to
144 * noop if __CHECKER__. 153 * noop if __CHECKER__.
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 49466b13c5c6..9ca008f0c542 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -39,10 +39,17 @@
39 preempt_enable(); \ 39 preempt_enable(); \
40} while (0) 40} while (0)
41 41
42#ifdef CONFIG_SMP 42#define get_cpu_ptr(var) ({ \
43 preempt_disable(); \
44 this_cpu_ptr(var); })
45
46#define put_cpu_ptr(var) do { \
47 (void)(var); \
48 preempt_enable(); \
49} while (0)
43 50
44/* minimum unit size, also is the maximum supported allocation size */ 51/* minimum unit size, also is the maximum supported allocation size */
45#define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10) 52#define PCPU_MIN_UNIT_SIZE PFN_ALIGN(32 << 10)
46 53
47/* 54/*
48 * Percpu allocator can serve percpu allocations before slab is 55 * Percpu allocator can serve percpu allocations before slab is
@@ -137,37 +144,20 @@ extern int __init pcpu_page_first_chunk(size_t reserved_size,
137 * dynamically allocated. Non-atomic access to the current CPU's 144 * dynamically allocated. Non-atomic access to the current CPU's
138 * version should probably be combined with get_cpu()/put_cpu(). 145 * version should probably be combined with get_cpu()/put_cpu().
139 */ 146 */
147#ifdef CONFIG_SMP
140#define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) 148#define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu)))
149#else
150#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); })
151#endif
141 152
142extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align); 153extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align);
143extern bool is_kernel_percpu_address(unsigned long addr); 154extern bool is_kernel_percpu_address(unsigned long addr);
144 155
145#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA 156#if !defined(CONFIG_SMP) || !defined(CONFIG_HAVE_SETUP_PER_CPU_AREA)
146extern void __init setup_per_cpu_areas(void); 157extern void __init setup_per_cpu_areas(void);
147#endif 158#endif
148extern void __init percpu_init_late(void); 159extern void __init percpu_init_late(void);
149 160
150#else /* CONFIG_SMP */
151
152#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); })
153
154/* can't distinguish from other static vars, always false */
155static inline bool is_kernel_percpu_address(unsigned long addr)
156{
157 return false;
158}
159
160static inline void __init setup_per_cpu_areas(void) { }
161
162static inline void __init percpu_init_late(void) { }
163
164static inline void *pcpu_lpage_remapped(void *kaddr)
165{
166 return NULL;
167}
168
169#endif /* CONFIG_SMP */
170
171extern void __percpu *__alloc_percpu(size_t size, size_t align); 161extern void __percpu *__alloc_percpu(size_t size, size_t align);
172extern void free_percpu(void __percpu *__pdata); 162extern void free_percpu(void __percpu *__pdata);
173extern phys_addr_t per_cpu_ptr_to_phys(void *addr); 163extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
@@ -250,6 +240,48 @@ extern void __bad_size_call_parameter(void);
250 pscr_ret__; \ 240 pscr_ret__; \
251}) 241})
252 242
243#define __pcpu_size_call_return2(stem, variable, ...) \
244({ \
245 typeof(variable) pscr2_ret__; \
246 __verify_pcpu_ptr(&(variable)); \
247 switch(sizeof(variable)) { \
248 case 1: pscr2_ret__ = stem##1(variable, __VA_ARGS__); break; \
249 case 2: pscr2_ret__ = stem##2(variable, __VA_ARGS__); break; \
250 case 4: pscr2_ret__ = stem##4(variable, __VA_ARGS__); break; \
251 case 8: pscr2_ret__ = stem##8(variable, __VA_ARGS__); break; \
252 default: \
253 __bad_size_call_parameter(); break; \
254 } \
255 pscr2_ret__; \
256})
257
258/*
259 * Special handling for cmpxchg_double. cmpxchg_double is passed two
260 * percpu variables. The first has to be aligned to a double word
261 * boundary and the second has to follow directly thereafter.
262 * We enforce this on all architectures even if they don't support
263 * a double cmpxchg instruction, since it's a cheap requirement, and it
264 * avoids breaking the requirement for architectures with the instruction.
265 */
266#define __pcpu_double_call_return_bool(stem, pcp1, pcp2, ...) \
267({ \
268 bool pdcrb_ret__; \
269 __verify_pcpu_ptr(&pcp1); \
270 BUILD_BUG_ON(sizeof(pcp1) != sizeof(pcp2)); \
271 VM_BUG_ON((unsigned long)(&pcp1) % (2 * sizeof(pcp1))); \
272 VM_BUG_ON((unsigned long)(&pcp2) != \
273 (unsigned long)(&pcp1) + sizeof(pcp1)); \
274 switch(sizeof(pcp1)) { \
275 case 1: pdcrb_ret__ = stem##1(pcp1, pcp2, __VA_ARGS__); break; \
276 case 2: pdcrb_ret__ = stem##2(pcp1, pcp2, __VA_ARGS__); break; \
277 case 4: pdcrb_ret__ = stem##4(pcp1, pcp2, __VA_ARGS__); break; \
278 case 8: pdcrb_ret__ = stem##8(pcp1, pcp2, __VA_ARGS__); break; \
279 default: \
280 __bad_size_call_parameter(); break; \
281 } \
282 pdcrb_ret__; \
283})
284
253#define __pcpu_size_call(stem, variable, ...) \ 285#define __pcpu_size_call(stem, variable, ...) \
254do { \ 286do { \
255 __verify_pcpu_ptr(&(variable)); \ 287 __verify_pcpu_ptr(&(variable)); \
@@ -412,6 +444,128 @@ do { \
412# define this_cpu_xor(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val)) 444# define this_cpu_xor(pcp, val) __pcpu_size_call(this_cpu_or_, (pcp), (val))
413#endif 445#endif
414 446
447#define _this_cpu_generic_add_return(pcp, val) \
448({ \
449 typeof(pcp) ret__; \
450 preempt_disable(); \
451 __this_cpu_add(pcp, val); \
452 ret__ = __this_cpu_read(pcp); \
453 preempt_enable(); \
454 ret__; \
455})
456
457#ifndef this_cpu_add_return
458# ifndef this_cpu_add_return_1
459# define this_cpu_add_return_1(pcp, val) _this_cpu_generic_add_return(pcp, val)
460# endif
461# ifndef this_cpu_add_return_2
462# define this_cpu_add_return_2(pcp, val) _this_cpu_generic_add_return(pcp, val)
463# endif
464# ifndef this_cpu_add_return_4
465# define this_cpu_add_return_4(pcp, val) _this_cpu_generic_add_return(pcp, val)
466# endif
467# ifndef this_cpu_add_return_8
468# define this_cpu_add_return_8(pcp, val) _this_cpu_generic_add_return(pcp, val)
469# endif
470# define this_cpu_add_return(pcp, val) __pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
471#endif
472
473#define this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
474#define this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
475#define this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)
476
477#define _this_cpu_generic_xchg(pcp, nval) \
478({ typeof(pcp) ret__; \
479 preempt_disable(); \
480 ret__ = __this_cpu_read(pcp); \
481 __this_cpu_write(pcp, nval); \
482 preempt_enable(); \
483 ret__; \
484})
485
486#ifndef this_cpu_xchg
487# ifndef this_cpu_xchg_1
488# define this_cpu_xchg_1(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
489# endif
490# ifndef this_cpu_xchg_2
491# define this_cpu_xchg_2(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
492# endif
493# ifndef this_cpu_xchg_4
494# define this_cpu_xchg_4(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
495# endif
496# ifndef this_cpu_xchg_8
497# define this_cpu_xchg_8(pcp, nval) _this_cpu_generic_xchg(pcp, nval)
498# endif
499# define this_cpu_xchg(pcp, nval) \
500 __pcpu_size_call_return2(this_cpu_xchg_, (pcp), nval)
501#endif
502
503#define _this_cpu_generic_cmpxchg(pcp, oval, nval) \
504({ typeof(pcp) ret__; \
505 preempt_disable(); \
506 ret__ = __this_cpu_read(pcp); \
507 if (ret__ == (oval)) \
508 __this_cpu_write(pcp, nval); \
509 preempt_enable(); \
510 ret__; \
511})
512
513#ifndef this_cpu_cmpxchg
514# ifndef this_cpu_cmpxchg_1
515# define this_cpu_cmpxchg_1(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
516# endif
517# ifndef this_cpu_cmpxchg_2
518# define this_cpu_cmpxchg_2(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
519# endif
520# ifndef this_cpu_cmpxchg_4
521# define this_cpu_cmpxchg_4(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
522# endif
523# ifndef this_cpu_cmpxchg_8
524# define this_cpu_cmpxchg_8(pcp, oval, nval) _this_cpu_generic_cmpxchg(pcp, oval, nval)
525# endif
526# define this_cpu_cmpxchg(pcp, oval, nval) \
527 __pcpu_size_call_return2(this_cpu_cmpxchg_, pcp, oval, nval)
528#endif
529
530/*
531 * cmpxchg_double replaces two adjacent scalars at once. The first
532 * two parameters are per cpu variables which have to be of the same
533 * size. A truth value is returned to indicate success or failure
534 * (since a double register result is difficult to handle). There is
535 * very limited hardware support for these operations, so only certain
536 * sizes may work.
537 */
538#define _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
539({ \
540 int ret__; \
541 preempt_disable(); \
542 ret__ = __this_cpu_generic_cmpxchg_double(pcp1, pcp2, \
543 oval1, oval2, nval1, nval2); \
544 preempt_enable(); \
545 ret__; \
546})
547
548#ifndef this_cpu_cmpxchg_double
549# ifndef this_cpu_cmpxchg_double_1
550# define this_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
551 _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
552# endif
553# ifndef this_cpu_cmpxchg_double_2
554# define this_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
555 _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
556# endif
557# ifndef this_cpu_cmpxchg_double_4
558# define this_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
559 _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
560# endif
561# ifndef this_cpu_cmpxchg_double_8
562# define this_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
563 _this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
564# endif
565# define this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
566 __pcpu_double_call_return_bool(this_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2))
567#endif
568
415/* 569/*
416 * Generic percpu operations that do not require preemption handling. 570 * Generic percpu operations that do not require preemption handling.
417 * Either we do not care about races or the caller has the 571 * Either we do not care about races or the caller has the
@@ -539,11 +693,120 @@ do { \
539# define __this_cpu_xor(pcp, val) __pcpu_size_call(__this_cpu_xor_, (pcp), (val)) 693# define __this_cpu_xor(pcp, val) __pcpu_size_call(__this_cpu_xor_, (pcp), (val))
540#endif 694#endif
541 695
696#define __this_cpu_generic_add_return(pcp, val) \
697({ \
698 __this_cpu_add(pcp, val); \
699 __this_cpu_read(pcp); \
700})
701
702#ifndef __this_cpu_add_return
703# ifndef __this_cpu_add_return_1
704# define __this_cpu_add_return_1(pcp, val) __this_cpu_generic_add_return(pcp, val)
705# endif
706# ifndef __this_cpu_add_return_2
707# define __this_cpu_add_return_2(pcp, val) __this_cpu_generic_add_return(pcp, val)
708# endif
709# ifndef __this_cpu_add_return_4
710# define __this_cpu_add_return_4(pcp, val) __this_cpu_generic_add_return(pcp, val)
711# endif
712# ifndef __this_cpu_add_return_8
713# define __this_cpu_add_return_8(pcp, val) __this_cpu_generic_add_return(pcp, val)
714# endif
715# define __this_cpu_add_return(pcp, val) __pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
716#endif
717
718#define __this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
719#define __this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
720#define __this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)
721
722#define __this_cpu_generic_xchg(pcp, nval) \
723({ typeof(pcp) ret__; \
724 ret__ = __this_cpu_read(pcp); \
725 __this_cpu_write(pcp, nval); \
726 ret__; \
727})
728
729#ifndef __this_cpu_xchg
730# ifndef __this_cpu_xchg_1
731# define __this_cpu_xchg_1(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
732# endif
733# ifndef __this_cpu_xchg_2
734# define __this_cpu_xchg_2(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
735# endif
736# ifndef __this_cpu_xchg_4
737# define __this_cpu_xchg_4(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
738# endif
739# ifndef __this_cpu_xchg_8
740# define __this_cpu_xchg_8(pcp, nval) __this_cpu_generic_xchg(pcp, nval)
741# endif
742# define __this_cpu_xchg(pcp, nval) \
743 __pcpu_size_call_return2(__this_cpu_xchg_, (pcp), nval)
744#endif
745
746#define __this_cpu_generic_cmpxchg(pcp, oval, nval) \
747({ \
748 typeof(pcp) ret__; \
749 ret__ = __this_cpu_read(pcp); \
750 if (ret__ == (oval)) \
751 __this_cpu_write(pcp, nval); \
752 ret__; \
753})
754
755#ifndef __this_cpu_cmpxchg
756# ifndef __this_cpu_cmpxchg_1
757# define __this_cpu_cmpxchg_1(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
758# endif
759# ifndef __this_cpu_cmpxchg_2
760# define __this_cpu_cmpxchg_2(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
761# endif
762# ifndef __this_cpu_cmpxchg_4
763# define __this_cpu_cmpxchg_4(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
764# endif
765# ifndef __this_cpu_cmpxchg_8
766# define __this_cpu_cmpxchg_8(pcp, oval, nval) __this_cpu_generic_cmpxchg(pcp, oval, nval)
767# endif
768# define __this_cpu_cmpxchg(pcp, oval, nval) \
769 __pcpu_size_call_return2(__this_cpu_cmpxchg_, pcp, oval, nval)
770#endif
771
772#define __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
773({ \
774 int __ret = 0; \
775 if (__this_cpu_read(pcp1) == (oval1) && \
776 __this_cpu_read(pcp2) == (oval2)) { \
777 __this_cpu_write(pcp1, (nval1)); \
778 __this_cpu_write(pcp2, (nval2)); \
779 __ret = 1; \
780 } \
781 (__ret); \
782})
783
784#ifndef __this_cpu_cmpxchg_double
785# ifndef __this_cpu_cmpxchg_double_1
786# define __this_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
787 __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
788# endif
789# ifndef __this_cpu_cmpxchg_double_2
790# define __this_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
791 __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
792# endif
793# ifndef __this_cpu_cmpxchg_double_4
794# define __this_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
795 __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
796# endif
797# ifndef __this_cpu_cmpxchg_double_8
798# define __this_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
799 __this_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
800# endif
801# define __this_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
802 __pcpu_double_call_return_bool(__this_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2))
803#endif
804
542/* 805/*
543 * IRQ safe versions of the per cpu RMW operations. Note that these operations 806 * IRQ safe versions of the per cpu RMW operations. Note that these operations
544 * are *not* safe against modification of the same variable from another 807 * are *not* safe against modification of the same variable from another
545 * processors (which one gets when using regular atomic operations) 808 * processors (which one gets when using regular atomic operations)
546 . They are guaranteed to be atomic vs. local interrupts and 809 * They are guaranteed to be atomic vs. local interrupts and
547 * preemption only. 810 * preemption only.
548 */ 811 */
549#define irqsafe_cpu_generic_to_op(pcp, val, op) \ 812#define irqsafe_cpu_generic_to_op(pcp, val, op) \
@@ -630,4 +893,65 @@ do { \
630# define irqsafe_cpu_xor(pcp, val) __pcpu_size_call(irqsafe_cpu_xor_, (val)) 893# define irqsafe_cpu_xor(pcp, val) __pcpu_size_call(irqsafe_cpu_xor_, (val))
631#endif 894#endif
632 895
896#define irqsafe_cpu_generic_cmpxchg(pcp, oval, nval) \
897({ \
898 typeof(pcp) ret__; \
899 unsigned long flags; \
900 local_irq_save(flags); \
901 ret__ = __this_cpu_read(pcp); \
902 if (ret__ == (oval)) \
903 __this_cpu_write(pcp, nval); \
904 local_irq_restore(flags); \
905 ret__; \
906})
907
908#ifndef irqsafe_cpu_cmpxchg
909# ifndef irqsafe_cpu_cmpxchg_1
910# define irqsafe_cpu_cmpxchg_1(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
911# endif
912# ifndef irqsafe_cpu_cmpxchg_2
913# define irqsafe_cpu_cmpxchg_2(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
914# endif
915# ifndef irqsafe_cpu_cmpxchg_4
916# define irqsafe_cpu_cmpxchg_4(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
917# endif
918# ifndef irqsafe_cpu_cmpxchg_8
919# define irqsafe_cpu_cmpxchg_8(pcp, oval, nval) irqsafe_cpu_generic_cmpxchg(pcp, oval, nval)
920# endif
921# define irqsafe_cpu_cmpxchg(pcp, oval, nval) \
922 __pcpu_size_call_return2(irqsafe_cpu_cmpxchg_, (pcp), oval, nval)
923#endif
924
925#define irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
926({ \
927 int ret__; \
928 unsigned long flags; \
929 local_irq_save(flags); \
930 ret__ = __this_cpu_generic_cmpxchg_double(pcp1, pcp2, \
931 oval1, oval2, nval1, nval2); \
932 local_irq_restore(flags); \
933 ret__; \
934})
935
936#ifndef irqsafe_cpu_cmpxchg_double
937# ifndef irqsafe_cpu_cmpxchg_double_1
938# define irqsafe_cpu_cmpxchg_double_1(pcp1, pcp2, oval1, oval2, nval1, nval2) \
939 irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
940# endif
941# ifndef irqsafe_cpu_cmpxchg_double_2
942# define irqsafe_cpu_cmpxchg_double_2(pcp1, pcp2, oval1, oval2, nval1, nval2) \
943 irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
944# endif
945# ifndef irqsafe_cpu_cmpxchg_double_4
946# define irqsafe_cpu_cmpxchg_double_4(pcp1, pcp2, oval1, oval2, nval1, nval2) \
947 irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
948# endif
949# ifndef irqsafe_cpu_cmpxchg_double_8
950# define irqsafe_cpu_cmpxchg_double_8(pcp1, pcp2, oval1, oval2, nval1, nval2) \
951 irqsafe_generic_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2)
952# endif
953# define irqsafe_cpu_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \
954 __pcpu_double_call_return_bool(irqsafe_cpu_cmpxchg_double_, (pcp1), (pcp2), (oval1), (oval2), (nval1), (nval2))
955#endif
956
633#endif /* __LINUX_PERCPU_H */ 957#endif /* __LINUX_PERCPU_H */
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
index 8a7d510ffa9c..5edc9014263a 100644
--- a/include/linux/percpu_counter.h
+++ b/include/linux/percpu_counter.h
@@ -75,7 +75,12 @@ static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
75 barrier(); /* Prevent reloads of fbc->count */ 75 barrier(); /* Prevent reloads of fbc->count */
76 if (ret >= 0) 76 if (ret >= 0)
77 return ret; 77 return ret;
78 return 1; 78 return 0;
79}
80
81static inline int percpu_counter_initialized(struct percpu_counter *fbc)
82{
83 return (fbc->counters != NULL);
79} 84}
80 85
81#else 86#else
@@ -128,6 +133,10 @@ static inline s64 percpu_counter_read(struct percpu_counter *fbc)
128 return fbc->count; 133 return fbc->count;
129} 134}
130 135
136/*
137 * percpu_counter is intended to track positive numbers. In the UP case the
138 * number should never be negative.
139 */
131static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc) 140static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
132{ 141{
133 return fbc->count; 142 return fbc->count;
@@ -143,6 +152,11 @@ static inline s64 percpu_counter_sum(struct percpu_counter *fbc)
143 return percpu_counter_read(fbc); 152 return percpu_counter_read(fbc);
144} 153}
145 154
155static inline int percpu_counter_initialized(struct percpu_counter *fbc)
156{
157 return 1;
158}
159
146#endif /* CONFIG_SMP */ 160#endif /* CONFIG_SMP */
147 161
148static inline void percpu_counter_inc(struct percpu_counter *fbc) 162static inline void percpu_counter_inc(struct percpu_counter *fbc)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 716f99b682c1..e0786e35f247 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -2,8 +2,8 @@
2 * Performance events: 2 * Performance events:
3 * 3 *
4 * Copyright (C) 2008-2009, Thomas Gleixner <tglx@linutronix.de> 4 * Copyright (C) 2008-2009, Thomas Gleixner <tglx@linutronix.de>
5 * Copyright (C) 2008-2009, Red Hat, Inc., Ingo Molnar 5 * Copyright (C) 2008-2011, Red Hat, Inc., Ingo Molnar
6 * Copyright (C) 2008-2009, Red Hat, Inc., Peter Zijlstra 6 * Copyright (C) 2008-2011, Red Hat, Inc., Peter Zijlstra
7 * 7 *
8 * Data type definitions, declarations, prototypes. 8 * Data type definitions, declarations, prototypes.
9 * 9 *
@@ -52,6 +52,8 @@ enum perf_hw_id {
52 PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4, 52 PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4,
53 PERF_COUNT_HW_BRANCH_MISSES = 5, 53 PERF_COUNT_HW_BRANCH_MISSES = 5,
54 PERF_COUNT_HW_BUS_CYCLES = 6, 54 PERF_COUNT_HW_BUS_CYCLES = 6,
55 PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7,
56 PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8,
55 57
56 PERF_COUNT_HW_MAX, /* non-ABI */ 58 PERF_COUNT_HW_MAX, /* non-ABI */
57}; 59};
@@ -135,14 +137,14 @@ enum perf_event_sample_format {
135 * 137 *
136 * struct read_format { 138 * struct read_format {
137 * { u64 value; 139 * { u64 value;
138 * { u64 time_enabled; } && PERF_FORMAT_ENABLED 140 * { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED
139 * { u64 time_running; } && PERF_FORMAT_RUNNING 141 * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
140 * { u64 id; } && PERF_FORMAT_ID 142 * { u64 id; } && PERF_FORMAT_ID
141 * } && !PERF_FORMAT_GROUP 143 * } && !PERF_FORMAT_GROUP
142 * 144 *
143 * { u64 nr; 145 * { u64 nr;
144 * { u64 time_enabled; } && PERF_FORMAT_ENABLED 146 * { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED
145 * { u64 time_running; } && PERF_FORMAT_RUNNING 147 * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
146 * { u64 value; 148 * { u64 value;
147 * { u64 id; } && PERF_FORMAT_ID 149 * { u64 id; } && PERF_FORMAT_ID
148 * } cntr[nr]; 150 * } cntr[nr];
@@ -215,8 +217,9 @@ struct perf_event_attr {
215 */ 217 */
216 precise_ip : 2, /* skid constraint */ 218 precise_ip : 2, /* skid constraint */
217 mmap_data : 1, /* non-exec mmap data */ 219 mmap_data : 1, /* non-exec mmap data */
220 sample_id_all : 1, /* sample_type all events */
218 221
219 __reserved_1 : 46; 222 __reserved_1 : 45;
220 223
221 union { 224 union {
222 __u32 wakeup_events; /* wakeup every n events */ 225 __u32 wakeup_events; /* wakeup every n events */
@@ -224,8 +227,14 @@ struct perf_event_attr {
224 }; 227 };
225 228
226 __u32 bp_type; 229 __u32 bp_type;
227 __u64 bp_addr; 230 union {
228 __u64 bp_len; 231 __u64 bp_addr;
232 __u64 config1; /* extension of config */
233 };
234 union {
235 __u64 bp_len;
236 __u64 config2; /* extension of config1 */
237 };
229}; 238};
230 239
231/* 240/*
@@ -327,6 +336,15 @@ struct perf_event_header {
327enum perf_event_type { 336enum perf_event_type {
328 337
329 /* 338 /*
339 * If perf_event_attr.sample_id_all is set then all event types will
340 * have the sample_type selected fields related to where/when
341 * (identity) an event took place (TID, TIME, ID, CPU, STREAM_ID)
342 * described in PERF_RECORD_SAMPLE below, it will be stashed just after
343 * the perf_event_header and the fields already present for the existing
344 * fields, i.e. at the end of the payload. That way a newer perf.data
345 * file will be supported by older perf tools, with these new optional
346 * fields being ignored.
347 *
330 * The MMAP events record the PROT_EXEC mappings so that we can 348 * The MMAP events record the PROT_EXEC mappings so that we can
331 * correlate userspace IPs to code. They have the following structure: 349 * correlate userspace IPs to code. They have the following structure:
332 * 350 *
@@ -452,8 +470,9 @@ enum perf_callchain_context {
452 PERF_CONTEXT_MAX = (__u64)-4095, 470 PERF_CONTEXT_MAX = (__u64)-4095,
453}; 471};
454 472
455#define PERF_FLAG_FD_NO_GROUP (1U << 0) 473#define PERF_FLAG_FD_NO_GROUP (1U << 0)
456#define PERF_FLAG_FD_OUTPUT (1U << 1) 474#define PERF_FLAG_FD_OUTPUT (1U << 1)
475#define PERF_FLAG_PID_CGROUP (1U << 2) /* pid=cgroup id, per-cpu mode only */
457 476
458#ifdef __KERNEL__ 477#ifdef __KERNEL__
459/* 478/*
@@ -461,14 +480,15 @@ enum perf_callchain_context {
461 */ 480 */
462 481
463#ifdef CONFIG_PERF_EVENTS 482#ifdef CONFIG_PERF_EVENTS
483# include <linux/cgroup.h>
464# include <asm/perf_event.h> 484# include <asm/perf_event.h>
465# include <asm/local64.h> 485# include <asm/local64.h>
466#endif 486#endif
467 487
468struct perf_guest_info_callbacks { 488struct perf_guest_info_callbacks {
469 int (*is_in_guest) (void); 489 int (*is_in_guest)(void);
470 int (*is_user_mode) (void); 490 int (*is_user_mode)(void);
471 unsigned long (*get_guest_ip) (void); 491 unsigned long (*get_guest_ip)(void);
472}; 492};
473 493
474#ifdef CONFIG_HAVE_HW_BREAKPOINT 494#ifdef CONFIG_HAVE_HW_BREAKPOINT
@@ -486,6 +506,8 @@ struct perf_guest_info_callbacks {
486#include <linux/workqueue.h> 506#include <linux/workqueue.h>
487#include <linux/ftrace.h> 507#include <linux/ftrace.h>
488#include <linux/cpu.h> 508#include <linux/cpu.h>
509#include <linux/irq_work.h>
510#include <linux/jump_label.h>
489#include <asm/atomic.h> 511#include <asm/atomic.h>
490#include <asm/local.h> 512#include <asm/local.h>
491 513
@@ -527,18 +549,27 @@ struct hw_perf_event {
527 unsigned long event_base; 549 unsigned long event_base;
528 int idx; 550 int idx;
529 int last_cpu; 551 int last_cpu;
552 unsigned int extra_reg;
553 u64 extra_config;
554 int extra_alloc;
530 }; 555 };
531 struct { /* software */ 556 struct { /* software */
532 s64 remaining;
533 struct hrtimer hrtimer; 557 struct hrtimer hrtimer;
534 }; 558 };
535#ifdef CONFIG_HAVE_HW_BREAKPOINT 559#ifdef CONFIG_HAVE_HW_BREAKPOINT
536 struct { /* breakpoint */ 560 struct { /* breakpoint */
537 struct arch_hw_breakpoint info; 561 struct arch_hw_breakpoint info;
538 struct list_head bp_list; 562 struct list_head bp_list;
563 /*
564 * Crufty hack to avoid the chicken and egg
565 * problem hw_breakpoint has with context
566 * creation and event initalization.
567 */
568 struct task_struct *bp_target;
539 }; 569 };
540#endif 570#endif
541 }; 571 };
572 int state;
542 local64_t prev_count; 573 local64_t prev_count;
543 u64 sample_period; 574 u64 sample_period;
544 u64 last_period; 575 u64 last_period;
@@ -550,6 +581,13 @@ struct hw_perf_event {
550#endif 581#endif
551}; 582};
552 583
584/*
585 * hw_perf_event::state flags
586 */
587#define PERF_HES_STOPPED 0x01 /* the counter is stopped */
588#define PERF_HES_UPTODATE 0x02 /* event->count up-to-date */
589#define PERF_HES_ARCH 0x04
590
553struct perf_event; 591struct perf_event;
554 592
555/* 593/*
@@ -561,36 +599,74 @@ struct perf_event;
561 * struct pmu - generic performance monitoring unit 599 * struct pmu - generic performance monitoring unit
562 */ 600 */
563struct pmu { 601struct pmu {
564 int (*enable) (struct perf_event *event); 602 struct list_head entry;
565 void (*disable) (struct perf_event *event); 603
566 int (*start) (struct perf_event *event); 604 struct device *dev;
567 void (*stop) (struct perf_event *event); 605 char *name;
568 void (*read) (struct perf_event *event); 606 int type;
569 void (*unthrottle) (struct perf_event *event); 607
608 int * __percpu pmu_disable_count;
609 struct perf_cpu_context * __percpu pmu_cpu_context;
610 int task_ctx_nr;
611
612 /*
613 * Fully disable/enable this PMU, can be used to protect from the PMI
614 * as well as for lazy/batch writing of the MSRs.
615 */
616 void (*pmu_enable) (struct pmu *pmu); /* optional */
617 void (*pmu_disable) (struct pmu *pmu); /* optional */
618
619 /*
620 * Try and initialize the event for this PMU.
621 * Should return -ENOENT when the @event doesn't match this PMU.
622 */
623 int (*event_init) (struct perf_event *event);
624
625#define PERF_EF_START 0x01 /* start the counter when adding */
626#define PERF_EF_RELOAD 0x02 /* reload the counter when starting */
627#define PERF_EF_UPDATE 0x04 /* update the counter when stopping */
628
629 /*
630 * Adds/Removes a counter to/from the PMU, can be done inside
631 * a transaction, see the ->*_txn() methods.
632 */
633 int (*add) (struct perf_event *event, int flags);
634 void (*del) (struct perf_event *event, int flags);
635
636 /*
637 * Starts/Stops a counter present on the PMU. The PMI handler
638 * should stop the counter when perf_event_overflow() returns
639 * !0. ->start() will be used to continue.
640 */
641 void (*start) (struct perf_event *event, int flags);
642 void (*stop) (struct perf_event *event, int flags);
570 643
571 /* 644 /*
572 * Group events scheduling is treated as a transaction, add group 645 * Updates the counter value of the event.
573 * events as a whole and perform one schedulability test. If the test
574 * fails, roll back the whole group
575 */ 646 */
647 void (*read) (struct perf_event *event);
576 648
577 /* 649 /*
578 * Start the transaction, after this ->enable() doesn't need 650 * Group events scheduling is treated as a transaction, add
579 * to do schedulability tests. 651 * group events as a whole and perform one schedulability test.
652 * If the test fails, roll back the whole group
653 *
654 * Start the transaction, after this ->add() doesn't need to
655 * do schedulability tests.
580 */ 656 */
581 void (*start_txn) (const struct pmu *pmu); 657 void (*start_txn) (struct pmu *pmu); /* optional */
582 /* 658 /*
583 * If ->start_txn() disabled the ->enable() schedulability test 659 * If ->start_txn() disabled the ->add() schedulability test
584 * then ->commit_txn() is required to perform one. On success 660 * then ->commit_txn() is required to perform one. On success
585 * the transaction is closed. On error the transaction is kept 661 * the transaction is closed. On error the transaction is kept
586 * open until ->cancel_txn() is called. 662 * open until ->cancel_txn() is called.
587 */ 663 */
588 int (*commit_txn) (const struct pmu *pmu); 664 int (*commit_txn) (struct pmu *pmu); /* optional */
589 /* 665 /*
590 * Will cancel the transaction, assumes ->disable() is called for 666 * Will cancel the transaction, assumes ->del() is called
591 * each successfull ->enable() during the transaction. 667 * for each successful ->add() during the transaction.
592 */ 668 */
593 void (*cancel_txn) (const struct pmu *pmu); 669 void (*cancel_txn) (struct pmu *pmu); /* optional */
594}; 670};
595 671
596/** 672/**
@@ -631,11 +707,6 @@ struct perf_buffer {
631 void *data_pages[0]; 707 void *data_pages[0];
632}; 708};
633 709
634struct perf_pending_entry {
635 struct perf_pending_entry *next;
636 void (*func)(struct perf_pending_entry *);
637};
638
639struct perf_sample_data; 710struct perf_sample_data;
640 711
641typedef void (*perf_overflow_handler_t)(struct perf_event *, int, 712typedef void (*perf_overflow_handler_t)(struct perf_event *, int,
@@ -643,19 +714,36 @@ typedef void (*perf_overflow_handler_t)(struct perf_event *, int,
643 struct pt_regs *regs); 714 struct pt_regs *regs);
644 715
645enum perf_group_flag { 716enum perf_group_flag {
646 PERF_GROUP_SOFTWARE = 0x1, 717 PERF_GROUP_SOFTWARE = 0x1,
647}; 718};
648 719
649#define SWEVENT_HLIST_BITS 8 720#define SWEVENT_HLIST_BITS 8
650#define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS) 721#define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS)
651 722
652struct swevent_hlist { 723struct swevent_hlist {
653 struct hlist_head heads[SWEVENT_HLIST_SIZE]; 724 struct hlist_head heads[SWEVENT_HLIST_SIZE];
654 struct rcu_head rcu_head; 725 struct rcu_head rcu_head;
655}; 726};
656 727
657#define PERF_ATTACH_CONTEXT 0x01 728#define PERF_ATTACH_CONTEXT 0x01
658#define PERF_ATTACH_GROUP 0x02 729#define PERF_ATTACH_GROUP 0x02
730#define PERF_ATTACH_TASK 0x04
731
732#ifdef CONFIG_CGROUP_PERF
733/*
734 * perf_cgroup_info keeps track of time_enabled for a cgroup.
735 * This is a per-cpu dynamically allocated data structure.
736 */
737struct perf_cgroup_info {
738 u64 time;
739 u64 timestamp;
740};
741
742struct perf_cgroup {
743 struct cgroup_subsys_state css;
744 struct perf_cgroup_info *info; /* timing info, one per cpu */
745};
746#endif
659 747
660/** 748/**
661 * struct perf_event - performance event kernel representation: 749 * struct perf_event - performance event kernel representation:
@@ -669,7 +757,7 @@ struct perf_event {
669 int nr_siblings; 757 int nr_siblings;
670 int group_flags; 758 int group_flags;
671 struct perf_event *group_leader; 759 struct perf_event *group_leader;
672 const struct pmu *pmu; 760 struct pmu *pmu;
673 761
674 enum perf_event_active_state state; 762 enum perf_event_active_state state;
675 unsigned int attach_state; 763 unsigned int attach_state;
@@ -702,7 +790,20 @@ struct perf_event {
702 u64 tstamp_running; 790 u64 tstamp_running;
703 u64 tstamp_stopped; 791 u64 tstamp_stopped;
704 792
793 /*
794 * timestamp shadows the actual context timing but it can
795 * be safely used in NMI interrupt context. It reflects the
796 * context time as it was when the event was last scheduled in.
797 *
798 * ctx_time already accounts for ctx->timestamp. Therefore to
799 * compute ctx_time for a sample, simply add perf_clock().
800 */
801 u64 shadow_ctx_time;
802
705 struct perf_event_attr attr; 803 struct perf_event_attr attr;
804 u16 header_size;
805 u16 id_header_size;
806 u16 read_size;
706 struct hw_perf_event hw; 807 struct hw_perf_event hw;
707 808
708 struct perf_event_context *ctx; 809 struct perf_event_context *ctx;
@@ -743,7 +844,7 @@ struct perf_event {
743 int pending_wakeup; 844 int pending_wakeup;
744 int pending_kill; 845 int pending_kill;
745 int pending_disable; 846 int pending_disable;
746 struct perf_pending_entry pending; 847 struct irq_work pending;
747 848
748 atomic_t event_limit; 849 atomic_t event_limit;
749 850
@@ -760,15 +861,27 @@ struct perf_event {
760 struct event_filter *filter; 861 struct event_filter *filter;
761#endif 862#endif
762 863
864#ifdef CONFIG_CGROUP_PERF
865 struct perf_cgroup *cgrp; /* cgroup event is attach to */
866 int cgrp_defer_enabled;
867#endif
868
763#endif /* CONFIG_PERF_EVENTS */ 869#endif /* CONFIG_PERF_EVENTS */
764}; 870};
765 871
872enum perf_event_context_type {
873 task_context,
874 cpu_context,
875};
876
766/** 877/**
767 * struct perf_event_context - event context structure 878 * struct perf_event_context - event context structure
768 * 879 *
769 * Used as a container for task events and CPU events as well: 880 * Used as a container for task events and CPU events as well:
770 */ 881 */
771struct perf_event_context { 882struct perf_event_context {
883 struct pmu *pmu;
884 enum perf_event_context_type type;
772 /* 885 /*
773 * Protect the states of the events in the list, 886 * Protect the states of the events in the list,
774 * nr_active, and the list: 887 * nr_active, and the list:
@@ -788,6 +901,7 @@ struct perf_event_context {
788 int nr_active; 901 int nr_active;
789 int is_active; 902 int is_active;
790 int nr_stat; 903 int nr_stat;
904 int rotate_disable;
791 atomic_t refcount; 905 atomic_t refcount;
792 struct task_struct *task; 906 struct task_struct *task;
793 907
@@ -806,8 +920,15 @@ struct perf_event_context {
806 u64 generation; 920 u64 generation;
807 int pin_count; 921 int pin_count;
808 struct rcu_head rcu_head; 922 struct rcu_head rcu_head;
923 int nr_cgroups; /* cgroup events present */
809}; 924};
810 925
926/*
927 * Number of contexts where an event can trigger:
928 * task, softirq, hardirq, nmi.
929 */
930#define PERF_NR_CONTEXTS 4
931
811/** 932/**
812 * struct perf_event_cpu_context - per cpu event context structure 933 * struct perf_event_cpu_context - per cpu event context structure
813 */ 934 */
@@ -815,18 +936,11 @@ struct perf_cpu_context {
815 struct perf_event_context ctx; 936 struct perf_event_context ctx;
816 struct perf_event_context *task_ctx; 937 struct perf_event_context *task_ctx;
817 int active_oncpu; 938 int active_oncpu;
818 int max_pertask;
819 int exclusive; 939 int exclusive;
820 struct swevent_hlist *swevent_hlist; 940 struct list_head rotation_list;
821 struct mutex hlist_mutex; 941 int jiffies_interval;
822 int hlist_refcount; 942 struct pmu *active_pmu;
823 943 struct perf_cgroup *cgrp;
824 /*
825 * Recursion avoidance:
826 *
827 * task, softirq, irq, nmi context
828 */
829 int recursion[4];
830}; 944};
831 945
832struct perf_output_handle { 946struct perf_output_handle {
@@ -842,26 +956,20 @@ struct perf_output_handle {
842 956
843#ifdef CONFIG_PERF_EVENTS 957#ifdef CONFIG_PERF_EVENTS
844 958
845/* 959extern int perf_pmu_register(struct pmu *pmu, char *name, int type);
846 * Set by architecture code: 960extern void perf_pmu_unregister(struct pmu *pmu);
847 */
848extern int perf_max_events;
849 961
850extern const struct pmu *hw_perf_event_init(struct perf_event *event); 962extern int perf_num_counters(void);
851 963extern const char *perf_pmu_name(void);
852extern void perf_event_task_sched_in(struct task_struct *task); 964extern void __perf_event_task_sched_in(struct task_struct *task);
853extern void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next); 965extern void __perf_event_task_sched_out(struct task_struct *task, struct task_struct *next);
854extern void perf_event_task_tick(struct task_struct *task);
855extern int perf_event_init_task(struct task_struct *child); 966extern int perf_event_init_task(struct task_struct *child);
856extern void perf_event_exit_task(struct task_struct *child); 967extern void perf_event_exit_task(struct task_struct *child);
857extern void perf_event_free_task(struct task_struct *task); 968extern void perf_event_free_task(struct task_struct *task);
858extern void set_perf_event_pending(void); 969extern void perf_event_delayed_put(struct task_struct *task);
859extern void perf_event_do_pending(void);
860extern void perf_event_print_debug(void); 970extern void perf_event_print_debug(void);
861extern void __perf_disable(void); 971extern void perf_pmu_disable(struct pmu *pmu);
862extern bool __perf_enable(void); 972extern void perf_pmu_enable(struct pmu *pmu);
863extern void perf_disable(void);
864extern void perf_enable(void);
865extern int perf_event_task_disable(void); 973extern int perf_event_task_disable(void);
866extern int perf_event_task_enable(void); 974extern int perf_event_task_enable(void);
867extern void perf_event_update_userpage(struct perf_event *event); 975extern void perf_event_update_userpage(struct perf_event *event);
@@ -869,7 +977,7 @@ extern int perf_event_release_kernel(struct perf_event *event);
869extern struct perf_event * 977extern struct perf_event *
870perf_event_create_kernel_counter(struct perf_event_attr *attr, 978perf_event_create_kernel_counter(struct perf_event_attr *attr,
871 int cpu, 979 int cpu,
872 pid_t pid, 980 struct task_struct *task,
873 perf_overflow_handler_t callback); 981 perf_overflow_handler_t callback);
874extern u64 perf_event_read_value(struct perf_event *event, 982extern u64 perf_event_read_value(struct perf_event *event,
875 u64 *enabled, u64 *running); 983 u64 *enabled, u64 *running);
@@ -895,8 +1003,7 @@ struct perf_sample_data {
895 struct perf_raw_record *raw; 1003 struct perf_raw_record *raw;
896}; 1004};
897 1005
898static inline 1006static inline void perf_sample_data_init(struct perf_sample_data *data, u64 addr)
899void perf_sample_data_init(struct perf_sample_data *data, u64 addr)
900{ 1007{
901 data->addr = addr; 1008 data->addr = addr;
902 data->raw = NULL; 1009 data->raw = NULL;
@@ -915,28 +1022,25 @@ extern int perf_event_overflow(struct perf_event *event, int nmi,
915 struct perf_sample_data *data, 1022 struct perf_sample_data *data,
916 struct pt_regs *regs); 1023 struct pt_regs *regs);
917 1024
1025static inline bool is_sampling_event(struct perf_event *event)
1026{
1027 return event->attr.sample_period != 0;
1028}
1029
918/* 1030/*
919 * Return 1 for a software event, 0 for a hardware event 1031 * Return 1 for a software event, 0 for a hardware event
920 */ 1032 */
921static inline int is_software_event(struct perf_event *event) 1033static inline int is_software_event(struct perf_event *event)
922{ 1034{
923 switch (event->attr.type) { 1035 return event->pmu->task_ctx_nr == perf_sw_context;
924 case PERF_TYPE_SOFTWARE:
925 case PERF_TYPE_TRACEPOINT:
926 /* for now the breakpoint stuff also works as software event */
927 case PERF_TYPE_BREAKPOINT:
928 return 1;
929 }
930 return 0;
931} 1036}
932 1037
933extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX]; 1038extern struct jump_label_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
934 1039
935extern void __perf_sw_event(u32, u64, int, struct pt_regs *, u64); 1040extern void __perf_sw_event(u32, u64, int, struct pt_regs *, u64);
936 1041
937#ifndef perf_arch_fetch_caller_regs 1042#ifndef perf_arch_fetch_caller_regs
938static inline void 1043static inline void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip) { }
939perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip) { }
940#endif 1044#endif
941 1045
942/* 1046/*
@@ -954,12 +1058,12 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs)
954 perf_arch_fetch_caller_regs(regs, CALLER_ADDR0); 1058 perf_arch_fetch_caller_regs(regs, CALLER_ADDR0);
955} 1059}
956 1060
957static inline void 1061static __always_inline void
958perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr) 1062perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
959{ 1063{
960 if (atomic_read(&perf_swevent_enabled[event_id])) { 1064 struct pt_regs hot_regs;
961 struct pt_regs hot_regs;
962 1065
1066 if (static_branch(&perf_swevent_enabled[event_id])) {
963 if (!regs) { 1067 if (!regs) {
964 perf_fetch_caller_regs(&hot_regs); 1068 perf_fetch_caller_regs(&hot_regs);
965 regs = &hot_regs; 1069 regs = &hot_regs;
@@ -968,6 +1072,21 @@ perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
968 } 1072 }
969} 1073}
970 1074
1075extern struct jump_label_key perf_sched_events;
1076
1077static inline void perf_event_task_sched_in(struct task_struct *task)
1078{
1079 if (static_branch(&perf_sched_events))
1080 __perf_event_task_sched_in(task);
1081}
1082
1083static inline void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next)
1084{
1085 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, NULL, 0);
1086
1087 __perf_event_task_sched_out(task, next);
1088}
1089
971extern void perf_event_mmap(struct vm_area_struct *vma); 1090extern void perf_event_mmap(struct vm_area_struct *vma);
972extern struct perf_guest_info_callbacks *perf_guest_cbs; 1091extern struct perf_guest_info_callbacks *perf_guest_cbs;
973extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); 1092extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
@@ -976,12 +1095,26 @@ extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks
976extern void perf_event_comm(struct task_struct *tsk); 1095extern void perf_event_comm(struct task_struct *tsk);
977extern void perf_event_fork(struct task_struct *tsk); 1096extern void perf_event_fork(struct task_struct *tsk);
978 1097
979extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs); 1098/* Callchains */
1099DECLARE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry);
1100
1101extern void perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs);
1102extern void perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs);
1103
1104static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64 ip)
1105{
1106 if (entry->nr < PERF_MAX_STACK_DEPTH)
1107 entry->ip[entry->nr++] = ip;
1108}
980 1109
981extern int sysctl_perf_event_paranoid; 1110extern int sysctl_perf_event_paranoid;
982extern int sysctl_perf_event_mlock; 1111extern int sysctl_perf_event_mlock;
983extern int sysctl_perf_event_sample_rate; 1112extern int sysctl_perf_event_sample_rate;
984 1113
1114extern int perf_proc_update_handler(struct ctl_table *table, int write,
1115 void __user *buffer, size_t *lenp,
1116 loff_t *ppos);
1117
985static inline bool perf_paranoid_tracepoint_raw(void) 1118static inline bool perf_paranoid_tracepoint_raw(void)
986{ 1119{
987 return sysctl_perf_event_paranoid > -1; 1120 return sysctl_perf_event_paranoid > -1;
@@ -1004,9 +1137,9 @@ extern void perf_tp_event(u64 addr, u64 count, void *record,
1004extern void perf_bp_event(struct perf_event *event, void *data); 1137extern void perf_bp_event(struct perf_event *event, void *data);
1005 1138
1006#ifndef perf_misc_flags 1139#ifndef perf_misc_flags
1007#define perf_misc_flags(regs) (user_mode(regs) ? PERF_RECORD_MISC_USER : \ 1140# define perf_misc_flags(regs) \
1008 PERF_RECORD_MISC_KERNEL) 1141 (user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL)
1009#define perf_instruction_pointer(regs) instruction_pointer(regs) 1142# define perf_instruction_pointer(regs) instruction_pointer(regs)
1010#endif 1143#endif
1011 1144
1012extern int perf_output_begin(struct perf_output_handle *handle, 1145extern int perf_output_begin(struct perf_output_handle *handle,
@@ -1019,21 +1152,18 @@ extern int perf_swevent_get_recursion_context(void);
1019extern void perf_swevent_put_recursion_context(int rctx); 1152extern void perf_swevent_put_recursion_context(int rctx);
1020extern void perf_event_enable(struct perf_event *event); 1153extern void perf_event_enable(struct perf_event *event);
1021extern void perf_event_disable(struct perf_event *event); 1154extern void perf_event_disable(struct perf_event *event);
1155extern void perf_event_task_tick(void);
1022#else 1156#else
1023static inline void 1157static inline void
1024perf_event_task_sched_in(struct task_struct *task) { } 1158perf_event_task_sched_in(struct task_struct *task) { }
1025static inline void 1159static inline void
1026perf_event_task_sched_out(struct task_struct *task, 1160perf_event_task_sched_out(struct task_struct *task,
1027 struct task_struct *next) { } 1161 struct task_struct *next) { }
1028static inline void
1029perf_event_task_tick(struct task_struct *task) { }
1030static inline int perf_event_init_task(struct task_struct *child) { return 0; } 1162static inline int perf_event_init_task(struct task_struct *child) { return 0; }
1031static inline void perf_event_exit_task(struct task_struct *child) { } 1163static inline void perf_event_exit_task(struct task_struct *child) { }
1032static inline void perf_event_free_task(struct task_struct *task) { } 1164static inline void perf_event_free_task(struct task_struct *task) { }
1033static inline void perf_event_do_pending(void) { } 1165static inline void perf_event_delayed_put(struct task_struct *task) { }
1034static inline void perf_event_print_debug(void) { } 1166static inline void perf_event_print_debug(void) { }
1035static inline void perf_disable(void) { }
1036static inline void perf_enable(void) { }
1037static inline int perf_event_task_disable(void) { return -EINVAL; } 1167static inline int perf_event_task_disable(void) { return -EINVAL; }
1038static inline int perf_event_task_enable(void) { return -EINVAL; } 1168static inline int perf_event_task_enable(void) { return -EINVAL; }
1039 1169
@@ -1044,9 +1174,9 @@ static inline void
1044perf_bp_event(struct perf_event *event, void *data) { } 1174perf_bp_event(struct perf_event *event, void *data) { }
1045 1175
1046static inline int perf_register_guest_info_callbacks 1176static inline int perf_register_guest_info_callbacks
1047(struct perf_guest_info_callbacks *callbacks) { return 0; } 1177(struct perf_guest_info_callbacks *callbacks) { return 0; }
1048static inline int perf_unregister_guest_info_callbacks 1178static inline int perf_unregister_guest_info_callbacks
1049(struct perf_guest_info_callbacks *callbacks) { return 0; } 1179(struct perf_guest_info_callbacks *callbacks) { return 0; }
1050 1180
1051static inline void perf_event_mmap(struct vm_area_struct *vma) { } 1181static inline void perf_event_mmap(struct vm_area_struct *vma) { }
1052static inline void perf_event_comm(struct task_struct *tsk) { } 1182static inline void perf_event_comm(struct task_struct *tsk) { }
@@ -1056,25 +1186,25 @@ static inline int perf_swevent_get_recursion_context(void) { return -1; }
1056static inline void perf_swevent_put_recursion_context(int rctx) { } 1186static inline void perf_swevent_put_recursion_context(int rctx) { }
1057static inline void perf_event_enable(struct perf_event *event) { } 1187static inline void perf_event_enable(struct perf_event *event) { }
1058static inline void perf_event_disable(struct perf_event *event) { } 1188static inline void perf_event_disable(struct perf_event *event) { }
1189static inline void perf_event_task_tick(void) { }
1059#endif 1190#endif
1060 1191
1061#define perf_output_put(handle, x) \ 1192#define perf_output_put(handle, x) perf_output_copy((handle), &(x), sizeof(x))
1062 perf_output_copy((handle), &(x), sizeof(x))
1063 1193
1064/* 1194/*
1065 * This has to have a higher priority than migration_notifier in sched.c. 1195 * This has to have a higher priority than migration_notifier in sched.c.
1066 */ 1196 */
1067#define perf_cpu_notifier(fn) \ 1197#define perf_cpu_notifier(fn) \
1068do { \ 1198do { \
1069 static struct notifier_block fn##_nb __cpuinitdata = \ 1199 static struct notifier_block fn##_nb __cpuinitdata = \
1070 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \ 1200 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
1071 fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \ 1201 fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \
1072 (void *)(unsigned long)smp_processor_id()); \ 1202 (void *)(unsigned long)smp_processor_id()); \
1073 fn(&fn##_nb, (unsigned long)CPU_STARTING, \ 1203 fn(&fn##_nb, (unsigned long)CPU_STARTING, \
1074 (void *)(unsigned long)smp_processor_id()); \ 1204 (void *)(unsigned long)smp_processor_id()); \
1075 fn(&fn##_nb, (unsigned long)CPU_ONLINE, \ 1205 fn(&fn##_nb, (unsigned long)CPU_ONLINE, \
1076 (void *)(unsigned long)smp_processor_id()); \ 1206 (void *)(unsigned long)smp_processor_id()); \
1077 register_cpu_notifier(&fn##_nb); \ 1207 register_cpu_notifier(&fn##_nb); \
1078} while (0) 1208} while (0)
1079 1209
1080#endif /* __KERNEL__ */ 1210#endif /* __KERNEL__ */
diff --git a/include/linux/phonet.h b/include/linux/phonet.h
index 76edadf046d3..6fb13841db45 100644
--- a/include/linux/phonet.h
+++ b/include/linux/phonet.h
@@ -36,6 +36,7 @@
36/* Socket options for SOL_PNPIPE level */ 36/* Socket options for SOL_PNPIPE level */
37#define PNPIPE_ENCAP 1 37#define PNPIPE_ENCAP 1
38#define PNPIPE_IFINDEX 2 38#define PNPIPE_IFINDEX 2
39#define PNPIPE_HANDLE 3
39 40
40#define PNADDR_ANY 0 41#define PNADDR_ANY 0
41#define PNADDR_BROADCAST 0xFC 42#define PNADDR_BROADCAST 0xFC
@@ -47,6 +48,8 @@
47 48
48/* ioctls */ 49/* ioctls */
49#define SIOCPNGETOBJECT (SIOCPROTOPRIVATE + 0) 50#define SIOCPNGETOBJECT (SIOCPROTOPRIVATE + 0)
51#define SIOCPNADDRESOURCE (SIOCPROTOPRIVATE + 14)
52#define SIOCPNDELRESOURCE (SIOCPROTOPRIVATE + 15)
50 53
51/* Phonet protocol header */ 54/* Phonet protocol header */
52struct phonethdr { 55struct phonethdr {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6b0a782c6224..7da5fa845959 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -116,7 +116,7 @@ struct mii_bus {
116 /* list of all PHYs on bus */ 116 /* list of all PHYs on bus */
117 struct phy_device *phy_map[PHY_MAX_ADDR]; 117 struct phy_device *phy_map[PHY_MAX_ADDR];
118 118
119 /* Phy addresses to be ignored when probing */ 119 /* PHY addresses to be ignored when probing */
120 u32 phy_mask; 120 u32 phy_mask;
121 121
122 /* 122 /*
@@ -283,7 +283,7 @@ struct phy_device {
283 283
284 phy_interface_t interface; 284 phy_interface_t interface;
285 285
286 /* Bus address of the PHY (0-32) */ 286 /* Bus address of the PHY (0-31) */
287 int addr; 287 int addr;
288 288
289 /* 289 /*
@@ -472,11 +472,7 @@ static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val)
472int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id); 472int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
473struct phy_device* get_phy_device(struct mii_bus *bus, int addr); 473struct phy_device* get_phy_device(struct mii_bus *bus, int addr);
474int phy_device_register(struct phy_device *phy); 474int phy_device_register(struct phy_device *phy);
475int phy_clear_interrupt(struct phy_device *phydev);
476int phy_config_interrupt(struct phy_device *phydev, u32 interrupts);
477int phy_init_hw(struct phy_device *phydev); 475int phy_init_hw(struct phy_device *phydev);
478int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
479 u32 flags, phy_interface_t interface);
480struct phy_device * phy_attach(struct net_device *dev, 476struct phy_device * phy_attach(struct net_device *dev,
481 const char *bus_id, u32 flags, phy_interface_t interface); 477 const char *bus_id, u32 flags, phy_interface_t interface);
482struct phy_device *phy_find_first(struct mii_bus *bus); 478struct phy_device *phy_find_first(struct mii_bus *bus);
@@ -492,17 +488,12 @@ void phy_start(struct phy_device *phydev);
492void phy_stop(struct phy_device *phydev); 488void phy_stop(struct phy_device *phydev);
493int phy_start_aneg(struct phy_device *phydev); 489int phy_start_aneg(struct phy_device *phydev);
494 490
495void phy_sanitize_settings(struct phy_device *phydev);
496int phy_stop_interrupts(struct phy_device *phydev); 491int phy_stop_interrupts(struct phy_device *phydev);
497int phy_enable_interrupts(struct phy_device *phydev);
498int phy_disable_interrupts(struct phy_device *phydev);
499 492
500static inline int phy_read_status(struct phy_device *phydev) { 493static inline int phy_read_status(struct phy_device *phydev) {
501 return phydev->drv->read_status(phydev); 494 return phydev->drv->read_status(phydev);
502} 495}
503 496
504int genphy_config_advert(struct phy_device *phydev);
505int genphy_setup_forced(struct phy_device *phydev);
506int genphy_restart_aneg(struct phy_device *phydev); 497int genphy_restart_aneg(struct phy_device *phydev);
507int genphy_config_aneg(struct phy_device *phydev); 498int genphy_config_aneg(struct phy_device *phydev);
508int genphy_update_link(struct phy_device *phydev); 499int genphy_update_link(struct phy_device *phydev);
@@ -511,8 +502,6 @@ int genphy_suspend(struct phy_device *phydev);
511int genphy_resume(struct phy_device *phydev); 502int genphy_resume(struct phy_device *phydev);
512void phy_driver_unregister(struct phy_driver *drv); 503void phy_driver_unregister(struct phy_driver *drv);
513int phy_driver_register(struct phy_driver *new_driver); 504int phy_driver_register(struct phy_driver *new_driver);
514void phy_prepare_link(struct phy_device *phydev,
515 void (*adjust_link)(struct net_device *));
516void phy_state_machine(struct work_struct *work); 505void phy_state_machine(struct work_struct *work);
517void phy_start_machine(struct phy_device *phydev, 506void phy_start_machine(struct phy_device *phydev,
518 void (*handler)(struct net_device *)); 507 void (*handler)(struct net_device *));
@@ -523,7 +512,6 @@ int phy_mii_ioctl(struct phy_device *phydev,
523 struct ifreq *ifr, int cmd); 512 struct ifreq *ifr, int cmd);
524int phy_start_interrupts(struct phy_device *phydev); 513int phy_start_interrupts(struct phy_device *phydev);
525void phy_print_status(struct phy_device *phydev); 514void phy_print_status(struct phy_device *phydev);
526struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id);
527void phy_device_free(struct phy_device *phydev); 515void phy_device_free(struct phy_device *phydev);
528 516
529int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, 517int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 49f1c2f66e95..b152d44fb181 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -21,7 +21,7 @@ enum pid_type
21 * quickly from the numeric pid value. The attached processes may be 21 * quickly from the numeric pid value. The attached processes may be
22 * quickly accessed by following pointers from struct pid. 22 * quickly accessed by following pointers from struct pid.
23 * 23 *
24 * Storing pid_t values in the kernel and refering to them later has a 24 * Storing pid_t values in the kernel and referring to them later has a
25 * problem. The process originally with that pid may have exited and the 25 * problem. The process originally with that pid may have exited and the
26 * pid allocator wrapped, and another process could have come along 26 * pid allocator wrapped, and another process could have come along
27 * and been assigned that pid. 27 * and been assigned that pid.
@@ -105,7 +105,7 @@ extern struct pid_namespace init_pid_ns;
105 * or rcu_read_lock() held. 105 * or rcu_read_lock() held.
106 * 106 *
107 * find_pid_ns() finds the pid in the namespace specified 107 * find_pid_ns() finds the pid in the namespace specified
108 * find_vpid() finr the pid by its virtual id, i.e. in the current namespace 108 * find_vpid() finds the pid by its virtual id, i.e. in the current namespace
109 * 109 *
110 * see also find_task_by_vpid() set in include/linux/sched.h 110 * see also find_task_by_vpid() set in include/linux/sched.h
111 */ 111 */
@@ -117,7 +117,7 @@ extern struct pid *find_vpid(int nr);
117 */ 117 */
118extern struct pid *find_get_pid(int nr); 118extern struct pid *find_get_pid(int nr);
119extern struct pid *find_ge_pid(int nr, struct pid_namespace *); 119extern struct pid *find_ge_pid(int nr, struct pid_namespace *);
120int next_pidmap(struct pid_namespace *pid_ns, int last); 120int next_pidmap(struct pid_namespace *pid_ns, unsigned int last);
121 121
122extern struct pid *alloc_pid(struct pid_namespace *ns); 122extern struct pid *alloc_pid(struct pid_namespace *ns);
123extern void free_pid(struct pid *pid); 123extern void free_pid(struct pid *pid);
@@ -141,6 +141,17 @@ static inline struct pid_namespace *ns_of_pid(struct pid *pid)
141} 141}
142 142
143/* 143/*
144 * is_child_reaper returns true if the pid is the init process
145 * of the current namespace. As this one could be checked before
146 * pid_ns->child_reaper is assigned in copy_process, we check
147 * with the pid number.
148 */
149static inline bool is_child_reaper(struct pid *pid)
150{
151 return pid->numbers[pid->level].nr == 1;
152}
153
154/*
144 * the helpers to get the pid's id seen from different namespaces 155 * the helpers to get the pid's id seen from different namespaces
145 * 156 *
146 * pid_nr() : global id, i.e. the id seen from the init namespace; 157 * pid_nr() : global id, i.e. the id seen from the init namespace;
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 445796945ac9..77257c92155a 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -30,6 +30,7 @@ struct pipe_buffer {
30 * struct pipe_inode_info - a linux kernel pipe 30 * struct pipe_inode_info - a linux kernel pipe
31 * @wait: reader/writer wait point in case of empty/full pipe 31 * @wait: reader/writer wait point in case of empty/full pipe
32 * @nrbufs: the number of non-empty pipe buffers in this pipe 32 * @nrbufs: the number of non-empty pipe buffers in this pipe
33 * @buffers: total number of buffers (should be a power of 2)
33 * @curbuf: the current pipe buffer entry 34 * @curbuf: the current pipe buffer entry
34 * @tmp_page: cached released page 35 * @tmp_page: cached released page
35 * @readers: number of current readers of this pipe 36 * @readers: number of current readers of this pipe
@@ -160,5 +161,6 @@ void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
160 161
161/* for F_SETPIPE_SZ and F_GETPIPE_SZ */ 162/* for F_SETPIPE_SZ and F_GETPIPE_SZ */
162long pipe_fcntl(struct file *, unsigned int, unsigned long arg); 163long pipe_fcntl(struct file *, unsigned int, unsigned long arg);
164struct pipe_inode_info *get_pipe_info(struct file *file);
163 165
164#endif 166#endif
diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index 7f6ba8658abe..defbde203d07 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -332,6 +332,7 @@ enum {
332 FLOW_KEY_SKUID, 332 FLOW_KEY_SKUID,
333 FLOW_KEY_SKGID, 333 FLOW_KEY_SKGID,
334 FLOW_KEY_VLAN_TAG, 334 FLOW_KEY_VLAN_TAG,
335 FLOW_KEY_RXHASH,
335 __FLOW_KEY_MAX, 336 __FLOW_KEY_MAX,
336}; 337};
337 338
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index 2cfa4bc8dea6..c5336705921f 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -223,7 +223,7 @@ struct tc_gred_qopt {
223 __u32 limit; /* HARD maximal queue length (bytes) */ 223 __u32 limit; /* HARD maximal queue length (bytes) */
224 __u32 qth_min; /* Min average length threshold (bytes) */ 224 __u32 qth_min; /* Min average length threshold (bytes) */
225 __u32 qth_max; /* Max average length threshold (bytes) */ 225 __u32 qth_max; /* Max average length threshold (bytes) */
226 __u32 DP; /* upto 2^32 DPs */ 226 __u32 DP; /* up to 2^32 DPs */
227 __u32 backlog; 227 __u32 backlog;
228 __u32 qave; 228 __u32 qave;
229 __u32 forced; 229 __u32 forced;
@@ -247,6 +247,35 @@ struct tc_gred_sopt {
247 __u16 pad1; 247 __u16 pad1;
248}; 248};
249 249
250/* CHOKe section */
251
252enum {
253 TCA_CHOKE_UNSPEC,
254 TCA_CHOKE_PARMS,
255 TCA_CHOKE_STAB,
256 __TCA_CHOKE_MAX,
257};
258
259#define TCA_CHOKE_MAX (__TCA_CHOKE_MAX - 1)
260
261struct tc_choke_qopt {
262 __u32 limit; /* Hard queue length (packets) */
263 __u32 qth_min; /* Min average threshold (packets) */
264 __u32 qth_max; /* Max average threshold (packets) */
265 unsigned char Wlog; /* log(W) */
266 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
267 unsigned char Scell_log; /* cell size for idle damping */
268 unsigned char flags; /* see RED flags */
269};
270
271struct tc_choke_xstats {
272 __u32 early; /* Early drops */
273 __u32 pdrop; /* Drops due to queue limits */
274 __u32 other; /* Drops due to drop() calls */
275 __u32 marked; /* Marked packets */
276 __u32 matched; /* Drops due to flow match */
277};
278
250/* HTB section */ 279/* HTB section */
251#define TC_HTB_NUMPRIO 8 280#define TC_HTB_NUMPRIO 8
252#define TC_HTB_MAXDEPTH 8 281#define TC_HTB_MAXDEPTH 8
@@ -435,6 +464,7 @@ enum {
435 TCA_NETEM_DELAY_DIST, 464 TCA_NETEM_DELAY_DIST,
436 TCA_NETEM_REORDER, 465 TCA_NETEM_REORDER,
437 TCA_NETEM_CORRUPT, 466 TCA_NETEM_CORRUPT,
467 TCA_NETEM_LOSS,
438 __TCA_NETEM_MAX, 468 __TCA_NETEM_MAX,
439}; 469};
440 470
@@ -465,7 +495,33 @@ struct tc_netem_corrupt {
465 __u32 correlation; 495 __u32 correlation;
466}; 496};
467 497
498enum {
499 NETEM_LOSS_UNSPEC,
500 NETEM_LOSS_GI, /* General Intuitive - 4 state model */
501 NETEM_LOSS_GE, /* Gilbert Elliot models */
502 __NETEM_LOSS_MAX
503};
504#define NETEM_LOSS_MAX (__NETEM_LOSS_MAX - 1)
505
506/* State transition probablities for 4 state model */
507struct tc_netem_gimodel {
508 __u32 p13;
509 __u32 p31;
510 __u32 p32;
511 __u32 p14;
512 __u32 p23;
513};
514
515/* Gilbert-Elliot models */
516struct tc_netem_gemodel {
517 __u32 p;
518 __u32 r;
519 __u32 h;
520 __u32 k1;
521};
522
468#define NETEM_DIST_SCALE 8192 523#define NETEM_DIST_SCALE 8192
524#define NETEM_DIST_MAX 16384
469 525
470/* DRR */ 526/* DRR */
471 527
@@ -481,4 +537,70 @@ struct tc_drr_stats {
481 __u32 deficit; 537 __u32 deficit;
482}; 538};
483 539
540/* MQPRIO */
541#define TC_QOPT_BITMASK 15
542#define TC_QOPT_MAX_QUEUE 16
543
544struct tc_mqprio_qopt {
545 __u8 num_tc;
546 __u8 prio_tc_map[TC_QOPT_BITMASK + 1];
547 __u8 hw;
548 __u16 count[TC_QOPT_MAX_QUEUE];
549 __u16 offset[TC_QOPT_MAX_QUEUE];
550};
551
552/* SFB */
553
554enum {
555 TCA_SFB_UNSPEC,
556 TCA_SFB_PARMS,
557 __TCA_SFB_MAX,
558};
559
560#define TCA_SFB_MAX (__TCA_SFB_MAX - 1)
561
562/*
563 * Note: increment, decrement are Q0.16 fixed-point values.
564 */
565struct tc_sfb_qopt {
566 __u32 rehash_interval; /* delay between hash move, in ms */
567 __u32 warmup_time; /* double buffering warmup time in ms (warmup_time < rehash_interval) */
568 __u32 max; /* max len of qlen_min */
569 __u32 bin_size; /* maximum queue length per bin */
570 __u32 increment; /* probability increment, (d1 in Blue) */
571 __u32 decrement; /* probability decrement, (d2 in Blue) */
572 __u32 limit; /* max SFB queue length */
573 __u32 penalty_rate; /* inelastic flows are rate limited to 'rate' pps */
574 __u32 penalty_burst;
575};
576
577struct tc_sfb_xstats {
578 __u32 earlydrop;
579 __u32 penaltydrop;
580 __u32 bucketdrop;
581 __u32 queuedrop;
582 __u32 childdrop; /* drops in child qdisc */
583 __u32 marked;
584 __u32 maxqlen;
585 __u32 maxprob;
586 __u32 avgprob;
587};
588
589#define SFB_MAX_PROB 0xFFFF
590
591/* QFQ */
592enum {
593 TCA_QFQ_UNSPEC,
594 TCA_QFQ_WEIGHT,
595 TCA_QFQ_LMAX,
596 __TCA_QFQ_MAX
597};
598
599#define TCA_QFQ_MAX (__TCA_QFQ_MAX - 1)
600
601struct tc_qfq_stats {
602 __u32 weight;
603 __u32 lmax;
604};
605
484#endif 606#endif
diff --git a/include/linux/platform_data/msm_serial_hs.h b/include/linux/platform_data/msm_serial_hs.h
new file mode 100644
index 000000000000..98a2046f8b31
--- /dev/null
+++ b/include/linux/platform_data/msm_serial_hs.h
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2008 Google, Inc.
3 * Author: Nick Pelly <npelly@google.com>
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __ASM_ARCH_MSM_SERIAL_HS_H
16#define __ASM_ARCH_MSM_SERIAL_HS_H
17
18#include <linux/serial_core.h>
19
20/* API to request the uart clock off or on for low power management
21 * Clients should call request_clock_off() when no uart data is expected,
22 * and must call request_clock_on() before any further uart data can be
23 * received. */
24extern void msm_hs_request_clock_off(struct uart_port *uport);
25extern void msm_hs_request_clock_on(struct uart_port *uport);
26
27/**
28 * struct msm_serial_hs_platform_data
29 * @rx_wakeup_irq: Rx activity irq
30 * @rx_to_inject: extra character to be inserted to Rx tty on wakeup
31 * @inject_rx: 1 = insert rx_to_inject. 0 = do not insert extra character
32 * @exit_lpm_cb: function called before every Tx transaction
33 *
34 * This is an optional structure required for UART Rx GPIO IRQ based
35 * wakeup from low power state. UART wakeup can be triggered by RX activity
36 * (using a wakeup GPIO on the UART RX pin). This should only be used if
37 * there is not a wakeup GPIO on the UART CTS, and the first RX byte is
38 * known (eg., with the Bluetooth Texas Instruments HCILL protocol),
39 * since the first RX byte will always be lost. RTS will be asserted even
40 * while the UART is clocked off in this mode of operation.
41 */
42struct msm_serial_hs_platform_data {
43 int rx_wakeup_irq;
44 unsigned char inject_rx_on_wakeup;
45 char rx_to_inject;
46 void (*exit_lpm_cb)(struct uart_port *);
47};
48
49#endif
diff --git a/include/linux/platform_data/tegra_usb.h b/include/linux/platform_data/tegra_usb.h
new file mode 100644
index 000000000000..6bca5b569acb
--- /dev/null
+++ b/include/linux/platform_data/tegra_usb.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef _TEGRA_USB_H_
16#define _TEGRA_USB_H_
17
18enum tegra_usb_operating_modes {
19 TEGRA_USB_DEVICE,
20 TEGRA_USB_HOST,
21 TEGRA_USB_OTG,
22};
23
24struct tegra_ehci_platform_data {
25 enum tegra_usb_operating_modes operating_mode;
26 /* power down the phy on bus suspend */
27 int power_down_on_bus_suspend;
28 void *phy_config;
29};
30
31#endif /* _TEGRA_USB_H_ */
diff --git a/include/linux/platform_data/uio_pruss.h b/include/linux/platform_data/uio_pruss.h
new file mode 100644
index 000000000000..f39140aabc6f
--- /dev/null
+++ b/include/linux/platform_data/uio_pruss.h
@@ -0,0 +1,25 @@
1/*
2 * include/linux/platform_data/uio_pruss.h
3 *
4 * Platform data for uio_pruss driver
5 *
6 * Copyright (C) 2010-11 Texas Instruments Incorporated - http://www.ti.com/
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation version 2.
11 *
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#ifndef _UIO_PRUSS_H_
19#define _UIO_PRUSS_H_
20
21/* To configure the PRUSS INTC base offset for UIO driver */
22struct uio_pruss_pdata {
23 u32 pintc_base;
24};
25#endif /* _UIO_PRUSS_H_ */
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index d7ecad0093bb..ede1a80e3358 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -14,6 +14,8 @@
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/mod_devicetable.h> 15#include <linux/mod_devicetable.h>
16 16
17struct mfd_cell;
18
17struct platform_device { 19struct platform_device {
18 const char * name; 20 const char * name;
19 int id; 21 int id;
@@ -23,6 +25,9 @@ struct platform_device {
23 25
24 const struct platform_device_id *id_entry; 26 const struct platform_device_id *id_entry;
25 27
28 /* MFD cell pointer */
29 struct mfd_cell *mfd_cell;
30
26 /* arch specific additions */ 31 /* arch specific additions */
27 struct pdev_archdata archdata; 32 struct pdev_archdata archdata;
28}; 33};
@@ -130,8 +135,15 @@ extern void platform_driver_unregister(struct platform_driver *);
130extern int platform_driver_probe(struct platform_driver *driver, 135extern int platform_driver_probe(struct platform_driver *driver,
131 int (*probe)(struct platform_device *)); 136 int (*probe)(struct platform_device *));
132 137
133#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) 138static inline void *platform_get_drvdata(const struct platform_device *pdev)
134#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) 139{
140 return dev_get_drvdata(&pdev->dev);
141}
142
143static inline void platform_set_drvdata(struct platform_device *pdev, void *data)
144{
145 dev_set_drvdata(&pdev->dev, data);
146}
135 147
136extern struct platform_device *platform_create_bundle(struct platform_driver *driver, 148extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
137 int (*probe)(struct platform_device *), 149 int (*probe)(struct platform_device *),
@@ -190,4 +202,64 @@ static inline char *early_platform_driver_setup_func(void) \
190} 202}
191#endif /* MODULE */ 203#endif /* MODULE */
192 204
205#ifdef CONFIG_PM_SLEEP
206extern int platform_pm_prepare(struct device *dev);
207extern void platform_pm_complete(struct device *dev);
208#else
209#define platform_pm_prepare NULL
210#define platform_pm_complete NULL
211#endif
212
213#ifdef CONFIG_SUSPEND
214extern int platform_pm_suspend(struct device *dev);
215extern int platform_pm_suspend_noirq(struct device *dev);
216extern int platform_pm_resume(struct device *dev);
217extern int platform_pm_resume_noirq(struct device *dev);
218#else
219#define platform_pm_suspend NULL
220#define platform_pm_resume NULL
221#define platform_pm_suspend_noirq NULL
222#define platform_pm_resume_noirq NULL
223#endif
224
225#ifdef CONFIG_HIBERNATE_CALLBACKS
226extern int platform_pm_freeze(struct device *dev);
227extern int platform_pm_freeze_noirq(struct device *dev);
228extern int platform_pm_thaw(struct device *dev);
229extern int platform_pm_thaw_noirq(struct device *dev);
230extern int platform_pm_poweroff(struct device *dev);
231extern int platform_pm_poweroff_noirq(struct device *dev);
232extern int platform_pm_restore(struct device *dev);
233extern int platform_pm_restore_noirq(struct device *dev);
234#else
235#define platform_pm_freeze NULL
236#define platform_pm_thaw NULL
237#define platform_pm_poweroff NULL
238#define platform_pm_restore NULL
239#define platform_pm_freeze_noirq NULL
240#define platform_pm_thaw_noirq NULL
241#define platform_pm_poweroff_noirq NULL
242#define platform_pm_restore_noirq NULL
243#endif
244
245#ifdef CONFIG_PM_SLEEP
246#define USE_PLATFORM_PM_SLEEP_OPS \
247 .prepare = platform_pm_prepare, \
248 .complete = platform_pm_complete, \
249 .suspend = platform_pm_suspend, \
250 .resume = platform_pm_resume, \
251 .freeze = platform_pm_freeze, \
252 .thaw = platform_pm_thaw, \
253 .poweroff = platform_pm_poweroff, \
254 .restore = platform_pm_restore, \
255 .suspend_noirq = platform_pm_suspend_noirq, \
256 .resume_noirq = platform_pm_resume_noirq, \
257 .freeze_noirq = platform_pm_freeze_noirq, \
258 .thaw_noirq = platform_pm_thaw_noirq, \
259 .poweroff_noirq = platform_pm_poweroff_noirq, \
260 .restore_noirq = platform_pm_restore_noirq,
261#else
262#define USE_PLATFORM_PM_SLEEP_OPS
263#endif
264
193#endif /* _PLATFORM_DEVICE_H_ */ 265#endif /* _PLATFORM_DEVICE_H_ */
diff --git a/include/linux/plist.h b/include/linux/plist.h
index 7254eda078e5..c9b9f322c8d8 100644
--- a/include/linux/plist.h
+++ b/include/linux/plist.h
@@ -31,15 +31,17 @@
31 * 31 *
32 * Simple ASCII art explanation: 32 * Simple ASCII art explanation:
33 * 33 *
34 * |HEAD | 34 * pl:prio_list (only for plist_node)
35 * | | 35 * nl:node_list
36 * |prio_list.prev|<------------------------------------| 36 * HEAD| NODE(S)
37 * |prio_list.next|<->|pl|<->|pl|<--------------->|pl|<-| 37 * |
38 * |10 | |10| |21| |21| |21| |40| (prio) 38 * ||------------------------------------|
39 * | | | | | | | | | | | | 39 * ||->|pl|<->|pl|<--------------->|pl|<-|
40 * | | | | | | | | | | | | 40 * | |10| |21| |21| |21| |40| (prio)
41 * |node_list.next|<->|nl|<->|nl|<->|nl|<->|nl|<->|nl|<-| 41 * | | | | | | | | | | |
42 * |node_list.prev|<------------------------------------| 42 * | | | | | | | | | | |
43 * |->|nl|<->|nl|<->|nl|<->|nl|<->|nl|<->|nl|<-|
44 * |-------------------------------------------|
43 * 45 *
44 * The nodes on the prio_list list are sorted by priority to simplify 46 * The nodes on the prio_list list are sorted by priority to simplify
45 * the insertion of new nodes. There are no nodes with duplicate 47 * the insertion of new nodes. There are no nodes with duplicate
@@ -78,7 +80,6 @@
78#include <linux/spinlock_types.h> 80#include <linux/spinlock_types.h>
79 81
80struct plist_head { 82struct plist_head {
81 struct list_head prio_list;
82 struct list_head node_list; 83 struct list_head node_list;
83#ifdef CONFIG_DEBUG_PI_LIST 84#ifdef CONFIG_DEBUG_PI_LIST
84 raw_spinlock_t *rawlock; 85 raw_spinlock_t *rawlock;
@@ -88,7 +89,8 @@ struct plist_head {
88 89
89struct plist_node { 90struct plist_node {
90 int prio; 91 int prio;
91 struct plist_head plist; 92 struct list_head prio_list;
93 struct list_head node_list;
92}; 94};
93 95
94#ifdef CONFIG_DEBUG_PI_LIST 96#ifdef CONFIG_DEBUG_PI_LIST
@@ -100,7 +102,6 @@ struct plist_node {
100#endif 102#endif
101 103
102#define _PLIST_HEAD_INIT(head) \ 104#define _PLIST_HEAD_INIT(head) \
103 .prio_list = LIST_HEAD_INIT((head).prio_list), \
104 .node_list = LIST_HEAD_INIT((head).node_list) 105 .node_list = LIST_HEAD_INIT((head).node_list)
105 106
106/** 107/**
@@ -133,7 +134,8 @@ struct plist_node {
133#define PLIST_NODE_INIT(node, __prio) \ 134#define PLIST_NODE_INIT(node, __prio) \
134{ \ 135{ \
135 .prio = (__prio), \ 136 .prio = (__prio), \
136 .plist = { _PLIST_HEAD_INIT((node).plist) }, \ 137 .prio_list = LIST_HEAD_INIT((node).prio_list), \
138 .node_list = LIST_HEAD_INIT((node).node_list), \
137} 139}
138 140
139/** 141/**
@@ -144,7 +146,6 @@ struct plist_node {
144static inline void 146static inline void
145plist_head_init(struct plist_head *head, spinlock_t *lock) 147plist_head_init(struct plist_head *head, spinlock_t *lock)
146{ 148{
147 INIT_LIST_HEAD(&head->prio_list);
148 INIT_LIST_HEAD(&head->node_list); 149 INIT_LIST_HEAD(&head->node_list);
149#ifdef CONFIG_DEBUG_PI_LIST 150#ifdef CONFIG_DEBUG_PI_LIST
150 head->spinlock = lock; 151 head->spinlock = lock;
@@ -160,7 +161,6 @@ plist_head_init(struct plist_head *head, spinlock_t *lock)
160static inline void 161static inline void
161plist_head_init_raw(struct plist_head *head, raw_spinlock_t *lock) 162plist_head_init_raw(struct plist_head *head, raw_spinlock_t *lock)
162{ 163{
163 INIT_LIST_HEAD(&head->prio_list);
164 INIT_LIST_HEAD(&head->node_list); 164 INIT_LIST_HEAD(&head->node_list);
165#ifdef CONFIG_DEBUG_PI_LIST 165#ifdef CONFIG_DEBUG_PI_LIST
166 head->rawlock = lock; 166 head->rawlock = lock;
@@ -176,7 +176,8 @@ plist_head_init_raw(struct plist_head *head, raw_spinlock_t *lock)
176static inline void plist_node_init(struct plist_node *node, int prio) 176static inline void plist_node_init(struct plist_node *node, int prio)
177{ 177{
178 node->prio = prio; 178 node->prio = prio;
179 plist_head_init(&node->plist, NULL); 179 INIT_LIST_HEAD(&node->prio_list);
180 INIT_LIST_HEAD(&node->node_list);
180} 181}
181 182
182extern void plist_add(struct plist_node *node, struct plist_head *head); 183extern void plist_add(struct plist_node *node, struct plist_head *head);
@@ -188,7 +189,7 @@ extern void plist_del(struct plist_node *node, struct plist_head *head);
188 * @head: the head for your list 189 * @head: the head for your list
189 */ 190 */
190#define plist_for_each(pos, head) \ 191#define plist_for_each(pos, head) \
191 list_for_each_entry(pos, &(head)->node_list, plist.node_list) 192 list_for_each_entry(pos, &(head)->node_list, node_list)
192 193
193/** 194/**
194 * plist_for_each_safe - iterate safely over a plist of given type 195 * plist_for_each_safe - iterate safely over a plist of given type
@@ -199,7 +200,7 @@ extern void plist_del(struct plist_node *node, struct plist_head *head);
199 * Iterate over a plist of given type, safe against removal of list entry. 200 * Iterate over a plist of given type, safe against removal of list entry.
200 */ 201 */
201#define plist_for_each_safe(pos, n, head) \ 202#define plist_for_each_safe(pos, n, head) \
202 list_for_each_entry_safe(pos, n, &(head)->node_list, plist.node_list) 203 list_for_each_entry_safe(pos, n, &(head)->node_list, node_list)
203 204
204/** 205/**
205 * plist_for_each_entry - iterate over list of given type 206 * plist_for_each_entry - iterate over list of given type
@@ -208,7 +209,7 @@ extern void plist_del(struct plist_node *node, struct plist_head *head);
208 * @mem: the name of the list_struct within the struct 209 * @mem: the name of the list_struct within the struct
209 */ 210 */
210#define plist_for_each_entry(pos, head, mem) \ 211#define plist_for_each_entry(pos, head, mem) \
211 list_for_each_entry(pos, &(head)->node_list, mem.plist.node_list) 212 list_for_each_entry(pos, &(head)->node_list, mem.node_list)
212 213
213/** 214/**
214 * plist_for_each_entry_safe - iterate safely over list of given type 215 * plist_for_each_entry_safe - iterate safely over list of given type
@@ -220,7 +221,7 @@ extern void plist_del(struct plist_node *node, struct plist_head *head);
220 * Iterate over list of given type, safe against removal of list entry. 221 * Iterate over list of given type, safe against removal of list entry.
221 */ 222 */
222#define plist_for_each_entry_safe(pos, n, head, m) \ 223#define plist_for_each_entry_safe(pos, n, head, m) \
223 list_for_each_entry_safe(pos, n, &(head)->node_list, m.plist.node_list) 224 list_for_each_entry_safe(pos, n, &(head)->node_list, m.node_list)
224 225
225/** 226/**
226 * plist_head_empty - return !0 if a plist_head is empty 227 * plist_head_empty - return !0 if a plist_head is empty
@@ -237,7 +238,7 @@ static inline int plist_head_empty(const struct plist_head *head)
237 */ 238 */
238static inline int plist_node_empty(const struct plist_node *node) 239static inline int plist_node_empty(const struct plist_node *node)
239{ 240{
240 return plist_head_empty(&node->plist); 241 return list_empty(&node->node_list);
241} 242}
242 243
243/* All functions below assume the plist_head is not empty. */ 244/* All functions below assume the plist_head is not empty. */
@@ -285,7 +286,7 @@ static inline int plist_node_empty(const struct plist_node *node)
285static inline struct plist_node *plist_first(const struct plist_head *head) 286static inline struct plist_node *plist_first(const struct plist_head *head)
286{ 287{
287 return list_entry(head->node_list.next, 288 return list_entry(head->node_list.next,
288 struct plist_node, plist.node_list); 289 struct plist_node, node_list);
289} 290}
290 291
291/** 292/**
@@ -297,7 +298,7 @@ static inline struct plist_node *plist_first(const struct plist_head *head)
297static inline struct plist_node *plist_last(const struct plist_head *head) 298static inline struct plist_node *plist_last(const struct plist_head *head)
298{ 299{
299 return list_entry(head->node_list.prev, 300 return list_entry(head->node_list.prev,
300 struct plist_node, plist.node_list); 301 struct plist_node, node_list);
301} 302}
302 303
303#endif 304#endif
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 52e8c55ff314..411e4f4be52b 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -41,6 +41,12 @@ extern void (*pm_power_off_prepare)(void);
41 41
42struct device; 42struct device;
43 43
44#ifdef CONFIG_PM
45extern const char power_group_name[]; /* = "power" */
46#else
47#define power_group_name NULL
48#endif
49
44typedef struct pm_message { 50typedef struct pm_message {
45 int event; 51 int event;
46} pm_message_t; 52} pm_message_t;
@@ -261,7 +267,7 @@ const struct dev_pm_ops name = { \
261 * callbacks provided by device drivers supporting both the system sleep PM and 267 * callbacks provided by device drivers supporting both the system sleep PM and
262 * runtime PM, make the pm member point to generic_subsys_pm_ops. 268 * runtime PM, make the pm member point to generic_subsys_pm_ops.
263 */ 269 */
264#ifdef CONFIG_PM_OPS 270#ifdef CONFIG_PM
265extern struct dev_pm_ops generic_subsys_pm_ops; 271extern struct dev_pm_ops generic_subsys_pm_ops;
266#define GENERIC_SUBSYS_PM_OPS (&generic_subsys_pm_ops) 272#define GENERIC_SUBSYS_PM_OPS (&generic_subsys_pm_ops)
267#else 273#else
@@ -361,45 +367,6 @@ extern struct dev_pm_ops generic_subsys_pm_ops;
361 { .event = PM_EVENT_AUTO_RESUME, }) 367 { .event = PM_EVENT_AUTO_RESUME, })
362 368
363/** 369/**
364 * Device power management states
365 *
366 * These state labels are used internally by the PM core to indicate the current
367 * status of a device with respect to the PM core operations.
368 *
369 * DPM_ON Device is regarded as operational. Set this way
370 * initially and when ->complete() is about to be called.
371 * Also set when ->prepare() fails.
372 *
373 * DPM_PREPARING Device is going to be prepared for a PM transition. Set
374 * when ->prepare() is about to be called.
375 *
376 * DPM_RESUMING Device is going to be resumed. Set when ->resume(),
377 * ->thaw(), or ->restore() is about to be called.
378 *
379 * DPM_SUSPENDING Device has been prepared for a power transition. Set
380 * when ->prepare() has just succeeded.
381 *
382 * DPM_OFF Device is regarded as inactive. Set immediately after
383 * ->suspend(), ->freeze(), or ->poweroff() has succeeded.
384 * Also set when ->resume()_noirq, ->thaw_noirq(), or
385 * ->restore_noirq() is about to be called.
386 *
387 * DPM_OFF_IRQ Device is in a "deep sleep". Set immediately after
388 * ->suspend_noirq(), ->freeze_noirq(), or
389 * ->poweroff_noirq() has just succeeded.
390 */
391
392enum dpm_state {
393 DPM_INVALID,
394 DPM_ON,
395 DPM_PREPARING,
396 DPM_RESUMING,
397 DPM_SUSPENDING,
398 DPM_OFF,
399 DPM_OFF_IRQ,
400};
401
402/**
403 * Device run-time power management status. 370 * Device run-time power management status.
404 * 371 *
405 * These status labels are used internally by the PM core to indicate the 372 * These status labels are used internally by the PM core to indicate the
@@ -438,6 +405,9 @@ enum rpm_status {
438 * 405 *
439 * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback 406 * RPM_REQ_SUSPEND Run the device bus type's ->runtime_suspend() callback
440 * 407 *
408 * RPM_REQ_AUTOSUSPEND Same as RPM_REQ_SUSPEND, but not until the device has
409 * been inactive for as long as power.autosuspend_delay
410 *
441 * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback 411 * RPM_REQ_RESUME Run the device bus type's ->runtime_resume() callback
442 */ 412 */
443 413
@@ -445,26 +415,31 @@ enum rpm_request {
445 RPM_REQ_NONE = 0, 415 RPM_REQ_NONE = 0,
446 RPM_REQ_IDLE, 416 RPM_REQ_IDLE,
447 RPM_REQ_SUSPEND, 417 RPM_REQ_SUSPEND,
418 RPM_REQ_AUTOSUSPEND,
448 RPM_REQ_RESUME, 419 RPM_REQ_RESUME,
449}; 420};
450 421
422struct wakeup_source;
423
451struct dev_pm_info { 424struct dev_pm_info {
452 pm_message_t power_state; 425 pm_message_t power_state;
453 unsigned int can_wakeup:1; 426 unsigned int can_wakeup:1;
454 unsigned int should_wakeup:1; 427 unsigned int async_suspend:1;
455 unsigned async_suspend:1; 428 bool is_prepared:1; /* Owned by the PM core */
456 enum dpm_state status; /* Owned by the PM core */ 429 bool is_suspended:1; /* Ditto */
430 spinlock_t lock;
457#ifdef CONFIG_PM_SLEEP 431#ifdef CONFIG_PM_SLEEP
458 struct list_head entry; 432 struct list_head entry;
459 struct completion completion; 433 struct completion completion;
460 unsigned long wakeup_count; 434 struct wakeup_source *wakeup;
435#else
436 unsigned int should_wakeup:1;
461#endif 437#endif
462#ifdef CONFIG_PM_RUNTIME 438#ifdef CONFIG_PM_RUNTIME
463 struct timer_list suspend_timer; 439 struct timer_list suspend_timer;
464 unsigned long timer_expires; 440 unsigned long timer_expires;
465 struct work_struct work; 441 struct work_struct work;
466 wait_queue_head_t wait_queue; 442 wait_queue_head_t wait_queue;
467 spinlock_t lock;
468 atomic_t usage_count; 443 atomic_t usage_count;
469 atomic_t child_count; 444 atomic_t child_count;
470 unsigned int disable_depth:3; 445 unsigned int disable_depth:3;
@@ -474,17 +449,32 @@ struct dev_pm_info {
474 unsigned int deferred_resume:1; 449 unsigned int deferred_resume:1;
475 unsigned int run_wake:1; 450 unsigned int run_wake:1;
476 unsigned int runtime_auto:1; 451 unsigned int runtime_auto:1;
452 unsigned int no_callbacks:1;
453 unsigned int irq_safe:1;
454 unsigned int use_autosuspend:1;
455 unsigned int timer_autosuspends:1;
477 enum rpm_request request; 456 enum rpm_request request;
478 enum rpm_status runtime_status; 457 enum rpm_status runtime_status;
479 int runtime_error; 458 int runtime_error;
459 int autosuspend_delay;
460 unsigned long last_busy;
480 unsigned long active_jiffies; 461 unsigned long active_jiffies;
481 unsigned long suspended_jiffies; 462 unsigned long suspended_jiffies;
482 unsigned long accounting_timestamp; 463 unsigned long accounting_timestamp;
464 void *subsys_data; /* Owned by the subsystem. */
483#endif 465#endif
484}; 466};
485 467
486extern void update_pm_runtime_accounting(struct device *dev); 468extern void update_pm_runtime_accounting(struct device *dev);
487 469
470/*
471 * Power domains provide callbacks that are executed during system suspend,
472 * hibernation, system resume and during runtime PM transitions along with
473 * subsystem-level and driver-level callbacks.
474 */
475struct dev_power_domain {
476 struct dev_pm_ops ops;
477};
488 478
489/* 479/*
490 * The PM_EVENT_ messages are also used by drivers implementing the legacy 480 * The PM_EVENT_ messages are also used by drivers implementing the legacy
@@ -542,14 +532,16 @@ extern void update_pm_runtime_accounting(struct device *dev);
542 532
543#ifdef CONFIG_PM_SLEEP 533#ifdef CONFIG_PM_SLEEP
544extern void device_pm_lock(void); 534extern void device_pm_lock(void);
545extern int sysdev_resume(void);
546extern void dpm_resume_noirq(pm_message_t state); 535extern void dpm_resume_noirq(pm_message_t state);
547extern void dpm_resume_end(pm_message_t state); 536extern void dpm_resume_end(pm_message_t state);
537extern void dpm_resume(pm_message_t state);
538extern void dpm_complete(pm_message_t state);
548 539
549extern void device_pm_unlock(void); 540extern void device_pm_unlock(void);
550extern int sysdev_suspend(pm_message_t state);
551extern int dpm_suspend_noirq(pm_message_t state); 541extern int dpm_suspend_noirq(pm_message_t state);
552extern int dpm_suspend_start(pm_message_t state); 542extern int dpm_suspend_start(pm_message_t state);
543extern int dpm_suspend(pm_message_t state);
544extern int dpm_prepare(pm_message_t state);
553 545
554extern void __suspend_report_result(const char *function, void *fn, int ret); 546extern void __suspend_report_result(const char *function, void *fn, int ret);
555 547
@@ -558,12 +550,17 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
558 __suspend_report_result(__func__, fn, ret); \ 550 __suspend_report_result(__func__, fn, ret); \
559 } while (0) 551 } while (0)
560 552
561extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); 553extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
554
555extern int pm_generic_prepare(struct device *dev);
556extern int pm_generic_suspend(struct device *dev);
557extern int pm_generic_resume(struct device *dev);
558extern int pm_generic_freeze(struct device *dev);
559extern int pm_generic_thaw(struct device *dev);
560extern int pm_generic_restore(struct device *dev);
561extern int pm_generic_poweroff(struct device *dev);
562extern void pm_generic_complete(struct device *dev);
562 563
563/* drivers/base/power/wakeup.c */
564extern void pm_wakeup_event(struct device *dev, unsigned int msec);
565extern void pm_stay_awake(struct device *dev);
566extern void pm_relax(void);
567#else /* !CONFIG_PM_SLEEP */ 564#else /* !CONFIG_PM_SLEEP */
568 565
569#define device_pm_lock() do {} while (0) 566#define device_pm_lock() do {} while (0)
@@ -576,11 +573,19 @@ static inline int dpm_suspend_start(pm_message_t state)
576 573
577#define suspend_report_result(fn, ret) do {} while (0) 574#define suspend_report_result(fn, ret) do {} while (0)
578 575
579static inline void device_pm_wait_for_dev(struct device *a, struct device *b) {} 576static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
577{
578 return 0;
579}
580 580
581static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {} 581#define pm_generic_prepare NULL
582static inline void pm_stay_awake(struct device *dev) {} 582#define pm_generic_suspend NULL
583static inline void pm_relax(void) {} 583#define pm_generic_resume NULL
584#define pm_generic_freeze NULL
585#define pm_generic_thaw NULL
586#define pm_generic_restore NULL
587#define pm_generic_poweroff NULL
588#define pm_generic_complete NULL
584#endif /* !CONFIG_PM_SLEEP */ 589#endif /* !CONFIG_PM_SLEEP */
585 590
586/* How to reorder dpm_list after device_move() */ 591/* How to reorder dpm_list after device_move() */
@@ -591,13 +596,4 @@ enum dpm_order {
591 DPM_ORDER_DEV_LAST, 596 DPM_ORDER_DEV_LAST,
592}; 597};
593 598
594/*
595 * Global Power Management flags
596 * Used to keep APM and ACPI from both being active
597 */
598extern unsigned int pm_flags;
599
600#define PM_APM 1
601#define PM_ACPI 2
602
603#endif /* _LINUX_PM_H */ 599#endif /* _LINUX_PM_H */
diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h
index 77cbddb3784c..a7d87f911cab 100644
--- a/include/linux/pm_qos_params.h
+++ b/include/linux/pm_qos_params.h
@@ -16,6 +16,10 @@
16#define PM_QOS_NUM_CLASSES 4 16#define PM_QOS_NUM_CLASSES 4
17#define PM_QOS_DEFAULT_VALUE -1 17#define PM_QOS_DEFAULT_VALUE -1
18 18
19#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
20#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
21#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
22
19struct pm_qos_request_list { 23struct pm_qos_request_list {
20 struct plist_node list; 24 struct plist_node list;
21 int pm_qos_class; 25 int pm_qos_class;
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 6e81888c6222..878cf84baeb1 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -12,18 +12,24 @@
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/pm.h> 13#include <linux/pm.h>
14 14
15#include <linux/jiffies.h>
16
17/* Runtime PM flag argument bits */
18#define RPM_ASYNC 0x01 /* Request is asynchronous */
19#define RPM_NOWAIT 0x02 /* Don't wait for concurrent
20 state change */
21#define RPM_GET_PUT 0x04 /* Increment/decrement the
22 usage_count */
23#define RPM_AUTO 0x08 /* Use autosuspend_delay */
24
15#ifdef CONFIG_PM_RUNTIME 25#ifdef CONFIG_PM_RUNTIME
16 26
17extern struct workqueue_struct *pm_wq; 27extern struct workqueue_struct *pm_wq;
18 28
19extern int pm_runtime_idle(struct device *dev); 29extern int __pm_runtime_idle(struct device *dev, int rpmflags);
20extern int pm_runtime_suspend(struct device *dev); 30extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
21extern int pm_runtime_resume(struct device *dev); 31extern int __pm_runtime_resume(struct device *dev, int rpmflags);
22extern int pm_request_idle(struct device *dev);
23extern int pm_schedule_suspend(struct device *dev, unsigned int delay); 32extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
24extern int pm_request_resume(struct device *dev);
25extern int __pm_runtime_get(struct device *dev, bool sync);
26extern int __pm_runtime_put(struct device *dev, bool sync);
27extern int __pm_runtime_set_status(struct device *dev, unsigned int status); 33extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
28extern int pm_runtime_barrier(struct device *dev); 34extern int pm_runtime_barrier(struct device *dev);
29extern void pm_runtime_enable(struct device *dev); 35extern void pm_runtime_enable(struct device *dev);
@@ -33,6 +39,11 @@ extern void pm_runtime_forbid(struct device *dev);
33extern int pm_generic_runtime_idle(struct device *dev); 39extern int pm_generic_runtime_idle(struct device *dev);
34extern int pm_generic_runtime_suspend(struct device *dev); 40extern int pm_generic_runtime_suspend(struct device *dev);
35extern int pm_generic_runtime_resume(struct device *dev); 41extern int pm_generic_runtime_resume(struct device *dev);
42extern void pm_runtime_no_callbacks(struct device *dev);
43extern void pm_runtime_irq_safe(struct device *dev);
44extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
45extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);
46extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev);
36 47
37static inline bool pm_children_suspended(struct device *dev) 48static inline bool pm_children_suspended(struct device *dev)
38{ 49{
@@ -67,22 +78,43 @@ static inline void device_set_run_wake(struct device *dev, bool enable)
67 78
68static inline bool pm_runtime_suspended(struct device *dev) 79static inline bool pm_runtime_suspended(struct device *dev)
69{ 80{
70 return dev->power.runtime_status == RPM_SUSPENDED; 81 return dev->power.runtime_status == RPM_SUSPENDED
82 && !dev->power.disable_depth;
83}
84
85static inline bool pm_runtime_enabled(struct device *dev)
86{
87 return !dev->power.disable_depth;
88}
89
90static inline bool pm_runtime_callbacks_present(struct device *dev)
91{
92 return !dev->power.no_callbacks;
93}
94
95static inline void pm_runtime_mark_last_busy(struct device *dev)
96{
97 ACCESS_ONCE(dev->power.last_busy) = jiffies;
71} 98}
72 99
73#else /* !CONFIG_PM_RUNTIME */ 100#else /* !CONFIG_PM_RUNTIME */
74 101
75static inline int pm_runtime_idle(struct device *dev) { return -ENOSYS; } 102static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
76static inline int pm_runtime_suspend(struct device *dev) { return -ENOSYS; } 103{
77static inline int pm_runtime_resume(struct device *dev) { return 0; } 104 return -ENOSYS;
78static inline int pm_request_idle(struct device *dev) { return -ENOSYS; } 105}
106static inline int __pm_runtime_suspend(struct device *dev, int rpmflags)
107{
108 return -ENOSYS;
109}
110static inline int __pm_runtime_resume(struct device *dev, int rpmflags)
111{
112 return 1;
113}
79static inline int pm_schedule_suspend(struct device *dev, unsigned int delay) 114static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
80{ 115{
81 return -ENOSYS; 116 return -ENOSYS;
82} 117}
83static inline int pm_request_resume(struct device *dev) { return 0; }
84static inline int __pm_runtime_get(struct device *dev, bool sync) { return 1; }
85static inline int __pm_runtime_put(struct device *dev, bool sync) { return 0; }
86static inline int __pm_runtime_set_status(struct device *dev, 118static inline int __pm_runtime_set_status(struct device *dev,
87 unsigned int status) { return 0; } 119 unsigned int status) { return 0; }
88static inline int pm_runtime_barrier(struct device *dev) { return 0; } 120static inline int pm_runtime_barrier(struct device *dev) { return 0; }
@@ -98,31 +130,94 @@ static inline void pm_runtime_put_noidle(struct device *dev) {}
98static inline bool device_run_wake(struct device *dev) { return false; } 130static inline bool device_run_wake(struct device *dev) { return false; }
99static inline void device_set_run_wake(struct device *dev, bool enable) {} 131static inline void device_set_run_wake(struct device *dev, bool enable) {}
100static inline bool pm_runtime_suspended(struct device *dev) { return false; } 132static inline bool pm_runtime_suspended(struct device *dev) { return false; }
133static inline bool pm_runtime_enabled(struct device *dev) { return false; }
101 134
102static inline int pm_generic_runtime_idle(struct device *dev) { return 0; } 135static inline int pm_generic_runtime_idle(struct device *dev) { return 0; }
103static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; } 136static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
104static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } 137static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
138static inline void pm_runtime_no_callbacks(struct device *dev) {}
139static inline void pm_runtime_irq_safe(struct device *dev) {}
140
141static inline bool pm_runtime_callbacks_present(struct device *dev) { return false; }
142static inline void pm_runtime_mark_last_busy(struct device *dev) {}
143static inline void __pm_runtime_use_autosuspend(struct device *dev,
144 bool use) {}
145static inline void pm_runtime_set_autosuspend_delay(struct device *dev,
146 int delay) {}
147static inline unsigned long pm_runtime_autosuspend_expiration(
148 struct device *dev) { return 0; }
105 149
106#endif /* !CONFIG_PM_RUNTIME */ 150#endif /* !CONFIG_PM_RUNTIME */
107 151
152static inline int pm_runtime_idle(struct device *dev)
153{
154 return __pm_runtime_idle(dev, 0);
155}
156
157static inline int pm_runtime_suspend(struct device *dev)
158{
159 return __pm_runtime_suspend(dev, 0);
160}
161
162static inline int pm_runtime_autosuspend(struct device *dev)
163{
164 return __pm_runtime_suspend(dev, RPM_AUTO);
165}
166
167static inline int pm_runtime_resume(struct device *dev)
168{
169 return __pm_runtime_resume(dev, 0);
170}
171
172static inline int pm_request_idle(struct device *dev)
173{
174 return __pm_runtime_idle(dev, RPM_ASYNC);
175}
176
177static inline int pm_request_resume(struct device *dev)
178{
179 return __pm_runtime_resume(dev, RPM_ASYNC);
180}
181
182static inline int pm_request_autosuspend(struct device *dev)
183{
184 return __pm_runtime_suspend(dev, RPM_ASYNC | RPM_AUTO);
185}
186
108static inline int pm_runtime_get(struct device *dev) 187static inline int pm_runtime_get(struct device *dev)
109{ 188{
110 return __pm_runtime_get(dev, false); 189 return __pm_runtime_resume(dev, RPM_GET_PUT | RPM_ASYNC);
111} 190}
112 191
113static inline int pm_runtime_get_sync(struct device *dev) 192static inline int pm_runtime_get_sync(struct device *dev)
114{ 193{
115 return __pm_runtime_get(dev, true); 194 return __pm_runtime_resume(dev, RPM_GET_PUT);
116} 195}
117 196
118static inline int pm_runtime_put(struct device *dev) 197static inline int pm_runtime_put(struct device *dev)
119{ 198{
120 return __pm_runtime_put(dev, false); 199 return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
200}
201
202static inline int pm_runtime_put_autosuspend(struct device *dev)
203{
204 return __pm_runtime_suspend(dev,
205 RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
121} 206}
122 207
123static inline int pm_runtime_put_sync(struct device *dev) 208static inline int pm_runtime_put_sync(struct device *dev)
124{ 209{
125 return __pm_runtime_put(dev, true); 210 return __pm_runtime_idle(dev, RPM_GET_PUT);
211}
212
213static inline int pm_runtime_put_sync_suspend(struct device *dev)
214{
215 return __pm_runtime_suspend(dev, RPM_GET_PUT);
216}
217
218static inline int pm_runtime_put_sync_autosuspend(struct device *dev)
219{
220 return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO);
126} 221}
127 222
128static inline int pm_runtime_set_active(struct device *dev) 223static inline int pm_runtime_set_active(struct device *dev)
@@ -140,4 +235,56 @@ static inline void pm_runtime_disable(struct device *dev)
140 __pm_runtime_disable(dev, true); 235 __pm_runtime_disable(dev, true);
141} 236}
142 237
238static inline void pm_runtime_use_autosuspend(struct device *dev)
239{
240 __pm_runtime_use_autosuspend(dev, true);
241}
242
243static inline void pm_runtime_dont_use_autosuspend(struct device *dev)
244{
245 __pm_runtime_use_autosuspend(dev, false);
246}
247
248struct pm_clk_notifier_block {
249 struct notifier_block nb;
250 struct dev_power_domain *pwr_domain;
251 char *con_ids[];
252};
253
254#ifdef CONFIG_PM_RUNTIME_CLK
255extern int pm_runtime_clk_init(struct device *dev);
256extern void pm_runtime_clk_destroy(struct device *dev);
257extern int pm_runtime_clk_add(struct device *dev, const char *con_id);
258extern void pm_runtime_clk_remove(struct device *dev, const char *con_id);
259extern int pm_runtime_clk_suspend(struct device *dev);
260extern int pm_runtime_clk_resume(struct device *dev);
261#else
262static inline int pm_runtime_clk_init(struct device *dev)
263{
264 return -EINVAL;
265}
266static inline void pm_runtime_clk_destroy(struct device *dev)
267{
268}
269static inline int pm_runtime_clk_add(struct device *dev, const char *con_id)
270{
271 return -EINVAL;
272}
273static inline void pm_runtime_clk_remove(struct device *dev, const char *con_id)
274{
275}
276#define pm_runtime_clock_suspend NULL
277#define pm_runtime_clock_resume NULL
278#endif
279
280#ifdef CONFIG_HAVE_CLK
281extern void pm_runtime_clk_add_notifier(struct bus_type *bus,
282 struct pm_clk_notifier_block *clknb);
283#else
284static inline void pm_runtime_clk_add_notifier(struct bus_type *bus,
285 struct pm_clk_notifier_block *clknb)
286{
287}
288#endif
289
143#endif 290#endif
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
index 76aca48722ae..a32da962d693 100644
--- a/include/linux/pm_wakeup.h
+++ b/include/linux/pm_wakeup.h
@@ -2,6 +2,7 @@
2 * pm_wakeup.h - Power management wakeup interface 2 * pm_wakeup.h - Power management wakeup interface
3 * 3 *
4 * Copyright (C) 2008 Alan Stern 4 * Copyright (C) 2008 Alan Stern
5 * Copyright (C) 2010 Rafael J. Wysocki, Novell Inc.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -27,19 +28,71 @@
27 28
28#include <linux/types.h> 29#include <linux/types.h>
29 30
30#ifdef CONFIG_PM 31/**
31 32 * struct wakeup_source - Representation of wakeup sources
32/* Changes to device_may_wakeup take effect on the next pm state change.
33 * 33 *
34 * By default, most devices should leave wakeup disabled. The exceptions 34 * @total_time: Total time this wakeup source has been active.
35 * are devices that everyone expects to be wakeup sources: keyboards, 35 * @max_time: Maximum time this wakeup source has been continuously active.
36 * power buttons, possibly network interfaces, etc. 36 * @last_time: Monotonic clock when the wakeup source's was activated last time.
37 * @event_count: Number of signaled wakeup events.
38 * @active_count: Number of times the wakeup sorce was activated.
39 * @relax_count: Number of times the wakeup sorce was deactivated.
40 * @hit_count: Number of times the wakeup sorce might abort system suspend.
41 * @active: Status of the wakeup source.
42 */
43struct wakeup_source {
44 char *name;
45 struct list_head entry;
46 spinlock_t lock;
47 struct timer_list timer;
48 unsigned long timer_expires;
49 ktime_t total_time;
50 ktime_t max_time;
51 ktime_t last_time;
52 unsigned long event_count;
53 unsigned long active_count;
54 unsigned long relax_count;
55 unsigned long hit_count;
56 unsigned int active:1;
57};
58
59#ifdef CONFIG_PM_SLEEP
60
61/*
62 * Changes to device_may_wakeup take effect on the next pm state change.
37 */ 63 */
38static inline void device_init_wakeup(struct device *dev, bool val) 64
65static inline bool device_can_wakeup(struct device *dev)
39{ 66{
40 dev->power.can_wakeup = dev->power.should_wakeup = val; 67 return dev->power.can_wakeup;
41} 68}
42 69
70static inline bool device_may_wakeup(struct device *dev)
71{
72 return dev->power.can_wakeup && !!dev->power.wakeup;
73}
74
75/* drivers/base/power/wakeup.c */
76extern struct wakeup_source *wakeup_source_create(const char *name);
77extern void wakeup_source_destroy(struct wakeup_source *ws);
78extern void wakeup_source_add(struct wakeup_source *ws);
79extern void wakeup_source_remove(struct wakeup_source *ws);
80extern struct wakeup_source *wakeup_source_register(const char *name);
81extern void wakeup_source_unregister(struct wakeup_source *ws);
82extern int device_wakeup_enable(struct device *dev);
83extern int device_wakeup_disable(struct device *dev);
84extern void device_set_wakeup_capable(struct device *dev, bool capable);
85extern int device_init_wakeup(struct device *dev, bool val);
86extern int device_set_wakeup_enable(struct device *dev, bool enable);
87extern void __pm_stay_awake(struct wakeup_source *ws);
88extern void pm_stay_awake(struct device *dev);
89extern void __pm_relax(struct wakeup_source *ws);
90extern void pm_relax(struct device *dev);
91extern void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec);
92extern void pm_wakeup_event(struct device *dev, unsigned int msec);
93
94#else /* !CONFIG_PM_SLEEP */
95
43static inline void device_set_wakeup_capable(struct device *dev, bool capable) 96static inline void device_set_wakeup_capable(struct device *dev, bool capable)
44{ 97{
45 dev->power.can_wakeup = capable; 98 dev->power.can_wakeup = capable;
@@ -50,43 +103,66 @@ static inline bool device_can_wakeup(struct device *dev)
50 return dev->power.can_wakeup; 103 return dev->power.can_wakeup;
51} 104}
52 105
53static inline void device_set_wakeup_enable(struct device *dev, bool enable) 106static inline struct wakeup_source *wakeup_source_create(const char *name)
54{ 107{
55 dev->power.should_wakeup = enable; 108 return NULL;
56} 109}
57 110
58static inline bool device_may_wakeup(struct device *dev) 111static inline void wakeup_source_destroy(struct wakeup_source *ws) {}
112
113static inline void wakeup_source_add(struct wakeup_source *ws) {}
114
115static inline void wakeup_source_remove(struct wakeup_source *ws) {}
116
117static inline struct wakeup_source *wakeup_source_register(const char *name)
59{ 118{
60 return dev->power.can_wakeup && dev->power.should_wakeup; 119 return NULL;
61} 120}
62 121
63#else /* !CONFIG_PM */ 122static inline void wakeup_source_unregister(struct wakeup_source *ws) {}
64 123
65/* For some reason the following routines work even without CONFIG_PM */ 124static inline int device_wakeup_enable(struct device *dev)
66static inline void device_init_wakeup(struct device *dev, bool val)
67{ 125{
68 dev->power.can_wakeup = val; 126 dev->power.should_wakeup = true;
127 return 0;
69} 128}
70 129
71static inline void device_set_wakeup_capable(struct device *dev, bool capable) 130static inline int device_wakeup_disable(struct device *dev)
72{ 131{
73 dev->power.can_wakeup = capable; 132 dev->power.should_wakeup = false;
133 return 0;
74} 134}
75 135
76static inline bool device_can_wakeup(struct device *dev) 136static inline int device_set_wakeup_enable(struct device *dev, bool enable)
77{ 137{
78 return dev->power.can_wakeup; 138 dev->power.should_wakeup = enable;
139 return 0;
79} 140}
80 141
81static inline void device_set_wakeup_enable(struct device *dev, bool enable) 142static inline int device_init_wakeup(struct device *dev, bool val)
82{ 143{
144 device_set_wakeup_capable(dev, val);
145 device_set_wakeup_enable(dev, val);
146 return 0;
83} 147}
84 148
85static inline bool device_may_wakeup(struct device *dev) 149static inline bool device_may_wakeup(struct device *dev)
86{ 150{
87 return false; 151 return dev->power.can_wakeup && dev->power.should_wakeup;
88} 152}
89 153
90#endif /* !CONFIG_PM */ 154static inline void __pm_stay_awake(struct wakeup_source *ws) {}
155
156static inline void pm_stay_awake(struct device *dev) {}
157
158static inline void __pm_relax(struct wakeup_source *ws) {}
159
160static inline void pm_relax(struct device *dev) {}
161
162static inline void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec) {}
163
164static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {}
165
166#endif /* !CONFIG_PM_SLEEP */
91 167
92#endif /* _LINUX_PM_WAKEUP_H */ 168#endif /* _LINUX_PM_WAKEUP_H */
diff --git a/include/linux/pnfs_osd_xdr.h b/include/linux/pnfs_osd_xdr.h
new file mode 100644
index 000000000000..76efbdd01622
--- /dev/null
+++ b/include/linux/pnfs_osd_xdr.h
@@ -0,0 +1,345 @@
1/*
2 * pNFS-osd on-the-wire data structures
3 *
4 * Copyright (C) 2007 Panasas Inc. [year of first publication]
5 * All rights reserved.
6 *
7 * Benny Halevy <bhalevy@panasas.com>
8 * Boaz Harrosh <bharrosh@panasas.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * See the file COPYING included with this distribution for more details.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of the Panasas company nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
28 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
29 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
34 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 */
39#ifndef __PNFS_OSD_XDR_H__
40#define __PNFS_OSD_XDR_H__
41
42#include <linux/nfs_fs.h>
43#include <linux/nfs_page.h>
44#include <scsi/osd_protocol.h>
45
46#define PNFS_OSD_OSDNAME_MAXSIZE 256
47
48/*
49 * draft-ietf-nfsv4-minorversion-22
50 * draft-ietf-nfsv4-pnfs-obj-12
51 */
52
53/* Layout Structure */
54
55enum pnfs_osd_raid_algorithm4 {
56 PNFS_OSD_RAID_0 = 1,
57 PNFS_OSD_RAID_4 = 2,
58 PNFS_OSD_RAID_5 = 3,
59 PNFS_OSD_RAID_PQ = 4 /* Reed-Solomon P+Q */
60};
61
62/* struct pnfs_osd_data_map4 {
63 * uint32_t odm_num_comps;
64 * length4 odm_stripe_unit;
65 * uint32_t odm_group_width;
66 * uint32_t odm_group_depth;
67 * uint32_t odm_mirror_cnt;
68 * pnfs_osd_raid_algorithm4 odm_raid_algorithm;
69 * };
70 */
71struct pnfs_osd_data_map {
72 u32 odm_num_comps;
73 u64 odm_stripe_unit;
74 u32 odm_group_width;
75 u32 odm_group_depth;
76 u32 odm_mirror_cnt;
77 u32 odm_raid_algorithm;
78};
79
80/* struct pnfs_osd_objid4 {
81 * deviceid4 oid_device_id;
82 * uint64_t oid_partition_id;
83 * uint64_t oid_object_id;
84 * };
85 */
86struct pnfs_osd_objid {
87 struct nfs4_deviceid oid_device_id;
88 u64 oid_partition_id;
89 u64 oid_object_id;
90};
91
92/* For printout. I use:
93 * kprint("dev(%llx:%llx)", _DEVID_LO(pointer), _DEVID_HI(pointer));
94 * BE style
95 */
96#define _DEVID_LO(oid_device_id) \
97 (unsigned long long)be64_to_cpup((__be64 *)(oid_device_id)->data)
98
99#define _DEVID_HI(oid_device_id) \
100 (unsigned long long)be64_to_cpup(((__be64 *)(oid_device_id)->data) + 1)
101
102static inline int
103pnfs_osd_objid_xdr_sz(void)
104{
105 return (NFS4_DEVICEID4_SIZE / 4) + 2 + 2;
106}
107
108enum pnfs_osd_version {
109 PNFS_OSD_MISSING = 0,
110 PNFS_OSD_VERSION_1 = 1,
111 PNFS_OSD_VERSION_2 = 2
112};
113
114struct pnfs_osd_opaque_cred {
115 u32 cred_len;
116 void *cred;
117};
118
119enum pnfs_osd_cap_key_sec {
120 PNFS_OSD_CAP_KEY_SEC_NONE = 0,
121 PNFS_OSD_CAP_KEY_SEC_SSV = 1,
122};
123
124/* struct pnfs_osd_object_cred4 {
125 * pnfs_osd_objid4 oc_object_id;
126 * pnfs_osd_version4 oc_osd_version;
127 * pnfs_osd_cap_key_sec4 oc_cap_key_sec;
128 * opaque oc_capability_key<>;
129 * opaque oc_capability<>;
130 * };
131 */
132struct pnfs_osd_object_cred {
133 struct pnfs_osd_objid oc_object_id;
134 u32 oc_osd_version;
135 u32 oc_cap_key_sec;
136 struct pnfs_osd_opaque_cred oc_cap_key;
137 struct pnfs_osd_opaque_cred oc_cap;
138};
139
140/* struct pnfs_osd_layout4 {
141 * pnfs_osd_data_map4 olo_map;
142 * uint32_t olo_comps_index;
143 * pnfs_osd_object_cred4 olo_components<>;
144 * };
145 */
146struct pnfs_osd_layout {
147 struct pnfs_osd_data_map olo_map;
148 u32 olo_comps_index;
149 u32 olo_num_comps;
150 struct pnfs_osd_object_cred *olo_comps;
151};
152
153/* Device Address */
154enum pnfs_osd_targetid_type {
155 OBJ_TARGET_ANON = 1,
156 OBJ_TARGET_SCSI_NAME = 2,
157 OBJ_TARGET_SCSI_DEVICE_ID = 3,
158};
159
160/* union pnfs_osd_targetid4 switch (pnfs_osd_targetid_type4 oti_type) {
161 * case OBJ_TARGET_SCSI_NAME:
162 * string oti_scsi_name<>;
163 *
164 * case OBJ_TARGET_SCSI_DEVICE_ID:
165 * opaque oti_scsi_device_id<>;
166 *
167 * default:
168 * void;
169 * };
170 *
171 * union pnfs_osd_targetaddr4 switch (bool ota_available) {
172 * case TRUE:
173 * netaddr4 ota_netaddr;
174 * case FALSE:
175 * void;
176 * };
177 *
178 * struct pnfs_osd_deviceaddr4 {
179 * pnfs_osd_targetid4 oda_targetid;
180 * pnfs_osd_targetaddr4 oda_targetaddr;
181 * uint64_t oda_lun;
182 * opaque oda_systemid<>;
183 * pnfs_osd_object_cred4 oda_root_obj_cred;
184 * opaque oda_osdname<>;
185 * };
186 */
187struct pnfs_osd_targetid {
188 u32 oti_type;
189 struct nfs4_string oti_scsi_device_id;
190};
191
192enum { PNFS_OSD_TARGETID_MAX = 1 + PNFS_OSD_OSDNAME_MAXSIZE / 4 };
193
194/* struct netaddr4 {
195 * // see struct rpcb in RFC1833
196 * string r_netid<>; // network id
197 * string r_addr<>; // universal address
198 * };
199 */
200struct pnfs_osd_net_addr {
201 struct nfs4_string r_netid;
202 struct nfs4_string r_addr;
203};
204
205struct pnfs_osd_targetaddr {
206 u32 ota_available;
207 struct pnfs_osd_net_addr ota_netaddr;
208};
209
210enum {
211 NETWORK_ID_MAX = 16 / 4,
212 UNIVERSAL_ADDRESS_MAX = 64 / 4,
213 PNFS_OSD_TARGETADDR_MAX = 3 + NETWORK_ID_MAX + UNIVERSAL_ADDRESS_MAX,
214};
215
216struct pnfs_osd_deviceaddr {
217 struct pnfs_osd_targetid oda_targetid;
218 struct pnfs_osd_targetaddr oda_targetaddr;
219 u8 oda_lun[8];
220 struct nfs4_string oda_systemid;
221 struct pnfs_osd_object_cred oda_root_obj_cred;
222 struct nfs4_string oda_osdname;
223};
224
225enum {
226 ODA_OSDNAME_MAX = PNFS_OSD_OSDNAME_MAXSIZE / 4,
227 PNFS_OSD_DEVICEADDR_MAX =
228 PNFS_OSD_TARGETID_MAX + PNFS_OSD_TARGETADDR_MAX +
229 2 /*oda_lun*/ +
230 1 + OSD_SYSTEMID_LEN +
231 1 + ODA_OSDNAME_MAX,
232};
233
234/* LAYOUTCOMMIT: layoutupdate */
235
236/* union pnfs_osd_deltaspaceused4 switch (bool dsu_valid) {
237 * case TRUE:
238 * int64_t dsu_delta;
239 * case FALSE:
240 * void;
241 * };
242 *
243 * struct pnfs_osd_layoutupdate4 {
244 * pnfs_osd_deltaspaceused4 olu_delta_space_used;
245 * bool olu_ioerr_flag;
246 * };
247 */
248struct pnfs_osd_layoutupdate {
249 u32 dsu_valid;
250 s64 dsu_delta;
251 u32 olu_ioerr_flag;
252};
253
254/* LAYOUTRETURN: I/O Rrror Report */
255
256enum pnfs_osd_errno {
257 PNFS_OSD_ERR_EIO = 1,
258 PNFS_OSD_ERR_NOT_FOUND = 2,
259 PNFS_OSD_ERR_NO_SPACE = 3,
260 PNFS_OSD_ERR_BAD_CRED = 4,
261 PNFS_OSD_ERR_NO_ACCESS = 5,
262 PNFS_OSD_ERR_UNREACHABLE = 6,
263 PNFS_OSD_ERR_RESOURCE = 7
264};
265
266/* struct pnfs_osd_ioerr4 {
267 * pnfs_osd_objid4 oer_component;
268 * length4 oer_comp_offset;
269 * length4 oer_comp_length;
270 * bool oer_iswrite;
271 * pnfs_osd_errno4 oer_errno;
272 * };
273 */
274struct pnfs_osd_ioerr {
275 struct pnfs_osd_objid oer_component;
276 u64 oer_comp_offset;
277 u64 oer_comp_length;
278 u32 oer_iswrite;
279 u32 oer_errno;
280};
281
282/* OSD XDR API */
283/* Layout helpers */
284/* Layout decoding is done in two parts:
285 * 1. First Call pnfs_osd_xdr_decode_layout_map to read in only the header part
286 * of the layout. @iter members need not be initialized.
287 * Returned:
288 * @layout members are set. (@layout->olo_comps set to NULL).
289 *
290 * Zero on success, or negative error if passed xdr is broken.
291 *
292 * 2. 2nd Call pnfs_osd_xdr_decode_layout_comp() in a loop until it returns
293 * false, to decode the next component.
294 * Returned:
295 * true if there is more to decode or false if we are done or error.
296 *
297 * Example:
298 * struct pnfs_osd_xdr_decode_layout_iter iter;
299 * struct pnfs_osd_layout layout;
300 * struct pnfs_osd_object_cred comp;
301 * int status;
302 *
303 * status = pnfs_osd_xdr_decode_layout_map(&layout, &iter, xdr);
304 * if (unlikely(status))
305 * goto err;
306 * while(pnfs_osd_xdr_decode_layout_comp(&comp, &iter, xdr, &status)) {
307 * // All of @comp strings point to inside the xdr_buffer
308 * // or scrach buffer. Copy them out to user memory eg.
309 * copy_single_comp(dest_comp++, &comp);
310 * }
311 * if (unlikely(status))
312 * goto err;
313 */
314
315struct pnfs_osd_xdr_decode_layout_iter {
316 unsigned total_comps;
317 unsigned decoded_comps;
318};
319
320extern int pnfs_osd_xdr_decode_layout_map(struct pnfs_osd_layout *layout,
321 struct pnfs_osd_xdr_decode_layout_iter *iter, struct xdr_stream *xdr);
322
323extern bool pnfs_osd_xdr_decode_layout_comp(struct pnfs_osd_object_cred *comp,
324 struct pnfs_osd_xdr_decode_layout_iter *iter, struct xdr_stream *xdr,
325 int *err);
326
327/* Device Info helpers */
328
329/* Note: All strings inside @deviceaddr point to space inside @p.
330 * @p should stay valid while @deviceaddr is in use.
331 */
332extern void pnfs_osd_xdr_decode_deviceaddr(
333 struct pnfs_osd_deviceaddr *deviceaddr, __be32 *p);
334
335/* layoutupdate (layout_commit) xdr helpers */
336extern int
337pnfs_osd_xdr_encode_layoutupdate(struct xdr_stream *xdr,
338 struct pnfs_osd_layoutupdate *lou);
339
340/* osd_ioerror encoding/decoding (layout_return) */
341/* Client */
342extern __be32 *pnfs_osd_xdr_ioerr_reserve_space(struct xdr_stream *xdr);
343extern void pnfs_osd_xdr_encode_ioerr(__be32 *p, struct pnfs_osd_ioerr *ioerr);
344
345#endif /* __PNFS_OSD_XDR_H__ */
diff --git a/include/linux/poll.h b/include/linux/poll.h
index 600cc1fde64d..cf40010ce0cd 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -57,7 +57,7 @@ struct poll_table_entry {
57}; 57};
58 58
59/* 59/*
60 * Structures and helpers for sys_poll/sys_poll 60 * Structures and helpers for select/poll syscall
61 */ 61 */
62struct poll_wqueues { 62struct poll_wqueues {
63 poll_table pt; 63 poll_table pt;
@@ -73,6 +73,8 @@ extern void poll_initwait(struct poll_wqueues *pwq);
73extern void poll_freewait(struct poll_wqueues *pwq); 73extern void poll_freewait(struct poll_wqueues *pwq);
74extern int poll_schedule_timeout(struct poll_wqueues *pwq, int state, 74extern int poll_schedule_timeout(struct poll_wqueues *pwq, int state,
75 ktime_t *expires, unsigned long slack); 75 ktime_t *expires, unsigned long slack);
76extern long select_estimate_accuracy(struct timespec *tv);
77
76 78
77static inline int poll_schedule(struct poll_wqueues *pwq, int state) 79static inline int poll_schedule(struct poll_wqueues *pwq, int state)
78{ 80{
@@ -80,7 +82,7 @@ static inline int poll_schedule(struct poll_wqueues *pwq, int state)
80} 82}
81 83
82/* 84/*
83 * Scaleable version of the fd_set. 85 * Scalable version of the fd_set.
84 */ 86 */
85 87
86typedef struct { 88typedef struct {
diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
new file mode 100644
index 000000000000..34c4498b800f
--- /dev/null
+++ b/include/linux/posix-clock.h
@@ -0,0 +1,151 @@
1/*
2 * posix-clock.h - support for dynamic clock devices
3 *
4 * Copyright (C) 2010 OMICRON electronics GmbH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20#ifndef _LINUX_POSIX_CLOCK_H_
21#define _LINUX_POSIX_CLOCK_H_
22
23#include <linux/cdev.h>
24#include <linux/fs.h>
25#include <linux/poll.h>
26#include <linux/posix-timers.h>
27#include <linux/rwsem.h>
28
29struct posix_clock;
30
31/**
32 * struct posix_clock_operations - functional interface to the clock
33 *
34 * Every posix clock is represented by a character device. Drivers may
35 * optionally offer extended capabilities by implementing the
36 * character device methods. The character device file operations are
37 * first handled by the clock device layer, then passed on to the
38 * driver by calling these functions.
39 *
40 * @owner: The clock driver should set to THIS_MODULE
41 * @clock_adjtime: Adjust the clock
42 * @clock_gettime: Read the current time
43 * @clock_getres: Get the clock resolution
44 * @clock_settime: Set the current time value
45 * @timer_create: Create a new timer
46 * @timer_delete: Remove a previously created timer
47 * @timer_gettime: Get remaining time and interval of a timer
48 * @timer_settime: Set a timer's initial expiration and interval
49 * @fasync: Optional character device fasync method
50 * @mmap: Optional character device mmap method
51 * @open: Optional character device open method
52 * @release: Optional character device release method
53 * @ioctl: Optional character device ioctl method
54 * @read: Optional character device read method
55 * @poll: Optional character device poll method
56 */
57struct posix_clock_operations {
58 struct module *owner;
59
60 int (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
61
62 int (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
63
64 int (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
65
66 int (*clock_settime)(struct posix_clock *pc,
67 const struct timespec *ts);
68
69 int (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
70
71 int (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
72
73 void (*timer_gettime)(struct posix_clock *pc,
74 struct k_itimer *kit, struct itimerspec *tsp);
75
76 int (*timer_settime)(struct posix_clock *pc,
77 struct k_itimer *kit, int flags,
78 struct itimerspec *tsp, struct itimerspec *old);
79 /*
80 * Optional character device methods:
81 */
82 int (*fasync) (struct posix_clock *pc,
83 int fd, struct file *file, int on);
84
85 long (*ioctl) (struct posix_clock *pc,
86 unsigned int cmd, unsigned long arg);
87
88 int (*mmap) (struct posix_clock *pc,
89 struct vm_area_struct *vma);
90
91 int (*open) (struct posix_clock *pc, fmode_t f_mode);
92
93 uint (*poll) (struct posix_clock *pc,
94 struct file *file, poll_table *wait);
95
96 int (*release) (struct posix_clock *pc);
97
98 ssize_t (*read) (struct posix_clock *pc,
99 uint flags, char __user *buf, size_t cnt);
100};
101
102/**
103 * struct posix_clock - represents a dynamic posix clock
104 *
105 * @ops: Functional interface to the clock
106 * @cdev: Character device instance for this clock
107 * @kref: Reference count.
108 * @rwsem: Protects the 'zombie' field from concurrent access.
109 * @zombie: If 'zombie' is true, then the hardware has disappeared.
110 * @release: A function to free the structure when the reference count reaches
111 * zero. May be NULL if structure is statically allocated.
112 *
113 * Drivers should embed their struct posix_clock within a private
114 * structure, obtaining a reference to it during callbacks using
115 * container_of().
116 */
117struct posix_clock {
118 struct posix_clock_operations ops;
119 struct cdev cdev;
120 struct kref kref;
121 struct rw_semaphore rwsem;
122 bool zombie;
123 void (*release)(struct posix_clock *clk);
124};
125
126/**
127 * posix_clock_register() - register a new clock
128 * @clk: Pointer to the clock. Caller must provide 'ops' and 'release'
129 * @devid: Allocated device id
130 *
131 * A clock driver calls this function to register itself with the
132 * clock device subsystem. If 'clk' points to dynamically allocated
133 * memory, then the caller must provide a 'release' function to free
134 * that memory.
135 *
136 * Returns zero on success, non-zero otherwise.
137 */
138int posix_clock_register(struct posix_clock *clk, dev_t devid);
139
140/**
141 * posix_clock_unregister() - unregister a clock
142 * @clk: Clock instance previously registered via posix_clock_register()
143 *
144 * A clock driver calls this function to remove itself from the clock
145 * device subsystem. The posix_clock itself will remain (in an
146 * inactive state) until its reference count drops to zero, at which
147 * point it will be deallocated with its 'release' method.
148 */
149void posix_clock_unregister(struct posix_clock *clk);
150
151#endif
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 3e23844a6990..959c14132f46 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -4,6 +4,8 @@
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/timex.h>
8#include <linux/alarmtimer.h>
7 9
8union cpu_time_count { 10union cpu_time_count {
9 cputime_t cpu; 11 cputime_t cpu;
@@ -17,10 +19,21 @@ struct cpu_timer_list {
17 int firing; 19 int firing;
18}; 20};
19 21
22/*
23 * Bit fields within a clockid:
24 *
25 * The most significant 29 bits hold either a pid or a file descriptor.
26 *
27 * Bit 2 indicates whether a cpu clock refers to a thread or a process.
28 *
29 * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.
30 *
31 * A clockid is invalid if bits 2, 1, and 0 are all set.
32 */
20#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3)) 33#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
21#define CPUCLOCK_PERTHREAD(clock) \ 34#define CPUCLOCK_PERTHREAD(clock) \
22 (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0) 35 (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
23#define CPUCLOCK_PID_MASK 7 36
24#define CPUCLOCK_PERTHREAD_MASK 4 37#define CPUCLOCK_PERTHREAD_MASK 4
25#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK) 38#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
26#define CPUCLOCK_CLOCK_MASK 3 39#define CPUCLOCK_CLOCK_MASK 3
@@ -28,12 +41,17 @@ struct cpu_timer_list {
28#define CPUCLOCK_VIRT 1 41#define CPUCLOCK_VIRT 1
29#define CPUCLOCK_SCHED 2 42#define CPUCLOCK_SCHED 2
30#define CPUCLOCK_MAX 3 43#define CPUCLOCK_MAX 3
44#define CLOCKFD CPUCLOCK_MAX
45#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)
31 46
32#define MAKE_PROCESS_CPUCLOCK(pid, clock) \ 47#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
33 ((~(clockid_t) (pid) << 3) | (clockid_t) (clock)) 48 ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
34#define MAKE_THREAD_CPUCLOCK(tid, clock) \ 49#define MAKE_THREAD_CPUCLOCK(tid, clock) \
35 MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK) 50 MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
36 51
52#define FD_TO_CLOCKID(fd) ((~(clockid_t) (fd) << 3) | CLOCKFD)
53#define CLOCKID_TO_FD(clk) ((unsigned int) ~((clk) >> 3))
54
37/* POSIX.1b interval timer structure. */ 55/* POSIX.1b interval timer structure. */
38struct k_itimer { 56struct k_itimer {
39 struct list_head list; /* free/ allocate list */ 57 struct list_head list; /* free/ allocate list */
@@ -63,14 +81,17 @@ struct k_itimer {
63 unsigned long incr; 81 unsigned long incr;
64 unsigned long expires; 82 unsigned long expires;
65 } mmtimer; 83 } mmtimer;
84 struct alarm alarmtimer;
85 struct rcu_head rcu;
66 } it; 86 } it;
67}; 87};
68 88
69struct k_clock { 89struct k_clock {
70 int res; /* in nanoseconds */
71 int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); 90 int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
72 int (*clock_set) (const clockid_t which_clock, struct timespec * tp); 91 int (*clock_set) (const clockid_t which_clock,
92 const struct timespec *tp);
73 int (*clock_get) (const clockid_t which_clock, struct timespec * tp); 93 int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
94 int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
74 int (*timer_create) (struct k_itimer *timer); 95 int (*timer_create) (struct k_itimer *timer);
75 int (*nsleep) (const clockid_t which_clock, int flags, 96 int (*nsleep) (const clockid_t which_clock, int flags,
76 struct timespec *, struct timespec __user *); 97 struct timespec *, struct timespec __user *);
@@ -84,28 +105,14 @@ struct k_clock {
84 struct itimerspec * cur_setting); 105 struct itimerspec * cur_setting);
85}; 106};
86 107
87void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock); 108extern struct k_clock clock_posix_cpu;
109extern struct k_clock clock_posix_dynamic;
88 110
89/* error handlers for timer_create, nanosleep and settime */ 111void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock);
90int do_posix_clock_nonanosleep(const clockid_t, int flags, struct timespec *,
91 struct timespec __user *);
92int do_posix_clock_nosettime(const clockid_t, struct timespec *tp);
93 112
94/* function to call to trigger timer event */ 113/* function to call to trigger timer event */
95int posix_timer_event(struct k_itimer *timr, int si_private); 114int posix_timer_event(struct k_itimer *timr, int si_private);
96 115
97int posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *ts);
98int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *ts);
99int posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *ts);
100int posix_cpu_timer_create(struct k_itimer *timer);
101int posix_cpu_nsleep(const clockid_t which_clock, int flags,
102 struct timespec *rqtp, struct timespec __user *rmtp);
103long posix_cpu_nsleep_restart(struct restart_block *restart_block);
104int posix_cpu_timer_set(struct k_itimer *timer, int flags,
105 struct itimerspec *new, struct itimerspec *old);
106int posix_cpu_timer_del(struct k_itimer *timer);
107void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp);
108
109void posix_cpu_timer_schedule(struct k_itimer *timer); 116void posix_cpu_timer_schedule(struct k_itimer *timer);
110 117
111void run_posix_cpu_timers(struct task_struct *task); 118void run_posix_cpu_timers(struct task_struct *task);
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 67608161df6b..54211c1cd926 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -71,6 +71,7 @@ posix_acl_release(struct posix_acl *acl)
71 71
72/* posix_acl.c */ 72/* posix_acl.c */
73 73
74extern void posix_acl_init(struct posix_acl *, int);
74extern struct posix_acl *posix_acl_alloc(int, gfp_t); 75extern struct posix_acl *posix_acl_alloc(int, gfp_t);
75extern struct posix_acl *posix_acl_clone(const struct posix_acl *, gfp_t); 76extern struct posix_acl *posix_acl_clone(const struct posix_acl *, gfp_t);
76extern int posix_acl_valid(const struct posix_acl *); 77extern int posix_acl_valid(const struct posix_acl *);
@@ -108,6 +109,25 @@ static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
108 return acl; 109 return acl;
109} 110}
110 111
112static inline int negative_cached_acl(struct inode *inode, int type)
113{
114 struct posix_acl **p, *acl;
115 switch (type) {
116 case ACL_TYPE_ACCESS:
117 p = &inode->i_acl;
118 break;
119 case ACL_TYPE_DEFAULT:
120 p = &inode->i_default_acl;
121 break;
122 default:
123 BUG();
124 }
125 acl = ACCESS_ONCE(*p);
126 if (acl)
127 return 0;
128 return 1;
129}
130
111static inline void set_cached_acl(struct inode *inode, 131static inline void set_cached_acl(struct inode *inode,
112 int type, 132 int type,
113 struct posix_acl *acl) 133 struct posix_acl *acl)
diff --git a/include/linux/power/bq20z75.h b/include/linux/power/bq20z75.h
new file mode 100644
index 000000000000..b0843b68af92
--- /dev/null
+++ b/include/linux/power/bq20z75.h
@@ -0,0 +1,39 @@
1/*
2 * Gas Gauge driver for TI's BQ20Z75
3 *
4 * Copyright (c) 2010, NVIDIA Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef __LINUX_POWER_BQ20Z75_H_
22#define __LINUX_POWER_BQ20Z75_H_
23
24#include <linux/power_supply.h>
25#include <linux/types.h>
26
27/**
28 * struct bq20z75_platform_data - platform data for bq20z75 devices
29 * @battery_detect: GPIO which is used to detect battery presence
30 * @battery_detect_present: gpio state when battery is present (0 / 1)
31 * @i2c_retry_count: # of times to retry on i2c IO failure
32 */
33struct bq20z75_platform_data {
34 int battery_detect;
35 int battery_detect_present;
36 int i2c_retry_count;
37};
38
39#endif
diff --git a/include/linux/power/bq27x00_battery.h b/include/linux/power/bq27x00_battery.h
new file mode 100644
index 000000000000..a857f719bf40
--- /dev/null
+++ b/include/linux/power/bq27x00_battery.h
@@ -0,0 +1,19 @@
1#ifndef __LINUX_BQ27X00_BATTERY_H__
2#define __LINUX_BQ27X00_BATTERY_H__
3
4/**
5 * struct bq27000_plaform_data - Platform data for bq27000 devices
6 * @name: Name of the battery. If NULL the driver will fallback to "bq27000".
7 * @read: HDQ read callback.
8 * This function should provide access to the HDQ bus the battery is
9 * connected to.
10 * The first parameter is a pointer to the battery device, the second the
11 * register to be read. The return value should either be the content of
12 * the passed register or an error value.
13 */
14struct bq27000_platform_data {
15 const char *name;
16 int (*read)(struct device *dev, unsigned int);
17};
18
19#endif
diff --git a/include/linux/power/gpio-charger.h b/include/linux/power/gpio-charger.h
new file mode 100644
index 000000000000..de1dfe09a03d
--- /dev/null
+++ b/include/linux/power/gpio-charger.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * You should have received a copy of the GNU General Public License along
10 * with this program; if not, write to the Free Software Foundation, Inc.,
11 * 675 Mass Ave, Cambridge, MA 02139, USA.
12 *
13 */
14
15#ifndef __LINUX_POWER_GPIO_CHARGER_H__
16#define __LINUX_POWER_GPIO_CHARGER_H__
17
18#include <linux/power_supply.h>
19#include <linux/types.h>
20
21/**
22 * struct gpio_charger_platform_data - platform_data for gpio_charger devices
23 * @name: Name for the chargers power_supply device
24 * @type: Type of the charger
25 * @gpio: GPIO which is used to indicate the chargers status
26 * @gpio_active_low: Should be set to 1 if the GPIO is active low otherwise 0
27 * @supplied_to: Array of battery names to which this chargers supplies power
28 * @num_supplicants: Number of entries in the supplied_to array
29 */
30struct gpio_charger_platform_data {
31 const char *name;
32 enum power_supply_type type;
33
34 int gpio;
35 int gpio_active_low;
36
37 char **supplied_to;
38 size_t num_supplicants;
39};
40
41#endif
diff --git a/include/linux/power/isp1704_charger.h b/include/linux/power/isp1704_charger.h
new file mode 100644
index 000000000000..68096a6aa2d7
--- /dev/null
+++ b/include/linux/power/isp1704_charger.h
@@ -0,0 +1,29 @@
1/*
2 * ISP1704 USB Charger Detection driver
3 *
4 * Copyright (C) 2011 Nokia Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21
22#ifndef __ISP1704_CHARGER_H
23#define __ISP1704_CHARGER_H
24
25struct isp1704_charger_data {
26 void (*set_power)(bool on);
27};
28
29#endif
diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
new file mode 100644
index 000000000000..7995deb8bfc1
--- /dev/null
+++ b/include/linux/power/max17042_battery.h
@@ -0,0 +1,30 @@
1/*
2 * Fuel gauge driver for Maxim 17042 / 8966 / 8997
3 * Note that Maxim 8966 and 8997 are mfd and this is its subdevice.
4 *
5 * Copyright (C) 2011 Samsung Electronics
6 * MyungJoo Ham <myungjoo.ham@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef __MAX17042_BATTERY_H_
24#define __MAX17042_BATTERY_H_
25
26struct max17042_platform_data {
27 bool enable_current_sense;
28};
29
30#endif /* __MAX17042_BATTERY_H_ */
diff --git a/include/linux/power/max8903_charger.h b/include/linux/power/max8903_charger.h
new file mode 100644
index 000000000000..24f51db8a83f
--- /dev/null
+++ b/include/linux/power/max8903_charger.h
@@ -0,0 +1,57 @@
1/*
2 * max8903_charger.h - Maxim 8903 USB/Adapter Charger Driver
3 *
4 * Copyright (C) 2011 Samsung Electronics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef __MAX8903_CHARGER_H__
24#define __MAX8903_CHARGER_H__
25
26struct max8903_pdata {
27 /*
28 * GPIOs
29 * cen, chg, flt, and usus are optional.
30 * dok, dcm, and uok are not optional depending on the status of
31 * dc_valid and usb_valid.
32 */
33 int cen; /* Charger Enable input */
34 int dok; /* DC(Adapter) Power OK output */
35 int uok; /* USB Power OK output */
36 int chg; /* Charger status output */
37 int flt; /* Fault output */
38 int dcm; /* Current-Limit Mode input (1: DC, 2: USB) */
39 int usus; /* USB Suspend Input (1: suspended) */
40
41 /*
42 * DC(Adapter/TA) is wired
43 * When dc_valid is true,
44 * dok and dcm should be valid.
45 *
46 * At least one of dc_valid or usb_valid should be true.
47 */
48 bool dc_valid;
49 /*
50 * USB is wired
51 * When usb_valid is true,
52 * uok should be valid.
53 */
54 bool usb_valid;
55};
56
57#endif /* __MAX8903_CHARGER_H__ */
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 30083a896f36..204c18dfdc9e 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -89,6 +89,7 @@ enum power_supply_property {
89 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 89 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
90 POWER_SUPPLY_PROP_VOLTAGE_NOW, 90 POWER_SUPPLY_PROP_VOLTAGE_NOW,
91 POWER_SUPPLY_PROP_VOLTAGE_AVG, 91 POWER_SUPPLY_PROP_VOLTAGE_AVG,
92 POWER_SUPPLY_PROP_CURRENT_MAX,
92 POWER_SUPPLY_PROP_CURRENT_NOW, 93 POWER_SUPPLY_PROP_CURRENT_NOW,
93 POWER_SUPPLY_PROP_CURRENT_AVG, 94 POWER_SUPPLY_PROP_CURRENT_AVG,
94 POWER_SUPPLY_PROP_POWER_NOW, 95 POWER_SUPPLY_PROP_POWER_NOW,
@@ -125,7 +126,10 @@ enum power_supply_type {
125 POWER_SUPPLY_TYPE_BATTERY = 0, 126 POWER_SUPPLY_TYPE_BATTERY = 0,
126 POWER_SUPPLY_TYPE_UPS, 127 POWER_SUPPLY_TYPE_UPS,
127 POWER_SUPPLY_TYPE_MAINS, 128 POWER_SUPPLY_TYPE_MAINS,
128 POWER_SUPPLY_TYPE_USB, 129 POWER_SUPPLY_TYPE_USB, /* Standard Downstream Port */
130 POWER_SUPPLY_TYPE_USB_DCP, /* Dedicated Charging Port */
131 POWER_SUPPLY_TYPE_USB_CDP, /* Charging Downstream Port */
132 POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */
129}; 133};
130 134
131union power_supply_propval { 135union power_supply_propval {
@@ -169,6 +173,8 @@ struct power_supply {
169 char *full_trig_name; 173 char *full_trig_name;
170 struct led_trigger *online_trig; 174 struct led_trigger *online_trig;
171 char *online_trig_name; 175 char *online_trig_name;
176 struct led_trigger *charging_blink_full_solid_trig;
177 char *charging_blink_full_solid_trig_name;
172#endif 178#endif
173}; 179};
174 180
@@ -209,4 +215,49 @@ extern void power_supply_unregister(struct power_supply *psy);
209/* For APM emulation, think legacy userspace. */ 215/* For APM emulation, think legacy userspace. */
210extern struct class *power_supply_class; 216extern struct class *power_supply_class;
211 217
218static inline bool power_supply_is_amp_property(enum power_supply_property psp)
219{
220 switch (psp) {
221 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
222 case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN:
223 case POWER_SUPPLY_PROP_CHARGE_FULL:
224 case POWER_SUPPLY_PROP_CHARGE_EMPTY:
225 case POWER_SUPPLY_PROP_CHARGE_NOW:
226 case POWER_SUPPLY_PROP_CHARGE_AVG:
227 case POWER_SUPPLY_PROP_CHARGE_COUNTER:
228 case POWER_SUPPLY_PROP_CURRENT_MAX:
229 case POWER_SUPPLY_PROP_CURRENT_NOW:
230 case POWER_SUPPLY_PROP_CURRENT_AVG:
231 return 1;
232 default:
233 break;
234 }
235
236 return 0;
237}
238
239static inline bool power_supply_is_watt_property(enum power_supply_property psp)
240{
241 switch (psp) {
242 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
243 case POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN:
244 case POWER_SUPPLY_PROP_ENERGY_FULL:
245 case POWER_SUPPLY_PROP_ENERGY_EMPTY:
246 case POWER_SUPPLY_PROP_ENERGY_NOW:
247 case POWER_SUPPLY_PROP_ENERGY_AVG:
248 case POWER_SUPPLY_PROP_VOLTAGE_MAX:
249 case POWER_SUPPLY_PROP_VOLTAGE_MIN:
250 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
251 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
252 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
253 case POWER_SUPPLY_PROP_VOLTAGE_AVG:
254 case POWER_SUPPLY_PROP_POWER_NOW:
255 return 1;
256 default:
257 break;
258 }
259
260 return 0;
261}
262
212#endif /* __LINUX_POWER_SUPPLY_H__ */ 263#endif /* __LINUX_POWER_SUPPLY_H__ */
diff --git a/include/linux/pps.h b/include/linux/pps.h
index 0194ab06177b..a9bb1d93451a 100644
--- a/include/linux/pps.h
+++ b/include/linux/pps.h
@@ -114,11 +114,18 @@ struct pps_fdata {
114 struct pps_ktime timeout; 114 struct pps_ktime timeout;
115}; 115};
116 116
117struct pps_bind_args {
118 int tsformat; /* format of time stamps */
119 int edge; /* selected event type */
120 int consumer; /* selected kernel consumer */
121};
122
117#include <linux/ioctl.h> 123#include <linux/ioctl.h>
118 124
119#define PPS_GETPARAMS _IOR('p', 0xa1, struct pps_kparams *) 125#define PPS_GETPARAMS _IOR('p', 0xa1, struct pps_kparams *)
120#define PPS_SETPARAMS _IOW('p', 0xa2, struct pps_kparams *) 126#define PPS_SETPARAMS _IOW('p', 0xa2, struct pps_kparams *)
121#define PPS_GETCAP _IOR('p', 0xa3, int *) 127#define PPS_GETCAP _IOR('p', 0xa3, int *)
122#define PPS_FETCH _IOWR('p', 0xa4, struct pps_fdata *) 128#define PPS_FETCH _IOWR('p', 0xa4, struct pps_fdata *)
129#define PPS_KC_BIND _IOW('p', 0xa5, struct pps_bind_args *)
123 130
124#endif /* _PPS_H_ */ 131#endif /* _PPS_H_ */
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h
index e0a193f830ef..94048547f29a 100644
--- a/include/linux/pps_kernel.h
+++ b/include/linux/pps_kernel.h
@@ -18,6 +18,9 @@
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#ifndef LINUX_PPS_KERNEL_H
22#define LINUX_PPS_KERNEL_H
23
21#include <linux/pps.h> 24#include <linux/pps.h>
22 25
23#include <linux/cdev.h> 26#include <linux/cdev.h>
@@ -28,18 +31,28 @@
28 * Global defines 31 * Global defines
29 */ 32 */
30 33
34struct pps_device;
35
31/* The specific PPS source info */ 36/* The specific PPS source info */
32struct pps_source_info { 37struct pps_source_info {
33 char name[PPS_MAX_NAME_LEN]; /* simbolic name */ 38 char name[PPS_MAX_NAME_LEN]; /* simbolic name */
34 char path[PPS_MAX_NAME_LEN]; /* path of connected device */ 39 char path[PPS_MAX_NAME_LEN]; /* path of connected device */
35 int mode; /* PPS's allowed mode */ 40 int mode; /* PPS's allowed mode */
36 41
37 void (*echo)(int source, int event, void *data); /* PPS echo function */ 42 void (*echo)(struct pps_device *pps,
43 int event, void *data); /* PPS echo function */
38 44
39 struct module *owner; 45 struct module *owner;
40 struct device *dev; 46 struct device *dev;
41}; 47};
42 48
49struct pps_event_time {
50#ifdef CONFIG_NTP_PPS
51 struct timespec ts_raw;
52#endif /* CONFIG_NTP_PPS */
53 struct timespec ts_real;
54};
55
43/* The main struct */ 56/* The main struct */
44struct pps_device { 57struct pps_device {
45 struct pps_source_info info; /* PSS source info */ 58 struct pps_source_info info; /* PSS source info */
@@ -52,38 +65,56 @@ struct pps_device {
52 struct pps_ktime clear_tu; 65 struct pps_ktime clear_tu;
53 int current_mode; /* PPS mode at event time */ 66 int current_mode; /* PPS mode at event time */
54 67
55 int go; /* PPS event is arrived? */ 68 unsigned int last_ev; /* last PPS event id */
56 wait_queue_head_t queue; /* PPS event queue */ 69 wait_queue_head_t queue; /* PPS event queue */
57 70
58 unsigned int id; /* PPS source unique ID */ 71 unsigned int id; /* PPS source unique ID */
59 struct cdev cdev; 72 struct cdev cdev;
60 struct device *dev; 73 struct device *dev;
61 int devno;
62 struct fasync_struct *async_queue; /* fasync method */ 74 struct fasync_struct *async_queue; /* fasync method */
63 spinlock_t lock; 75 spinlock_t lock;
64
65 atomic_t usage; /* usage count */
66}; 76};
67 77
68/* 78/*
69 * Global variables 79 * Global variables
70 */ 80 */
71 81
72extern spinlock_t pps_idr_lock;
73extern struct idr pps_idr;
74extern struct timespec pps_irq_ts[];
75
76extern struct device_attribute pps_attrs[]; 82extern struct device_attribute pps_attrs[];
77 83
78/* 84/*
79 * Exported functions 85 * Exported functions
80 */ 86 */
81 87
82struct pps_device *pps_get_source(int source); 88extern struct pps_device *pps_register_source(
83extern void pps_put_source(struct pps_device *pps); 89 struct pps_source_info *info, int default_params);
84extern int pps_register_source(struct pps_source_info *info, 90extern void pps_unregister_source(struct pps_device *pps);
85 int default_params);
86extern void pps_unregister_source(int source);
87extern int pps_register_cdev(struct pps_device *pps); 91extern int pps_register_cdev(struct pps_device *pps);
88extern void pps_unregister_cdev(struct pps_device *pps); 92extern void pps_unregister_cdev(struct pps_device *pps);
89extern void pps_event(int source, struct pps_ktime *ts, int event, void *data); 93extern void pps_event(struct pps_device *pps,
94 struct pps_event_time *ts, int event, void *data);
95
96static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
97 struct timespec ts)
98{
99 kt->sec = ts.tv_sec;
100 kt->nsec = ts.tv_nsec;
101}
102
103#ifdef CONFIG_NTP_PPS
104
105static inline void pps_get_ts(struct pps_event_time *ts)
106{
107 getnstime_raw_and_real(&ts->ts_raw, &ts->ts_real);
108}
109
110#else /* CONFIG_NTP_PPS */
111
112static inline void pps_get_ts(struct pps_event_time *ts)
113{
114 getnstimeofday(&ts->ts_real);
115}
116
117#endif /* CONFIG_NTP_PPS */
118
119#endif /* LINUX_PPS_KERNEL_H */
120
diff --git a/include/linux/prefetch.h b/include/linux/prefetch.h
index af7c36a5a521..a3bfbdf63d32 100644
--- a/include/linux/prefetch.h
+++ b/include/linux/prefetch.h
@@ -29,7 +29,7 @@
29 prefetchw(x) - prefetches the cacheline at "x" for write 29 prefetchw(x) - prefetches the cacheline at "x" for write
30 spin_lock_prefetch(x) - prefetches the spinlock *x for taking 30 spin_lock_prefetch(x) - prefetches the spinlock *x for taking
31 31
32 there is also PREFETCH_STRIDE which is the architecure-prefered 32 there is also PREFETCH_STRIDE which is the architecure-preferred
33 "lookahead" size for prefetching streamed operations. 33 "lookahead" size for prefetching streamed operations.
34 34
35*/ 35*/
diff --git a/include/linux/printk.h b/include/linux/printk.h
new file mode 100644
index 000000000000..0101d55d9651
--- /dev/null
+++ b/include/linux/printk.h
@@ -0,0 +1,309 @@
1#ifndef __KERNEL_PRINTK__
2#define __KERNEL_PRINTK__
3
4#include <linux/init.h>
5
6extern const char linux_banner[];
7extern const char linux_proc_banner[];
8
9#define KERN_EMERG "<0>" /* system is unusable */
10#define KERN_ALERT "<1>" /* action must be taken immediately */
11#define KERN_CRIT "<2>" /* critical conditions */
12#define KERN_ERR "<3>" /* error conditions */
13#define KERN_WARNING "<4>" /* warning conditions */
14#define KERN_NOTICE "<5>" /* normal but significant condition */
15#define KERN_INFO "<6>" /* informational */
16#define KERN_DEBUG "<7>" /* debug-level messages */
17
18/* Use the default kernel loglevel */
19#define KERN_DEFAULT "<d>"
20/*
21 * Annotation for a "continued" line of log printout (only done after a
22 * line that had no enclosing \n). Only to be used by core/arch code
23 * during early bootup (a continued line is not SMP-safe otherwise).
24 */
25#define KERN_CONT "<c>"
26
27extern int console_printk[];
28
29#define console_loglevel (console_printk[0])
30#define default_message_loglevel (console_printk[1])
31#define minimum_console_loglevel (console_printk[2])
32#define default_console_loglevel (console_printk[3])
33
34static inline void console_silent(void)
35{
36 console_loglevel = 0;
37}
38
39static inline void console_verbose(void)
40{
41 if (console_loglevel)
42 console_loglevel = 15;
43}
44
45struct va_format {
46 const char *fmt;
47 va_list *va;
48};
49
50/*
51 * FW_BUG
52 * Add this to a message where you are sure the firmware is buggy or behaves
53 * really stupid or out of spec. Be aware that the responsible BIOS developer
54 * should be able to fix this issue or at least get a concrete idea of the
55 * problem by reading your message without the need of looking at the kernel
56 * code.
57 *
58 * Use it for definite and high priority BIOS bugs.
59 *
60 * FW_WARN
61 * Use it for not that clear (e.g. could the kernel messed up things already?)
62 * and medium priority BIOS bugs.
63 *
64 * FW_INFO
65 * Use this one if you want to tell the user or vendor about something
66 * suspicious, but generally harmless related to the firmware.
67 *
68 * Use it for information or very low priority BIOS bugs.
69 */
70#define FW_BUG "[Firmware Bug]: "
71#define FW_WARN "[Firmware Warn]: "
72#define FW_INFO "[Firmware Info]: "
73
74/*
75 * HW_ERR
76 * Add this to a message for hardware errors, so that user can report
77 * it to hardware vendor instead of LKML or software vendor.
78 */
79#define HW_ERR "[Hardware Error]: "
80
81/*
82 * Dummy printk for disabled debugging statements to use whilst maintaining
83 * gcc's format and side-effect checking.
84 */
85static inline __attribute__ ((format (printf, 1, 2)))
86int no_printk(const char *fmt, ...)
87{
88 return 0;
89}
90
91extern asmlinkage __attribute__ ((format (printf, 1, 2)))
92void early_printk(const char *fmt, ...);
93
94extern int printk_needs_cpu(int cpu);
95extern void printk_tick(void);
96
97#ifdef CONFIG_PRINTK
98asmlinkage __attribute__ ((format (printf, 1, 0)))
99int vprintk(const char *fmt, va_list args);
100asmlinkage __attribute__ ((format (printf, 1, 2))) __cold
101int printk(const char *fmt, ...);
102
103/*
104 * Please don't use printk_ratelimit(), because it shares ratelimiting state
105 * with all other unrelated printk_ratelimit() callsites. Instead use
106 * printk_ratelimited() or plain old __ratelimit().
107 */
108extern int __printk_ratelimit(const char *func);
109#define printk_ratelimit() __printk_ratelimit(__func__)
110extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
111 unsigned int interval_msec);
112
113extern int printk_delay_msec;
114extern int dmesg_restrict;
115extern int kptr_restrict;
116
117void log_buf_kexec_setup(void);
118void __init setup_log_buf(int early);
119#else
120static inline __attribute__ ((format (printf, 1, 0)))
121int vprintk(const char *s, va_list args)
122{
123 return 0;
124}
125static inline __attribute__ ((format (printf, 1, 2))) __cold
126int printk(const char *s, ...)
127{
128 return 0;
129}
130static inline int printk_ratelimit(void)
131{
132 return 0;
133}
134static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
135 unsigned int interval_msec)
136{
137 return false;
138}
139
140static inline void log_buf_kexec_setup(void)
141{
142}
143
144static inline void setup_log_buf(int early)
145{
146}
147#endif
148
149extern void dump_stack(void) __cold;
150
151#ifndef pr_fmt
152#define pr_fmt(fmt) fmt
153#endif
154
155#define pr_emerg(fmt, ...) \
156 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
157#define pr_alert(fmt, ...) \
158 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
159#define pr_crit(fmt, ...) \
160 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
161#define pr_err(fmt, ...) \
162 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
163#define pr_warning(fmt, ...) \
164 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
165#define pr_warn pr_warning
166#define pr_notice(fmt, ...) \
167 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
168#define pr_info(fmt, ...) \
169 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
170#define pr_cont(fmt, ...) \
171 printk(KERN_CONT fmt, ##__VA_ARGS__)
172
173/* pr_devel() should produce zero code unless DEBUG is defined */
174#ifdef DEBUG
175#define pr_devel(fmt, ...) \
176 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
177#else
178#define pr_devel(fmt, ...) \
179 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
180#endif
181
182/* If you are writing a driver, please use dev_dbg instead */
183#if defined(DEBUG)
184#define pr_debug(fmt, ...) \
185 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
186#elif defined(CONFIG_DYNAMIC_DEBUG)
187/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
188#define pr_debug(fmt, ...) \
189 dynamic_pr_debug(fmt, ##__VA_ARGS__)
190#else
191#define pr_debug(fmt, ...) \
192 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
193#endif
194
195/*
196 * Print a one-time message (analogous to WARN_ONCE() et al):
197 */
198
199#ifdef CONFIG_PRINTK
200#define printk_once(fmt, ...) \
201({ \
202 static bool __print_once; \
203 \
204 if (!__print_once) { \
205 __print_once = true; \
206 printk(fmt, ##__VA_ARGS__); \
207 } \
208})
209#else
210#define printk_once(fmt, ...) \
211 no_printk(fmt, ##__VA_ARGS__)
212#endif
213
214#define pr_emerg_once(fmt, ...) \
215 printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
216#define pr_alert_once(fmt, ...) \
217 printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
218#define pr_crit_once(fmt, ...) \
219 printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
220#define pr_err_once(fmt, ...) \
221 printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
222#define pr_warn_once(fmt, ...) \
223 printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
224#define pr_notice_once(fmt, ...) \
225 printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
226#define pr_info_once(fmt, ...) \
227 printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
228#define pr_cont_once(fmt, ...) \
229 printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
230/* If you are writing a driver, please use dev_dbg instead */
231#if defined(DEBUG)
232#define pr_debug_once(fmt, ...) \
233 printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
234#else
235#define pr_debug_once(fmt, ...) \
236 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
237#endif
238
239/*
240 * ratelimited messages with local ratelimit_state,
241 * no local ratelimit_state used in the !PRINTK case
242 */
243#ifdef CONFIG_PRINTK
244#define printk_ratelimited(fmt, ...) \
245({ \
246 static DEFINE_RATELIMIT_STATE(_rs, \
247 DEFAULT_RATELIMIT_INTERVAL, \
248 DEFAULT_RATELIMIT_BURST); \
249 \
250 if (__ratelimit(&_rs)) \
251 printk(fmt, ##__VA_ARGS__); \
252})
253#else
254#define printk_ratelimited(fmt, ...) \
255 no_printk(fmt, ##__VA_ARGS__)
256#endif
257
258#define pr_emerg_ratelimited(fmt, ...) \
259 printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
260#define pr_alert_ratelimited(fmt, ...) \
261 printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
262#define pr_crit_ratelimited(fmt, ...) \
263 printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
264#define pr_err_ratelimited(fmt, ...) \
265 printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
266#define pr_warn_ratelimited(fmt, ...) \
267 printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
268#define pr_notice_ratelimited(fmt, ...) \
269 printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
270#define pr_info_ratelimited(fmt, ...) \
271 printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
272/* no pr_cont_ratelimited, don't do that... */
273/* If you are writing a driver, please use dev_dbg instead */
274#if defined(DEBUG)
275#define pr_debug_ratelimited(fmt, ...) \
276 printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
277#else
278#define pr_debug_ratelimited(fmt, ...) \
279 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
280#endif
281
282enum {
283 DUMP_PREFIX_NONE,
284 DUMP_PREFIX_ADDRESS,
285 DUMP_PREFIX_OFFSET
286};
287extern void hex_dump_to_buffer(const void *buf, size_t len,
288 int rowsize, int groupsize,
289 char *linebuf, size_t linebuflen, bool ascii);
290#ifdef CONFIG_PRINTK
291extern void print_hex_dump(const char *level, const char *prefix_str,
292 int prefix_type, int rowsize, int groupsize,
293 const void *buf, size_t len, bool ascii);
294extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
295 const void *buf, size_t len);
296#else
297static inline void print_hex_dump(const char *level, const char *prefix_str,
298 int prefix_type, int rowsize, int groupsize,
299 const void *buf, size_t len, bool ascii)
300{
301}
302static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
303 const void *buf, size_t len)
304{
305}
306
307#endif
308
309#endif
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 379eaed72d4b..e7576cf9e32d 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -50,7 +50,7 @@ typedef int (write_proc_t)(struct file *file, const char __user *buffer,
50 50
51struct proc_dir_entry { 51struct proc_dir_entry {
52 unsigned int low_ino; 52 unsigned int low_ino;
53 unsigned short namelen; 53 unsigned int namelen;
54 const char *name; 54 const char *name;
55 mode_t mode; 55 mode_t mode;
56 nlink_t nlink; 56 nlink_t nlink;
@@ -173,11 +173,7 @@ extern void proc_net_remove(struct net *net, const char *name);
173extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, 173extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
174 struct proc_dir_entry *parent); 174 struct proc_dir_entry *parent);
175 175
176/* While the {get|set|dup}_mm_exe_file functions are for mm_structs, they are 176extern struct file *proc_ns_fget(int fd);
177 * only needed to implement /proc/<pid>|self/exe so we define them here. */
178extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
179extern struct file *get_mm_exe_file(struct mm_struct *mm);
180extern void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm);
181 177
182#else 178#else
183 179
@@ -208,6 +204,8 @@ static inline struct proc_dir_entry *proc_symlink(const char *name,
208 struct proc_dir_entry *parent,const char *dest) {return NULL;} 204 struct proc_dir_entry *parent,const char *dest) {return NULL;}
209static inline struct proc_dir_entry *proc_mkdir(const char *name, 205static inline struct proc_dir_entry *proc_mkdir(const char *name,
210 struct proc_dir_entry *parent) {return NULL;} 206 struct proc_dir_entry *parent) {return NULL;}
207static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
208 mode_t mode, struct proc_dir_entry *parent) { return NULL; }
211 209
212static inline struct proc_dir_entry *create_proc_read_entry(const char *name, 210static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
213 mode_t mode, struct proc_dir_entry *base, 211 mode_t mode, struct proc_dir_entry *base,
@@ -226,19 +224,11 @@ static inline void pid_ns_release_proc(struct pid_namespace *ns)
226{ 224{
227} 225}
228 226
229static inline void set_mm_exe_file(struct mm_struct *mm, 227static inline struct file *proc_ns_fget(int fd)
230 struct file *new_exe_file)
231{}
232
233static inline struct file *get_mm_exe_file(struct mm_struct *mm)
234{ 228{
235 return NULL; 229 return ERR_PTR(-EINVAL);
236} 230}
237 231
238static inline void dup_mm_exe_file(struct mm_struct *oldmm,
239 struct mm_struct *newmm)
240{}
241
242#endif /* CONFIG_PROC_FS */ 232#endif /* CONFIG_PROC_FS */
243 233
244#if !defined(CONFIG_PROC_KCORE) 234#if !defined(CONFIG_PROC_KCORE)
@@ -250,6 +240,18 @@ kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
250extern void kclist_add(struct kcore_list *, void *, size_t, int type); 240extern void kclist_add(struct kcore_list *, void *, size_t, int type);
251#endif 241#endif
252 242
243struct nsproxy;
244struct proc_ns_operations {
245 const char *name;
246 int type;
247 void *(*get)(struct task_struct *task);
248 void (*put)(void *ns);
249 int (*install)(struct nsproxy *nsproxy, void *ns);
250};
251extern const struct proc_ns_operations netns_operations;
252extern const struct proc_ns_operations utsns_operations;
253extern const struct proc_ns_operations ipcns_operations;
254
253union proc_op { 255union proc_op {
254 int (*proc_get_link)(struct inode *, struct path *); 256 int (*proc_get_link)(struct inode *, struct path *);
255 int (*proc_read)(struct task_struct *task, char *page); 257 int (*proc_read)(struct task_struct *task, char *page);
@@ -268,6 +270,8 @@ struct proc_inode {
268 struct proc_dir_entry *pde; 270 struct proc_dir_entry *pde;
269 struct ctl_table_header *sysctl; 271 struct ctl_table_header *sysctl;
270 struct ctl_table *sysctl_entry; 272 struct ctl_table *sysctl_entry;
273 void *ns;
274 const struct proc_ns_operations *ns_ops;
271 struct inode vfs_inode; 275 struct inode vfs_inode;
272}; 276};
273 277
@@ -286,12 +290,4 @@ static inline struct net *PDE_NET(struct proc_dir_entry *pde)
286 return pde->parent->data; 290 return pde->parent->data;
287} 291}
288 292
289struct proc_maps_private {
290 struct pid *pid;
291 struct task_struct *task;
292#ifdef CONFIG_MMU
293 struct vm_area_struct *tail_vma;
294#endif
295};
296
297#endif /* _LINUX_PROC_FS_H */ 293#endif /* _LINUX_PROC_FS_H */
diff --git a/include/linux/pstore.h b/include/linux/pstore.h
new file mode 100644
index 000000000000..2455ef2683f0
--- /dev/null
+++ b/include/linux/pstore.h
@@ -0,0 +1,62 @@
1/*
2 * Persistent Storage - pstore.h
3 *
4 * Copyright (C) 2010 Intel Corporation <tony.luck@intel.com>
5 *
6 * This code is the generic layer to export data records from platform
7 * level persistent storage via a file system.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#ifndef _LINUX_PSTORE_H
23#define _LINUX_PSTORE_H
24
25/* types */
26enum pstore_type_id {
27 PSTORE_TYPE_DMESG = 0,
28 PSTORE_TYPE_MCE = 1,
29 PSTORE_TYPE_UNKNOWN = 255
30};
31
32struct pstore_info {
33 struct module *owner;
34 char *name;
35 struct mutex buf_mutex; /* serialize access to 'buf' */
36 char *buf;
37 size_t bufsize;
38 int (*open)(struct pstore_info *psi);
39 int (*close)(struct pstore_info *psi);
40 ssize_t (*read)(u64 *id, enum pstore_type_id *type,
41 struct timespec *time);
42 u64 (*write)(enum pstore_type_id type, size_t size);
43 int (*erase)(u64 id);
44};
45
46#ifdef CONFIG_PSTORE
47extern int pstore_register(struct pstore_info *);
48extern int pstore_write(enum pstore_type_id type, char *buf, size_t size);
49#else
50static inline int
51pstore_register(struct pstore_info *psi)
52{
53 return -ENODEV;
54}
55static inline int
56pstore_write(enum pstore_type_id type, char *buf, size_t size)
57{
58 return -ENODEV;
59}
60#endif
61
62#endif /*_LINUX_PSTORE_H*/
diff --git a/include/linux/pti.h b/include/linux/pti.h
new file mode 100644
index 000000000000..81af667bb2d5
--- /dev/null
+++ b/include/linux/pti.h
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) Intel 2011
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 *
15 * The PTI (Parallel Trace Interface) driver directs trace data routed from
16 * various parts in the system out through the Intel Penwell PTI port and
17 * out of the mobile device for analysis with a debugging tool
18 * (Lauterbach, Fido). This is part of a solution for the MIPI P1149.7,
19 * compact JTAG, standard.
20 *
21 * This header file will allow other parts of the OS to use the
22 * interface to write out it's contents for debugging a mobile system.
23 */
24
25#ifndef PTI_H_
26#define PTI_H_
27
28/* offset for last dword of any PTI message. Part of MIPI P1149.7 */
29#define PTI_LASTDWORD_DTS 0x30
30
31/* basic structure used as a write address to the PTI HW */
32struct pti_masterchannel {
33 u8 master;
34 u8 channel;
35};
36
37/* the following functions are defined in misc/pti.c */
38void pti_writedata(struct pti_masterchannel *mc, u8 *buf, int count);
39struct pti_masterchannel *pti_request_masterchannel(u8 type);
40void pti_release_masterchannel(struct pti_masterchannel *mc);
41
42#endif /*PTI_H_*/
diff --git a/include/linux/ptp_classify.h b/include/linux/ptp_classify.h
index 943a85ab0020..e07e2742a865 100644
--- a/include/linux/ptp_classify.h
+++ b/include/linux/ptp_classify.h
@@ -25,6 +25,7 @@
25 25
26#include <linux/if_ether.h> 26#include <linux/if_ether.h>
27#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
28#include <linux/ip.h>
28#include <linux/filter.h> 29#include <linux/filter.h>
29#ifdef __KERNEL__ 30#ifdef __KERNEL__
30#include <linux/in.h> 31#include <linux/in.h>
@@ -58,6 +59,12 @@
58#define OFF_NEXT 6 59#define OFF_NEXT 6
59#define OFF_UDP_DST 2 60#define OFF_UDP_DST 2
60 61
62#define OFF_PTP_SOURCE_UUID 22 /* PTPv1 only */
63#define OFF_PTP_SEQUENCE_ID 30
64#define OFF_PTP_CONTROL 32 /* PTPv1 only */
65
66#define IPV4_HLEN(data) (((struct iphdr *)(data + OFF_IHL))->ihl << 2)
67
61#define IP6_HLEN 40 68#define IP6_HLEN 40
62#define UDP_HLEN 8 69#define UDP_HLEN 8
63 70
diff --git a/include/linux/ptp_clock.h b/include/linux/ptp_clock.h
new file mode 100644
index 000000000000..94e981f810a2
--- /dev/null
+++ b/include/linux/ptp_clock.h
@@ -0,0 +1,84 @@
1/*
2 * PTP 1588 clock support - user space interface
3 *
4 * Copyright (C) 2010 OMICRON electronics GmbH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef _PTP_CLOCK_H_
22#define _PTP_CLOCK_H_
23
24#include <linux/ioctl.h>
25#include <linux/types.h>
26
27/* PTP_xxx bits, for the flags field within the request structures. */
28#define PTP_ENABLE_FEATURE (1<<0)
29#define PTP_RISING_EDGE (1<<1)
30#define PTP_FALLING_EDGE (1<<2)
31
32/*
33 * struct ptp_clock_time - represents a time value
34 *
35 * The sign of the seconds field applies to the whole value. The
36 * nanoseconds field is always unsigned. The reserved field is
37 * included for sub-nanosecond resolution, should the demand for
38 * this ever appear.
39 *
40 */
41struct ptp_clock_time {
42 __s64 sec; /* seconds */
43 __u32 nsec; /* nanoseconds */
44 __u32 reserved;
45};
46
47struct ptp_clock_caps {
48 int max_adj; /* Maximum frequency adjustment in parts per billon. */
49 int n_alarm; /* Number of programmable alarms. */
50 int n_ext_ts; /* Number of external time stamp channels. */
51 int n_per_out; /* Number of programmable periodic signals. */
52 int pps; /* Whether the clock supports a PPS callback. */
53 int rsv[15]; /* Reserved for future use. */
54};
55
56struct ptp_extts_request {
57 unsigned int index; /* Which channel to configure. */
58 unsigned int flags; /* Bit field for PTP_xxx flags. */
59 unsigned int rsv[2]; /* Reserved for future use. */
60};
61
62struct ptp_perout_request {
63 struct ptp_clock_time start; /* Absolute start time. */
64 struct ptp_clock_time period; /* Desired period, zero means disable. */
65 unsigned int index; /* Which channel to configure. */
66 unsigned int flags; /* Reserved for future use. */
67 unsigned int rsv[4]; /* Reserved for future use. */
68};
69
70#define PTP_CLK_MAGIC '='
71
72#define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
73#define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
74#define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
75#define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int)
76
77struct ptp_extts_event {
78 struct ptp_clock_time t; /* Time event occured. */
79 unsigned int index; /* Which channel produced the event. */
80 unsigned int flags; /* Reserved for future use. */
81 unsigned int rsv[2]; /* Reserved for future use. */
82};
83
84#endif
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
new file mode 100644
index 000000000000..dd2e44fba63e
--- /dev/null
+++ b/include/linux/ptp_clock_kernel.h
@@ -0,0 +1,139 @@
1/*
2 * PTP 1588 clock support
3 *
4 * Copyright (C) 2010 OMICRON electronics GmbH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef _PTP_CLOCK_KERNEL_H_
22#define _PTP_CLOCK_KERNEL_H_
23
24#include <linux/ptp_clock.h>
25
26
27struct ptp_clock_request {
28 enum {
29 PTP_CLK_REQ_EXTTS,
30 PTP_CLK_REQ_PEROUT,
31 PTP_CLK_REQ_PPS,
32 } type;
33 union {
34 struct ptp_extts_request extts;
35 struct ptp_perout_request perout;
36 };
37};
38
39/**
40 * struct ptp_clock_info - decribes a PTP hardware clock
41 *
42 * @owner: The clock driver should set to THIS_MODULE.
43 * @name: A short name to identify the clock.
44 * @max_adj: The maximum possible frequency adjustment, in parts per billon.
45 * @n_alarm: The number of programmable alarms.
46 * @n_ext_ts: The number of external time stamp channels.
47 * @n_per_out: The number of programmable periodic signals.
48 * @pps: Indicates whether the clock supports a PPS callback.
49 *
50 * clock operations
51 *
52 * @adjfreq: Adjusts the frequency of the hardware clock.
53 * parameter delta: Desired period change in parts per billion.
54 *
55 * @adjtime: Shifts the time of the hardware clock.
56 * parameter delta: Desired change in nanoseconds.
57 *
58 * @gettime: Reads the current time from the hardware clock.
59 * parameter ts: Holds the result.
60 *
61 * @settime: Set the current time on the hardware clock.
62 * parameter ts: Time value to set.
63 *
64 * @enable: Request driver to enable or disable an ancillary feature.
65 * parameter request: Desired resource to enable or disable.
66 * parameter on: Caller passes one to enable or zero to disable.
67 *
68 * Drivers should embed their ptp_clock_info within a private
69 * structure, obtaining a reference to it using container_of().
70 *
71 * The callbacks must all return zero on success, non-zero otherwise.
72 */
73
74struct ptp_clock_info {
75 struct module *owner;
76 char name[16];
77 s32 max_adj;
78 int n_alarm;
79 int n_ext_ts;
80 int n_per_out;
81 int pps;
82 int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta);
83 int (*adjtime)(struct ptp_clock_info *ptp, s64 delta);
84 int (*gettime)(struct ptp_clock_info *ptp, struct timespec *ts);
85 int (*settime)(struct ptp_clock_info *ptp, const struct timespec *ts);
86 int (*enable)(struct ptp_clock_info *ptp,
87 struct ptp_clock_request *request, int on);
88};
89
90struct ptp_clock;
91
92/**
93 * ptp_clock_register() - register a PTP hardware clock driver
94 *
95 * @info: Structure describing the new clock.
96 */
97
98extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info);
99
100/**
101 * ptp_clock_unregister() - unregister a PTP hardware clock driver
102 *
103 * @ptp: The clock to remove from service.
104 */
105
106extern int ptp_clock_unregister(struct ptp_clock *ptp);
107
108
109enum ptp_clock_events {
110 PTP_CLOCK_ALARM,
111 PTP_CLOCK_EXTTS,
112 PTP_CLOCK_PPS,
113};
114
115/**
116 * struct ptp_clock_event - decribes a PTP hardware clock event
117 *
118 * @type: One of the ptp_clock_events enumeration values.
119 * @index: Identifies the source of the event.
120 * @timestamp: When the event occured.
121 */
122
123struct ptp_clock_event {
124 int type;
125 int index;
126 u64 timestamp;
127};
128
129/**
130 * ptp_clock_event() - notify the PTP layer about an event
131 *
132 * @ptp: The clock obtained from ptp_clock_register().
133 * @event: Message structure describing the event.
134 */
135
136extern void ptp_clock_event(struct ptp_clock *ptp,
137 struct ptp_clock_event *event);
138
139#endif
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 4272521e29e9..9178d5cc0b01 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -100,15 +100,14 @@
100#include <linux/sched.h> /* For struct task_struct. */ 100#include <linux/sched.h> /* For struct task_struct. */
101 101
102 102
103extern long arch_ptrace(struct task_struct *child, long request, long addr, long data); 103extern long arch_ptrace(struct task_struct *child, long request,
104extern int ptrace_traceme(void); 104 unsigned long addr, unsigned long data);
105extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len); 105extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
106extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len); 106extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
107extern int ptrace_attach(struct task_struct *tsk);
108extern int ptrace_detach(struct task_struct *, unsigned int);
109extern void ptrace_disable(struct task_struct *); 107extern void ptrace_disable(struct task_struct *);
110extern int ptrace_check_attach(struct task_struct *task, int kill); 108extern int ptrace_check_attach(struct task_struct *task, int kill);
111extern int ptrace_request(struct task_struct *child, long request, long addr, long data); 109extern int ptrace_request(struct task_struct *child, long request,
110 unsigned long addr, unsigned long data);
112extern void ptrace_notify(int exit_code); 111extern void ptrace_notify(int exit_code);
113extern void __ptrace_link(struct task_struct *child, 112extern void __ptrace_link(struct task_struct *child,
114 struct task_struct *new_parent); 113 struct task_struct *new_parent);
@@ -132,8 +131,10 @@ static inline void ptrace_unlink(struct task_struct *child)
132 __ptrace_unlink(child); 131 __ptrace_unlink(child);
133} 132}
134 133
135int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data); 134int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
136int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data); 135 unsigned long data);
136int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
137 unsigned long data);
137 138
138/** 139/**
139 * task_ptrace - return %PT_* flags that apply to a task 140 * task_ptrace - return %PT_* flags that apply to a task
@@ -188,6 +189,10 @@ static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
188 child->ptrace = current->ptrace; 189 child->ptrace = current->ptrace;
189 __ptrace_link(child, current->parent); 190 __ptrace_link(child, current->parent);
190 } 191 }
192
193#ifdef CONFIG_HAVE_HW_BREAKPOINT
194 atomic_set(&child->ptrace_bp_refcnt, 1);
195#endif
191} 196}
192 197
193/** 198/**
@@ -349,6 +354,13 @@ extern int task_current_syscall(struct task_struct *target, long *callno,
349 unsigned long args[6], unsigned int maxargs, 354 unsigned long args[6], unsigned int maxargs,
350 unsigned long *sp, unsigned long *pc); 355 unsigned long *sp, unsigned long *pc);
351 356
352#endif 357#ifdef CONFIG_HAVE_HW_BREAKPOINT
358extern int ptrace_get_breakpoints(struct task_struct *tsk);
359extern void ptrace_put_breakpoints(struct task_struct *tsk);
360#else
361static inline void ptrace_put_breakpoints(struct task_struct *tsk) { }
362#endif /* CONFIG_HAVE_HW_BREAKPOINT */
363
364#endif /* __KERNEL */
353 365
354#endif 366#endif
diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h
index 01b3d759f1fc..5e3e25a3c9c3 100644
--- a/include/linux/pwm_backlight.h
+++ b/include/linux/pwm_backlight.h
@@ -4,14 +4,18 @@
4#ifndef __LINUX_PWM_BACKLIGHT_H 4#ifndef __LINUX_PWM_BACKLIGHT_H
5#define __LINUX_PWM_BACKLIGHT_H 5#define __LINUX_PWM_BACKLIGHT_H
6 6
7#include <linux/backlight.h>
8
7struct platform_pwm_backlight_data { 9struct platform_pwm_backlight_data {
8 int pwm_id; 10 int pwm_id;
9 unsigned int max_brightness; 11 unsigned int max_brightness;
10 unsigned int dft_brightness; 12 unsigned int dft_brightness;
13 unsigned int lth_brightness;
11 unsigned int pwm_period_ns; 14 unsigned int pwm_period_ns;
12 int (*init)(struct device *dev); 15 int (*init)(struct device *dev);
13 int (*notify)(struct device *dev, int brightness); 16 int (*notify)(struct device *dev, int brightness);
14 void (*exit)(struct device *dev); 17 void (*exit)(struct device *dev);
18 int (*check_fb)(struct device *dev, struct fb_info *info);
15}; 19};
16 20
17#endif 21#endif
diff --git a/include/linux/pxa2xx_ssp.h b/include/linux/pxa2xx_ssp.h
new file mode 100644
index 000000000000..44835fb39793
--- /dev/null
+++ b/include/linux/pxa2xx_ssp.h
@@ -0,0 +1,209 @@
1/*
2 * pxa2xx_ssp.h
3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This driver supports the following PXA CPU/SSP ports:-
11 *
12 * PXA250 SSP
13 * PXA255 SSP, NSSP
14 * PXA26x SSP, NSSP, ASSP
15 * PXA27x SSP1, SSP2, SSP3
16 * PXA3xx SSP1, SSP2, SSP3, SSP4
17 */
18
19#ifndef __LINUX_SSP_H
20#define __LINUX_SSP_H
21
22#include <linux/list.h>
23#include <linux/io.h>
24
25/*
26 * SSP Serial Port Registers
27 * PXA250, PXA255, PXA26x and PXA27x SSP controllers are all slightly different.
28 * PXA255, PXA26x and PXA27x have extra ports, registers and bits.
29 */
30
31#define SSCR0 (0x00) /* SSP Control Register 0 */
32#define SSCR1 (0x04) /* SSP Control Register 1 */
33#define SSSR (0x08) /* SSP Status Register */
34#define SSITR (0x0C) /* SSP Interrupt Test Register */
35#define SSDR (0x10) /* SSP Data Write/Data Read Register */
36
37#define SSTO (0x28) /* SSP Time Out Register */
38#define SSPSP (0x2C) /* SSP Programmable Serial Protocol */
39#define SSTSA (0x30) /* SSP Tx Timeslot Active */
40#define SSRSA (0x34) /* SSP Rx Timeslot Active */
41#define SSTSS (0x38) /* SSP Timeslot Status */
42#define SSACD (0x3C) /* SSP Audio Clock Divider */
43#define SSACDD (0x40) /* SSP Audio Clock Dither Divider */
44
45/* Common PXA2xx bits first */
46#define SSCR0_DSS (0x0000000f) /* Data Size Select (mask) */
47#define SSCR0_DataSize(x) ((x) - 1) /* Data Size Select [4..16] */
48#define SSCR0_FRF (0x00000030) /* FRame Format (mask) */
49#define SSCR0_Motorola (0x0 << 4) /* Motorola's Serial Peripheral Interface (SPI) */
50#define SSCR0_TI (0x1 << 4) /* Texas Instruments' Synchronous Serial Protocol (SSP) */
51#define SSCR0_National (0x2 << 4) /* National Microwire */
52#define SSCR0_ECS (1 << 6) /* External clock select */
53#define SSCR0_SSE (1 << 7) /* Synchronous Serial Port Enable */
54#define SSCR0_SCR(x) ((x) << 8) /* Serial Clock Rate (mask) */
55
56/* PXA27x, PXA3xx */
57#define SSCR0_EDSS (1 << 20) /* Extended data size select */
58#define SSCR0_NCS (1 << 21) /* Network clock select */
59#define SSCR0_RIM (1 << 22) /* Receive FIFO overrrun interrupt mask */
60#define SSCR0_TUM (1 << 23) /* Transmit FIFO underrun interrupt mask */
61#define SSCR0_FRDC (0x07000000) /* Frame rate divider control (mask) */
62#define SSCR0_SlotsPerFrm(x) (((x) - 1) << 24) /* Time slots per frame [1..8] */
63#define SSCR0_FPCKE (1 << 29) /* FIFO packing enable */
64#define SSCR0_ACS (1 << 30) /* Audio clock select */
65#define SSCR0_MOD (1 << 31) /* Mode (normal or network) */
66
67
68#define SSCR1_RIE (1 << 0) /* Receive FIFO Interrupt Enable */
69#define SSCR1_TIE (1 << 1) /* Transmit FIFO Interrupt Enable */
70#define SSCR1_LBM (1 << 2) /* Loop-Back Mode */
71#define SSCR1_SPO (1 << 3) /* Motorola SPI SSPSCLK polarity setting */
72#define SSCR1_SPH (1 << 4) /* Motorola SPI SSPSCLK phase setting */
73#define SSCR1_MWDS (1 << 5) /* Microwire Transmit Data Size */
74
75#define SSSR_ALT_FRM_MASK 3 /* Masks the SFRM signal number */
76#define SSSR_TNF (1 << 2) /* Transmit FIFO Not Full */
77#define SSSR_RNE (1 << 3) /* Receive FIFO Not Empty */
78#define SSSR_BSY (1 << 4) /* SSP Busy */
79#define SSSR_TFS (1 << 5) /* Transmit FIFO Service Request */
80#define SSSR_RFS (1 << 6) /* Receive FIFO Service Request */
81#define SSSR_ROR (1 << 7) /* Receive FIFO Overrun */
82
83#ifdef CONFIG_ARCH_PXA
84#define RX_THRESH_DFLT 8
85#define TX_THRESH_DFLT 8
86
87#define SSSR_TFL_MASK (0xf << 8) /* Transmit FIFO Level mask */
88#define SSSR_RFL_MASK (0xf << 12) /* Receive FIFO Level mask */
89
90#define SSCR1_TFT (0x000003c0) /* Transmit FIFO Threshold (mask) */
91#define SSCR1_TxTresh(x) (((x) - 1) << 6) /* level [1..16] */
92#define SSCR1_RFT (0x00003c00) /* Receive FIFO Threshold (mask) */
93#define SSCR1_RxTresh(x) (((x) - 1) << 10) /* level [1..16] */
94
95#else
96
97#define RX_THRESH_DFLT 2
98#define TX_THRESH_DFLT 2
99
100#define SSSR_TFL_MASK (0x3 << 8) /* Transmit FIFO Level mask */
101#define SSSR_RFL_MASK (0x3 << 12) /* Receive FIFO Level mask */
102
103#define SSCR1_TFT (0x000000c0) /* Transmit FIFO Threshold (mask) */
104#define SSCR1_TxTresh(x) (((x) - 1) << 6) /* level [1..4] */
105#define SSCR1_RFT (0x00000c00) /* Receive FIFO Threshold (mask) */
106#define SSCR1_RxTresh(x) (((x) - 1) << 10) /* level [1..4] */
107#endif
108
109/* extra bits in PXA255, PXA26x and PXA27x SSP ports */
110#define SSCR0_TISSP (1 << 4) /* TI Sync Serial Protocol */
111#define SSCR0_PSP (3 << 4) /* PSP - Programmable Serial Protocol */
112#define SSCR1_TTELP (1 << 31) /* TXD Tristate Enable Last Phase */
113#define SSCR1_TTE (1 << 30) /* TXD Tristate Enable */
114#define SSCR1_EBCEI (1 << 29) /* Enable Bit Count Error interrupt */
115#define SSCR1_SCFR (1 << 28) /* Slave Clock free Running */
116#define SSCR1_ECRA (1 << 27) /* Enable Clock Request A */
117#define SSCR1_ECRB (1 << 26) /* Enable Clock request B */
118#define SSCR1_SCLKDIR (1 << 25) /* Serial Bit Rate Clock Direction */
119#define SSCR1_SFRMDIR (1 << 24) /* Frame Direction */
120#define SSCR1_RWOT (1 << 23) /* Receive Without Transmit */
121#define SSCR1_TRAIL (1 << 22) /* Trailing Byte */
122#define SSCR1_TSRE (1 << 21) /* Transmit Service Request Enable */
123#define SSCR1_RSRE (1 << 20) /* Receive Service Request Enable */
124#define SSCR1_TINTE (1 << 19) /* Receiver Time-out Interrupt enable */
125#define SSCR1_PINTE (1 << 18) /* Peripheral Trailing Byte Interrupt Enable */
126#define SSCR1_IFS (1 << 16) /* Invert Frame Signal */
127#define SSCR1_STRF (1 << 15) /* Select FIFO or EFWR */
128#define SSCR1_EFWR (1 << 14) /* Enable FIFO Write/Read */
129
130#define SSSR_BCE (1 << 23) /* Bit Count Error */
131#define SSSR_CSS (1 << 22) /* Clock Synchronisation Status */
132#define SSSR_TUR (1 << 21) /* Transmit FIFO Under Run */
133#define SSSR_EOC (1 << 20) /* End Of Chain */
134#define SSSR_TINT (1 << 19) /* Receiver Time-out Interrupt */
135#define SSSR_PINT (1 << 18) /* Peripheral Trailing Byte Interrupt */
136
137
138#define SSPSP_SCMODE(x) ((x) << 0) /* Serial Bit Rate Clock Mode */
139#define SSPSP_SFRMP (1 << 2) /* Serial Frame Polarity */
140#define SSPSP_ETDS (1 << 3) /* End of Transfer data State */
141#define SSPSP_STRTDLY(x) ((x) << 4) /* Start Delay */
142#define SSPSP_DMYSTRT(x) ((x) << 7) /* Dummy Start */
143#define SSPSP_SFRMDLY(x) ((x) << 9) /* Serial Frame Delay */
144#define SSPSP_SFRMWDTH(x) ((x) << 16) /* Serial Frame Width */
145#define SSPSP_DMYSTOP(x) ((x) << 23) /* Dummy Stop */
146#define SSPSP_FSRT (1 << 25) /* Frame Sync Relative Timing */
147
148/* PXA3xx */
149#define SSPSP_EDMYSTRT(x) ((x) << 26) /* Extended Dummy Start */
150#define SSPSP_EDMYSTOP(x) ((x) << 28) /* Extended Dummy Stop */
151#define SSPSP_TIMING_MASK (0x7f8001f0)
152
153#define SSACD_SCDB (1 << 3) /* SSPSYSCLK Divider Bypass */
154#define SSACD_ACPS(x) ((x) << 4) /* Audio clock PLL select */
155#define SSACD_ACDS(x) ((x) << 0) /* Audio clock divider select */
156#define SSACD_SCDX8 (1 << 7) /* SYSCLK division ratio select */
157
158enum pxa_ssp_type {
159 SSP_UNDEFINED = 0,
160 PXA25x_SSP, /* pxa 210, 250, 255, 26x */
161 PXA25x_NSSP, /* pxa 255, 26x (including ASSP) */
162 PXA27x_SSP,
163 PXA168_SSP,
164 CE4100_SSP,
165};
166
167struct ssp_device {
168 struct platform_device *pdev;
169 struct list_head node;
170
171 struct clk *clk;
172 void __iomem *mmio_base;
173 unsigned long phys_base;
174
175 const char *label;
176 int port_id;
177 int type;
178 int use_count;
179 int irq;
180 int drcmr_rx;
181 int drcmr_tx;
182};
183
184/**
185 * pxa_ssp_write_reg - Write to a SSP register
186 *
187 * @dev: SSP device to access
188 * @reg: Register to write to
189 * @val: Value to be written.
190 */
191static inline void pxa_ssp_write_reg(struct ssp_device *dev, u32 reg, u32 val)
192{
193 __raw_writel(val, dev->mmio_base + reg);
194}
195
196/**
197 * pxa_ssp_read_reg - Read from a SSP register
198 *
199 * @dev: SSP device to access
200 * @reg: Register to read from
201 */
202static inline u32 pxa_ssp_read_reg(struct ssp_device *dev, u32 reg)
203{
204 return __raw_readl(dev->mmio_base + reg);
205}
206
207struct ssp_device *pxa_ssp_request(int port, const char *label);
208void pxa_ssp_free(struct ssp_device *);
209#endif
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 94c1f03b50eb..9a85412e0db6 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -322,9 +322,12 @@ struct dquot_operations {
322 qsize_t *(*get_reserved_space) (struct inode *); 322 qsize_t *(*get_reserved_space) (struct inode *);
323}; 323};
324 324
325struct path;
326
325/* Operations handling requests from userspace */ 327/* Operations handling requests from userspace */
326struct quotactl_ops { 328struct quotactl_ops {
327 int (*quota_on)(struct super_block *, int, int, char *); 329 int (*quota_on)(struct super_block *, int, int, struct path *);
330 int (*quota_on_meta)(struct super_block *, int, int);
328 int (*quota_off)(struct super_block *, int); 331 int (*quota_off)(struct super_block *, int);
329 int (*quota_sync)(struct super_block *, int, int); 332 int (*quota_sync)(struct super_block *, int, int);
330 int (*get_info)(struct super_block *, int, struct if_dqinfo *); 333 int (*get_info)(struct super_block *, int, struct if_dqinfo *);
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index d1a9193960f1..26f9e3612e0f 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -31,8 +31,9 @@ static inline bool is_quota_modification(struct inode *inode, struct iattr *ia)
31#define quota_error(sb, fmt, args...) \ 31#define quota_error(sb, fmt, args...) \
32 __quota_error((sb), __func__, fmt , ## args) 32 __quota_error((sb), __func__, fmt , ## args)
33 33
34extern void __quota_error(struct super_block *sb, const char *func, 34extern __attribute__((format (printf, 3, 4)))
35 const char *fmt, ...); 35void __quota_error(struct super_block *sb, const char *func,
36 const char *fmt, ...);
36 37
37/* 38/*
38 * declaration of quota_function calls in kernel. 39 * declaration of quota_function calls in kernel.
@@ -75,11 +76,9 @@ int dquot_mark_dquot_dirty(struct dquot *dquot);
75 76
76int dquot_file_open(struct inode *inode, struct file *file); 77int dquot_file_open(struct inode *inode, struct file *file);
77 78
78int dquot_quota_on(struct super_block *sb, int type, int format_id,
79 char *path);
80int dquot_enable(struct inode *inode, int type, int format_id, 79int dquot_enable(struct inode *inode, int type, int format_id,
81 unsigned int flags); 80 unsigned int flags);
82int dquot_quota_on_path(struct super_block *sb, int type, int format_id, 81int dquot_quota_on(struct super_block *sb, int type, int format_id,
83 struct path *path); 82 struct path *path);
84int dquot_quota_on_mount(struct super_block *sb, char *qf_name, 83int dquot_quota_on_mount(struct super_block *sb, char *qf_name,
85 int format_id, int type); 84 int format_id, int type);
@@ -278,7 +277,7 @@ static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
278 /* 277 /*
279 * Mark inode fully dirty. Since we are allocating blocks, inode 278 * Mark inode fully dirty. Since we are allocating blocks, inode
280 * would become fully dirty soon anyway and it reportedly 279 * would become fully dirty soon anyway and it reportedly
281 * reduces inode_lock contention. 280 * reduces lock contention.
282 */ 281 */
283 mark_inode_dirty(inode); 282 mark_inode_dirty(inode);
284 } 283 }
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 634b8e674ac5..23241c2fecce 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -34,19 +34,15 @@
34 * needed for RCU lookups (because root->height is unreliable). The only 34 * needed for RCU lookups (because root->height is unreliable). The only
35 * time callers need worry about this is when doing a lookup_slot under 35 * time callers need worry about this is when doing a lookup_slot under
36 * RCU. 36 * RCU.
37 *
38 * Indirect pointer in fact is also used to tag the last pointer of a node
39 * when it is shrunk, before we rcu free the node. See shrink code for
40 * details.
37 */ 41 */
38#define RADIX_TREE_INDIRECT_PTR 1 42#define RADIX_TREE_INDIRECT_PTR 1
39#define RADIX_TREE_RETRY ((void *)-1UL)
40
41static inline void *radix_tree_ptr_to_indirect(void *ptr)
42{
43 return (void *)((unsigned long)ptr | RADIX_TREE_INDIRECT_PTR);
44}
45 43
46static inline void *radix_tree_indirect_to_ptr(void *ptr) 44#define radix_tree_indirect_to_ptr(ptr) \
47{ 45 radix_tree_indirect_to_ptr((void __force *)(ptr))
48 return (void *)((unsigned long)ptr & ~RADIX_TREE_INDIRECT_PTR);
49}
50 46
51static inline int radix_tree_is_indirect_ptr(void *ptr) 47static inline int radix_tree_is_indirect_ptr(void *ptr)
52{ 48{
@@ -61,7 +57,7 @@ static inline int radix_tree_is_indirect_ptr(void *ptr)
61struct radix_tree_root { 57struct radix_tree_root {
62 unsigned int height; 58 unsigned int height;
63 gfp_t gfp_mask; 59 gfp_t gfp_mask;
64 struct radix_tree_node *rnode; 60 struct radix_tree_node __rcu *rnode;
65}; 61};
66 62
67#define RADIX_TREE_INIT(mask) { \ 63#define RADIX_TREE_INIT(mask) { \
@@ -138,16 +134,45 @@ do { \
138 * removed. 134 * removed.
139 * 135 *
140 * For use with radix_tree_lookup_slot(). Caller must hold tree at least read 136 * For use with radix_tree_lookup_slot(). Caller must hold tree at least read
141 * locked across slot lookup and dereference. More likely, will be used with 137 * locked across slot lookup and dereference. Not required if write lock is
142 * radix_tree_replace_slot(), as well, so caller will hold tree write locked. 138 * held (ie. items cannot be concurrently inserted).
139 *
140 * radix_tree_deref_retry must be used to confirm validity of the pointer if
141 * only the read lock is held.
143 */ 142 */
144static inline void *radix_tree_deref_slot(void **pslot) 143static inline void *radix_tree_deref_slot(void **pslot)
145{ 144{
146 void *ret = rcu_dereference(*pslot); 145 return rcu_dereference(*pslot);
147 if (unlikely(radix_tree_is_indirect_ptr(ret)))
148 ret = RADIX_TREE_RETRY;
149 return ret;
150} 146}
147
148/**
149 * radix_tree_deref_slot_protected - dereference a slot without RCU lock but with tree lock held
150 * @pslot: pointer to slot, returned by radix_tree_lookup_slot
151 * Returns: item that was stored in that slot with any direct pointer flag
152 * removed.
153 *
154 * Similar to radix_tree_deref_slot but only used during migration when a pages
155 * mapping is being moved. The caller does not hold the RCU read lock but it
156 * must hold the tree lock to prevent parallel updates.
157 */
158static inline void *radix_tree_deref_slot_protected(void **pslot,
159 spinlock_t *treelock)
160{
161 return rcu_dereference_protected(*pslot, lockdep_is_held(treelock));
162}
163
164/**
165 * radix_tree_deref_retry - check radix_tree_deref_slot
166 * @arg: pointer returned by radix_tree_deref_slot
167 * Returns: 0 if retry is not required, otherwise retry is required
168 *
169 * radix_tree_deref_retry must be used with radix_tree_deref_slot.
170 */
171static inline int radix_tree_deref_retry(void *arg)
172{
173 return unlikely((unsigned long)arg & RADIX_TREE_INDIRECT_PTR);
174}
175
151/** 176/**
152 * radix_tree_replace_slot - replace item in a slot 177 * radix_tree_replace_slot - replace item in a slot
153 * @pslot: pointer to slot, returned by radix_tree_lookup_slot 178 * @pslot: pointer to slot, returned by radix_tree_lookup_slot
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
index ffa2efbbe382..75cbf4f62fe8 100644
--- a/include/linux/raid/md_p.h
+++ b/include/linux/raid/md_p.h
@@ -251,7 +251,7 @@ struct mdp_superblock_1 {
251 __le64 utime; /* 40 bits second, 24 btes microseconds */ 251 __le64 utime; /* 40 bits second, 24 btes microseconds */
252 __le64 events; /* incremented when superblock updated */ 252 __le64 events; /* incremented when superblock updated */
253 __le64 resync_offset; /* data before this offset (from data_offset) known to be in sync */ 253 __le64 resync_offset; /* data before this offset (from data_offset) known to be in sync */
254 __le32 sb_csum; /* checksum upto devs[max_dev] */ 254 __le32 sb_csum; /* checksum up to devs[max_dev] */
255 __le32 max_dev; /* size of devs[] array to consider */ 255 __le32 max_dev; /* size of devs[] array to consider */
256 __u8 pad3[64-32]; /* set to 0 when writing */ 256 __u8 pad3[64-32]; /* set to 0 when writing */
257 257
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h
index e7320b5e82fb..3a8f0c9b2933 100644
--- a/include/linux/ramfs.h
+++ b/include/linux/ramfs.h
@@ -3,8 +3,8 @@
3 3
4struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir, 4struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir,
5 int mode, dev_t dev); 5 int mode, dev_t dev);
6extern int ramfs_get_sb(struct file_system_type *fs_type, 6extern struct dentry *ramfs_mount(struct file_system_type *fs_type,
7 int flags, const char *dev_name, void *data, struct vfsmount *mnt); 7 int flags, const char *dev_name, void *data);
8 8
9#ifndef CONFIG_MMU 9#ifndef CONFIG_MMU
10extern int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize); 10extern int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize);
diff --git a/include/linux/ramoops.h b/include/linux/ramoops.h
new file mode 100644
index 000000000000..0ae68a2c1212
--- /dev/null
+++ b/include/linux/ramoops.h
@@ -0,0 +1,15 @@
1#ifndef __RAMOOPS_H
2#define __RAMOOPS_H
3
4/*
5 * Ramoops platform data
6 * @mem_size memory size for ramoops
7 * @mem_address physical memory address to contain ramoops
8 */
9
10struct ramoops_platform_data {
11 unsigned long mem_size;
12 unsigned long mem_address;
13};
14
15#endif
diff --git a/include/linux/rar_register.h b/include/linux/rar_register.h
index ffa805780f85..5c6118189363 100644
--- a/include/linux/rar_register.h
+++ b/include/linux/rar_register.h
@@ -34,11 +34,27 @@
34 34
35struct rar_device; 35struct rar_device;
36 36
37#if defined(CONFIG_RAR_REGISTER)
37int register_rar(int num, 38int register_rar(int num,
38 int (*callback)(unsigned long data), unsigned long data); 39 int (*callback)(unsigned long data), unsigned long data);
39void unregister_rar(int num); 40void unregister_rar(int num);
40int rar_get_address(int rar_index, dma_addr_t *start, dma_addr_t *end); 41int rar_get_address(int rar_index, dma_addr_t *start, dma_addr_t *end);
41int rar_lock(int rar_index); 42int rar_lock(int rar_index);
43#else
44extern void unregister_rar(int num) { }
45extern int rar_lock(int rar_index) { return -EIO; }
46
47extern inline int register_rar(int num,
48 int (*callback)(unsigned long data), unsigned long data)
49{
50 return -ENODEV;
51}
52
53extern int rar_get_address(int rar_index, dma_addr_t *start, dma_addr_t *end)
54{
55 return -ENODEV;
56}
57#endif /* RAR_REGISTER */
42 58
43#endif /* __KERNEL__ */ 59#endif /* __KERNEL__ */
44#endif /* _RAR_REGISTER_H */ 60#endif /* _RAR_REGISTER_H */
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h
index 8f69d09a41a5..2f007157fab9 100644
--- a/include/linux/ratelimit.h
+++ b/include/linux/ratelimit.h
@@ -36,7 +36,49 @@ static inline void ratelimit_state_init(struct ratelimit_state *rs,
36 rs->begin = 0; 36 rs->begin = 0;
37} 37}
38 38
39extern struct ratelimit_state printk_ratelimit_state;
40
39extern int ___ratelimit(struct ratelimit_state *rs, const char *func); 41extern int ___ratelimit(struct ratelimit_state *rs, const char *func);
40#define __ratelimit(state) ___ratelimit(state, __func__) 42#define __ratelimit(state) ___ratelimit(state, __func__)
41 43
44#ifdef CONFIG_PRINTK
45
46#define WARN_ON_RATELIMIT(condition, state) \
47 WARN_ON((condition) && __ratelimit(state))
48
49#define __WARN_RATELIMIT(condition, state, format...) \
50({ \
51 int rtn = 0; \
52 if (unlikely(__ratelimit(state))) \
53 rtn = WARN(condition, format); \
54 rtn; \
55})
56
57#define WARN_RATELIMIT(condition, format...) \
58({ \
59 static DEFINE_RATELIMIT_STATE(_rs, \
60 DEFAULT_RATELIMIT_INTERVAL, \
61 DEFAULT_RATELIMIT_BURST); \
62 __WARN_RATELIMIT(condition, &_rs, format); \
63})
64
65#else
66
67#define WARN_ON_RATELIMIT(condition, state) \
68 WARN_ON(condition)
69
70#define __WARN_RATELIMIT(condition, state, format...) \
71({ \
72 int rtn = WARN(condition, format); \
73 rtn; \
74})
75
76#define WARN_RATELIMIT(condition, format...) \
77({ \
78 int rtn = WARN(condition, format); \
79 rtn; \
80})
81
82#endif
83
42#endif /* _LINUX_RATELIMIT_H */ 84#endif /* _LINUX_RATELIMIT_H */
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 7066acb2c530..033b507b33b1 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -136,6 +136,14 @@ static inline void rb_set_color(struct rb_node *rb, int color)
136#define RB_EMPTY_NODE(node) (rb_parent(node) == node) 136#define RB_EMPTY_NODE(node) (rb_parent(node) == node)
137#define RB_CLEAR_NODE(node) (rb_set_parent(node, node)) 137#define RB_CLEAR_NODE(node) (rb_set_parent(node, node))
138 138
139static inline void rb_init_node(struct rb_node *rb)
140{
141 rb->rb_parent_color = 0;
142 rb->rb_right = NULL;
143 rb->rb_left = NULL;
144 RB_CLEAR_NODE(rb);
145}
146
139extern void rb_insert_color(struct rb_node *, struct rb_root *); 147extern void rb_insert_color(struct rb_node *, struct rb_root *);
140extern void rb_erase(struct rb_node *, struct rb_root *); 148extern void rb_erase(struct rb_node *, struct rb_root *);
141 149
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 4ec3b38ce9c5..e3beb315517a 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -10,6 +10,21 @@
10#include <linux/rcupdate.h> 10#include <linux/rcupdate.h>
11 11
12/* 12/*
13 * Why is there no list_empty_rcu()? Because list_empty() serves this
14 * purpose. The list_empty() function fetches the RCU-protected pointer
15 * and compares it to the address of the list head, but neither dereferences
16 * this pointer itself nor provides this pointer to the caller. Therefore,
17 * it is not necessary to use rcu_dereference(), so that list_empty() can
18 * be used anywhere you would want to use a list_empty_rcu().
19 */
20
21/*
22 * return the ->next pointer of a list_head in an rcu safe
23 * way, we must not access it directly
24 */
25#define list_next_rcu(list) (*((struct list_head __rcu **)(&(list)->next)))
26
27/*
13 * Insert a new entry between two known consecutive entries. 28 * Insert a new entry between two known consecutive entries.
14 * 29 *
15 * This is only for internal list manipulation where we know 30 * This is only for internal list manipulation where we know
@@ -20,7 +35,7 @@ static inline void __list_add_rcu(struct list_head *new,
20{ 35{
21 new->next = next; 36 new->next = next;
22 new->prev = prev; 37 new->prev = prev;
23 rcu_assign_pointer(prev->next, new); 38 rcu_assign_pointer(list_next_rcu(prev), new);
24 next->prev = new; 39 next->prev = new;
25} 40}
26 41
@@ -138,7 +153,7 @@ static inline void list_replace_rcu(struct list_head *old,
138{ 153{
139 new->next = old->next; 154 new->next = old->next;
140 new->prev = old->prev; 155 new->prev = old->prev;
141 rcu_assign_pointer(new->prev->next, new); 156 rcu_assign_pointer(list_next_rcu(new->prev), new);
142 new->next->prev = new; 157 new->next->prev = new;
143 old->prev = LIST_POISON2; 158 old->prev = LIST_POISON2;
144} 159}
@@ -193,7 +208,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
193 */ 208 */
194 209
195 last->next = at; 210 last->next = at;
196 rcu_assign_pointer(head->next, first); 211 rcu_assign_pointer(list_next_rcu(head), first);
197 first->prev = head; 212 first->prev = head;
198 at->prev = last; 213 at->prev = last;
199} 214}
@@ -208,7 +223,9 @@ static inline void list_splice_init_rcu(struct list_head *list,
208 * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock(). 223 * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
209 */ 224 */
210#define list_entry_rcu(ptr, type, member) \ 225#define list_entry_rcu(ptr, type, member) \
211 container_of(rcu_dereference_raw(ptr), type, member) 226 ({typeof (*ptr) __rcu *__ptr = (typeof (*ptr) __rcu __force *)ptr; \
227 container_of((typeof(ptr))rcu_dereference_raw(__ptr), type, member); \
228 })
212 229
213/** 230/**
214 * list_first_entry_rcu - get the first element from a list 231 * list_first_entry_rcu - get the first element from a list
@@ -224,11 +241,6 @@ static inline void list_splice_init_rcu(struct list_head *list,
224#define list_first_entry_rcu(ptr, type, member) \ 241#define list_first_entry_rcu(ptr, type, member) \
225 list_entry_rcu((ptr)->next, type, member) 242 list_entry_rcu((ptr)->next, type, member)
226 243
227#define __list_for_each_rcu(pos, head) \
228 for (pos = rcu_dereference_raw((head)->next); \
229 pos != (head); \
230 pos = rcu_dereference_raw(pos->next))
231
232/** 244/**
233 * list_for_each_entry_rcu - iterate over rcu list of given type 245 * list_for_each_entry_rcu - iterate over rcu list of given type
234 * @pos: the type * to use as a loop cursor. 246 * @pos: the type * to use as a loop cursor.
@@ -241,7 +253,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
241 */ 253 */
242#define list_for_each_entry_rcu(pos, head, member) \ 254#define list_for_each_entry_rcu(pos, head, member) \
243 for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ 255 for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \
244 prefetch(pos->member.next), &pos->member != (head); \ 256 &pos->member != (head); \
245 pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) 257 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
246 258
247 259
@@ -257,9 +269,9 @@ static inline void list_splice_init_rcu(struct list_head *list,
257 * as long as the traversal is guarded by rcu_read_lock(). 269 * as long as the traversal is guarded by rcu_read_lock().
258 */ 270 */
259#define list_for_each_continue_rcu(pos, head) \ 271#define list_for_each_continue_rcu(pos, head) \
260 for ((pos) = rcu_dereference_raw((pos)->next); \ 272 for ((pos) = rcu_dereference_raw(list_next_rcu(pos)); \
261 prefetch((pos)->next), (pos) != (head); \ 273 (pos) != (head); \
262 (pos) = rcu_dereference_raw((pos)->next)) 274 (pos) = rcu_dereference_raw(list_next_rcu(pos)))
263 275
264/** 276/**
265 * list_for_each_entry_continue_rcu - continue iteration over list of given type 277 * list_for_each_entry_continue_rcu - continue iteration over list of given type
@@ -272,7 +284,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
272 */ 284 */
273#define list_for_each_entry_continue_rcu(pos, head, member) \ 285#define list_for_each_entry_continue_rcu(pos, head, member) \
274 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \ 286 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
275 prefetch(pos->member.next), &pos->member != (head); \ 287 &pos->member != (head); \
276 pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) 288 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
277 289
278/** 290/**
@@ -314,12 +326,19 @@ static inline void hlist_replace_rcu(struct hlist_node *old,
314 326
315 new->next = next; 327 new->next = next;
316 new->pprev = old->pprev; 328 new->pprev = old->pprev;
317 rcu_assign_pointer(*new->pprev, new); 329 rcu_assign_pointer(*(struct hlist_node __rcu **)new->pprev, new);
318 if (next) 330 if (next)
319 new->next->pprev = &new->next; 331 new->next->pprev = &new->next;
320 old->pprev = LIST_POISON2; 332 old->pprev = LIST_POISON2;
321} 333}
322 334
335/*
336 * return the first or the next element in an RCU protected hlist
337 */
338#define hlist_first_rcu(head) (*((struct hlist_node __rcu **)(&(head)->first)))
339#define hlist_next_rcu(node) (*((struct hlist_node __rcu **)(&(node)->next)))
340#define hlist_pprev_rcu(node) (*((struct hlist_node __rcu **)((node)->pprev)))
341
323/** 342/**
324 * hlist_add_head_rcu 343 * hlist_add_head_rcu
325 * @n: the element to add to the hash list. 344 * @n: the element to add to the hash list.
@@ -346,7 +365,7 @@ static inline void hlist_add_head_rcu(struct hlist_node *n,
346 365
347 n->next = first; 366 n->next = first;
348 n->pprev = &h->first; 367 n->pprev = &h->first;
349 rcu_assign_pointer(h->first, n); 368 rcu_assign_pointer(hlist_first_rcu(h), n);
350 if (first) 369 if (first)
351 first->pprev = &n->next; 370 first->pprev = &n->next;
352} 371}
@@ -374,7 +393,7 @@ static inline void hlist_add_before_rcu(struct hlist_node *n,
374{ 393{
375 n->pprev = next->pprev; 394 n->pprev = next->pprev;
376 n->next = next; 395 n->next = next;
377 rcu_assign_pointer(*(n->pprev), n); 396 rcu_assign_pointer(hlist_pprev_rcu(n), n);
378 next->pprev = &n->next; 397 next->pprev = &n->next;
379} 398}
380 399
@@ -401,15 +420,15 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
401{ 420{
402 n->next = prev->next; 421 n->next = prev->next;
403 n->pprev = &prev->next; 422 n->pprev = &prev->next;
404 rcu_assign_pointer(prev->next, n); 423 rcu_assign_pointer(hlist_next_rcu(prev), n);
405 if (n->next) 424 if (n->next)
406 n->next->pprev = &n->next; 425 n->next->pprev = &n->next;
407} 426}
408 427
409#define __hlist_for_each_rcu(pos, head) \ 428#define __hlist_for_each_rcu(pos, head) \
410 for (pos = rcu_dereference((head)->first); \ 429 for (pos = rcu_dereference(hlist_first_rcu(head)); \
411 pos && ({ prefetch(pos->next); 1; }); \ 430 pos; \
412 pos = rcu_dereference(pos->next)) 431 pos = rcu_dereference(hlist_next_rcu(pos)))
413 432
414/** 433/**
415 * hlist_for_each_entry_rcu - iterate over rcu list of given type 434 * hlist_for_each_entry_rcu - iterate over rcu list of given type
@@ -422,11 +441,11 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
422 * the _rcu list-mutation primitives such as hlist_add_head_rcu() 441 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
423 * as long as the traversal is guarded by rcu_read_lock(). 442 * as long as the traversal is guarded by rcu_read_lock().
424 */ 443 */
425#define hlist_for_each_entry_rcu(tpos, pos, head, member) \ 444#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
426 for (pos = rcu_dereference_raw((head)->first); \ 445 for (pos = rcu_dereference_raw(hlist_first_rcu(head)); \
427 pos && ({ prefetch(pos->next); 1; }) && \ 446 pos && \
428 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \ 447 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
429 pos = rcu_dereference_raw(pos->next)) 448 pos = rcu_dereference_raw(hlist_next_rcu(pos)))
430 449
431/** 450/**
432 * hlist_for_each_entry_rcu_bh - iterate over rcu list of given type 451 * hlist_for_each_entry_rcu_bh - iterate over rcu list of given type
@@ -441,7 +460,7 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
441 */ 460 */
442#define hlist_for_each_entry_rcu_bh(tpos, pos, head, member) \ 461#define hlist_for_each_entry_rcu_bh(tpos, pos, head, member) \
443 for (pos = rcu_dereference_bh((head)->first); \ 462 for (pos = rcu_dereference_bh((head)->first); \
444 pos && ({ prefetch(pos->next); 1; }) && \ 463 pos && \
445 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \ 464 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
446 pos = rcu_dereference_bh(pos->next)) 465 pos = rcu_dereference_bh(pos->next))
447 466
@@ -453,7 +472,7 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
453 */ 472 */
454#define hlist_for_each_entry_continue_rcu(tpos, pos, member) \ 473#define hlist_for_each_entry_continue_rcu(tpos, pos, member) \
455 for (pos = rcu_dereference((pos)->next); \ 474 for (pos = rcu_dereference((pos)->next); \
456 pos && ({ prefetch(pos->next); 1; }) && \ 475 pos && \
457 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \ 476 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
458 pos = rcu_dereference(pos->next)) 477 pos = rcu_dereference(pos->next))
459 478
@@ -465,7 +484,7 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
465 */ 484 */
466#define hlist_for_each_entry_continue_rcu_bh(tpos, pos, member) \ 485#define hlist_for_each_entry_continue_rcu_bh(tpos, pos, member) \
467 for (pos = rcu_dereference_bh((pos)->next); \ 486 for (pos = rcu_dereference_bh((pos)->next); \
468 pos && ({ prefetch(pos->next); 1; }) && \ 487 pos && \
469 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \ 488 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
470 pos = rcu_dereference_bh(pos->next)) 489 pos = rcu_dereference_bh(pos->next))
471 490
diff --git a/include/linux/rculist_bl.h b/include/linux/rculist_bl.h
new file mode 100644
index 000000000000..cf1244fbf3b6
--- /dev/null
+++ b/include/linux/rculist_bl.h
@@ -0,0 +1,128 @@
1#ifndef _LINUX_RCULIST_BL_H
2#define _LINUX_RCULIST_BL_H
3
4/*
5 * RCU-protected bl list version. See include/linux/list_bl.h.
6 */
7#include <linux/list_bl.h>
8#include <linux/rcupdate.h>
9
10static inline void hlist_bl_set_first_rcu(struct hlist_bl_head *h,
11 struct hlist_bl_node *n)
12{
13 LIST_BL_BUG_ON((unsigned long)n & LIST_BL_LOCKMASK);
14 LIST_BL_BUG_ON(((unsigned long)h->first & LIST_BL_LOCKMASK) !=
15 LIST_BL_LOCKMASK);
16 rcu_assign_pointer(h->first,
17 (struct hlist_bl_node *)((unsigned long)n | LIST_BL_LOCKMASK));
18}
19
20static inline struct hlist_bl_node *hlist_bl_first_rcu(struct hlist_bl_head *h)
21{
22 return (struct hlist_bl_node *)
23 ((unsigned long)rcu_dereference(h->first) & ~LIST_BL_LOCKMASK);
24}
25
26/**
27 * hlist_bl_del_init_rcu - deletes entry from hash list with re-initialization
28 * @n: the element to delete from the hash list.
29 *
30 * Note: hlist_bl_unhashed() on the node returns true after this. It is
31 * useful for RCU based read lockfree traversal if the writer side
32 * must know if the list entry is still hashed or already unhashed.
33 *
34 * In particular, it means that we can not poison the forward pointers
35 * that may still be used for walking the hash list and we can only
36 * zero the pprev pointer so list_unhashed() will return true after
37 * this.
38 *
39 * The caller must take whatever precautions are necessary (such as
40 * holding appropriate locks) to avoid racing with another
41 * list-mutation primitive, such as hlist_bl_add_head_rcu() or
42 * hlist_bl_del_rcu(), running on this same list. However, it is
43 * perfectly legal to run concurrently with the _rcu list-traversal
44 * primitives, such as hlist_bl_for_each_entry_rcu().
45 */
46static inline void hlist_bl_del_init_rcu(struct hlist_bl_node *n)
47{
48 if (!hlist_bl_unhashed(n)) {
49 __hlist_bl_del(n);
50 n->pprev = NULL;
51 }
52}
53
54/**
55 * hlist_bl_del_rcu - deletes entry from hash list without re-initialization
56 * @n: the element to delete from the hash list.
57 *
58 * Note: hlist_bl_unhashed() on entry does not return true after this,
59 * the entry is in an undefined state. It is useful for RCU based
60 * lockfree traversal.
61 *
62 * In particular, it means that we can not poison the forward
63 * pointers that may still be used for walking the hash list.
64 *
65 * The caller must take whatever precautions are necessary
66 * (such as holding appropriate locks) to avoid racing
67 * with another list-mutation primitive, such as hlist_bl_add_head_rcu()
68 * or hlist_bl_del_rcu(), running on this same list.
69 * However, it is perfectly legal to run concurrently with
70 * the _rcu list-traversal primitives, such as
71 * hlist_bl_for_each_entry().
72 */
73static inline void hlist_bl_del_rcu(struct hlist_bl_node *n)
74{
75 __hlist_bl_del(n);
76 n->pprev = LIST_POISON2;
77}
78
79/**
80 * hlist_bl_add_head_rcu
81 * @n: the element to add to the hash list.
82 * @h: the list to add to.
83 *
84 * Description:
85 * Adds the specified element to the specified hlist_bl,
86 * while permitting racing traversals.
87 *
88 * The caller must take whatever precautions are necessary
89 * (such as holding appropriate locks) to avoid racing
90 * with another list-mutation primitive, such as hlist_bl_add_head_rcu()
91 * or hlist_bl_del_rcu(), running on this same list.
92 * However, it is perfectly legal to run concurrently with
93 * the _rcu list-traversal primitives, such as
94 * hlist_bl_for_each_entry_rcu(), used to prevent memory-consistency
95 * problems on Alpha CPUs. Regardless of the type of CPU, the
96 * list-traversal primitive must be guarded by rcu_read_lock().
97 */
98static inline void hlist_bl_add_head_rcu(struct hlist_bl_node *n,
99 struct hlist_bl_head *h)
100{
101 struct hlist_bl_node *first;
102
103 /* don't need hlist_bl_first_rcu because we're under lock */
104 first = hlist_bl_first(h);
105
106 n->next = first;
107 if (first)
108 first->pprev = &n->next;
109 n->pprev = &h->first;
110
111 /* need _rcu because we can have concurrent lock free readers */
112 hlist_bl_set_first_rcu(h, n);
113}
114/**
115 * hlist_bl_for_each_entry_rcu - iterate over rcu list of given type
116 * @tpos: the type * to use as a loop cursor.
117 * @pos: the &struct hlist_bl_node to use as a loop cursor.
118 * @head: the head for your list.
119 * @member: the name of the hlist_bl_node within the struct.
120 *
121 */
122#define hlist_bl_for_each_entry_rcu(tpos, pos, head, member) \
123 for (pos = hlist_bl_first_rcu(head); \
124 pos && \
125 ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1; }); \
126 pos = rcu_dereference_raw(pos->next))
127
128#endif
diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h
index b70ffe53cb9f..2ae13714828b 100644
--- a/include/linux/rculist_nulls.h
+++ b/include/linux/rculist_nulls.h
@@ -37,6 +37,12 @@ static inline void hlist_nulls_del_init_rcu(struct hlist_nulls_node *n)
37 } 37 }
38} 38}
39 39
40#define hlist_nulls_first_rcu(head) \
41 (*((struct hlist_nulls_node __rcu __force **)&(head)->first))
42
43#define hlist_nulls_next_rcu(node) \
44 (*((struct hlist_nulls_node __rcu __force **)&(node)->next))
45
40/** 46/**
41 * hlist_nulls_del_rcu - deletes entry from hash list without re-initialization 47 * hlist_nulls_del_rcu - deletes entry from hash list without re-initialization
42 * @n: the element to delete from the hash list. 48 * @n: the element to delete from the hash list.
@@ -88,7 +94,7 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
88 94
89 n->next = first; 95 n->next = first;
90 n->pprev = &h->first; 96 n->pprev = &h->first;
91 rcu_assign_pointer(h->first, n); 97 rcu_assign_pointer(hlist_nulls_first_rcu(h), n);
92 if (!is_a_nulls(first)) 98 if (!is_a_nulls(first))
93 first->pprev = &n->next; 99 first->pprev = &n->next;
94} 100}
@@ -100,11 +106,11 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
100 * @member: the name of the hlist_nulls_node within the struct. 106 * @member: the name of the hlist_nulls_node within the struct.
101 * 107 *
102 */ 108 */
103#define hlist_nulls_for_each_entry_rcu(tpos, pos, head, member) \ 109#define hlist_nulls_for_each_entry_rcu(tpos, pos, head, member) \
104 for (pos = rcu_dereference_raw((head)->first); \ 110 for (pos = rcu_dereference_raw(hlist_nulls_first_rcu(head)); \
105 (!is_a_nulls(pos)) && \ 111 (!is_a_nulls(pos)) && \
106 ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1; }); \ 112 ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1; }); \
107 pos = rcu_dereference_raw(pos->next)) 113 pos = rcu_dereference_raw(hlist_nulls_next_rcu(pos)))
108 114
109#endif 115#endif
110#endif 116#endif
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 83af1f8d8b74..99f9aa7c2804 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -41,11 +41,29 @@
41#include <linux/lockdep.h> 41#include <linux/lockdep.h>
42#include <linux/completion.h> 42#include <linux/completion.h>
43#include <linux/debugobjects.h> 43#include <linux/debugobjects.h>
44#include <linux/compiler.h>
44 45
45#ifdef CONFIG_RCU_TORTURE_TEST 46#ifdef CONFIG_RCU_TORTURE_TEST
46extern int rcutorture_runnable; /* for sysctl */ 47extern int rcutorture_runnable; /* for sysctl */
47#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 48#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
48 49
50#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
51extern void rcutorture_record_test_transition(void);
52extern void rcutorture_record_progress(unsigned long vernum);
53#else
54static inline void rcutorture_record_test_transition(void)
55{
56}
57static inline void rcutorture_record_progress(unsigned long vernum)
58{
59}
60#endif
61
62#define UINT_CMP_GE(a, b) (UINT_MAX / 2 >= (a) - (b))
63#define UINT_CMP_LT(a, b) (UINT_MAX / 2 < (a) - (b))
64#define ULONG_CMP_GE(a, b) (ULONG_MAX / 2 >= (a) - (b))
65#define ULONG_CMP_LT(a, b) (ULONG_MAX / 2 < (a) - (b))
66
49/** 67/**
50 * struct rcu_head - callback structure for use with RCU 68 * struct rcu_head - callback structure for use with RCU
51 * @next: next update requests in a list 69 * @next: next update requests in a list
@@ -57,29 +75,91 @@ struct rcu_head {
57}; 75};
58 76
59/* Exported common interfaces */ 77/* Exported common interfaces */
60extern void rcu_barrier(void); 78extern void call_rcu_sched(struct rcu_head *head,
79 void (*func)(struct rcu_head *rcu));
80extern void synchronize_sched(void);
61extern void rcu_barrier_bh(void); 81extern void rcu_barrier_bh(void);
62extern void rcu_barrier_sched(void); 82extern void rcu_barrier_sched(void);
63extern void synchronize_sched_expedited(void); 83
64extern int sched_expedited_torture_stats(char *page); 84static inline void __rcu_read_lock_bh(void)
85{
86 local_bh_disable();
87}
88
89static inline void __rcu_read_unlock_bh(void)
90{
91 local_bh_enable();
92}
93
94#ifdef CONFIG_PREEMPT_RCU
95
96extern void __rcu_read_lock(void);
97extern void __rcu_read_unlock(void);
98void synchronize_rcu(void);
99
100/*
101 * Defined as a macro as it is a very low level header included from
102 * areas that don't even know about current. This gives the rcu_read_lock()
103 * nesting depth, but makes sense only if CONFIG_PREEMPT_RCU -- in other
104 * types of kernel builds, the rcu_read_lock() nesting depth is unknowable.
105 */
106#define rcu_preempt_depth() (current->rcu_read_lock_nesting)
107
108#else /* #ifdef CONFIG_PREEMPT_RCU */
109
110static inline void __rcu_read_lock(void)
111{
112 preempt_disable();
113}
114
115static inline void __rcu_read_unlock(void)
116{
117 preempt_enable();
118}
119
120static inline void synchronize_rcu(void)
121{
122 synchronize_sched();
123}
124
125static inline int rcu_preempt_depth(void)
126{
127 return 0;
128}
129
130#endif /* #else #ifdef CONFIG_PREEMPT_RCU */
65 131
66/* Internal to kernel */ 132/* Internal to kernel */
67extern void rcu_init(void); 133extern void rcu_sched_qs(int cpu);
134extern void rcu_bh_qs(int cpu);
135extern void rcu_check_callbacks(int cpu, int user);
136struct notifier_block;
137
138#ifdef CONFIG_NO_HZ
139
140extern void rcu_enter_nohz(void);
141extern void rcu_exit_nohz(void);
142
143#else /* #ifdef CONFIG_NO_HZ */
144
145static inline void rcu_enter_nohz(void)
146{
147}
148
149static inline void rcu_exit_nohz(void)
150{
151}
152
153#endif /* #else #ifdef CONFIG_NO_HZ */
68 154
69#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) 155#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
70#include <linux/rcutree.h> 156#include <linux/rcutree.h>
71#elif defined(CONFIG_TINY_RCU) 157#elif defined(CONFIG_TINY_RCU) || defined(CONFIG_TINY_PREEMPT_RCU)
72#include <linux/rcutiny.h> 158#include <linux/rcutiny.h>
73#else 159#else
74#error "Unknown RCU implementation specified to kernel configuration" 160#error "Unknown RCU implementation specified to kernel configuration"
75#endif 161#endif
76 162
77#define RCU_HEAD_INIT { .next = NULL, .func = NULL }
78#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT
79#define INIT_RCU_HEAD(ptr) do { \
80 (ptr)->next = NULL; (ptr)->func = NULL; \
81} while (0)
82
83/* 163/*
84 * init_rcu_head_on_stack()/destroy_rcu_head_on_stack() are needed for dynamic 164 * init_rcu_head_on_stack()/destroy_rcu_head_on_stack() are needed for dynamic
85 * initialization and destruction of rcu_head on the stack. rcu_head structures 165 * initialization and destruction of rcu_head on the stack. rcu_head structures
@@ -120,14 +200,15 @@ extern struct lockdep_map rcu_sched_lock_map;
120extern int debug_lockdep_rcu_enabled(void); 200extern int debug_lockdep_rcu_enabled(void);
121 201
122/** 202/**
123 * rcu_read_lock_held - might we be in RCU read-side critical section? 203 * rcu_read_lock_held() - might we be in RCU read-side critical section?
124 * 204 *
125 * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an RCU 205 * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an RCU
126 * read-side critical section. In absence of CONFIG_DEBUG_LOCK_ALLOC, 206 * read-side critical section. In absence of CONFIG_DEBUG_LOCK_ALLOC,
127 * this assumes we are in an RCU read-side critical section unless it can 207 * this assumes we are in an RCU read-side critical section unless it can
128 * prove otherwise. 208 * prove otherwise. This is useful for debug checks in functions that
209 * require that they be called within an RCU read-side critical section.
129 * 210 *
130 * Check debug_lockdep_rcu_enabled() to prevent false positives during boot 211 * Checks debug_lockdep_rcu_enabled() to prevent false positives during boot
131 * and while lockdep is disabled. 212 * and while lockdep is disabled.
132 */ 213 */
133static inline int rcu_read_lock_held(void) 214static inline int rcu_read_lock_held(void)
@@ -144,14 +225,16 @@ static inline int rcu_read_lock_held(void)
144extern int rcu_read_lock_bh_held(void); 225extern int rcu_read_lock_bh_held(void);
145 226
146/** 227/**
147 * rcu_read_lock_sched_held - might we be in RCU-sched read-side critical section? 228 * rcu_read_lock_sched_held() - might we be in RCU-sched read-side critical section?
148 * 229 *
149 * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an 230 * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an
150 * RCU-sched read-side critical section. In absence of 231 * RCU-sched read-side critical section. In absence of
151 * CONFIG_DEBUG_LOCK_ALLOC, this assumes we are in an RCU-sched read-side 232 * CONFIG_DEBUG_LOCK_ALLOC, this assumes we are in an RCU-sched read-side
152 * critical section unless it can prove otherwise. Note that disabling 233 * critical section unless it can prove otherwise. Note that disabling
153 * of preemption (including disabling irqs) counts as an RCU-sched 234 * of preemption (including disabling irqs) counts as an RCU-sched
154 * read-side critical section. 235 * read-side critical section. This is useful for debug checks in functions
236 * that required that they be called within an RCU-sched read-side
237 * critical section.
155 * 238 *
156 * Check debug_lockdep_rcu_enabled() to prevent false positives during boot 239 * Check debug_lockdep_rcu_enabled() to prevent false positives during boot
157 * and while lockdep is disabled. 240 * and while lockdep is disabled.
@@ -211,7 +294,11 @@ static inline int rcu_read_lock_sched_held(void)
211 294
212extern int rcu_my_thread_group_empty(void); 295extern int rcu_my_thread_group_empty(void);
213 296
214#define __do_rcu_dereference_check(c) \ 297/**
298 * rcu_lockdep_assert - emit lockdep splat if specified condition not met
299 * @c: condition to check
300 */
301#define rcu_lockdep_assert(c) \
215 do { \ 302 do { \
216 static bool __warned; \ 303 static bool __warned; \
217 if (debug_lockdep_rcu_enabled() && !__warned && !(c)) { \ 304 if (debug_lockdep_rcu_enabled() && !__warned && !(c)) { \
@@ -220,41 +307,183 @@ extern int rcu_my_thread_group_empty(void);
220 } \ 307 } \
221 } while (0) 308 } while (0)
222 309
310#else /* #ifdef CONFIG_PROVE_RCU */
311
312#define rcu_lockdep_assert(c) do { } while (0)
313
314#endif /* #else #ifdef CONFIG_PROVE_RCU */
315
316/*
317 * Helper functions for rcu_dereference_check(), rcu_dereference_protected()
318 * and rcu_assign_pointer(). Some of these could be folded into their
319 * callers, but they are left separate in order to ease introduction of
320 * multiple flavors of pointers to match the multiple flavors of RCU
321 * (e.g., __rcu_bh, * __rcu_sched, and __srcu), should this make sense in
322 * the future.
323 */
324
325#ifdef __CHECKER__
326#define rcu_dereference_sparse(p, space) \
327 ((void)(((typeof(*p) space *)p) == p))
328#else /* #ifdef __CHECKER__ */
329#define rcu_dereference_sparse(p, space)
330#endif /* #else #ifdef __CHECKER__ */
331
332#define __rcu_access_pointer(p, space) \
333 ({ \
334 typeof(*p) *_________p1 = (typeof(*p)*__force )ACCESS_ONCE(p); \
335 rcu_dereference_sparse(p, space); \
336 ((typeof(*p) __force __kernel *)(_________p1)); \
337 })
338#define __rcu_dereference_check(p, c, space) \
339 ({ \
340 typeof(*p) *_________p1 = (typeof(*p)*__force )ACCESS_ONCE(p); \
341 rcu_lockdep_assert(c); \
342 rcu_dereference_sparse(p, space); \
343 smp_read_barrier_depends(); \
344 ((typeof(*p) __force __kernel *)(_________p1)); \
345 })
346#define __rcu_dereference_protected(p, c, space) \
347 ({ \
348 rcu_lockdep_assert(c); \
349 rcu_dereference_sparse(p, space); \
350 ((typeof(*p) __force __kernel *)(p)); \
351 })
352
353#define __rcu_access_index(p, space) \
354 ({ \
355 typeof(p) _________p1 = ACCESS_ONCE(p); \
356 rcu_dereference_sparse(p, space); \
357 (_________p1); \
358 })
359#define __rcu_dereference_index_check(p, c) \
360 ({ \
361 typeof(p) _________p1 = ACCESS_ONCE(p); \
362 rcu_lockdep_assert(c); \
363 smp_read_barrier_depends(); \
364 (_________p1); \
365 })
366#define __rcu_assign_pointer(p, v, space) \
367 ({ \
368 if (!__builtin_constant_p(v) || \
369 ((v) != NULL)) \
370 smp_wmb(); \
371 (p) = (typeof(*v) __force space *)(v); \
372 })
373
374
375/**
376 * rcu_access_pointer() - fetch RCU pointer with no dereferencing
377 * @p: The pointer to read
378 *
379 * Return the value of the specified RCU-protected pointer, but omit the
380 * smp_read_barrier_depends() and keep the ACCESS_ONCE(). This is useful
381 * when the value of this pointer is accessed, but the pointer is not
382 * dereferenced, for example, when testing an RCU-protected pointer against
383 * NULL. Although rcu_access_pointer() may also be used in cases where
384 * update-side locks prevent the value of the pointer from changing, you
385 * should instead use rcu_dereference_protected() for this use case.
386 */
387#define rcu_access_pointer(p) __rcu_access_pointer((p), __rcu)
388
223/** 389/**
224 * rcu_dereference_check - rcu_dereference with debug checking 390 * rcu_dereference_check() - rcu_dereference with debug checking
225 * @p: The pointer to read, prior to dereferencing 391 * @p: The pointer to read, prior to dereferencing
226 * @c: The conditions under which the dereference will take place 392 * @c: The conditions under which the dereference will take place
227 * 393 *
228 * Do an rcu_dereference(), but check that the conditions under which the 394 * Do an rcu_dereference(), but check that the conditions under which the
229 * dereference will take place are correct. Typically the conditions indicate 395 * dereference will take place are correct. Typically the conditions
230 * the various locking conditions that should be held at that point. The check 396 * indicate the various locking conditions that should be held at that
231 * should return true if the conditions are satisfied. 397 * point. The check should return true if the conditions are satisfied.
398 * An implicit check for being in an RCU read-side critical section
399 * (rcu_read_lock()) is included.
232 * 400 *
233 * For example: 401 * For example:
234 * 402 *
235 * bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || 403 * bar = rcu_dereference_check(foo->bar, lockdep_is_held(&foo->lock));
236 * lockdep_is_held(&foo->lock));
237 * 404 *
238 * could be used to indicate to lockdep that foo->bar may only be dereferenced 405 * could be used to indicate to lockdep that foo->bar may only be dereferenced
239 * if either the RCU read lock is held, or that the lock required to replace 406 * if either rcu_read_lock() is held, or that the lock required to replace
240 * the bar struct at foo->bar is held. 407 * the bar struct at foo->bar is held.
241 * 408 *
242 * Note that the list of conditions may also include indications of when a lock 409 * Note that the list of conditions may also include indications of when a lock
243 * need not be held, for example during initialisation or destruction of the 410 * need not be held, for example during initialisation or destruction of the
244 * target struct: 411 * target struct:
245 * 412 *
246 * bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || 413 * bar = rcu_dereference_check(foo->bar, lockdep_is_held(&foo->lock) ||
247 * lockdep_is_held(&foo->lock) ||
248 * atomic_read(&foo->usage) == 0); 414 * atomic_read(&foo->usage) == 0);
415 *
416 * Inserts memory barriers on architectures that require them
417 * (currently only the Alpha), prevents the compiler from refetching
418 * (and from merging fetches), and, more importantly, documents exactly
419 * which pointers are protected by RCU and checks that the pointer is
420 * annotated as __rcu.
249 */ 421 */
250#define rcu_dereference_check(p, c) \ 422#define rcu_dereference_check(p, c) \
251 ({ \ 423 __rcu_dereference_check((p), rcu_read_lock_held() || (c), __rcu)
252 __do_rcu_dereference_check(c); \ 424
253 rcu_dereference_raw(p); \ 425/**
254 }) 426 * rcu_dereference_bh_check() - rcu_dereference_bh with debug checking
427 * @p: The pointer to read, prior to dereferencing
428 * @c: The conditions under which the dereference will take place
429 *
430 * This is the RCU-bh counterpart to rcu_dereference_check().
431 */
432#define rcu_dereference_bh_check(p, c) \
433 __rcu_dereference_check((p), rcu_read_lock_bh_held() || (c), __rcu)
434
435/**
436 * rcu_dereference_sched_check() - rcu_dereference_sched with debug checking
437 * @p: The pointer to read, prior to dereferencing
438 * @c: The conditions under which the dereference will take place
439 *
440 * This is the RCU-sched counterpart to rcu_dereference_check().
441 */
442#define rcu_dereference_sched_check(p, c) \
443 __rcu_dereference_check((p), rcu_read_lock_sched_held() || (c), \
444 __rcu)
445
446#define rcu_dereference_raw(p) rcu_dereference_check(p, 1) /*@@@ needed? @@@*/
255 447
256/** 448/**
257 * rcu_dereference_protected - fetch RCU pointer when updates prevented 449 * rcu_access_index() - fetch RCU index with no dereferencing
450 * @p: The index to read
451 *
452 * Return the value of the specified RCU-protected index, but omit the
453 * smp_read_barrier_depends() and keep the ACCESS_ONCE(). This is useful
454 * when the value of this index is accessed, but the index is not
455 * dereferenced, for example, when testing an RCU-protected index against
456 * -1. Although rcu_access_index() may also be used in cases where
457 * update-side locks prevent the value of the index from changing, you
458 * should instead use rcu_dereference_index_protected() for this use case.
459 */
460#define rcu_access_index(p) __rcu_access_index((p), __rcu)
461
462/**
463 * rcu_dereference_index_check() - rcu_dereference for indices with debug checking
464 * @p: The pointer to read, prior to dereferencing
465 * @c: The conditions under which the dereference will take place
466 *
467 * Similar to rcu_dereference_check(), but omits the sparse checking.
468 * This allows rcu_dereference_index_check() to be used on integers,
469 * which can then be used as array indices. Attempting to use
470 * rcu_dereference_check() on an integer will give compiler warnings
471 * because the sparse address-space mechanism relies on dereferencing
472 * the RCU-protected pointer. Dereferencing integers is not something
473 * that even gcc will put up with.
474 *
475 * Note that this function does not implicitly check for RCU read-side
476 * critical sections. If this function gains lots of uses, it might
477 * make sense to provide versions for each flavor of RCU, but it does
478 * not make sense as of early 2010.
479 */
480#define rcu_dereference_index_check(p, c) \
481 __rcu_dereference_index_check((p), (c))
482
483/**
484 * rcu_dereference_protected() - fetch RCU pointer when updates prevented
485 * @p: The pointer to read, prior to dereferencing
486 * @c: The conditions under which the dereference will take place
258 * 487 *
259 * Return the value of the specified RCU-protected pointer, but omit 488 * Return the value of the specified RCU-protected pointer, but omit
260 * both the smp_read_barrier_depends() and the ACCESS_ONCE(). This 489 * both the smp_read_barrier_depends() and the ACCESS_ONCE(). This
@@ -263,35 +492,61 @@ extern int rcu_my_thread_group_empty(void);
263 * prevent the compiler from repeating this reference or combining it 492 * prevent the compiler from repeating this reference or combining it
264 * with other references, so it should not be used without protection 493 * with other references, so it should not be used without protection
265 * of appropriate locks. 494 * of appropriate locks.
495 *
496 * This function is only for update-side use. Using this function
497 * when protected only by rcu_read_lock() will result in infrequent
498 * but very ugly failures.
266 */ 499 */
267#define rcu_dereference_protected(p, c) \ 500#define rcu_dereference_protected(p, c) \
268 ({ \ 501 __rcu_dereference_protected((p), (c), __rcu)
269 __do_rcu_dereference_check(c); \
270 (p); \
271 })
272 502
273#else /* #ifdef CONFIG_PROVE_RCU */ 503/**
504 * rcu_dereference_bh_protected() - fetch RCU-bh pointer when updates prevented
505 * @p: The pointer to read, prior to dereferencing
506 * @c: The conditions under which the dereference will take place
507 *
508 * This is the RCU-bh counterpart to rcu_dereference_protected().
509 */
510#define rcu_dereference_bh_protected(p, c) \
511 __rcu_dereference_protected((p), (c), __rcu)
274 512
275#define rcu_dereference_check(p, c) rcu_dereference_raw(p) 513/**
276#define rcu_dereference_protected(p, c) (p) 514 * rcu_dereference_sched_protected() - fetch RCU-sched pointer when updates prevented
515 * @p: The pointer to read, prior to dereferencing
516 * @c: The conditions under which the dereference will take place
517 *
518 * This is the RCU-sched counterpart to rcu_dereference_protected().
519 */
520#define rcu_dereference_sched_protected(p, c) \
521 __rcu_dereference_protected((p), (c), __rcu)
277 522
278#endif /* #else #ifdef CONFIG_PROVE_RCU */
279 523
280/** 524/**
281 * rcu_access_pointer - fetch RCU pointer with no dereferencing 525 * rcu_dereference() - fetch RCU-protected pointer for dereferencing
526 * @p: The pointer to read, prior to dereferencing
282 * 527 *
283 * Return the value of the specified RCU-protected pointer, but omit the 528 * This is a simple wrapper around rcu_dereference_check().
284 * smp_read_barrier_depends() and keep the ACCESS_ONCE(). This is useful 529 */
285 * when the value of this pointer is accessed, but the pointer is not 530#define rcu_dereference(p) rcu_dereference_check(p, 0)
286 * dereferenced, for example, when testing an RCU-protected pointer against 531
287 * NULL. This may also be used in cases where update-side locks prevent 532/**
288 * the value of the pointer from changing, but rcu_dereference_protected() 533 * rcu_dereference_bh() - fetch an RCU-bh-protected pointer for dereferencing
289 * is a lighter-weight primitive for this use case. 534 * @p: The pointer to read, prior to dereferencing
535 *
536 * Makes rcu_dereference_check() do the dirty work.
537 */
538#define rcu_dereference_bh(p) rcu_dereference_bh_check(p, 0)
539
540/**
541 * rcu_dereference_sched() - fetch RCU-sched-protected pointer for dereferencing
542 * @p: The pointer to read, prior to dereferencing
543 *
544 * Makes rcu_dereference_check() do the dirty work.
290 */ 545 */
291#define rcu_access_pointer(p) ACCESS_ONCE(p) 546#define rcu_dereference_sched(p) rcu_dereference_sched_check(p, 0)
292 547
293/** 548/**
294 * rcu_read_lock - mark the beginning of an RCU read-side critical section. 549 * rcu_read_lock() - mark the beginning of an RCU read-side critical section
295 * 550 *
296 * When synchronize_rcu() is invoked on one CPU while other CPUs 551 * When synchronize_rcu() is invoked on one CPU while other CPUs
297 * are within RCU read-side critical sections, then the 552 * are within RCU read-side critical sections, then the
@@ -302,7 +557,7 @@ extern int rcu_my_thread_group_empty(void);
302 * until after the all the other CPUs exit their critical sections. 557 * until after the all the other CPUs exit their critical sections.
303 * 558 *
304 * Note, however, that RCU callbacks are permitted to run concurrently 559 * Note, however, that RCU callbacks are permitted to run concurrently
305 * with RCU read-side critical sections. One way that this can happen 560 * with new RCU read-side critical sections. One way that this can happen
306 * is via the following sequence of events: (1) CPU 0 enters an RCU 561 * is via the following sequence of events: (1) CPU 0 enters an RCU
307 * read-side critical section, (2) CPU 1 invokes call_rcu() to register 562 * read-side critical section, (2) CPU 1 invokes call_rcu() to register
308 * an RCU callback, (3) CPU 0 exits the RCU read-side critical section, 563 * an RCU callback, (3) CPU 0 exits the RCU read-side critical section,
@@ -317,7 +572,20 @@ extern int rcu_my_thread_group_empty(void);
317 * will be deferred until the outermost RCU read-side critical section 572 * will be deferred until the outermost RCU read-side critical section
318 * completes. 573 * completes.
319 * 574 *
320 * It is illegal to block while in an RCU read-side critical section. 575 * You can avoid reading and understanding the next paragraph by
576 * following this rule: don't put anything in an rcu_read_lock() RCU
577 * read-side critical section that would block in a !PREEMPT kernel.
578 * But if you want the full story, read on!
579 *
580 * In non-preemptible RCU implementations (TREE_RCU and TINY_RCU), it
581 * is illegal to block while in an RCU read-side critical section. In
582 * preemptible RCU implementations (TREE_PREEMPT_RCU and TINY_PREEMPT_RCU)
583 * in CONFIG_PREEMPT kernel builds, RCU read-side critical sections may
584 * be preempted, but explicit blocking is illegal. Finally, in preemptible
585 * RCU implementations in real-time (CONFIG_PREEMPT_RT) kernel builds,
586 * RCU read-side critical sections may be preempted and they may also
587 * block, but only when acquiring spinlocks that are subject to priority
588 * inheritance.
321 */ 589 */
322static inline void rcu_read_lock(void) 590static inline void rcu_read_lock(void)
323{ 591{
@@ -337,7 +605,7 @@ static inline void rcu_read_lock(void)
337 */ 605 */
338 606
339/** 607/**
340 * rcu_read_unlock - marks the end of an RCU read-side critical section. 608 * rcu_read_unlock() - marks the end of an RCU read-side critical section.
341 * 609 *
342 * See rcu_read_lock() for more information. 610 * See rcu_read_lock() for more information.
343 */ 611 */
@@ -349,15 +617,16 @@ static inline void rcu_read_unlock(void)
349} 617}
350 618
351/** 619/**
352 * rcu_read_lock_bh - mark the beginning of a softirq-only RCU critical section 620 * rcu_read_lock_bh() - mark the beginning of an RCU-bh critical section
353 * 621 *
354 * This is equivalent of rcu_read_lock(), but to be used when updates 622 * This is equivalent of rcu_read_lock(), but to be used when updates
355 * are being done using call_rcu_bh(). Since call_rcu_bh() callbacks 623 * are being done using call_rcu_bh() or synchronize_rcu_bh(). Since
356 * consider completion of a softirq handler to be a quiescent state, 624 * both call_rcu_bh() and synchronize_rcu_bh() consider completion of a
357 * a process in RCU read-side critical section must be protected by 625 * softirq handler to be a quiescent state, a process in RCU read-side
358 * disabling softirqs. Read-side critical sections in interrupt context 626 * critical section must be protected by disabling softirqs. Read-side
359 * can use just rcu_read_lock(). 627 * critical sections in interrupt context can use just rcu_read_lock(),
360 * 628 * though this should at least be commented to avoid confusing people
629 * reading the code.
361 */ 630 */
362static inline void rcu_read_lock_bh(void) 631static inline void rcu_read_lock_bh(void)
363{ 632{
@@ -379,13 +648,12 @@ static inline void rcu_read_unlock_bh(void)
379} 648}
380 649
381/** 650/**
382 * rcu_read_lock_sched - mark the beginning of a RCU-classic critical section 651 * rcu_read_lock_sched() - mark the beginning of a RCU-sched critical section
383 * 652 *
384 * Should be used with either 653 * This is equivalent of rcu_read_lock(), but to be used when updates
385 * - synchronize_sched() 654 * are being done using call_rcu_sched() or synchronize_rcu_sched().
386 * or 655 * Read-side critical sections can also be introduced by anything that
387 * - call_rcu_sched() and rcu_barrier_sched() 656 * disables preemption, including local_irq_disable() and friends.
388 * on the write-side to insure proper synchronization.
389 */ 657 */
390static inline void rcu_read_lock_sched(void) 658static inline void rcu_read_lock_sched(void)
391{ 659{
@@ -420,54 +688,14 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
420 preempt_enable_notrace(); 688 preempt_enable_notrace();
421} 689}
422 690
423
424/** 691/**
425 * rcu_dereference_raw - fetch an RCU-protected pointer 692 * rcu_assign_pointer() - assign to RCU-protected pointer
693 * @p: pointer to assign to
694 * @v: value to assign (publish)
426 * 695 *
427 * The caller must be within some flavor of RCU read-side critical 696 * Assigns the specified value to the specified RCU-protected
428 * section, or must be otherwise preventing the pointer from changing, 697 * pointer, ensuring that any concurrent RCU readers will see
429 * for example, by holding an appropriate lock. This pointer may later 698 * any prior initialization. Returns the value assigned.
430 * be safely dereferenced. It is the caller's responsibility to have
431 * done the right thing, as this primitive does no checking of any kind.
432 *
433 * Inserts memory barriers on architectures that require them
434 * (currently only the Alpha), and, more importantly, documents
435 * exactly which pointers are protected by RCU.
436 */
437#define rcu_dereference_raw(p) ({ \
438 typeof(p) _________p1 = ACCESS_ONCE(p); \
439 smp_read_barrier_depends(); \
440 (_________p1); \
441 })
442
443/**
444 * rcu_dereference - fetch an RCU-protected pointer, checking for RCU
445 *
446 * Makes rcu_dereference_check() do the dirty work.
447 */
448#define rcu_dereference(p) \
449 rcu_dereference_check(p, rcu_read_lock_held())
450
451/**
452 * rcu_dereference_bh - fetch an RCU-protected pointer, checking for RCU-bh
453 *
454 * Makes rcu_dereference_check() do the dirty work.
455 */
456#define rcu_dereference_bh(p) \
457 rcu_dereference_check(p, rcu_read_lock_bh_held() || irqs_disabled())
458
459/**
460 * rcu_dereference_sched - fetch RCU-protected pointer, checking for RCU-sched
461 *
462 * Makes rcu_dereference_check() do the dirty work.
463 */
464#define rcu_dereference_sched(p) \
465 rcu_dereference_check(p, rcu_read_lock_sched_held())
466
467/**
468 * rcu_assign_pointer - assign (publicize) a pointer to a newly
469 * initialized structure that will be dereferenced by RCU read-side
470 * critical sections. Returns the value assigned.
471 * 699 *
472 * Inserts memory barriers on architectures that require them 700 * Inserts memory barriers on architectures that require them
473 * (pretty much all of them other than x86), and also prevents 701 * (pretty much all of them other than x86), and also prevents
@@ -476,14 +704,17 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
476 * call documents which pointers will be dereferenced by RCU read-side 704 * call documents which pointers will be dereferenced by RCU read-side
477 * code. 705 * code.
478 */ 706 */
479
480#define rcu_assign_pointer(p, v) \ 707#define rcu_assign_pointer(p, v) \
481 ({ \ 708 __rcu_assign_pointer((p), (v), __rcu)
482 if (!__builtin_constant_p(v) || \ 709
483 ((v) != NULL)) \ 710/**
484 smp_wmb(); \ 711 * RCU_INIT_POINTER() - initialize an RCU protected pointer
485 (p) = (v); \ 712 *
486 }) 713 * Initialize an RCU-protected pointer in such a way to avoid RCU-lockdep
714 * splats.
715 */
716#define RCU_INIT_POINTER(p, v) \
717 p = (typeof(*v) __force __rcu *)(v)
487 718
488/* Infrastructure to implement the synchronize_() primitives. */ 719/* Infrastructure to implement the synchronize_() primitives. */
489 720
@@ -494,26 +725,37 @@ struct rcu_synchronize {
494 725
495extern void wakeme_after_rcu(struct rcu_head *head); 726extern void wakeme_after_rcu(struct rcu_head *head);
496 727
728#ifdef CONFIG_PREEMPT_RCU
729
497/** 730/**
498 * call_rcu - Queue an RCU callback for invocation after a grace period. 731 * call_rcu() - Queue an RCU callback for invocation after a grace period.
499 * @head: structure to be used for queueing the RCU updates. 732 * @head: structure to be used for queueing the RCU updates.
500 * @func: actual update function to be invoked after the grace period 733 * @func: actual callback function to be invoked after the grace period
501 * 734 *
502 * The update function will be invoked some time after a full grace 735 * The callback function will be invoked some time after a full grace
503 * period elapses, in other words after all currently executing RCU 736 * period elapses, in other words after all pre-existing RCU read-side
504 * read-side critical sections have completed. RCU read-side critical 737 * critical sections have completed. However, the callback function
738 * might well execute concurrently with RCU read-side critical sections
739 * that started after call_rcu() was invoked. RCU read-side critical
505 * sections are delimited by rcu_read_lock() and rcu_read_unlock(), 740 * sections are delimited by rcu_read_lock() and rcu_read_unlock(),
506 * and may be nested. 741 * and may be nested.
507 */ 742 */
508extern void call_rcu(struct rcu_head *head, 743extern void call_rcu(struct rcu_head *head,
509 void (*func)(struct rcu_head *head)); 744 void (*func)(struct rcu_head *head));
510 745
746#else /* #ifdef CONFIG_PREEMPT_RCU */
747
748/* In classic RCU, call_rcu() is just call_rcu_sched(). */
749#define call_rcu call_rcu_sched
750
751#endif /* #else #ifdef CONFIG_PREEMPT_RCU */
752
511/** 753/**
512 * call_rcu_bh - Queue an RCU for invocation after a quicker grace period. 754 * call_rcu_bh() - Queue an RCU for invocation after a quicker grace period.
513 * @head: structure to be used for queueing the RCU updates. 755 * @head: structure to be used for queueing the RCU updates.
514 * @func: actual update function to be invoked after the grace period 756 * @func: actual callback function to be invoked after the grace period
515 * 757 *
516 * The update function will be invoked some time after a full grace 758 * The callback function will be invoked some time after a full grace
517 * period elapses, in other words after all currently executing RCU 759 * period elapses, in other words after all currently executing RCU
518 * read-side critical sections have completed. call_rcu_bh() assumes 760 * read-side critical sections have completed. call_rcu_bh() assumes
519 * that the read-side critical sections end on completion of a softirq 761 * that the read-side critical sections end on completion of a softirq
@@ -543,6 +785,7 @@ extern struct debug_obj_descr rcuhead_debug_descr;
543 785
544static inline void debug_rcu_head_queue(struct rcu_head *head) 786static inline void debug_rcu_head_queue(struct rcu_head *head)
545{ 787{
788 WARN_ON_ONCE((unsigned long)head & 0x3);
546 debug_object_activate(head, &rcuhead_debug_descr); 789 debug_object_activate(head, &rcuhead_debug_descr);
547 debug_object_active_state(head, &rcuhead_debug_descr, 790 debug_object_active_state(head, &rcuhead_debug_descr,
548 STATE_RCU_HEAD_READY, 791 STATE_RCU_HEAD_READY,
@@ -566,37 +809,60 @@ static inline void debug_rcu_head_unqueue(struct rcu_head *head)
566} 809}
567#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ 810#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
568 811
569#ifndef CONFIG_PROVE_RCU 812static __always_inline bool __is_kfree_rcu_offset(unsigned long offset)
570#define __do_rcu_dereference_check(c) do { } while (0) 813{
571#endif /* #ifdef CONFIG_PROVE_RCU */ 814 return offset < 4096;
815}
572 816
573#define __rcu_dereference_index_check(p, c) \ 817static __always_inline
574 ({ \ 818void __kfree_rcu(struct rcu_head *head, unsigned long offset)
575 typeof(p) _________p1 = ACCESS_ONCE(p); \ 819{
576 __do_rcu_dereference_check(c); \ 820 typedef void (*rcu_callback)(struct rcu_head *);
577 smp_read_barrier_depends(); \ 821
578 (_________p1); \ 822 BUILD_BUG_ON(!__builtin_constant_p(offset));
579 }) 823
824 /* See the kfree_rcu() header comment. */
825 BUILD_BUG_ON(!__is_kfree_rcu_offset(offset));
826
827 call_rcu(head, (rcu_callback)offset);
828}
829
830extern void kfree(const void *);
831
832static inline void __rcu_reclaim(struct rcu_head *head)
833{
834 unsigned long offset = (unsigned long)head->func;
835
836 if (__is_kfree_rcu_offset(offset))
837 kfree((void *)head - offset);
838 else
839 head->func(head);
840}
580 841
581/** 842/**
582 * rcu_dereference_index_check() - rcu_dereference for indices with debug checking 843 * kfree_rcu() - kfree an object after a grace period.
583 * @p: The pointer to read, prior to dereferencing 844 * @ptr: pointer to kfree
584 * @c: The conditions under which the dereference will take place 845 * @rcu_head: the name of the struct rcu_head within the type of @ptr.
585 * 846 *
586 * Similar to rcu_dereference_check(), but omits the sparse checking. 847 * Many rcu callbacks functions just call kfree() on the base structure.
587 * This allows rcu_dereference_index_check() to be used on integers, 848 * These functions are trivial, but their size adds up, and furthermore
588 * which can then be used as array indices. Attempting to use 849 * when they are used in a kernel module, that module must invoke the
589 * rcu_dereference_check() on an integer will give compiler warnings 850 * high-latency rcu_barrier() function at module-unload time.
590 * because the sparse address-space mechanism relies on dereferencing 851 *
591 * the RCU-protected pointer. Dereferencing integers is not something 852 * The kfree_rcu() function handles this issue. Rather than encoding a
592 * that even gcc will put up with. 853 * function address in the embedded rcu_head structure, kfree_rcu() instead
593 * 854 * encodes the offset of the rcu_head structure within the base structure.
594 * Note that this function does not implicitly check for RCU read-side 855 * Because the functions are not allowed in the low-order 4096 bytes of
595 * critical sections. If this function gains lots of uses, it might 856 * kernel virtual memory, offsets up to 4095 bytes can be accommodated.
596 * make sense to provide versions for each flavor of RCU, but it does 857 * If the offset is larger than 4095 bytes, a compile-time error will
597 * not make sense as of early 2010. 858 * be generated in __kfree_rcu(). If this error is triggered, you can
859 * either fall back to use of call_rcu() or rearrange the structure to
860 * position the rcu_head structure into the first 4096 bytes.
861 *
862 * Note that the allowable offset might decrease in the future, for example,
863 * to allow something like kmem_cache_free_rcu().
598 */ 864 */
599#define rcu_dereference_index_check(p, c) \ 865#define kfree_rcu(ptr, rcu_head) \
600 __rcu_dereference_index_check((p), (c)) 866 __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
601 867
602#endif /* __LINUX_RCUPDATE_H */ 868#endif /* __LINUX_RCUPDATE_H */
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index e2e893144a84..52b3e0281fd0 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -27,116 +27,125 @@
27 27
28#include <linux/cache.h> 28#include <linux/cache.h>
29 29
30void rcu_sched_qs(int cpu); 30static inline void rcu_init(void)
31void rcu_bh_qs(int cpu);
32static inline void rcu_note_context_switch(int cpu)
33{ 31{
34 rcu_sched_qs(cpu);
35} 32}
36 33
37#define __rcu_read_lock() preempt_disable() 34#ifdef CONFIG_TINY_RCU
38#define __rcu_read_unlock() preempt_enable()
39#define __rcu_read_lock_bh() local_bh_disable()
40#define __rcu_read_unlock_bh() local_bh_enable()
41#define call_rcu_sched call_rcu
42
43#define rcu_init_sched() do { } while (0)
44extern void rcu_check_callbacks(int cpu, int user);
45 35
46static inline int rcu_needs_cpu(int cpu) 36static inline void synchronize_rcu_expedited(void)
47{ 37{
48 return 0; 38 synchronize_sched(); /* Only one CPU, so pretty fast anyway!!! */
49} 39}
50 40
51/* 41static inline void rcu_barrier(void)
52 * Return the number of grace periods.
53 */
54static inline long rcu_batches_completed(void)
55{ 42{
56 return 0; 43 rcu_barrier_sched(); /* Only one CPU, so only one list of callbacks! */
57} 44}
58 45
59/* 46#else /* #ifdef CONFIG_TINY_RCU */
60 * Return the number of bottom-half grace periods.
61 */
62static inline long rcu_batches_completed_bh(void)
63{
64 return 0;
65}
66 47
67static inline void rcu_force_quiescent_state(void) 48void rcu_barrier(void);
49void synchronize_rcu_expedited(void);
50
51#endif /* #else #ifdef CONFIG_TINY_RCU */
52
53static inline void synchronize_rcu_bh(void)
68{ 54{
55 synchronize_sched();
69} 56}
70 57
71static inline void rcu_bh_force_quiescent_state(void) 58static inline void synchronize_rcu_bh_expedited(void)
72{ 59{
60 synchronize_sched();
73} 61}
74 62
75static inline void rcu_sched_force_quiescent_state(void) 63static inline void synchronize_sched_expedited(void)
76{ 64{
65 synchronize_sched();
77} 66}
78 67
79extern void synchronize_sched(void); 68#ifdef CONFIG_TINY_RCU
80 69
81static inline void synchronize_rcu(void) 70static inline void rcu_preempt_note_context_switch(void)
82{ 71{
83 synchronize_sched();
84} 72}
85 73
86static inline void synchronize_rcu_bh(void) 74static inline void exit_rcu(void)
87{ 75{
88 synchronize_sched();
89} 76}
90 77
91static inline void synchronize_rcu_expedited(void) 78static inline int rcu_needs_cpu(int cpu)
92{ 79{
93 synchronize_sched(); 80 return 0;
94} 81}
95 82
96static inline void synchronize_rcu_bh_expedited(void) 83#else /* #ifdef CONFIG_TINY_RCU */
84
85void rcu_preempt_note_context_switch(void);
86extern void exit_rcu(void);
87int rcu_preempt_needs_cpu(void);
88
89static inline int rcu_needs_cpu(int cpu)
97{ 90{
98 synchronize_sched(); 91 return rcu_preempt_needs_cpu();
99} 92}
100 93
101struct notifier_block; 94#endif /* #else #ifdef CONFIG_TINY_RCU */
102 95
103#ifdef CONFIG_NO_HZ 96static inline void rcu_note_context_switch(int cpu)
97{
98 rcu_sched_qs(cpu);
99 rcu_preempt_note_context_switch();
100}
104 101
105extern void rcu_enter_nohz(void); 102/*
106extern void rcu_exit_nohz(void); 103 * Take advantage of the fact that there is only one CPU, which
104 * allows us to ignore virtualization-based context switches.
105 */
106static inline void rcu_virt_note_context_switch(int cpu)
107{
108}
107 109
108#else /* #ifdef CONFIG_NO_HZ */ 110/*
111 * Return the number of grace periods.
112 */
113static inline long rcu_batches_completed(void)
114{
115 return 0;
116}
109 117
110static inline void rcu_enter_nohz(void) 118/*
119 * Return the number of bottom-half grace periods.
120 */
121static inline long rcu_batches_completed_bh(void)
111{ 122{
123 return 0;
112} 124}
113 125
114static inline void rcu_exit_nohz(void) 126static inline void rcu_force_quiescent_state(void)
115{ 127{
116} 128}
117 129
118#endif /* #else #ifdef CONFIG_NO_HZ */ 130static inline void rcu_bh_force_quiescent_state(void)
131{
132}
119 133
120static inline void exit_rcu(void) 134static inline void rcu_sched_force_quiescent_state(void)
121{ 135{
122} 136}
123 137
124static inline int rcu_preempt_depth(void) 138static inline void rcu_cpu_stall_reset(void)
125{ 139{
126 return 0;
127} 140}
128 141
129#ifdef CONFIG_DEBUG_LOCK_ALLOC 142#ifdef CONFIG_DEBUG_LOCK_ALLOC
130
131extern int rcu_scheduler_active __read_mostly; 143extern int rcu_scheduler_active __read_mostly;
132extern void rcu_scheduler_starting(void); 144extern void rcu_scheduler_starting(void);
133
134#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ 145#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
135
136static inline void rcu_scheduler_starting(void) 146static inline void rcu_scheduler_starting(void)
137{ 147{
138} 148}
139
140#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ 149#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
141 150
142#endif /* __LINUX_RCUTINY_H */ 151#endif /* __LINUX_RCUTINY_H */
diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
index c0ed1c056f29..e65d06634dd8 100644
--- a/include/linux/rcutree.h
+++ b/include/linux/rcutree.h
@@ -30,64 +30,35 @@
30#ifndef __LINUX_RCUTREE_H 30#ifndef __LINUX_RCUTREE_H
31#define __LINUX_RCUTREE_H 31#define __LINUX_RCUTREE_H
32 32
33struct notifier_block; 33extern void rcu_init(void);
34
35extern void rcu_sched_qs(int cpu);
36extern void rcu_bh_qs(int cpu);
37extern void rcu_note_context_switch(int cpu); 34extern void rcu_note_context_switch(int cpu);
38extern int rcu_needs_cpu(int cpu); 35extern int rcu_needs_cpu(int cpu);
39 36extern void rcu_cpu_stall_reset(void);
40#ifdef CONFIG_TREE_PREEMPT_RCU
41
42extern void __rcu_read_lock(void);
43extern void __rcu_read_unlock(void);
44extern void synchronize_rcu(void);
45extern void exit_rcu(void);
46 37
47/* 38/*
48 * Defined as macro as it is a very low level header 39 * Note a virtualization-based context switch. This is simply a
49 * included from areas that don't even know about current 40 * wrapper around rcu_note_context_switch(), which allows TINY_RCU
41 * to save a few bytes.
50 */ 42 */
51#define rcu_preempt_depth() (current->rcu_read_lock_nesting) 43static inline void rcu_virt_note_context_switch(int cpu)
52
53#else /* #ifdef CONFIG_TREE_PREEMPT_RCU */
54
55static inline void __rcu_read_lock(void)
56{ 44{
57 preempt_disable(); 45 rcu_note_context_switch(cpu);
58} 46}
59 47
60static inline void __rcu_read_unlock(void) 48#ifdef CONFIG_TREE_PREEMPT_RCU
61{
62 preempt_enable();
63}
64 49
65#define synchronize_rcu synchronize_sched 50extern void exit_rcu(void);
66 51
67static inline void exit_rcu(void) 52#else /* #ifdef CONFIG_TREE_PREEMPT_RCU */
68{
69}
70 53
71static inline int rcu_preempt_depth(void) 54static inline void exit_rcu(void)
72{ 55{
73 return 0;
74} 56}
75 57
76#endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */ 58#endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */
77 59
78static inline void __rcu_read_lock_bh(void)
79{
80 local_bh_disable();
81}
82static inline void __rcu_read_unlock_bh(void)
83{
84 local_bh_enable();
85}
86
87extern void call_rcu_sched(struct rcu_head *head,
88 void (*func)(struct rcu_head *rcu));
89extern void synchronize_rcu_bh(void); 60extern void synchronize_rcu_bh(void);
90extern void synchronize_sched(void); 61extern void synchronize_sched_expedited(void);
91extern void synchronize_rcu_expedited(void); 62extern void synchronize_rcu_expedited(void);
92 63
93static inline void synchronize_rcu_bh_expedited(void) 64static inline void synchronize_rcu_bh_expedited(void)
@@ -95,27 +66,18 @@ static inline void synchronize_rcu_bh_expedited(void)
95 synchronize_sched_expedited(); 66 synchronize_sched_expedited();
96} 67}
97 68
98extern void rcu_check_callbacks(int cpu, int user); 69extern void rcu_barrier(void);
99 70
71extern unsigned long rcutorture_testseq;
72extern unsigned long rcutorture_vernum;
100extern long rcu_batches_completed(void); 73extern long rcu_batches_completed(void);
101extern long rcu_batches_completed_bh(void); 74extern long rcu_batches_completed_bh(void);
102extern long rcu_batches_completed_sched(void); 75extern long rcu_batches_completed_sched(void);
76
103extern void rcu_force_quiescent_state(void); 77extern void rcu_force_quiescent_state(void);
104extern void rcu_bh_force_quiescent_state(void); 78extern void rcu_bh_force_quiescent_state(void);
105extern void rcu_sched_force_quiescent_state(void); 79extern void rcu_sched_force_quiescent_state(void);
106 80
107#ifdef CONFIG_NO_HZ
108void rcu_enter_nohz(void);
109void rcu_exit_nohz(void);
110#else /* CONFIG_NO_HZ */
111static inline void rcu_enter_nohz(void)
112{
113}
114static inline void rcu_exit_nohz(void)
115{
116}
117#endif /* CONFIG_NO_HZ */
118
119/* A context switch is a grace period for RCU-sched and RCU-bh. */ 81/* A context switch is a grace period for RCU-sched and RCU-bh. */
120static inline int rcu_blocking_is_gp(void) 82static inline int rcu_blocking_is_gp(void)
121{ 83{
diff --git a/include/linux/rds.h b/include/linux/rds.h
index 24bce3ded9ea..91950950aa59 100644
--- a/include/linux/rds.h
+++ b/include/linux/rds.h
@@ -36,15 +36,6 @@
36 36
37#include <linux/types.h> 37#include <linux/types.h>
38 38
39/* These sparse annotated types shouldn't be in any user
40 * visible header file. We should clean this up rather
41 * than kludging around them. */
42#ifndef __KERNEL__
43#define __be16 u_int16_t
44#define __be32 u_int32_t
45#define __be64 u_int64_t
46#endif
47
48#define RDS_IB_ABI_VERSION 0x301 39#define RDS_IB_ABI_VERSION 0x301
49 40
50/* 41/*
@@ -82,6 +73,10 @@
82#define RDS_CMSG_RDMA_MAP 3 73#define RDS_CMSG_RDMA_MAP 3
83#define RDS_CMSG_RDMA_STATUS 4 74#define RDS_CMSG_RDMA_STATUS 4
84#define RDS_CMSG_CONG_UPDATE 5 75#define RDS_CMSG_CONG_UPDATE 5
76#define RDS_CMSG_ATOMIC_FADD 6
77#define RDS_CMSG_ATOMIC_CSWP 7
78#define RDS_CMSG_MASKED_ATOMIC_FADD 8
79#define RDS_CMSG_MASKED_ATOMIC_CSWP 9
85 80
86#define RDS_INFO_FIRST 10000 81#define RDS_INFO_FIRST 10000
87#define RDS_INFO_COUNTERS 10000 82#define RDS_INFO_COUNTERS 10000
@@ -98,9 +93,9 @@
98#define RDS_INFO_LAST 10010 93#define RDS_INFO_LAST 10010
99 94
100struct rds_info_counter { 95struct rds_info_counter {
101 u_int8_t name[32]; 96 uint8_t name[32];
102 u_int64_t value; 97 uint64_t value;
103} __packed; 98} __attribute__((packed));
104 99
105#define RDS_INFO_CONNECTION_FLAG_SENDING 0x01 100#define RDS_INFO_CONNECTION_FLAG_SENDING 0x01
106#define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02 101#define RDS_INFO_CONNECTION_FLAG_CONNECTING 0x02
@@ -109,56 +104,48 @@ struct rds_info_counter {
109#define TRANSNAMSIZ 16 104#define TRANSNAMSIZ 16
110 105
111struct rds_info_connection { 106struct rds_info_connection {
112 u_int64_t next_tx_seq; 107 uint64_t next_tx_seq;
113 u_int64_t next_rx_seq; 108 uint64_t next_rx_seq;
114 __be32 laddr;
115 __be32 faddr;
116 u_int8_t transport[TRANSNAMSIZ]; /* null term ascii */
117 u_int8_t flags;
118} __packed;
119
120struct rds_info_flow {
121 __be32 laddr; 109 __be32 laddr;
122 __be32 faddr; 110 __be32 faddr;
123 u_int32_t bytes; 111 uint8_t transport[TRANSNAMSIZ]; /* null term ascii */
124 __be16 lport; 112 uint8_t flags;
125 __be16 fport; 113} __attribute__((packed));
126} __packed;
127 114
128#define RDS_INFO_MESSAGE_FLAG_ACK 0x01 115#define RDS_INFO_MESSAGE_FLAG_ACK 0x01
129#define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02 116#define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02
130 117
131struct rds_info_message { 118struct rds_info_message {
132 u_int64_t seq; 119 uint64_t seq;
133 u_int32_t len; 120 uint32_t len;
134 __be32 laddr; 121 __be32 laddr;
135 __be32 faddr; 122 __be32 faddr;
136 __be16 lport; 123 __be16 lport;
137 __be16 fport; 124 __be16 fport;
138 u_int8_t flags; 125 uint8_t flags;
139} __packed; 126} __attribute__((packed));
140 127
141struct rds_info_socket { 128struct rds_info_socket {
142 u_int32_t sndbuf; 129 uint32_t sndbuf;
143 __be32 bound_addr; 130 __be32 bound_addr;
144 __be32 connected_addr; 131 __be32 connected_addr;
145 __be16 bound_port; 132 __be16 bound_port;
146 __be16 connected_port; 133 __be16 connected_port;
147 u_int32_t rcvbuf; 134 uint32_t rcvbuf;
148 u_int64_t inum; 135 uint64_t inum;
149} __packed; 136} __attribute__((packed));
150 137
151struct rds_info_tcp_socket { 138struct rds_info_tcp_socket {
152 __be32 local_addr; 139 __be32 local_addr;
153 __be16 local_port; 140 __be16 local_port;
154 __be32 peer_addr; 141 __be32 peer_addr;
155 __be16 peer_port; 142 __be16 peer_port;
156 u_int64_t hdr_rem; 143 uint64_t hdr_rem;
157 u_int64_t data_rem; 144 uint64_t data_rem;
158 u_int32_t last_sent_nxt; 145 uint32_t last_sent_nxt;
159 u_int32_t last_expected_una; 146 uint32_t last_expected_una;
160 u_int32_t last_seen_una; 147 uint32_t last_seen_una;
161} __packed; 148} __attribute__((packed));
162 149
163#define RDS_IB_GID_LEN 16 150#define RDS_IB_GID_LEN 16
164struct rds_info_rdma_connection { 151struct rds_info_rdma_connection {
@@ -212,42 +199,69 @@ struct rds_info_rdma_connection {
212 * (so that the application does not have to worry about 199 * (so that the application does not have to worry about
213 * alignment). 200 * alignment).
214 */ 201 */
215typedef u_int64_t rds_rdma_cookie_t; 202typedef uint64_t rds_rdma_cookie_t;
216 203
217struct rds_iovec { 204struct rds_iovec {
218 u_int64_t addr; 205 uint64_t addr;
219 u_int64_t bytes; 206 uint64_t bytes;
220}; 207};
221 208
222struct rds_get_mr_args { 209struct rds_get_mr_args {
223 struct rds_iovec vec; 210 struct rds_iovec vec;
224 u_int64_t cookie_addr; 211 uint64_t cookie_addr;
225 uint64_t flags; 212 uint64_t flags;
226}; 213};
227 214
228struct rds_get_mr_for_dest_args { 215struct rds_get_mr_for_dest_args {
229 struct sockaddr_storage dest_addr; 216 struct sockaddr_storage dest_addr;
230 struct rds_iovec vec; 217 struct rds_iovec vec;
231 u_int64_t cookie_addr; 218 uint64_t cookie_addr;
232 uint64_t flags; 219 uint64_t flags;
233}; 220};
234 221
235struct rds_free_mr_args { 222struct rds_free_mr_args {
236 rds_rdma_cookie_t cookie; 223 rds_rdma_cookie_t cookie;
237 u_int64_t flags; 224 uint64_t flags;
238}; 225};
239 226
240struct rds_rdma_args { 227struct rds_rdma_args {
241 rds_rdma_cookie_t cookie; 228 rds_rdma_cookie_t cookie;
242 struct rds_iovec remote_vec; 229 struct rds_iovec remote_vec;
243 u_int64_t local_vec_addr; 230 uint64_t local_vec_addr;
244 u_int64_t nr_local; 231 uint64_t nr_local;
245 u_int64_t flags; 232 uint64_t flags;
246 u_int64_t user_token; 233 uint64_t user_token;
234};
235
236struct rds_atomic_args {
237 rds_rdma_cookie_t cookie;
238 uint64_t local_addr;
239 uint64_t remote_addr;
240 union {
241 struct {
242 uint64_t compare;
243 uint64_t swap;
244 } cswp;
245 struct {
246 uint64_t add;
247 } fadd;
248 struct {
249 uint64_t compare;
250 uint64_t swap;
251 uint64_t compare_mask;
252 uint64_t swap_mask;
253 } m_cswp;
254 struct {
255 uint64_t add;
256 uint64_t nocarry_mask;
257 } m_fadd;
258 };
259 uint64_t flags;
260 uint64_t user_token;
247}; 261};
248 262
249struct rds_rdma_notify { 263struct rds_rdma_notify {
250 u_int64_t user_token; 264 uint64_t user_token;
251 int32_t status; 265 int32_t status;
252}; 266};
253 267
@@ -266,5 +280,6 @@ struct rds_rdma_notify {
266#define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */ 280#define RDS_RDMA_USE_ONCE 0x0008 /* free MR after use */
267#define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */ 281#define RDS_RDMA_DONTWAIT 0x0010 /* Don't wait in SET_BARRIER */
268#define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */ 282#define RDS_RDMA_NOTIFY_ME 0x0020 /* Notify when operation completes */
283#define RDS_RDMA_SILENT 0x0040 /* Do not interrupt remote */
269 284
270#endif /* IB_RDS_H */ 285#endif /* IB_RDS_H */
diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h
index f509877c2ed4..76579f964a29 100644
--- a/include/linux/regulator/ab8500.h
+++ b/include/linux/regulator/ab8500.h
@@ -3,23 +3,72 @@
3 * 3 *
4 * License Terms: GNU General Public License v2 4 * License Terms: GNU General Public License v2
5 * 5 *
6 * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson 6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
7 * 7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
8 */ 8 */
9 9
10#ifndef __LINUX_MFD_AB8500_REGULATOR_H 10#ifndef __LINUX_MFD_AB8500_REGULATOR_H
11#define __LINUX_MFD_AB8500_REGULATOR_H 11#define __LINUX_MFD_AB8500_REGULATOR_H
12 12
13/* AB8500 regulators */ 13/* AB8500 regulators */
14#define AB8500_LDO_AUX1 0 14enum ab8500_regulator_id {
15#define AB8500_LDO_AUX2 1 15 AB8500_LDO_AUX1,
16#define AB8500_LDO_AUX3 2 16 AB8500_LDO_AUX2,
17#define AB8500_LDO_INTCORE 3 17 AB8500_LDO_AUX3,
18#define AB8500_LDO_TVOUT 4 18 AB8500_LDO_INTCORE,
19#define AB8500_LDO_AUDIO 5 19 AB8500_LDO_TVOUT,
20#define AB8500_LDO_ANAMIC1 6 20 AB8500_LDO_USB,
21#define AB8500_LDO_ANAMIC2 7 21 AB8500_LDO_AUDIO,
22#define AB8500_LDO_DMIC 8 22 AB8500_LDO_ANAMIC1,
23#define AB8500_LDO_ANA 9 23 AB8500_LDO_ANAMIC2,
24 AB8500_LDO_DMIC,
25 AB8500_LDO_ANA,
26 AB8500_NUM_REGULATORS,
27};
28
29/* AB8500 register initialization */
30struct ab8500_regulator_reg_init {
31 int id;
32 u8 value;
33};
34
35#define INIT_REGULATOR_REGISTER(_id, _value) \
36 { \
37 .id = _id, \
38 .value = _value, \
39 }
40
41/* AB8500 registers */
42enum ab8500_regulator_reg {
43 AB8500_REGUREQUESTCTRL2,
44 AB8500_REGUREQUESTCTRL3,
45 AB8500_REGUREQUESTCTRL4,
46 AB8500_REGUSYSCLKREQ1HPVALID1,
47 AB8500_REGUSYSCLKREQ1HPVALID2,
48 AB8500_REGUHWHPREQ1VALID1,
49 AB8500_REGUHWHPREQ1VALID2,
50 AB8500_REGUHWHPREQ2VALID1,
51 AB8500_REGUHWHPREQ2VALID2,
52 AB8500_REGUSWHPREQVALID1,
53 AB8500_REGUSWHPREQVALID2,
54 AB8500_REGUSYSCLKREQVALID1,
55 AB8500_REGUSYSCLKREQVALID2,
56 AB8500_REGUMISC1,
57 AB8500_VAUDIOSUPPLY,
58 AB8500_REGUCTRL1VAMIC,
59 AB8500_VPLLVANAREGU,
60 AB8500_VREFDDR,
61 AB8500_EXTSUPPLYREGU,
62 AB8500_VAUX12REGU,
63 AB8500_VRF1VAUX3REGU,
64 AB8500_VAUX1SEL,
65 AB8500_VAUX2SEL,
66 AB8500_VRF1VAUX3SEL,
67 AB8500_REGUCTRL2SPARE,
68 AB8500_REGUCTRLDISCH,
69 AB8500_REGUCTRLDISCH2,
70 AB8500_VSMPS1SEL1,
71 AB8500_NUM_REGULATOR_REGISTERS,
72};
24 73
25#endif 74#endif
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index ebd747265294..9e87c1cb7270 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -153,7 +153,10 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector);
153int regulator_is_supported_voltage(struct regulator *regulator, 153int regulator_is_supported_voltage(struct regulator *regulator,
154 int min_uV, int max_uV); 154 int min_uV, int max_uV);
155int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); 155int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
156int regulator_set_voltage_time(struct regulator *regulator,
157 int old_uV, int new_uV);
156int regulator_get_voltage(struct regulator *regulator); 158int regulator_get_voltage(struct regulator *regulator);
159int regulator_sync_voltage(struct regulator *regulator);
157int regulator_set_current_limit(struct regulator *regulator, 160int regulator_set_current_limit(struct regulator *regulator,
158 int min_uA, int max_uA); 161 int min_uA, int max_uA);
159int regulator_get_current_limit(struct regulator *regulator); 162int regulator_get_current_limit(struct regulator *regulator);
diff --git a/include/linux/regulator/db8500-prcmu.h b/include/linux/regulator/db8500-prcmu.h
new file mode 100644
index 000000000000..612062313b68
--- /dev/null
+++ b/include/linux/regulator/db8500-prcmu.h
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 *
6 * Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
7 *
8 * Interface to power domain regulators on DB8500
9 */
10
11#ifndef __REGULATOR_H__
12#define __REGULATOR_H__
13
14/* Number of DB8500 regulators and regulator enumeration */
15enum db8500_regulator_id {
16 DB8500_REGULATOR_VAPE,
17 DB8500_REGULATOR_VARM,
18 DB8500_REGULATOR_VMODEM,
19 DB8500_REGULATOR_VPLL,
20 DB8500_REGULATOR_VSMPS1,
21 DB8500_REGULATOR_VSMPS2,
22 DB8500_REGULATOR_VSMPS3,
23 DB8500_REGULATOR_VRF1,
24 DB8500_REGULATOR_SWITCH_SVAMMDSP,
25 DB8500_REGULATOR_SWITCH_SVAMMDSPRET,
26 DB8500_REGULATOR_SWITCH_SVAPIPE,
27 DB8500_REGULATOR_SWITCH_SIAMMDSP,
28 DB8500_REGULATOR_SWITCH_SIAMMDSPRET,
29 DB8500_REGULATOR_SWITCH_SIAPIPE,
30 DB8500_REGULATOR_SWITCH_SGA,
31 DB8500_REGULATOR_SWITCH_B2R2_MCDE,
32 DB8500_REGULATOR_SWITCH_ESRAM12,
33 DB8500_REGULATOR_SWITCH_ESRAM12RET,
34 DB8500_REGULATOR_SWITCH_ESRAM34,
35 DB8500_REGULATOR_SWITCH_ESRAM34RET,
36 DB8500_NUM_REGULATORS
37};
38
39/*
40 * Exported interface for CPUIdle only. This function is called with all
41 * interrupts turned off.
42 */
43int power_state_active_is_enabled(void);
44
45#endif
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 592cd7c642c2..6c433b89c80d 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -42,7 +42,11 @@ enum regulator_status {
42 * 42 *
43 * @set_voltage: Set the voltage for the regulator within the range specified. 43 * @set_voltage: Set the voltage for the regulator within the range specified.
44 * The driver should select the voltage closest to min_uV. 44 * The driver should select the voltage closest to min_uV.
45 * @set_voltage_sel: Set the voltage for the regulator using the specified
46 * selector.
45 * @get_voltage: Return the currently configured voltage for the regulator. 47 * @get_voltage: Return the currently configured voltage for the regulator.
48 * @get_voltage_sel: Return the currently configured voltage selector for the
49 * regulator.
46 * @list_voltage: Return one of the supported voltages, in microvolts; zero 50 * @list_voltage: Return one of the supported voltages, in microvolts; zero
47 * if the selector indicates a voltage that is unusable on this system; 51 * if the selector indicates a voltage that is unusable on this system;
48 * or negative errno. Selectors range from zero to one less than 52 * or negative errno. Selectors range from zero to one less than
@@ -59,7 +63,11 @@ enum regulator_status {
59 * when running with the specified parameters. 63 * when running with the specified parameters.
60 * 64 *
61 * @enable_time: Time taken for the regulator voltage output voltage to 65 * @enable_time: Time taken for the regulator voltage output voltage to
62 * stabalise after being enabled, in microseconds. 66 * stabilise after being enabled, in microseconds.
67 * @set_voltage_time_sel: Time taken for the regulator voltage output voltage
68 * to stabilise after being set to a new value, in microseconds.
69 * The function provides the from and to voltage selector, the
70 * function should return the worst case.
63 * 71 *
64 * @set_suspend_voltage: Set the voltage for the regulator when the system 72 * @set_suspend_voltage: Set the voltage for the regulator when the system
65 * is suspended. 73 * is suspended.
@@ -79,8 +87,11 @@ struct regulator_ops {
79 int (*list_voltage) (struct regulator_dev *, unsigned selector); 87 int (*list_voltage) (struct regulator_dev *, unsigned selector);
80 88
81 /* get/set regulator voltage */ 89 /* get/set regulator voltage */
82 int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV); 90 int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV,
91 unsigned *selector);
92 int (*set_voltage_sel) (struct regulator_dev *, unsigned selector);
83 int (*get_voltage) (struct regulator_dev *); 93 int (*get_voltage) (struct regulator_dev *);
94 int (*get_voltage_sel) (struct regulator_dev *);
84 95
85 /* get/set regulator current */ 96 /* get/set regulator current */
86 int (*set_current_limit) (struct regulator_dev *, 97 int (*set_current_limit) (struct regulator_dev *,
@@ -96,8 +107,11 @@ struct regulator_ops {
96 int (*set_mode) (struct regulator_dev *, unsigned int mode); 107 int (*set_mode) (struct regulator_dev *, unsigned int mode);
97 unsigned int (*get_mode) (struct regulator_dev *); 108 unsigned int (*get_mode) (struct regulator_dev *);
98 109
99 /* Time taken to enable the regulator */ 110 /* Time taken to enable or set voltage on the regulator */
100 int (*enable_time) (struct regulator_dev *); 111 int (*enable_time) (struct regulator_dev *);
112 int (*set_voltage_time_sel) (struct regulator_dev *,
113 unsigned int old_selector,
114 unsigned int new_selector);
101 115
102 /* report regulator status ... most other accessors report 116 /* report regulator status ... most other accessors report
103 * control inputs, this reports results of combining inputs 117 * control inputs, this reports results of combining inputs
@@ -168,9 +182,9 @@ struct regulator_desc {
168 */ 182 */
169struct regulator_dev { 183struct regulator_dev {
170 struct regulator_desc *desc; 184 struct regulator_desc *desc;
171 int use_count;
172 int open_count;
173 int exclusive; 185 int exclusive;
186 u32 use_count;
187 u32 open_count;
174 188
175 /* lists we belong to */ 189 /* lists we belong to */
176 struct list_head list; /* list of all regulators */ 190 struct list_head list; /* list of all regulators */
@@ -188,10 +202,14 @@ struct regulator_dev {
188 struct regulator_dev *supply; /* for tree */ 202 struct regulator_dev *supply; /* for tree */
189 203
190 void *reg_data; /* regulator_dev data */ 204 void *reg_data; /* regulator_dev data */
205
206#ifdef CONFIG_DEBUG_FS
207 struct dentry *debugfs;
208#endif
191}; 209};
192 210
193struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, 211struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
194 struct device *dev, struct regulator_init_data *init_data, 212 struct device *dev, const struct regulator_init_data *init_data,
195 void *driver_data); 213 void *driver_data);
196void regulator_unregister(struct regulator_dev *rdev); 214void regulator_unregister(struct regulator_dev *rdev);
197 215
diff --git a/include/linux/regulator/lp3972.h b/include/linux/regulator/lp3972.h
new file mode 100644
index 000000000000..9bb7389b7a1e
--- /dev/null
+++ b/include/linux/regulator/lp3972.h
@@ -0,0 +1,48 @@
1/*
2 * National Semiconductors LP3972 PMIC chip client interface
3 *
4 * Based on lp3971.h
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef __LINUX_REGULATOR_LP3972_H
22#define __LINUX_REGULATOR_LP3972_H
23
24#include <linux/regulator/machine.h>
25
26#define LP3972_LDO1 0
27#define LP3972_LDO2 1
28#define LP3972_LDO3 2
29#define LP3972_LDO4 3
30#define LP3972_LDO5 4
31
32#define LP3972_DCDC1 5
33#define LP3972_DCDC2 6
34#define LP3972_DCDC3 7
35
36#define LP3972_NUM_REGULATORS 8
37
38struct lp3972_regulator_subdev {
39 int id;
40 struct regulator_init_data *initdata;
41};
42
43struct lp3972_platform_data {
44 int num_regulators;
45 struct lp3972_regulator_subdev *regulators;
46};
47
48#endif
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index e2980287245e..ce3127a75c88 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -68,6 +68,8 @@ struct regulator_state {
68 * 68 *
69 * @min_uV: Smallest voltage consumers may set. 69 * @min_uV: Smallest voltage consumers may set.
70 * @max_uV: Largest voltage consumers may set. 70 * @max_uV: Largest voltage consumers may set.
71 * @uV_offset: Offset applied to voltages from consumer to compensate for
72 * voltage drops.
71 * 73 *
72 * @min_uA: Smallest consumers consumers may set. 74 * @min_uA: Smallest consumers consumers may set.
73 * @max_uA: Largest current consumers may set. 75 * @max_uA: Largest current consumers may set.
@@ -99,6 +101,8 @@ struct regulation_constraints {
99 int min_uV; 101 int min_uV;
100 int max_uV; 102 int max_uV;
101 103
104 int uV_offset;
105
102 /* current output range (inclusive) - for current control */ 106 /* current output range (inclusive) - for current control */
103 int min_uA; 107 int min_uA;
104 int max_uA; 108 int max_uA;
@@ -160,8 +164,6 @@ struct regulator_consumer_supply {
160 * @supply_regulator: Parent regulator. Specified using the regulator name 164 * @supply_regulator: Parent regulator. Specified using the regulator name
161 * as it appears in the name field in sysfs, which can 165 * as it appears in the name field in sysfs, which can
162 * be explicitly set using the constraints field 'name'. 166 * be explicitly set using the constraints field 'name'.
163 * @supply_regulator_dev: Parent regulator (if any) - DEPRECATED in favour
164 * of supply_regulator.
165 * 167 *
166 * @constraints: Constraints. These must be specified for the regulator to 168 * @constraints: Constraints. These must be specified for the regulator to
167 * be usable. 169 * be usable.
@@ -173,7 +175,6 @@ struct regulator_consumer_supply {
173 */ 175 */
174struct regulator_init_data { 176struct regulator_init_data {
175 const char *supply_regulator; /* or NULL for system supply */ 177 const char *supply_regulator; /* or NULL for system supply */
176 struct device *supply_regulator_dev; /* or NULL for system supply */
177 178
178 struct regulation_constraints constraints; 179 struct regulation_constraints constraints;
179 180
@@ -186,13 +187,19 @@ struct regulator_init_data {
186}; 187};
187 188
188int regulator_suspend_prepare(suspend_state_t state); 189int regulator_suspend_prepare(suspend_state_t state);
190int regulator_suspend_finish(void);
189 191
190#ifdef CONFIG_REGULATOR 192#ifdef CONFIG_REGULATOR
191void regulator_has_full_constraints(void); 193void regulator_has_full_constraints(void);
194void regulator_use_dummy_regulator(void);
192#else 195#else
193static inline void regulator_has_full_constraints(void) 196static inline void regulator_has_full_constraints(void)
194{ 197{
195} 198}
199
200static inline void regulator_use_dummy_regulator(void)
201{
202}
196#endif 203#endif
197 204
198#endif 205#endif
diff --git a/include/linux/regulator/max8952.h b/include/linux/regulator/max8952.h
new file mode 100644
index 000000000000..45e42855ad05
--- /dev/null
+++ b/include/linux/regulator/max8952.h
@@ -0,0 +1,135 @@
1/*
2 * max8952.h - Voltage regulation for the Maxim 8952
3 *
4 * Copyright (C) 2010 Samsung Electrnoics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef REGULATOR_MAX8952
23#define REGULATOR_MAX8952
24
25#include <linux/regulator/machine.h>
26
27enum {
28 MAX8952_DVS_MODE0,
29 MAX8952_DVS_MODE1,
30 MAX8952_DVS_MODE2,
31 MAX8952_DVS_MODE3,
32};
33
34enum {
35 MAX8952_DVS_770mV = 0,
36 MAX8952_DVS_780mV,
37 MAX8952_DVS_790mV,
38 MAX8952_DVS_800mV,
39 MAX8952_DVS_810mV,
40 MAX8952_DVS_820mV,
41 MAX8952_DVS_830mV,
42 MAX8952_DVS_840mV,
43 MAX8952_DVS_850mV,
44 MAX8952_DVS_860mV,
45 MAX8952_DVS_870mV,
46 MAX8952_DVS_880mV,
47 MAX8952_DVS_890mV,
48 MAX8952_DVS_900mV,
49 MAX8952_DVS_910mV,
50 MAX8952_DVS_920mV,
51 MAX8952_DVS_930mV,
52 MAX8952_DVS_940mV,
53 MAX8952_DVS_950mV,
54 MAX8952_DVS_960mV,
55 MAX8952_DVS_970mV,
56 MAX8952_DVS_980mV,
57 MAX8952_DVS_990mV,
58 MAX8952_DVS_1000mV,
59 MAX8952_DVS_1010mV,
60 MAX8952_DVS_1020mV,
61 MAX8952_DVS_1030mV,
62 MAX8952_DVS_1040mV,
63 MAX8952_DVS_1050mV,
64 MAX8952_DVS_1060mV,
65 MAX8952_DVS_1070mV,
66 MAX8952_DVS_1080mV,
67 MAX8952_DVS_1090mV,
68 MAX8952_DVS_1100mV,
69 MAX8952_DVS_1110mV,
70 MAX8952_DVS_1120mV,
71 MAX8952_DVS_1130mV,
72 MAX8952_DVS_1140mV,
73 MAX8952_DVS_1150mV,
74 MAX8952_DVS_1160mV,
75 MAX8952_DVS_1170mV,
76 MAX8952_DVS_1180mV,
77 MAX8952_DVS_1190mV,
78 MAX8952_DVS_1200mV,
79 MAX8952_DVS_1210mV,
80 MAX8952_DVS_1220mV,
81 MAX8952_DVS_1230mV,
82 MAX8952_DVS_1240mV,
83 MAX8952_DVS_1250mV,
84 MAX8952_DVS_1260mV,
85 MAX8952_DVS_1270mV,
86 MAX8952_DVS_1280mV,
87 MAX8952_DVS_1290mV,
88 MAX8952_DVS_1300mV,
89 MAX8952_DVS_1310mV,
90 MAX8952_DVS_1320mV,
91 MAX8952_DVS_1330mV,
92 MAX8952_DVS_1340mV,
93 MAX8952_DVS_1350mV,
94 MAX8952_DVS_1360mV,
95 MAX8952_DVS_1370mV,
96 MAX8952_DVS_1380mV,
97 MAX8952_DVS_1390mV,
98 MAX8952_DVS_1400mV,
99};
100
101enum {
102 MAX8952_SYNC_FREQ_26MHZ, /* Default */
103 MAX8952_SYNC_FREQ_13MHZ,
104 MAX8952_SYNC_FREQ_19_2MHZ,
105};
106
107enum {
108 MAX8952_RAMP_32mV_us = 0, /* Default */
109 MAX8952_RAMP_16mV_us,
110 MAX8952_RAMP_8mV_us,
111 MAX8952_RAMP_4mV_us,
112 MAX8952_RAMP_2mV_us,
113 MAX8952_RAMP_1mV_us,
114 MAX8952_RAMP_0_5mV_us,
115 MAX8952_RAMP_0_25mV_us,
116};
117
118#define MAX8952_NUM_DVS_MODE 4
119
120struct max8952_platform_data {
121 int gpio_vid0;
122 int gpio_vid1;
123 int gpio_en;
124
125 u8 default_mode;
126 u8 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */
127
128 u8 sync_freq;
129 u8 ramp_speed;
130
131 struct regulator_init_data reg_data;
132};
133
134
135#endif /* REGULATOR_MAX8952 */
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 91a4177e60ce..eca75df00fed 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -22,7 +22,6 @@
22#include <asm/unaligned.h> 22#include <asm/unaligned.h>
23#include <linux/bitops.h> 23#include <linux/bitops.h>
24#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
25#include <linux/smp_lock.h>
26#include <linux/buffer_head.h> 25#include <linux/buffer_head.h>
27#include <linux/reiserfs_fs_i.h> 26#include <linux/reiserfs_fs_i.h>
28#include <linux/reiserfs_fs_sb.h> 27#include <linux/reiserfs_fs_sb.h>
@@ -1125,15 +1124,18 @@ struct reiserfs_de_head {
1125# define aligned_address(addr) ((void *)((long)(addr) & ~((1UL << ADDR_UNALIGNED_BITS) - 1))) 1124# define aligned_address(addr) ((void *)((long)(addr) & ~((1UL << ADDR_UNALIGNED_BITS) - 1)))
1126# define unaligned_offset(addr) (((int)((long)(addr) & ((1 << ADDR_UNALIGNED_BITS) - 1))) << 3) 1125# define unaligned_offset(addr) (((int)((long)(addr) & ((1 << ADDR_UNALIGNED_BITS) - 1))) << 3)
1127 1126
1128# define set_bit_unaligned(nr, addr) ext2_set_bit((nr) + unaligned_offset(addr), aligned_address(addr)) 1127# define set_bit_unaligned(nr, addr) \
1129# define clear_bit_unaligned(nr, addr) ext2_clear_bit((nr) + unaligned_offset(addr), aligned_address(addr)) 1128 __test_and_set_bit_le((nr) + unaligned_offset(addr), aligned_address(addr))
1130# define test_bit_unaligned(nr, addr) ext2_test_bit((nr) + unaligned_offset(addr), aligned_address(addr)) 1129# define clear_bit_unaligned(nr, addr) \
1130 __test_and_clear_bit_le((nr) + unaligned_offset(addr), aligned_address(addr))
1131# define test_bit_unaligned(nr, addr) \
1132 test_bit_le((nr) + unaligned_offset(addr), aligned_address(addr))
1131 1133
1132#else 1134#else
1133 1135
1134# define set_bit_unaligned(nr, addr) ext2_set_bit(nr, addr) 1136# define set_bit_unaligned(nr, addr) __test_and_set_bit_le(nr, addr)
1135# define clear_bit_unaligned(nr, addr) ext2_clear_bit(nr, addr) 1137# define clear_bit_unaligned(nr, addr) __test_and_clear_bit_le(nr, addr)
1136# define test_bit_unaligned(nr, addr) ext2_test_bit(nr, addr) 1138# define test_bit_unaligned(nr, addr) test_bit_le(nr, addr)
1137 1139
1138#endif 1140#endif
1139 1141
@@ -1555,7 +1557,7 @@ struct tree_balance {
1555/* When inserting an item. */ 1557/* When inserting an item. */
1556#define M_INSERT 'i' 1558#define M_INSERT 'i'
1557/* When inserting into (directories only) or appending onto an already 1559/* When inserting into (directories only) or appending onto an already
1558 existant item. */ 1560 existent item. */
1559#define M_PASTE 'p' 1561#define M_PASTE 'p'
1560/* When deleting an item. */ 1562/* When deleting an item. */
1561#define M_DELETE 'd' 1563#define M_DELETE 'd'
@@ -2072,6 +2074,8 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
2072void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs); 2074void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
2073int reiserfs_setattr(struct dentry *dentry, struct iattr *attr); 2075int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
2074 2076
2077int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
2078
2075/* namei.c */ 2079/* namei.c */
2076void set_de_name_and_namelen(struct reiserfs_dir_entry *de); 2080void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
2077int search_by_entry_key(struct super_block *sb, const struct cpu_key *key, 2081int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
@@ -2328,14 +2332,10 @@ __u32 keyed_hash(const signed char *msg, int len);
2328__u32 yura_hash(const signed char *msg, int len); 2332__u32 yura_hash(const signed char *msg, int len);
2329__u32 r5_hash(const signed char *msg, int len); 2333__u32 r5_hash(const signed char *msg, int len);
2330 2334
2331/* the ext2 bit routines adjust for big or little endian as 2335#define reiserfs_test_and_set_le_bit __test_and_set_bit_le
2332** appropriate for the arch, so in our laziness we use them rather 2336#define reiserfs_test_and_clear_le_bit __test_and_clear_bit_le
2333** than using the bit routines they call more directly. These 2337#define reiserfs_test_le_bit test_bit_le
2334** routines must be used when changing on disk bitmaps. */ 2338#define reiserfs_find_next_zero_le_bit find_next_zero_bit_le
2335#define reiserfs_test_and_set_le_bit ext2_set_bit
2336#define reiserfs_test_and_clear_le_bit ext2_clear_bit
2337#define reiserfs_test_le_bit ext2_test_bit
2338#define reiserfs_find_next_zero_le_bit ext2_find_next_zero_bit
2339 2339
2340/* sometimes reiserfs_truncate may require to allocate few new blocks 2340/* sometimes reiserfs_truncate may require to allocate few new blocks
2341 to perform indirect2direct conversion. People probably used to 2341 to perform indirect2direct conversion. People probably used to
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index b2cf2089769b..6deef5dc95fb 100644
--- a/include/linux/reiserfs_xattr.h
+++ b/include/linux/reiserfs_xattr.h
@@ -41,7 +41,7 @@ int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
41int reiserfs_lookup_privroot(struct super_block *sb); 41int reiserfs_lookup_privroot(struct super_block *sb);
42int reiserfs_delete_xattrs(struct inode *inode); 42int reiserfs_delete_xattrs(struct inode *inode);
43int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs); 43int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
44int reiserfs_permission(struct inode *inode, int mask); 44int reiserfs_permission(struct inode *inode, int mask, unsigned int flags);
45 45
46#ifdef CONFIG_REISERFS_FS_XATTR 46#ifdef CONFIG_REISERFS_FS_XATTR
47#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) 47#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
@@ -63,6 +63,7 @@ extern const struct xattr_handler reiserfs_xattr_trusted_handler;
63extern const struct xattr_handler reiserfs_xattr_security_handler; 63extern const struct xattr_handler reiserfs_xattr_security_handler;
64#ifdef CONFIG_REISERFS_FS_SECURITY 64#ifdef CONFIG_REISERFS_FS_SECURITY
65int reiserfs_security_init(struct inode *dir, struct inode *inode, 65int reiserfs_security_init(struct inode *dir, struct inode *inode,
66 const struct qstr *qstr,
66 struct reiserfs_security_handle *sec); 67 struct reiserfs_security_handle *sec);
67int reiserfs_security_write(struct reiserfs_transaction_handle *th, 68int reiserfs_security_write(struct reiserfs_transaction_handle *th,
68 struct inode *inode, 69 struct inode *inode,
@@ -130,6 +131,7 @@ static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
130#ifndef CONFIG_REISERFS_FS_SECURITY 131#ifndef CONFIG_REISERFS_FS_SECURITY
131static inline int reiserfs_security_init(struct inode *dir, 132static inline int reiserfs_security_init(struct inode *dir,
132 struct inode *inode, 133 struct inode *inode,
134 const struct qstr *qstr,
133 struct reiserfs_security_handle *sec) 135 struct reiserfs_security_handle *sec)
134{ 136{
135 return 0; 137 return 0;
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index fcb9884df618..c9d625ca659e 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -129,20 +129,22 @@ int __must_check res_counter_charge(struct res_counter *counter,
129void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val); 129void res_counter_uncharge_locked(struct res_counter *counter, unsigned long val);
130void res_counter_uncharge(struct res_counter *counter, unsigned long val); 130void res_counter_uncharge(struct res_counter *counter, unsigned long val);
131 131
132static inline bool res_counter_limit_check_locked(struct res_counter *cnt) 132/**
133{ 133 * res_counter_margin - calculate chargeable space of a counter
134 if (cnt->usage < cnt->limit) 134 * @cnt: the counter
135 return true; 135 *
136 136 * Returns the difference between the hard limit and the current usage
137 return false; 137 * of resource counter @cnt.
138} 138 */
139 139static inline unsigned long long res_counter_margin(struct res_counter *cnt)
140static inline bool res_counter_soft_limit_check_locked(struct res_counter *cnt)
141{ 140{
142 if (cnt->usage < cnt->soft_limit) 141 unsigned long long margin;
143 return true; 142 unsigned long flags;
144 143
145 return false; 144 spin_lock_irqsave(&cnt->lock, flags);
145 margin = cnt->limit - cnt->usage;
146 spin_unlock_irqrestore(&cnt->lock, flags);
147 return margin;
146} 148}
147 149
148/** 150/**
@@ -167,32 +169,6 @@ res_counter_soft_limit_excess(struct res_counter *cnt)
167 return excess; 169 return excess;
168} 170}
169 171
170/*
171 * Helper function to detect if the cgroup is within it's limit or
172 * not. It's currently called from cgroup_rss_prepare()
173 */
174static inline bool res_counter_check_under_limit(struct res_counter *cnt)
175{
176 bool ret;
177 unsigned long flags;
178
179 spin_lock_irqsave(&cnt->lock, flags);
180 ret = res_counter_limit_check_locked(cnt);
181 spin_unlock_irqrestore(&cnt->lock, flags);
182 return ret;
183}
184
185static inline bool res_counter_check_under_soft_limit(struct res_counter *cnt)
186{
187 bool ret;
188 unsigned long flags;
189
190 spin_lock_irqsave(&cnt->lock, flags);
191 ret = res_counter_soft_limit_check_locked(cnt);
192 spin_unlock_irqrestore(&cnt->lock, flags);
193 return ret;
194}
195
196static inline void res_counter_reset_max(struct res_counter *cnt) 172static inline void res_counter_reset_max(struct res_counter *cnt)
197{ 173{
198 unsigned long flags; 174 unsigned long flags;
diff --git a/include/linux/resource.h b/include/linux/resource.h
index 88d36f9145ba..d01c96c1966e 100644
--- a/include/linux/resource.h
+++ b/include/linux/resource.h
@@ -2,6 +2,7 @@
2#define _LINUX_RESOURCE_H 2#define _LINUX_RESOURCE_H
3 3
4#include <linux/time.h> 4#include <linux/time.h>
5#include <linux/types.h>
5 6
6/* 7/*
7 * Resource control/accounting header file for linux 8 * Resource control/accounting header file for linux
diff --git a/include/linux/resume-trace.h b/include/linux/resume-trace.h
index bc8c3881c729..f31db2368782 100644
--- a/include/linux/resume-trace.h
+++ b/include/linux/resume-trace.h
@@ -3,6 +3,7 @@
3 3
4#ifdef CONFIG_PM_TRACE 4#ifdef CONFIG_PM_TRACE
5#include <asm/resume-trace.h> 5#include <asm/resume-trace.h>
6#include <linux/types.h>
6 7
7extern int pm_trace_enabled; 8extern int pm_trace_enabled;
8 9
@@ -14,6 +15,7 @@ static inline int pm_trace_is_enabled(void)
14struct device; 15struct device;
15extern void set_trace_device(struct device *); 16extern void set_trace_device(struct device *);
16extern void generate_resume_trace(const void *tracedata, unsigned int user); 17extern void generate_resume_trace(const void *tracedata, unsigned int user);
18extern int show_trace_dev_match(char *buf, size_t size);
17 19
18#define TRACE_DEVICE(dev) do { \ 20#define TRACE_DEVICE(dev) do { \
19 if (pm_trace_enabled) \ 21 if (pm_trace_enabled) \
diff --git a/include/linux/rfkill-gpio.h b/include/linux/rfkill-gpio.h
new file mode 100644
index 000000000000..a175d0598033
--- /dev/null
+++ b/include/linux/rfkill-gpio.h
@@ -0,0 +1,43 @@
1/*
2 * Copyright (c) 2011, NVIDIA Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19
20#ifndef __RFKILL_GPIO_H
21#define __RFKILL_GPIO_H
22
23#include <linux/types.h>
24#include <linux/rfkill.h>
25
26/**
27 * struct rfkill_gpio_platform_data - platform data for rfkill gpio device.
28 * for unused gpio's, the expected value is -1.
29 * @name: name for the gpio rf kill instance
30 * @reset_gpio: GPIO which is used for reseting rfkill switch
31 * @shutdown_gpio: GPIO which is used for shutdown of rfkill switch
32 * @power_clk_name: [optional] name of clk to turn off while blocked
33 */
34
35struct rfkill_gpio_platform_data {
36 char *name;
37 int reset_gpio;
38 int shutdown_gpio;
39 const char *power_clk_name;
40 enum rfkill_type type;
41};
42
43#endif /* __RFKILL_GPIO_H */
diff --git a/include/linux/rfkill-regulator.h b/include/linux/rfkill-regulator.h
new file mode 100644
index 000000000000..aca36bc83315
--- /dev/null
+++ b/include/linux/rfkill-regulator.h
@@ -0,0 +1,48 @@
1/*
2 * rfkill-regulator.c - Regulator consumer driver for rfkill
3 *
4 * Copyright (C) 2009 Guiming Zhuo <gmzhuo@gmail.com>
5 * Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12
13#ifndef __LINUX_RFKILL_REGULATOR_H
14#define __LINUX_RFKILL_REGULATOR_H
15
16/*
17 * Use "vrfkill" as supply id when declaring the regulator consumer:
18 *
19 * static struct regulator_consumer_supply pcap_regulator_V6_consumers [] = {
20 * { .dev_name = "rfkill-regulator.0", .supply = "vrfkill" },
21 * };
22 *
23 * If you have several regulator driven rfkill, you can append a numerical id to
24 * .dev_name as done above, and use the same id when declaring the platform
25 * device:
26 *
27 * static struct rfkill_regulator_platform_data ezx_rfkill_bt_data = {
28 * .name = "ezx-bluetooth",
29 * .type = RFKILL_TYPE_BLUETOOTH,
30 * };
31 *
32 * static struct platform_device a910_rfkill = {
33 * .name = "rfkill-regulator",
34 * .id = 0,
35 * .dev = {
36 * .platform_data = &ezx_rfkill_bt_data,
37 * },
38 * };
39 */
40
41#include <linux/rfkill.h>
42
43struct rfkill_regulator_platform_data {
44 char *name; /* the name for the rfkill switch */
45 enum rfkill_type type; /* the type as specified in rfkill.h */
46};
47
48#endif /* __LINUX_RFKILL_REGULATOR_H */
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index 08c32e4f261a..c6c608482cba 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -354,37 +354,6 @@ static inline bool rfkill_blocked(struct rfkill *rfkill)
354} 354}
355#endif /* RFKILL || RFKILL_MODULE */ 355#endif /* RFKILL || RFKILL_MODULE */
356 356
357
358#ifdef CONFIG_RFKILL_LEDS
359/**
360 * rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED.
361 * This function might return a NULL pointer if registering of the
362 * LED trigger failed. Use this as "default_trigger" for the LED.
363 */
364const char *rfkill_get_led_trigger_name(struct rfkill *rfkill);
365
366/**
367 * rfkill_set_led_trigger_name -- set the LED trigger name
368 * @rfkill: rfkill struct
369 * @name: LED trigger name
370 *
371 * This function sets the LED trigger name of the radio LED
372 * trigger that rfkill creates. It is optional, but if called
373 * must be called before rfkill_register() to be effective.
374 */
375void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name);
376#else
377static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill)
378{
379 return NULL;
380}
381
382static inline void
383rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name)
384{
385}
386#endif
387
388#endif /* __KERNEL__ */ 357#endif /* __KERNEL__ */
389 358
390#endif /* RFKILL_H */ 359#endif /* RFKILL_H */
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 25b4f686d918..ab38ac80b0f9 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -62,18 +62,6 @@ enum ring_buffer_type {
62unsigned ring_buffer_event_length(struct ring_buffer_event *event); 62unsigned ring_buffer_event_length(struct ring_buffer_event *event);
63void *ring_buffer_event_data(struct ring_buffer_event *event); 63void *ring_buffer_event_data(struct ring_buffer_event *event);
64 64
65/**
66 * ring_buffer_event_time_delta - return the delta timestamp of the event
67 * @event: the event to get the delta timestamp of
68 *
69 * The delta timestamp is the 27 bit timestamp since the last event.
70 */
71static inline unsigned
72ring_buffer_event_time_delta(struct ring_buffer_event *event)
73{
74 return event->time_delta;
75}
76
77/* 65/*
78 * ring_buffer_discard_commit will remove an event that has not 66 * ring_buffer_discard_commit will remove an event that has not
79 * ben committed yet. If this is used, then ring_buffer_unlock_commit 67 * ben committed yet. If this is used, then ring_buffer_unlock_commit
@@ -112,6 +100,8 @@ void ring_buffer_free(struct ring_buffer *buffer);
112 100
113int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size); 101int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size);
114 102
103void ring_buffer_change_overwrite(struct ring_buffer *buffer, int val);
104
115struct ring_buffer_event *ring_buffer_lock_reserve(struct ring_buffer *buffer, 105struct ring_buffer_event *ring_buffer_lock_reserve(struct ring_buffer *buffer,
116 unsigned long length); 106 unsigned long length);
117int ring_buffer_unlock_commit(struct ring_buffer *buffer, 107int ring_buffer_unlock_commit(struct ring_buffer *buffer,
diff --git a/include/linux/rio.h b/include/linux/rio.h
index bd6eb0ed34a7..4d50611112ba 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -24,6 +24,7 @@
24#define RIO_NO_HOPCOUNT -1 24#define RIO_NO_HOPCOUNT -1
25#define RIO_INVALID_DESTID 0xffff 25#define RIO_INVALID_DESTID 0xffff
26 26
27#define RIO_MAX_MPORTS 8
27#define RIO_MAX_MPORT_RESOURCES 16 28#define RIO_MAX_MPORT_RESOURCES 16
28#define RIO_MAX_DEV_RESOURCES 16 29#define RIO_MAX_DEV_RESOURCES 16
29 30
@@ -66,13 +67,62 @@
66 67
67#define RIO_PW_MSG_SIZE 64 68#define RIO_PW_MSG_SIZE 64
68 69
70/*
71 * A component tag value (stored in the component tag CSR) is used as device's
72 * unique identifier assigned during enumeration. Besides being used for
73 * identifying switches (which do not have device ID register), it also is used
74 * by error management notification and therefore has to be assigned
75 * to endpoints as well.
76 */
77#define RIO_CTAG_RESRVD 0xfffe0000 /* Reserved */
78#define RIO_CTAG_UDEVID 0x0001ffff /* Unique device identifier */
79
69extern struct bus_type rio_bus_type; 80extern struct bus_type rio_bus_type;
81extern struct device rio_bus;
70extern struct list_head rio_devices; /* list of all devices */ 82extern struct list_head rio_devices; /* list of all devices */
71 83
72struct rio_mport; 84struct rio_mport;
85struct rio_dev;
73union rio_pw_msg; 86union rio_pw_msg;
74 87
75/** 88/**
89 * struct rio_switch - RIO switch info
90 * @node: Node in global list of switches
91 * @switchid: Switch ID that is unique across a network
92 * @route_table: Copy of switch routing table
93 * @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0
94 * @add_entry: Callback for switch-specific route add function
95 * @get_entry: Callback for switch-specific route get function
96 * @clr_table: Callback for switch-specific clear route table function
97 * @set_domain: Callback for switch-specific domain setting function
98 * @get_domain: Callback for switch-specific domain get function
99 * @em_init: Callback for switch-specific error management init function
100 * @em_handle: Callback for switch-specific error management handler function
101 * @sw_sysfs: Callback that initializes switch-specific sysfs attributes
102 * @nextdev: Array of per-port pointers to the next attached device
103 */
104struct rio_switch {
105 struct list_head node;
106 u16 switchid;
107 u8 *route_table;
108 u32 port_ok;
109 int (*add_entry) (struct rio_mport *mport, u16 destid, u8 hopcount,
110 u16 table, u16 route_destid, u8 route_port);
111 int (*get_entry) (struct rio_mport *mport, u16 destid, u8 hopcount,
112 u16 table, u16 route_destid, u8 *route_port);
113 int (*clr_table) (struct rio_mport *mport, u16 destid, u8 hopcount,
114 u16 table);
115 int (*set_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
116 u8 sw_domain);
117 int (*get_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
118 u8 *sw_domain);
119 int (*em_init) (struct rio_dev *dev);
120 int (*em_handle) (struct rio_dev *dev, u8 swport);
121 int (*sw_sysfs) (struct rio_dev *dev, int create);
122 struct rio_dev *nextdev[0];
123};
124
125/**
76 * struct rio_dev - RIO device info 126 * struct rio_dev - RIO device info
77 * @global_list: Node in list of all RIO devices 127 * @global_list: Node in list of all RIO devices
78 * @net_list: Node in list of RIO devices in a network 128 * @net_list: Node in list of RIO devices in a network
@@ -92,12 +142,14 @@ union rio_pw_msg;
92 * @phys_efptr: RIO device extended features pointer 142 * @phys_efptr: RIO device extended features pointer
93 * @em_efptr: RIO Error Management features pointer 143 * @em_efptr: RIO Error Management features pointer
94 * @dma_mask: Mask of bits of RIO address this device implements 144 * @dma_mask: Mask of bits of RIO address this device implements
95 * @rswitch: Pointer to &struct rio_switch if valid for this device
96 * @driver: Driver claiming this device 145 * @driver: Driver claiming this device
97 * @dev: Device model device 146 * @dev: Device model device
98 * @riores: RIO resources this device owns 147 * @riores: RIO resources this device owns
99 * @pwcback: port-write callback function for this device 148 * @pwcback: port-write callback function for this device
100 * @destid: Network destination ID 149 * @destid: Network destination ID (or associated destid for switch)
150 * @hopcount: Hopcount to this device
151 * @prev: Previous RIO device connected to the current one
152 * @rswitch: struct rio_switch (if valid for this device)
101 */ 153 */
102struct rio_dev { 154struct rio_dev {
103 struct list_head global_list; /* node in list of all RIO devices */ 155 struct list_head global_list; /* node in list of all RIO devices */
@@ -111,24 +163,27 @@ struct rio_dev {
111 u16 asm_rev; 163 u16 asm_rev;
112 u16 efptr; 164 u16 efptr;
113 u32 pef; 165 u32 pef;
114 u32 swpinfo; /* Only used for switches */ 166 u32 swpinfo;
115 u32 src_ops; 167 u32 src_ops;
116 u32 dst_ops; 168 u32 dst_ops;
117 u32 comp_tag; 169 u32 comp_tag;
118 u32 phys_efptr; 170 u32 phys_efptr;
119 u32 em_efptr; 171 u32 em_efptr;
120 u64 dma_mask; 172 u64 dma_mask;
121 struct rio_switch *rswitch; /* RIO switch info */
122 struct rio_driver *driver; /* RIO driver claiming this device */ 173 struct rio_driver *driver; /* RIO driver claiming this device */
123 struct device dev; /* LDM device structure */ 174 struct device dev; /* LDM device structure */
124 struct resource riores[RIO_MAX_DEV_RESOURCES]; 175 struct resource riores[RIO_MAX_DEV_RESOURCES];
125 int (*pwcback) (struct rio_dev *rdev, union rio_pw_msg *msg, int step); 176 int (*pwcback) (struct rio_dev *rdev, union rio_pw_msg *msg, int step);
126 u16 destid; 177 u16 destid;
178 u8 hopcount;
179 struct rio_dev *prev;
180 struct rio_switch rswitch[0]; /* RIO switch info */
127}; 181};
128 182
129#define rio_dev_g(n) list_entry(n, struct rio_dev, global_list) 183#define rio_dev_g(n) list_entry(n, struct rio_dev, global_list)
130#define rio_dev_f(n) list_entry(n, struct rio_dev, net_list) 184#define rio_dev_f(n) list_entry(n, struct rio_dev, net_list)
131#define to_rio_dev(n) container_of(n, struct rio_dev, dev) 185#define to_rio_dev(n) container_of(n, struct rio_dev, dev)
186#define sw_to_rio_dev(n) container_of(n, struct rio_dev, rswitch[0])
132 187
133/** 188/**
134 * struct rio_msg - RIO message event 189 * struct rio_msg - RIO message event
@@ -174,6 +229,7 @@ enum rio_phy_type {
174 * @index: Port index, unique among all port interfaces of the same type 229 * @index: Port index, unique among all port interfaces of the same type
175 * @sys_size: RapidIO common transport system size 230 * @sys_size: RapidIO common transport system size
176 * @phy_type: RapidIO phy type 231 * @phy_type: RapidIO phy type
232 * @phys_efptr: RIO port extended features pointer
177 * @name: Port name string 233 * @name: Port name string
178 * @priv: Master port private data 234 * @priv: Master port private data
179 */ 235 */
@@ -186,7 +242,7 @@ struct rio_mport {
186 struct rio_msg inb_msg[RIO_MAX_MBOX]; 242 struct rio_msg inb_msg[RIO_MAX_MBOX];
187 struct rio_msg outb_msg[RIO_MAX_MBOX]; 243 struct rio_msg outb_msg[RIO_MAX_MBOX];
188 int host_deviceid; /* Host device ID */ 244 int host_deviceid; /* Host device ID */
189 struct rio_ops *ops; /* maintenance transaction functions */ 245 struct rio_ops *ops; /* low-level architecture-dependent routines */
190 unsigned char id; /* port ID, unique among all ports */ 246 unsigned char id; /* port ID, unique among all ports */
191 unsigned char index; /* port index, unique among all port 247 unsigned char index; /* port index, unique among all port
192 interfaces of the same type */ 248 interfaces of the same type */
@@ -195,6 +251,7 @@ struct rio_mport {
195 * 1 - Large size, 65536 devices. 251 * 1 - Large size, 65536 devices.
196 */ 252 */
197 enum rio_phy_type phy_type; /* RapidIO phy type */ 253 enum rio_phy_type phy_type; /* RapidIO phy type */
254 u32 phys_efptr;
198 unsigned char name[40]; 255 unsigned char name[40];
199 void *priv; /* Master port private data */ 256 void *priv; /* Master port private data */
200}; 257};
@@ -215,42 +272,9 @@ struct rio_net {
215 unsigned char id; /* RIO network ID */ 272 unsigned char id; /* RIO network ID */
216}; 273};
217 274
218/** 275/* Definitions used by switch sysfs initialization callback */
219 * struct rio_switch - RIO switch info 276#define RIO_SW_SYSFS_CREATE 1 /* Create switch attributes */
220 * @node: Node in global list of switches 277#define RIO_SW_SYSFS_REMOVE 0 /* Remove switch attributes */
221 * @switchid: Switch ID that is unique across a network
222 * @hopcount: Hopcount to this switch
223 * @destid: Associated destid in the path
224 * @route_table: Copy of switch routing table
225 * @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0
226 * @add_entry: Callback for switch-specific route add function
227 * @get_entry: Callback for switch-specific route get function
228 * @clr_table: Callback for switch-specific clear route table function
229 * @set_domain: Callback for switch-specific domain setting function
230 * @get_domain: Callback for switch-specific domain get function
231 * @em_init: Callback for switch-specific error management initialization function
232 * @em_handle: Callback for switch-specific error management handler function
233 */
234struct rio_switch {
235 struct list_head node;
236 u16 switchid;
237 u16 hopcount;
238 u16 destid;
239 u8 *route_table;
240 u32 port_ok;
241 int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
242 u16 table, u16 route_destid, u8 route_port);
243 int (*get_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
244 u16 table, u16 route_destid, u8 * route_port);
245 int (*clr_table) (struct rio_mport *mport, u16 destid, u8 hopcount,
246 u16 table);
247 int (*set_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
248 u8 sw_domain);
249 int (*get_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
250 u8 *sw_domain);
251 int (*em_init) (struct rio_dev *dev);
252 int (*em_handle) (struct rio_dev *dev, u8 swport);
253};
254 278
255/* Low-level architecture-dependent routines */ 279/* Low-level architecture-dependent routines */
256 280
@@ -262,6 +286,13 @@ struct rio_switch {
262 * @cwrite: Callback to perform network write of config space. 286 * @cwrite: Callback to perform network write of config space.
263 * @dsend: Callback to send a doorbell message. 287 * @dsend: Callback to send a doorbell message.
264 * @pwenable: Callback to enable/disable port-write message handling. 288 * @pwenable: Callback to enable/disable port-write message handling.
289 * @open_outb_mbox: Callback to initialize outbound mailbox.
290 * @close_outb_mbox: Callback to shut down outbound mailbox.
291 * @open_inb_mbox: Callback to initialize inbound mailbox.
292 * @close_inb_mbox: Callback to shut down inbound mailbox.
293 * @add_outb_message: Callback to add a message to an outbound mailbox queue.
294 * @add_inb_buffer: Callback to add a buffer to an inbound mailbox queue.
295 * @get_inb_message: Callback to get a message from an inbound mailbox queue.
265 */ 296 */
266struct rio_ops { 297struct rio_ops {
267 int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len, 298 int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len,
@@ -274,6 +305,16 @@ struct rio_ops {
274 u8 hopcount, u32 offset, int len, u32 data); 305 u8 hopcount, u32 offset, int len, u32 data);
275 int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data); 306 int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data);
276 int (*pwenable) (struct rio_mport *mport, int enable); 307 int (*pwenable) (struct rio_mport *mport, int enable);
308 int (*open_outb_mbox)(struct rio_mport *mport, void *dev_id,
309 int mbox, int entries);
310 void (*close_outb_mbox)(struct rio_mport *mport, int mbox);
311 int (*open_inb_mbox)(struct rio_mport *mport, void *dev_id,
312 int mbox, int entries);
313 void (*close_inb_mbox)(struct rio_mport *mport, int mbox);
314 int (*add_outb_message)(struct rio_mport *mport, struct rio_dev *rdev,
315 int mbox, void *buffer, size_t len);
316 int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf);
317 void *(*get_inb_message)(struct rio_mport *mport, int mbox);
277}; 318};
278 319
279#define RIO_RESOURCE_MEM 0x00000100 320#define RIO_RESOURCE_MEM 0x00000100
@@ -355,12 +396,7 @@ union rio_pw_msg {
355}; 396};
356 397
357/* Architecture and hardware-specific functions */ 398/* Architecture and hardware-specific functions */
358extern int rio_init_mports(void); 399extern int rio_register_mport(struct rio_mport *);
359extern void rio_register_mport(struct rio_mport *);
360extern int rio_hw_add_outb_message(struct rio_mport *, struct rio_dev *, int,
361 void *, size_t);
362extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *);
363extern void *rio_hw_get_inb_message(struct rio_mport *, int);
364extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int); 400extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int);
365extern void rio_close_inb_mbox(struct rio_mport *, int); 401extern void rio_close_inb_mbox(struct rio_mport *, int);
366extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int); 402extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
diff --git a/include/linux/rio_drv.h b/include/linux/rio_drv.h
index edc55da717b3..229b3ca23134 100644
--- a/include/linux/rio_drv.h
+++ b/include/linux/rio_drv.h
@@ -150,16 +150,8 @@ static inline int rio_local_write_config_8(struct rio_mport *port, u32 offset,
150static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset, 150static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
151 u32 * data) 151 u32 * data)
152{ 152{
153 u8 hopcount = 0xff; 153 return rio_mport_read_config_32(rdev->net->hport, rdev->destid,
154 u16 destid = rdev->destid; 154 rdev->hopcount, offset, data);
155
156 if (rdev->rswitch) {
157 destid = rdev->rswitch->destid;
158 hopcount = rdev->rswitch->hopcount;
159 }
160
161 return rio_mport_read_config_32(rdev->net->hport, destid, hopcount,
162 offset, data);
163}; 155};
164 156
165/** 157/**
@@ -174,16 +166,8 @@ static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
174static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset, 166static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
175 u32 data) 167 u32 data)
176{ 168{
177 u8 hopcount = 0xff; 169 return rio_mport_write_config_32(rdev->net->hport, rdev->destid,
178 u16 destid = rdev->destid; 170 rdev->hopcount, offset, data);
179
180 if (rdev->rswitch) {
181 destid = rdev->rswitch->destid;
182 hopcount = rdev->rswitch->hopcount;
183 }
184
185 return rio_mport_write_config_32(rdev->net->hport, destid, hopcount,
186 offset, data);
187}; 171};
188 172
189/** 173/**
@@ -198,16 +182,8 @@ static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
198static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset, 182static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
199 u16 * data) 183 u16 * data)
200{ 184{
201 u8 hopcount = 0xff; 185 return rio_mport_read_config_16(rdev->net->hport, rdev->destid,
202 u16 destid = rdev->destid; 186 rdev->hopcount, offset, data);
203
204 if (rdev->rswitch) {
205 destid = rdev->rswitch->destid;
206 hopcount = rdev->rswitch->hopcount;
207 }
208
209 return rio_mport_read_config_16(rdev->net->hport, destid, hopcount,
210 offset, data);
211}; 187};
212 188
213/** 189/**
@@ -222,16 +198,8 @@ static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
222static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset, 198static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
223 u16 data) 199 u16 data)
224{ 200{
225 u8 hopcount = 0xff; 201 return rio_mport_write_config_16(rdev->net->hport, rdev->destid,
226 u16 destid = rdev->destid; 202 rdev->hopcount, offset, data);
227
228 if (rdev->rswitch) {
229 destid = rdev->rswitch->destid;
230 hopcount = rdev->rswitch->hopcount;
231 }
232
233 return rio_mport_write_config_16(rdev->net->hport, destid, hopcount,
234 offset, data);
235}; 203};
236 204
237/** 205/**
@@ -245,16 +213,8 @@ static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
245 */ 213 */
246static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data) 214static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
247{ 215{
248 u8 hopcount = 0xff; 216 return rio_mport_read_config_8(rdev->net->hport, rdev->destid,
249 u16 destid = rdev->destid; 217 rdev->hopcount, offset, data);
250
251 if (rdev->rswitch) {
252 destid = rdev->rswitch->destid;
253 hopcount = rdev->rswitch->hopcount;
254 }
255
256 return rio_mport_read_config_8(rdev->net->hport, destid, hopcount,
257 offset, data);
258}; 218};
259 219
260/** 220/**
@@ -268,16 +228,8 @@ static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
268 */ 228 */
269static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data) 229static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data)
270{ 230{
271 u8 hopcount = 0xff; 231 return rio_mport_write_config_8(rdev->net->hport, rdev->destid,
272 u16 destid = rdev->destid; 232 rdev->hopcount, offset, data);
273
274 if (rdev->rswitch) {
275 destid = rdev->rswitch->destid;
276 hopcount = rdev->rswitch->hopcount;
277 }
278
279 return rio_mport_write_config_8(rdev->net->hport, destid, hopcount,
280 offset, data);
281}; 233};
282 234
283extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, 235extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid,
@@ -365,7 +317,8 @@ static inline int rio_add_outb_message(struct rio_mport *mport,
365 struct rio_dev *rdev, int mbox, 317 struct rio_dev *rdev, int mbox,
366 void *buffer, size_t len) 318 void *buffer, size_t len)
367{ 319{
368 return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len); 320 return mport->ops->add_outb_message(mport, rdev, mbox,
321 buffer, len);
369} 322}
370 323
371extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int, 324extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
@@ -384,7 +337,7 @@ extern int rio_release_inb_mbox(struct rio_mport *, int);
384static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox, 337static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
385 void *buffer) 338 void *buffer)
386{ 339{
387 return rio_hw_add_inb_buffer(mport, mbox, buffer); 340 return mport->ops->add_inb_buffer(mport, mbox, buffer);
388} 341}
389 342
390/** 343/**
@@ -396,7 +349,7 @@ static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
396 */ 349 */
397static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox) 350static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
398{ 351{
399 return rio_hw_get_inb_message(mport, mbox); 352 return mport->ops->get_inb_message(mport, mbox);
400} 353}
401 354
402/* Doorbell management */ 355/* Doorbell management */
diff --git a/include/linux/rio_ids.h b/include/linux/rio_ids.h
index db50e1c288b7..0cee0152aca9 100644
--- a/include/linux/rio_ids.h
+++ b/include/linux/rio_ids.h
@@ -34,5 +34,10 @@
34#define RIO_DID_IDTCPS16 0x035b 34#define RIO_DID_IDTCPS16 0x035b
35#define RIO_DID_IDTCPS6Q 0x035f 35#define RIO_DID_IDTCPS6Q 0x035f
36#define RIO_DID_IDTCPS10Q 0x035e 36#define RIO_DID_IDTCPS10Q 0x035e
37#define RIO_DID_IDTCPS1848 0x0374
38#define RIO_DID_IDTCPS1432 0x0375
39#define RIO_DID_IDTCPS1616 0x0379
40#define RIO_DID_IDTVPS1616 0x0377
41#define RIO_DID_IDTSPS1616 0x0378
37 42
38#endif /* LINUX_RIO_IDS_H */ 43#endif /* LINUX_RIO_IDS_H */
diff --git a/include/linux/rio_regs.h b/include/linux/rio_regs.h
index aedee0489fb4..9026b30238f3 100644
--- a/include/linux/rio_regs.h
+++ b/include/linux/rio_regs.h
@@ -14,10 +14,12 @@
14#define LINUX_RIO_REGS_H 14#define LINUX_RIO_REGS_H
15 15
16/* 16/*
17 * In RapidIO, each device has a 2MB configuration space that is 17 * In RapidIO, each device has a 16MB configuration space that is
18 * accessed via maintenance transactions. Portions of configuration 18 * accessed via maintenance transactions. Portions of configuration
19 * space are standardized and/or reserved. 19 * space are standardized and/or reserved.
20 */ 20 */
21#define RIO_MAINT_SPACE_SZ 0x1000000 /* 16MB of RapidIO mainenance space */
22
21#define RIO_DEV_ID_CAR 0x00 /* [I] Device Identity CAR */ 23#define RIO_DEV_ID_CAR 0x00 /* [I] Device Identity CAR */
22#define RIO_DEV_INFO_CAR 0x04 /* [I] Device Information CAR */ 24#define RIO_DEV_INFO_CAR 0x04 /* [I] Device Information CAR */
23#define RIO_ASM_ID_CAR 0x08 /* [I] Assembly Identity CAR */ 25#define RIO_ASM_ID_CAR 0x08 /* [I] Assembly Identity CAR */
@@ -33,6 +35,7 @@
33#define RIO_PEF_MEMORY 0x40000000 /* [I] MMIO */ 35#define RIO_PEF_MEMORY 0x40000000 /* [I] MMIO */
34#define RIO_PEF_PROCESSOR 0x20000000 /* [I] Processor */ 36#define RIO_PEF_PROCESSOR 0x20000000 /* [I] Processor */
35#define RIO_PEF_SWITCH 0x10000000 /* [I] Switch */ 37#define RIO_PEF_SWITCH 0x10000000 /* [I] Switch */
38#define RIO_PEF_MULTIPORT 0x08000000 /* [VI, 2.1] Multiport */
36#define RIO_PEF_INB_MBOX 0x00f00000 /* [II] Mailboxes */ 39#define RIO_PEF_INB_MBOX 0x00f00000 /* [II] Mailboxes */
37#define RIO_PEF_INB_MBOX0 0x00800000 /* [II] Mailbox 0 */ 40#define RIO_PEF_INB_MBOX0 0x00800000 /* [II] Mailbox 0 */
38#define RIO_PEF_INB_MBOX1 0x00400000 /* [II] Mailbox 1 */ 41#define RIO_PEF_INB_MBOX1 0x00400000 /* [II] Mailbox 1 */
@@ -51,6 +54,7 @@
51#define RIO_SWP_INFO_PORT_TOTAL_MASK 0x0000ff00 /* [I] Total number of ports */ 54#define RIO_SWP_INFO_PORT_TOTAL_MASK 0x0000ff00 /* [I] Total number of ports */
52#define RIO_SWP_INFO_PORT_NUM_MASK 0x000000ff /* [I] Maintenance transaction port number */ 55#define RIO_SWP_INFO_PORT_NUM_MASK 0x000000ff /* [I] Maintenance transaction port number */
53#define RIO_GET_TOTAL_PORTS(x) ((x & RIO_SWP_INFO_PORT_TOTAL_MASK) >> 8) 56#define RIO_GET_TOTAL_PORTS(x) ((x & RIO_SWP_INFO_PORT_TOTAL_MASK) >> 8)
57#define RIO_GET_PORT_NUM(x) (x & RIO_SWP_INFO_PORT_NUM_MASK)
54 58
55#define RIO_SRC_OPS_CAR 0x18 /* [I] Source Operations CAR */ 59#define RIO_SRC_OPS_CAR 0x18 /* [I] Source Operations CAR */
56#define RIO_SRC_OPS_READ 0x00008000 /* [I] Read op */ 60#define RIO_SRC_OPS_READ 0x00008000 /* [I] Read op */
@@ -159,6 +163,7 @@
159#define RIO_COMPONENT_TAG_CSR 0x6c /* [III] Component Tag CSR */ 163#define RIO_COMPONENT_TAG_CSR 0x6c /* [III] Component Tag CSR */
160 164
161#define RIO_STD_RTE_CONF_DESTID_SEL_CSR 0x70 165#define RIO_STD_RTE_CONF_DESTID_SEL_CSR 0x70
166#define RIO_STD_RTE_CONF_EXTCFGEN 0x80000000
162#define RIO_STD_RTE_CONF_PORT_SEL_CSR 0x74 167#define RIO_STD_RTE_CONF_PORT_SEL_CSR 0x74
163#define RIO_STD_RTE_DEFAULT_PORT 0x78 168#define RIO_STD_RTE_DEFAULT_PORT 0x78
164 169
@@ -222,15 +227,17 @@
222#define RIO_PORT_GEN_MASTER 0x40000000 227#define RIO_PORT_GEN_MASTER 0x40000000
223#define RIO_PORT_GEN_DISCOVERED 0x20000000 228#define RIO_PORT_GEN_DISCOVERED 0x20000000
224#define RIO_PORT_N_MNT_REQ_CSR(x) (0x0040 + x*0x20) /* 0x0002 */ 229#define RIO_PORT_N_MNT_REQ_CSR(x) (0x0040 + x*0x20) /* 0x0002 */
230#define RIO_MNT_REQ_CMD_RD 0x03 /* Reset-device command */
231#define RIO_MNT_REQ_CMD_IS 0x04 /* Input-status command */
225#define RIO_PORT_N_MNT_RSP_CSR(x) (0x0044 + x*0x20) /* 0x0002 */ 232#define RIO_PORT_N_MNT_RSP_CSR(x) (0x0044 + x*0x20) /* 0x0002 */
226#define RIO_PORT_N_MNT_RSP_RVAL 0x80000000 /* Response Valid */ 233#define RIO_PORT_N_MNT_RSP_RVAL 0x80000000 /* Response Valid */
227#define RIO_PORT_N_MNT_RSP_ASTAT 0x000003e0 /* ackID Status */ 234#define RIO_PORT_N_MNT_RSP_ASTAT 0x000007e0 /* ackID Status */
228#define RIO_PORT_N_MNT_RSP_LSTAT 0x0000001f /* Link Status */ 235#define RIO_PORT_N_MNT_RSP_LSTAT 0x0000001f /* Link Status */
229#define RIO_PORT_N_ACK_STS_CSR(x) (0x0048 + x*0x20) /* 0x0002 */ 236#define RIO_PORT_N_ACK_STS_CSR(x) (0x0048 + x*0x20) /* 0x0002 */
230#define RIO_PORT_N_ACK_CLEAR 0x80000000 237#define RIO_PORT_N_ACK_CLEAR 0x80000000
231#define RIO_PORT_N_ACK_INBOUND 0x1f000000 238#define RIO_PORT_N_ACK_INBOUND 0x3f000000
232#define RIO_PORT_N_ACK_OUTSTAND 0x00001f00 239#define RIO_PORT_N_ACK_OUTSTAND 0x00003f00
233#define RIO_PORT_N_ACK_OUTBOUND 0x0000001f 240#define RIO_PORT_N_ACK_OUTBOUND 0x0000003f
234#define RIO_PORT_N_ERR_STS_CSR(x) (0x0058 + x*0x20) 241#define RIO_PORT_N_ERR_STS_CSR(x) (0x0058 + x*0x20)
235#define RIO_PORT_N_ERR_STS_PW_OUT_ES 0x00010000 /* Output Error-stopped */ 242#define RIO_PORT_N_ERR_STS_PW_OUT_ES 0x00010000 /* Output Error-stopped */
236#define RIO_PORT_N_ERR_STS_PW_INP_ES 0x00000100 /* Input Error-stopped */ 243#define RIO_PORT_N_ERR_STS_PW_INP_ES 0x00000100 /* Input Error-stopped */
@@ -238,7 +245,6 @@
238#define RIO_PORT_N_ERR_STS_PORT_ERR 0x00000004 245#define RIO_PORT_N_ERR_STS_PORT_ERR 0x00000004
239#define RIO_PORT_N_ERR_STS_PORT_OK 0x00000002 246#define RIO_PORT_N_ERR_STS_PORT_OK 0x00000002
240#define RIO_PORT_N_ERR_STS_PORT_UNINIT 0x00000001 247#define RIO_PORT_N_ERR_STS_PORT_UNINIT 0x00000001
241#define RIO_PORT_N_ERR_STS_CLR_MASK 0x07120204
242#define RIO_PORT_N_CTL_CSR(x) (0x005c + x*0x20) 248#define RIO_PORT_N_CTL_CSR(x) (0x005c + x*0x20)
243#define RIO_PORT_N_CTL_PWIDTH 0xc0000000 249#define RIO_PORT_N_CTL_PWIDTH 0xc0000000
244#define RIO_PORT_N_CTL_PWIDTH_1 0x00000000 250#define RIO_PORT_N_CTL_PWIDTH_1 0x00000000
@@ -261,6 +267,10 @@
261#define RIO_EM_EFB_HEADER 0x000 /* Error Management Extensions Block Header */ 267#define RIO_EM_EFB_HEADER 0x000 /* Error Management Extensions Block Header */
262#define RIO_EM_LTL_ERR_DETECT 0x008 /* Logical/Transport Layer Error Detect CSR */ 268#define RIO_EM_LTL_ERR_DETECT 0x008 /* Logical/Transport Layer Error Detect CSR */
263#define RIO_EM_LTL_ERR_EN 0x00c /* Logical/Transport Layer Error Enable CSR */ 269#define RIO_EM_LTL_ERR_EN 0x00c /* Logical/Transport Layer Error Enable CSR */
270#define REM_LTL_ERR_ILLTRAN 0x08000000 /* Illegal Transaction decode */
271#define REM_LTL_ERR_UNSOLR 0x00800000 /* Unsolicited Response */
272#define REM_LTL_ERR_UNSUPTR 0x00400000 /* Unsupported Transaction */
273#define REM_LTL_ERR_IMPSPEC 0x000000ff /* Implementation Specific */
264#define RIO_EM_LTL_HIADDR_CAP 0x010 /* Logical/Transport Layer High Address Capture CSR */ 274#define RIO_EM_LTL_HIADDR_CAP 0x010 /* Logical/Transport Layer High Address Capture CSR */
265#define RIO_EM_LTL_ADDR_CAP 0x014 /* Logical/Transport Layer Address Capture CSR */ 275#define RIO_EM_LTL_ADDR_CAP 0x014 /* Logical/Transport Layer Address Capture CSR */
266#define RIO_EM_LTL_DEVID_CAP 0x018 /* Logical/Transport Layer Device ID Capture CSR */ 276#define RIO_EM_LTL_DEVID_CAP 0x018 /* Logical/Transport Layer Device ID Capture CSR */
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 31b2fd75dcba..2148b122779b 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -7,7 +7,7 @@
7#include <linux/list.h> 7#include <linux/list.h>
8#include <linux/slab.h> 8#include <linux/slab.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/spinlock.h> 10#include <linux/mutex.h>
11#include <linux/memcontrol.h> 11#include <linux/memcontrol.h>
12 12
13/* 13/*
@@ -25,20 +25,17 @@
25 * pointing to this anon_vma once its vma list is empty. 25 * pointing to this anon_vma once its vma list is empty.
26 */ 26 */
27struct anon_vma { 27struct anon_vma {
28 spinlock_t lock; /* Serialize access to vma list */
29 struct anon_vma *root; /* Root of this anon_vma tree */ 28 struct anon_vma *root; /* Root of this anon_vma tree */
30#if defined(CONFIG_KSM) || defined(CONFIG_MIGRATION) 29 struct mutex mutex; /* Serialize access to vma list */
31
32 /* 30 /*
33 * The external_refcount is taken by either KSM or page migration 31 * The refcount is taken on an anon_vma when there is no
34 * to take a reference to an anon_vma when there is no
35 * guarantee that the vma of page tables will exist for 32 * guarantee that the vma of page tables will exist for
36 * the duration of the operation. A caller that takes 33 * the duration of the operation. A caller that takes
37 * the reference is responsible for clearing up the 34 * the reference is responsible for clearing up the
38 * anon_vma if they are the last user on release 35 * anon_vma if they are the last user on release
39 */ 36 */
40 atomic_t external_refcount; 37 atomic_t refcount;
41#endif 38
42 /* 39 /*
43 * NOTE: the LSB of the head.next is set by 40 * NOTE: the LSB of the head.next is set by
44 * mm_take_all_locks() _after_ taking the above lock. So the 41 * mm_take_all_locks() _after_ taking the above lock. So the
@@ -67,45 +64,22 @@ struct anon_vma_chain {
67 struct vm_area_struct *vma; 64 struct vm_area_struct *vma;
68 struct anon_vma *anon_vma; 65 struct anon_vma *anon_vma;
69 struct list_head same_vma; /* locked by mmap_sem & page_table_lock */ 66 struct list_head same_vma; /* locked by mmap_sem & page_table_lock */
70 struct list_head same_anon_vma; /* locked by anon_vma->lock */ 67 struct list_head same_anon_vma; /* locked by anon_vma->mutex */
71}; 68};
72 69
73#ifdef CONFIG_MMU 70#ifdef CONFIG_MMU
74#if defined(CONFIG_KSM) || defined(CONFIG_MIGRATION)
75static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma)
76{
77 atomic_set(&anon_vma->external_refcount, 0);
78}
79
80static inline int anonvma_external_refcount(struct anon_vma *anon_vma)
81{
82 return atomic_read(&anon_vma->external_refcount);
83}
84
85static inline void get_anon_vma(struct anon_vma *anon_vma) 71static inline void get_anon_vma(struct anon_vma *anon_vma)
86{ 72{
87 atomic_inc(&anon_vma->external_refcount); 73 atomic_inc(&anon_vma->refcount);
88}
89
90void drop_anon_vma(struct anon_vma *);
91#else
92static inline void anonvma_external_refcount_init(struct anon_vma *anon_vma)
93{
94}
95
96static inline int anonvma_external_refcount(struct anon_vma *anon_vma)
97{
98 return 0;
99} 74}
100 75
101static inline void get_anon_vma(struct anon_vma *anon_vma) 76void __put_anon_vma(struct anon_vma *anon_vma);
102{
103}
104 77
105static inline void drop_anon_vma(struct anon_vma *anon_vma) 78static inline void put_anon_vma(struct anon_vma *anon_vma)
106{ 79{
80 if (atomic_dec_and_test(&anon_vma->refcount))
81 __put_anon_vma(anon_vma);
107} 82}
108#endif /* CONFIG_KSM */
109 83
110static inline struct anon_vma *page_anon_vma(struct page *page) 84static inline struct anon_vma *page_anon_vma(struct page *page)
111{ 85{
@@ -119,24 +93,24 @@ static inline void vma_lock_anon_vma(struct vm_area_struct *vma)
119{ 93{
120 struct anon_vma *anon_vma = vma->anon_vma; 94 struct anon_vma *anon_vma = vma->anon_vma;
121 if (anon_vma) 95 if (anon_vma)
122 spin_lock(&anon_vma->root->lock); 96 mutex_lock(&anon_vma->root->mutex);
123} 97}
124 98
125static inline void vma_unlock_anon_vma(struct vm_area_struct *vma) 99static inline void vma_unlock_anon_vma(struct vm_area_struct *vma)
126{ 100{
127 struct anon_vma *anon_vma = vma->anon_vma; 101 struct anon_vma *anon_vma = vma->anon_vma;
128 if (anon_vma) 102 if (anon_vma)
129 spin_unlock(&anon_vma->root->lock); 103 mutex_unlock(&anon_vma->root->mutex);
130} 104}
131 105
132static inline void anon_vma_lock(struct anon_vma *anon_vma) 106static inline void anon_vma_lock(struct anon_vma *anon_vma)
133{ 107{
134 spin_lock(&anon_vma->root->lock); 108 mutex_lock(&anon_vma->root->mutex);
135} 109}
136 110
137static inline void anon_vma_unlock(struct anon_vma *anon_vma) 111static inline void anon_vma_unlock(struct anon_vma *anon_vma)
138{ 112{
139 spin_unlock(&anon_vma->root->lock); 113 mutex_unlock(&anon_vma->root->mutex);
140} 114}
141 115
142/* 116/*
@@ -148,7 +122,6 @@ void unlink_anon_vmas(struct vm_area_struct *);
148int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *); 122int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
149int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *); 123int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
150void __anon_vma_link(struct vm_area_struct *); 124void __anon_vma_link(struct vm_area_struct *);
151void anon_vma_free(struct anon_vma *);
152 125
153static inline void anon_vma_merge(struct vm_area_struct *vma, 126static inline void anon_vma_merge(struct vm_area_struct *vma,
154 struct vm_area_struct *next) 127 struct vm_area_struct *next)
@@ -157,6 +130,8 @@ static inline void anon_vma_merge(struct vm_area_struct *vma,
157 unlink_anon_vmas(next); 130 unlink_anon_vmas(next);
158} 131}
159 132
133struct anon_vma *page_get_anon_vma(struct page *page);
134
160/* 135/*
161 * rmap interfaces called when adding or removing pte of page 136 * rmap interfaces called when adding or removing pte of page
162 */ 137 */
@@ -198,6 +173,8 @@ enum ttu_flags {
198}; 173};
199#define TTU_ACTION(x) ((x) & TTU_ACTION_MASK) 174#define TTU_ACTION(x) ((x) & TTU_ACTION_MASK)
200 175
176bool is_vma_temporary_stack(struct vm_area_struct *vma);
177
201int try_to_unmap(struct page *, enum ttu_flags flags); 178int try_to_unmap(struct page *, enum ttu_flags flags);
202int try_to_unmap_one(struct page *, struct vm_area_struct *, 179int try_to_unmap_one(struct page *, struct vm_area_struct *,
203 unsigned long address, enum ttu_flags flags); 180 unsigned long address, enum ttu_flags flags);
@@ -205,9 +182,20 @@ int try_to_unmap_one(struct page *, struct vm_area_struct *,
205/* 182/*
206 * Called from mm/filemap_xip.c to unmap empty zero page 183 * Called from mm/filemap_xip.c to unmap empty zero page
207 */ 184 */
208pte_t *page_check_address(struct page *, struct mm_struct *, 185pte_t *__page_check_address(struct page *, struct mm_struct *,
209 unsigned long, spinlock_t **, int); 186 unsigned long, spinlock_t **, int);
210 187
188static inline pte_t *page_check_address(struct page *page, struct mm_struct *mm,
189 unsigned long address,
190 spinlock_t **ptlp, int sync)
191{
192 pte_t *ptep;
193
194 __cond_lock(*ptlp, ptep = __page_check_address(page, mm, address,
195 ptlp, sync));
196 return ptep;
197}
198
211/* 199/*
212 * Used by swapoff to help locate where page is expected in vma. 200 * Used by swapoff to help locate where page is expected in vma.
213 */ 201 */
diff --git a/include/linux/romfs_fs.h b/include/linux/romfs_fs.h
index c490fbc43fe2..5f57f93b284f 100644
--- a/include/linux/romfs_fs.h
+++ b/include/linux/romfs_fs.h
@@ -1,6 +1,9 @@
1#ifndef __LINUX_ROMFS_FS_H 1#ifndef __LINUX_ROMFS_FS_H
2#define __LINUX_ROMFS_FS_H 2#define __LINUX_ROMFS_FS_H
3 3
4#include <linux/types.h>
5#include <linux/fs.h>
6
4/* The basic structures of the romfs filesystem */ 7/* The basic structures of the romfs filesystem */
5 8
6#define ROMBSIZE BLOCK_SIZE 9#define ROMBSIZE BLOCK_SIZE
diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h
index 215278b8df2a..3f594dce5716 100644
--- a/include/linux/rotary_encoder.h
+++ b/include/linux/rotary_encoder.h
@@ -10,6 +10,7 @@ struct rotary_encoder_platform_data {
10 unsigned int inverted_b; 10 unsigned int inverted_b;
11 bool relative_axis; 11 bool relative_axis;
12 bool rollover; 12 bool rollover;
13 bool half_period;
13}; 14};
14 15
15#endif /* __ROTARY_ENCODER_H__ */ 16#endif /* __ROTARY_ENCODER_H__ */
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 14dbc83ded20..b27ebea25660 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -92,10 +92,10 @@ struct rtc_pll_info {
92#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */ 92#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */
93 93
94/* interrupt flags */ 94/* interrupt flags */
95#define RTC_IRQF 0x80 /* any of the following is active */ 95#define RTC_IRQF 0x80 /* Any of the following is active */
96#define RTC_PF 0x40 96#define RTC_PF 0x40 /* Periodic interrupt */
97#define RTC_AF 0x20 97#define RTC_AF 0x20 /* Alarm interrupt */
98#define RTC_UF 0x10 98#define RTC_UF 0x10 /* Update interrupt for 1Hz RTC */
99 99
100#ifdef __KERNEL__ 100#ifdef __KERNEL__
101 101
@@ -107,12 +107,17 @@ extern int rtc_year_days(unsigned int day, unsigned int month, unsigned int year
107extern int rtc_valid_tm(struct rtc_time *tm); 107extern int rtc_valid_tm(struct rtc_time *tm);
108extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); 108extern int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time);
109extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); 109extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
110ktime_t rtc_tm_to_ktime(struct rtc_time tm);
111struct rtc_time rtc_ktime_to_tm(ktime_t kt);
112
110 113
111#include <linux/device.h> 114#include <linux/device.h>
112#include <linux/seq_file.h> 115#include <linux/seq_file.h>
113#include <linux/cdev.h> 116#include <linux/cdev.h>
114#include <linux/poll.h> 117#include <linux/poll.h>
115#include <linux/mutex.h> 118#include <linux/mutex.h>
119#include <linux/timerqueue.h>
120#include <linux/workqueue.h>
116 121
117extern struct class *rtc_class; 122extern struct class *rtc_class;
118 123
@@ -128,7 +133,6 @@ extern struct class *rtc_class;
128 * The (current) exceptions are mostly filesystem hooks: 133 * The (current) exceptions are mostly filesystem hooks:
129 * - the proc() hook for procfs 134 * - the proc() hook for procfs
130 * - non-ioctl() chardev hooks: open(), release(), read_callback() 135 * - non-ioctl() chardev hooks: open(), release(), read_callback()
131 * - periodic irq calls: irq_set_state(), irq_set_freq()
132 * 136 *
133 * REVISIT those periodic irq calls *do* have ops_lock when they're 137 * REVISIT those periodic irq calls *do* have ops_lock when they're
134 * issued through ioctl() ... 138 * issued through ioctl() ...
@@ -143,15 +147,24 @@ struct rtc_class_ops {
143 int (*set_alarm)(struct device *, struct rtc_wkalrm *); 147 int (*set_alarm)(struct device *, struct rtc_wkalrm *);
144 int (*proc)(struct device *, struct seq_file *); 148 int (*proc)(struct device *, struct seq_file *);
145 int (*set_mmss)(struct device *, unsigned long secs); 149 int (*set_mmss)(struct device *, unsigned long secs);
146 int (*irq_set_state)(struct device *, int enabled);
147 int (*irq_set_freq)(struct device *, int freq);
148 int (*read_callback)(struct device *, int data); 150 int (*read_callback)(struct device *, int data);
149 int (*alarm_irq_enable)(struct device *, unsigned int enabled); 151 int (*alarm_irq_enable)(struct device *, unsigned int enabled);
150 int (*update_irq_enable)(struct device *, unsigned int enabled);
151}; 152};
152 153
153#define RTC_DEVICE_NAME_SIZE 20 154#define RTC_DEVICE_NAME_SIZE 20
154struct rtc_task; 155typedef struct rtc_task {
156 void (*func)(void *private_data);
157 void *private_data;
158} rtc_task_t;
159
160
161struct rtc_timer {
162 struct rtc_task task;
163 struct timerqueue_node node;
164 ktime_t period;
165 int enabled;
166};
167
155 168
156/* flags */ 169/* flags */
157#define RTC_DEV_BUSY 0 170#define RTC_DEV_BUSY 0
@@ -179,6 +192,15 @@ struct rtc_device
179 spinlock_t irq_task_lock; 192 spinlock_t irq_task_lock;
180 int irq_freq; 193 int irq_freq;
181 int max_user_freq; 194 int max_user_freq;
195
196 struct timerqueue_head timerqueue;
197 struct rtc_timer aie_timer;
198 struct rtc_timer uie_rtctimer;
199 struct hrtimer pie_timer; /* sub second exp, so needs hrtimer */
200 int pie_enabled;
201 struct work_struct irqwork;
202
203
182#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 204#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
183 struct work_struct uie_task; 205 struct work_struct uie_task;
184 struct timer_list uie_timer; 206 struct timer_list uie_timer;
@@ -201,10 +223,13 @@ extern void rtc_device_unregister(struct rtc_device *rtc);
201extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); 223extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm);
202extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); 224extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm);
203extern int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs); 225extern int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs);
226int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm);
204extern int rtc_read_alarm(struct rtc_device *rtc, 227extern int rtc_read_alarm(struct rtc_device *rtc,
205 struct rtc_wkalrm *alrm); 228 struct rtc_wkalrm *alrm);
206extern int rtc_set_alarm(struct rtc_device *rtc, 229extern int rtc_set_alarm(struct rtc_device *rtc,
207 struct rtc_wkalrm *alrm); 230 struct rtc_wkalrm *alrm);
231extern int rtc_initialize_alarm(struct rtc_device *rtc,
232 struct rtc_wkalrm *alrm);
208extern void rtc_update_irq(struct rtc_device *rtc, 233extern void rtc_update_irq(struct rtc_device *rtc,
209 unsigned long num, unsigned long events); 234 unsigned long num, unsigned long events);
210 235
@@ -224,15 +249,21 @@ extern int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled);
224extern int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc, 249extern int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc,
225 unsigned int enabled); 250 unsigned int enabled);
226 251
227typedef struct rtc_task { 252void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode);
228 void (*func)(void *private_data); 253void rtc_aie_update_irq(void *private);
229 void *private_data; 254void rtc_uie_update_irq(void *private);
230} rtc_task_t; 255enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer);
231 256
232int rtc_register(rtc_task_t *task); 257int rtc_register(rtc_task_t *task);
233int rtc_unregister(rtc_task_t *task); 258int rtc_unregister(rtc_task_t *task);
234int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); 259int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg);
235 260
261void rtc_timer_init(struct rtc_timer *timer, void (*f)(void* p), void* data);
262int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer,
263 ktime_t expires, ktime_t period);
264int rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer* timer);
265void rtc_timer_do_work(struct work_struct *work);
266
236static inline bool is_leap_year(unsigned int year) 267static inline bool is_leap_year(unsigned int year)
237{ 268{
238 return (!(year % 4) && (year % 100)) || !(year % 400); 269 return (!(year % 4) && (year % 100)) || !(year % 400);
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 58d44491880f..bbad657a3725 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -605,6 +605,7 @@ struct tcamsg {
605#ifdef __KERNEL__ 605#ifdef __KERNEL__
606 606
607#include <linux/mutex.h> 607#include <linux/mutex.h>
608#include <linux/netdevice.h>
608 609
609static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str) 610static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
610{ 611{
@@ -749,6 +750,35 @@ extern int rtnl_is_locked(void);
749extern int lockdep_rtnl_is_held(void); 750extern int lockdep_rtnl_is_held(void);
750#endif /* #ifdef CONFIG_PROVE_LOCKING */ 751#endif /* #ifdef CONFIG_PROVE_LOCKING */
751 752
753/**
754 * rcu_dereference_rtnl - rcu_dereference with debug checking
755 * @p: The pointer to read, prior to dereferencing
756 *
757 * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
758 * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference()
759 */
760#define rcu_dereference_rtnl(p) \
761 rcu_dereference_check(p, rcu_read_lock_held() || \
762 lockdep_rtnl_is_held())
763
764/**
765 * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL
766 * @p: The pointer to read, prior to dereferencing
767 *
768 * Return the value of the specified RCU-protected pointer, but omit
769 * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because
770 * caller holds RTNL.
771 */
772#define rtnl_dereference(p) \
773 rcu_dereference_protected(p, lockdep_rtnl_is_held())
774
775static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev)
776{
777 return rtnl_dereference(dev->ingress_queue);
778}
779
780extern struct netdev_queue *dev_ingress_queue_create(struct net_device *dev);
781
752extern void rtnetlink_init(void); 782extern void rtnetlink_init(void);
753extern void __rtnl_unlock(void); 783extern void __rtnl_unlock(void);
754 784
diff --git a/include/linux/rwlock_types.h b/include/linux/rwlock_types.h
index bd31808c7d8e..cc0072e93e36 100644
--- a/include/linux/rwlock_types.h
+++ b/include/linux/rwlock_types.h
@@ -43,14 +43,6 @@ typedef struct {
43 RW_DEP_MAP_INIT(lockname) } 43 RW_DEP_MAP_INIT(lockname) }
44#endif 44#endif
45 45
46/*
47 * RW_LOCK_UNLOCKED defeat lockdep state tracking and is hence
48 * deprecated.
49 *
50 * Please use DEFINE_RWLOCK() or __RW_LOCK_UNLOCKED() as appropriate.
51 */
52#define RW_LOCK_UNLOCKED __RW_LOCK_UNLOCKED(old_style_rw_init)
53
54#define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) 46#define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x)
55 47
56#endif /* __LINUX_RWLOCK_TYPES_H */ 48#endif /* __LINUX_RWLOCK_TYPES_H */
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h
index bdfcc2527970..34701241b673 100644
--- a/include/linux/rwsem-spinlock.h
+++ b/include/linux/rwsem-spinlock.h
@@ -12,15 +12,7 @@
12#error "please don't include linux/rwsem-spinlock.h directly, use linux/rwsem.h instead" 12#error "please don't include linux/rwsem-spinlock.h directly, use linux/rwsem.h instead"
13#endif 13#endif
14 14
15#include <linux/spinlock.h>
16#include <linux/list.h>
17
18#ifdef __KERNEL__ 15#ifdef __KERNEL__
19
20#include <linux/types.h>
21
22struct rwsem_waiter;
23
24/* 16/*
25 * the rw-semaphore definition 17 * the rw-semaphore definition
26 * - if activity is 0 then there are no active readers or writers 18 * - if activity is 0 then there are no active readers or writers
@@ -37,28 +29,7 @@ struct rw_semaphore {
37#endif 29#endif
38}; 30};
39 31
40#ifdef CONFIG_DEBUG_LOCK_ALLOC 32#define RWSEM_UNLOCKED_VALUE 0x00000000
41# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
42#else
43# define __RWSEM_DEP_MAP_INIT(lockname)
44#endif
45
46#define __RWSEM_INITIALIZER(name) \
47{ 0, __SPIN_LOCK_UNLOCKED(name.wait_lock), LIST_HEAD_INIT((name).wait_list) \
48 __RWSEM_DEP_MAP_INIT(name) }
49
50#define DECLARE_RWSEM(name) \
51 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
52
53extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
54 struct lock_class_key *key);
55
56#define init_rwsem(sem) \
57do { \
58 static struct lock_class_key __key; \
59 \
60 __init_rwsem((sem), #sem, &__key); \
61} while (0)
62 33
63extern void __down_read(struct rw_semaphore *sem); 34extern void __down_read(struct rw_semaphore *sem);
64extern int __down_read_trylock(struct rw_semaphore *sem); 35extern int __down_read_trylock(struct rw_semaphore *sem);
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index efd348fe8ca7..a8afe9cd000c 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -11,6 +11,9 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/list.h>
15#include <linux/spinlock.h>
16
14#include <asm/system.h> 17#include <asm/system.h>
15#include <asm/atomic.h> 18#include <asm/atomic.h>
16 19
@@ -19,9 +22,57 @@ struct rw_semaphore;
19#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK 22#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
20#include <linux/rwsem-spinlock.h> /* use a generic implementation */ 23#include <linux/rwsem-spinlock.h> /* use a generic implementation */
21#else 24#else
22#include <asm/rwsem.h> /* use an arch-specific implementation */ 25/* All arch specific implementations share the same struct */
26struct rw_semaphore {
27 long count;
28 spinlock_t wait_lock;
29 struct list_head wait_list;
30#ifdef CONFIG_DEBUG_LOCK_ALLOC
31 struct lockdep_map dep_map;
32#endif
33};
34
35extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
36extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
37extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *);
38extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
39
40/* Include the arch specific part */
41#include <asm/rwsem.h>
42
43/* In all implementations count != 0 means locked */
44static inline int rwsem_is_locked(struct rw_semaphore *sem)
45{
46 return sem->count != 0;
47}
48
49#endif
50
51/* Common initializer macros and functions */
52
53#ifdef CONFIG_DEBUG_LOCK_ALLOC
54# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
55#else
56# define __RWSEM_DEP_MAP_INIT(lockname)
23#endif 57#endif
24 58
59#define __RWSEM_INITIALIZER(name) \
60 { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED(name.wait_lock), \
61 LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
62
63#define DECLARE_RWSEM(name) \
64 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
65
66extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
67 struct lock_class_key *key);
68
69#define init_rwsem(sem) \
70do { \
71 static struct lock_class_key __key; \
72 \
73 __init_rwsem((sem), #sem, &__key); \
74} while (0)
75
25/* 76/*
26 * lock for reading 77 * lock for reading
27 */ 78 */
diff --git a/include/linux/s3c_adc_battery.h b/include/linux/s3c_adc_battery.h
index dbce22faa660..fbe58b7e63eb 100644
--- a/include/linux/s3c_adc_battery.h
+++ b/include/linux/s3c_adc_battery.h
@@ -14,6 +14,7 @@ struct s3c_adc_bat_pdata {
14 void (*disable_charger)(void); 14 void (*disable_charger)(void);
15 15
16 int gpio_charge_finished; 16 int gpio_charge_finished;
17 int gpio_inverted;
17 18
18 const struct s3c_adc_bat_thresh *lut_noac; 19 const struct s3c_adc_bat_thresh *lut_noac;
19 unsigned int lut_noac_cnt; 20 unsigned int lut_noac_cnt;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index c9ac4fc837ba..9c990d13ae35 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -21,7 +21,8 @@
21#define CLONE_DETACHED 0x00400000 /* Unused, ignored */ 21#define CLONE_DETACHED 0x00400000 /* Unused, ignored */
22#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ 22#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */
23#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ 23#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
24#define CLONE_STOPPED 0x02000000 /* Start in stopped state */ 24/* 0x02000000 was previously the unused CLONE_STOPPED (Start in stopped state)
25 and is now available for re-use. */
25#define CLONE_NEWUTS 0x04000000 /* New utsname group? */ 26#define CLONE_NEWUTS 0x04000000 /* New utsname group? */
26#define CLONE_NEWIPC 0x08000000 /* New ipcs */ 27#define CLONE_NEWIPC 0x08000000 /* New ipcs */
27#define CLONE_NEWUSER 0x10000000 /* New user namespace */ 28#define CLONE_NEWUSER 0x10000000 /* New user namespace */
@@ -71,7 +72,6 @@ struct sched_param {
71#include <linux/smp.h> 72#include <linux/smp.h>
72#include <linux/sem.h> 73#include <linux/sem.h>
73#include <linux/signal.h> 74#include <linux/signal.h>
74#include <linux/path.h>
75#include <linux/compiler.h> 75#include <linux/compiler.h>
76#include <linux/completion.h> 76#include <linux/completion.h>
77#include <linux/pid.h> 77#include <linux/pid.h>
@@ -89,7 +89,6 @@ struct sched_param {
89#include <linux/timer.h> 89#include <linux/timer.h>
90#include <linux/hrtimer.h> 90#include <linux/hrtimer.h>
91#include <linux/task_io_accounting.h> 91#include <linux/task_io_accounting.h>
92#include <linux/kobject.h>
93#include <linux/latencytop.h> 92#include <linux/latencytop.h>
94#include <linux/cred.h> 93#include <linux/cred.h>
95 94
@@ -104,6 +103,7 @@ struct robust_list_head;
104struct bio_list; 103struct bio_list;
105struct fs_struct; 104struct fs_struct;
106struct perf_event_context; 105struct perf_event_context;
106struct blk_plug;
107 107
108/* 108/*
109 * List of flags we want to share for kernel threads, 109 * List of flags we want to share for kernel threads,
@@ -147,7 +147,7 @@ extern unsigned long nr_iowait_cpu(int cpu);
147extern unsigned long this_cpu_load(void); 147extern unsigned long this_cpu_load(void);
148 148
149 149
150extern void calc_global_load(void); 150extern void calc_global_load(unsigned long ticks);
151 151
152extern unsigned long get_parent_ip(unsigned long addr); 152extern unsigned long get_parent_ip(unsigned long addr);
153 153
@@ -319,7 +319,7 @@ extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
319 void __user *buffer, 319 void __user *buffer,
320 size_t *lenp, loff_t *ppos); 320 size_t *lenp, loff_t *ppos);
321extern unsigned int softlockup_panic; 321extern unsigned int softlockup_panic;
322extern int softlockup_thresh; 322void lockup_detector_init(void);
323#else 323#else
324static inline void touch_softlockup_watchdog(void) 324static inline void touch_softlockup_watchdog(void)
325{ 325{
@@ -330,6 +330,9 @@ static inline void touch_softlockup_watchdog_sync(void)
330static inline void touch_all_softlockup_watchdogs(void) 330static inline void touch_all_softlockup_watchdogs(void)
331{ 331{
332} 332}
333static inline void lockup_detector_init(void)
334{
335}
333#endif 336#endif
334 337
335#ifdef CONFIG_DETECT_HUNG_TASK 338#ifdef CONFIG_DETECT_HUNG_TASK
@@ -340,6 +343,9 @@ extern unsigned long sysctl_hung_task_warnings;
340extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write, 343extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
341 void __user *buffer, 344 void __user *buffer,
342 size_t *lenp, loff_t *ppos); 345 size_t *lenp, loff_t *ppos);
346#else
347/* Avoid need for ifdefs elsewhere in the code */
348enum { sysctl_hung_task_timeout_secs = 0 };
343#endif 349#endif
344 350
345/* Attach to any functions which should be ignored in wchan output. */ 351/* Attach to any functions which should be ignored in wchan output. */
@@ -357,7 +363,7 @@ extern signed long schedule_timeout_interruptible(signed long timeout);
357extern signed long schedule_timeout_killable(signed long timeout); 363extern signed long schedule_timeout_killable(signed long timeout);
358extern signed long schedule_timeout_uninterruptible(signed long timeout); 364extern signed long schedule_timeout_uninterruptible(signed long timeout);
359asmlinkage void schedule(void); 365asmlinkage void schedule(void);
360extern int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner); 366extern int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner);
361 367
362struct nsproxy; 368struct nsproxy;
363struct user_namespace; 369struct user_namespace;
@@ -432,6 +438,7 @@ extern int get_dumpable(struct mm_struct *mm);
432#endif 438#endif
433 /* leave room for more dump flags */ 439 /* leave room for more dump flags */
434#define MMF_VM_MERGEABLE 16 /* KSM may merge identical pages */ 440#define MMF_VM_MERGEABLE 16 /* KSM may merge identical pages */
441#define MMF_VM_HUGEPAGE 17 /* set when VM_HUGEPAGE is set on vma */
435 442
436#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK) 443#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
437 444
@@ -510,8 +517,11 @@ struct thread_group_cputimer {
510 spinlock_t lock; 517 spinlock_t lock;
511}; 518};
512 519
520#include <linux/rwsem.h>
521struct autogroup;
522
513/* 523/*
514 * NOTE! "signal_struct" does not have it's own 524 * NOTE! "signal_struct" does not have its own
515 * locking, because a shared signal_struct always 525 * locking, because a shared signal_struct always
516 * implies a shared sighand_struct, so locking 526 * implies a shared sighand_struct, so locking
517 * sighand_struct is always a proper superset of 527 * sighand_struct is always a proper superset of
@@ -577,6 +587,9 @@ struct signal_struct {
577 587
578 struct tty_struct *tty; /* NULL if no tty */ 588 struct tty_struct *tty; /* NULL if no tty */
579 589
590#ifdef CONFIG_SCHED_AUTOGROUP
591 struct autogroup *autogroup;
592#endif
580 /* 593 /*
581 * Cumulative resource counters for dead threads in the group, 594 * Cumulative resource counters for dead threads in the group,
582 * and for reaped dead child processes forked by this group. 595 * and for reaped dead child processes forked by this group.
@@ -624,9 +637,25 @@ struct signal_struct {
624 unsigned audit_tty; 637 unsigned audit_tty;
625 struct tty_audit_buf *tty_audit_buf; 638 struct tty_audit_buf *tty_audit_buf;
626#endif 639#endif
640#ifdef CONFIG_CGROUPS
641 /*
642 * The threadgroup_fork_lock prevents threads from forking with
643 * CLONE_THREAD while held for writing. Use this for fork-sensitive
644 * threadgroup-wide operations. It's taken for reading in fork.c in
645 * copy_process().
646 * Currently only needed write-side by cgroups.
647 */
648 struct rw_semaphore threadgroup_fork_lock;
649#endif
627 650
628 int oom_adj; /* OOM kill score adjustment (bit shift) */ 651 int oom_adj; /* OOM kill score adjustment (bit shift) */
629 int oom_score_adj; /* OOM kill score adjustment */ 652 int oom_score_adj; /* OOM kill score adjustment */
653 int oom_score_adj_min; /* OOM kill score adjustment minimum value.
654 * Only settable by CAP_SYS_RESOURCE. */
655
656 struct mutex cred_guard_mutex; /* guard against foreign influences on
657 * credential calculations
658 * (notably. ptrace) */
630}; 659};
631 660
632/* Context switch must be unlocked if interrupts are to be enabled */ 661/* Context switch must be unlocked if interrupts are to be enabled */
@@ -638,9 +667,8 @@ struct signal_struct {
638 * Bits in flags field of signal_struct. 667 * Bits in flags field of signal_struct.
639 */ 668 */
640#define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */ 669#define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */
641#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */ 670#define SIGNAL_STOP_CONTINUED 0x00000002 /* SIGCONT since WCONTINUED reap */
642#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */ 671#define SIGNAL_GROUP_EXIT 0x00000004 /* group exit in progress */
643#define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */
644/* 672/*
645 * Pending notifications to parent. 673 * Pending notifications to parent.
646 */ 674 */
@@ -669,8 +697,11 @@ struct user_struct {
669 atomic_t inotify_watches; /* How many inotify watches does this user have? */ 697 atomic_t inotify_watches; /* How many inotify watches does this user have? */
670 atomic_t inotify_devs; /* How many inotify devs does this user have opened? */ 698 atomic_t inotify_devs; /* How many inotify devs does this user have opened? */
671#endif 699#endif
700#ifdef CONFIG_FANOTIFY
701 atomic_t fanotify_listeners;
702#endif
672#ifdef CONFIG_EPOLL 703#ifdef CONFIG_EPOLL
673 atomic_t epoll_watches; /* The number of file descriptors currently watched */ 704 atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
674#endif 705#endif
675#ifdef CONFIG_POSIX_MQUEUE 706#ifdef CONFIG_POSIX_MQUEUE
676 /* protected by mq_lock */ 707 /* protected by mq_lock */
@@ -713,10 +744,6 @@ struct sched_info {
713 /* timestamps */ 744 /* timestamps */
714 unsigned long long last_arrival,/* when we last ran on a cpu */ 745 unsigned long long last_arrival,/* when we last ran on a cpu */
715 last_queued; /* when we were last queued to run */ 746 last_queued; /* when we were last queued to run */
716#ifdef CONFIG_SCHEDSTATS
717 /* BKL stats */
718 unsigned int bkl_count;
719#endif
720}; 747};
721#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ 748#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
722 749
@@ -774,17 +801,39 @@ enum cpu_idle_type {
774}; 801};
775 802
776/* 803/*
777 * sched-domains (multiprocessor balancing) declarations: 804 * Increase resolution of nice-level calculations for 64-bit architectures.
805 * The extra resolution improves shares distribution and load balancing of
806 * low-weight task groups (eg. nice +19 on an autogroup), deeper taskgroup
807 * hierarchies, especially on larger systems. This is not a user-visible change
808 * and does not change the user-interface for setting shares/weights.
809 *
810 * We increase resolution only if we have enough bits to allow this increased
811 * resolution (i.e. BITS_PER_LONG > 32). The costs for increasing resolution
812 * when BITS_PER_LONG <= 32 are pretty high and the returns do not justify the
813 * increased costs.
778 */ 814 */
815#if 0 /* BITS_PER_LONG > 32 -- currently broken: it increases power usage under light load */
816# define SCHED_LOAD_RESOLUTION 10
817# define scale_load(w) ((w) << SCHED_LOAD_RESOLUTION)
818# define scale_load_down(w) ((w) >> SCHED_LOAD_RESOLUTION)
819#else
820# define SCHED_LOAD_RESOLUTION 0
821# define scale_load(w) (w)
822# define scale_load_down(w) (w)
823#endif
779 824
780/* 825#define SCHED_LOAD_SHIFT (10 + SCHED_LOAD_RESOLUTION)
781 * Increase resolution of nice-level calculations:
782 */
783#define SCHED_LOAD_SHIFT 10
784#define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT) 826#define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT)
785 827
786#define SCHED_LOAD_SCALE_FUZZ SCHED_LOAD_SCALE 828/*
829 * Increase resolution of cpu_power calculations
830 */
831#define SCHED_POWER_SHIFT 10
832#define SCHED_POWER_SCALE (1L << SCHED_POWER_SHIFT)
787 833
834/*
835 * sched-domains (multiprocessor balancing) declarations:
836 */
788#ifdef CONFIG_SMP 837#ifdef CONFIG_SMP
789#define SD_LOAD_BALANCE 0x0001 /* Do load balancing on this domain. */ 838#define SD_LOAD_BALANCE 0x0001 /* Do load balancing on this domain. */
790#define SD_BALANCE_NEWIDLE 0x0002 /* Balance when about to become idle */ 839#define SD_BALANCE_NEWIDLE 0x0002 /* Balance when about to become idle */
@@ -799,6 +848,7 @@ enum cpu_idle_type {
799#define SD_SERIALIZE 0x0400 /* Only a single load balancing instance */ 848#define SD_SERIALIZE 0x0400 /* Only a single load balancing instance */
800#define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */ 849#define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */
801#define SD_PREFER_SIBLING 0x1000 /* Prefer to place tasks in a sibling domain */ 850#define SD_PREFER_SIBLING 0x1000 /* Prefer to place tasks in a sibling domain */
851#define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */
802 852
803enum powersavings_balance_level { 853enum powersavings_balance_level {
804 POWERSAVINGS_BALANCE_NONE = 0, /* No power saving load balance */ 854 POWERSAVINGS_BALANCE_NONE = 0, /* No power saving load balance */
@@ -836,7 +886,7 @@ extern int __weak arch_sd_sibiling_asym_packing(void);
836 886
837/* 887/*
838 * Optimise SD flags for power savings: 888 * Optimise SD flags for power savings:
839 * SD_BALANCE_NEWIDLE helps agressive task consolidation and power savings. 889 * SD_BALANCE_NEWIDLE helps aggressive task consolidation and power savings.
840 * Keep default SD flags if sched_{smt,mc}_power_saving=0 890 * Keep default SD flags if sched_{smt,mc}_power_saving=0
841 */ 891 */
842 892
@@ -848,14 +898,21 @@ static inline int sd_power_saving_flags(void)
848 return 0; 898 return 0;
849} 899}
850 900
851struct sched_group { 901struct sched_group_power {
852 struct sched_group *next; /* Must be a circular list */ 902 atomic_t ref;
853
854 /* 903 /*
855 * CPU power of this group, SCHED_LOAD_SCALE being max power for a 904 * CPU power of this group, SCHED_LOAD_SCALE being max power for a
856 * single CPU. 905 * single CPU.
857 */ 906 */
858 unsigned int cpu_power, cpu_power_orig; 907 unsigned int power, power_orig;
908};
909
910struct sched_group {
911 struct sched_group *next; /* Must be a circular list */
912 atomic_t ref;
913
914 unsigned int group_weight;
915 struct sched_group_power *sgp;
859 916
860 /* 917 /*
861 * The CPUs this group covers. 918 * The CPUs this group covers.
@@ -863,9 +920,6 @@ struct sched_group {
863 * NOTE: this field is variable length. (Allocated dynamically 920 * NOTE: this field is variable length. (Allocated dynamically
864 * by attaching extra space to the end of the structure, 921 * by attaching extra space to the end of the structure,
865 * depending on how many CPUs the kernel has booted up with) 922 * depending on how many CPUs the kernel has booted up with)
866 *
867 * It is also be embedded into static data structures at build
868 * time. (See 'struct static_sched_group' in kernel/sched.c)
869 */ 923 */
870 unsigned long cpumask[0]; 924 unsigned long cpumask[0];
871}; 925};
@@ -875,16 +929,6 @@ static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
875 return to_cpumask(sg->cpumask); 929 return to_cpumask(sg->cpumask);
876} 930}
877 931
878enum sched_domain_level {
879 SD_LV_NONE = 0,
880 SD_LV_SIBLING,
881 SD_LV_MC,
882 SD_LV_CPU,
883 SD_LV_NODE,
884 SD_LV_ALLNODES,
885 SD_LV_MAX
886};
887
888struct sched_domain_attr { 932struct sched_domain_attr {
889 int relax_domain_level; 933 int relax_domain_level;
890}; 934};
@@ -893,6 +937,8 @@ struct sched_domain_attr {
893 .relax_domain_level = -1, \ 937 .relax_domain_level = -1, \
894} 938}
895 939
940extern int sched_domain_level_max;
941
896struct sched_domain { 942struct sched_domain {
897 /* These fields must be setup */ 943 /* These fields must be setup */
898 struct sched_domain *parent; /* top domain must be null terminated */ 944 struct sched_domain *parent; /* top domain must be null terminated */
@@ -910,7 +956,7 @@ struct sched_domain {
910 unsigned int forkexec_idx; 956 unsigned int forkexec_idx;
911 unsigned int smt_gain; 957 unsigned int smt_gain;
912 int flags; /* See SD_* */ 958 int flags; /* See SD_* */
913 enum sched_domain_level level; 959 int level;
914 960
915 /* Runtime fields. */ 961 /* Runtime fields. */
916 unsigned long last_balance; /* init to jiffies. units in jiffies */ 962 unsigned long last_balance; /* init to jiffies. units in jiffies */
@@ -953,6 +999,10 @@ struct sched_domain {
953#ifdef CONFIG_SCHED_DEBUG 999#ifdef CONFIG_SCHED_DEBUG
954 char *name; 1000 char *name;
955#endif 1001#endif
1002 union {
1003 void *private; /* used during construction */
1004 struct rcu_head rcu; /* used during destruction */
1005 };
956 1006
957 unsigned int span_weight; 1007 unsigned int span_weight;
958 /* 1008 /*
@@ -961,9 +1011,6 @@ struct sched_domain {
961 * NOTE: this field is variable length. (Allocated dynamically 1011 * NOTE: this field is variable length. (Allocated dynamically
962 * by attaching extra space to the end of the structure, 1012 * by attaching extra space to the end of the structure,
963 * depending on how many CPUs the kernel has booted up with) 1013 * depending on how many CPUs the kernel has booted up with)
964 *
965 * It is also be embedded into static data structures at build
966 * time. (See 'struct static_sched_domain' in kernel/sched.c)
967 */ 1014 */
968 unsigned long span[0]; 1015 unsigned long span[0];
969}; 1016};
@@ -1026,10 +1073,15 @@ struct sched_domain;
1026 */ 1073 */
1027#define WF_SYNC 0x01 /* waker goes to sleep after wakup */ 1074#define WF_SYNC 0x01 /* waker goes to sleep after wakup */
1028#define WF_FORK 0x02 /* child wakeup after fork */ 1075#define WF_FORK 0x02 /* child wakeup after fork */
1076#define WF_MIGRATED 0x04 /* internal use, task got migrated */
1029 1077
1030#define ENQUEUE_WAKEUP 1 1078#define ENQUEUE_WAKEUP 1
1031#define ENQUEUE_WAKING 2 1079#define ENQUEUE_HEAD 2
1032#define ENQUEUE_HEAD 4 1080#ifdef CONFIG_SMP
1081#define ENQUEUE_WAKING 4 /* sched_class::task_waking was called */
1082#else
1083#define ENQUEUE_WAKING 0
1084#endif
1033 1085
1034#define DEQUEUE_SLEEP 1 1086#define DEQUEUE_SLEEP 1
1035 1087
@@ -1039,6 +1091,7 @@ struct sched_class {
1039 void (*enqueue_task) (struct rq *rq, struct task_struct *p, int flags); 1091 void (*enqueue_task) (struct rq *rq, struct task_struct *p, int flags);
1040 void (*dequeue_task) (struct rq *rq, struct task_struct *p, int flags); 1092 void (*dequeue_task) (struct rq *rq, struct task_struct *p, int flags);
1041 void (*yield_task) (struct rq *rq); 1093 void (*yield_task) (struct rq *rq);
1094 bool (*yield_to_task) (struct rq *rq, struct task_struct *p, bool preempt);
1042 1095
1043 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p, int flags); 1096 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p, int flags);
1044 1097
@@ -1046,12 +1099,11 @@ struct sched_class {
1046 void (*put_prev_task) (struct rq *rq, struct task_struct *p); 1099 void (*put_prev_task) (struct rq *rq, struct task_struct *p);
1047 1100
1048#ifdef CONFIG_SMP 1101#ifdef CONFIG_SMP
1049 int (*select_task_rq)(struct rq *rq, struct task_struct *p, 1102 int (*select_task_rq)(struct task_struct *p, int sd_flag, int flags);
1050 int sd_flag, int flags);
1051 1103
1052 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task); 1104 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
1053 void (*post_schedule) (struct rq *this_rq); 1105 void (*post_schedule) (struct rq *this_rq);
1054 void (*task_waking) (struct rq *this_rq, struct task_struct *task); 1106 void (*task_waking) (struct task_struct *task);
1055 void (*task_woken) (struct rq *this_rq, struct task_struct *task); 1107 void (*task_woken) (struct rq *this_rq, struct task_struct *task);
1056 1108
1057 void (*set_cpus_allowed)(struct task_struct *p, 1109 void (*set_cpus_allowed)(struct task_struct *p,
@@ -1065,18 +1117,16 @@ struct sched_class {
1065 void (*task_tick) (struct rq *rq, struct task_struct *p, int queued); 1117 void (*task_tick) (struct rq *rq, struct task_struct *p, int queued);
1066 void (*task_fork) (struct task_struct *p); 1118 void (*task_fork) (struct task_struct *p);
1067 1119
1068 void (*switched_from) (struct rq *this_rq, struct task_struct *task, 1120 void (*switched_from) (struct rq *this_rq, struct task_struct *task);
1069 int running); 1121 void (*switched_to) (struct rq *this_rq, struct task_struct *task);
1070 void (*switched_to) (struct rq *this_rq, struct task_struct *task,
1071 int running);
1072 void (*prio_changed) (struct rq *this_rq, struct task_struct *task, 1122 void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
1073 int oldprio, int running); 1123 int oldprio);
1074 1124
1075 unsigned int (*get_rr_interval) (struct rq *rq, 1125 unsigned int (*get_rr_interval) (struct rq *rq,
1076 struct task_struct *task); 1126 struct task_struct *task);
1077 1127
1078#ifdef CONFIG_FAIR_GROUP_SCHED 1128#ifdef CONFIG_FAIR_GROUP_SCHED
1079 void (*moved_group) (struct task_struct *p, int on_rq); 1129 void (*task_move_group) (struct task_struct *p, int on_rq);
1080#endif 1130#endif
1081}; 1131};
1082 1132
@@ -1165,6 +1215,13 @@ struct sched_rt_entity {
1165struct rcu_node; 1215struct rcu_node;
1166struct od_table_entry; 1216struct od_table_entry;
1167 1217
1218enum perf_event_task_context {
1219 perf_invalid_context = -1,
1220 perf_hw_context = 0,
1221 perf_sw_context,
1222 perf_nr_task_contexts,
1223};
1224
1168struct task_struct { 1225struct task_struct {
1169 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ 1226 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
1170 void *stack; 1227 void *stack;
@@ -1172,13 +1229,11 @@ struct task_struct {
1172 unsigned int flags; /* per process flags, defined below */ 1229 unsigned int flags; /* per process flags, defined below */
1173 unsigned int ptrace; 1230 unsigned int ptrace;
1174 1231
1175 int lock_depth; /* BKL lock depth */
1176
1177#ifdef CONFIG_SMP 1232#ifdef CONFIG_SMP
1178#ifdef __ARCH_WANT_UNLOCKED_CTXSW 1233 struct task_struct *wake_entry;
1179 int oncpu; 1234 int on_cpu;
1180#endif
1181#endif 1235#endif
1236 int on_rq;
1182 1237
1183 int prio, static_prio, normal_prio; 1238 int prio, static_prio, normal_prio;
1184 unsigned int rt_priority; 1239 unsigned int rt_priority;
@@ -1207,21 +1262,34 @@ struct task_struct {
1207 unsigned int policy; 1262 unsigned int policy;
1208 cpumask_t cpus_allowed; 1263 cpumask_t cpus_allowed;
1209 1264
1210#ifdef CONFIG_TREE_PREEMPT_RCU 1265#ifdef CONFIG_PREEMPT_RCU
1211 int rcu_read_lock_nesting; 1266 int rcu_read_lock_nesting;
1212 char rcu_read_unlock_special; 1267 char rcu_read_unlock_special;
1213 struct rcu_node *rcu_blocked_node; 1268#if defined(CONFIG_RCU_BOOST) && defined(CONFIG_TREE_PREEMPT_RCU)
1269 int rcu_boosted;
1270#endif /* #if defined(CONFIG_RCU_BOOST) && defined(CONFIG_TREE_PREEMPT_RCU) */
1214 struct list_head rcu_node_entry; 1271 struct list_head rcu_node_entry;
1272#endif /* #ifdef CONFIG_PREEMPT_RCU */
1273#ifdef CONFIG_TREE_PREEMPT_RCU
1274 struct rcu_node *rcu_blocked_node;
1215#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */ 1275#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
1276#ifdef CONFIG_RCU_BOOST
1277 struct rt_mutex *rcu_boost_mutex;
1278#endif /* #ifdef CONFIG_RCU_BOOST */
1216 1279
1217#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 1280#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
1218 struct sched_info sched_info; 1281 struct sched_info sched_info;
1219#endif 1282#endif
1220 1283
1221 struct list_head tasks; 1284 struct list_head tasks;
1285#ifdef CONFIG_SMP
1222 struct plist_node pushable_tasks; 1286 struct plist_node pushable_tasks;
1287#endif
1223 1288
1224 struct mm_struct *mm, *active_mm; 1289 struct mm_struct *mm, *active_mm;
1290#ifdef CONFIG_COMPAT_BRK
1291 unsigned brk_randomized:1;
1292#endif
1225#if defined(SPLIT_RSS_COUNTING) 1293#if defined(SPLIT_RSS_COUNTING)
1226 struct task_rss_stat rss_stat; 1294 struct task_rss_stat rss_stat;
1227#endif 1295#endif
@@ -1229,6 +1297,7 @@ struct task_struct {
1229 int exit_state; 1297 int exit_state;
1230 int exit_code, exit_signal; 1298 int exit_code, exit_signal;
1231 int pdeath_signal; /* The signal sent when the parent dies */ 1299 int pdeath_signal; /* The signal sent when the parent dies */
1300 unsigned int group_stop; /* GROUP_STOP_*, siglock protected */
1232 /* ??? */ 1301 /* ??? */
1233 unsigned int personality; 1302 unsigned int personality;
1234 unsigned did_exec:1; 1303 unsigned did_exec:1;
@@ -1239,6 +1308,7 @@ struct task_struct {
1239 1308
1240 /* Revert to default priority/policy when forking */ 1309 /* Revert to default priority/policy when forking */
1241 unsigned sched_reset_on_fork:1; 1310 unsigned sched_reset_on_fork:1;
1311 unsigned sched_contributes_to_load:1;
1242 1312
1243 pid_t pid; 1313 pid_t pid;
1244 pid_t tgid; 1314 pid_t tgid;
@@ -1293,13 +1363,10 @@ struct task_struct {
1293 struct list_head cpu_timers[3]; 1363 struct list_head cpu_timers[3];
1294 1364
1295/* process credentials */ 1365/* process credentials */
1296 const struct cred *real_cred; /* objective and real subjective task 1366 const struct cred __rcu *real_cred; /* objective and real subjective task
1297 * credentials (COW) */ 1367 * credentials (COW) */
1298 const struct cred *cred; /* effective (overridable) subjective task 1368 const struct cred __rcu *cred; /* effective (overridable) subjective task
1299 * credentials (COW) */ 1369 * credentials (COW) */
1300 struct mutex cred_guard_mutex; /* guard against foreign influences on
1301 * credential calculations
1302 * (notably. ptrace) */
1303 struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */ 1370 struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
1304 1371
1305 char comm[TASK_COMM_LEN]; /* executable name excluding path 1372 char comm[TASK_COMM_LEN]; /* executable name excluding path
@@ -1400,6 +1467,11 @@ struct task_struct {
1400/* stacked block device info */ 1467/* stacked block device info */
1401 struct bio_list *bio_list; 1468 struct bio_list *bio_list;
1402 1469
1470#ifdef CONFIG_BLOCK
1471/* stack plugging */
1472 struct blk_plug *plug;
1473#endif
1474
1403/* VM state */ 1475/* VM state */
1404 struct reclaim_state *reclaim_state; 1476 struct reclaim_state *reclaim_state;
1405 1477
@@ -1423,7 +1495,7 @@ struct task_struct {
1423#endif 1495#endif
1424#ifdef CONFIG_CGROUPS 1496#ifdef CONFIG_CGROUPS
1425 /* Control Group info protected by css_set_lock */ 1497 /* Control Group info protected by css_set_lock */
1426 struct css_set *cgroups; 1498 struct css_set __rcu *cgroups;
1427 /* cg_list protected by css_set_lock and tsk->alloc_lock */ 1499 /* cg_list protected by css_set_lock and tsk->alloc_lock */
1428 struct list_head cg_list; 1500 struct list_head cg_list;
1429#endif 1501#endif
@@ -1436,13 +1508,14 @@ struct task_struct {
1436 struct futex_pi_state *pi_state_cache; 1508 struct futex_pi_state *pi_state_cache;
1437#endif 1509#endif
1438#ifdef CONFIG_PERF_EVENTS 1510#ifdef CONFIG_PERF_EVENTS
1439 struct perf_event_context *perf_event_ctxp; 1511 struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
1440 struct mutex perf_event_mutex; 1512 struct mutex perf_event_mutex;
1441 struct list_head perf_event_list; 1513 struct list_head perf_event_list;
1442#endif 1514#endif
1443#ifdef CONFIG_NUMA 1515#ifdef CONFIG_NUMA
1444 struct mempolicy *mempolicy; /* Protected by alloc_lock */ 1516 struct mempolicy *mempolicy; /* Protected by alloc_lock */
1445 short il_next; 1517 short il_next;
1518 short pref_node_fork;
1446#endif 1519#endif
1447 atomic_t fs_excl; /* holding fs exclusive resources */ 1520 atomic_t fs_excl; /* holding fs exclusive resources */
1448 struct rcu_head rcu; 1521 struct rcu_head rcu;
@@ -1495,17 +1568,20 @@ struct task_struct {
1495#ifdef CONFIG_TRACING 1568#ifdef CONFIG_TRACING
1496 /* state flags for use by tracers */ 1569 /* state flags for use by tracers */
1497 unsigned long trace; 1570 unsigned long trace;
1498 /* bitmask of trace recursion */ 1571 /* bitmask and counter of trace recursion */
1499 unsigned long trace_recursion; 1572 unsigned long trace_recursion;
1500#endif /* CONFIG_TRACING */ 1573#endif /* CONFIG_TRACING */
1501#ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */ 1574#ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */
1502 struct memcg_batch_info { 1575 struct memcg_batch_info {
1503 int do_batch; /* incremented when batch uncharge started */ 1576 int do_batch; /* incremented when batch uncharge started */
1504 struct mem_cgroup *memcg; /* target memcg of uncharge */ 1577 struct mem_cgroup *memcg; /* target memcg of uncharge */
1505 unsigned long bytes; /* uncharged usage */ 1578 unsigned long nr_pages; /* uncharged usage */
1506 unsigned long memsw_bytes; /* uncharged mem+swap usage */ 1579 unsigned long memsw_nr_pages; /* uncharged mem+swap usage */
1507 } memcg_batch; 1580 } memcg_batch;
1508#endif 1581#endif
1582#ifdef CONFIG_HAVE_HW_BREAKPOINT
1583 atomic_t ptrace_bp_refcnt;
1584#endif
1509}; 1585};
1510 1586
1511/* Future-safe accessor for struct task_struct's cpus_allowed. */ 1587/* Future-safe accessor for struct task_struct's cpus_allowed. */
@@ -1693,8 +1769,6 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
1693/* 1769/*
1694 * Per process flags 1770 * Per process flags
1695 */ 1771 */
1696#define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */
1697 /* Not implemented yet, only for 486*/
1698#define PF_STARTING 0x00000002 /* being created */ 1772#define PF_STARTING 0x00000002 /* being created */
1699#define PF_EXITING 0x00000004 /* getting shut down */ 1773#define PF_EXITING 0x00000004 /* getting shut down */
1700#define PF_EXITPIDONE 0x00000008 /* pi exit done on shut down */ 1774#define PF_EXITPIDONE 0x00000008 /* pi exit done on shut down */
@@ -1706,14 +1780,12 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
1706#define PF_DUMPCORE 0x00000200 /* dumped core */ 1780#define PF_DUMPCORE 0x00000200 /* dumped core */
1707#define PF_SIGNALED 0x00000400 /* killed by a signal */ 1781#define PF_SIGNALED 0x00000400 /* killed by a signal */
1708#define PF_MEMALLOC 0x00000800 /* Allocating memory */ 1782#define PF_MEMALLOC 0x00000800 /* Allocating memory */
1709#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */
1710#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ 1783#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */
1711#define PF_FREEZING 0x00004000 /* freeze in progress. do not account to load */ 1784#define PF_FREEZING 0x00004000 /* freeze in progress. do not account to load */
1712#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ 1785#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */
1713#define PF_FROZEN 0x00010000 /* frozen for system suspend */ 1786#define PF_FROZEN 0x00010000 /* frozen for system suspend */
1714#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ 1787#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */
1715#define PF_KSWAPD 0x00040000 /* I am kswapd */ 1788#define PF_KSWAPD 0x00040000 /* I am kswapd */
1716#define PF_OOM_ORIGIN 0x00080000 /* Allocating much memory to others */
1717#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */ 1789#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */
1718#define PF_KTHREAD 0x00200000 /* I am a kernel thread */ 1790#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
1719#define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ 1791#define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */
@@ -1724,7 +1796,7 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
1724#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ 1796#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
1725#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */ 1797#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */
1726#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ 1798#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */
1727#define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezeable */ 1799#define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezable */
1728#define PF_FREEZER_NOSIG 0x80000000 /* Freezer won't send signals to it */ 1800#define PF_FREEZER_NOSIG 0x80000000 /* Freezer won't send signals to it */
1729 1801
1730/* 1802/*
@@ -1752,16 +1824,33 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
1752#define tsk_used_math(p) ((p)->flags & PF_USED_MATH) 1824#define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
1753#define used_math() tsk_used_math(current) 1825#define used_math() tsk_used_math(current)
1754 1826
1755#ifdef CONFIG_TREE_PREEMPT_RCU 1827/*
1828 * task->group_stop flags
1829 */
1830#define GROUP_STOP_SIGMASK 0xffff /* signr of the last group stop */
1831#define GROUP_STOP_PENDING (1 << 16) /* task should stop for group stop */
1832#define GROUP_STOP_CONSUME (1 << 17) /* consume group stop count */
1833#define GROUP_STOP_TRAPPING (1 << 18) /* switching from STOPPED to TRACED */
1834#define GROUP_STOP_DEQUEUED (1 << 19) /* stop signal dequeued */
1835
1836extern void task_clear_group_stop_pending(struct task_struct *task);
1837
1838#ifdef CONFIG_PREEMPT_RCU
1756 1839
1757#define RCU_READ_UNLOCK_BLOCKED (1 << 0) /* blocked while in RCU read-side. */ 1840#define RCU_READ_UNLOCK_BLOCKED (1 << 0) /* blocked while in RCU read-side. */
1758#define RCU_READ_UNLOCK_NEED_QS (1 << 1) /* RCU core needs CPU response. */ 1841#define RCU_READ_UNLOCK_BOOSTED (1 << 1) /* boosted while in RCU read-side. */
1842#define RCU_READ_UNLOCK_NEED_QS (1 << 2) /* RCU core needs CPU response. */
1759 1843
1760static inline void rcu_copy_process(struct task_struct *p) 1844static inline void rcu_copy_process(struct task_struct *p)
1761{ 1845{
1762 p->rcu_read_lock_nesting = 0; 1846 p->rcu_read_lock_nesting = 0;
1763 p->rcu_read_unlock_special = 0; 1847 p->rcu_read_unlock_special = 0;
1848#ifdef CONFIG_TREE_PREEMPT_RCU
1764 p->rcu_blocked_node = NULL; 1849 p->rcu_blocked_node = NULL;
1850#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
1851#ifdef CONFIG_RCU_BOOST
1852 p->rcu_boost_mutex = NULL;
1853#endif /* #ifdef CONFIG_RCU_BOOST */
1765 INIT_LIST_HEAD(&p->rcu_node_entry); 1854 INIT_LIST_HEAD(&p->rcu_node_entry);
1766} 1855}
1767 1856
@@ -1774,9 +1863,16 @@ static inline void rcu_copy_process(struct task_struct *p)
1774#endif 1863#endif
1775 1864
1776#ifdef CONFIG_SMP 1865#ifdef CONFIG_SMP
1866extern void do_set_cpus_allowed(struct task_struct *p,
1867 const struct cpumask *new_mask);
1868
1777extern int set_cpus_allowed_ptr(struct task_struct *p, 1869extern int set_cpus_allowed_ptr(struct task_struct *p,
1778 const struct cpumask *new_mask); 1870 const struct cpumask *new_mask);
1779#else 1871#else
1872static inline void do_set_cpus_allowed(struct task_struct *p,
1873 const struct cpumask *new_mask)
1874{
1875}
1780static inline int set_cpus_allowed_ptr(struct task_struct *p, 1876static inline int set_cpus_allowed_ptr(struct task_struct *p,
1781 const struct cpumask *new_mask) 1877 const struct cpumask *new_mask)
1782{ 1878{
@@ -1838,6 +1934,19 @@ extern void sched_clock_idle_sleep_event(void);
1838extern void sched_clock_idle_wakeup_event(u64 delta_ns); 1934extern void sched_clock_idle_wakeup_event(u64 delta_ns);
1839#endif 1935#endif
1840 1936
1937#ifdef CONFIG_IRQ_TIME_ACCOUNTING
1938/*
1939 * An i/f to runtime opt-in for irq time accounting based off of sched_clock.
1940 * The reason for this explicit opt-in is not to have perf penalty with
1941 * slow sched_clocks.
1942 */
1943extern void enable_sched_clock_irqtime(void);
1944extern void disable_sched_clock_irqtime(void);
1945#else
1946static inline void enable_sched_clock_irqtime(void) {}
1947static inline void disable_sched_clock_irqtime(void) {}
1948#endif
1949
1841extern unsigned long long 1950extern unsigned long long
1842task_sched_runtime(struct task_struct *task); 1951task_sched_runtime(struct task_struct *task);
1843extern unsigned long long thread_group_sched_runtime(struct task_struct *task); 1952extern unsigned long long thread_group_sched_runtime(struct task_struct *task);
@@ -1853,14 +1962,11 @@ extern void sched_clock_idle_sleep_event(void);
1853extern void sched_clock_idle_wakeup_event(u64 delta_ns); 1962extern void sched_clock_idle_wakeup_event(u64 delta_ns);
1854 1963
1855#ifdef CONFIG_HOTPLUG_CPU 1964#ifdef CONFIG_HOTPLUG_CPU
1856extern void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p);
1857extern void idle_task_exit(void); 1965extern void idle_task_exit(void);
1858#else 1966#else
1859static inline void idle_task_exit(void) {} 1967static inline void idle_task_exit(void) {}
1860#endif 1968#endif
1861 1969
1862extern void sched_idle_next(void);
1863
1864#if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP) 1970#if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
1865extern void wake_up_idle_cpu(int cpu); 1971extern void wake_up_idle_cpu(int cpu);
1866#else 1972#else
@@ -1870,8 +1976,6 @@ static inline void wake_up_idle_cpu(int cpu) { }
1870extern unsigned int sysctl_sched_latency; 1976extern unsigned int sysctl_sched_latency;
1871extern unsigned int sysctl_sched_min_granularity; 1977extern unsigned int sysctl_sched_min_granularity;
1872extern unsigned int sysctl_sched_wakeup_granularity; 1978extern unsigned int sysctl_sched_wakeup_granularity;
1873extern unsigned int sysctl_sched_shares_ratelimit;
1874extern unsigned int sysctl_sched_shares_thresh;
1875extern unsigned int sysctl_sched_child_runs_first; 1979extern unsigned int sysctl_sched_child_runs_first;
1876 1980
1877enum sched_tunable_scaling { 1981enum sched_tunable_scaling {
@@ -1887,6 +1991,7 @@ extern unsigned int sysctl_sched_migration_cost;
1887extern unsigned int sysctl_sched_nr_migrate; 1991extern unsigned int sysctl_sched_nr_migrate;
1888extern unsigned int sysctl_sched_time_avg; 1992extern unsigned int sysctl_sched_time_avg;
1889extern unsigned int sysctl_timer_migration; 1993extern unsigned int sysctl_timer_migration;
1994extern unsigned int sysctl_sched_shares_window;
1890 1995
1891int sched_proc_update_handler(struct ctl_table *table, int write, 1996int sched_proc_update_handler(struct ctl_table *table, int write,
1892 void __user *buffer, size_t *length, 1997 void __user *buffer, size_t *length,
@@ -1910,7 +2015,23 @@ int sched_rt_handler(struct ctl_table *table, int write,
1910 void __user *buffer, size_t *lenp, 2015 void __user *buffer, size_t *lenp,
1911 loff_t *ppos); 2016 loff_t *ppos);
1912 2017
1913extern unsigned int sysctl_sched_compat_yield; 2018#ifdef CONFIG_SCHED_AUTOGROUP
2019extern unsigned int sysctl_sched_autogroup_enabled;
2020
2021extern void sched_autogroup_create_attach(struct task_struct *p);
2022extern void sched_autogroup_detach(struct task_struct *p);
2023extern void sched_autogroup_fork(struct signal_struct *sig);
2024extern void sched_autogroup_exit(struct signal_struct *sig);
2025#ifdef CONFIG_PROC_FS
2026extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m);
2027extern int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice);
2028#endif
2029#else
2030static inline void sched_autogroup_create_attach(struct task_struct *p) { }
2031static inline void sched_autogroup_detach(struct task_struct *p) { }
2032static inline void sched_autogroup_fork(struct signal_struct *sig) { }
2033static inline void sched_autogroup_exit(struct signal_struct *sig) { }
2034#endif
1914 2035
1915#ifdef CONFIG_RT_MUTEXES 2036#ifdef CONFIG_RT_MUTEXES
1916extern int rt_mutex_getprio(struct task_struct *p); 2037extern int rt_mutex_getprio(struct task_struct *p);
@@ -1924,15 +2045,17 @@ static inline int rt_mutex_getprio(struct task_struct *p)
1924# define rt_mutex_adjust_pi(p) do { } while (0) 2045# define rt_mutex_adjust_pi(p) do { } while (0)
1925#endif 2046#endif
1926 2047
2048extern bool yield_to(struct task_struct *p, bool preempt);
1927extern void set_user_nice(struct task_struct *p, long nice); 2049extern void set_user_nice(struct task_struct *p, long nice);
1928extern int task_prio(const struct task_struct *p); 2050extern int task_prio(const struct task_struct *p);
1929extern int task_nice(const struct task_struct *p); 2051extern int task_nice(const struct task_struct *p);
1930extern int can_nice(const struct task_struct *p, const int nice); 2052extern int can_nice(const struct task_struct *p, const int nice);
1931extern int task_curr(const struct task_struct *p); 2053extern int task_curr(const struct task_struct *p);
1932extern int idle_cpu(int cpu); 2054extern int idle_cpu(int cpu);
1933extern int sched_setscheduler(struct task_struct *, int, struct sched_param *); 2055extern int sched_setscheduler(struct task_struct *, int,
2056 const struct sched_param *);
1934extern int sched_setscheduler_nocheck(struct task_struct *, int, 2057extern int sched_setscheduler_nocheck(struct task_struct *, int,
1935 struct sched_param *); 2058 const struct sched_param *);
1936extern struct task_struct *idle_task(int cpu); 2059extern struct task_struct *idle_task(int cpu);
1937extern struct task_struct *curr_task(int cpu); 2060extern struct task_struct *curr_task(int cpu);
1938extern void set_curr_task(int cpu, struct task_struct *p); 2061extern void set_curr_task(int cpu, struct task_struct *p);
@@ -1995,18 +2118,17 @@ extern void release_uids(struct user_namespace *ns);
1995 2118
1996#include <asm/current.h> 2119#include <asm/current.h>
1997 2120
1998extern void do_timer(unsigned long ticks); 2121extern void xtime_update(unsigned long ticks);
1999 2122
2000extern int wake_up_state(struct task_struct *tsk, unsigned int state); 2123extern int wake_up_state(struct task_struct *tsk, unsigned int state);
2001extern int wake_up_process(struct task_struct *tsk); 2124extern int wake_up_process(struct task_struct *tsk);
2002extern void wake_up_new_task(struct task_struct *tsk, 2125extern void wake_up_new_task(struct task_struct *tsk);
2003 unsigned long clone_flags);
2004#ifdef CONFIG_SMP 2126#ifdef CONFIG_SMP
2005 extern void kick_process(struct task_struct *tsk); 2127 extern void kick_process(struct task_struct *tsk);
2006#else 2128#else
2007 static inline void kick_process(struct task_struct *tsk) { } 2129 static inline void kick_process(struct task_struct *tsk) { }
2008#endif 2130#endif
2009extern void sched_fork(struct task_struct *p, int clone_flags); 2131extern void sched_fork(struct task_struct *p);
2010extern void sched_dead(struct task_struct *p); 2132extern void sched_dead(struct task_struct *p);
2011 2133
2012extern void proc_caches_init(void); 2134extern void proc_caches_init(void);
@@ -2131,8 +2253,10 @@ extern void set_task_comm(struct task_struct *tsk, char *from);
2131extern char *get_task_comm(char *to, struct task_struct *tsk); 2253extern char *get_task_comm(char *to, struct task_struct *tsk);
2132 2254
2133#ifdef CONFIG_SMP 2255#ifdef CONFIG_SMP
2256void scheduler_ipi(void);
2134extern unsigned long wait_task_inactive(struct task_struct *, long match_state); 2257extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
2135#else 2258#else
2259static inline void scheduler_ipi(void) { }
2136static inline unsigned long wait_task_inactive(struct task_struct *p, 2260static inline unsigned long wait_task_inactive(struct task_struct *p,
2137 long match_state) 2261 long match_state)
2138{ 2262{
@@ -2222,15 +2346,47 @@ static inline void task_unlock(struct task_struct *p)
2222 spin_unlock(&p->alloc_lock); 2346 spin_unlock(&p->alloc_lock);
2223} 2347}
2224 2348
2225extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk, 2349extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
2226 unsigned long *flags); 2350 unsigned long *flags);
2227 2351
2352#define lock_task_sighand(tsk, flags) \
2353({ struct sighand_struct *__ss; \
2354 __cond_lock(&(tsk)->sighand->siglock, \
2355 (__ss = __lock_task_sighand(tsk, flags))); \
2356 __ss; \
2357}) \
2358
2228static inline void unlock_task_sighand(struct task_struct *tsk, 2359static inline void unlock_task_sighand(struct task_struct *tsk,
2229 unsigned long *flags) 2360 unsigned long *flags)
2230{ 2361{
2231 spin_unlock_irqrestore(&tsk->sighand->siglock, *flags); 2362 spin_unlock_irqrestore(&tsk->sighand->siglock, *flags);
2232} 2363}
2233 2364
2365/* See the declaration of threadgroup_fork_lock in signal_struct. */
2366#ifdef CONFIG_CGROUPS
2367static inline void threadgroup_fork_read_lock(struct task_struct *tsk)
2368{
2369 down_read(&tsk->signal->threadgroup_fork_lock);
2370}
2371static inline void threadgroup_fork_read_unlock(struct task_struct *tsk)
2372{
2373 up_read(&tsk->signal->threadgroup_fork_lock);
2374}
2375static inline void threadgroup_fork_write_lock(struct task_struct *tsk)
2376{
2377 down_write(&tsk->signal->threadgroup_fork_lock);
2378}
2379static inline void threadgroup_fork_write_unlock(struct task_struct *tsk)
2380{
2381 up_write(&tsk->signal->threadgroup_fork_lock);
2382}
2383#else
2384static inline void threadgroup_fork_read_lock(struct task_struct *tsk) {}
2385static inline void threadgroup_fork_read_unlock(struct task_struct *tsk) {}
2386static inline void threadgroup_fork_write_lock(struct task_struct *tsk) {}
2387static inline void threadgroup_fork_write_unlock(struct task_struct *tsk) {}
2388#endif
2389
2234#ifndef __HAVE_THREAD_FUNCTIONS 2390#ifndef __HAVE_THREAD_FUNCTIONS
2235 2391
2236#define task_thread_info(task) ((struct thread_info *)(task)->stack) 2392#define task_thread_info(task) ((struct thread_info *)(task)->stack)
@@ -2380,9 +2536,9 @@ extern int __cond_resched_lock(spinlock_t *lock);
2380 2536
2381extern int __cond_resched_softirq(void); 2537extern int __cond_resched_softirq(void);
2382 2538
2383#define cond_resched_softirq() ({ \ 2539#define cond_resched_softirq() ({ \
2384 __might_sleep(__FILE__, __LINE__, SOFTIRQ_OFFSET); \ 2540 __might_sleep(__FILE__, __LINE__, SOFTIRQ_DISABLE_OFFSET); \
2385 __cond_resched_softirq(); \ 2541 __cond_resched_softirq(); \
2386}) 2542})
2387 2543
2388/* 2544/*
@@ -2453,7 +2609,7 @@ extern void normalize_rt_tasks(void);
2453 2609
2454#ifdef CONFIG_CGROUP_SCHED 2610#ifdef CONFIG_CGROUP_SCHED
2455 2611
2456extern struct task_group init_task_group; 2612extern struct task_group root_task_group;
2457 2613
2458extern struct task_group *sched_create_group(struct task_group *parent); 2614extern struct task_group *sched_create_group(struct task_group *parent);
2459extern void sched_destroy_group(struct task_group *tg); 2615extern void sched_destroy_group(struct task_group *tg);
@@ -2518,13 +2674,6 @@ static inline void inc_syscw(struct task_struct *tsk)
2518#define TASK_SIZE_OF(tsk) TASK_SIZE 2674#define TASK_SIZE_OF(tsk) TASK_SIZE
2519#endif 2675#endif
2520 2676
2521/*
2522 * Call the function if the target task is executing on a CPU right now:
2523 */
2524extern void task_oncpu_function_call(struct task_struct *p,
2525 void (*func) (void *info), void *info);
2526
2527
2528#ifdef CONFIG_MM_OWNER 2677#ifdef CONFIG_MM_OWNER
2529extern void mm_update_next_owner(struct mm_struct *mm); 2678extern void mm_update_next_owner(struct mm_struct *mm);
2530extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p); 2679extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p);
diff --git a/include/linux/sdla.h b/include/linux/sdla.h
index 564acd3a71c1..9995c7fc3f60 100644
--- a/include/linux/sdla.h
+++ b/include/linux/sdla.h
@@ -112,11 +112,7 @@ struct sdla_dlci_conf {
112 short Tb_max; 112 short Tb_max;
113}; 113};
114 114
115#ifndef __KERNEL__ 115#ifdef __KERNEL__
116
117void sdla(void *cfg_info, char *dev, struct frad_conf *conf, int quiet);
118
119#else
120 116
121/* important Z80 window addresses */ 117/* important Z80 window addresses */
122#define SDLA_CONTROL_WND 0xE000 118#define SDLA_CONTROL_WND 0xE000
diff --git a/include/linux/security.h b/include/linux/security.h
index a22219afff09..8ce59ef3e5af 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -25,6 +25,7 @@
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/fsnotify.h> 26#include <linux/fsnotify.h>
27#include <linux/binfmts.h> 27#include <linux/binfmts.h>
28#include <linux/dcache.h>
28#include <linux/signal.h> 29#include <linux/signal.h>
29#include <linux/resource.h> 30#include <linux/resource.h>
30#include <linux/sem.h> 31#include <linux/sem.h>
@@ -46,14 +47,15 @@
46 47
47struct ctl_table; 48struct ctl_table;
48struct audit_krule; 49struct audit_krule;
50struct user_namespace;
49 51
50/* 52/*
51 * These functions are in security/capability.c and are used 53 * These functions are in security/capability.c and are used
52 * as the default capabilities functions 54 * as the default capabilities functions
53 */ 55 */
54extern int cap_capable(struct task_struct *tsk, const struct cred *cred, 56extern int cap_capable(struct task_struct *tsk, const struct cred *cred,
55 int cap, int audit); 57 struct user_namespace *ns, int cap, int audit);
56extern int cap_settime(struct timespec *ts, struct timezone *tz); 58extern int cap_settime(const struct timespec *ts, const struct timezone *tz);
57extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode); 59extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
58extern int cap_ptrace_traceme(struct task_struct *parent); 60extern int cap_ptrace_traceme(struct task_struct *parent);
59extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 61extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -74,10 +76,9 @@ extern int cap_file_mmap(struct file *file, unsigned long reqprot,
74extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); 76extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
75extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, 77extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
76 unsigned long arg4, unsigned long arg5); 78 unsigned long arg4, unsigned long arg5);
77extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp); 79extern int cap_task_setscheduler(struct task_struct *p);
78extern int cap_task_setioprio(struct task_struct *p, int ioprio); 80extern int cap_task_setioprio(struct task_struct *p, int ioprio);
79extern int cap_task_setnice(struct task_struct *p, int nice); 81extern int cap_task_setnice(struct task_struct *p, int nice);
80extern int cap_syslog(int type, bool from_file);
81extern int cap_vm_enough_memory(struct mm_struct *mm, long pages); 82extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
82 83
83struct msghdr; 84struct msghdr;
@@ -268,6 +269,12 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
268 * @orig the original mount data copied from userspace. 269 * @orig the original mount data copied from userspace.
269 * @copy copied data which will be passed to the security module. 270 * @copy copied data which will be passed to the security module.
270 * Returns 0 if the copy was successful. 271 * Returns 0 if the copy was successful.
272 * @sb_remount:
273 * Extracts security system specifc mount options and verifys no changes
274 * are being made to those options.
275 * @sb superblock being remounted
276 * @data contains the filesystem-specific data.
277 * Return 0 if permission is granted.
271 * @sb_umount: 278 * @sb_umount:
272 * Check permission before the @mnt file system is unmounted. 279 * Check permission before the @mnt file system is unmounted.
273 * @mnt contains the mounted file system. 280 * @mnt contains the mounted file system.
@@ -316,6 +323,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
316 * then it should return -EOPNOTSUPP to skip this processing. 323 * then it should return -EOPNOTSUPP to skip this processing.
317 * @inode contains the inode structure of the newly created inode. 324 * @inode contains the inode structure of the newly created inode.
318 * @dir contains the inode structure of the parent directory. 325 * @dir contains the inode structure of the parent directory.
326 * @qstr contains the last path component of the new object
319 * @name will be set to the allocated name suffix (e.g. selinux). 327 * @name will be set to the allocated name suffix (e.g. selinux).
320 * @value will be set to the allocated attribute value. 328 * @value will be set to the allocated attribute value.
321 * @len will be set to the length of the value. 329 * @len will be set to the length of the value.
@@ -458,7 +466,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
458 * called when the actual read/write operations are performed. 466 * called when the actual read/write operations are performed.
459 * @inode contains the inode structure to check. 467 * @inode contains the inode structure to check.
460 * @mask contains the permission mask. 468 * @mask contains the permission mask.
461 * @nd contains the nameidata (may be NULL).
462 * Return 0 if permission is granted. 469 * Return 0 if permission is granted.
463 * @inode_setattr: 470 * @inode_setattr:
464 * Check permission before setting file attributes. Note that the kernel 471 * Check permission before setting file attributes. Note that the kernel
@@ -797,8 +804,9 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
797 * @unix_stream_connect: 804 * @unix_stream_connect:
798 * Check permissions before establishing a Unix domain stream connection 805 * Check permissions before establishing a Unix domain stream connection
799 * between @sock and @other. 806 * between @sock and @other.
800 * @sock contains the socket structure. 807 * @sock contains the sock structure.
801 * @other contains the peer socket structure. 808 * @other contains the peer sock structure.
809 * @newsk contains the new sock structure.
802 * Return 0 if permission is granted. 810 * Return 0 if permission is granted.
803 * @unix_may_send: 811 * @unix_may_send:
804 * Check permissions before connecting or sending datagrams from @sock to 812 * Check permissions before connecting or sending datagrams from @sock to
@@ -959,6 +967,12 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
959 * Sets the new child socket's sid to the openreq sid. 967 * Sets the new child socket's sid to the openreq sid.
960 * @inet_conn_established: 968 * @inet_conn_established:
961 * Sets the connection's peersid to the secmark on skb. 969 * Sets the connection's peersid to the secmark on skb.
970 * @secmark_relabel_packet:
971 * check if the process should be allowed to relabel packets to the given secid
972 * @security_secmark_refcount_inc
973 * tells the LSM to increment the number of secmark labeling rules loaded
974 * @security_secmark_refcount_dec
975 * tells the LSM to decrement the number of secmark labeling rules loaded
962 * @req_classify_flow: 976 * @req_classify_flow:
963 * Sets the flow's sid to the openreq sid. 977 * Sets the flow's sid to the openreq sid.
964 * @tun_dev_create: 978 * @tun_dev_create:
@@ -1053,8 +1067,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1053 * @cred points to the credentials to provide the context against which to 1067 * @cred points to the credentials to provide the context against which to
1054 * evaluate the security data on the key. 1068 * evaluate the security data on the key.
1055 * @perm describes the combination of permissions required of this key. 1069 * @perm describes the combination of permissions required of this key.
1056 * Return 1 if permission granted, 0 if permission denied and -ve it the 1070 * Return 0 if permission is granted, -ve error otherwise.
1057 * normal permissions model should be effected.
1058 * @key_getsecurity: 1071 * @key_getsecurity:
1059 * Get a textual representation of the security context attached to a key 1072 * Get a textual representation of the security context attached to a key
1060 * for the purposes of honouring KEYCTL_GETSECURITY. This function 1073 * for the purposes of honouring KEYCTL_GETSECURITY. This function
@@ -1250,15 +1263,10 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1250 * credentials. 1263 * credentials.
1251 * @tsk contains the task_struct for the process. 1264 * @tsk contains the task_struct for the process.
1252 * @cred contains the credentials to use. 1265 * @cred contains the credentials to use.
1266 * @ns contains the user namespace we want the capability in
1253 * @cap contains the capability <include/linux/capability.h>. 1267 * @cap contains the capability <include/linux/capability.h>.
1254 * @audit: Whether to write an audit message or not 1268 * @audit: Whether to write an audit message or not
1255 * Return 0 if the capability is granted for @tsk. 1269 * Return 0 if the capability is granted for @tsk.
1256 * @sysctl:
1257 * Check permission before accessing the @table sysctl variable in the
1258 * manner specified by @op.
1259 * @table contains the ctl_table structure for the sysctl variable.
1260 * @op contains the operation (001 = search, 002 = write, 004 = read).
1261 * Return 0 if permission is granted.
1262 * @syslog: 1270 * @syslog:
1263 * Check permission before accessing the kernel message ring or changing 1271 * Check permission before accessing the kernel message ring or changing
1264 * logging to the console. 1272 * logging to the console.
@@ -1279,9 +1287,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1279 * Return 0 if permission is granted. 1287 * Return 0 if permission is granted.
1280 * 1288 *
1281 * @secid_to_secctx: 1289 * @secid_to_secctx:
1282 * Convert secid to security context. 1290 * Convert secid to security context. If secdata is NULL the length of
1291 * the result will be returned in seclen, but no secdata will be returned.
1292 * This does mean that the length could change between calls to check the
1293 * length and the next call which actually allocates and returns the secdata.
1283 * @secid contains the security ID. 1294 * @secid contains the security ID.
1284 * @secdata contains the pointer that stores the converted security context. 1295 * @secdata contains the pointer that stores the converted security context.
1296 * @seclen pointer which contains the length of the data
1285 * @secctx_to_secid: 1297 * @secctx_to_secid:
1286 * Convert security context to secid. 1298 * Convert security context to secid.
1287 * @secid contains the pointer to the generated security ID. 1299 * @secid contains the pointer to the generated security ID.
@@ -1374,12 +1386,11 @@ struct security_operations {
1374 const kernel_cap_t *inheritable, 1386 const kernel_cap_t *inheritable,
1375 const kernel_cap_t *permitted); 1387 const kernel_cap_t *permitted);
1376 int (*capable) (struct task_struct *tsk, const struct cred *cred, 1388 int (*capable) (struct task_struct *tsk, const struct cred *cred,
1377 int cap, int audit); 1389 struct user_namespace *ns, int cap, int audit);
1378 int (*sysctl) (struct ctl_table *table, int op);
1379 int (*quotactl) (int cmds, int type, int id, struct super_block *sb); 1390 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1380 int (*quota_on) (struct dentry *dentry); 1391 int (*quota_on) (struct dentry *dentry);
1381 int (*syslog) (int type, bool from_file); 1392 int (*syslog) (int type);
1382 int (*settime) (struct timespec *ts, struct timezone *tz); 1393 int (*settime) (const struct timespec *ts, const struct timezone *tz);
1383 int (*vm_enough_memory) (struct mm_struct *mm, long pages); 1394 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1384 1395
1385 int (*bprm_set_creds) (struct linux_binprm *bprm); 1396 int (*bprm_set_creds) (struct linux_binprm *bprm);
@@ -1391,6 +1402,7 @@ struct security_operations {
1391 int (*sb_alloc_security) (struct super_block *sb); 1402 int (*sb_alloc_security) (struct super_block *sb);
1392 void (*sb_free_security) (struct super_block *sb); 1403 void (*sb_free_security) (struct super_block *sb);
1393 int (*sb_copy_data) (char *orig, char *copy); 1404 int (*sb_copy_data) (char *orig, char *copy);
1405 int (*sb_remount) (struct super_block *sb, void *data);
1394 int (*sb_kern_mount) (struct super_block *sb, int flags, void *data); 1406 int (*sb_kern_mount) (struct super_block *sb, int flags, void *data);
1395 int (*sb_show_options) (struct seq_file *m, struct super_block *sb); 1407 int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
1396 int (*sb_statfs) (struct dentry *dentry); 1408 int (*sb_statfs) (struct dentry *dentry);
@@ -1427,7 +1439,8 @@ struct security_operations {
1427 int (*inode_alloc_security) (struct inode *inode); 1439 int (*inode_alloc_security) (struct inode *inode);
1428 void (*inode_free_security) (struct inode *inode); 1440 void (*inode_free_security) (struct inode *inode);
1429 int (*inode_init_security) (struct inode *inode, struct inode *dir, 1441 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1430 char **name, void **value, size_t *len); 1442 const struct qstr *qstr, char **name,
1443 void **value, size_t *len);
1431 int (*inode_create) (struct inode *dir, 1444 int (*inode_create) (struct inode *dir,
1432 struct dentry *dentry, int mode); 1445 struct dentry *dentry, int mode);
1433 int (*inode_link) (struct dentry *old_dentry, 1446 int (*inode_link) (struct dentry *old_dentry,
@@ -1443,7 +1456,7 @@ struct security_operations {
1443 struct inode *new_dir, struct dentry *new_dentry); 1456 struct inode *new_dir, struct dentry *new_dentry);
1444 int (*inode_readlink) (struct dentry *dentry); 1457 int (*inode_readlink) (struct dentry *dentry);
1445 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); 1458 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1446 int (*inode_permission) (struct inode *inode, int mask); 1459 int (*inode_permission) (struct inode *inode, int mask, unsigned flags);
1447 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr); 1460 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1448 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry); 1461 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1449 int (*inode_setxattr) (struct dentry *dentry, const char *name, 1462 int (*inode_setxattr) (struct dentry *dentry, const char *name,
@@ -1501,8 +1514,7 @@ struct security_operations {
1501 int (*task_getioprio) (struct task_struct *p); 1514 int (*task_getioprio) (struct task_struct *p);
1502 int (*task_setrlimit) (struct task_struct *p, unsigned int resource, 1515 int (*task_setrlimit) (struct task_struct *p, unsigned int resource,
1503 struct rlimit *new_rlim); 1516 struct rlimit *new_rlim);
1504 int (*task_setscheduler) (struct task_struct *p, int policy, 1517 int (*task_setscheduler) (struct task_struct *p);
1505 struct sched_param *lp);
1506 int (*task_getscheduler) (struct task_struct *p); 1518 int (*task_getscheduler) (struct task_struct *p);
1507 int (*task_movememory) (struct task_struct *p); 1519 int (*task_movememory) (struct task_struct *p);
1508 int (*task_kill) (struct task_struct *p, 1520 int (*task_kill) (struct task_struct *p,
@@ -1560,8 +1572,7 @@ struct security_operations {
1560 int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen); 1572 int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
1561 1573
1562#ifdef CONFIG_SECURITY_NETWORK 1574#ifdef CONFIG_SECURITY_NETWORK
1563 int (*unix_stream_connect) (struct socket *sock, 1575 int (*unix_stream_connect) (struct sock *sock, struct sock *other, struct sock *newsk);
1564 struct socket *other, struct sock *newsk);
1565 int (*unix_may_send) (struct socket *sock, struct socket *other); 1576 int (*unix_may_send) (struct socket *sock, struct socket *other);
1566 1577
1567 int (*socket_create) (int family, int type, int protocol, int kern); 1578 int (*socket_create) (int family, int type, int protocol, int kern);
@@ -1594,6 +1605,9 @@ struct security_operations {
1594 struct request_sock *req); 1605 struct request_sock *req);
1595 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req); 1606 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1596 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb); 1607 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1608 int (*secmark_relabel_packet) (u32 secid);
1609 void (*secmark_refcount_inc) (void);
1610 void (*secmark_refcount_dec) (void);
1597 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl); 1611 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
1598 int (*tun_dev_create)(void); 1612 int (*tun_dev_create)(void);
1599 void (*tun_dev_post_create)(struct sock *sk); 1613 void (*tun_dev_post_create)(struct sock *sk);
@@ -1614,7 +1628,7 @@ struct security_operations {
1614 int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir); 1628 int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1615 int (*xfrm_state_pol_flow_match) (struct xfrm_state *x, 1629 int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1616 struct xfrm_policy *xp, 1630 struct xfrm_policy *xp,
1617 struct flowi *fl); 1631 const struct flowi *fl);
1618 int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall); 1632 int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
1619#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1633#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1620 1634
@@ -1653,14 +1667,16 @@ int security_capset(struct cred *new, const struct cred *old,
1653 const kernel_cap_t *effective, 1667 const kernel_cap_t *effective,
1654 const kernel_cap_t *inheritable, 1668 const kernel_cap_t *inheritable,
1655 const kernel_cap_t *permitted); 1669 const kernel_cap_t *permitted);
1656int security_capable(int cap); 1670int security_capable(struct user_namespace *ns, const struct cred *cred,
1657int security_real_capable(struct task_struct *tsk, int cap); 1671 int cap);
1658int security_real_capable_noaudit(struct task_struct *tsk, int cap); 1672int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
1659int security_sysctl(struct ctl_table *table, int op); 1673 int cap);
1674int security_real_capable_noaudit(struct task_struct *tsk,
1675 struct user_namespace *ns, int cap);
1660int security_quotactl(int cmds, int type, int id, struct super_block *sb); 1676int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1661int security_quota_on(struct dentry *dentry); 1677int security_quota_on(struct dentry *dentry);
1662int security_syslog(int type, bool from_file); 1678int security_syslog(int type);
1663int security_settime(struct timespec *ts, struct timezone *tz); 1679int security_settime(const struct timespec *ts, const struct timezone *tz);
1664int security_vm_enough_memory(long pages); 1680int security_vm_enough_memory(long pages);
1665int security_vm_enough_memory_mm(struct mm_struct *mm, long pages); 1681int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1666int security_vm_enough_memory_kern(long pages); 1682int security_vm_enough_memory_kern(long pages);
@@ -1672,6 +1688,7 @@ int security_bprm_secureexec(struct linux_binprm *bprm);
1672int security_sb_alloc(struct super_block *sb); 1688int security_sb_alloc(struct super_block *sb);
1673void security_sb_free(struct super_block *sb); 1689void security_sb_free(struct super_block *sb);
1674int security_sb_copy_data(char *orig, char *copy); 1690int security_sb_copy_data(char *orig, char *copy);
1691int security_sb_remount(struct super_block *sb, void *data);
1675int security_sb_kern_mount(struct super_block *sb, int flags, void *data); 1692int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
1676int security_sb_show_options(struct seq_file *m, struct super_block *sb); 1693int security_sb_show_options(struct seq_file *m, struct super_block *sb);
1677int security_sb_statfs(struct dentry *dentry); 1694int security_sb_statfs(struct dentry *dentry);
@@ -1687,7 +1704,8 @@ int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
1687int security_inode_alloc(struct inode *inode); 1704int security_inode_alloc(struct inode *inode);
1688void security_inode_free(struct inode *inode); 1705void security_inode_free(struct inode *inode);
1689int security_inode_init_security(struct inode *inode, struct inode *dir, 1706int security_inode_init_security(struct inode *inode, struct inode *dir,
1690 char **name, void **value, size_t *len); 1707 const struct qstr *qstr, char **name,
1708 void **value, size_t *len);
1691int security_inode_create(struct inode *dir, struct dentry *dentry, int mode); 1709int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1692int security_inode_link(struct dentry *old_dentry, struct inode *dir, 1710int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1693 struct dentry *new_dentry); 1711 struct dentry *new_dentry);
@@ -1702,6 +1720,7 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1702int security_inode_readlink(struct dentry *dentry); 1720int security_inode_readlink(struct dentry *dentry);
1703int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd); 1721int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1704int security_inode_permission(struct inode *inode, int mask); 1722int security_inode_permission(struct inode *inode, int mask);
1723int security_inode_exec_permission(struct inode *inode, unsigned int flags);
1705int security_inode_setattr(struct dentry *dentry, struct iattr *attr); 1724int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1706int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry); 1725int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1707int security_inode_setxattr(struct dentry *dentry, const char *name, 1726int security_inode_setxattr(struct dentry *dentry, const char *name,
@@ -1752,8 +1771,7 @@ int security_task_setioprio(struct task_struct *p, int ioprio);
1752int security_task_getioprio(struct task_struct *p); 1771int security_task_getioprio(struct task_struct *p);
1753int security_task_setrlimit(struct task_struct *p, unsigned int resource, 1772int security_task_setrlimit(struct task_struct *p, unsigned int resource,
1754 struct rlimit *new_rlim); 1773 struct rlimit *new_rlim);
1755int security_task_setscheduler(struct task_struct *p, 1774int security_task_setscheduler(struct task_struct *p);
1756 int policy, struct sched_param *lp);
1757int security_task_getscheduler(struct task_struct *p); 1775int security_task_getscheduler(struct task_struct *p);
1758int security_task_movememory(struct task_struct *p); 1776int security_task_movememory(struct task_struct *p);
1759int security_task_kill(struct task_struct *p, struct siginfo *info, 1777int security_task_kill(struct task_struct *p, struct siginfo *info,
@@ -1847,38 +1865,34 @@ static inline int security_capset(struct cred *new,
1847 return cap_capset(new, old, effective, inheritable, permitted); 1865 return cap_capset(new, old, effective, inheritable, permitted);
1848} 1866}
1849 1867
1850static inline int security_capable(int cap) 1868static inline int security_capable(struct user_namespace *ns,
1869 const struct cred *cred, int cap)
1851{ 1870{
1852 return cap_capable(current, current_cred(), cap, SECURITY_CAP_AUDIT); 1871 return cap_capable(current, cred, ns, cap, SECURITY_CAP_AUDIT);
1853} 1872}
1854 1873
1855static inline int security_real_capable(struct task_struct *tsk, int cap) 1874static inline int security_real_capable(struct task_struct *tsk, struct user_namespace *ns, int cap)
1856{ 1875{
1857 int ret; 1876 int ret;
1858 1877
1859 rcu_read_lock(); 1878 rcu_read_lock();
1860 ret = cap_capable(tsk, __task_cred(tsk), cap, SECURITY_CAP_AUDIT); 1879 ret = cap_capable(tsk, __task_cred(tsk), ns, cap, SECURITY_CAP_AUDIT);
1861 rcu_read_unlock(); 1880 rcu_read_unlock();
1862 return ret; 1881 return ret;
1863} 1882}
1864 1883
1865static inline 1884static inline
1866int security_real_capable_noaudit(struct task_struct *tsk, int cap) 1885int security_real_capable_noaudit(struct task_struct *tsk, struct user_namespace *ns, int cap)
1867{ 1886{
1868 int ret; 1887 int ret;
1869 1888
1870 rcu_read_lock(); 1889 rcu_read_lock();
1871 ret = cap_capable(tsk, __task_cred(tsk), cap, 1890 ret = cap_capable(tsk, __task_cred(tsk), ns, cap,
1872 SECURITY_CAP_NOAUDIT); 1891 SECURITY_CAP_NOAUDIT);
1873 rcu_read_unlock(); 1892 rcu_read_unlock();
1874 return ret; 1893 return ret;
1875} 1894}
1876 1895
1877static inline int security_sysctl(struct ctl_table *table, int op)
1878{
1879 return 0;
1880}
1881
1882static inline int security_quotactl(int cmds, int type, int id, 1896static inline int security_quotactl(int cmds, int type, int id,
1883 struct super_block *sb) 1897 struct super_block *sb)
1884{ 1898{
@@ -1890,12 +1904,13 @@ static inline int security_quota_on(struct dentry *dentry)
1890 return 0; 1904 return 0;
1891} 1905}
1892 1906
1893static inline int security_syslog(int type, bool from_file) 1907static inline int security_syslog(int type)
1894{ 1908{
1895 return cap_syslog(type, from_file); 1909 return 0;
1896} 1910}
1897 1911
1898static inline int security_settime(struct timespec *ts, struct timezone *tz) 1912static inline int security_settime(const struct timespec *ts,
1913 const struct timezone *tz)
1899{ 1914{
1900 return cap_settime(ts, tz); 1915 return cap_settime(ts, tz);
1901} 1916}
@@ -1955,6 +1970,11 @@ static inline int security_sb_copy_data(char *orig, char *copy)
1955 return 0; 1970 return 0;
1956} 1971}
1957 1972
1973static inline int security_sb_remount(struct super_block *sb, void *data)
1974{
1975 return 0;
1976}
1977
1958static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data) 1978static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data)
1959{ 1979{
1960 return 0; 1980 return 0;
@@ -2014,6 +2034,7 @@ static inline void security_inode_free(struct inode *inode)
2014 2034
2015static inline int security_inode_init_security(struct inode *inode, 2035static inline int security_inode_init_security(struct inode *inode,
2016 struct inode *dir, 2036 struct inode *dir,
2037 const struct qstr *qstr,
2017 char **name, 2038 char **name,
2018 void **value, 2039 void **value,
2019 size_t *len) 2040 size_t *len)
@@ -2092,6 +2113,12 @@ static inline int security_inode_permission(struct inode *inode, int mask)
2092 return 0; 2113 return 0;
2093} 2114}
2094 2115
2116static inline int security_inode_exec_permission(struct inode *inode,
2117 unsigned int flags)
2118{
2119 return 0;
2120}
2121
2095static inline int security_inode_setattr(struct dentry *dentry, 2122static inline int security_inode_setattr(struct dentry *dentry,
2096 struct iattr *attr) 2123 struct iattr *attr)
2097{ 2124{
@@ -2320,11 +2347,9 @@ static inline int security_task_setrlimit(struct task_struct *p,
2320 return 0; 2347 return 0;
2321} 2348}
2322 2349
2323static inline int security_task_setscheduler(struct task_struct *p, 2350static inline int security_task_setscheduler(struct task_struct *p)
2324 int policy,
2325 struct sched_param *lp)
2326{ 2351{
2327 return cap_task_setscheduler(p, policy, lp); 2352 return cap_task_setscheduler(p);
2328} 2353}
2329 2354
2330static inline int security_task_getscheduler(struct task_struct *p) 2355static inline int security_task_getscheduler(struct task_struct *p)
@@ -2517,8 +2542,7 @@ static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32
2517 2542
2518#ifdef CONFIG_SECURITY_NETWORK 2543#ifdef CONFIG_SECURITY_NETWORK
2519 2544
2520int security_unix_stream_connect(struct socket *sock, struct socket *other, 2545int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
2521 struct sock *newsk);
2522int security_unix_may_send(struct socket *sock, struct socket *other); 2546int security_unix_may_send(struct socket *sock, struct socket *other);
2523int security_socket_create(int family, int type, int protocol, int kern); 2547int security_socket_create(int family, int type, int protocol, int kern);
2524int security_socket_post_create(struct socket *sock, int family, 2548int security_socket_post_create(struct socket *sock, int family,
@@ -2551,13 +2575,16 @@ void security_inet_csk_clone(struct sock *newsk,
2551 const struct request_sock *req); 2575 const struct request_sock *req);
2552void security_inet_conn_established(struct sock *sk, 2576void security_inet_conn_established(struct sock *sk,
2553 struct sk_buff *skb); 2577 struct sk_buff *skb);
2578int security_secmark_relabel_packet(u32 secid);
2579void security_secmark_refcount_inc(void);
2580void security_secmark_refcount_dec(void);
2554int security_tun_dev_create(void); 2581int security_tun_dev_create(void);
2555void security_tun_dev_post_create(struct sock *sk); 2582void security_tun_dev_post_create(struct sock *sk);
2556int security_tun_dev_attach(struct sock *sk); 2583int security_tun_dev_attach(struct sock *sk);
2557 2584
2558#else /* CONFIG_SECURITY_NETWORK */ 2585#else /* CONFIG_SECURITY_NETWORK */
2559static inline int security_unix_stream_connect(struct socket *sock, 2586static inline int security_unix_stream_connect(struct sock *sock,
2560 struct socket *other, 2587 struct sock *other,
2561 struct sock *newsk) 2588 struct sock *newsk)
2562{ 2589{
2563 return 0; 2590 return 0;
@@ -2705,6 +2732,19 @@ static inline void security_inet_conn_established(struct sock *sk,
2705{ 2732{
2706} 2733}
2707 2734
2735static inline int security_secmark_relabel_packet(u32 secid)
2736{
2737 return 0;
2738}
2739
2740static inline void security_secmark_refcount_inc(void)
2741{
2742}
2743
2744static inline void security_secmark_refcount_dec(void)
2745{
2746}
2747
2708static inline int security_tun_dev_create(void) 2748static inline int security_tun_dev_create(void)
2709{ 2749{
2710 return 0; 2750 return 0;
@@ -2733,7 +2773,8 @@ int security_xfrm_state_delete(struct xfrm_state *x);
2733void security_xfrm_state_free(struct xfrm_state *x); 2773void security_xfrm_state_free(struct xfrm_state *x);
2734int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir); 2774int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
2735int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 2775int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2736 struct xfrm_policy *xp, struct flowi *fl); 2776 struct xfrm_policy *xp,
2777 const struct flowi *fl);
2737int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid); 2778int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2738void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl); 2779void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
2739 2780
@@ -2785,7 +2826,7 @@ static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_s
2785} 2826}
2786 2827
2787static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 2828static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2788 struct xfrm_policy *xp, struct flowi *fl) 2829 struct xfrm_policy *xp, const struct flowi *fl)
2789{ 2830{
2790 return 1; 2831 return 1;
2791} 2832}
diff --git a/include/linux/selection.h b/include/linux/selection.h
index 8cdaa1151d2e..85193aa8c1e3 100644
--- a/include/linux/selection.h
+++ b/include/linux/selection.h
@@ -39,5 +39,6 @@ extern void putconsxy(struct vc_data *vc, unsigned char *p);
39 39
40extern u16 vcs_scr_readw(struct vc_data *vc, const u16 *org); 40extern u16 vcs_scr_readw(struct vc_data *vc, const u16 *org);
41extern void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org); 41extern void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org);
42extern void vcs_scr_updated(struct vc_data *vc);
42 43
43#endif 44#endif
diff --git a/include/linux/selinux.h b/include/linux/selinux.h
index 82e0f26a1299..44f459612690 100644
--- a/include/linux/selinux.h
+++ b/include/linux/selinux.h
@@ -21,74 +21,11 @@ struct kern_ipc_perm;
21#ifdef CONFIG_SECURITY_SELINUX 21#ifdef CONFIG_SECURITY_SELINUX
22 22
23/** 23/**
24 * selinux_string_to_sid - map a security context string to a security ID
25 * @str: the security context string to be mapped
26 * @sid: ID value returned via this.
27 *
28 * Returns 0 if successful, with the SID stored in sid. A value
29 * of zero for sid indicates no SID could be determined (but no error
30 * occurred).
31 */
32int selinux_string_to_sid(char *str, u32 *sid);
33
34/**
35 * selinux_secmark_relabel_packet_permission - secmark permission check
36 * @sid: SECMARK ID value to be applied to network packet
37 *
38 * Returns 0 if the current task is allowed to set the SECMARK label of
39 * packets with the supplied security ID. Note that it is implicit that
40 * the packet is always being relabeled from the default unlabeled value,
41 * and that the access control decision is made in the AVC.
42 */
43int selinux_secmark_relabel_packet_permission(u32 sid);
44
45/**
46 * selinux_secmark_refcount_inc - increments the secmark use counter
47 *
48 * SELinux keeps track of the current SECMARK targets in use so it knows
49 * when to apply SECMARK label access checks to network packets. This
50 * function incements this reference count to indicate that a new SECMARK
51 * target has been configured.
52 */
53void selinux_secmark_refcount_inc(void);
54
55/**
56 * selinux_secmark_refcount_dec - decrements the secmark use counter
57 *
58 * SELinux keeps track of the current SECMARK targets in use so it knows
59 * when to apply SECMARK label access checks to network packets. This
60 * function decements this reference count to indicate that one of the
61 * existing SECMARK targets has been removed/flushed.
62 */
63void selinux_secmark_refcount_dec(void);
64
65/**
66 * selinux_is_enabled - is SELinux enabled? 24 * selinux_is_enabled - is SELinux enabled?
67 */ 25 */
68bool selinux_is_enabled(void); 26bool selinux_is_enabled(void);
69#else 27#else
70 28
71static inline int selinux_string_to_sid(const char *str, u32 *sid)
72{
73 *sid = 0;
74 return 0;
75}
76
77static inline int selinux_secmark_relabel_packet_permission(u32 sid)
78{
79 return 0;
80}
81
82static inline void selinux_secmark_refcount_inc(void)
83{
84 return;
85}
86
87static inline void selinux_secmark_refcount_dec(void)
88{
89 return;
90}
91
92static inline bool selinux_is_enabled(void) 29static inline bool selinux_is_enabled(void)
93{ 30{
94 return false; 31 return false;
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 5310d27abd2a..39fa04966aa8 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -29,9 +29,6 @@ struct semaphore {
29#define DEFINE_SEMAPHORE(name) \ 29#define DEFINE_SEMAPHORE(name) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) 30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
31 31
32#define DECLARE_MUTEX(name) \
33 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
34
35static inline void sema_init(struct semaphore *sem, int val) 32static inline void sema_init(struct semaphore *sem, int val)
36{ 33{
37 static struct lock_class_key __key; 34 static struct lock_class_key __key;
@@ -39,9 +36,6 @@ static inline void sema_init(struct semaphore *sem, int val)
39 lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0); 36 lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
40} 37}
41 38
42#define init_MUTEX(sem) sema_init(sem, 1)
43#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
44
45extern void down(struct semaphore *sem); 39extern void down(struct semaphore *sem);
46extern int __must_check down_interruptible(struct semaphore *sem); 40extern int __must_check down_interruptible(struct semaphore *sem);
47extern int __must_check down_killable(struct semaphore *sem); 41extern int __must_check down_killable(struct semaphore *sem);
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 632205ccc25d..c6db9fb33c44 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -28,6 +28,7 @@
28 28
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/preempt.h> 30#include <linux/preempt.h>
31#include <asm/processor.h>
31 32
32typedef struct { 33typedef struct {
33 unsigned sequence; 34 unsigned sequence;
@@ -41,9 +42,6 @@ typedef struct {
41#define __SEQLOCK_UNLOCKED(lockname) \ 42#define __SEQLOCK_UNLOCKED(lockname) \
42 { 0, __SPIN_LOCK_UNLOCKED(lockname) } 43 { 0, __SPIN_LOCK_UNLOCKED(lockname) }
43 44
44#define SEQLOCK_UNLOCKED \
45 __SEQLOCK_UNLOCKED(old_style_seqlock_init)
46
47#define seqlock_init(x) \ 45#define seqlock_init(x) \
48 do { \ 46 do { \
49 (x)->sequence = 0; \ 47 (x)->sequence = 0; \
@@ -88,12 +86,12 @@ static __always_inline unsigned read_seqbegin(const seqlock_t *sl)
88 unsigned ret; 86 unsigned ret;
89 87
90repeat: 88repeat:
91 ret = sl->sequence; 89 ret = ACCESS_ONCE(sl->sequence);
92 smp_rmb();
93 if (unlikely(ret & 1)) { 90 if (unlikely(ret & 1)) {
94 cpu_relax(); 91 cpu_relax();
95 goto repeat; 92 goto repeat;
96 } 93 }
94 smp_rmb();
97 95
98 return ret; 96 return ret;
99} 97}
@@ -107,7 +105,7 @@ static __always_inline int read_seqretry(const seqlock_t *sl, unsigned start)
107{ 105{
108 smp_rmb(); 106 smp_rmb();
109 107
110 return (sl->sequence != start); 108 return unlikely(sl->sequence != start);
111} 109}
112 110
113 111
@@ -125,14 +123,25 @@ typedef struct seqcount {
125#define SEQCNT_ZERO { 0 } 123#define SEQCNT_ZERO { 0 }
126#define seqcount_init(x) do { *(x) = (seqcount_t) SEQCNT_ZERO; } while (0) 124#define seqcount_init(x) do { *(x) = (seqcount_t) SEQCNT_ZERO; } while (0)
127 125
128/* Start of read using pointer to a sequence counter only. */ 126/**
129static inline unsigned read_seqcount_begin(const seqcount_t *s) 127 * __read_seqcount_begin - begin a seq-read critical section (without barrier)
128 * @s: pointer to seqcount_t
129 * Returns: count to be passed to read_seqcount_retry
130 *
131 * __read_seqcount_begin is like read_seqcount_begin, but has no smp_rmb()
132 * barrier. Callers should ensure that smp_rmb() or equivalent ordering is
133 * provided before actually loading any of the variables that are to be
134 * protected in this critical section.
135 *
136 * Use carefully, only in critical code, and comment how the barrier is
137 * provided.
138 */
139static inline unsigned __read_seqcount_begin(const seqcount_t *s)
130{ 140{
131 unsigned ret; 141 unsigned ret;
132 142
133repeat: 143repeat:
134 ret = s->sequence; 144 ret = s->sequence;
135 smp_rmb();
136 if (unlikely(ret & 1)) { 145 if (unlikely(ret & 1)) {
137 cpu_relax(); 146 cpu_relax();
138 goto repeat; 147 goto repeat;
@@ -140,14 +149,56 @@ repeat:
140 return ret; 149 return ret;
141} 150}
142 151
143/* 152/**
144 * Test if reader processed invalid data because sequence number has changed. 153 * read_seqcount_begin - begin a seq-read critical section
154 * @s: pointer to seqcount_t
155 * Returns: count to be passed to read_seqcount_retry
156 *
157 * read_seqcount_begin opens a read critical section of the given seqcount.
158 * Validity of the critical section is tested by checking read_seqcount_retry
159 * function.
160 */
161static inline unsigned read_seqcount_begin(const seqcount_t *s)
162{
163 unsigned ret = __read_seqcount_begin(s);
164 smp_rmb();
165 return ret;
166}
167
168/**
169 * __read_seqcount_retry - end a seq-read critical section (without barrier)
170 * @s: pointer to seqcount_t
171 * @start: count, from read_seqcount_begin
172 * Returns: 1 if retry is required, else 0
173 *
174 * __read_seqcount_retry is like read_seqcount_retry, but has no smp_rmb()
175 * barrier. Callers should ensure that smp_rmb() or equivalent ordering is
176 * provided before actually loading any of the variables that are to be
177 * protected in this critical section.
178 *
179 * Use carefully, only in critical code, and comment how the barrier is
180 * provided.
181 */
182static inline int __read_seqcount_retry(const seqcount_t *s, unsigned start)
183{
184 return unlikely(s->sequence != start);
185}
186
187/**
188 * read_seqcount_retry - end a seq-read critical section
189 * @s: pointer to seqcount_t
190 * @start: count, from read_seqcount_begin
191 * Returns: 1 if retry is required, else 0
192 *
193 * read_seqcount_retry closes a read critical section of the given seqcount.
194 * If the critical section was invalid, it must be ignored (and typically
195 * retried).
145 */ 196 */
146static inline int read_seqcount_retry(const seqcount_t *s, unsigned start) 197static inline int read_seqcount_retry(const seqcount_t *s, unsigned start)
147{ 198{
148 smp_rmb(); 199 smp_rmb();
149 200
150 return s->sequence != start; 201 return __read_seqcount_retry(s, start);
151} 202}
152 203
153 204
@@ -167,6 +218,19 @@ static inline void write_seqcount_end(seqcount_t *s)
167 s->sequence++; 218 s->sequence++;
168} 219}
169 220
221/**
222 * write_seqcount_barrier - invalidate in-progress read-side seq operations
223 * @s: pointer to seqcount_t
224 *
225 * After write_seqcount_barrier, no read-side seq operations will complete
226 * successfully and see data older than this.
227 */
228static inline void write_seqcount_barrier(seqcount_t *s)
229{
230 smp_wmb();
231 s->sequence+=2;
232}
233
170/* 234/*
171 * Possible sw/hw IRQ protected versions of the interfaces. 235 * Possible sw/hw IRQ protected versions of the interfaces.
172 */ 236 */
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 7638deaaba65..97f5b45bbc07 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -35,6 +35,8 @@ struct plat_serial8250_port {
35 void (*set_termios)(struct uart_port *, 35 void (*set_termios)(struct uart_port *,
36 struct ktermios *new, 36 struct ktermios *new,
37 struct ktermios *old); 37 struct ktermios *old);
38 void (*pm)(struct uart_port *, unsigned int state,
39 unsigned old);
38}; 40};
39 41
40/* 42/*
@@ -76,5 +78,11 @@ extern int serial8250_find_port_for_earlycon(void);
76extern int setup_early_serial8250_console(char *cmdline); 78extern int setup_early_serial8250_console(char *cmdline);
77extern void serial8250_do_set_termios(struct uart_port *port, 79extern void serial8250_do_set_termios(struct uart_port *port,
78 struct ktermios *termios, struct ktermios *old); 80 struct ktermios *termios, struct ktermios *old);
81extern void serial8250_do_pm(struct uart_port *port, unsigned int state,
82 unsigned int oldstate);
83
84extern void serial8250_set_isa_configurator(void (*v)
85 (int port, struct uart_port *up,
86 unsigned short *capabilities));
79 87
80#endif 88#endif
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 563e23400913..a5c31146a337 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -45,7 +45,8 @@
45#define PORT_OCTEON 17 /* Cavium OCTEON internal UART */ 45#define PORT_OCTEON 17 /* Cavium OCTEON internal UART */
46#define PORT_AR7 18 /* Texas Instruments AR7 internal UART */ 46#define PORT_AR7 18 /* Texas Instruments AR7 internal UART */
47#define PORT_U6_16550A 19 /* ST-Ericsson U6xxx internal UART */ 47#define PORT_U6_16550A 19 /* ST-Ericsson U6xxx internal UART */
48#define PORT_MAX_8250 19 /* max port ID */ 48#define PORT_TEGRA 20 /* NVIDIA Tegra internal UART */
49#define PORT_MAX_8250 20 /* max port ID */
49 50
50/* 51/*
51 * ARM specific type numbers. These are not currently guaranteed 52 * ARM specific type numbers. These are not currently guaranteed
@@ -95,7 +96,7 @@
95/* PPC CPM type number */ 96/* PPC CPM type number */
96#define PORT_CPM 58 97#define PORT_CPM 58
97 98
98/* MPC52xx type numbers */ 99/* MPC52xx (and MPC512x) type numbers */
99#define PORT_MPC52xx 59 100#define PORT_MPC52xx 59
100 101
101/* IBM icom */ 102/* IBM icom */
@@ -196,6 +197,15 @@
196/* High Speed UART for Medfield */ 197/* High Speed UART for Medfield */
197#define PORT_MFD 95 198#define PORT_MFD 95
198 199
200/* TI OMAP-UART */
201#define PORT_OMAP 96
202
203/* VIA VT8500 SoC */
204#define PORT_VT8500 97
205
206/* Xilinx PSS UART */
207#define PORT_XUARTPS 98
208
199#ifdef __KERNEL__ 209#ifdef __KERNEL__
200 210
201#include <linux/compiler.h> 211#include <linux/compiler.h>
@@ -206,6 +216,7 @@
206#include <linux/tty.h> 216#include <linux/tty.h>
207#include <linux/mutex.h> 217#include <linux/mutex.h>
208#include <linux/sysrq.h> 218#include <linux/sysrq.h>
219#include <linux/pps_kernel.h>
209 220
210struct uart_port; 221struct uart_port;
211struct serial_struct; 222struct serial_struct;
@@ -289,6 +300,8 @@ struct uart_port {
289 void (*set_termios)(struct uart_port *, 300 void (*set_termios)(struct uart_port *,
290 struct ktermios *new, 301 struct ktermios *new,
291 struct ktermios *old); 302 struct ktermios *old);
303 void (*pm)(struct uart_port *, unsigned int state,
304 unsigned int old);
292 unsigned int irq; /* irq number */ 305 unsigned int irq; /* irq number */
293 unsigned long irqflags; /* irq flags */ 306 unsigned long irqflags; /* irq flags */
294 unsigned int uartclk; /* base uart clock */ 307 unsigned int uartclk; /* base uart clock */
@@ -306,6 +319,7 @@ struct uart_port {
306#define UPIO_TSI (5) /* Tsi108/109 type IO */ 319#define UPIO_TSI (5) /* Tsi108/109 type IO */
307#define UPIO_DWAPB (6) /* DesignWare APB UART */ 320#define UPIO_DWAPB (6) /* DesignWare APB UART */
308#define UPIO_RM9000 (7) /* RM9000 type IO */ 321#define UPIO_RM9000 (7) /* RM9000 type IO */
322#define UPIO_DWAPB32 (8) /* DesignWare APB UART (32 bit accesses) */
309 323
310 unsigned int read_status_mask; /* driver specific */ 324 unsigned int read_status_mask; /* driver specific */
311 unsigned int ignore_status_mask; /* driver specific */ 325 unsigned int ignore_status_mask; /* driver specific */
@@ -356,6 +370,7 @@ struct uart_port {
356 struct device *dev; /* parent device */ 370 struct device *dev; /* parent device */
357 unsigned char hub6; /* this should be in the 8250 driver */ 371 unsigned char hub6; /* this should be in the 8250 driver */
358 unsigned char suspended; 372 unsigned char suspended;
373 unsigned char irq_wake;
359 unsigned char unused[2]; 374 unsigned char unused[2];
360 void *private_data; /* generic platform data pointer */ 375 void *private_data; /* generic platform data pointer */
361}; 376};
@@ -411,6 +426,14 @@ unsigned int uart_get_baud_rate(struct uart_port *port, struct ktermios *termios
411 unsigned int max); 426 unsigned int max);
412unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud); 427unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud);
413 428
429/* Base timer interval for polling */
430static inline int uart_poll_timeout(struct uart_port *port)
431{
432 int timeout = port->timeout;
433
434 return timeout > 6 ? (timeout / 2 - 2) : 1;
435}
436
414/* 437/*
415 * Console helpers. 438 * Console helpers.
416 */ 439 */
@@ -510,10 +533,10 @@ uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
510 struct uart_state *state = uport->state; 533 struct uart_state *state = uport->state;
511 struct tty_port *port = &state->port; 534 struct tty_port *port = &state->port;
512 struct tty_ldisc *ld = tty_ldisc_ref(port->tty); 535 struct tty_ldisc *ld = tty_ldisc_ref(port->tty);
513 struct timespec ts; 536 struct pps_event_time ts;
514 537
515 if (ld && ld->ops->dcd_change) 538 if (ld && ld->ops->dcd_change)
516 getnstimeofday(&ts); 539 pps_get_ts(&ts);
517 540
518 uport->icount.dcd++; 541 uport->icount.dcd++;
519#ifdef CONFIG_HARD_PPS 542#ifdef CONFIG_HARD_PPS
diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h
index c7a0ce11cd47..c75bda37c18e 100644
--- a/include/linux/serial_reg.h
+++ b/include/linux/serial_reg.h
@@ -57,6 +57,7 @@
57 * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654 57 * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654
58 * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750 58 * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750
59 * TI16C752: 8 16 56 60 8 16 32 56 59 * TI16C752: 8 16 56 60 8 16 32 56
60 * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA
60 */ 61 */
61#define UART_FCR_R_TRIG_00 0x00 62#define UART_FCR_R_TRIG_00 0x00
62#define UART_FCR_R_TRIG_01 0x40 63#define UART_FCR_R_TRIG_01 0x40
@@ -99,6 +100,13 @@
99#define UART_LCR_WLEN7 0x02 /* Wordlength: 7 bits */ 100#define UART_LCR_WLEN7 0x02 /* Wordlength: 7 bits */
100#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */ 101#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
101 102
103/*
104 * Access to some registers depends on register access / configuration
105 * mode.
106 */
107#define UART_LCR_CONF_MODE_A UART_LCR_DLAB /* Configutation mode A */
108#define UART_LCR_CONF_MODE_B 0xBF /* Configutation mode B */
109
102#define UART_MCR 4 /* Out: Modem Control Register */ 110#define UART_MCR 4 /* Out: Modem Control Register */
103#define UART_MCR_CLKSEL 0x80 /* Divide clock by 4 (TI16C752, EFR[4]=1) */ 111#define UART_MCR_CLKSEL 0x80 /* Divide clock by 4 (TI16C752, EFR[4]=1) */
104#define UART_MCR_TCRTLR 0x40 /* Access TCR/TLR (TI16C752, EFR[4]=1) */ 112#define UART_MCR_TCRTLR 0x40 /* Access TCR/TLR (TI16C752, EFR[4]=1) */
@@ -111,6 +119,7 @@
111#define UART_MCR_DTR 0x01 /* DTR complement */ 119#define UART_MCR_DTR 0x01 /* DTR complement */
112 120
113#define UART_LSR 5 /* In: Line Status Register */ 121#define UART_LSR 5 /* In: Line Status Register */
122#define UART_LSR_FIFOE 0x80 /* Fifo error */
114#define UART_LSR_TEMT 0x40 /* Transmitter empty */ 123#define UART_LSR_TEMT 0x40 /* Transmitter empty */
115#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */ 124#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
116#define UART_LSR_BI 0x10 /* Break interrupt indicator */ 125#define UART_LSR_BI 0x10 /* Break interrupt indicator */
@@ -341,5 +350,17 @@
341#define UART_OMAP_SYSS 0x16 /* System status register */ 350#define UART_OMAP_SYSS 0x16 /* System status register */
342#define UART_OMAP_WER 0x17 /* Wake-up enable register */ 351#define UART_OMAP_WER 0x17 /* Wake-up enable register */
343 352
353/*
354 * These are the definitions for the MDR1 register
355 */
356#define UART_OMAP_MDR1_16X_MODE 0x00 /* UART 16x mode */
357#define UART_OMAP_MDR1_SIR_MODE 0x01 /* SIR mode */
358#define UART_OMAP_MDR1_16X_ABAUD_MODE 0x02 /* UART 16x auto-baud */
359#define UART_OMAP_MDR1_13X_MODE 0x03 /* UART 13x mode */
360#define UART_OMAP_MDR1_MIR_MODE 0x04 /* MIR mode */
361#define UART_OMAP_MDR1_FIR_MODE 0x05 /* FIR mode */
362#define UART_OMAP_MDR1_CIR_MODE 0x06 /* CIR mode */
363#define UART_OMAP_MDR1_DISABLE 0x07 /* Disable (default state) */
364
344#endif /* _LINUX_SERIAL_REG_H */ 365#endif /* _LINUX_SERIAL_REG_H */
345 366
diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h
index baed2122c5a6..a2afc9fbe186 100644
--- a/include/linux/serial_sci.h
+++ b/include/linux/serial_sci.h
@@ -8,6 +8,23 @@
8 * Generic header for SuperH SCI(F) (used by sh/sh64/h8300 and related parts) 8 * Generic header for SuperH SCI(F) (used by sh/sh64/h8300 and related parts)
9 */ 9 */
10 10
11enum {
12 SCBRR_ALGO_1, /* ((clk + 16 * bps) / (16 * bps) - 1) */
13 SCBRR_ALGO_2, /* ((clk + 16 * bps) / (32 * bps) - 1) */
14 SCBRR_ALGO_3, /* (((clk * 2) + 16 * bps) / (16 * bps) - 1) */
15 SCBRR_ALGO_4, /* (((clk * 2) + 16 * bps) / (32 * bps) - 1) */
16 SCBRR_ALGO_5, /* (((clk * 1000 / 32) / bps) - 1) */
17};
18
19#define SCSCR_TIE (1 << 7)
20#define SCSCR_RIE (1 << 6)
21#define SCSCR_TE (1 << 5)
22#define SCSCR_RE (1 << 4)
23#define SCSCR_REIE (1 << 3) /* not supported by all parts */
24#define SCSCR_TOIE (1 << 2) /* not supported by all parts */
25#define SCSCR_CKE1 (1 << 1)
26#define SCSCR_CKE0 (1 << 0)
27
11/* Offsets into the sci_port->irqs array */ 28/* Offsets into the sci_port->irqs array */
12enum { 29enum {
13 SCIx_ERI_IRQ, 30 SCIx_ERI_IRQ,
@@ -17,23 +34,32 @@ enum {
17 SCIx_NR_IRQS, 34 SCIx_NR_IRQS,
18}; 35};
19 36
37#define SCIx_IRQ_MUXED(irq) \
38{ \
39 [SCIx_ERI_IRQ] = (irq), \
40 [SCIx_RXI_IRQ] = (irq), \
41 [SCIx_TXI_IRQ] = (irq), \
42 [SCIx_BRI_IRQ] = (irq), \
43}
44
20struct device; 45struct device;
21 46
22/* 47/*
23 * Platform device specific platform_data struct 48 * Platform device specific platform_data struct
24 */ 49 */
25struct plat_sci_port { 50struct plat_sci_port {
26 void __iomem *membase; /* io cookie */
27 unsigned long mapbase; /* resource base */ 51 unsigned long mapbase; /* resource base */
28 unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */ 52 unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */
29 unsigned int type; /* SCI / SCIF / IRDA */ 53 unsigned int type; /* SCI / SCIF / IRDA */
30 upf_t flags; /* UPF_* flags */ 54 upf_t flags; /* UPF_* flags */
31 char *clk; /* clock string */ 55
56 unsigned int scbrr_algo_id; /* SCBRR calculation algo */
57 unsigned int scscr; /* SCSCR initialization */
58
32 struct device *dma_dev; 59 struct device *dma_dev;
33#ifdef CONFIG_SERIAL_SH_SCI_DMA 60
34 unsigned int dma_slave_tx; 61 unsigned int dma_slave_tx;
35 unsigned int dma_slave_rx; 62 unsigned int dma_slave_rx;
36#endif
37}; 63};
38 64
39#endif /* __LINUX_SERIAL_SCI_H */ 65#endif /* __LINUX_SERIAL_SCI_H */
diff --git a/include/linux/serio.h b/include/linux/serio.h
index b5552568178d..e26f4788845f 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -41,7 +41,9 @@ struct serio {
41 int (*start)(struct serio *); 41 int (*start)(struct serio *);
42 void (*stop)(struct serio *); 42 void (*stop)(struct serio *);
43 43
44 struct serio *parent, *child; 44 struct serio *parent;
45 struct list_head child_node; /* Entry in parent->children list */
46 struct list_head children;
45 unsigned int depth; /* level of nesting in serio hierarchy */ 47 unsigned int depth; /* level of nesting in serio hierarchy */
46 48
47 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */ 49 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
@@ -54,10 +56,9 @@ struct serio {
54#define to_serio_port(d) container_of(d, struct serio, dev) 56#define to_serio_port(d) container_of(d, struct serio, dev)
55 57
56struct serio_driver { 58struct serio_driver {
57 void *private; 59 const char *description;
58 char *description;
59 60
60 struct serio_device_id *id_table; 61 const struct serio_device_id *id_table;
61 bool manual_bind; 62 bool manual_bind;
62 63
63 void (*write_wakeup)(struct serio *); 64 void (*write_wakeup)(struct serio *);
@@ -197,5 +198,6 @@ static inline void serio_continue_rx(struct serio *serio)
197#define SERIO_W8001 0x39 198#define SERIO_W8001 0x39
198#define SERIO_DYNAPRO 0x3a 199#define SERIO_DYNAPRO 0x3a
199#define SERIO_HAMPSHIRE 0x3b 200#define SERIO_HAMPSHIRE 0x3b
201#define SERIO_PS2MULT 0x3c
200 202
201#endif 203#endif
diff --git a/include/linux/sfi.h b/include/linux/sfi.h
index 0299b4ce63db..fe817918b30e 100644
--- a/include/linux/sfi.h
+++ b/include/linux/sfi.h
@@ -70,9 +70,6 @@
70#define SFI_SIG_APIC "APIC" 70#define SFI_SIG_APIC "APIC"
71#define SFI_SIG_XSDT "XSDT" 71#define SFI_SIG_XSDT "XSDT"
72#define SFI_SIG_WAKE "WAKE" 72#define SFI_SIG_WAKE "WAKE"
73#define SFI_SIG_SPIB "SPIB"
74#define SFI_SIG_I2CB "I2CB"
75#define SFI_SIG_GPEM "GPEM"
76#define SFI_SIG_DEVS "DEVS" 73#define SFI_SIG_DEVS "DEVS"
77#define SFI_SIG_GPIO "GPIO" 74#define SFI_SIG_GPIO "GPIO"
78 75
@@ -80,6 +77,8 @@
80#define SFI_OEM_ID_SIZE 6 77#define SFI_OEM_ID_SIZE 6
81#define SFI_OEM_TABLE_ID_SIZE 8 78#define SFI_OEM_TABLE_ID_SIZE 8
82 79
80#define SFI_NAME_LEN 16
81
83#define SFI_SYST_SEARCH_BEGIN 0x000E0000 82#define SFI_SYST_SEARCH_BEGIN 0x000E0000
84#define SFI_SYST_SEARCH_END 0x000FFFFF 83#define SFI_SYST_SEARCH_END 0x000FFFFF
85 84
@@ -159,34 +158,13 @@ struct sfi_device_table_entry {
159 u16 addr; 158 u16 addr;
160 u8 irq; 159 u8 irq;
161 u32 max_freq; 160 u32 max_freq;
162 char name[16]; 161 char name[SFI_NAME_LEN];
163} __packed; 162} __packed;
164 163
165struct sfi_gpio_table_entry { 164struct sfi_gpio_table_entry {
166 char controller_name[16]; 165 char controller_name[SFI_NAME_LEN];
167 u16 pin_no; 166 u16 pin_no;
168 char pin_name[16]; 167 char pin_name[SFI_NAME_LEN];
169} __packed;
170
171struct sfi_spi_table_entry {
172 u16 host_num; /* attached to host 0, 1...*/
173 u16 cs; /* chip select */
174 u16 irq_info;
175 char name[16];
176 u8 dev_info[10];
177} __packed;
178
179struct sfi_i2c_table_entry {
180 u16 host_num;
181 u16 addr; /* slave addr */
182 u16 irq_info;
183 char name[16];
184 u8 dev_info[10];
185} __packed;
186
187struct sfi_gpe_table_entry {
188 u16 logical_id; /* logical id */
189 u16 phys_id; /* physical GPE id */
190} __packed; 168} __packed;
191 169
192typedef int (*sfi_table_handler) (struct sfi_table_header *table); 170typedef int (*sfi_table_handler) (struct sfi_table_header *table);
diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h
index 875ce50719a9..9a52f72527dc 100644
--- a/include/linux/sh_clk.h
+++ b/include/linux/sh_clk.h
@@ -4,26 +4,34 @@
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/seq_file.h> 5#include <linux/seq_file.h>
6#include <linux/cpufreq.h> 6#include <linux/cpufreq.h>
7#include <linux/types.h>
8#include <linux/kref.h>
7#include <linux/clk.h> 9#include <linux/clk.h>
8#include <linux/err.h> 10#include <linux/err.h>
9 11
10struct clk; 12struct clk;
11 13
14struct clk_mapping {
15 phys_addr_t phys;
16 void __iomem *base;
17 unsigned long len;
18 struct kref ref;
19};
20
12struct clk_ops { 21struct clk_ops {
22#ifdef CONFIG_SH_CLK_CPG_LEGACY
13 void (*init)(struct clk *clk); 23 void (*init)(struct clk *clk);
24#endif
14 int (*enable)(struct clk *clk); 25 int (*enable)(struct clk *clk);
15 void (*disable)(struct clk *clk); 26 void (*disable)(struct clk *clk);
16 unsigned long (*recalc)(struct clk *clk); 27 unsigned long (*recalc)(struct clk *clk);
17 int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id); 28 int (*set_rate)(struct clk *clk, unsigned long rate);
18 int (*set_parent)(struct clk *clk, struct clk *parent); 29 int (*set_parent)(struct clk *clk, struct clk *parent);
19 long (*round_rate)(struct clk *clk, unsigned long rate); 30 long (*round_rate)(struct clk *clk, unsigned long rate);
20}; 31};
21 32
22struct clk { 33struct clk {
23 struct list_head node; 34 struct list_head node;
24 const char *name;
25 int id;
26
27 struct clk *parent; 35 struct clk *parent;
28 struct clk **parent_table; /* list of parents to */ 36 struct clk **parent_table; /* list of parents to */
29 unsigned short parent_num; /* choose between */ 37 unsigned short parent_num; /* choose between */
@@ -45,7 +53,9 @@ struct clk {
45 unsigned long arch_flags; 53 unsigned long arch_flags;
46 void *priv; 54 void *priv;
47 struct dentry *dentry; 55 struct dentry *dentry;
56 struct clk_mapping *mapping;
48 struct cpufreq_frequency_table *freq_table; 57 struct cpufreq_frequency_table *freq_table;
58 unsigned int nr_freqs;
49}; 59};
50 60
51#define CLK_ENABLE_ON_INIT (1 << 0) 61#define CLK_ENABLE_ON_INIT (1 << 0)
@@ -59,36 +69,6 @@ int clk_register(struct clk *);
59void clk_unregister(struct clk *); 69void clk_unregister(struct clk *);
60void clk_enable_init_clocks(void); 70void clk_enable_init_clocks(void);
61 71
62/**
63 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
64 * @clk: clock source
65 * @rate: desired clock rate in Hz
66 * @algo_id: algorithm id to be passed down to ops->set_rate
67 *
68 * Returns success (0) or negative errno.
69 */
70int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
71
72enum clk_sh_algo_id {
73 NO_CHANGE = 0,
74
75 IUS_N1_N1,
76 IUS_322,
77 IUS_522,
78 IUS_N11,
79
80 SB_N1,
81
82 SB3_N1,
83 SB3_32,
84 SB3_43,
85 SB3_54,
86
87 BP_N1,
88
89 IP_N1,
90};
91
92struct clk_div_mult_table { 72struct clk_div_mult_table {
93 unsigned int *divisors; 73 unsigned int *divisors;
94 unsigned int nr_divisors; 74 unsigned int nr_divisors;
@@ -111,6 +91,13 @@ int clk_rate_table_find(struct clk *clk,
111 struct cpufreq_frequency_table *freq_table, 91 struct cpufreq_frequency_table *freq_table,
112 unsigned long rate); 92 unsigned long rate);
113 93
94long clk_rate_div_range_round(struct clk *clk, unsigned int div_min,
95 unsigned int div_max, unsigned long rate);
96
97long clk_round_parent(struct clk *clk, unsigned long target,
98 unsigned long *best_freq, unsigned long *parent_freq,
99 unsigned int div_min, unsigned int div_max);
100
114#define SH_CLK_MSTP32(_parent, _enable_reg, _enable_bit, _flags) \ 101#define SH_CLK_MSTP32(_parent, _enable_reg, _enable_bit, _flags) \
115{ \ 102{ \
116 .parent = _parent, \ 103 .parent = _parent, \
diff --git a/include/linux/sh_intc.h b/include/linux/sh_intc.h
index 0d6cd38e673d..5812fefbcedf 100644
--- a/include/linux/sh_intc.h
+++ b/include/linux/sh_intc.h
@@ -20,6 +20,12 @@ struct intc_group {
20 20
21#define INTC_GROUP(enum_id, ids...) { enum_id, { ids } } 21#define INTC_GROUP(enum_id, ids...) { enum_id, { ids } }
22 22
23struct intc_subgroup {
24 unsigned long reg, reg_width;
25 intc_enum parent_id;
26 intc_enum enum_ids[32];
27};
28
23struct intc_mask_reg { 29struct intc_mask_reg {
24 unsigned long set_reg, clr_reg, reg_width; 30 unsigned long set_reg, clr_reg, reg_width;
25 intc_enum enum_ids[32]; 31 intc_enum enum_ids[32];
@@ -69,9 +75,12 @@ struct intc_hw_desc {
69 unsigned int nr_sense_regs; 75 unsigned int nr_sense_regs;
70 struct intc_mask_reg *ack_regs; 76 struct intc_mask_reg *ack_regs;
71 unsigned int nr_ack_regs; 77 unsigned int nr_ack_regs;
78 struct intc_subgroup *subgroups;
79 unsigned int nr_subgroups;
72}; 80};
73 81
74#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a) 82#define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
83
75#define INTC_HW_DESC(vectors, groups, mask_regs, \ 84#define INTC_HW_DESC(vectors, groups, mask_regs, \
76 prio_regs, sense_regs, ack_regs) \ 85 prio_regs, sense_regs, ack_regs) \
77{ \ 86{ \
@@ -105,8 +114,11 @@ struct intc_desc symbol __initdata = { \
105 prio_regs, sense_regs, ack_regs), \ 114 prio_regs, sense_regs, ack_regs), \
106} 115}
107 116
108int __init register_intc_controller(struct intc_desc *desc); 117int register_intc_controller(struct intc_desc *desc);
118void reserve_intc_vectors(struct intc_vect *vectors, unsigned int nr_vecs);
109int intc_set_priority(unsigned int irq, unsigned int prio); 119int intc_set_priority(unsigned int irq, unsigned int prio);
120int intc_irq_lookup(const char *chipname, intc_enum enum_id);
121void intc_finalize(void);
110 122
111#ifdef CONFIG_INTC_USERIMASK 123#ifdef CONFIG_INTC_USERIMASK
112int register_intc_userimask(unsigned long addr); 124int register_intc_userimask(unsigned long addr);
@@ -117,7 +129,4 @@ static inline int register_intc_userimask(unsigned long addr)
117} 129}
118#endif 130#endif
119 131
120int reserve_irq_vector(unsigned int irq);
121void reserve_irq_legacy(void);
122
123#endif /* __SH_INTC_H */ 132#endif /* __SH_INTC_H */
diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h
index 07c08af9f8f6..30cae70874f4 100644
--- a/include/linux/sh_pfc.h
+++ b/include/linux/sh_pfc.h
@@ -92,5 +92,6 @@ struct pinmux_info {
92}; 92};
93 93
94int register_pinmux(struct pinmux_info *pip); 94int register_pinmux(struct pinmux_info *pip);
95int unregister_pinmux(struct pinmux_info *pip);
95 96
96#endif /* __SH_PFC_H */ 97#endif /* __SH_PFC_H */
diff --git a/include/linux/sh_timer.h b/include/linux/sh_timer.h
index 864bd56bd3b0..4d9dcd138315 100644
--- a/include/linux/sh_timer.h
+++ b/include/linux/sh_timer.h
@@ -5,7 +5,6 @@ struct sh_timer_config {
5 char *name; 5 char *name;
6 long channel_offset; 6 long channel_offset;
7 int timer_bit; 7 int timer_bit;
8 char *clk;
9 unsigned long clockevent_rating; 8 unsigned long clockevent_rating;
10 unsigned long clocksource_rating; 9 unsigned long clocksource_rating;
11}; 10};
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 399be5ad2f99..aa08fa8fd79b 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -3,12 +3,15 @@
3 3
4#include <linux/swap.h> 4#include <linux/swap.h>
5#include <linux/mempolicy.h> 5#include <linux/mempolicy.h>
6#include <linux/pagemap.h>
6#include <linux/percpu_counter.h> 7#include <linux/percpu_counter.h>
7 8
8/* inode in-kernel data */ 9/* inode in-kernel data */
9 10
10#define SHMEM_NR_DIRECT 16 11#define SHMEM_NR_DIRECT 16
11 12
13#define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))
14
12struct shmem_inode_info { 15struct shmem_inode_info {
13 spinlock_t lock; 16 spinlock_t lock;
14 unsigned long flags; 17 unsigned long flags;
@@ -17,8 +20,12 @@ struct shmem_inode_info {
17 unsigned long next_index; /* highest alloced index + 1 */ 20 unsigned long next_index; /* highest alloced index + 1 */
18 struct shared_policy policy; /* NUMA memory alloc policy */ 21 struct shared_policy policy; /* NUMA memory alloc policy */
19 struct page *i_indirect; /* top indirect blocks page */ 22 struct page *i_indirect; /* top indirect blocks page */
20 swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */ 23 union {
24 swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */
25 char inline_symlink[SHMEM_SYMLINK_INLINE_LEN];
26 };
21 struct list_head swaplist; /* chain of maybes on swap */ 27 struct list_head swaplist; /* chain of maybes on swap */
28 struct list_head xattr_list; /* list of shmem_xattr */
22 struct inode vfs_inode; 29 struct inode vfs_inode;
23}; 30};
24 31
@@ -39,7 +46,27 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
39 return container_of(inode, struct shmem_inode_info, vfs_inode); 46 return container_of(inode, struct shmem_inode_info, vfs_inode);
40} 47}
41 48
49/*
50 * Functions in mm/shmem.c called directly from elsewhere:
51 */
42extern int init_tmpfs(void); 52extern int init_tmpfs(void);
43extern int shmem_fill_super(struct super_block *sb, void *data, int silent); 53extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
54extern struct file *shmem_file_setup(const char *name,
55 loff_t size, unsigned long flags);
56extern int shmem_zero_setup(struct vm_area_struct *);
57extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
58extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
59 pgoff_t index, gfp_t gfp_mask);
60extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
61extern int shmem_unuse(swp_entry_t entry, struct page *page);
62extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
63 struct page **pagep, swp_entry_t *ent);
64
65static inline struct page *shmem_read_mapping_page(
66 struct address_space *mapping, pgoff_t index)
67{
68 return shmem_read_mapping_page_gfp(mapping, index,
69 mapping_gfp_mask(mapping));
70}
44 71
45#endif 72#endif
diff --git a/include/linux/sht15.h b/include/linux/sht15.h
index 046bce05ecab..f85c7c523da0 100644
--- a/include/linux/sht15.h
+++ b/include/linux/sht15.h
@@ -8,17 +8,27 @@
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 *
12 * For further information, see the Documentation/hwmon/sht15 file.
11 */ 13 */
12 14
13/** 15/**
14 * struct sht15_platform_data - sht15 connectivity info 16 * struct sht15_platform_data - sht15 connectivity info
15 * @gpio_data: no. of gpio to which bidirectional data line is connected 17 * @gpio_data: no. of gpio to which bidirectional data line is
16 * @gpio_sck: no. of gpio to which the data clock is connected. 18 * connected.
17 * @supply_mv: supply voltage in mv. Overridden by regulator if available. 19 * @gpio_sck: no. of gpio to which the data clock is connected.
18 **/ 20 * @supply_mv: supply voltage in mv. Overridden by regulator if
21 * available.
22 * @checksum: flag to indicate the checksum should be validated.
23 * @no_otp_reload: flag to indicate no reload from OTP.
24 * @low_resolution: flag to indicate the temp/humidity resolution to use.
25 */
19struct sht15_platform_data { 26struct sht15_platform_data {
20 int gpio_data; 27 int gpio_data;
21 int gpio_sck; 28 int gpio_sck;
22 int supply_mv; 29 int supply_mv;
30 bool checksum;
31 bool no_otp_reload;
32 bool low_resolution;
23}; 33};
24 34
diff --git a/include/linux/sigma.h b/include/linux/sigma.h
new file mode 100644
index 000000000000..e2accb3164d8
--- /dev/null
+++ b/include/linux/sigma.h
@@ -0,0 +1,60 @@
1/*
2 * Load firmware files from Analog Devices SigmaStudio
3 *
4 * Copyright 2009-2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __SIGMA_FIRMWARE_H__
10#define __SIGMA_FIRMWARE_H__
11
12#include <linux/firmware.h>
13#include <linux/types.h>
14
15struct i2c_client;
16
17#define SIGMA_MAGIC "ADISIGM"
18
19struct sigma_firmware {
20 const struct firmware *fw;
21 size_t pos;
22};
23
24struct sigma_firmware_header {
25 unsigned char magic[7];
26 u8 version;
27 u32 crc;
28};
29
30enum {
31 SIGMA_ACTION_WRITEXBYTES = 0,
32 SIGMA_ACTION_WRITESINGLE,
33 SIGMA_ACTION_WRITESAFELOAD,
34 SIGMA_ACTION_DELAY,
35 SIGMA_ACTION_PLLWAIT,
36 SIGMA_ACTION_NOOP,
37 SIGMA_ACTION_END,
38};
39
40struct sigma_action {
41 u8 instr;
42 u8 len_hi;
43 u16 len;
44 u16 addr;
45 unsigned char payload[];
46};
47
48static inline u32 sigma_action_len(struct sigma_action *sa)
49{
50 return (sa->len_hi << 16) | sa->len;
51}
52
53static inline size_t sigma_action_size(struct sigma_action *sa, u32 payload_len)
54{
55 return sizeof(*sa) + payload_len + (payload_len % 2);
56}
57
58extern int process_sigma_firmware(struct i2c_client *client, const char *name);
59
60#endif
diff --git a/include/linux/signal.h b/include/linux/signal.h
index fcd2b14b1932..a822300a253b 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -7,6 +7,8 @@
7#ifdef __KERNEL__ 7#ifdef __KERNEL__
8#include <linux/list.h> 8#include <linux/list.h>
9 9
10struct task_struct;
11
10/* for sysctl */ 12/* for sysctl */
11extern int print_fatal_signals; 13extern int print_fatal_signals;
12/* 14/*
@@ -123,13 +125,13 @@ _SIG_SET_BINOP(sigorsets, _sig_or)
123#define _sig_and(x,y) ((x) & (y)) 125#define _sig_and(x,y) ((x) & (y))
124_SIG_SET_BINOP(sigandsets, _sig_and) 126_SIG_SET_BINOP(sigandsets, _sig_and)
125 127
126#define _sig_nand(x,y) ((x) & ~(y)) 128#define _sig_andn(x,y) ((x) & ~(y))
127_SIG_SET_BINOP(signandsets, _sig_nand) 129_SIG_SET_BINOP(sigandnsets, _sig_andn)
128 130
129#undef _SIG_SET_BINOP 131#undef _SIG_SET_BINOP
130#undef _sig_or 132#undef _sig_or
131#undef _sig_and 133#undef _sig_and
132#undef _sig_nand 134#undef _sig_andn
133 135
134#define _SIG_SET_OP(name, op) \ 136#define _SIG_SET_OP(name, op) \
135static inline void name(sigset_t *set) \ 137static inline void name(sigset_t *set) \
@@ -234,6 +236,9 @@ static inline int valid_signal(unsigned long sig)
234 return sig <= _NSIG ? 1 : 0; 236 return sig <= _NSIG ? 1 : 0;
235} 237}
236 238
239struct timespec;
240struct pt_regs;
241
237extern int next_signal(struct sigpending *pending, sigset_t *mask); 242extern int next_signal(struct sigpending *pending, sigset_t *mask);
238extern int do_send_sig_info(int sig, struct siginfo *info, 243extern int do_send_sig_info(int sig, struct siginfo *info,
239 struct task_struct *p, bool group); 244 struct task_struct *p, bool group);
@@ -242,10 +247,12 @@ extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
242extern long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, 247extern long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig,
243 siginfo_t *info); 248 siginfo_t *info);
244extern long do_sigpending(void __user *, unsigned long); 249extern long do_sigpending(void __user *, unsigned long);
250extern int do_sigtimedwait(const sigset_t *, siginfo_t *,
251 const struct timespec *);
245extern int sigprocmask(int, sigset_t *, sigset_t *); 252extern int sigprocmask(int, sigset_t *, sigset_t *);
253extern void set_current_blocked(const sigset_t *);
246extern int show_unhandled_signals; 254extern int show_unhandled_signals;
247 255
248struct pt_regs;
249extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); 256extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
250extern void exit_signals(struct task_struct *tsk); 257extern void exit_signals(struct task_struct *tsk);
251 258
diff --git a/include/linux/signalfd.h b/include/linux/signalfd.h
index b363b916c909..3ff4961da9b5 100644
--- a/include/linux/signalfd.h
+++ b/include/linux/signalfd.h
@@ -33,6 +33,7 @@ struct signalfd_siginfo {
33 __u64 ssi_utime; 33 __u64 ssi_utime;
34 __u64 ssi_stime; 34 __u64 ssi_stime;
35 __u64 ssi_addr; 35 __u64 ssi_addr;
36 __u16 ssi_addr_lsb;
36 37
37 /* 38 /*
38 * Pad strcture to 128 bytes. Remember to update the 39 * Pad strcture to 128 bytes. Remember to update the
@@ -43,7 +44,7 @@ struct signalfd_siginfo {
43 * comes out of a read(2) and we really don't want to have 44 * comes out of a read(2) and we really don't want to have
44 * a compat on read(2). 45 * a compat on read(2).
45 */ 46 */
46 __u8 __pad[48]; 47 __u8 __pad[46];
47}; 48};
48 49
49 50
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 77eb60d2b496..c0a4f3ab0cc0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -122,15 +122,26 @@ struct sk_buff_head {
122 122
123struct sk_buff; 123struct sk_buff;
124 124
125/* To allow 64K frame to be packed as single skb without frag_list */ 125/* To allow 64K frame to be packed as single skb without frag_list. Since
126 * GRO uses frags we allocate at least 16 regardless of page size.
127 */
128#if (65536/PAGE_SIZE + 2) < 16
129#define MAX_SKB_FRAGS 16UL
130#else
126#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 2) 131#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 2)
132#endif
127 133
128typedef struct skb_frag_struct skb_frag_t; 134typedef struct skb_frag_struct skb_frag_t;
129 135
130struct skb_frag_struct { 136struct skb_frag_struct {
131 struct page *page; 137 struct page *page;
138#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
132 __u32 page_offset; 139 __u32 page_offset;
133 __u32 size; 140 __u32 size;
141#else
142 __u16 page_offset;
143 __u16 size;
144#endif
134}; 145};
135 146
136#define HAVE_HW_TIME_STAMP 147#define HAVE_HW_TIME_STAMP
@@ -163,26 +174,19 @@ struct skb_shared_hwtstamps {
163 ktime_t syststamp; 174 ktime_t syststamp;
164}; 175};
165 176
166/** 177/* Definitions for tx_flags in struct skb_shared_info */
167 * struct skb_shared_tx - instructions for time stamping of outgoing packets 178enum {
168 * @hardware: generate hardware time stamp 179 /* generate hardware time stamp */
169 * @software: generate software time stamp 180 SKBTX_HW_TSTAMP = 1 << 0,
170 * @in_progress: device driver is going to provide 181
171 * hardware time stamp 182 /* generate software time stamp */
172 * @prevent_sk_orphan: make sk reference available on driver level 183 SKBTX_SW_TSTAMP = 1 << 1,
173 * @flags: all shared_tx flags 184
174 * 185 /* device driver is going to provide hardware time stamp */
175 * These flags are attached to packets as part of the 186 SKBTX_IN_PROGRESS = 1 << 2,
176 * &skb_shared_info. Use skb_tx() to get a pointer. 187
177 */ 188 /* ensure the originating sk reference is available on driver level */
178union skb_shared_tx { 189 SKBTX_DRV_NEEDS_SK_REF = 1 << 3,
179 struct {
180 __u8 hardware:1,
181 software:1,
182 in_progress:1,
183 prevent_sk_orphan:1;
184 };
185 __u8 flags;
186}; 190};
187 191
188/* This data is invariant across clones and lives at 192/* This data is invariant across clones and lives at
@@ -195,7 +199,7 @@ struct skb_shared_info {
195 unsigned short gso_segs; 199 unsigned short gso_segs;
196 unsigned short gso_type; 200 unsigned short gso_type;
197 __be32 ip6_frag_id; 201 __be32 ip6_frag_id;
198 union skb_shared_tx tx_flags; 202 __u8 tx_flags;
199 struct sk_buff *frag_list; 203 struct sk_buff *frag_list;
200 struct skb_shared_hwtstamps hwtstamps; 204 struct skb_shared_hwtstamps hwtstamps;
201 205
@@ -257,6 +261,11 @@ typedef unsigned int sk_buff_data_t;
257typedef unsigned char *sk_buff_data_t; 261typedef unsigned char *sk_buff_data_t;
258#endif 262#endif
259 263
264#if defined(CONFIG_NF_DEFRAG_IPV4) || defined(CONFIG_NF_DEFRAG_IPV4_MODULE) || \
265 defined(CONFIG_NF_DEFRAG_IPV6) || defined(CONFIG_NF_DEFRAG_IPV6_MODULE)
266#define NET_SKBUFF_NF_DEFRAG_NEEDED 1
267#endif
268
260/** 269/**
261 * struct sk_buff - socket buffer 270 * struct sk_buff - socket buffer
262 * @next: Next buffer in list 271 * @next: Next buffer in list
@@ -364,6 +373,8 @@ struct sk_buff {
364 void (*destructor)(struct sk_buff *skb); 373 void (*destructor)(struct sk_buff *skb);
365#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 374#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
366 struct nf_conntrack *nfct; 375 struct nf_conntrack *nfct;
376#endif
377#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
367 struct sk_buff *nfct_reasm; 378 struct sk_buff *nfct_reasm;
368#endif 379#endif
369#ifdef CONFIG_BRIDGE_NETFILTER 380#ifdef CONFIG_BRIDGE_NETFILTER
@@ -380,17 +391,15 @@ struct sk_buff {
380 391
381 __u32 rxhash; 392 __u32 rxhash;
382 393
394 __u16 queue_mapping;
383 kmemcheck_bitfield_begin(flags2); 395 kmemcheck_bitfield_begin(flags2);
384 __u16 queue_mapping:16;
385#ifdef CONFIG_IPV6_NDISC_NODETYPE 396#ifdef CONFIG_IPV6_NDISC_NODETYPE
386 __u8 ndisc_nodetype:2, 397 __u8 ndisc_nodetype:2;
387 deliver_no_wcard:1;
388#else
389 __u8 deliver_no_wcard:1;
390#endif 398#endif
399 __u8 ooo_okay:1;
391 kmemcheck_bitfield_end(flags2); 400 kmemcheck_bitfield_end(flags2);
392 401
393 /* 0/14 bit hole */ 402 /* 0/13 bit hole */
394 403
395#ifdef CONFIG_NET_DMA 404#ifdef CONFIG_NET_DMA
396 dma_cookie_t dma_cookie; 405 dma_cookie_t dma_cookie;
@@ -462,22 +471,10 @@ static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
462 skb->_skb_refdst = (unsigned long)dst; 471 skb->_skb_refdst = (unsigned long)dst;
463} 472}
464 473
465/** 474extern void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst);
466 * skb_dst_set_noref - sets skb dst, without a reference
467 * @skb: buffer
468 * @dst: dst entry
469 *
470 * Sets skb dst, assuming a reference was not taken on dst
471 * skb_dst_drop() should not dst_release() this dst
472 */
473static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst)
474{
475 WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held());
476 skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF;
477}
478 475
479/** 476/**
480 * skb_dst_is_noref - Test if skb dst isnt refcounted 477 * skb_dst_is_noref - Test if skb dst isn't refcounted
481 * @skb: buffer 478 * @skb: buffer
482 */ 479 */
483static inline bool skb_dst_is_noref(const struct sk_buff *skb) 480static inline bool skb_dst_is_noref(const struct sk_buff *skb)
@@ -498,13 +495,13 @@ extern struct sk_buff *__alloc_skb(unsigned int size,
498static inline struct sk_buff *alloc_skb(unsigned int size, 495static inline struct sk_buff *alloc_skb(unsigned int size,
499 gfp_t priority) 496 gfp_t priority)
500{ 497{
501 return __alloc_skb(size, priority, 0, -1); 498 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
502} 499}
503 500
504static inline struct sk_buff *alloc_skb_fclone(unsigned int size, 501static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
505 gfp_t priority) 502 gfp_t priority)
506{ 503{
507 return __alloc_skb(size, priority, 1, -1); 504 return __alloc_skb(size, priority, 1, NUMA_NO_NODE);
508} 505}
509 506
510extern bool skb_recycle_check(struct sk_buff *skb, int skb_size); 507extern bool skb_recycle_check(struct sk_buff *skb, int skb_size);
@@ -558,6 +555,15 @@ extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
558 unsigned int to, struct ts_config *config, 555 unsigned int to, struct ts_config *config,
559 struct ts_state *state); 556 struct ts_state *state);
560 557
558extern __u32 __skb_get_rxhash(struct sk_buff *skb);
559static inline __u32 skb_get_rxhash(struct sk_buff *skb)
560{
561 if (!skb->rxhash)
562 skb->rxhash = __skb_get_rxhash(skb);
563
564 return skb->rxhash;
565}
566
561#ifdef NET_SKBUFF_DATA_USES_OFFSET 567#ifdef NET_SKBUFF_DATA_USES_OFFSET
562static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) 568static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
563{ 569{
@@ -578,11 +584,6 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
578 return &skb_shinfo(skb)->hwtstamps; 584 return &skb_shinfo(skb)->hwtstamps;
579} 585}
580 586
581static inline union skb_shared_tx *skb_tx(struct sk_buff *skb)
582{
583 return &skb_shinfo(skb)->tx_flags;
584}
585
586/** 587/**
587 * skb_queue_empty - check if a queue is empty 588 * skb_queue_empty - check if a queue is empty
588 * @list: queue head 589 * @list: queue head
@@ -604,7 +605,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
604static inline bool skb_queue_is_last(const struct sk_buff_head *list, 605static inline bool skb_queue_is_last(const struct sk_buff_head *list,
605 const struct sk_buff *skb) 606 const struct sk_buff *skb)
606{ 607{
607 return (skb->next == (struct sk_buff *) list); 608 return skb->next == (struct sk_buff *)list;
608} 609}
609 610
610/** 611/**
@@ -617,7 +618,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
617static inline bool skb_queue_is_first(const struct sk_buff_head *list, 618static inline bool skb_queue_is_first(const struct sk_buff_head *list,
618 const struct sk_buff *skb) 619 const struct sk_buff *skb)
619{ 620{
620 return (skb->prev == (struct sk_buff *) list); 621 return skb->prev == (struct sk_buff *)list;
621} 622}
622 623
623/** 624/**
@@ -1123,7 +1124,7 @@ extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
1123 int off, int size); 1124 int off, int size);
1124 1125
1125#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) 1126#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
1126#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frags(skb)) 1127#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frag_list(skb))
1127#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) 1128#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
1128 1129
1129#ifdef NET_SKBUFF_DATA_USES_OFFSET 1130#ifdef NET_SKBUFF_DATA_USES_OFFSET
@@ -1255,6 +1256,11 @@ static inline void skb_reserve(struct sk_buff *skb, int len)
1255 skb->tail += len; 1256 skb->tail += len;
1256} 1257}
1257 1258
1259static inline void skb_reset_mac_len(struct sk_buff *skb)
1260{
1261 skb->mac_len = skb->network_header - skb->mac_header;
1262}
1263
1258#ifdef NET_SKBUFF_DATA_USES_OFFSET 1264#ifdef NET_SKBUFF_DATA_USES_OFFSET
1259static inline unsigned char *skb_transport_header(const struct sk_buff *skb) 1265static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
1260{ 1266{
@@ -1364,6 +1370,11 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1364} 1370}
1365#endif /* NET_SKBUFF_DATA_USES_OFFSET */ 1371#endif /* NET_SKBUFF_DATA_USES_OFFSET */
1366 1372
1373static inline int skb_checksum_start_offset(const struct sk_buff *skb)
1374{
1375 return skb->csum_start - skb_headroom(skb);
1376}
1377
1367static inline int skb_transport_offset(const struct sk_buff *skb) 1378static inline int skb_transport_offset(const struct sk_buff *skb)
1368{ 1379{
1369 return skb_transport_header(skb) - skb->data; 1380 return skb_transport_header(skb) - skb->data;
@@ -1436,7 +1447,7 @@ extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
1436 1447
1437static inline void __skb_trim(struct sk_buff *skb, unsigned int len) 1448static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
1438{ 1449{
1439 if (unlikely(skb->data_len)) { 1450 if (unlikely(skb_is_nonlinear(skb))) {
1440 WARN_ON(1); 1451 WARN_ON(1);
1441 return; 1452 return;
1442 } 1453 }
@@ -1561,13 +1572,25 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
1561 return skb; 1572 return skb;
1562} 1573}
1563 1574
1564extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask); 1575/**
1576 * __netdev_alloc_page - allocate a page for ps-rx on a specific device
1577 * @dev: network device to receive on
1578 * @gfp_mask: alloc_pages_node mask
1579 *
1580 * Allocate a new page. dev currently unused.
1581 *
1582 * %NULL is returned if there is no free memory.
1583 */
1584static inline struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask)
1585{
1586 return alloc_pages_node(NUMA_NO_NODE, gfp_mask, 0);
1587}
1565 1588
1566/** 1589/**
1567 * netdev_alloc_page - allocate a page for ps-rx on a specific device 1590 * netdev_alloc_page - allocate a page for ps-rx on a specific device
1568 * @dev: network device to receive on 1591 * @dev: network device to receive on
1569 * 1592 *
1570 * Allocate a new page node local to the specified device. 1593 * Allocate a new page. dev currently unused.
1571 * 1594 *
1572 * %NULL is returned if there is no free memory. 1595 * %NULL is returned if there is no free memory.
1573 */ 1596 */
@@ -1764,7 +1787,7 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
1764 1787
1765#define skb_queue_walk(queue, skb) \ 1788#define skb_queue_walk(queue, skb) \
1766 for (skb = (queue)->next; \ 1789 for (skb = (queue)->next; \
1767 prefetch(skb->next), (skb != (struct sk_buff *)(queue)); \ 1790 skb != (struct sk_buff *)(queue); \
1768 skb = skb->next) 1791 skb = skb->next)
1769 1792
1770#define skb_queue_walk_safe(queue, skb, tmp) \ 1793#define skb_queue_walk_safe(queue, skb, tmp) \
@@ -1773,7 +1796,7 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
1773 skb = tmp, tmp = skb->next) 1796 skb = tmp, tmp = skb->next)
1774 1797
1775#define skb_queue_walk_from(queue, skb) \ 1798#define skb_queue_walk_from(queue, skb) \
1776 for (; prefetch(skb->next), (skb != (struct sk_buff *)(queue)); \ 1799 for (; skb != (struct sk_buff *)(queue); \
1777 skb = skb->next) 1800 skb = skb->next)
1778 1801
1779#define skb_queue_walk_from_safe(queue, skb, tmp) \ 1802#define skb_queue_walk_from_safe(queue, skb, tmp) \
@@ -1783,11 +1806,20 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
1783 1806
1784#define skb_queue_reverse_walk(queue, skb) \ 1807#define skb_queue_reverse_walk(queue, skb) \
1785 for (skb = (queue)->prev; \ 1808 for (skb = (queue)->prev; \
1786 prefetch(skb->prev), (skb != (struct sk_buff *)(queue)); \ 1809 skb != (struct sk_buff *)(queue); \
1787 skb = skb->prev) 1810 skb = skb->prev)
1788 1811
1812#define skb_queue_reverse_walk_safe(queue, skb, tmp) \
1813 for (skb = (queue)->prev, tmp = skb->prev; \
1814 skb != (struct sk_buff *)(queue); \
1815 skb = tmp, tmp = skb->prev)
1816
1817#define skb_queue_reverse_walk_from_safe(queue, skb, tmp) \
1818 for (tmp = skb->prev; \
1819 skb != (struct sk_buff *)(queue); \
1820 skb = tmp, tmp = skb->prev)
1789 1821
1790static inline bool skb_has_frags(const struct sk_buff *skb) 1822static inline bool skb_has_frag_list(const struct sk_buff *skb)
1791{ 1823{
1792 return skb_shinfo(skb)->frag_list != NULL; 1824 return skb_shinfo(skb)->frag_list != NULL;
1793} 1825}
@@ -1853,7 +1885,7 @@ extern void skb_split(struct sk_buff *skb,
1853extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, 1885extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
1854 int shiftlen); 1886 int shiftlen);
1855 1887
1856extern struct sk_buff *skb_segment(struct sk_buff *skb, int features); 1888extern struct sk_buff *skb_segment(struct sk_buff *skb, u32 features);
1857 1889
1858static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, 1890static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
1859 int len, void *buffer) 1891 int len, void *buffer)
@@ -1987,8 +2019,8 @@ extern void skb_tstamp_tx(struct sk_buff *orig_skb,
1987 2019
1988static inline void sw_tx_timestamp(struct sk_buff *skb) 2020static inline void sw_tx_timestamp(struct sk_buff *skb)
1989{ 2021{
1990 union skb_shared_tx *shtx = skb_tx(skb); 2022 if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP &&
1991 if (shtx->software && !shtx->in_progress) 2023 !(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS))
1992 skb_tstamp_tx(skb, NULL); 2024 skb_tstamp_tx(skb, NULL);
1993} 2025}
1994 2026
@@ -2049,6 +2081,8 @@ static inline void nf_conntrack_get(struct nf_conntrack *nfct)
2049 if (nfct) 2081 if (nfct)
2050 atomic_inc(&nfct->use); 2082 atomic_inc(&nfct->use);
2051} 2083}
2084#endif
2085#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2052static inline void nf_conntrack_get_reasm(struct sk_buff *skb) 2086static inline void nf_conntrack_get_reasm(struct sk_buff *skb)
2053{ 2087{
2054 if (skb) 2088 if (skb)
@@ -2077,6 +2111,8 @@ static inline void nf_reset(struct sk_buff *skb)
2077#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 2111#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
2078 nf_conntrack_put(skb->nfct); 2112 nf_conntrack_put(skb->nfct);
2079 skb->nfct = NULL; 2113 skb->nfct = NULL;
2114#endif
2115#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2080 nf_conntrack_put_reasm(skb->nfct_reasm); 2116 nf_conntrack_put_reasm(skb->nfct_reasm);
2081 skb->nfct_reasm = NULL; 2117 skb->nfct_reasm = NULL;
2082#endif 2118#endif
@@ -2093,6 +2129,8 @@ static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
2093 dst->nfct = src->nfct; 2129 dst->nfct = src->nfct;
2094 nf_conntrack_get(src->nfct); 2130 nf_conntrack_get(src->nfct);
2095 dst->nfctinfo = src->nfctinfo; 2131 dst->nfctinfo = src->nfctinfo;
2132#endif
2133#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2096 dst->nfct_reasm = src->nfct_reasm; 2134 dst->nfct_reasm = src->nfct_reasm;
2097 nf_conntrack_get_reasm(src->nfct_reasm); 2135 nf_conntrack_get_reasm(src->nfct_reasm);
2098#endif 2136#endif
@@ -2106,6 +2144,8 @@ static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src)
2106{ 2144{
2107#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 2145#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
2108 nf_conntrack_put(dst->nfct); 2146 nf_conntrack_put(dst->nfct);
2147#endif
2148#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
2109 nf_conntrack_put_reasm(dst->nfct_reasm); 2149 nf_conntrack_put_reasm(dst->nfct_reasm);
2110#endif 2150#endif
2111#ifdef CONFIG_BRIDGE_NETFILTER 2151#ifdef CONFIG_BRIDGE_NETFILTER
@@ -2159,11 +2199,12 @@ static inline u16 skb_get_rx_queue(const struct sk_buff *skb)
2159 2199
2160static inline bool skb_rx_queue_recorded(const struct sk_buff *skb) 2200static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
2161{ 2201{
2162 return (skb->queue_mapping != 0); 2202 return skb->queue_mapping != 0;
2163} 2203}
2164 2204
2165extern u16 skb_tx_hash(const struct net_device *dev, 2205extern u16 __skb_tx_hash(const struct net_device *dev,
2166 const struct sk_buff *skb); 2206 const struct sk_buff *skb,
2207 unsigned int num_tx_queues);
2167 2208
2168#ifdef CONFIG_XFRM 2209#ifdef CONFIG_XFRM
2169static inline struct sec_path *skb_sec_path(struct sk_buff *skb) 2210static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
@@ -2209,6 +2250,21 @@ static inline void skb_forward_csum(struct sk_buff *skb)
2209 skb->ip_summed = CHECKSUM_NONE; 2250 skb->ip_summed = CHECKSUM_NONE;
2210} 2251}
2211 2252
2253/**
2254 * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE
2255 * @skb: skb to check
2256 *
2257 * fresh skbs have their ip_summed set to CHECKSUM_NONE.
2258 * Instead of forcing ip_summed to CHECKSUM_NONE, we can
2259 * use this helper, to document places where we make this assertion.
2260 */
2261static inline void skb_checksum_none_assert(struct sk_buff *skb)
2262{
2263#ifdef DEBUG
2264 BUG_ON(skb->ip_summed != CHECKSUM_NONE);
2265#endif
2266}
2267
2212bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off); 2268bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
2213#endif /* __KERNEL__ */ 2269#endif /* __KERNEL__ */
2214#endif /* _LINUX_SKBUFF_H */ 2270#endif /* _LINUX_SKBUFF_H */
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 59260e21bdf5..ad4dd1c8d30a 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -105,9 +105,6 @@ void kmem_cache_destroy(struct kmem_cache *);
105int kmem_cache_shrink(struct kmem_cache *); 105int kmem_cache_shrink(struct kmem_cache *);
106void kmem_cache_free(struct kmem_cache *, void *); 106void kmem_cache_free(struct kmem_cache *, void *);
107unsigned int kmem_cache_size(struct kmem_cache *); 107unsigned int kmem_cache_size(struct kmem_cache *);
108const char *kmem_cache_name(struct kmem_cache *);
109int kern_ptr_validate(const void *ptr, unsigned long size);
110int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
111 108
112/* 109/*
113 * Please use this macro to create slab caches. Simply specify the 110 * Please use this macro to create slab caches. Simply specify the
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 791a502f6906..83203ae9390b 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -138,11 +138,12 @@ void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
138void *__kmalloc(size_t size, gfp_t flags); 138void *__kmalloc(size_t size, gfp_t flags);
139 139
140#ifdef CONFIG_TRACING 140#ifdef CONFIG_TRACING
141extern void *kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags); 141extern void *kmem_cache_alloc_trace(size_t size,
142 struct kmem_cache *cachep, gfp_t flags);
142extern size_t slab_buffer_size(struct kmem_cache *cachep); 143extern size_t slab_buffer_size(struct kmem_cache *cachep);
143#else 144#else
144static __always_inline void * 145static __always_inline void *
145kmem_cache_alloc_notrace(struct kmem_cache *cachep, gfp_t flags) 146kmem_cache_alloc_trace(size_t size, struct kmem_cache *cachep, gfp_t flags)
146{ 147{
147 return kmem_cache_alloc(cachep, flags); 148 return kmem_cache_alloc(cachep, flags);
148} 149}
@@ -179,10 +180,7 @@ found:
179#endif 180#endif
180 cachep = malloc_sizes[i].cs_cachep; 181 cachep = malloc_sizes[i].cs_cachep;
181 182
182 ret = kmem_cache_alloc_notrace(cachep, flags); 183 ret = kmem_cache_alloc_trace(size, cachep, flags);
183
184 trace_kmalloc(_THIS_IP_, ret,
185 size, slab_buffer_size(cachep), flags);
186 184
187 return ret; 185 return ret;
188 } 186 }
@@ -194,14 +192,16 @@ extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
194extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); 192extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
195 193
196#ifdef CONFIG_TRACING 194#ifdef CONFIG_TRACING
197extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, 195extern void *kmem_cache_alloc_node_trace(size_t size,
198 gfp_t flags, 196 struct kmem_cache *cachep,
199 int nodeid); 197 gfp_t flags,
198 int nodeid);
200#else 199#else
201static __always_inline void * 200static __always_inline void *
202kmem_cache_alloc_node_notrace(struct kmem_cache *cachep, 201kmem_cache_alloc_node_trace(size_t size,
203 gfp_t flags, 202 struct kmem_cache *cachep,
204 int nodeid) 203 gfp_t flags,
204 int nodeid)
205{ 205{
206 return kmem_cache_alloc_node(cachep, flags, nodeid); 206 return kmem_cache_alloc_node(cachep, flags, nodeid);
207} 207}
@@ -210,7 +210,6 @@ kmem_cache_alloc_node_notrace(struct kmem_cache *cachep,
210static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) 210static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
211{ 211{
212 struct kmem_cache *cachep; 212 struct kmem_cache *cachep;
213 void *ret;
214 213
215 if (__builtin_constant_p(size)) { 214 if (__builtin_constant_p(size)) {
216 int i = 0; 215 int i = 0;
@@ -234,13 +233,7 @@ found:
234#endif 233#endif
235 cachep = malloc_sizes[i].cs_cachep; 234 cachep = malloc_sizes[i].cs_cachep;
236 235
237 ret = kmem_cache_alloc_node_notrace(cachep, flags, node); 236 return kmem_cache_alloc_node_trace(size, cachep, flags, node);
238
239 trace_kmalloc_node(_THIS_IP_, ret,
240 size, slab_buffer_size(cachep),
241 flags, node);
242
243 return ret;
244 } 237 }
245 return __kmalloc_node(size, flags, node); 238 return __kmalloc_node(size, flags, node);
246} 239}
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 9f63538928c0..c8668d161dd8 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -10,9 +10,8 @@
10#include <linux/gfp.h> 10#include <linux/gfp.h>
11#include <linux/workqueue.h> 11#include <linux/workqueue.h>
12#include <linux/kobject.h> 12#include <linux/kobject.h>
13#include <linux/kmemleak.h>
14 13
15#include <trace/events/kmem.h> 14#include <linux/kmemleak.h>
16 15
17enum stat_item { 16enum stat_item {
18 ALLOC_FASTPATH, /* Allocation from cpu slab */ 17 ALLOC_FASTPATH, /* Allocation from cpu slab */
@@ -33,10 +32,12 @@ enum stat_item {
33 DEACTIVATE_TO_TAIL, /* Cpu slab was moved to the tail of partials */ 32 DEACTIVATE_TO_TAIL, /* Cpu slab was moved to the tail of partials */
34 DEACTIVATE_REMOTE_FREES,/* Slab contained remotely freed objects */ 33 DEACTIVATE_REMOTE_FREES,/* Slab contained remotely freed objects */
35 ORDER_FALLBACK, /* Number of times fallback was necessary */ 34 ORDER_FALLBACK, /* Number of times fallback was necessary */
35 CMPXCHG_DOUBLE_CPU_FAIL,/* Failure of this_cpu_cmpxchg_double */
36 NR_SLUB_STAT_ITEMS }; 36 NR_SLUB_STAT_ITEMS };
37 37
38struct kmem_cache_cpu { 38struct kmem_cache_cpu {
39 void **freelist; /* Pointer to first free per cpu object */ 39 void **freelist; /* Pointer to next available object */
40 unsigned long tid; /* Globally unique transaction id */
40 struct page *page; /* The slab from which we are allocating */ 41 struct page *page; /* The slab from which we are allocating */
41 int node; /* The node of the page (or -1 for debug) */ 42 int node; /* The node of the page (or -1 for debug) */
42#ifdef CONFIG_SLUB_STATS 43#ifdef CONFIG_SLUB_STATS
@@ -71,6 +72,7 @@ struct kmem_cache {
71 struct kmem_cache_cpu __percpu *cpu_slab; 72 struct kmem_cache_cpu __percpu *cpu_slab;
72 /* Used for retriving partial slabs etc */ 73 /* Used for retriving partial slabs etc */
73 unsigned long flags; 74 unsigned long flags;
75 unsigned long min_partial;
74 int size; /* The size of an object including meta data */ 76 int size; /* The size of an object including meta data */
75 int objsize; /* The size of an object without meta data */ 77 int objsize; /* The size of an object without meta data */
76 int offset; /* Free pointer offset. */ 78 int offset; /* Free pointer offset. */
@@ -84,10 +86,10 @@ struct kmem_cache {
84 void (*ctor)(void *); 86 void (*ctor)(void *);
85 int inuse; /* Offset to metadata */ 87 int inuse; /* Offset to metadata */
86 int align; /* Alignment */ 88 int align; /* Alignment */
87 unsigned long min_partial; 89 int reserved; /* Reserved bytes at the end of slabs */
88 const char *name; /* Name (only for display!) */ 90 const char *name; /* Name (only for display!) */
89 struct list_head list; /* List of slab caches */ 91 struct list_head list; /* List of slab caches */
90#ifdef CONFIG_SLUB_DEBUG 92#ifdef CONFIG_SYSFS
91 struct kobject kobj; /* For sysfs */ 93 struct kobject kobj; /* For sysfs */
92#endif 94#endif
93 95
@@ -96,11 +98,8 @@ struct kmem_cache {
96 * Defragmentation by allocating from a remote node. 98 * Defragmentation by allocating from a remote node.
97 */ 99 */
98 int remote_node_defrag_ratio; 100 int remote_node_defrag_ratio;
99 struct kmem_cache_node *node[MAX_NUMNODES];
100#else
101 /* Avoid an extra cache line for UP */
102 struct kmem_cache_node local_node;
103#endif 101#endif
102 struct kmem_cache_node *node[MAX_NUMNODES];
104}; 103};
105 104
106/* 105/*
@@ -139,19 +138,16 @@ struct kmem_cache {
139 138
140#ifdef CONFIG_ZONE_DMA 139#ifdef CONFIG_ZONE_DMA
141#define SLUB_DMA __GFP_DMA 140#define SLUB_DMA __GFP_DMA
142/* Reserve extra caches for potential DMA use */
143#define KMALLOC_CACHES (2 * SLUB_PAGE_SHIFT)
144#else 141#else
145/* Disable DMA functionality */ 142/* Disable DMA functionality */
146#define SLUB_DMA (__force gfp_t)0 143#define SLUB_DMA (__force gfp_t)0
147#define KMALLOC_CACHES SLUB_PAGE_SHIFT
148#endif 144#endif
149 145
150/* 146/*
151 * We keep the general caches in an array of slab caches that are used for 147 * We keep the general caches in an array of slab caches that are used for
152 * 2^x bytes of allocations. 148 * 2^x bytes of allocations.
153 */ 149 */
154extern struct kmem_cache kmalloc_caches[KMALLOC_CACHES]; 150extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
155 151
156/* 152/*
157 * Sorry that the following has to be that ugly but some versions of GCC 153 * Sorry that the following has to be that ugly but some versions of GCC
@@ -181,7 +177,8 @@ static __always_inline int kmalloc_index(size_t size)
181 if (size <= 4 * 1024) return 12; 177 if (size <= 4 * 1024) return 12;
182/* 178/*
183 * The following is only needed to support architectures with a larger page 179 * The following is only needed to support architectures with a larger page
184 * size than 4k. 180 * size than 4k. We need to support 2 * PAGE_SIZE here. So for a 64k page
181 * size we would have to go up to 128k.
185 */ 182 */
186 if (size <= 8 * 1024) return 13; 183 if (size <= 8 * 1024) return 13;
187 if (size <= 16 * 1024) return 14; 184 if (size <= 16 * 1024) return 14;
@@ -192,7 +189,8 @@ static __always_inline int kmalloc_index(size_t size)
192 if (size <= 512 * 1024) return 19; 189 if (size <= 512 * 1024) return 19;
193 if (size <= 1024 * 1024) return 20; 190 if (size <= 1024 * 1024) return 20;
194 if (size <= 2 * 1024 * 1024) return 21; 191 if (size <= 2 * 1024 * 1024) return 21;
195 return -1; 192 BUG();
193 return -1; /* Will never be reached */
196 194
197/* 195/*
198 * What we really wanted to do and cannot do because of compiler issues is: 196 * What we really wanted to do and cannot do because of compiler issues is:
@@ -216,37 +214,46 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
216 if (index == 0) 214 if (index == 0)
217 return NULL; 215 return NULL;
218 216
219 return &kmalloc_caches[index]; 217 return kmalloc_caches[index];
220} 218}
221 219
222void *kmem_cache_alloc(struct kmem_cache *, gfp_t); 220void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
223void *__kmalloc(size_t size, gfp_t flags); 221void *__kmalloc(size_t size, gfp_t flags);
224 222
223static __always_inline void *
224kmalloc_order(size_t size, gfp_t flags, unsigned int order)
225{
226 void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
227 kmemleak_alloc(ret, size, 1, flags);
228 return ret;
229}
230
225#ifdef CONFIG_TRACING 231#ifdef CONFIG_TRACING
226extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags); 232extern void *
233kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size);
234extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order);
227#else 235#else
228static __always_inline void * 236static __always_inline void *
229kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags) 237kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size)
230{ 238{
231 return kmem_cache_alloc(s, gfpflags); 239 return kmem_cache_alloc(s, gfpflags);
232} 240}
241
242static __always_inline void *
243kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
244{
245 return kmalloc_order(size, flags, order);
246}
233#endif 247#endif
234 248
235static __always_inline void *kmalloc_large(size_t size, gfp_t flags) 249static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
236{ 250{
237 unsigned int order = get_order(size); 251 unsigned int order = get_order(size);
238 void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order); 252 return kmalloc_order_trace(size, flags, order);
239
240 kmemleak_alloc(ret, size, 1, flags);
241 trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags);
242
243 return ret;
244} 253}
245 254
246static __always_inline void *kmalloc(size_t size, gfp_t flags) 255static __always_inline void *kmalloc(size_t size, gfp_t flags)
247{ 256{
248 void *ret;
249
250 if (__builtin_constant_p(size)) { 257 if (__builtin_constant_p(size)) {
251 if (size > SLUB_MAX_SIZE) 258 if (size > SLUB_MAX_SIZE)
252 return kmalloc_large(size, flags); 259 return kmalloc_large(size, flags);
@@ -257,11 +264,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
257 if (!s) 264 if (!s)
258 return ZERO_SIZE_PTR; 265 return ZERO_SIZE_PTR;
259 266
260 ret = kmem_cache_alloc_notrace(s, flags); 267 return kmem_cache_alloc_trace(s, flags, size);
261
262 trace_kmalloc(_THIS_IP_, ret, size, s->size, flags);
263
264 return ret;
265 } 268 }
266 } 269 }
267 return __kmalloc(size, flags); 270 return __kmalloc(size, flags);
@@ -272,14 +275,14 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node);
272void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); 275void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
273 276
274#ifdef CONFIG_TRACING 277#ifdef CONFIG_TRACING
275extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s, 278extern void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
276 gfp_t gfpflags, 279 gfp_t gfpflags,
277 int node); 280 int node, size_t size);
278#else 281#else
279static __always_inline void * 282static __always_inline void *
280kmem_cache_alloc_node_notrace(struct kmem_cache *s, 283kmem_cache_alloc_node_trace(struct kmem_cache *s,
281 gfp_t gfpflags, 284 gfp_t gfpflags,
282 int node) 285 int node, size_t size)
283{ 286{
284 return kmem_cache_alloc_node(s, gfpflags, node); 287 return kmem_cache_alloc_node(s, gfpflags, node);
285} 288}
@@ -287,8 +290,6 @@ kmem_cache_alloc_node_notrace(struct kmem_cache *s,
287 290
288static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) 291static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
289{ 292{
290 void *ret;
291
292 if (__builtin_constant_p(size) && 293 if (__builtin_constant_p(size) &&
293 size <= SLUB_MAX_SIZE && !(flags & SLUB_DMA)) { 294 size <= SLUB_MAX_SIZE && !(flags & SLUB_DMA)) {
294 struct kmem_cache *s = kmalloc_slab(size); 295 struct kmem_cache *s = kmalloc_slab(size);
@@ -296,12 +297,7 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
296 if (!s) 297 if (!s)
297 return ZERO_SIZE_PTR; 298 return ZERO_SIZE_PTR;
298 299
299 ret = kmem_cache_alloc_node_notrace(s, flags, node); 300 return kmem_cache_alloc_node_trace(s, flags, node, size);
300
301 trace_kmalloc_node(_THIS_IP_, ret,
302 size, s->size, flags, node);
303
304 return ret;
305 } 301 }
306 return __kmalloc_node(size, flags, node); 302 return __kmalloc_node(size, flags, node);
307} 303}
diff --git a/include/linux/sm501.h b/include/linux/sm501.h
index 214f93209b8c..02fde50a79a5 100644
--- a/include/linux/sm501.h
+++ b/include/linux/sm501.h
@@ -172,3 +172,11 @@ struct sm501_platdata {
172 struct sm501_platdata_gpio_i2c *gpio_i2c; 172 struct sm501_platdata_gpio_i2c *gpio_i2c;
173 unsigned int gpio_i2c_nr; 173 unsigned int gpio_i2c_nr;
174}; 174};
175
176#if defined(CONFIG_PPC32)
177#define smc501_readl(addr) ioread32be((addr))
178#define smc501_writel(val, addr) iowrite32be((val), (addr))
179#else
180#define smc501_readl(addr) readl(addr)
181#define smc501_writel(val, addr) writel(val, addr)
182#endif
diff --git a/include/linux/smb.h b/include/linux/smb.h
deleted file mode 100644
index 82fefddc5987..000000000000
--- a/include/linux/smb.h
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * smb.h
3 *
4 * Copyright (C) 1995, 1996 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_H
10#define _LINUX_SMB_H
11
12#include <linux/types.h>
13#include <linux/magic.h>
14#ifdef __KERNEL__
15#include <linux/time.h>
16#endif
17
18enum smb_protocol {
19 SMB_PROTOCOL_NONE,
20 SMB_PROTOCOL_CORE,
21 SMB_PROTOCOL_COREPLUS,
22 SMB_PROTOCOL_LANMAN1,
23 SMB_PROTOCOL_LANMAN2,
24 SMB_PROTOCOL_NT1
25};
26
27enum smb_case_hndl {
28 SMB_CASE_DEFAULT,
29 SMB_CASE_LOWER,
30 SMB_CASE_UPPER
31};
32
33struct smb_dskattr {
34 __u16 total;
35 __u16 allocblocks;
36 __u16 blocksize;
37 __u16 free;
38};
39
40struct smb_conn_opt {
41
42 /* The socket */
43 unsigned int fd;
44
45 enum smb_protocol protocol;
46 enum smb_case_hndl case_handling;
47
48 /* Connection-Options */
49
50 __u32 max_xmit;
51 __u16 server_uid;
52 __u16 tid;
53
54 /* The following are LANMAN 1.0 options */
55 __u16 secmode;
56 __u16 maxmux;
57 __u16 maxvcs;
58 __u16 rawmode;
59 __u32 sesskey;
60
61 /* The following are NT LM 0.12 options */
62 __u32 maxraw;
63 __u32 capabilities;
64 __s16 serverzone;
65};
66
67#ifdef __KERNEL__
68
69#define SMB_NLS_MAXNAMELEN 20
70struct smb_nls_codepage {
71 char local_name[SMB_NLS_MAXNAMELEN];
72 char remote_name[SMB_NLS_MAXNAMELEN];
73};
74
75
76#define SMB_MAXNAMELEN 255
77#define SMB_MAXPATHLEN 1024
78
79/*
80 * Contains all relevant data on a SMB networked file.
81 */
82struct smb_fattr {
83 __u16 attr;
84
85 unsigned long f_ino;
86 umode_t f_mode;
87 nlink_t f_nlink;
88 uid_t f_uid;
89 gid_t f_gid;
90 dev_t f_rdev;
91 loff_t f_size;
92 struct timespec f_atime;
93 struct timespec f_mtime;
94 struct timespec f_ctime;
95 unsigned long f_blocks;
96 int f_unix;
97};
98
99enum smb_conn_state {
100 CONN_VALID, /* everything's fine */
101 CONN_INVALID, /* Something went wrong, but did not
102 try to reconnect yet. */
103 CONN_RETRIED, /* Tried a reconnection, but was refused */
104 CONN_RETRYING /* Currently trying to reconnect */
105};
106
107#define SMB_HEADER_LEN 37 /* includes everything up to, but not
108 * including smb_bcc */
109
110#define SMB_INITIAL_PACKET_SIZE 4000
111#define SMB_MAX_PACKET_SIZE 32768
112
113/* reserve this much space for trans2 parameters. Shouldn't have to be more
114 than 10 or so, but OS/2 seems happier like this. */
115#define SMB_TRANS2_MAX_PARAM 64
116
117#endif
118#endif
diff --git a/include/linux/smb_fs.h b/include/linux/smb_fs.h
deleted file mode 100644
index 923cd8a247b1..000000000000
--- a/include/linux/smb_fs.h
+++ /dev/null
@@ -1,153 +0,0 @@
1/*
2 * smb_fs.h
3 *
4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_FS_H
10#define _LINUX_SMB_FS_H
11
12#include <linux/smb.h>
13
14/*
15 * ioctl commands
16 */
17#define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_old_uid_t)
18#define SMB_IOC_NEWCONN _IOW('u', 2, struct smb_conn_opt)
19
20/* __kernel_uid_t can never change, so we have to use __kernel_uid32_t */
21#define SMB_IOC_GETMOUNTUID32 _IOR('u', 3, __kernel_uid32_t)
22
23
24#ifdef __KERNEL__
25#include <linux/smb_fs_i.h>
26#include <linux/smb_fs_sb.h>
27
28#include <linux/fs.h>
29#include <linux/pagemap.h>
30#include <linux/vmalloc.h>
31#include <linux/smb_mount.h>
32#include <linux/jiffies.h>
33#include <asm/unaligned.h>
34
35static inline struct smb_sb_info *SMB_SB(struct super_block *sb)
36{
37 return sb->s_fs_info;
38}
39
40static inline struct smb_inode_info *SMB_I(struct inode *inode)
41{
42 return container_of(inode, struct smb_inode_info, vfs_inode);
43}
44
45/* macro names are short for word, double-word, long value (?) */
46#define WVAL(buf, pos) (get_unaligned_le16((u8 *)(buf) + (pos)))
47#define DVAL(buf, pos) (get_unaligned_le32((u8 *)(buf) + (pos)))
48#define LVAL(buf, pos) (get_unaligned_le64((u8 *)(buf) + (pos)))
49
50#define WSET(buf, pos, val) put_unaligned_le16((val), (u8 *)(buf) + (pos))
51#define DSET(buf, pos, val) put_unaligned_le32((val), (u8 *)(buf) + (pos))
52#define LSET(buf, pos, val) put_unaligned_le64((val), (u8 *)(buf) + (pos))
53
54/* where to find the base of the SMB packet proper */
55#define smb_base(buf) ((u8 *)(((u8 *)(buf))+4))
56
57/*
58 * Flags for the in-memory inode
59 */
60#define SMB_F_LOCALWRITE 0x02 /* file modified locally */
61
62
63/* NT1 protocol capability bits */
64#define SMB_CAP_RAW_MODE 0x00000001
65#define SMB_CAP_MPX_MODE 0x00000002
66#define SMB_CAP_UNICODE 0x00000004
67#define SMB_CAP_LARGE_FILES 0x00000008
68#define SMB_CAP_NT_SMBS 0x00000010
69#define SMB_CAP_RPC_REMOTE_APIS 0x00000020
70#define SMB_CAP_STATUS32 0x00000040
71#define SMB_CAP_LEVEL_II_OPLOCKS 0x00000080
72#define SMB_CAP_LOCK_AND_READ 0x00000100
73#define SMB_CAP_NT_FIND 0x00000200
74#define SMB_CAP_DFS 0x00001000
75#define SMB_CAP_LARGE_READX 0x00004000
76#define SMB_CAP_LARGE_WRITEX 0x00008000
77#define SMB_CAP_UNIX 0x00800000 /* unofficial ... */
78
79
80/*
81 * This is the time we allow an inode, dentry or dir cache to live. It is bad
82 * for performance to have shorter ttl on an inode than on the cache. It can
83 * cause refresh on each inode for a dir listing ... one-by-one
84 */
85#define SMB_MAX_AGE(server) (((server)->mnt->ttl * HZ) / 1000)
86
87static inline void
88smb_age_dentry(struct smb_sb_info *server, struct dentry *dentry)
89{
90 dentry->d_time = jiffies - SMB_MAX_AGE(server);
91}
92
93struct smb_cache_head {
94 time_t mtime; /* unused */
95 unsigned long time; /* cache age */
96 unsigned long end; /* last valid fpos in cache */
97 int eof;
98};
99
100#define SMB_DIRCACHE_SIZE ((int)(PAGE_CACHE_SIZE/sizeof(struct dentry *)))
101union smb_dir_cache {
102 struct smb_cache_head head;
103 struct dentry *dentry[SMB_DIRCACHE_SIZE];
104};
105
106#define SMB_FIRSTCACHE_SIZE ((int)((SMB_DIRCACHE_SIZE * \
107 sizeof(struct dentry *) - sizeof(struct smb_cache_head)) / \
108 sizeof(struct dentry *)))
109
110#define SMB_DIRCACHE_START (SMB_DIRCACHE_SIZE - SMB_FIRSTCACHE_SIZE)
111
112struct smb_cache_control {
113 struct smb_cache_head head;
114 struct page *page;
115 union smb_dir_cache *cache;
116 unsigned long fpos, ofs;
117 int filled, valid, idx;
118};
119
120#define SMB_OPS_NUM_STATIC 5
121struct smb_ops {
122 int (*read)(struct inode *inode, loff_t offset, int count,
123 char *data);
124 int (*write)(struct inode *inode, loff_t offset, int count, const
125 char *data);
126 int (*readdir)(struct file *filp, void *dirent, filldir_t filldir,
127 struct smb_cache_control *ctl);
128
129 int (*getattr)(struct smb_sb_info *server, struct dentry *dir,
130 struct smb_fattr *fattr);
131 /* int (*setattr)(...); */ /* setattr is really icky! */
132
133 int (*truncate)(struct inode *inode, loff_t length);
134
135
136 /* --- --- --- end of "static" entries --- --- --- */
137
138 int (*convert)(unsigned char *output, int olen,
139 const unsigned char *input, int ilen,
140 struct nls_table *nls_from,
141 struct nls_table *nls_to);
142};
143
144static inline int
145smb_is_open(struct inode *i)
146{
147 return (SMB_I(i)->open == server_from_inode(i)->generation);
148}
149
150extern void smb_install_null_ops(struct smb_ops *);
151#endif /* __KERNEL__ */
152
153#endif /* _LINUX_SMB_FS_H */
diff --git a/include/linux/smb_fs_i.h b/include/linux/smb_fs_i.h
deleted file mode 100644
index 8ccf4eca2c3d..000000000000
--- a/include/linux/smb_fs_i.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * smb_fs_i.h
3 *
4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_FS_I
10#define _LINUX_SMB_FS_I
11
12#include <linux/types.h>
13#include <linux/fs.h>
14
15/*
16 * smb fs inode data (in memory only)
17 */
18struct smb_inode_info {
19
20 /*
21 * file handles are local to a connection. A file is open if
22 * (open == generation).
23 */
24 unsigned int open; /* open generation */
25 __u16 fileid; /* What id to handle a file with? */
26 __u16 attr; /* Attribute fields, DOS value */
27
28 __u16 access; /* Access mode */
29 __u16 flags;
30 unsigned long oldmtime; /* last time refreshed */
31 unsigned long closed; /* timestamp when closed */
32 unsigned openers; /* number of fileid users */
33
34 struct inode vfs_inode; /* must be at the end */
35};
36
37#endif
diff --git a/include/linux/smb_fs_sb.h b/include/linux/smb_fs_sb.h
deleted file mode 100644
index bb947dd1fba9..000000000000
--- a/include/linux/smb_fs_sb.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * smb_fs_sb.h
3 *
4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _SMB_FS_SB
10#define _SMB_FS_SB
11
12#include <linux/types.h>
13#include <linux/backing-dev.h>
14#include <linux/smb.h>
15
16/*
17 * Upper limit on the total number of active smb_request structs.
18 */
19#define MAX_REQUEST_HARD 256
20
21enum smb_receive_state {
22 SMB_RECV_START, /* No data read, looking for length + sig */
23 SMB_RECV_HEADER, /* Reading the header data */
24 SMB_RECV_HCOMPLETE, /* Done with the header */
25 SMB_RECV_PARAM, /* Reading parameter words */
26 SMB_RECV_DATA, /* Reading data bytes */
27 SMB_RECV_END, /* End of request */
28 SMB_RECV_DROP, /* Dropping this SMB */
29 SMB_RECV_REQUEST, /* Received a request and not a reply */
30};
31
32/* structure access macros */
33#define server_from_inode(inode) SMB_SB((inode)->i_sb)
34#define server_from_dentry(dentry) SMB_SB((dentry)->d_sb)
35#define SB_of(server) ((server)->super_block)
36
37struct smb_sb_info {
38 /* List of all smbfs superblocks */
39 struct list_head entry;
40
41 enum smb_conn_state state;
42 struct file * sock_file;
43 int conn_error;
44 enum smb_receive_state rstate;
45
46 atomic_t nr_requests;
47 struct list_head xmitq;
48 struct list_head recvq;
49 u16 mid;
50
51 struct smb_mount_data_kernel *mnt;
52
53 /* Connections are counted. Each time a new socket arrives,
54 * generation is incremented.
55 */
56 unsigned int generation;
57 struct pid *conn_pid;
58 struct smb_conn_opt opt;
59 wait_queue_head_t conn_wq;
60 int conn_complete;
61 struct semaphore sem;
62
63 unsigned char header[SMB_HEADER_LEN + 20*2 + 2];
64 u32 header_len;
65 u32 smb_len;
66 u32 smb_read;
67
68 /* We use our own data_ready callback, but need the original one */
69 void *data_ready;
70
71 /* nls pointers for codepage conversions */
72 struct nls_table *remote_nls;
73 struct nls_table *local_nls;
74
75 struct smb_ops *ops;
76
77 struct super_block *super_block;
78
79 struct backing_dev_info bdi;
80};
81
82static inline int
83smb_lock_server_interruptible(struct smb_sb_info *server)
84{
85 return down_interruptible(&(server->sem));
86}
87
88static inline void
89smb_lock_server(struct smb_sb_info *server)
90{
91 down(&(server->sem));
92}
93
94static inline void
95smb_unlock_server(struct smb_sb_info *server)
96{
97 up(&(server->sem));
98}
99
100#endif
diff --git a/include/linux/smb_mount.h b/include/linux/smb_mount.h
deleted file mode 100644
index d10f00cb5703..000000000000
--- a/include/linux/smb_mount.h
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * smb_mount.h
3 *
4 * Copyright (C) 1995, 1996 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
6 *
7 */
8
9#ifndef _LINUX_SMB_MOUNT_H
10#define _LINUX_SMB_MOUNT_H
11
12#include <linux/types.h>
13
14#define SMB_MOUNT_VERSION 6
15
16struct smb_mount_data {
17 int version;
18 __kernel_uid_t mounted_uid; /* Who may umount() this filesystem? */
19 __kernel_uid_t uid;
20 __kernel_gid_t gid;
21 __kernel_mode_t file_mode;
22 __kernel_mode_t dir_mode;
23};
24
25
26#ifdef __KERNEL__
27
28/* "vers" in big-endian */
29#define SMB_MOUNT_ASCII 0x76657273
30
31#define SMB_MOUNT_OLDVERSION 6
32#undef SMB_MOUNT_VERSION
33#define SMB_MOUNT_VERSION 7
34
35/* flags */
36#define SMB_MOUNT_WIN95 0x0001 /* Win 95 server */
37#define SMB_MOUNT_OLDATTR 0x0002 /* Use core getattr (Win 95 speedup) */
38#define SMB_MOUNT_DIRATTR 0x0004 /* Use find_first for getattr */
39#define SMB_MOUNT_CASE 0x0008 /* Be case sensitive */
40#define SMB_MOUNT_UNICODE 0x0010 /* Server talks unicode */
41#define SMB_MOUNT_UID 0x0020 /* Use user specified uid */
42#define SMB_MOUNT_GID 0x0040 /* Use user specified gid */
43#define SMB_MOUNT_FMODE 0x0080 /* Use user specified file mode */
44#define SMB_MOUNT_DMODE 0x0100 /* Use user specified dir mode */
45
46struct smb_mount_data_kernel {
47 int version;
48
49 uid_t mounted_uid; /* Who may umount() this filesystem? */
50 uid_t uid;
51 gid_t gid;
52 mode_t file_mode;
53 mode_t dir_mode;
54
55 u32 flags;
56
57 /* maximum age in jiffies (inode, dentry and dircache) */
58 int ttl;
59
60 struct smb_nls_codepage codepage;
61};
62
63#endif
64
65#endif
diff --git a/include/linux/smbno.h b/include/linux/smbno.h
deleted file mode 100644
index f99e02d9ffe2..000000000000
--- a/include/linux/smbno.h
+++ /dev/null
@@ -1,363 +0,0 @@
1#ifndef _SMBNO_H_
2#define _SMBNO_H_
3
4/* these define the attribute byte as seen by DOS */
5#define aRONLY (1L<<0)
6#define aHIDDEN (1L<<1)
7#define aSYSTEM (1L<<2)
8#define aVOLID (1L<<3)
9#define aDIR (1L<<4)
10#define aARCH (1L<<5)
11
12/* error classes */
13#define SUCCESS 0 /* The request was successful. */
14#define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
15#define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
16#define ERRHRD 0x03 /* Error is an hardware error. */
17#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
18
19/* SMB X/Open error codes for the ERRdos error class */
20
21#define ERRbadfunc 1 /* Invalid function (or system call) */
22#define ERRbadfile 2 /* File not found (pathname error) */
23#define ERRbadpath 3 /* Directory not found */
24#define ERRnofids 4 /* Too many open files */
25#define ERRnoaccess 5 /* Access denied */
26#define ERRbadfid 6 /* Invalid fid */
27#define ERRbadmcb 7 /* Memory control blocks destroyed */
28#define ERRnomem 8 /* Out of memory */
29#define ERRbadmem 9 /* Invalid memory block address */
30#define ERRbadenv 10 /* Invalid environment */
31#define ERRbadformat 11 /* Invalid format */
32#define ERRbadaccess 12 /* Invalid open mode */
33#define ERRbaddata 13 /* Invalid data (only from ioctl call) */
34#define ERRres 14 /* reserved */
35#define ERRbaddrive 15 /* Invalid drive */
36#define ERRremcd 16 /* Attempt to delete current directory */
37#define ERRdiffdevice 17 /* rename/move across different filesystems */
38#define ERRnofiles 18 /* no more files found in file search */
39#define ERRbadshare 32 /* Share mode on file conflict with open mode */
40#define ERRlock 33 /* Lock request conflicts with existing lock */
41#define ERRfilexists 80 /* File in operation already exists */
42#define ERRbadpipe 230 /* Named pipe invalid */
43#define ERRpipebusy 231 /* All instances of pipe are busy */
44#define ERRpipeclosing 232 /* named pipe close in progress */
45#define ERRnotconnected 233 /* No process on other end of named pipe */
46#define ERRmoredata 234 /* More data to be returned */
47
48#define ERROR_INVALID_PARAMETER 87
49#define ERROR_DISK_FULL 112
50#define ERROR_INVALID_NAME 123
51#define ERROR_DIR_NOT_EMPTY 145
52#define ERROR_NOT_LOCKED 158
53#define ERROR_ALREADY_EXISTS 183 /* see also 80 ? */
54#define ERROR_EAS_DIDNT_FIT 275 /* Extended attributes didn't fit */
55#define ERROR_EAS_NOT_SUPPORTED 282 /* Extended attributes not supported */
56
57/* Error codes for the ERRSRV class */
58
59#define ERRerror 1 /* Non specific error code */
60#define ERRbadpw 2 /* Bad password */
61#define ERRbadtype 3 /* reserved */
62#define ERRaccess 4 /* No permissions to do the requested operation */
63#define ERRinvnid 5 /* tid invalid */
64#define ERRinvnetname 6 /* Invalid servername */
65#define ERRinvdevice 7 /* Invalid device */
66#define ERRqfull 49 /* Print queue full */
67#define ERRqtoobig 50 /* Queued item too big */
68#define ERRinvpfid 52 /* Invalid print file in smb_fid */
69#define ERRsmbcmd 64 /* Unrecognised command */
70#define ERRsrverror 65 /* smb server internal error */
71#define ERRfilespecs 67 /* fid and pathname invalid combination */
72#define ERRbadlink 68 /* reserved */
73#define ERRbadpermits 69 /* Access specified for a file is not valid */
74#define ERRbadpid 70 /* reserved */
75#define ERRsetattrmode 71 /* attribute mode invalid */
76#define ERRpaused 81 /* Message server paused */
77#define ERRmsgoff 82 /* Not receiving messages */
78#define ERRnoroom 83 /* No room for message */
79#define ERRrmuns 87 /* too many remote usernames */
80#define ERRtimeout 88 /* operation timed out */
81#define ERRnoresource 89 /* No resources currently available for request. */
82#define ERRtoomanyuids 90 /* too many userids */
83#define ERRbaduid 91 /* bad userid */
84#define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
85#define ERRuseSTD 251 /* temporarily unable to use raw mode, use std.mode */
86#define ERRcontMPX 252 /* resume MPX mode */
87#define ERRbadPW /* reserved */
88#define ERRnosupport 0xFFFF
89
90/* Error codes for the ERRHRD class */
91
92#define ERRnowrite 19 /* read only media */
93#define ERRbadunit 20 /* Unknown device */
94#define ERRnotready 21 /* Drive not ready */
95#define ERRbadcmd 22 /* Unknown command */
96#define ERRdata 23 /* Data (CRC) error */
97#define ERRbadreq 24 /* Bad request structure length */
98#define ERRseek 25
99#define ERRbadmedia 26
100#define ERRbadsector 27
101#define ERRnopaper 28
102#define ERRwrite 29 /* write fault */
103#define ERRread 30 /* read fault */
104#define ERRgeneral 31 /* General hardware failure */
105#define ERRwrongdisk 34
106#define ERRFCBunavail 35
107#define ERRsharebufexc 36 /* share buffer exceeded */
108#define ERRdiskfull 39
109
110/*
111 * Access modes when opening a file
112 */
113#define SMB_ACCMASK 0x0003
114#define SMB_O_RDONLY 0x0000
115#define SMB_O_WRONLY 0x0001
116#define SMB_O_RDWR 0x0002
117
118/* offsets into message for common items */
119#define smb_com 8
120#define smb_rcls 9
121#define smb_reh 10
122#define smb_err 11
123#define smb_flg 13
124#define smb_flg2 14
125#define smb_reb 13
126#define smb_tid 28
127#define smb_pid 30
128#define smb_uid 32
129#define smb_mid 34
130#define smb_wct 36
131#define smb_vwv 37
132#define smb_vwv0 37
133#define smb_vwv1 39
134#define smb_vwv2 41
135#define smb_vwv3 43
136#define smb_vwv4 45
137#define smb_vwv5 47
138#define smb_vwv6 49
139#define smb_vwv7 51
140#define smb_vwv8 53
141#define smb_vwv9 55
142#define smb_vwv10 57
143#define smb_vwv11 59
144#define smb_vwv12 61
145#define smb_vwv13 63
146#define smb_vwv14 65
147
148/* these are the trans2 sub fields for primary requests */
149#define smb_tpscnt smb_vwv0
150#define smb_tdscnt smb_vwv1
151#define smb_mprcnt smb_vwv2
152#define smb_mdrcnt smb_vwv3
153#define smb_msrcnt smb_vwv4
154#define smb_flags smb_vwv5
155#define smb_timeout smb_vwv6
156#define smb_pscnt smb_vwv9
157#define smb_psoff smb_vwv10
158#define smb_dscnt smb_vwv11
159#define smb_dsoff smb_vwv12
160#define smb_suwcnt smb_vwv13
161#define smb_setup smb_vwv14
162#define smb_setup0 smb_setup
163#define smb_setup1 (smb_setup+2)
164#define smb_setup2 (smb_setup+4)
165
166/* these are for the secondary requests */
167#define smb_spscnt smb_vwv2
168#define smb_spsoff smb_vwv3
169#define smb_spsdisp smb_vwv4
170#define smb_sdscnt smb_vwv5
171#define smb_sdsoff smb_vwv6
172#define smb_sdsdisp smb_vwv7
173#define smb_sfid smb_vwv8
174
175/* and these for responses */
176#define smb_tprcnt smb_vwv0
177#define smb_tdrcnt smb_vwv1
178#define smb_prcnt smb_vwv3
179#define smb_proff smb_vwv4
180#define smb_prdisp smb_vwv5
181#define smb_drcnt smb_vwv6
182#define smb_droff smb_vwv7
183#define smb_drdisp smb_vwv8
184
185/* the complete */
186#define SMBmkdir 0x00 /* create directory */
187#define SMBrmdir 0x01 /* delete directory */
188#define SMBopen 0x02 /* open file */
189#define SMBcreate 0x03 /* create file */
190#define SMBclose 0x04 /* close file */
191#define SMBflush 0x05 /* flush file */
192#define SMBunlink 0x06 /* delete file */
193#define SMBmv 0x07 /* rename file */
194#define SMBgetatr 0x08 /* get file attributes */
195#define SMBsetatr 0x09 /* set file attributes */
196#define SMBread 0x0A /* read from file */
197#define SMBwrite 0x0B /* write to file */
198#define SMBlock 0x0C /* lock byte range */
199#define SMBunlock 0x0D /* unlock byte range */
200#define SMBctemp 0x0E /* create temporary file */
201#define SMBmknew 0x0F /* make new file */
202#define SMBchkpth 0x10 /* check directory path */
203#define SMBexit 0x11 /* process exit */
204#define SMBlseek 0x12 /* seek */
205#define SMBtcon 0x70 /* tree connect */
206#define SMBtconX 0x75 /* tree connect and X*/
207#define SMBtdis 0x71 /* tree disconnect */
208#define SMBnegprot 0x72 /* negotiate protocol */
209#define SMBdskattr 0x80 /* get disk attributes */
210#define SMBsearch 0x81 /* search directory */
211#define SMBsplopen 0xC0 /* open print spool file */
212#define SMBsplwr 0xC1 /* write to print spool file */
213#define SMBsplclose 0xC2 /* close print spool file */
214#define SMBsplretq 0xC3 /* return print queue */
215#define SMBsends 0xD0 /* send single block message */
216#define SMBsendb 0xD1 /* send broadcast message */
217#define SMBfwdname 0xD2 /* forward user name */
218#define SMBcancelf 0xD3 /* cancel forward */
219#define SMBgetmac 0xD4 /* get machine name */
220#define SMBsendstrt 0xD5 /* send start of multi-block message */
221#define SMBsendend 0xD6 /* send end of multi-block message */
222#define SMBsendtxt 0xD7 /* send text of multi-block message */
223
224/* Core+ protocol */
225#define SMBlockread 0x13 /* Lock a range and read */
226#define SMBwriteunlock 0x14 /* Unlock a range then write */
227#define SMBreadbraw 0x1a /* read a block of data with no smb header */
228#define SMBwritebraw 0x1d /* write a block of data with no smb header */
229#define SMBwritec 0x20 /* secondary write request */
230#define SMBwriteclose 0x2c /* write a file then close it */
231
232/* dos extended protocol */
233#define SMBreadBraw 0x1A /* read block raw */
234#define SMBreadBmpx 0x1B /* read block multiplexed */
235#define SMBreadBs 0x1C /* read block (secondary response) */
236#define SMBwriteBraw 0x1D /* write block raw */
237#define SMBwriteBmpx 0x1E /* write block multiplexed */
238#define SMBwriteBs 0x1F /* write block (secondary request) */
239#define SMBwriteC 0x20 /* write complete response */
240#define SMBsetattrE 0x22 /* set file attributes expanded */
241#define SMBgetattrE 0x23 /* get file attributes expanded */
242#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
243#define SMBtrans 0x25 /* transaction - name, bytes in/out */
244#define SMBtranss 0x26 /* transaction (secondary request/response) */
245#define SMBioctl 0x27 /* IOCTL */
246#define SMBioctls 0x28 /* IOCTL (secondary request/response) */
247#define SMBcopy 0x29 /* copy */
248#define SMBmove 0x2A /* move */
249#define SMBecho 0x2B /* echo */
250#define SMBopenX 0x2D /* open and X */
251#define SMBreadX 0x2E /* read and X */
252#define SMBwriteX 0x2F /* write and X */
253#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
254#define SMBtconX 0x75 /* tree connect and X */
255#define SMBffirst 0x82 /* find first */
256#define SMBfunique 0x83 /* find unique */
257#define SMBfclose 0x84 /* find close */
258#define SMBinvalid 0xFE /* invalid command */
259
260
261/* Extended 2.0 protocol */
262#define SMBtrans2 0x32 /* TRANS2 protocol set */
263#define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
264#define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
265#define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
266#define SMBulogoffX 0x74 /* user logoff */
267
268/* these are the TRANS2 sub commands */
269#define TRANSACT2_OPEN 0
270#define TRANSACT2_FINDFIRST 1
271#define TRANSACT2_FINDNEXT 2
272#define TRANSACT2_QFSINFO 3
273#define TRANSACT2_SETFSINFO 4
274#define TRANSACT2_QPATHINFO 5
275#define TRANSACT2_SETPATHINFO 6
276#define TRANSACT2_QFILEINFO 7
277#define TRANSACT2_SETFILEINFO 8
278#define TRANSACT2_FSCTL 9
279#define TRANSACT2_IOCTL 10
280#define TRANSACT2_FINDNOTIFYFIRST 11
281#define TRANSACT2_FINDNOTIFYNEXT 12
282#define TRANSACT2_MKDIR 13
283
284/* Information Levels - Shared? */
285#define SMB_INFO_STANDARD 1
286#define SMB_INFO_QUERY_EA_SIZE 2
287#define SMB_INFO_QUERY_EAS_FROM_LIST 3
288#define SMB_INFO_QUERY_ALL_EAS 4
289#define SMB_INFO_IS_NAME_VALID 6
290
291/* Information Levels - TRANSACT2_FINDFIRST */
292#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
293#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
294#define SMB_FIND_FILE_NAMES_INFO 0x103
295#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
296
297/* Information Levels - TRANSACT2_QPATHINFO */
298#define SMB_QUERY_FILE_BASIC_INFO 0x101
299#define SMB_QUERY_FILE_STANDARD_INFO 0x102
300#define SMB_QUERY_FILE_EA_INFO 0x103
301#define SMB_QUERY_FILE_NAME_INFO 0x104
302#define SMB_QUERY_FILE_ALL_INFO 0x107
303#define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
304#define SMB_QUERY_FILE_STREAM_INFO 0x109
305#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10b
306
307/* Information Levels - TRANSACT2_SETFILEINFO */
308#define SMB_SET_FILE_BASIC_INFO 0x101
309#define SMB_SET_FILE_DISPOSITION_INFO 0x102
310#define SMB_SET_FILE_ALLOCATION_INFO 0x103
311#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
312
313/* smb_flg field flags */
314#define SMB_FLAGS_SUPPORT_LOCKREAD 0x01
315#define SMB_FLAGS_CLIENT_BUF_AVAIL 0x02
316#define SMB_FLAGS_RESERVED 0x04
317#define SMB_FLAGS_CASELESS_PATHNAMES 0x08
318#define SMB_FLAGS_CANONICAL_PATHNAMES 0x10
319#define SMB_FLAGS_REQUEST_OPLOCK 0x20
320#define SMB_FLAGS_REQUEST_BATCH_OPLOCK 0x40
321#define SMB_FLAGS_REPLY 0x80
322
323/* smb_flg2 field flags (samba-2.2.0/source/include/smb.h) */
324#define SMB_FLAGS2_LONG_PATH_COMPONENTS 0x0001
325#define SMB_FLAGS2_EXTENDED_ATTRIBUTES 0x0002
326#define SMB_FLAGS2_DFS_PATHNAMES 0x1000
327#define SMB_FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
328#define SMB_FLAGS2_32_BIT_ERROR_CODES 0x4000
329#define SMB_FLAGS2_UNICODE_STRINGS 0x8000
330
331
332/*
333 * UNIX stuff (from samba trans2.h)
334 */
335#define MIN_UNIX_INFO_LEVEL 0x200
336#define MAX_UNIX_INFO_LEVEL 0x2FF
337#define SMB_FIND_FILE_UNIX 0x202
338#define SMB_QUERY_FILE_UNIX_BASIC 0x200
339#define SMB_QUERY_FILE_UNIX_LINK 0x201
340#define SMB_QUERY_FILE_UNIX_HLINK 0x202
341#define SMB_SET_FILE_UNIX_BASIC 0x200
342#define SMB_SET_FILE_UNIX_LINK 0x201
343#define SMB_SET_FILE_UNIX_HLINK 0x203
344#define SMB_QUERY_CIFS_UNIX_INFO 0x200
345
346/* values which means "don't change it" */
347#define SMB_MODE_NO_CHANGE 0xFFFFFFFF
348#define SMB_UID_NO_CHANGE 0xFFFFFFFF
349#define SMB_GID_NO_CHANGE 0xFFFFFFFF
350#define SMB_TIME_NO_CHANGE 0xFFFFFFFFFFFFFFFFULL
351#define SMB_SIZE_NO_CHANGE 0xFFFFFFFFFFFFFFFFULL
352
353/* UNIX filetype mappings. */
354#define UNIX_TYPE_FILE 0
355#define UNIX_TYPE_DIR 1
356#define UNIX_TYPE_SYMLINK 2
357#define UNIX_TYPE_CHARDEV 3
358#define UNIX_TYPE_BLKDEV 4
359#define UNIX_TYPE_FIFO 5
360#define UNIX_TYPE_SOCKET 6
361#define UNIX_TYPE_UNKNOWN 0xFFFFFFFF
362
363#endif /* _SMBNO_H_ */
diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h
index bc21db598c06..76199b75d584 100644
--- a/include/linux/smc91x.h
+++ b/include/linux/smc91x.h
@@ -21,7 +21,7 @@
21#define RPC_LED_10 (0x02) /* LED = 10Mbps link detect */ 21#define RPC_LED_10 (0x02) /* LED = 10Mbps link detect */
22#define RPC_LED_FD (0x03) /* LED = Full Duplex Mode */ 22#define RPC_LED_FD (0x03) /* LED = Full Duplex Mode */
23#define RPC_LED_TX_RX (0x04) /* LED = TX or RX packet occurred */ 23#define RPC_LED_TX_RX (0x04) /* LED = TX or RX packet occurred */
24#define RPC_LED_100 (0x05) /* LED = 100Mbps link dectect */ 24#define RPC_LED_100 (0x05) /* LED = 100Mbps link detect */
25#define RPC_LED_TX (0x06) /* LED = TX packet occurred */ 25#define RPC_LED_TX (0x06) /* LED = TX packet occurred */
26#define RPC_LED_RX (0x07) /* LED = RX packet occurred */ 26#define RPC_LED_RX (0x07) /* LED = RX packet occurred */
27 27
diff --git a/include/linux/smp.h b/include/linux/smp.h
index f86d40768e7f..53b1beef27ad 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -10,12 +10,14 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/cpumask.h> 12#include <linux/cpumask.h>
13#include <linux/init.h>
13 14
14extern void cpu_idle(void); 15extern void cpu_idle(void);
15 16
17typedef void (*smp_call_func_t)(void *info);
16struct call_single_data { 18struct call_single_data {
17 struct list_head list; 19 struct list_head list;
18 void (*func) (void *info); 20 smp_call_func_t func;
19 void *info; 21 void *info;
20 u16 flags; 22 u16 flags;
21 u16 priv; 23 u16 priv;
@@ -24,8 +26,8 @@ struct call_single_data {
24/* total number of cpus in this system (may exceed NR_CPUS) */ 26/* total number of cpus in this system (may exceed NR_CPUS) */
25extern unsigned int total_cpus; 27extern unsigned int total_cpus;
26 28
27int smp_call_function_single(int cpuid, void (*func) (void *info), void *info, 29int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
28 int wait); 30 int wait);
29 31
30#ifdef CONFIG_SMP 32#ifdef CONFIG_SMP
31 33
@@ -69,15 +71,15 @@ extern void smp_cpus_done(unsigned int max_cpus);
69/* 71/*
70 * Call a function on all other processors 72 * Call a function on all other processors
71 */ 73 */
72int smp_call_function(void(*func)(void *info), void *info, int wait); 74int smp_call_function(smp_call_func_t func, void *info, int wait);
73void smp_call_function_many(const struct cpumask *mask, 75void smp_call_function_many(const struct cpumask *mask,
74 void (*func)(void *info), void *info, bool wait); 76 smp_call_func_t func, void *info, bool wait);
75 77
76void __smp_call_function_single(int cpuid, struct call_single_data *data, 78void __smp_call_function_single(int cpuid, struct call_single_data *data,
77 int wait); 79 int wait);
78 80
79int smp_call_function_any(const struct cpumask *mask, 81int smp_call_function_any(const struct cpumask *mask,
80 void (*func)(void *info), void *info, int wait); 82 smp_call_func_t func, void *info, int wait);
81 83
82/* 84/*
83 * sends a 'pull timer' event to a remote CPU 85 * sends a 'pull timer' event to a remote CPU
@@ -88,28 +90,21 @@ extern void smp_send_pull_timers(int cpu);
88 * Generic and arch helpers 90 * Generic and arch helpers
89 */ 91 */
90#ifdef CONFIG_USE_GENERIC_SMP_HELPERS 92#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
93void __init call_function_init(void);
91void generic_smp_call_function_single_interrupt(void); 94void generic_smp_call_function_single_interrupt(void);
92void generic_smp_call_function_interrupt(void); 95void generic_smp_call_function_interrupt(void);
93void ipi_call_lock(void); 96void ipi_call_lock(void);
94void ipi_call_unlock(void); 97void ipi_call_unlock(void);
95void ipi_call_lock_irq(void); 98void ipi_call_lock_irq(void);
96void ipi_call_unlock_irq(void); 99void ipi_call_unlock_irq(void);
100#else
101static inline void call_function_init(void) { }
97#endif 102#endif
98 103
99/* 104/*
100 * Call a function on all processors 105 * Call a function on all processors
101 */ 106 */
102int on_each_cpu(void (*func) (void *info), void *info, int wait); 107int on_each_cpu(smp_call_func_t func, void *info, int wait);
103
104#define MSG_ALL_BUT_SELF 0x8000 /* Assume <32768 CPU's */
105#define MSG_ALL 0x8001
106
107#define MSG_INVALIDATE_TLB 0x0001 /* Remote processor TLB invalidate */
108#define MSG_STOP_CPU 0x0002 /* Sent to shut down slave CPU's
109 * when rebooting
110 */
111#define MSG_RESCHEDULE 0x0003 /* Reschedule request from master CPU*/
112#define MSG_CALL_FUNCTION 0x0004 /* Call function on all other CPUs */
113 108
114/* 109/*
115 * Mark the boot cpu "online" so that it can call console drivers in 110 * Mark the boot cpu "online" so that it can call console drivers in
@@ -118,6 +113,8 @@ int on_each_cpu(void (*func) (void *info), void *info, int wait);
118void smp_prepare_boot_cpu(void); 113void smp_prepare_boot_cpu(void);
119 114
120extern unsigned int setup_max_cpus; 115extern unsigned int setup_max_cpus;
116extern void __init setup_nr_cpu_ids(void);
117extern void __init smp_init(void);
121 118
122#else /* !SMP */ 119#else /* !SMP */
123 120
@@ -127,7 +124,7 @@ static inline void smp_send_stop(void) { }
127 * These macros fold the SMP functionality into a single CPU system 124 * These macros fold the SMP functionality into a single CPU system
128 */ 125 */
129#define raw_smp_processor_id() 0 126#define raw_smp_processor_id() 0
130static inline int up_smp_call_function(void (*func)(void *), void *info) 127static inline int up_smp_call_function(smp_call_func_t func, void *info)
131{ 128{
132 return 0; 129 return 0;
133} 130}
@@ -145,10 +142,10 @@ static inline void smp_send_reschedule(int cpu) { }
145#define smp_prepare_boot_cpu() do {} while (0) 142#define smp_prepare_boot_cpu() do {} while (0)
146#define smp_call_function_many(mask, func, info, wait) \ 143#define smp_call_function_many(mask, func, info, wait) \
147 (up_smp_call_function(func, info)) 144 (up_smp_call_function(func, info))
148static inline void init_call_single_data(void) { } 145static inline void call_function_init(void) { }
149 146
150static inline int 147static inline int
151smp_call_function_any(const struct cpumask *mask, void (*func)(void *info), 148smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
152 void *info, int wait) 149 void *info, int wait)
153{ 150{
154 return smp_call_function_single(0, func, info, wait); 151 return smp_call_function_single(0, func, info, wait);
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
deleted file mode 100644
index 2ea1dd1ba21c..000000000000
--- a/include/linux/smp_lock.h
+++ /dev/null
@@ -1,65 +0,0 @@
1#ifndef __LINUX_SMPLOCK_H
2#define __LINUX_SMPLOCK_H
3
4#ifdef CONFIG_LOCK_KERNEL
5#include <linux/sched.h>
6
7#define kernel_locked() (current->lock_depth >= 0)
8
9extern int __lockfunc __reacquire_kernel_lock(void);
10extern void __lockfunc __release_kernel_lock(void);
11
12/*
13 * Release/re-acquire global kernel lock for the scheduler
14 */
15#define release_kernel_lock(tsk) do { \
16 if (unlikely((tsk)->lock_depth >= 0)) \
17 __release_kernel_lock(); \
18} while (0)
19
20static inline int reacquire_kernel_lock(struct task_struct *task)
21{
22 if (unlikely(task->lock_depth >= 0))
23 return __reacquire_kernel_lock();
24 return 0;
25}
26
27extern void __lockfunc
28_lock_kernel(const char *func, const char *file, int line)
29__acquires(kernel_lock);
30
31extern void __lockfunc
32_unlock_kernel(const char *func, const char *file, int line)
33__releases(kernel_lock);
34
35#define lock_kernel() do { \
36 _lock_kernel(__func__, __FILE__, __LINE__); \
37} while (0)
38
39#define unlock_kernel() do { \
40 _unlock_kernel(__func__, __FILE__, __LINE__); \
41} while (0)
42
43/*
44 * Various legacy drivers don't really need the BKL in a specific
45 * function, but they *do* need to know that the BKL became available.
46 * This function just avoids wrapping a bunch of lock/unlock pairs
47 * around code which doesn't really need it.
48 */
49static inline void cycle_kernel_lock(void)
50{
51 lock_kernel();
52 unlock_kernel();
53}
54
55#else
56
57#define lock_kernel()
58#define unlock_kernel()
59#define release_kernel_lock(task) do { } while(0)
60#define cycle_kernel_lock() do { } while(0)
61#define reacquire_kernel_lock(task) 0
62#define kernel_locked() 1
63
64#endif /* CONFIG_LOCK_KERNEL */
65#endif /* __LINUX_SMPLOCK_H */
diff --git a/include/linux/smsc911x.h b/include/linux/smsc911x.h
index 7144e8aa1e41..4dde70e74822 100644
--- a/include/linux/smsc911x.h
+++ b/include/linux/smsc911x.h
@@ -29,6 +29,7 @@ struct smsc911x_platform_config {
29 unsigned int irq_polarity; 29 unsigned int irq_polarity;
30 unsigned int irq_type; 30 unsigned int irq_type;
31 unsigned int flags; 31 unsigned int flags;
32 unsigned int shift;
32 phy_interface_t phy_interface; 33 phy_interface_t phy_interface;
33 unsigned char mac[6]; 34 unsigned char mac[6];
34}; 35};
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
index ebb0c80ffd6e..12b2b18e50c1 100644
--- a/include/linux/snmp.h
+++ b/include/linux/snmp.h
@@ -230,6 +230,7 @@ enum
230 LINUX_MIB_TCPMINTTLDROP, /* RFC 5082 */ 230 LINUX_MIB_TCPMINTTLDROP, /* RFC 5082 */
231 LINUX_MIB_TCPDEFERACCEPTDROP, 231 LINUX_MIB_TCPDEFERACCEPTDROP,
232 LINUX_MIB_IPRPFILTER, /* IP Reverse Path Filter (rp_filter) */ 232 LINUX_MIB_IPRPFILTER, /* IP Reverse Path Filter (rp_filter) */
233 LINUX_MIB_TCPTIMEWAITOVERFLOW, /* TCPTimeWaitOverflow */
233 __LINUX_MIB_MAX 234 __LINUX_MIB_MAX
234}; 235};
235 236
diff --git a/include/linux/socket.h b/include/linux/socket.h
index a8f56e1ec760..4ef98e422fde 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -30,12 +30,10 @@ struct cred;
30#define __sockaddr_check_size(size) \ 30#define __sockaddr_check_size(size) \
31 BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage))) 31 BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage)))
32 32
33#ifdef __KERNEL__ 33#ifdef CONFIG_PROC_FS
34# ifdef CONFIG_PROC_FS
35struct seq_file; 34struct seq_file;
36extern void socket_seq_show(struct seq_file *seq); 35extern void socket_seq_show(struct seq_file *seq);
37# endif 36#endif
38#endif /* __KERNEL__ */
39 37
40typedef unsigned short sa_family_t; 38typedef unsigned short sa_family_t;
41 39
@@ -90,7 +88,7 @@ struct cmsghdr {
90}; 88};
91 89
92/* 90/*
93 * Ancilliary data object information MACROS 91 * Ancillary data object information MACROS
94 * Table 5-14 of POSIX 1003.1g 92 * Table 5-14 of POSIX 1003.1g
95 */ 93 */
96 94
@@ -193,7 +191,8 @@ struct ucred {
193#define AF_PHONET 35 /* Phonet sockets */ 191#define AF_PHONET 35 /* Phonet sockets */
194#define AF_IEEE802154 36 /* IEEE802154 sockets */ 192#define AF_IEEE802154 36 /* IEEE802154 sockets */
195#define AF_CAIF 37 /* CAIF sockets */ 193#define AF_CAIF 37 /* CAIF sockets */
196#define AF_MAX 38 /* For now.. */ 194#define AF_ALG 38 /* Algorithm sockets */
195#define AF_MAX 39 /* For now.. */
197 196
198/* Protocol families, same as address families. */ 197/* Protocol families, same as address families. */
199#define PF_UNSPEC AF_UNSPEC 198#define PF_UNSPEC AF_UNSPEC
@@ -234,6 +233,7 @@ struct ucred {
234#define PF_PHONET AF_PHONET 233#define PF_PHONET AF_PHONET
235#define PF_IEEE802154 AF_IEEE802154 234#define PF_IEEE802154 AF_IEEE802154
236#define PF_CAIF AF_CAIF 235#define PF_CAIF AF_CAIF
236#define PF_ALG AF_ALG
237#define PF_MAX AF_MAX 237#define PF_MAX AF_MAX
238 238
239/* Maximum queue length specifiable by listen. */ 239/* Maximum queue length specifiable by listen. */
@@ -307,11 +307,11 @@ struct ucred {
307#define SOL_RDS 276 307#define SOL_RDS 276
308#define SOL_IUCV 277 308#define SOL_IUCV 277
309#define SOL_CAIF 278 309#define SOL_CAIF 278
310#define SOL_ALG 279
310 311
311/* IPX options */ 312/* IPX options */
312#define IPX_TYPE 1 313#define IPX_TYPE 1
313 314
314#ifdef __KERNEL__
315extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred); 315extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred);
316 316
317extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len); 317extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
@@ -322,11 +322,10 @@ extern int csum_partial_copy_fromiovecend(unsigned char *kdata,
322 int offset, 322 int offset,
323 unsigned int len, __wsum *csump); 323 unsigned int len, __wsum *csump);
324 324
325extern long verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode); 325extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode);
326extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len); 326extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
327extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata, 327extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
328 int offset, int len); 328 int offset, int len);
329extern int move_addr_to_user(struct sockaddr *kaddr, int klen, void __user *uaddr, int __user *ulen);
330extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr *kaddr); 329extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr *kaddr);
331extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); 330extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
332 331
@@ -334,6 +333,7 @@ struct timespec;
334 333
335extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, 334extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
336 unsigned int flags, struct timespec *timeout); 335 unsigned int flags, struct timespec *timeout);
337#endif 336extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg,
337 unsigned int vlen, unsigned int flags);
338#endif /* not kernel and not glibc */ 338#endif /* not kernel and not glibc */
339#endif /* _LINUX_SOCKET_H */ 339#endif /* _LINUX_SOCKET_H */
diff --git a/include/linux/sockios.h b/include/linux/sockios.h
index 241f179347d9..7997a506ad41 100644
--- a/include/linux/sockios.h
+++ b/include/linux/sockios.h
@@ -22,7 +22,7 @@
22 22
23/* Linux-specific socket ioctls */ 23/* Linux-specific socket ioctls */
24#define SIOCINQ FIONREAD 24#define SIOCINQ FIONREAD
25#define SIOCOUTQ TIOCOUTQ 25#define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */
26 26
27/* Routing table calls. */ 27/* Routing table calls. */
28#define SIOCADDRT 0x890B /* add routing table entry */ 28#define SIOCADDRT 0x890B /* add routing table entry */
@@ -83,6 +83,8 @@
83 83
84#define SIOCWANDEV 0x894A /* get/set netdev parameters */ 84#define SIOCWANDEV 0x894A /* get/set netdev parameters */
85 85
86#define SIOCOUTQNSD 0x894B /* output queue size (not sent only) */
87
86/* ARP cache control calls. */ 88/* ARP cache control calls. */
87 /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ 89 /* 0x8950 - 0x8952 * obsolete calls, don't re-use */
88#define SIOCDARP 0x8953 /* delete ARP table entry */ 90#define SIOCDARP 0x8953 /* delete ARP table entry */
diff --git a/include/linux/sonypi.h b/include/linux/sonypi.h
index 4f95c1aac2fd..c0f87da78f8a 100644
--- a/include/linux/sonypi.h
+++ b/include/linux/sonypi.h
@@ -40,6 +40,7 @@
40 40
41/* events the user application reading /dev/sonypi can use */ 41/* events the user application reading /dev/sonypi can use */
42 42
43#define SONYPI_EVENT_IGNORE 0
43#define SONYPI_EVENT_JOGDIAL_DOWN 1 44#define SONYPI_EVENT_JOGDIAL_DOWN 1
44#define SONYPI_EVENT_JOGDIAL_UP 2 45#define SONYPI_EVENT_JOGDIAL_UP 2
45#define SONYPI_EVENT_JOGDIAL_DOWN_PRESSED 3 46#define SONYPI_EVENT_JOGDIAL_DOWN_PRESSED 3
@@ -112,6 +113,7 @@
112#define SONYPI_EVENT_VOLUME_DEC_PRESSED 70 113#define SONYPI_EVENT_VOLUME_DEC_PRESSED 70
113#define SONYPI_EVENT_BRIGHTNESS_PRESSED 71 114#define SONYPI_EVENT_BRIGHTNESS_PRESSED 71
114#define SONYPI_EVENT_MEDIA_PRESSED 72 115#define SONYPI_EVENT_MEDIA_PRESSED 72
116#define SONYPI_EVENT_VENDOR_PRESSED 73
115 117
116/* get/set brightness */ 118/* get/set brightness */
117#define SONYPI_IOCGBRT _IOR('v', 0, __u8) 119#define SONYPI_IOCGBRT _IOR('v', 0, __u8)
diff --git a/include/linux/soundcard.h b/include/linux/soundcard.h
index 1904afedb82f..fe204fe39f7c 100644
--- a/include/linux/soundcard.h
+++ b/include/linux/soundcard.h
@@ -1231,7 +1231,7 @@ void seqbuf_dump(void); /* This function must be provided by programs */
1231#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) 1231#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
1232 1232
1233/* 1233/*
1234 * Timing and syncronization macros 1234 * Timing and synchronization macros
1235 */ 1235 */
1236 1236
1237#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ 1237#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
diff --git a/include/linux/spi/74x164.h b/include/linux/spi/74x164.h
new file mode 100644
index 000000000000..d85c52f294a0
--- /dev/null
+++ b/include/linux/spi/74x164.h
@@ -0,0 +1,11 @@
1#ifndef LINUX_SPI_74X164_H
2#define LINUX_SPI_74X164_H
3
4#define GEN_74X164_DRIVER_NAME "74x164"
5
6struct gen_74x164_chip_platform_data {
7 /* number assigned to the first GPIO */
8 unsigned base;
9};
10
11#endif
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 92bd0839d5b4..c64de9dd7631 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -14,7 +14,8 @@ enum ads7846_filter {
14struct ads7846_platform_data { 14struct ads7846_platform_data {
15 u16 model; /* 7843, 7845, 7846, 7873. */ 15 u16 model; /* 7843, 7845, 7846, 7873. */
16 u16 vref_delay_usecs; /* 0 for external vref; etc */ 16 u16 vref_delay_usecs; /* 0 for external vref; etc */
17 u16 vref_mv; /* external vref value, milliVolts */ 17 u16 vref_mv; /* external vref value, milliVolts
18 * ads7846: if 0, use internal vref */
18 bool keep_vref_on; /* set to keep vref on for differential 19 bool keep_vref_on; /* set to keep vref on for differential
19 * measurements as well */ 20 * measurements as well */
20 bool swap_xy; /* swap x and y axes */ 21 bool swap_xy; /* swap x and y axes */
diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h
deleted file mode 100644
index c91302f3a257..000000000000
--- a/include/linux/spi/dw_spi.h
+++ /dev/null
@@ -1,219 +0,0 @@
1#ifndef DW_SPI_HEADER_H
2#define DW_SPI_HEADER_H
3#include <linux/io.h>
4
5/* Bit fields in CTRLR0 */
6#define SPI_DFS_OFFSET 0
7
8#define SPI_FRF_OFFSET 4
9#define SPI_FRF_SPI 0x0
10#define SPI_FRF_SSP 0x1
11#define SPI_FRF_MICROWIRE 0x2
12#define SPI_FRF_RESV 0x3
13
14#define SPI_MODE_OFFSET 6
15#define SPI_SCPH_OFFSET 6
16#define SPI_SCOL_OFFSET 7
17
18#define SPI_TMOD_OFFSET 8
19#define SPI_TMOD_MASK (0x3 << SPI_TMOD_OFFSET)
20#define SPI_TMOD_TR 0x0 /* xmit & recv */
21#define SPI_TMOD_TO 0x1 /* xmit only */
22#define SPI_TMOD_RO 0x2 /* recv only */
23#define SPI_TMOD_EPROMREAD 0x3 /* eeprom read mode */
24
25#define SPI_SLVOE_OFFSET 10
26#define SPI_SRL_OFFSET 11
27#define SPI_CFS_OFFSET 12
28
29/* Bit fields in SR, 7 bits */
30#define SR_MASK 0x7f /* cover 7 bits */
31#define SR_BUSY (1 << 0)
32#define SR_TF_NOT_FULL (1 << 1)
33#define SR_TF_EMPT (1 << 2)
34#define SR_RF_NOT_EMPT (1 << 3)
35#define SR_RF_FULL (1 << 4)
36#define SR_TX_ERR (1 << 5)
37#define SR_DCOL (1 << 6)
38
39/* Bit fields in ISR, IMR, RISR, 7 bits */
40#define SPI_INT_TXEI (1 << 0)
41#define SPI_INT_TXOI (1 << 1)
42#define SPI_INT_RXUI (1 << 2)
43#define SPI_INT_RXOI (1 << 3)
44#define SPI_INT_RXFI (1 << 4)
45#define SPI_INT_MSTI (1 << 5)
46
47/* TX RX interrupt level threshhold, max can be 256 */
48#define SPI_INT_THRESHOLD 32
49
50enum dw_ssi_type {
51 SSI_MOTO_SPI = 0,
52 SSI_TI_SSP,
53 SSI_NS_MICROWIRE,
54};
55
56struct dw_spi_reg {
57 u32 ctrl0;
58 u32 ctrl1;
59 u32 ssienr;
60 u32 mwcr;
61 u32 ser;
62 u32 baudr;
63 u32 txfltr;
64 u32 rxfltr;
65 u32 txflr;
66 u32 rxflr;
67 u32 sr;
68 u32 imr;
69 u32 isr;
70 u32 risr;
71 u32 txoicr;
72 u32 rxoicr;
73 u32 rxuicr;
74 u32 msticr;
75 u32 icr;
76 u32 dmacr;
77 u32 dmatdlr;
78 u32 dmardlr;
79 u32 idr;
80 u32 version;
81 u32 dr; /* Currently oper as 32 bits,
82 though only low 16 bits matters */
83} __packed;
84
85struct dw_spi {
86 struct spi_master *master;
87 struct spi_device *cur_dev;
88 struct device *parent_dev;
89 enum dw_ssi_type type;
90
91 void __iomem *regs;
92 unsigned long paddr;
93 u32 iolen;
94 int irq;
95 u32 fifo_len; /* depth of the FIFO buffer */
96 u32 max_freq; /* max bus freq supported */
97
98 u16 bus_num;
99 u16 num_cs; /* supported slave numbers */
100
101 /* Driver message queue */
102 struct workqueue_struct *workqueue;
103 struct work_struct pump_messages;
104 spinlock_t lock;
105 struct list_head queue;
106 int busy;
107 int run;
108
109 /* Message Transfer pump */
110 struct tasklet_struct pump_transfers;
111
112 /* Current message transfer state info */
113 struct spi_message *cur_msg;
114 struct spi_transfer *cur_transfer;
115 struct chip_data *cur_chip;
116 struct chip_data *prev_chip;
117 size_t len;
118 void *tx;
119 void *tx_end;
120 void *rx;
121 void *rx_end;
122 int dma_mapped;
123 dma_addr_t rx_dma;
124 dma_addr_t tx_dma;
125 size_t rx_map_len;
126 size_t tx_map_len;
127 u8 n_bytes; /* current is a 1/2 bytes op */
128 u8 max_bits_per_word; /* maxim is 16b */
129 u32 dma_width;
130 int cs_change;
131 int (*write)(struct dw_spi *dws);
132 int (*read)(struct dw_spi *dws);
133 irqreturn_t (*transfer_handler)(struct dw_spi *dws);
134 void (*cs_control)(u32 command);
135
136 /* Dma info */
137 int dma_inited;
138 struct dma_chan *txchan;
139 struct dma_chan *rxchan;
140 int txdma_done;
141 int rxdma_done;
142 u64 tx_param;
143 u64 rx_param;
144 struct device *dma_dev;
145 dma_addr_t dma_addr;
146
147 /* Bus interface info */
148 void *priv;
149#ifdef CONFIG_DEBUG_FS
150 struct dentry *debugfs;
151#endif
152};
153
154#define dw_readl(dw, name) \
155 __raw_readl(&(((struct dw_spi_reg *)dw->regs)->name))
156#define dw_writel(dw, name, val) \
157 __raw_writel((val), &(((struct dw_spi_reg *)dw->regs)->name))
158#define dw_readw(dw, name) \
159 __raw_readw(&(((struct dw_spi_reg *)dw->regs)->name))
160#define dw_writew(dw, name, val) \
161 __raw_writew((val), &(((struct dw_spi_reg *)dw->regs)->name))
162
163static inline void spi_enable_chip(struct dw_spi *dws, int enable)
164{
165 dw_writel(dws, ssienr, (enable ? 1 : 0));
166}
167
168static inline void spi_set_clk(struct dw_spi *dws, u16 div)
169{
170 dw_writel(dws, baudr, div);
171}
172
173static inline void spi_chip_sel(struct dw_spi *dws, u16 cs)
174{
175 if (cs > dws->num_cs)
176 return;
177
178 if (dws->cs_control)
179 dws->cs_control(1);
180
181 dw_writel(dws, ser, 1 << cs);
182}
183
184/* Disable IRQ bits */
185static inline void spi_mask_intr(struct dw_spi *dws, u32 mask)
186{
187 u32 new_mask;
188
189 new_mask = dw_readl(dws, imr) & ~mask;
190 dw_writel(dws, imr, new_mask);
191}
192
193/* Enable IRQ bits */
194static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
195{
196 u32 new_mask;
197
198 new_mask = dw_readl(dws, imr) | mask;
199 dw_writel(dws, imr, new_mask);
200}
201
202/*
203 * Each SPI slave device to work with dw_api controller should
204 * has such a structure claiming its working mode (PIO/DMA etc),
205 * which can be save in the "controller_data" member of the
206 * struct spi_device
207 */
208struct dw_spi_chip {
209 u8 poll_mode; /* 0 for contoller polling mode */
210 u8 type; /* SPI/SSP/Micrwire */
211 u8 enable_dma;
212 void (*cs_control)(u32 command);
213};
214
215extern int dw_spi_add_host(struct dw_spi *dws);
216extern void dw_spi_remove_host(struct dw_spi *dws);
217extern int dw_spi_suspend_host(struct dw_spi *dws);
218extern int dw_spi_resume_host(struct dw_spi *dws);
219#endif /* DW_SPI_HEADER_H */
diff --git a/include/linux/spi/ifx_modem.h b/include/linux/spi/ifx_modem.h
new file mode 100644
index 000000000000..394fec9e7722
--- /dev/null
+++ b/include/linux/spi/ifx_modem.h
@@ -0,0 +1,19 @@
1#ifndef LINUX_IFX_MODEM_H
2#define LINUX_IFX_MODEM_H
3
4struct ifx_modem_platform_data {
5 unsigned short rst_out; /* modem reset out */
6 unsigned short pwr_on; /* power on */
7 unsigned short rst_pmu; /* reset modem */
8 unsigned short tx_pwr; /* modem power threshold */
9 unsigned short srdy; /* SRDY */
10 unsigned short mrdy; /* MRDY */
11 unsigned char modem_type; /* Modem type */
12 unsigned long max_hz; /* max SPI frequency */
13 unsigned short use_dma:1; /* spi protocol driver supplies
14 dma-able addrs */
15};
16#define IFX_MODEM_6160 1
17#define IFX_MODEM_6260 2
18
19#endif
diff --git a/include/linux/spi/mcp23s08.h b/include/linux/spi/mcp23s08.h
index 22ef107d7704..c42cff8ca191 100644
--- a/include/linux/spi/mcp23s08.h
+++ b/include/linux/spi/mcp23s08.h
@@ -2,21 +2,24 @@
2/* FIXME driver should be able to handle IRQs... */ 2/* FIXME driver should be able to handle IRQs... */
3 3
4struct mcp23s08_chip_info { 4struct mcp23s08_chip_info {
5 bool is_present; /* true iff populated */ 5 bool is_present; /* true if populated */
6 u8 pullups; /* BIT(x) means enable pullup x */ 6 unsigned pullups; /* BIT(x) means enable pullup x */
7}; 7};
8 8
9struct mcp23s08_platform_data { 9struct mcp23s08_platform_data {
10 /* Four slaves (numbered 0..3) can share one SPI chipselect, and 10 /* For mcp23s08, up to 4 slaves (numbered 0..3) can share one SPI
11 * will provide 8..32 GPIOs using 1..4 gpio_chip instances. 11 * chipselect, each providing 1 gpio_chip instance with 8 gpios.
12 * For mpc23s17, up to 8 slaves (numbered 0..7) can share one SPI
13 * chipselect, each providing 1 gpio_chip (port A + port B) with
14 * 16 gpios.
12 */ 15 */
13 struct mcp23s08_chip_info chip[4]; 16 struct mcp23s08_chip_info chip[8];
14 17
15 /* "base" is the number of the first GPIO. Dynamic assignment is 18 /* "base" is the number of the first GPIO. Dynamic assignment is
16 * not currently supported, and even if there are gaps in chip 19 * not currently supported, and even if there are gaps in chip
17 * addressing the GPIO numbers are sequential .. so for example 20 * addressing the GPIO numbers are sequential .. so for example
18 * if only slaves 0 and 3 are present, their GPIOs range from 21 * if only slaves 0 and 3 are present, their GPIOs range from
19 * base to base+15. 22 * base to base+15 (or base+31 for s17 variant).
20 */ 23 */
21 unsigned base; 24 unsigned base;
22 25
diff --git a/include/linux/spi/pxa2xx_spi.h b/include/linux/spi/pxa2xx_spi.h
new file mode 100644
index 000000000000..d3e1075f7b60
--- /dev/null
+++ b/include/linux/spi/pxa2xx_spi.h
@@ -0,0 +1,152 @@
1/*
2 * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18#ifndef __linux_pxa2xx_spi_h
19#define __linux_pxa2xx_spi_h
20
21#include <linux/pxa2xx_ssp.h>
22
23#define PXA2XX_CS_ASSERT (0x01)
24#define PXA2XX_CS_DEASSERT (0x02)
25
26/* device.platform_data for SSP controller devices */
27struct pxa2xx_spi_master {
28 u32 clock_enable;
29 u16 num_chipselect;
30 u8 enable_dma;
31};
32
33/* spi_board_info.controller_data for SPI slave devices,
34 * copied to spi_device.platform_data ... mostly for dma tuning
35 */
36struct pxa2xx_spi_chip {
37 u8 tx_threshold;
38 u8 rx_threshold;
39 u8 dma_burst_size;
40 u32 timeout;
41 u8 enable_loopback;
42 int gpio_cs;
43 void (*cs_control)(u32 command);
44};
45
46#ifdef CONFIG_ARCH_PXA
47
48#include <linux/clk.h>
49#include <mach/dma.h>
50
51extern void pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info);
52
53#else
54/*
55 * This is the implemtation for CE4100 on x86. ARM defines them in mach/ or
56 * plat/ include path.
57 * The CE4100 does not provide DMA support. This bits are here to let the driver
58 * compile and will never be used. Maybe we get DMA support at a later point in
59 * time.
60 */
61
62#define DCSR(n) (n)
63#define DSADR(n) (n)
64#define DTADR(n) (n)
65#define DCMD(n) (n)
66#define DRCMR(n) (n)
67
68#define DCSR_RUN (1 << 31) /* Run Bit */
69#define DCSR_NODESC (1 << 30) /* No-Descriptor Fetch */
70#define DCSR_STOPIRQEN (1 << 29) /* Stop Interrupt Enable */
71#define DCSR_REQPEND (1 << 8) /* Request Pending (read-only) */
72#define DCSR_STOPSTATE (1 << 3) /* Stop State (read-only) */
73#define DCSR_ENDINTR (1 << 2) /* End Interrupt */
74#define DCSR_STARTINTR (1 << 1) /* Start Interrupt */
75#define DCSR_BUSERR (1 << 0) /* Bus Error Interrupt */
76
77#define DCSR_EORIRQEN (1 << 28) /* End of Receive Interrupt Enable */
78#define DCSR_EORJMPEN (1 << 27) /* Jump to next descriptor on EOR */
79#define DCSR_EORSTOPEN (1 << 26) /* STOP on an EOR */
80#define DCSR_SETCMPST (1 << 25) /* Set Descriptor Compare Status */
81#define DCSR_CLRCMPST (1 << 24) /* Clear Descriptor Compare Status */
82#define DCSR_CMPST (1 << 10) /* The Descriptor Compare Status */
83#define DCSR_EORINTR (1 << 9) /* The end of Receive */
84
85#define DRCMR_MAPVLD (1 << 7) /* Map Valid */
86#define DRCMR_CHLNUM 0x1f /* mask for Channel Number */
87
88#define DDADR_DESCADDR 0xfffffff0 /* Address of next descriptor */
89#define DDADR_STOP (1 << 0) /* Stop */
90
91#define DCMD_INCSRCADDR (1 << 31) /* Source Address Increment Setting. */
92#define DCMD_INCTRGADDR (1 << 30) /* Target Address Increment Setting. */
93#define DCMD_FLOWSRC (1 << 29) /* Flow Control by the source. */
94#define DCMD_FLOWTRG (1 << 28) /* Flow Control by the target. */
95#define DCMD_STARTIRQEN (1 << 22) /* Start Interrupt Enable */
96#define DCMD_ENDIRQEN (1 << 21) /* End Interrupt Enable */
97#define DCMD_ENDIAN (1 << 18) /* Device Endian-ness. */
98#define DCMD_BURST8 (1 << 16) /* 8 byte burst */
99#define DCMD_BURST16 (2 << 16) /* 16 byte burst */
100#define DCMD_BURST32 (3 << 16) /* 32 byte burst */
101#define DCMD_WIDTH1 (1 << 14) /* 1 byte width */
102#define DCMD_WIDTH2 (2 << 14) /* 2 byte width (HalfWord) */
103#define DCMD_WIDTH4 (3 << 14) /* 4 byte width (Word) */
104#define DCMD_LENGTH 0x01fff /* length mask (max = 8K - 1) */
105
106/*
107 * Descriptor structure for PXA's DMA engine
108 * Note: this structure must always be aligned to a 16-byte boundary.
109 */
110
111typedef enum {
112 DMA_PRIO_HIGH = 0,
113 DMA_PRIO_MEDIUM = 1,
114 DMA_PRIO_LOW = 2
115} pxa_dma_prio;
116
117/*
118 * DMA registration
119 */
120
121static inline int pxa_request_dma(char *name,
122 pxa_dma_prio prio,
123 void (*irq_handler)(int, void *),
124 void *data)
125{
126 return -ENODEV;
127}
128
129static inline void pxa_free_dma(int dma_ch)
130{
131}
132
133/*
134 * The CE4100 does not have the clk framework implemented and SPI clock can
135 * not be switched on/off or the divider changed.
136 */
137static inline void clk_disable(struct clk *clk)
138{
139}
140
141static inline int clk_enable(struct clk *clk)
142{
143 return 0;
144}
145
146static inline unsigned long clk_get_rate(struct clk *clk)
147{
148 return 3686400;
149}
150
151#endif
152#endif
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 92e52a1e6af3..bb4f5fbbbd8e 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -204,6 +204,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
204/** 204/**
205 * struct spi_master - interface to SPI master controller 205 * struct spi_master - interface to SPI master controller
206 * @dev: device interface to this driver 206 * @dev: device interface to this driver
207 * @list: link with the global spi_master list
207 * @bus_num: board-specific (and often SOC-specific) identifier for a 208 * @bus_num: board-specific (and often SOC-specific) identifier for a
208 * given SPI controller. 209 * given SPI controller.
209 * @num_chipselect: chipselects are used to distinguish individual 210 * @num_chipselect: chipselects are used to distinguish individual
@@ -238,6 +239,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
238struct spi_master { 239struct spi_master {
239 struct device dev; 240 struct device dev;
240 241
242 struct list_head list;
243
241 /* other than negative (== assign one dynamically), bus_num is fully 244 /* other than negative (== assign one dynamically), bus_num is fully
242 * board-specific. usually that simplifies to being SOC-specific. 245 * board-specific. usually that simplifies to being SOC-specific.
243 * example: one SOC has three SPI controllers, numbered 0..2, 246 * example: one SOC has three SPI controllers, numbered 0..2,
@@ -578,7 +581,7 @@ extern int spi_bus_unlock(struct spi_master *master);
578 * Callable only from contexts that can sleep. 581 * Callable only from contexts that can sleep.
579 */ 582 */
580static inline int 583static inline int
581spi_write(struct spi_device *spi, const u8 *buf, size_t len) 584spi_write(struct spi_device *spi, const void *buf, size_t len)
582{ 585{
583 struct spi_transfer t = { 586 struct spi_transfer t = {
584 .tx_buf = buf, 587 .tx_buf = buf,
@@ -602,7 +605,7 @@ spi_write(struct spi_device *spi, const u8 *buf, size_t len)
602 * Callable only from contexts that can sleep. 605 * Callable only from contexts that can sleep.
603 */ 606 */
604static inline int 607static inline int
605spi_read(struct spi_device *spi, u8 *buf, size_t len) 608spi_read(struct spi_device *spi, void *buf, size_t len)
606{ 609{
607 struct spi_transfer t = { 610 struct spi_transfer t = {
608 .rx_buf = buf, 611 .rx_buf = buf,
@@ -617,8 +620,8 @@ spi_read(struct spi_device *spi, u8 *buf, size_t len)
617 620
618/* this copies txbuf and rxbuf data; for small transfers only! */ 621/* this copies txbuf and rxbuf data; for small transfers only! */
619extern int spi_write_then_read(struct spi_device *spi, 622extern int spi_write_then_read(struct spi_device *spi,
620 const u8 *txbuf, unsigned n_tx, 623 const void *txbuf, unsigned n_tx,
621 u8 *rxbuf, unsigned n_rx); 624 void *rxbuf, unsigned n_rx);
622 625
623/** 626/**
624 * spi_w8r8 - SPI synchronous 8 bit write followed by 8 bit read 627 * spi_w8r8 - SPI synchronous 8 bit write followed by 8 bit read
diff --git a/include/linux/spi/spi_oc_tiny.h b/include/linux/spi/spi_oc_tiny.h
new file mode 100644
index 000000000000..1ac529cf4f06
--- /dev/null
+++ b/include/linux/spi/spi_oc_tiny.h
@@ -0,0 +1,20 @@
1#ifndef _LINUX_SPI_SPI_OC_TINY_H
2#define _LINUX_SPI_SPI_OC_TINY_H
3
4/**
5 * struct tiny_spi_platform_data - platform data of the OpenCores tiny SPI
6 * @freq: input clock freq to the core.
7 * @baudwidth: baud rate divider width of the core.
8 * @gpio_cs_count: number of gpio pins used for chipselect.
9 * @gpio_cs: array of gpio pins used for chipselect.
10 *
11 * freq and baudwidth are used only if the divider is programmable.
12 */
13struct tiny_spi_platform_data {
14 unsigned int freq;
15 unsigned int baudwidth;
16 unsigned int gpio_cs_count;
17 int *gpio_cs;
18};
19
20#endif /* _LINUX_SPI_SPI_OC_TINY_H */
diff --git a/include/linux/spi/spidev.h b/include/linux/spi/spidev.h
index bf0570a84f7a..52d9ed01855f 100644
--- a/include/linux/spi/spidev.h
+++ b/include/linux/spi/spidev.h
@@ -66,7 +66,7 @@
66 * are in a different address space (and may be of different sizes in some 66 * are in a different address space (and may be of different sizes in some
67 * cases, such as 32-bit i386 userspace over a 64-bit x86_64 kernel). 67 * cases, such as 32-bit i386 userspace over a 64-bit x86_64 kernel).
68 * Zero-initialize the structure, including currently unused fields, to 68 * Zero-initialize the structure, including currently unused fields, to
69 * accomodate potential future updates. 69 * accommodate potential future updates.
70 * 70 *
71 * SPI_IOC_MESSAGE gives userspace the equivalent of kernel spi_sync(). 71 * SPI_IOC_MESSAGE gives userspace the equivalent of kernel spi_sync().
72 * Pass it an array of related transfers, they'll execute together. 72 * Pass it an array of related transfers, they'll execute together.
diff --git a/include/linux/spi/tsc2005.h b/include/linux/spi/tsc2005.h
new file mode 100644
index 000000000000..d9b0c84220c7
--- /dev/null
+++ b/include/linux/spi/tsc2005.h
@@ -0,0 +1,41 @@
1/*
2 * This file is part of TSC2005 touchscreen driver
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation
5 *
6 * Contact: Aaro Koskinen <aaro.koskinen@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifndef _LINUX_SPI_TSC2005_H
25#define _LINUX_SPI_TSC2005_H
26
27#include <linux/types.h>
28
29struct tsc2005_platform_data {
30 int ts_pressure_max;
31 int ts_pressure_fudge;
32 int ts_x_max;
33 int ts_x_fudge;
34 int ts_y_max;
35 int ts_y_fudge;
36 int ts_x_plate_ohm;
37 unsigned int esd_timeout_ms;
38 void (*set_reset)(bool enable);
39};
40
41#endif
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index f8854655860e..0b22d51258e6 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -50,6 +50,7 @@
50#include <linux/preempt.h> 50#include <linux/preempt.h>
51#include <linux/linkage.h> 51#include <linux/linkage.h>
52#include <linux/compiler.h> 52#include <linux/compiler.h>
53#include <linux/irqflags.h>
53#include <linux/thread_info.h> 54#include <linux/thread_info.h>
54#include <linux/kernel.h> 55#include <linux/kernel.h>
55#include <linux/stringify.h> 56#include <linux/stringify.h>
@@ -80,7 +81,7 @@
80#include <linux/spinlock_types.h> 81#include <linux/spinlock_types.h>
81 82
82/* 83/*
83 * Pull the arch_spin*() functions/declarations (UP-nondebug doesnt need them): 84 * Pull the arch_spin*() functions/declarations (UP-nondebug doesn't need them):
84 */ 85 */
85#ifdef CONFIG_SMP 86#ifdef CONFIG_SMP
86# include <asm/spinlock.h> 87# include <asm/spinlock.h>
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h
index 851b7783720d..73548eb13a5d 100644
--- a/include/linux/spinlock_types.h
+++ b/include/linux/spinlock_types.h
@@ -81,14 +81,6 @@ typedef struct spinlock {
81#define __SPIN_LOCK_UNLOCKED(lockname) \ 81#define __SPIN_LOCK_UNLOCKED(lockname) \
82 (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname) 82 (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname)
83 83
84/*
85 * SPIN_LOCK_UNLOCKED defeats lockdep state tracking and is hence
86 * deprecated.
87 * Please use DEFINE_SPINLOCK() or __SPIN_LOCK_UNLOCKED() as
88 * appropriate.
89 */
90#define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init)
91
92#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) 84#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
93 85
94#include <linux/rwlock_types.h> 86#include <linux/rwlock_types.h>
diff --git a/include/linux/spinlock_up.h b/include/linux/spinlock_up.h
index b14f6a91e19f..a26e2fb604e6 100644
--- a/include/linux/spinlock_up.h
+++ b/include/linux/spinlock_up.h
@@ -5,6 +5,8 @@
5# error "please don't include this file directly" 5# error "please don't include this file directly"
6#endif 6#endif
7 7
8#include <asm/processor.h> /* for cpu_relax() */
9
8/* 10/*
9 * include/linux/spinlock_up.h - UP-debug version of spinlocks. 11 * include/linux/spinlock_up.h - UP-debug version of spinlocks.
10 * 12 *
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 4d5d2f546dbf..58971e891f48 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -108,19 +108,43 @@ static inline int srcu_read_lock_held(struct srcu_struct *sp)
108#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ 108#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
109 109
110/** 110/**
111 * srcu_dereference - fetch SRCU-protected pointer with checking 111 * srcu_dereference_check - fetch SRCU-protected pointer for later dereferencing
112 * @p: the pointer to fetch and protect for later dereferencing
113 * @sp: pointer to the srcu_struct, which is used to check that we
114 * really are in an SRCU read-side critical section.
115 * @c: condition to check for update-side use
112 * 116 *
113 * Makes rcu_dereference_check() do the dirty work. 117 * If PROVE_RCU is enabled, invoking this outside of an RCU read-side
118 * critical section will result in an RCU-lockdep splat, unless @c evaluates
119 * to 1. The @c argument will normally be a logical expression containing
120 * lockdep_is_held() calls.
114 */ 121 */
115#define srcu_dereference(p, sp) \ 122#define srcu_dereference_check(p, sp, c) \
116 rcu_dereference_check(p, srcu_read_lock_held(sp)) 123 __rcu_dereference_check((p), srcu_read_lock_held(sp) || (c), __rcu)
124
125/**
126 * srcu_dereference - fetch SRCU-protected pointer for later dereferencing
127 * @p: the pointer to fetch and protect for later dereferencing
128 * @sp: pointer to the srcu_struct, which is used to check that we
129 * really are in an SRCU read-side critical section.
130 *
131 * Makes rcu_dereference_check() do the dirty work. If PROVE_RCU
132 * is enabled, invoking this outside of an RCU read-side critical
133 * section will result in an RCU-lockdep splat.
134 */
135#define srcu_dereference(p, sp) srcu_dereference_check((p), (sp), 0)
117 136
118/** 137/**
119 * srcu_read_lock - register a new reader for an SRCU-protected structure. 138 * srcu_read_lock - register a new reader for an SRCU-protected structure.
120 * @sp: srcu_struct in which to register the new reader. 139 * @sp: srcu_struct in which to register the new reader.
121 * 140 *
122 * Enter an SRCU read-side critical section. Note that SRCU read-side 141 * Enter an SRCU read-side critical section. Note that SRCU read-side
123 * critical sections may be nested. 142 * critical sections may be nested. However, it is illegal to
143 * call anything that waits on an SRCU grace period for the same
144 * srcu_struct, whether directly or indirectly. Please note that
145 * one way to indirectly wait on an SRCU grace period is to acquire
146 * a mutex that is held elsewhere while calling synchronize_srcu() or
147 * synchronize_srcu_expedited().
124 */ 148 */
125static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp) 149static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp)
126{ 150{
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index 623b704fdc42..252e44821787 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -55,6 +55,10 @@ struct ssb_sprom {
55 u8 tri5gl; /* 5.2GHz TX isolation */ 55 u8 tri5gl; /* 5.2GHz TX isolation */
56 u8 tri5g; /* 5.3GHz TX isolation */ 56 u8 tri5g; /* 5.3GHz TX isolation */
57 u8 tri5gh; /* 5.8GHz TX isolation */ 57 u8 tri5gh; /* 5.8GHz TX isolation */
58 u8 txpid2g[4]; /* 2GHz TX power index */
59 u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
60 u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
61 u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
58 u8 rxpo2g; /* 2GHz RX power offset */ 62 u8 rxpo2g; /* 2GHz RX power offset */
59 u8 rxpo5g; /* 5GHz RX power offset */ 63 u8 rxpo5g; /* 5GHz RX power offset */
60 u8 rssisav2g; /* 2GHz RSSI params */ 64 u8 rssisav2g; /* 2GHz RSSI params */
@@ -304,7 +308,7 @@ struct ssb_bus {
304 308
305 /* ID information about the Chip. */ 309 /* ID information about the Chip. */
306 u16 chip_id; 310 u16 chip_id;
307 u16 chip_rev; 311 u8 chip_rev;
308 u16 sprom_offset; 312 u16 sprom_offset;
309 u16 sprom_size; /* number of words in sprom */ 313 u16 sprom_size; /* number of words in sprom */
310 u8 chip_package; 314 u8 chip_package;
@@ -400,7 +404,9 @@ extern bool ssb_is_sprom_available(struct ssb_bus *bus);
400 404
401/* Set a fallback SPROM. 405/* Set a fallback SPROM.
402 * See kdoc at the function definition for complete documentation. */ 406 * See kdoc at the function definition for complete documentation. */
403extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom); 407extern int ssb_arch_register_fallback_sprom(
408 int (*sprom_callback)(struct ssb_bus *bus,
409 struct ssb_sprom *out));
404 410
405/* Suspend a SSB bus. 411/* Suspend a SSB bus.
406 * Call this from the parent bus suspend routine. */ 412 * Call this from the parent bus suspend routine. */
@@ -514,6 +520,7 @@ extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
514 * Otherwise static always-on powercontrol will be used. */ 520 * Otherwise static always-on powercontrol will be used. */
515extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl); 521extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
516 522
523extern void ssb_commit_settings(struct ssb_bus *bus);
517 524
518/* Various helper functions */ 525/* Various helper functions */
519extern u32 ssb_admatch_base(u32 adm); 526extern u32 ssb_admatch_base(u32 adm);
diff --git a/include/linux/ssb/ssb_driver_chipcommon.h b/include/linux/ssb/ssb_driver_chipcommon.h
index 2cdf249b4e5f..a08d693d8324 100644
--- a/include/linux/ssb/ssb_driver_chipcommon.h
+++ b/include/linux/ssb/ssb_driver_chipcommon.h
@@ -123,6 +123,8 @@
123#define SSB_CHIPCO_FLASHDATA 0x0048 123#define SSB_CHIPCO_FLASHDATA 0x0048
124#define SSB_CHIPCO_BCAST_ADDR 0x0050 124#define SSB_CHIPCO_BCAST_ADDR 0x0050
125#define SSB_CHIPCO_BCAST_DATA 0x0054 125#define SSB_CHIPCO_BCAST_DATA 0x0054
126#define SSB_CHIPCO_GPIOPULLUP 0x0058 /* Rev >= 20 only */
127#define SSB_CHIPCO_GPIOPULLDOWN 0x005C /* Rev >= 20 only */
126#define SSB_CHIPCO_GPIOIN 0x0060 128#define SSB_CHIPCO_GPIOIN 0x0060
127#define SSB_CHIPCO_GPIOOUT 0x0064 129#define SSB_CHIPCO_GPIOOUT 0x0064
128#define SSB_CHIPCO_GPIOOUTEN 0x0068 130#define SSB_CHIPCO_GPIOOUTEN 0x0068
@@ -131,6 +133,9 @@
131#define SSB_CHIPCO_GPIOIRQ 0x0074 133#define SSB_CHIPCO_GPIOIRQ 0x0074
132#define SSB_CHIPCO_WATCHDOG 0x0080 134#define SSB_CHIPCO_WATCHDOG 0x0080
133#define SSB_CHIPCO_GPIOTIMER 0x0088 /* LED powersave (corerev >= 16) */ 135#define SSB_CHIPCO_GPIOTIMER 0x0088 /* LED powersave (corerev >= 16) */
136#define SSB_CHIPCO_GPIOTIMER_OFFTIME 0x0000FFFF
137#define SSB_CHIPCO_GPIOTIMER_OFFTIME_SHIFT 0
138#define SSB_CHIPCO_GPIOTIMER_ONTIME 0xFFFF0000
134#define SSB_CHIPCO_GPIOTIMER_ONTIME_SHIFT 16 139#define SSB_CHIPCO_GPIOTIMER_ONTIME_SHIFT 16
135#define SSB_CHIPCO_GPIOTOUTM 0x008C /* LED powersave (corerev >= 16) */ 140#define SSB_CHIPCO_GPIOTOUTM 0x008C /* LED powersave (corerev >= 16) */
136#define SSB_CHIPCO_CLOCK_N 0x0090 141#define SSB_CHIPCO_CLOCK_N 0x0090
@@ -189,8 +194,10 @@
189#define SSB_CHIPCO_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */ 194#define SSB_CHIPCO_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
190#define SSB_CHIPCO_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */ 195#define SSB_CHIPCO_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
191#define SSB_CHIPCO_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */ 196#define SSB_CHIPCO_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
192#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00010000 /* HT available */ 197#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
193#define SSB_CHIPCO_CLKCTLST_HAVEALP 0x00020000 /* APL available */ 198#define SSB_CHIPCO_CLKCTLST_HAVEHT 0x00020000 /* HT available */
199#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
200#define SSB_CHIPCO_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
194#define SSB_CHIPCO_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */ 201#define SSB_CHIPCO_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
195#define SSB_CHIPCO_UART0_DATA 0x0300 202#define SSB_CHIPCO_UART0_DATA 0x0300
196#define SSB_CHIPCO_UART0_IMR 0x0304 203#define SSB_CHIPCO_UART0_IMR 0x0304
diff --git a/include/linux/ssb/ssb_driver_gige.h b/include/linux/ssb/ssb_driver_gige.h
index 942e38736901..eba52a100533 100644
--- a/include/linux/ssb/ssb_driver_gige.h
+++ b/include/linux/ssb/ssb_driver_gige.h
@@ -96,16 +96,21 @@ static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
96 return 0; 96 return 0;
97} 97}
98 98
99extern char * nvram_get(const char *name); 99#ifdef CONFIG_BCM47XX
100#include <asm/mach-bcm47xx/nvram.h>
100/* Get the device MAC address */ 101/* Get the device MAC address */
101static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr) 102static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
102{ 103{
103#ifdef CONFIG_BCM47XX 104 char buf[20];
104 char *res = nvram_get("et0macaddr"); 105 if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
105 if (res) 106 return;
106 memcpy(macaddr, res, 6); 107 nvram_parse_macaddr(buf, macaddr);
107#endif
108} 108}
109#else
110static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
111{
112}
113#endif
109 114
110extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev, 115extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
111 struct pci_dev *pdev); 116 struct pci_dev *pdev);
diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h
index a6d5225b9275..efbf459d571c 100644
--- a/include/linux/ssb/ssb_regs.h
+++ b/include/linux/ssb/ssb_regs.h
@@ -85,6 +85,8 @@
85#define SSB_IMSTATE_AP_RSV 0x00000030 /* Reserved */ 85#define SSB_IMSTATE_AP_RSV 0x00000030 /* Reserved */
86#define SSB_IMSTATE_IBE 0x00020000 /* In Band Error */ 86#define SSB_IMSTATE_IBE 0x00020000 /* In Band Error */
87#define SSB_IMSTATE_TO 0x00040000 /* Timeout */ 87#define SSB_IMSTATE_TO 0x00040000 /* Timeout */
88#define SSB_IMSTATE_BUSY 0x01800000 /* Busy (Backplane rev >= 2.3 only) */
89#define SSB_IMSTATE_REJECT 0x02000000 /* Reject (Backplane rev >= 2.3 only) */
88#define SSB_INTVEC 0x0F94 /* SB Interrupt Mask */ 90#define SSB_INTVEC 0x0F94 /* SB Interrupt Mask */
89#define SSB_INTVEC_PCI 0x00000001 /* Enable interrupts for PCI */ 91#define SSB_INTVEC_PCI 0x00000001 /* Enable interrupts for PCI */
90#define SSB_INTVEC_ENET0 0x00000002 /* Enable interrupts for enet 0 */ 92#define SSB_INTVEC_ENET0 0x00000002 /* Enable interrupts for enet 0 */
@@ -95,7 +97,7 @@
95#define SSB_INTVEC_ENET1 0x00000040 /* Enable interrupts for enet 1 */ 97#define SSB_INTVEC_ENET1 0x00000040 /* Enable interrupts for enet 1 */
96#define SSB_TMSLOW 0x0F98 /* SB Target State Low */ 98#define SSB_TMSLOW 0x0F98 /* SB Target State Low */
97#define SSB_TMSLOW_RESET 0x00000001 /* Reset */ 99#define SSB_TMSLOW_RESET 0x00000001 /* Reset */
98#define SSB_TMSLOW_REJECT_22 0x00000002 /* Reject (Backplane rev 2.2) */ 100#define SSB_TMSLOW_REJECT 0x00000002 /* Reject (Standard Backplane) */
99#define SSB_TMSLOW_REJECT_23 0x00000004 /* Reject (Backplane rev 2.3) */ 101#define SSB_TMSLOW_REJECT_23 0x00000004 /* Reject (Backplane rev 2.3) */
100#define SSB_TMSLOW_CLOCK 0x00010000 /* Clock Enable */ 102#define SSB_TMSLOW_CLOCK 0x00010000 /* Clock Enable */
101#define SSB_TMSLOW_FGC 0x00020000 /* Force Gated Clocks On */ 103#define SSB_TMSLOW_FGC 0x00020000 /* Force Gated Clocks On */
@@ -267,6 +269,8 @@
267/* SPROM Revision 4 */ 269/* SPROM Revision 4 */
268#define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */ 270#define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */
269#define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */ 271#define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */
272#define SSB_SPROM4_BFL2LO 0x0048 /* Board flags 2 (low 16 bits) */
273#define SSB_SPROM4_BFL2HI 0x004A /* Board flags 2 Hi */
270#define SSB_SPROM4_IL0MAC 0x004C /* 6 byte MAC address for a/b/g/n */ 274#define SSB_SPROM4_IL0MAC 0x004C /* 6 byte MAC address for a/b/g/n */
271#define SSB_SPROM4_CCODE 0x0052 /* Country Code (2 bytes) */ 275#define SSB_SPROM4_CCODE 0x0052 /* Country Code (2 bytes) */
272#define SSB_SPROM4_GPIOA 0x0056 /* Gen. Purpose IO # 0 and 1 */ 276#define SSB_SPROM4_GPIOA 0x0056 /* Gen. Purpose IO # 0 and 1 */
@@ -298,6 +302,46 @@
298#define SSB_SPROM4_AGAIN2_SHIFT 0 302#define SSB_SPROM4_AGAIN2_SHIFT 0
299#define SSB_SPROM4_AGAIN3 0xFF00 /* Antenna 3 */ 303#define SSB_SPROM4_AGAIN3 0xFF00 /* Antenna 3 */
300#define SSB_SPROM4_AGAIN3_SHIFT 8 304#define SSB_SPROM4_AGAIN3_SHIFT 8
305#define SSB_SPROM4_TXPID2G01 0x0062 /* TX Power Index 2GHz */
306#define SSB_SPROM4_TXPID2G0 0x00FF
307#define SSB_SPROM4_TXPID2G0_SHIFT 0
308#define SSB_SPROM4_TXPID2G1 0xFF00
309#define SSB_SPROM4_TXPID2G1_SHIFT 8
310#define SSB_SPROM4_TXPID2G23 0x0064 /* TX Power Index 2GHz */
311#define SSB_SPROM4_TXPID2G2 0x00FF
312#define SSB_SPROM4_TXPID2G2_SHIFT 0
313#define SSB_SPROM4_TXPID2G3 0xFF00
314#define SSB_SPROM4_TXPID2G3_SHIFT 8
315#define SSB_SPROM4_TXPID5G01 0x0066 /* TX Power Index 5GHz middle subband */
316#define SSB_SPROM4_TXPID5G0 0x00FF
317#define SSB_SPROM4_TXPID5G0_SHIFT 0
318#define SSB_SPROM4_TXPID5G1 0xFF00
319#define SSB_SPROM4_TXPID5G1_SHIFT 8
320#define SSB_SPROM4_TXPID5G23 0x0068 /* TX Power Index 5GHz middle subband */
321#define SSB_SPROM4_TXPID5G2 0x00FF
322#define SSB_SPROM4_TXPID5G2_SHIFT 0
323#define SSB_SPROM4_TXPID5G3 0xFF00
324#define SSB_SPROM4_TXPID5G3_SHIFT 8
325#define SSB_SPROM4_TXPID5GL01 0x006A /* TX Power Index 5GHz low subband */
326#define SSB_SPROM4_TXPID5GL0 0x00FF
327#define SSB_SPROM4_TXPID5GL0_SHIFT 0
328#define SSB_SPROM4_TXPID5GL1 0xFF00
329#define SSB_SPROM4_TXPID5GL1_SHIFT 8
330#define SSB_SPROM4_TXPID5GL23 0x006C /* TX Power Index 5GHz low subband */
331#define SSB_SPROM4_TXPID5GL2 0x00FF
332#define SSB_SPROM4_TXPID5GL2_SHIFT 0
333#define SSB_SPROM4_TXPID5GL3 0xFF00
334#define SSB_SPROM4_TXPID5GL3_SHIFT 8
335#define SSB_SPROM4_TXPID5GH01 0x006E /* TX Power Index 5GHz high subband */
336#define SSB_SPROM4_TXPID5GH0 0x00FF
337#define SSB_SPROM4_TXPID5GH0_SHIFT 0
338#define SSB_SPROM4_TXPID5GH1 0xFF00
339#define SSB_SPROM4_TXPID5GH1_SHIFT 8
340#define SSB_SPROM4_TXPID5GH23 0x0070 /* TX Power Index 5GHz high subband */
341#define SSB_SPROM4_TXPID5GH2 0x00FF
342#define SSB_SPROM4_TXPID5GH2_SHIFT 0
343#define SSB_SPROM4_TXPID5GH3 0xFF00
344#define SSB_SPROM4_TXPID5GH3_SHIFT 8
301#define SSB_SPROM4_MAXP_BG 0x0080 /* Max Power BG in path 1 */ 345#define SSB_SPROM4_MAXP_BG 0x0080 /* Max Power BG in path 1 */
302#define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */ 346#define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */
303#define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */ 347#define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
@@ -317,6 +361,8 @@
317#define SSB_SPROM5_CCODE 0x0044 /* Country Code (2 bytes) */ 361#define SSB_SPROM5_CCODE 0x0044 /* Country Code (2 bytes) */
318#define SSB_SPROM5_BFLLO 0x004A /* Boardflags (low 16 bits) */ 362#define SSB_SPROM5_BFLLO 0x004A /* Boardflags (low 16 bits) */
319#define SSB_SPROM5_BFLHI 0x004C /* Board Flags Hi */ 363#define SSB_SPROM5_BFLHI 0x004C /* Board Flags Hi */
364#define SSB_SPROM5_BFL2LO 0x004E /* Board flags 2 (low 16 bits) */
365#define SSB_SPROM5_BFL2HI 0x0050 /* Board flags 2 Hi */
320#define SSB_SPROM5_IL0MAC 0x0052 /* 6 byte MAC address for a/b/g/n */ 366#define SSB_SPROM5_IL0MAC 0x0052 /* 6 byte MAC address for a/b/g/n */
321#define SSB_SPROM5_GPIOA 0x0076 /* Gen. Purpose IO # 0 and 1 */ 367#define SSB_SPROM5_GPIOA 0x0076 /* Gen. Purpose IO # 0 and 1 */
322#define SSB_SPROM5_GPIOA_P0 0x00FF /* Pin 0 */ 368#define SSB_SPROM5_GPIOA_P0 0x00FF /* Pin 0 */
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 51efbef38fb0..25310f1d7f37 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -2,6 +2,7 @@
2#define __LINUX_STACKTRACE_H 2#define __LINUX_STACKTRACE_H
3 3
4struct task_struct; 4struct task_struct;
5struct pt_regs;
5 6
6#ifdef CONFIG_STACKTRACE 7#ifdef CONFIG_STACKTRACE
7struct task_struct; 8struct task_struct;
@@ -13,7 +14,8 @@ struct stack_trace {
13}; 14};
14 15
15extern void save_stack_trace(struct stack_trace *trace); 16extern void save_stack_trace(struct stack_trace *trace);
16extern void save_stack_trace_bp(struct stack_trace *trace, unsigned long bp); 17extern void save_stack_trace_regs(struct stack_trace *trace,
18 struct pt_regs *regs);
17extern void save_stack_trace_tsk(struct task_struct *tsk, 19extern void save_stack_trace_tsk(struct task_struct *tsk,
18 struct stack_trace *trace); 20 struct stack_trace *trace);
19 21
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 632ff7c03280..9529e49b0385 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -26,19 +26,25 @@
26#ifndef __STMMAC_PLATFORM_DATA 26#ifndef __STMMAC_PLATFORM_DATA
27#define __STMMAC_PLATFORM_DATA 27#define __STMMAC_PLATFORM_DATA
28 28
29/* platfrom data for platfrom device structure's platfrom_data field */ 29#include <linux/platform_device.h>
30
31/* platform data for platform device structure's platform_data field */
30 32
31/* Private data for the STM on-board ethernet driver */ 33/* Private data for the STM on-board ethernet driver */
32struct plat_stmmacenet_data { 34struct plat_stmmacenet_data {
33 int bus_id; 35 int bus_id;
34 int pbl; 36 int pbl;
37 int clk_csr;
35 int has_gmac; 38 int has_gmac;
36 int enh_desc; 39 int enh_desc;
40 int tx_coe;
41 int bugged_jumbo;
42 int pmt;
37 void (*fix_mac_speed)(void *priv, unsigned int speed); 43 void (*fix_mac_speed)(void *priv, unsigned int speed);
38 void (*bus_setup)(unsigned long ioaddr); 44 void (*bus_setup)(void __iomem *ioaddr);
39#ifdef CONFIG_STM_DRIVERS 45 int (*init)(struct platform_device *pdev);
40 struct stm_pad_config *pad_config; 46 void (*exit)(struct platform_device *pdev);
41#endif 47 void *custom_cfg;
42 void *bsp_priv; 48 void *bsp_priv;
43}; 49};
44 50
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index 6b524a0d02e4..092dc9b1ce7d 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -105,7 +105,7 @@ static inline int try_stop_cpus(const struct cpumask *cpumask,
105 * @cpus: the cpus to run the @fn() on (NULL = any online cpu) 105 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
106 * 106 *
107 * Description: This causes a thread to be scheduled on every cpu, 107 * Description: This causes a thread to be scheduled on every cpu,
108 * each of which disables interrupts. The result is that noone is 108 * each of which disables interrupts. The result is that no one is
109 * holding a spinlock or inside any other preempt-disabled region when 109 * holding a spinlock or inside any other preempt-disabled region when
110 * @fn() runs. 110 * @fn() runs.
111 * 111 *
@@ -126,8 +126,8 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus);
126 126
127#else /* CONFIG_STOP_MACHINE && CONFIG_SMP */ 127#else /* CONFIG_STOP_MACHINE && CONFIG_SMP */
128 128
129static inline int stop_machine(int (*fn)(void *), void *data, 129static inline int __stop_machine(int (*fn)(void *), void *data,
130 const struct cpumask *cpus) 130 const struct cpumask *cpus)
131{ 131{
132 int ret; 132 int ret;
133 local_irq_disable(); 133 local_irq_disable();
@@ -136,5 +136,11 @@ static inline int stop_machine(int (*fn)(void *), void *data,
136 return ret; 136 return ret;
137} 137}
138 138
139static inline int stop_machine(int (*fn)(void *), void *data,
140 const struct cpumask *cpus)
141{
142 return __stop_machine(fn, data, cpus);
143}
144
139#endif /* CONFIG_STOP_MACHINE && CONFIG_SMP */ 145#endif /* CONFIG_STOP_MACHINE && CONFIG_SMP */
140#endif /* _LINUX_STOP_MACHINE */ 146#endif /* _LINUX_STOP_MACHINE */
diff --git a/include/linux/string.h b/include/linux/string.h
index a716ee2a8adb..a176db2f2c85 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -123,6 +123,7 @@ extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
123extern void argv_free(char **argv); 123extern void argv_free(char **argv);
124 124
125extern bool sysfs_streq(const char *s1, const char *s2); 125extern bool sysfs_streq(const char *s1, const char *s2);
126extern int strtobool(const char *s, bool *res);
126 127
127#ifdef CONFIG_BINARY_PRINTF 128#ifdef CONFIG_BINARY_PRINTF
128int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); 129int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index 5bbc447175dc..8521067ed4f7 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -110,9 +110,9 @@ struct rpc_credops {
110 __be32 * (*crmarshal)(struct rpc_task *, __be32 *); 110 __be32 * (*crmarshal)(struct rpc_task *, __be32 *);
111 int (*crrefresh)(struct rpc_task *); 111 int (*crrefresh)(struct rpc_task *);
112 __be32 * (*crvalidate)(struct rpc_task *, __be32 *); 112 __be32 * (*crvalidate)(struct rpc_task *, __be32 *);
113 int (*crwrap_req)(struct rpc_task *, kxdrproc_t, 113 int (*crwrap_req)(struct rpc_task *, kxdreproc_t,
114 void *, __be32 *, void *); 114 void *, __be32 *, void *);
115 int (*crunwrap_resp)(struct rpc_task *, kxdrproc_t, 115 int (*crunwrap_resp)(struct rpc_task *, kxdrdproc_t,
116 void *, __be32 *, void *); 116 void *, __be32 *, void *);
117}; 117};
118 118
@@ -122,8 +122,8 @@ extern const struct rpc_authops authnull_ops;
122int __init rpc_init_authunix(void); 122int __init rpc_init_authunix(void);
123int __init rpc_init_generic_auth(void); 123int __init rpc_init_generic_auth(void);
124int __init rpcauth_init_module(void); 124int __init rpcauth_init_module(void);
125void __exit rpcauth_remove_module(void); 125void rpcauth_remove_module(void);
126void __exit rpc_destroy_generic_auth(void); 126void rpc_destroy_generic_auth(void);
127void rpc_destroy_authunix(void); 127void rpc_destroy_authunix(void);
128 128
129struct rpc_cred * rpc_lookup_cred(void); 129struct rpc_cred * rpc_lookup_cred(void);
@@ -139,8 +139,8 @@ struct rpc_cred * rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *
139void put_rpccred(struct rpc_cred *); 139void put_rpccred(struct rpc_cred *);
140__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); 140__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *);
141__be32 * rpcauth_checkverf(struct rpc_task *, __be32 *); 141__be32 * rpcauth_checkverf(struct rpc_task *, __be32 *);
142int rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, __be32 *data, void *obj); 142int rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp, __be32 *data, void *obj);
143int rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, __be32 *data, void *obj); 143int rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp, __be32 *data, void *obj);
144int rpcauth_refreshcred(struct rpc_task *); 144int rpcauth_refreshcred(struct rpc_task *);
145void rpcauth_invalcred(struct rpc_task *); 145void rpcauth_invalcred(struct rpc_task *);
146int rpcauth_uptodatecred(struct rpc_task *); 146int rpcauth_uptodatecred(struct rpc_task *);
diff --git a/include/linux/sunrpc/auth_gss.h b/include/linux/sunrpc/auth_gss.h
index 671538d25bc1..8eee9dbbfe7a 100644
--- a/include/linux/sunrpc/auth_gss.h
+++ b/include/linux/sunrpc/auth_gss.h
@@ -69,7 +69,7 @@ struct gss_cl_ctx {
69 enum rpc_gss_proc gc_proc; 69 enum rpc_gss_proc gc_proc;
70 u32 gc_seq; 70 u32 gc_seq;
71 spinlock_t gc_seq_lock; 71 spinlock_t gc_seq_lock;
72 struct gss_ctx *gc_gss_ctx; 72 struct gss_ctx __rcu *gc_gss_ctx;
73 struct xdr_netobj gc_wire_ctx; 73 struct xdr_netobj gc_wire_ctx;
74 u32 gc_win; 74 u32 gc_win;
75 unsigned long gc_expiry; 75 unsigned long gc_expiry;
@@ -80,7 +80,7 @@ struct gss_upcall_msg;
80struct gss_cred { 80struct gss_cred {
81 struct rpc_cred gc_base; 81 struct rpc_cred gc_base;
82 enum rpc_gss_svc gc_service; 82 enum rpc_gss_svc gc_service;
83 struct gss_cl_ctx *gc_ctx; 83 struct gss_cl_ctx __rcu *gc_ctx;
84 struct gss_upcall_msg *gc_upcall; 84 struct gss_upcall_msg *gc_upcall;
85 unsigned long gc_upcall_timestamp; 85 unsigned long gc_upcall_timestamp;
86 unsigned char gc_machine_cred : 1; 86 unsigned char gc_machine_cred : 1;
diff --git a/include/linux/sunrpc/bc_xprt.h b/include/linux/sunrpc/bc_xprt.h
index 7c91260c44a9..082884295f80 100644
--- a/include/linux/sunrpc/bc_xprt.h
+++ b/include/linux/sunrpc/bc_xprt.h
@@ -43,7 +43,7 @@ int bc_send(struct rpc_rqst *req);
43 */ 43 */
44static inline int svc_is_backchannel(const struct svc_rqst *rqstp) 44static inline int svc_is_backchannel(const struct svc_rqst *rqstp)
45{ 45{
46 if (rqstp->rq_server->bc_xprt) 46 if (rqstp->rq_server->sv_bc_xprt)
47 return 1; 47 return 1;
48 return 0; 48 return 0;
49} 49}
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 7bf3e84b92f4..8d2eef1a8582 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -13,6 +13,7 @@
13#ifndef _LINUX_SUNRPC_CACHE_H_ 13#ifndef _LINUX_SUNRPC_CACHE_H_
14#define _LINUX_SUNRPC_CACHE_H_ 14#define _LINUX_SUNRPC_CACHE_H_
15 15
16#include <linux/kref.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <asm/atomic.h> 18#include <asm/atomic.h>
18#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
@@ -34,10 +35,10 @@
34 * Each cache must be registered so that it can be cleaned regularly. 35 * Each cache must be registered so that it can be cleaned regularly.
35 * When the cache is unregistered, it is flushed completely. 36 * When the cache is unregistered, it is flushed completely.
36 * 37 *
37 * Entries have a ref count and a 'hashed' flag which counts the existance 38 * Entries have a ref count and a 'hashed' flag which counts the existence
38 * in the hash table. 39 * in the hash table.
39 * We only expire entries when refcount is zero. 40 * We only expire entries when refcount is zero.
40 * Existance in the cache is counted the refcount. 41 * Existence in the cache is counted the refcount.
41 */ 42 */
42 43
43/* Every cache item has a common header that is used 44/* Every cache item has a common header that is used
@@ -125,12 +126,15 @@ struct cache_detail {
125 */ 126 */
126struct cache_req { 127struct cache_req {
127 struct cache_deferred_req *(*defer)(struct cache_req *req); 128 struct cache_deferred_req *(*defer)(struct cache_req *req);
129 int thread_wait; /* How long (jiffies) we can block the
130 * current thread to wait for updates.
131 */
128}; 132};
129/* this must be embedded in a deferred_request that is being 133/* this must be embedded in a deferred_request that is being
130 * delayed awaiting cache-fill 134 * delayed awaiting cache-fill
131 */ 135 */
132struct cache_deferred_req { 136struct cache_deferred_req {
133 struct list_head hash; /* on hash chain */ 137 struct hlist_node hash; /* on hash chain */
134 struct list_head recent; /* on fifo */ 138 struct list_head recent; /* on fifo */
135 struct cache_head *item; /* cache item we wait on */ 139 struct cache_head *item; /* cache item we wait on */
136 void *owner; /* we might need to discard all defered requests 140 void *owner; /* we might need to discard all defered requests
@@ -194,7 +198,9 @@ extern void cache_purge(struct cache_detail *detail);
194#define NEVER (0x7FFFFFFF) 198#define NEVER (0x7FFFFFFF)
195extern void __init cache_initialize(void); 199extern void __init cache_initialize(void);
196extern int cache_register(struct cache_detail *cd); 200extern int cache_register(struct cache_detail *cd);
201extern int cache_register_net(struct cache_detail *cd, struct net *net);
197extern void cache_unregister(struct cache_detail *cd); 202extern void cache_unregister(struct cache_detail *cd);
203extern void cache_unregister_net(struct cache_detail *cd, struct net *net);
198 204
199extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, 205extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
200 mode_t, struct cache_detail *); 206 mode_t, struct cache_detail *);
@@ -218,14 +224,45 @@ static inline int get_int(char **bpp, int *anint)
218 return 0; 224 return 0;
219} 225}
220 226
227/*
228 * timestamps kept in the cache are expressed in seconds
229 * since boot. This is the best for measuring differences in
230 * real time.
231 */
232static inline time_t seconds_since_boot(void)
233{
234 struct timespec boot;
235 getboottime(&boot);
236 return get_seconds() - boot.tv_sec;
237}
238
239static inline time_t convert_to_wallclock(time_t sinceboot)
240{
241 struct timespec boot;
242 getboottime(&boot);
243 return boot.tv_sec + sinceboot;
244}
245
221static inline time_t get_expiry(char **bpp) 246static inline time_t get_expiry(char **bpp)
222{ 247{
223 int rv; 248 int rv;
249 struct timespec boot;
250
224 if (get_int(bpp, &rv)) 251 if (get_int(bpp, &rv))
225 return 0; 252 return 0;
226 if (rv < 0) 253 if (rv < 0)
227 return 0; 254 return 0;
228 return rv; 255 getboottime(&boot);
256 return rv - boot.tv_sec;
257}
258
259#ifdef CONFIG_NFSD_DEPRECATED
260static inline void sunrpc_invalidate(struct cache_head *h,
261 struct cache_detail *detail)
262{
263 h->expiry_time = seconds_since_boot() - 1;
264 detail->nextcheck = seconds_since_boot();
229} 265}
266#endif /* CONFIG_NFSD_DEPRECATED */
230 267
231#endif /* _LINUX_SUNRPC_CACHE_H_ */ 268#endif /* _LINUX_SUNRPC_CACHE_H_ */
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 85f38a63f098..db7bcaf7c5bd 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -89,8 +89,8 @@ struct rpc_version {
89 */ 89 */
90struct rpc_procinfo { 90struct rpc_procinfo {
91 u32 p_proc; /* RPC procedure number */ 91 u32 p_proc; /* RPC procedure number */
92 kxdrproc_t p_encode; /* XDR encode function */ 92 kxdreproc_t p_encode; /* XDR encode function */
93 kxdrproc_t p_decode; /* XDR decode function */ 93 kxdrdproc_t p_decode; /* XDR decode function */
94 unsigned int p_arglen; /* argument hdr length (u32) */ 94 unsigned int p_arglen; /* argument hdr length (u32) */
95 unsigned int p_replen; /* reply hdr length (u32) */ 95 unsigned int p_replen; /* reply hdr length (u32) */
96 unsigned int p_count; /* call count */ 96 unsigned int p_count; /* call count */
@@ -102,6 +102,7 @@ struct rpc_procinfo {
102#ifdef __KERNEL__ 102#ifdef __KERNEL__
103 103
104struct rpc_create_args { 104struct rpc_create_args {
105 struct net *net;
105 int protocol; 106 int protocol;
106 struct sockaddr *address; 107 struct sockaddr *address;
107 size_t addrsize; 108 size_t addrsize;
@@ -128,6 +129,7 @@ struct rpc_create_args {
128struct rpc_clnt *rpc_create(struct rpc_create_args *args); 129struct rpc_clnt *rpc_create(struct rpc_create_args *args);
129struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, 130struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
130 struct rpc_program *, u32); 131 struct rpc_program *, u32);
132void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
131struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); 133struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
132void rpc_shutdown_client(struct rpc_clnt *); 134void rpc_shutdown_client(struct rpc_clnt *);
133void rpc_release_client(struct rpc_clnt *); 135void rpc_release_client(struct rpc_clnt *);
@@ -137,7 +139,6 @@ int rpcb_register(u32, u32, int, unsigned short);
137int rpcb_v4_register(const u32 program, const u32 version, 139int rpcb_v4_register(const u32 program, const u32 version,
138 const struct sockaddr *address, 140 const struct sockaddr *address,
139 const char *netid); 141 const char *netid);
140int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int);
141void rpcb_getport_async(struct rpc_task *); 142void rpcb_getport_async(struct rpc_task *);
142 143
143void rpc_call_start(struct rpc_task *); 144void rpc_call_start(struct rpc_task *);
diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h
index 5d8048beb051..332da61cf8b7 100644
--- a/include/linux/sunrpc/gss_api.h
+++ b/include/linux/sunrpc/gss_api.h
@@ -126,6 +126,9 @@ struct gss_api_mech *gss_mech_get_by_name(const char *);
126/* Similar, but get by pseudoflavor. */ 126/* Similar, but get by pseudoflavor. */
127struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32); 127struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
128 128
129/* Fill in an array with a list of supported pseudoflavors */
130int gss_mech_list_pseudoflavors(u32 *);
131
129/* Just increments the mechanism's reference count and returns its input: */ 132/* Just increments the mechanism's reference count and returns its input: */
130struct gss_api_mech * gss_mech_get(struct gss_api_mech *); 133struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
131 134
diff --git a/include/linux/sunrpc/gss_krb5_enctypes.h b/include/linux/sunrpc/gss_krb5_enctypes.h
new file mode 100644
index 000000000000..ec6234eee89c
--- /dev/null
+++ b/include/linux/sunrpc/gss_krb5_enctypes.h
@@ -0,0 +1,4 @@
1/*
2 * Dumb way to share this static piece of information with nfsd
3 */
4#define KRB5_SUPPORTED_ENCTYPES "18,17,16,23,3,1,2"
diff --git a/include/linux/sunrpc/gss_spkm3.h b/include/linux/sunrpc/gss_spkm3.h
deleted file mode 100644
index e3e6a3437f8b..000000000000
--- a/include/linux/sunrpc/gss_spkm3.h
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * linux/include/linux/sunrpc/gss_spkm3.h
3 *
4 * Copyright (c) 2000 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Andy Adamson <andros@umich.edu>
8 */
9
10#include <linux/sunrpc/auth_gss.h>
11#include <linux/sunrpc/gss_err.h>
12#include <linux/sunrpc/gss_asn1.h>
13
14struct spkm3_ctx {
15 struct xdr_netobj ctx_id; /* per message context id */
16 int endtime; /* endtime of the context */
17 struct xdr_netobj mech_used;
18 unsigned int ret_flags ;
19 struct xdr_netobj conf_alg;
20 struct xdr_netobj derived_conf_key;
21 struct xdr_netobj intg_alg;
22 struct xdr_netobj derived_integ_key;
23};
24
25/* OIDs declarations for K-ALG, I-ALG, C-ALG, and OWF-ALG */
26extern const struct xdr_netobj hmac_md5_oid;
27extern const struct xdr_netobj cast5_cbc_oid;
28
29/* SPKM InnerContext Token types */
30
31#define SPKM_ERROR_TOK 3
32#define SPKM_MIC_TOK 4
33#define SPKM_WRAP_TOK 5
34#define SPKM_DEL_TOK 6
35
36u32 spkm3_make_token(struct spkm3_ctx *ctx, struct xdr_buf * text, struct xdr_netobj * token, int toktype);
37
38u32 spkm3_read_token(struct spkm3_ctx *ctx, struct xdr_netobj *read_token, struct xdr_buf *message_buffer, int toktype);
39
40#define CKSUMTYPE_RSA_MD5 0x0007
41#define CKSUMTYPE_HMAC_MD5 0x0008
42
43s32 make_spkm3_checksum(s32 cksumtype, struct xdr_netobj *key, char *header,
44 unsigned int hdrlen, struct xdr_buf *body,
45 unsigned int body_offset, struct xdr_netobj *cksum);
46void asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits);
47int decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen,
48 int explen);
49void spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen,
50 unsigned char *ctxhdr, int elen, int zbit);
51void spkm3_make_mic_token(unsigned char **tokp, int toklen,
52 struct xdr_netobj *mic_hdr,
53 struct xdr_netobj *md5cksum, int md5elen, int md5zbit);
54u32 spkm3_verify_mic_token(unsigned char **tokp, int *mic_hdrlen,
55 unsigned char **cksum);
diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h
index 77e624883393..c68a147939a6 100644
--- a/include/linux/sunrpc/msg_prot.h
+++ b/include/linux/sunrpc/msg_prot.h
@@ -145,6 +145,7 @@ typedef __be32 rpc_fraghdr;
145#define RPCBIND_NETID_TCP "tcp" 145#define RPCBIND_NETID_TCP "tcp"
146#define RPCBIND_NETID_UDP6 "udp6" 146#define RPCBIND_NETID_UDP6 "udp6"
147#define RPCBIND_NETID_TCP6 "tcp6" 147#define RPCBIND_NETID_TCP6 "tcp6"
148#define RPCBIND_NETID_LOCAL "local"
148 149
149/* 150/*
150 * Note that RFC 1833 does not put any size restrictions on the 151 * Note that RFC 1833 does not put any size restrictions on the
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 88513fd8e208..fe2d8e6b923b 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -84,7 +84,8 @@ struct rpc_task {
84#endif 84#endif
85 unsigned char tk_priority : 2,/* Task priority */ 85 unsigned char tk_priority : 2,/* Task priority */
86 tk_garb_retry : 2, 86 tk_garb_retry : 2,
87 tk_cred_retry : 2; 87 tk_cred_retry : 2,
88 tk_rebind_retry : 2;
88}; 89};
89#define tk_xprt tk_client->cl_xprt 90#define tk_xprt tk_client->cl_xprt
90 91
@@ -127,13 +128,16 @@ struct rpc_task_setup {
127#define RPC_TASK_KILLED 0x0100 /* task was killed */ 128#define RPC_TASK_KILLED 0x0100 /* task was killed */
128#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */ 129#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */
129#define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */ 130#define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */
131#define RPC_TASK_SENT 0x0800 /* message was sent */
132#define RPC_TASK_TIMEOUT 0x1000 /* fail with ETIMEDOUT on timeout */
130 133
131#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) 134#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC)
132#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) 135#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER)
133#define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) 136#define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS)
134#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) 137#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED)
135#define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) 138#define RPC_IS_SOFT(t) ((t)->tk_flags & (RPC_TASK_SOFT|RPC_TASK_TIMEOUT))
136#define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN) 139#define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN)
140#define RPC_WAS_SENT(t) ((t)->tk_flags & RPC_TASK_SENT)
137 141
138#define RPC_TASK_RUNNING 0 142#define RPC_TASK_RUNNING 0
139#define RPC_TASK_QUEUED 1 143#define RPC_TASK_QUEUED 1
@@ -212,6 +216,7 @@ struct rpc_task *rpc_run_task(const struct rpc_task_setup *);
212struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req, 216struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
213 const struct rpc_call_ops *ops); 217 const struct rpc_call_ops *ops);
214void rpc_put_task(struct rpc_task *); 218void rpc_put_task(struct rpc_task *);
219void rpc_put_task_async(struct rpc_task *);
215void rpc_exit_task(struct rpc_task *); 220void rpc_exit_task(struct rpc_task *);
216void rpc_exit(struct rpc_task *, int); 221void rpc_exit(struct rpc_task *, int);
217void rpc_release_calldata(const struct rpc_call_ops *, void *); 222void rpc_release_calldata(const struct rpc_call_ops *, void *);
diff --git a/include/linux/sunrpc/stats.h b/include/linux/sunrpc/stats.h
index 5fa0f2084307..680471d1f28a 100644
--- a/include/linux/sunrpc/stats.h
+++ b/include/linux/sunrpc/stats.h
@@ -38,8 +38,21 @@ struct svc_stat {
38 rpcbadclnt; 38 rpcbadclnt;
39}; 39};
40 40
41void rpc_proc_init(void); 41struct net;
42void rpc_proc_exit(void); 42#ifdef CONFIG_PROC_FS
43int rpc_proc_init(struct net *);
44void rpc_proc_exit(struct net *);
45#else
46static inline int rpc_proc_init(struct net *net)
47{
48 return 0;
49}
50
51static inline void rpc_proc_exit(struct net *net)
52{
53}
54#endif
55
43#ifdef MODULE 56#ifdef MODULE
44void rpc_modcount(struct inode *, int); 57void rpc_modcount(struct inode *, int);
45#endif 58#endif
@@ -54,9 +67,6 @@ void svc_proc_unregister(const char *);
54 67
55void svc_seq_show(struct seq_file *, 68void svc_seq_show(struct seq_file *,
56 const struct svc_stat *); 69 const struct svc_stat *);
57
58extern struct proc_dir_entry *proc_net_rpc;
59
60#else 70#else
61 71
62static inline struct proc_dir_entry *rpc_proc_register(struct rpc_stat *s) { return NULL; } 72static inline struct proc_dir_entry *rpc_proc_register(struct rpc_stat *s) { return NULL; }
@@ -69,9 +79,6 @@ static inline void svc_proc_unregister(const char *p) {}
69 79
70static inline void svc_seq_show(struct seq_file *seq, 80static inline void svc_seq_show(struct seq_file *seq,
71 const struct svc_stat *st) {} 81 const struct svc_stat *st) {}
72
73#define proc_net_rpc NULL
74
75#endif 82#endif
76 83
77#endif /* _LINUX_SUNRPC_STATS_H */ 84#endif /* _LINUX_SUNRPC_STATS_H */
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 5a3085b9b394..ea29330b78bd 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -99,7 +99,7 @@ struct svc_serv {
99 spinlock_t sv_cb_lock; /* protects the svc_cb_list */ 99 spinlock_t sv_cb_lock; /* protects the svc_cb_list */
100 wait_queue_head_t sv_cb_waitq; /* sleep here if there are no 100 wait_queue_head_t sv_cb_waitq; /* sleep here if there are no
101 * entries in the svc_cb_list */ 101 * entries in the svc_cb_list */
102 struct svc_xprt *bc_xprt; 102 struct svc_xprt *sv_bc_xprt; /* callback on fore channel */
103#endif /* CONFIG_NFS_V4_1 */ 103#endif /* CONFIG_NFS_V4_1 */
104}; 104};
105 105
@@ -269,6 +269,7 @@ struct svc_rqst {
269 struct cache_req rq_chandle; /* handle passed to caches for 269 struct cache_req rq_chandle; /* handle passed to caches for
270 * request delaying 270 * request delaying
271 */ 271 */
272 bool rq_dropme;
272 /* Catering to nfsd */ 273 /* Catering to nfsd */
273 struct auth_domain * rq_client; /* RPC peer info */ 274 struct auth_domain * rq_client; /* RPC peer info */
274 struct auth_domain * rq_gssclient; /* "gss/"-style peer info */ 275 struct auth_domain * rq_gssclient; /* "gss/"-style peer info */
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
index 5f4e18b3ce73..7ad9751a0d87 100644
--- a/include/linux/sunrpc/svc_xprt.h
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -12,6 +12,7 @@
12 12
13struct svc_xprt_ops { 13struct svc_xprt_ops {
14 struct svc_xprt *(*xpo_create)(struct svc_serv *, 14 struct svc_xprt *(*xpo_create)(struct svc_serv *,
15 struct net *net,
15 struct sockaddr *, int, 16 struct sockaddr *, int,
16 int); 17 int);
17 struct svc_xprt *(*xpo_accept)(struct svc_xprt *); 18 struct svc_xprt *(*xpo_accept)(struct svc_xprt *);
@@ -32,6 +33,16 @@ struct svc_xprt_class {
32 u32 xcl_max_payload; 33 u32 xcl_max_payload;
33}; 34};
34 35
36/*
37 * This is embedded in an object that wants a callback before deleting
38 * an xprt; intended for use by NFSv4.1, which needs to know when a
39 * client's tcp connection (and hence possibly a backchannel) goes away.
40 */
41struct svc_xpt_user {
42 struct list_head list;
43 void (*callback)(struct svc_xpt_user *);
44};
45
35struct svc_xprt { 46struct svc_xprt {
36 struct svc_xprt_class *xpt_class; 47 struct svc_xprt_class *xpt_class;
37 struct svc_xprt_ops *xpt_ops; 48 struct svc_xprt_ops *xpt_ops;
@@ -52,7 +63,6 @@ struct svc_xprt {
52#define XPT_LISTENER 11 /* listening endpoint */ 63#define XPT_LISTENER 11 /* listening endpoint */
53#define XPT_CACHE_AUTH 12 /* cache auth info */ 64#define XPT_CACHE_AUTH 12 /* cache auth info */
54 65
55 struct svc_pool *xpt_pool; /* current pool iff queued */
56 struct svc_serv *xpt_server; /* service for transport */ 66 struct svc_serv *xpt_server; /* service for transport */
57 atomic_t xpt_reserved; /* space on outq that is rsvd */ 67 atomic_t xpt_reserved; /* space on outq that is rsvd */
58 struct mutex xpt_mutex; /* to serialize sending data */ 68 struct mutex xpt_mutex; /* to serialize sending data */
@@ -66,14 +76,42 @@ struct svc_xprt {
66 struct sockaddr_storage xpt_remote; /* remote peer's address */ 76 struct sockaddr_storage xpt_remote; /* remote peer's address */
67 size_t xpt_remotelen; /* length of address */ 77 size_t xpt_remotelen; /* length of address */
68 struct rpc_wait_queue xpt_bc_pending; /* backchannel wait queue */ 78 struct rpc_wait_queue xpt_bc_pending; /* backchannel wait queue */
79 struct list_head xpt_users; /* callbacks on free */
80
81 struct net *xpt_net;
82 struct rpc_xprt *xpt_bc_xprt; /* NFSv4.1 backchannel */
69}; 83};
70 84
85static inline void unregister_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
86{
87 spin_lock(&xpt->xpt_lock);
88 list_del_init(&u->list);
89 spin_unlock(&xpt->xpt_lock);
90}
91
92static inline int register_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
93{
94 spin_lock(&xpt->xpt_lock);
95 if (test_bit(XPT_CLOSE, &xpt->xpt_flags)) {
96 /*
97 * The connection is about to be deleted soon (or,
98 * worse, may already be deleted--in which case we've
99 * already notified the xpt_users).
100 */
101 spin_unlock(&xpt->xpt_lock);
102 return -ENOTCONN;
103 }
104 list_add(&u->list, &xpt->xpt_users);
105 spin_unlock(&xpt->xpt_lock);
106 return 0;
107}
108
71int svc_reg_xprt_class(struct svc_xprt_class *); 109int svc_reg_xprt_class(struct svc_xprt_class *);
72void svc_unreg_xprt_class(struct svc_xprt_class *); 110void svc_unreg_xprt_class(struct svc_xprt_class *);
73void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *, 111void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *,
74 struct svc_serv *); 112 struct svc_serv *);
75int svc_create_xprt(struct svc_serv *, const char *, const int, 113int svc_create_xprt(struct svc_serv *, const char *, struct net *,
76 const unsigned short, int); 114 const int, const unsigned short, int);
77void svc_xprt_enqueue(struct svc_xprt *xprt); 115void svc_xprt_enqueue(struct svc_xprt *xprt);
78void svc_xprt_received(struct svc_xprt *); 116void svc_xprt_received(struct svc_xprt *);
79void svc_xprt_put(struct svc_xprt *xprt); 117void svc_xprt_put(struct svc_xprt *xprt);
diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
index d39dbdc7b10f..25d333c1b571 100644
--- a/include/linux/sunrpc/svcauth.h
+++ b/include/linux/sunrpc/svcauth.h
@@ -108,10 +108,15 @@ struct auth_ops {
108#define SVC_NEGATIVE 4 108#define SVC_NEGATIVE 4
109#define SVC_OK 5 109#define SVC_OK 5
110#define SVC_DROP 6 110#define SVC_DROP 6
111#define SVC_DENIED 7 111#define SVC_CLOSE 7 /* Like SVC_DROP, but request is definitely
112#define SVC_PENDING 8 112 * lost so if there is a tcp connection, it
113#define SVC_COMPLETE 9 113 * should be closed
114 */
115#define SVC_DENIED 8
116#define SVC_PENDING 9
117#define SVC_COMPLETE 10
114 118
119struct svc_xprt;
115 120
116extern int svc_authenticate(struct svc_rqst *rqstp, __be32 *authp); 121extern int svc_authenticate(struct svc_rqst *rqstp, __be32 *authp);
117extern int svc_authorise(struct svc_rqst *rqstp); 122extern int svc_authorise(struct svc_rqst *rqstp);
@@ -121,13 +126,13 @@ extern void svc_auth_unregister(rpc_authflavor_t flavor);
121 126
122extern struct auth_domain *unix_domain_find(char *name); 127extern struct auth_domain *unix_domain_find(char *name);
123extern void auth_domain_put(struct auth_domain *item); 128extern void auth_domain_put(struct auth_domain *item);
124extern int auth_unix_add_addr(struct in6_addr *addr, struct auth_domain *dom); 129extern int auth_unix_add_addr(struct net *net, struct in6_addr *addr, struct auth_domain *dom);
125extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *new); 130extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *new);
126extern struct auth_domain *auth_domain_find(char *name); 131extern struct auth_domain *auth_domain_find(char *name);
127extern struct auth_domain *auth_unix_lookup(struct in6_addr *addr); 132extern struct auth_domain *auth_unix_lookup(struct net *net, struct in6_addr *addr);
128extern int auth_unix_forget_old(struct auth_domain *dom); 133extern int auth_unix_forget_old(struct auth_domain *dom);
129extern void svcauth_unix_purge(void); 134extern void svcauth_unix_purge(void);
130extern void svcauth_unix_info_release(void *); 135extern void svcauth_unix_info_release(struct svc_xprt *xpt);
131extern int svcauth_unix_set_client(struct svc_rqst *rqstp); 136extern int svcauth_unix_set_client(struct svc_rqst *rqstp);
132 137
133static inline unsigned long hash_str(char *name, int bits) 138static inline unsigned long hash_str(char *name, int bits)
diff --git a/include/linux/sunrpc/svcauth_gss.h b/include/linux/sunrpc/svcauth_gss.h
index ca7d725861fc..83bbee3f089c 100644
--- a/include/linux/sunrpc/svcauth_gss.h
+++ b/include/linux/sunrpc/svcauth_gss.h
@@ -2,7 +2,7 @@
2 * linux/include/linux/sunrpc/svcauth_gss.h 2 * linux/include/linux/sunrpc/svcauth_gss.h
3 * 3 *
4 * Bruce Fields <bfields@umich.edu> 4 * Bruce Fields <bfields@umich.edu>
5 * Copyright (c) 2002 The Regents of the Unviersity of Michigan 5 * Copyright (c) 2002 The Regents of the University of Michigan
6 */ 6 */
7 7
8#ifndef _LINUX_SUNRPC_SVCAUTH_GSS_H 8#ifndef _LINUX_SUNRPC_SVCAUTH_GSS_H
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 1b353a76c304..85c50b40759d 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -28,7 +28,7 @@ struct svc_sock {
28 /* private TCP part */ 28 /* private TCP part */
29 u32 sk_reclen; /* length of record */ 29 u32 sk_reclen; /* length of record */
30 u32 sk_tcplen; /* current read length */ 30 u32 sk_tcplen; /* current read length */
31 struct rpc_xprt *sk_bc_xprt; /* NFSv4.1 backchannel xprt */ 31 struct page * sk_pages[RPCSVC_MAXPAGES]; /* received data */
32}; 32};
33 33
34/* 34/*
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 35cf2e8cd7c6..a20970ef9e4e 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -33,8 +33,8 @@ struct xdr_netobj {
33}; 33};
34 34
35/* 35/*
36 * This is the generic XDR function. rqstp is either a rpc_rqst (client 36 * This is the legacy generic XDR function. rqstp is either a rpc_rqst
37 * side) or svc_rqst pointer (server side). 37 * (client side) or svc_rqst pointer (server side).
38 * Encode functions always assume there's enough room in the buffer. 38 * Encode functions always assume there's enough room in the buffer.
39 */ 39 */
40typedef int (*kxdrproc_t)(void *rqstp, __be32 *data, void *obj); 40typedef int (*kxdrproc_t)(void *rqstp, __be32 *data, void *obj);
@@ -108,6 +108,7 @@ void xdr_encode_pages(struct xdr_buf *, struct page **, unsigned int,
108 unsigned int); 108 unsigned int);
109void xdr_inline_pages(struct xdr_buf *, unsigned int, 109void xdr_inline_pages(struct xdr_buf *, unsigned int,
110 struct page **, unsigned int, unsigned int); 110 struct page **, unsigned int, unsigned int);
111void xdr_terminate_string(struct xdr_buf *, const u32);
111 112
112static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int len) 113static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int len)
113{ 114{
@@ -131,6 +132,13 @@ xdr_decode_hyper(__be32 *p, __u64 *valp)
131 return p + 2; 132 return p + 2;
132} 133}
133 134
135static inline __be32 *
136xdr_decode_opaque_fixed(__be32 *p, void *ptr, unsigned int len)
137{
138 memcpy(ptr, p, len);
139 return p + XDR_QUADLEN(len);
140}
141
134/* 142/*
135 * Adjust kvec to reflect end of xdr'ed data (RPC client XDR) 143 * Adjust kvec to reflect end of xdr'ed data (RPC client XDR)
136 */ 144 */
@@ -193,13 +201,24 @@ struct xdr_stream {
193 201
194 __be32 *end; /* end of available buffer space */ 202 __be32 *end; /* end of available buffer space */
195 struct kvec *iov; /* pointer to the current kvec */ 203 struct kvec *iov; /* pointer to the current kvec */
204 struct kvec scratch; /* Scratch buffer */
205 struct page **page_ptr; /* pointer to the current page */
196}; 206};
197 207
208/*
209 * These are the xdr_stream style generic XDR encode and decode functions.
210 */
211typedef void (*kxdreproc_t)(void *rqstp, struct xdr_stream *xdr, void *obj);
212typedef int (*kxdrdproc_t)(void *rqstp, struct xdr_stream *xdr, void *obj);
213
198extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); 214extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p);
199extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes); 215extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
200extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, 216extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages,
201 unsigned int base, unsigned int len); 217 unsigned int base, unsigned int len);
202extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p); 218extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p);
219extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
220 struct page **pages, unsigned int len);
221extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen);
203extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); 222extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes);
204extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len); 223extern void xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
205extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); 224extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len);
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index ff5a77b28c50..81cce3b3ee66 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -12,7 +12,6 @@
12#include <linux/uio.h> 12#include <linux/uio.h>
13#include <linux/socket.h> 13#include <linux/socket.h>
14#include <linux/in.h> 14#include <linux/in.h>
15#include <linux/kref.h>
16#include <linux/ktime.h> 15#include <linux/ktime.h>
17#include <linux/sunrpc/sched.h> 16#include <linux/sunrpc/sched.h>
18#include <linux/sunrpc/xdr.h> 17#include <linux/sunrpc/xdr.h>
@@ -142,11 +141,12 @@ enum xprt_transports {
142 XPRT_TRANSPORT_UDP = IPPROTO_UDP, 141 XPRT_TRANSPORT_UDP = IPPROTO_UDP,
143 XPRT_TRANSPORT_TCP = IPPROTO_TCP, 142 XPRT_TRANSPORT_TCP = IPPROTO_TCP,
144 XPRT_TRANSPORT_BC_TCP = IPPROTO_TCP | XPRT_TRANSPORT_BC, 143 XPRT_TRANSPORT_BC_TCP = IPPROTO_TCP | XPRT_TRANSPORT_BC,
145 XPRT_TRANSPORT_RDMA = 256 144 XPRT_TRANSPORT_RDMA = 256,
145 XPRT_TRANSPORT_LOCAL = 257,
146}; 146};
147 147
148struct rpc_xprt { 148struct rpc_xprt {
149 struct kref kref; /* Reference count */ 149 atomic_t count; /* Reference count */
150 struct rpc_xprt_ops * ops; /* transport methods */ 150 struct rpc_xprt_ops * ops; /* transport methods */
151 151
152 const struct rpc_timeout *timeout; /* timeout parms */ 152 const struct rpc_timeout *timeout; /* timeout parms */
@@ -224,6 +224,7 @@ struct rpc_xprt {
224 bklog_u; /* backlog queue utilization */ 224 bklog_u; /* backlog queue utilization */
225 } stat; 225 } stat;
226 226
227 struct net *xprt_net;
227 const char *address_strings[RPC_DISPLAY_MAX]; 228 const char *address_strings[RPC_DISPLAY_MAX];
228}; 229};
229 230
@@ -249,6 +250,7 @@ static inline int bc_prealloc(struct rpc_rqst *req)
249 250
250struct xprt_create { 251struct xprt_create {
251 int ident; /* XPRT_TRANSPORT identifier */ 252 int ident; /* XPRT_TRANSPORT identifier */
253 struct net * net;
252 struct sockaddr * srcaddr; /* optional local address */ 254 struct sockaddr * srcaddr; /* optional local address */
253 struct sockaddr * dstaddr; /* remote peer address */ 255 struct sockaddr * dstaddr; /* remote peer address */
254 size_t addrlen; 256 size_t addrlen;
@@ -280,6 +282,8 @@ void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
280void xprt_release(struct rpc_task *task); 282void xprt_release(struct rpc_task *task);
281struct rpc_xprt * xprt_get(struct rpc_xprt *xprt); 283struct rpc_xprt * xprt_get(struct rpc_xprt *xprt);
282void xprt_put(struct rpc_xprt *xprt); 284void xprt_put(struct rpc_xprt *xprt);
285struct rpc_xprt * xprt_alloc(struct net *net, int size, int max_req);
286void xprt_free(struct rpc_xprt *);
283 287
284static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p) 288static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p)
285{ 289{
@@ -317,6 +321,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie);
317#define XPRT_CLOSING (6) 321#define XPRT_CLOSING (6)
318#define XPRT_CONNECTION_ABORT (7) 322#define XPRT_CONNECTION_ABORT (7)
319#define XPRT_CONNECTION_CLOSE (8) 323#define XPRT_CONNECTION_CLOSE (8)
324#define XPRT_INITIALIZED (9)
320 325
321static inline void xprt_set_connected(struct rpc_xprt *xprt) 326static inline void xprt_set_connected(struct rpc_xprt *xprt)
322{ 327{
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 4af270ec2204..083ffea7ba18 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -122,7 +122,7 @@ struct platform_suspend_ops {
122 * suspend_set_ops - set platform dependent suspend operations 122 * suspend_set_ops - set platform dependent suspend operations
123 * @ops: The new suspend operations to set. 123 * @ops: The new suspend operations to set.
124 */ 124 */
125extern void suspend_set_ops(struct platform_suspend_ops *ops); 125extern void suspend_set_ops(const struct platform_suspend_ops *ops);
126extern int suspend_valid_only_mem(suspend_state_t state); 126extern int suspend_valid_only_mem(suspend_state_t state);
127 127
128/** 128/**
@@ -147,7 +147,7 @@ extern int pm_suspend(suspend_state_t state);
147#else /* !CONFIG_SUSPEND */ 147#else /* !CONFIG_SUSPEND */
148#define suspend_valid_only_mem NULL 148#define suspend_valid_only_mem NULL
149 149
150static inline void suspend_set_ops(struct platform_suspend_ops *ops) {} 150static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
151static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } 151static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
152#endif /* !CONFIG_SUSPEND */ 152#endif /* !CONFIG_SUSPEND */
153 153
@@ -245,36 +245,21 @@ extern void swsusp_set_page_free(struct page *);
245extern void swsusp_unset_page_free(struct page *); 245extern void swsusp_unset_page_free(struct page *);
246extern unsigned long get_safe_page(gfp_t gfp_mask); 246extern unsigned long get_safe_page(gfp_t gfp_mask);
247 247
248extern void hibernation_set_ops(struct platform_hibernation_ops *ops); 248extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
249extern int hibernate(void); 249extern int hibernate(void);
250extern bool system_entering_hibernation(void); 250extern bool system_entering_hibernation(void);
251#else /* CONFIG_HIBERNATION */ 251#else /* CONFIG_HIBERNATION */
252static inline void register_nosave_region(unsigned long b, unsigned long e) {}
253static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
252static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } 254static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
253static inline void swsusp_set_page_free(struct page *p) {} 255static inline void swsusp_set_page_free(struct page *p) {}
254static inline void swsusp_unset_page_free(struct page *p) {} 256static inline void swsusp_unset_page_free(struct page *p) {}
255 257
256static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {} 258static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {}
257static inline int hibernate(void) { return -ENOSYS; } 259static inline int hibernate(void) { return -ENOSYS; }
258static inline bool system_entering_hibernation(void) { return false; } 260static inline bool system_entering_hibernation(void) { return false; }
259#endif /* CONFIG_HIBERNATION */ 261#endif /* CONFIG_HIBERNATION */
260 262
261#ifdef CONFIG_SUSPEND_NVS
262extern int suspend_nvs_register(unsigned long start, unsigned long size);
263extern int suspend_nvs_alloc(void);
264extern void suspend_nvs_free(void);
265extern void suspend_nvs_save(void);
266extern void suspend_nvs_restore(void);
267#else /* CONFIG_SUSPEND_NVS */
268static inline int suspend_nvs_register(unsigned long a, unsigned long b)
269{
270 return 0;
271}
272static inline int suspend_nvs_alloc(void) { return 0; }
273static inline void suspend_nvs_free(void) {}
274static inline void suspend_nvs_save(void) {}
275static inline void suspend_nvs_restore(void) {}
276#endif /* CONFIG_SUSPEND_NVS */
277
278#ifdef CONFIG_PM_SLEEP 263#ifdef CONFIG_PM_SLEEP
279void save_processor_state(void); 264void save_processor_state(void);
280void restore_processor_state(void); 265void restore_processor_state(void);
@@ -292,9 +277,9 @@ extern int unregister_pm_notifier(struct notifier_block *nb);
292/* drivers/base/power/wakeup.c */ 277/* drivers/base/power/wakeup.c */
293extern bool events_check_enabled; 278extern bool events_check_enabled;
294 279
295extern bool pm_check_wakeup_events(void); 280extern bool pm_wakeup_pending(void);
296extern bool pm_get_wakeup_count(unsigned long *count); 281extern bool pm_get_wakeup_count(unsigned int *count);
297extern bool pm_save_wakeup_count(unsigned long count); 282extern bool pm_save_wakeup_count(unsigned int count);
298#else /* !CONFIG_PM_SLEEP */ 283#else /* !CONFIG_PM_SLEEP */
299 284
300static inline int register_pm_notifier(struct notifier_block *nb) 285static inline int register_pm_notifier(struct notifier_block *nb)
@@ -308,18 +293,13 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
308} 293}
309 294
310#define pm_notifier(fn, pri) do { (void)(fn); } while (0) 295#define pm_notifier(fn, pri) do { (void)(fn); } while (0)
296
297static inline bool pm_wakeup_pending(void) { return false; }
311#endif /* !CONFIG_PM_SLEEP */ 298#endif /* !CONFIG_PM_SLEEP */
312 299
313extern struct mutex pm_mutex; 300extern struct mutex pm_mutex;
314 301
315#ifndef CONFIG_HIBERNATION 302#ifndef CONFIG_HIBERNATE_CALLBACKS
316static inline void register_nosave_region(unsigned long b, unsigned long e)
317{
318}
319static inline void register_nosave_region_late(unsigned long b, unsigned long e)
320{
321}
322
323static inline void lock_system_sleep(void) {} 303static inline void lock_system_sleep(void) {}
324static inline void unlock_system_sleep(void) {} 304static inline void unlock_system_sleep(void) {}
325 305
diff --git a/include/linux/svga.h b/include/linux/svga.h
index c59a51a2b0e7..bfa68e837d6a 100644
--- a/include/linux/svga.h
+++ b/include/linux/svga.h
@@ -67,25 +67,25 @@ struct svga_pll {
67 67
68/* Write a value to the attribute register */ 68/* Write a value to the attribute register */
69 69
70static inline void svga_wattr(u8 index, u8 data) 70static inline void svga_wattr(void __iomem *regbase, u8 index, u8 data)
71{ 71{
72 inb(0x3DA); 72 vga_r(regbase, VGA_IS1_RC);
73 outb(index, 0x3C0); 73 vga_w(regbase, VGA_ATT_IW, index);
74 outb(data, 0x3C0); 74 vga_w(regbase, VGA_ATT_W, data);
75} 75}
76 76
77/* Write a value to a sequence register with a mask */ 77/* Write a value to a sequence register with a mask */
78 78
79static inline void svga_wseq_mask(u8 index, u8 data, u8 mask) 79static inline void svga_wseq_mask(void __iomem *regbase, u8 index, u8 data, u8 mask)
80{ 80{
81 vga_wseq(NULL, index, (data & mask) | (vga_rseq(NULL, index) & ~mask)); 81 vga_wseq(regbase, index, (data & mask) | (vga_rseq(regbase, index) & ~mask));
82} 82}
83 83
84/* Write a value to a CRT register with a mask */ 84/* Write a value to a CRT register with a mask */
85 85
86static inline void svga_wcrt_mask(u8 index, u8 data, u8 mask) 86static inline void svga_wcrt_mask(void __iomem *regbase, u8 index, u8 data, u8 mask)
87{ 87{
88 vga_wcrt(NULL, index, (data & mask) | (vga_rcrt(NULL, index) & ~mask)); 88 vga_wcrt(regbase, index, (data & mask) | (vga_rcrt(regbase, index) & ~mask));
89} 89}
90 90
91static inline int svga_primary_device(struct pci_dev *dev) 91static inline int svga_primary_device(struct pci_dev *dev)
@@ -96,27 +96,27 @@ static inline int svga_primary_device(struct pci_dev *dev)
96} 96}
97 97
98 98
99void svga_wcrt_multi(const struct vga_regset *regset, u32 value); 99void svga_wcrt_multi(void __iomem *regbase, const struct vga_regset *regset, u32 value);
100void svga_wseq_multi(const struct vga_regset *regset, u32 value); 100void svga_wseq_multi(void __iomem *regbase, const struct vga_regset *regset, u32 value);
101 101
102void svga_set_default_gfx_regs(void); 102void svga_set_default_gfx_regs(void __iomem *regbase);
103void svga_set_default_atc_regs(void); 103void svga_set_default_atc_regs(void __iomem *regbase);
104void svga_set_default_seq_regs(void); 104void svga_set_default_seq_regs(void __iomem *regbase);
105void svga_set_default_crt_regs(void); 105void svga_set_default_crt_regs(void __iomem *regbase);
106void svga_set_textmode_vga_regs(void); 106void svga_set_textmode_vga_regs(void __iomem *regbase);
107 107
108void svga_settile(struct fb_info *info, struct fb_tilemap *map); 108void svga_settile(struct fb_info *info, struct fb_tilemap *map);
109void svga_tilecopy(struct fb_info *info, struct fb_tilearea *area); 109void svga_tilecopy(struct fb_info *info, struct fb_tilearea *area);
110void svga_tilefill(struct fb_info *info, struct fb_tilerect *rect); 110void svga_tilefill(struct fb_info *info, struct fb_tilerect *rect);
111void svga_tileblit(struct fb_info *info, struct fb_tileblit *blit); 111void svga_tileblit(struct fb_info *info, struct fb_tileblit *blit);
112void svga_tilecursor(struct fb_info *info, struct fb_tilecursor *cursor); 112void svga_tilecursor(void __iomem *regbase, struct fb_info *info, struct fb_tilecursor *cursor);
113int svga_get_tilemax(struct fb_info *info); 113int svga_get_tilemax(struct fb_info *info);
114void svga_get_caps(struct fb_info *info, struct fb_blit_caps *caps, 114void svga_get_caps(struct fb_info *info, struct fb_blit_caps *caps,
115 struct fb_var_screeninfo *var); 115 struct fb_var_screeninfo *var);
116 116
117int svga_compute_pll(const struct svga_pll *pll, u32 f_wanted, u16 *m, u16 *n, u16 *r, int node); 117int svga_compute_pll(const struct svga_pll *pll, u32 f_wanted, u16 *m, u16 *n, u16 *r, int node);
118int svga_check_timings(const struct svga_timing_regs *tm, struct fb_var_screeninfo *var, int node); 118int svga_check_timings(const struct svga_timing_regs *tm, struct fb_var_screeninfo *var, int node);
119void svga_set_timings(const struct svga_timing_regs *tm, struct fb_var_screeninfo *var, u32 hmul, u32 hdiv, u32 vmul, u32 vdiv, u32 hborder, int node); 119void svga_set_timings(void __iomem *regbase, const struct svga_timing_regs *tm, struct fb_var_screeninfo *var, u32 hmul, u32 hdiv, u32 vmul, u32 vdiv, u32 hborder, int node);
120 120
121int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix); 121int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix);
122 122
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 7cdd63366f88..a273468f8285 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -155,6 +155,15 @@ enum {
155#define SWAP_CLUSTER_MAX 32 155#define SWAP_CLUSTER_MAX 32
156#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX 156#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
157 157
158/*
159 * Ratio between the present memory in the zone and the "gap" that
160 * we're allowing kswapd to shrink in addition to the per-zone high
161 * wmark, even for zones that already have the high wmark satisfied,
162 * in order to provide better per-zone lru behavior. We are ok to
163 * spend not more than 1% of the memory for this zone balancing "gap".
164 */
165#define KSWAPD_ZONE_BALANCE_GAP_RATIO 100
166
158#define SWAP_MAP_MAX 0x3e /* Max duplication count, in first swap_map */ 167#define SWAP_MAP_MAX 0x3e /* Max duplication count, in first swap_map */
159#define SWAP_MAP_BAD 0x3f /* Note pageblock is bad, in first swap_map */ 168#define SWAP_MAP_BAD 0x3f /* Note pageblock is bad, in first swap_map */
160#define SWAP_HAS_CACHE 0x40 /* Flag page is cached, in first swap_map */ 169#define SWAP_HAS_CACHE 0x40 /* Flag page is cached, in first swap_map */
@@ -208,11 +217,14 @@ extern unsigned int nr_free_pagecache_pages(void);
208/* linux/mm/swap.c */ 217/* linux/mm/swap.c */
209extern void __lru_cache_add(struct page *, enum lru_list lru); 218extern void __lru_cache_add(struct page *, enum lru_list lru);
210extern void lru_cache_add_lru(struct page *, enum lru_list lru); 219extern void lru_cache_add_lru(struct page *, enum lru_list lru);
220extern void lru_add_page_tail(struct zone* zone,
221 struct page *page, struct page *page_tail);
211extern void activate_page(struct page *); 222extern void activate_page(struct page *);
212extern void mark_page_accessed(struct page *); 223extern void mark_page_accessed(struct page *);
213extern void lru_add_drain(void); 224extern void lru_add_drain(void);
214extern int lru_add_drain_all(void); 225extern int lru_add_drain_all(void);
215extern void rotate_reclaimable_page(struct page *page); 226extern void rotate_reclaimable_page(struct page *page);
227extern void deactivate_page(struct page *page);
216extern void swap_setup(void); 228extern void swap_setup(void);
217 229
218extern void add_page_to_unevictable_list(struct page *page); 230extern void add_page_to_unevictable_list(struct page *page);
@@ -245,7 +257,8 @@ extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
245extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem, 257extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
246 gfp_t gfp_mask, bool noswap, 258 gfp_t gfp_mask, bool noswap,
247 unsigned int swappiness, 259 unsigned int swappiness,
248 struct zone *zone); 260 struct zone *zone,
261 unsigned long *nr_scanned);
249extern int __isolate_lru_page(struct page *page, int mode, int file); 262extern int __isolate_lru_page(struct page *page, int mode, int file);
250extern unsigned long shrink_all_memory(unsigned long nr_pages); 263extern unsigned long shrink_all_memory(unsigned long nr_pages);
251extern int vm_swappiness; 264extern int vm_swappiness;
@@ -271,24 +284,22 @@ extern void scan_mapping_unevictable_pages(struct address_space *);
271extern unsigned long scan_unevictable_pages; 284extern unsigned long scan_unevictable_pages;
272extern int scan_unevictable_handler(struct ctl_table *, int, 285extern int scan_unevictable_handler(struct ctl_table *, int,
273 void __user *, size_t *, loff_t *); 286 void __user *, size_t *, loff_t *);
287#ifdef CONFIG_NUMA
274extern int scan_unevictable_register_node(struct node *node); 288extern int scan_unevictable_register_node(struct node *node);
275extern void scan_unevictable_unregister_node(struct node *node); 289extern void scan_unevictable_unregister_node(struct node *node);
290#else
291static inline int scan_unevictable_register_node(struct node *node)
292{
293 return 0;
294}
295static inline void scan_unevictable_unregister_node(struct node *node)
296{
297}
298#endif
276 299
277extern int kswapd_run(int nid); 300extern int kswapd_run(int nid);
278extern void kswapd_stop(int nid); 301extern void kswapd_stop(int nid);
279 302
280#ifdef CONFIG_MMU
281/* linux/mm/shmem.c */
282extern int shmem_unuse(swp_entry_t entry, struct page *page);
283#endif /* CONFIG_MMU */
284
285#ifdef CONFIG_CGROUP_MEM_RES_CTLR
286extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
287 struct page **pagep, swp_entry_t *ent);
288#endif
289
290extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
291
292#ifdef CONFIG_SWAP 303#ifdef CONFIG_SWAP
293/* linux/mm/page_io.c */ 304/* linux/mm/page_io.c */
294extern int swap_readpage(struct page *); 305extern int swap_readpage(struct page *);
@@ -337,6 +348,7 @@ struct backing_dev_info;
337extern struct mm_struct *swap_token_mm; 348extern struct mm_struct *swap_token_mm;
338extern void grab_swap_token(struct mm_struct *); 349extern void grab_swap_token(struct mm_struct *);
339extern void __put_swap_token(struct mm_struct *); 350extern void __put_swap_token(struct mm_struct *);
351extern void disable_swap_token(struct mem_cgroup *memcg);
340 352
341static inline int has_swap_token(struct mm_struct *mm) 353static inline int has_swap_token(struct mm_struct *mm)
342{ 354{
@@ -349,11 +361,6 @@ static inline void put_swap_token(struct mm_struct *mm)
349 __put_swap_token(mm); 361 __put_swap_token(mm);
350} 362}
351 363
352static inline void disable_swap_token(void)
353{
354 put_swap_token(swap_token_mm);
355}
356
357#ifdef CONFIG_CGROUP_MEM_RES_CTLR 364#ifdef CONFIG_CGROUP_MEM_RES_CTLR
358extern void 365extern void
359mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout); 366mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout);
@@ -479,7 +486,7 @@ static inline int has_swap_token(struct mm_struct *mm)
479 return 0; 486 return 0;
480} 487}
481 488
482static inline void disable_swap_token(void) 489static inline void disable_swap_token(struct mem_cgroup *memcg)
483{ 490{
484} 491}
485 492
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 8c0e349f4a6c..445702c60d04 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -24,6 +24,7 @@ extern int swiotlb_force;
24 24
25extern void swiotlb_init(int verbose); 25extern void swiotlb_init(int verbose);
26extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose); 26extern void swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose);
27extern unsigned long swioltb_nr_tbl(void);
27 28
28/* 29/*
29 * Enumeration for sync targets 30 * Enumeration for sync targets
diff --git a/include/linux/synclink.h b/include/linux/synclink.h
index 0ff2779c44d0..2e7d81c4e5ad 100644
--- a/include/linux/synclink.h
+++ b/include/linux/synclink.h
@@ -126,6 +126,7 @@
126#define MGSL_MODE_BISYNC 4 126#define MGSL_MODE_BISYNC 4
127#define MGSL_MODE_RAW 6 127#define MGSL_MODE_RAW 6
128#define MGSL_MODE_BASE_CLOCK 7 128#define MGSL_MODE_BASE_CLOCK 7
129#define MGSL_MODE_XSYNC 8
129 130
130#define MGSL_BUS_TYPE_ISA 1 131#define MGSL_BUS_TYPE_ISA 1
131#define MGSL_BUS_TYPE_EISA 2 132#define MGSL_BUS_TYPE_EISA 2
@@ -290,6 +291,10 @@ struct gpio_desc {
290#define MGSL_IOCSGPIO _IOW(MGSL_MAGIC_IOC,16,struct gpio_desc) 291#define MGSL_IOCSGPIO _IOW(MGSL_MAGIC_IOC,16,struct gpio_desc)
291#define MGSL_IOCGGPIO _IOR(MGSL_MAGIC_IOC,17,struct gpio_desc) 292#define MGSL_IOCGGPIO _IOR(MGSL_MAGIC_IOC,17,struct gpio_desc)
292#define MGSL_IOCWAITGPIO _IOWR(MGSL_MAGIC_IOC,18,struct gpio_desc) 293#define MGSL_IOCWAITGPIO _IOWR(MGSL_MAGIC_IOC,18,struct gpio_desc)
294#define MGSL_IOCSXSYNC _IO(MGSL_MAGIC_IOC, 19)
295#define MGSL_IOCGXSYNC _IO(MGSL_MAGIC_IOC, 20)
296#define MGSL_IOCSXCTRL _IO(MGSL_MAGIC_IOC, 21)
297#define MGSL_IOCGXCTRL _IO(MGSL_MAGIC_IOC, 22)
293 298
294#ifdef __KERNEL__ 299#ifdef __KERNEL__
295/* provide 32 bit ioctl compatibility on 64 bit systems */ 300/* provide 32 bit ioctl compatibility on 64 bit systems */
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e6319d18a55d..8c03b98df5f9 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -62,6 +62,7 @@ struct robust_list_head;
62struct getcpu_cache; 62struct getcpu_cache;
63struct old_linux_dirent; 63struct old_linux_dirent;
64struct perf_event_attr; 64struct perf_event_attr;
65struct file_handle;
65 66
66#include <linux/types.h> 67#include <linux/types.h>
67#include <linux/aio_abi.h> 68#include <linux/aio_abi.h>
@@ -125,64 +126,66 @@ extern struct trace_event_functions enter_syscall_print_funcs;
125extern struct trace_event_functions exit_syscall_print_funcs; 126extern struct trace_event_functions exit_syscall_print_funcs;
126 127
127#define SYSCALL_TRACE_ENTER_EVENT(sname) \ 128#define SYSCALL_TRACE_ENTER_EVENT(sname) \
128 static struct syscall_metadata \ 129 static struct syscall_metadata __syscall_meta_##sname; \
129 __attribute__((__aligned__(4))) __syscall_meta_##sname; \
130 static struct ftrace_event_call \
131 __attribute__((__aligned__(4))) event_enter_##sname; \
132 static struct ftrace_event_call __used \ 130 static struct ftrace_event_call __used \
133 __attribute__((__aligned__(4))) \
134 __attribute__((section("_ftrace_events"))) \
135 event_enter_##sname = { \ 131 event_enter_##sname = { \
136 .name = "sys_enter"#sname, \ 132 .name = "sys_enter"#sname, \
137 .class = &event_class_syscall_enter, \ 133 .class = &event_class_syscall_enter, \
138 .event.funcs = &enter_syscall_print_funcs, \ 134 .event.funcs = &enter_syscall_print_funcs, \
139 .data = (void *)&__syscall_meta_##sname,\ 135 .data = (void *)&__syscall_meta_##sname,\
140 } 136 .flags = TRACE_EVENT_FL_CAP_ANY, \
137 }; \
138 static struct ftrace_event_call __used \
139 __attribute__((section("_ftrace_events"))) \
140 *__event_enter_##sname = &event_enter_##sname;
141 141
142#define SYSCALL_TRACE_EXIT_EVENT(sname) \ 142#define SYSCALL_TRACE_EXIT_EVENT(sname) \
143 static struct syscall_metadata \ 143 static struct syscall_metadata __syscall_meta_##sname; \
144 __attribute__((__aligned__(4))) __syscall_meta_##sname; \
145 static struct ftrace_event_call \
146 __attribute__((__aligned__(4))) event_exit_##sname; \
147 static struct ftrace_event_call __used \ 144 static struct ftrace_event_call __used \
148 __attribute__((__aligned__(4))) \
149 __attribute__((section("_ftrace_events"))) \
150 event_exit_##sname = { \ 145 event_exit_##sname = { \
151 .name = "sys_exit"#sname, \ 146 .name = "sys_exit"#sname, \
152 .class = &event_class_syscall_exit, \ 147 .class = &event_class_syscall_exit, \
153 .event.funcs = &exit_syscall_print_funcs, \ 148 .event.funcs = &exit_syscall_print_funcs, \
154 .data = (void *)&__syscall_meta_##sname,\ 149 .data = (void *)&__syscall_meta_##sname,\
155 } 150 .flags = TRACE_EVENT_FL_CAP_ANY, \
151 }; \
152 static struct ftrace_event_call __used \
153 __attribute__((section("_ftrace_events"))) \
154 *__event_exit_##sname = &event_exit_##sname;
156 155
157#define SYSCALL_METADATA(sname, nb) \ 156#define SYSCALL_METADATA(sname, nb) \
158 SYSCALL_TRACE_ENTER_EVENT(sname); \ 157 SYSCALL_TRACE_ENTER_EVENT(sname); \
159 SYSCALL_TRACE_EXIT_EVENT(sname); \ 158 SYSCALL_TRACE_EXIT_EVENT(sname); \
160 static struct syscall_metadata __used \ 159 static struct syscall_metadata __used \
161 __attribute__((__aligned__(4))) \
162 __attribute__((section("__syscalls_metadata"))) \
163 __syscall_meta_##sname = { \ 160 __syscall_meta_##sname = { \
164 .name = "sys"#sname, \ 161 .name = "sys"#sname, \
162 .syscall_nr = -1, /* Filled in at boot */ \
165 .nb_args = nb, \ 163 .nb_args = nb, \
166 .types = types_##sname, \ 164 .types = types_##sname, \
167 .args = args_##sname, \ 165 .args = args_##sname, \
168 .enter_event = &event_enter_##sname, \ 166 .enter_event = &event_enter_##sname, \
169 .exit_event = &event_exit_##sname, \ 167 .exit_event = &event_exit_##sname, \
170 .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \ 168 .enter_fields = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
171 }; 169 }; \
170 static struct syscall_metadata __used \
171 __attribute__((section("__syscalls_metadata"))) \
172 *__p_syscall_meta_##sname = &__syscall_meta_##sname;
172 173
173#define SYSCALL_DEFINE0(sname) \ 174#define SYSCALL_DEFINE0(sname) \
174 SYSCALL_TRACE_ENTER_EVENT(_##sname); \ 175 SYSCALL_TRACE_ENTER_EVENT(_##sname); \
175 SYSCALL_TRACE_EXIT_EVENT(_##sname); \ 176 SYSCALL_TRACE_EXIT_EVENT(_##sname); \
176 static struct syscall_metadata __used \ 177 static struct syscall_metadata __used \
177 __attribute__((__aligned__(4))) \
178 __attribute__((section("__syscalls_metadata"))) \
179 __syscall_meta__##sname = { \ 178 __syscall_meta__##sname = { \
180 .name = "sys_"#sname, \ 179 .name = "sys_"#sname, \
180 .syscall_nr = -1, /* Filled in at boot */ \
181 .nb_args = 0, \ 181 .nb_args = 0, \
182 .enter_event = &event_enter__##sname, \ 182 .enter_event = &event_enter__##sname, \
183 .exit_event = &event_exit__##sname, \ 183 .exit_event = &event_exit__##sname, \
184 .enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \ 184 .enter_fields = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
185 }; \ 185 }; \
186 static struct syscall_metadata __used \
187 __attribute__((section("__syscalls_metadata"))) \
188 *__p_syscall_meta_##sname = &__syscall_meta__##sname; \
186 asmlinkage long sys_##sname(void) 189 asmlinkage long sys_##sname(void)
187#else 190#else
188#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) 191#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
@@ -313,6 +316,8 @@ asmlinkage long sys_clock_settime(clockid_t which_clock,
313 const struct timespec __user *tp); 316 const struct timespec __user *tp);
314asmlinkage long sys_clock_gettime(clockid_t which_clock, 317asmlinkage long sys_clock_gettime(clockid_t which_clock,
315 struct timespec __user *tp); 318 struct timespec __user *tp);
319asmlinkage long sys_clock_adjtime(clockid_t which_clock,
320 struct timex __user *tx);
316asmlinkage long sys_clock_getres(clockid_t which_clock, 321asmlinkage long sys_clock_getres(clockid_t which_clock,
317 struct timespec __user *tp); 322 struct timespec __user *tp);
318asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags, 323asmlinkage long sys_clock_nanosleep(clockid_t which_clock, int flags,
@@ -605,6 +610,8 @@ asmlinkage long sys_send(int, void __user *, size_t, unsigned);
605asmlinkage long sys_sendto(int, void __user *, size_t, unsigned, 610asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
606 struct sockaddr __user *, int); 611 struct sockaddr __user *, int);
607asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags); 612asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
613asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
614 unsigned int vlen, unsigned flags);
608asmlinkage long sys_recv(int, void __user *, size_t, unsigned); 615asmlinkage long sys_recv(int, void __user *, size_t, unsigned);
609asmlinkage long sys_recvfrom(int, void __user *, size_t, unsigned, 616asmlinkage long sys_recvfrom(int, void __user *, size_t, unsigned,
610 struct sockaddr __user *, int __user *); 617 struct sockaddr __user *, int __user *);
@@ -701,7 +708,8 @@ asmlinkage long sys_nfsservctl(int cmd,
701asmlinkage long sys_syslog(int type, char __user *buf, int len); 708asmlinkage long sys_syslog(int type, char __user *buf, int len);
702asmlinkage long sys_uselib(const char __user *library); 709asmlinkage long sys_uselib(const char __user *library);
703asmlinkage long sys_ni_syscall(void); 710asmlinkage long sys_ni_syscall(void);
704asmlinkage long sys_ptrace(long request, long pid, long addr, long data); 711asmlinkage long sys_ptrace(long request, long pid, unsigned long addr,
712 unsigned long data);
705 713
706asmlinkage long sys_add_key(const char __user *_type, 714asmlinkage long sys_add_key(const char __user *_type,
707 const char __user *_description, 715 const char __user *_description,
@@ -819,6 +827,7 @@ asmlinkage long sys_fanotify_init(unsigned int flags, unsigned int event_f_flags
819asmlinkage long sys_fanotify_mark(int fanotify_fd, unsigned int flags, 827asmlinkage long sys_fanotify_mark(int fanotify_fd, unsigned int flags,
820 u64 mask, int fd, 828 u64 mask, int fd,
821 const char __user *pathname); 829 const char __user *pathname);
830asmlinkage long sys_syncfs(int fd);
822 831
823int kernel_execve(const char *filename, const char *const argv[], const char *const envp[]); 832int kernel_execve(const char *filename, const char *const argv[], const char *const envp[]);
824 833
@@ -831,5 +840,11 @@ asmlinkage long sys_mmap_pgoff(unsigned long addr, unsigned long len,
831 unsigned long prot, unsigned long flags, 840 unsigned long prot, unsigned long flags,
832 unsigned long fd, unsigned long pgoff); 841 unsigned long fd, unsigned long pgoff);
833asmlinkage long sys_old_mmap(struct mmap_arg_struct __user *arg); 842asmlinkage long sys_old_mmap(struct mmap_arg_struct __user *arg);
834 843asmlinkage long sys_name_to_handle_at(int dfd, const char __user *name,
844 struct file_handle __user *handle,
845 int __user *mnt_id, int flag);
846asmlinkage long sys_open_by_handle_at(int mountdirfd,
847 struct file_handle __user *handle,
848 int flags);
849asmlinkage long sys_setns(int fd, int nstype);
835#endif 850#endif
diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
new file mode 100644
index 000000000000..27b3b0bc41a9
--- /dev/null
+++ b/include/linux/syscore_ops.h
@@ -0,0 +1,29 @@
1/*
2 * syscore_ops.h - System core operations.
3 *
4 * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
5 *
6 * This file is released under the GPLv2.
7 */
8
9#ifndef _LINUX_SYSCORE_OPS_H
10#define _LINUX_SYSCORE_OPS_H
11
12#include <linux/list.h>
13
14struct syscore_ops {
15 struct list_head node;
16 int (*suspend)(void);
17 void (*resume)(void);
18 void (*shutdown)(void);
19};
20
21extern void register_syscore_ops(struct syscore_ops *ops);
22extern void unregister_syscore_ops(struct syscore_ops *ops);
23#ifdef CONFIG_PM_SLEEP
24extern int syscore_suspend(void);
25extern void syscore_resume(void);
26#endif
27extern void syscore_shutdown(void);
28
29#endif
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 7bb5cb64f3b8..11684d9e6bd2 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -930,6 +930,7 @@ enum
930 930
931#ifdef __KERNEL__ 931#ifdef __KERNEL__
932#include <linux/list.h> 932#include <linux/list.h>
933#include <linux/rcupdate.h>
933 934
934/* For the /proc/sys support */ 935/* For the /proc/sys support */
935struct ctl_table; 936struct ctl_table;
@@ -1037,10 +1038,15 @@ struct ctl_table_root {
1037 struct ctl_table trees. */ 1038 struct ctl_table trees. */
1038struct ctl_table_header 1039struct ctl_table_header
1039{ 1040{
1040 struct ctl_table *ctl_table; 1041 union {
1041 struct list_head ctl_entry; 1042 struct {
1042 int used; 1043 struct ctl_table *ctl_table;
1043 int count; 1044 struct list_head ctl_entry;
1045 int used;
1046 int count;
1047 };
1048 struct rcu_head rcu;
1049 };
1044 struct completion *unregistering; 1050 struct completion *unregistering;
1045 struct ctl_table *ctl_table_arg; 1051 struct ctl_table *ctl_table_arg;
1046 struct ctl_table_root *root; 1052 struct ctl_table_root *root;
diff --git a/include/linux/sysdev.h b/include/linux/sysdev.h
index 1154c29f4101..d35e783a598c 100644
--- a/include/linux/sysdev.h
+++ b/include/linux/sysdev.h
@@ -7,13 +7,13 @@
7 * We still have a notion of a driver for a system device, because we still 7 * We still have a notion of a driver for a system device, because we still
8 * want to perform basic operations on these devices. 8 * want to perform basic operations on these devices.
9 * 9 *
10 * We also support auxillary drivers binding to devices of a certain class. 10 * We also support auxiliary drivers binding to devices of a certain class.
11 * 11 *
12 * This allows configurable drivers to register themselves for devices of 12 * This allows configurable drivers to register themselves for devices of
13 * a certain type. And, it allows class definitions to reside in generic 13 * a certain type. And, it allows class definitions to reside in generic
14 * code while arch-specific code can register specific drivers. 14 * code while arch-specific code can register specific drivers.
15 * 15 *
16 * Auxillary drivers registered with a NULL cls are registered as drivers 16 * Auxiliary drivers registered with a NULL cls are registered as drivers
17 * for all system devices, and get notification calls for each device. 17 * for all system devices, and get notification calls for each device.
18 */ 18 */
19 19
@@ -33,11 +33,6 @@ struct sysdev_class {
33 const char *name; 33 const char *name;
34 struct list_head drivers; 34 struct list_head drivers;
35 struct sysdev_class_attribute **attrs; 35 struct sysdev_class_attribute **attrs;
36
37 /* Default operations for these types of devices */
38 int (*shutdown)(struct sys_device *);
39 int (*suspend)(struct sys_device *, pm_message_t state);
40 int (*resume)(struct sys_device *);
41 struct kset kset; 36 struct kset kset;
42}; 37};
43 38
@@ -69,16 +64,13 @@ extern int sysdev_class_create_file(struct sysdev_class *,
69extern void sysdev_class_remove_file(struct sysdev_class *, 64extern void sysdev_class_remove_file(struct sysdev_class *,
70 struct sysdev_class_attribute *); 65 struct sysdev_class_attribute *);
71/** 66/**
72 * Auxillary system device drivers. 67 * Auxiliary system device drivers.
73 */ 68 */
74 69
75struct sysdev_driver { 70struct sysdev_driver {
76 struct list_head entry; 71 struct list_head entry;
77 int (*add)(struct sys_device *); 72 int (*add)(struct sys_device *);
78 int (*remove)(struct sys_device *); 73 int (*remove)(struct sys_device *);
79 int (*shutdown)(struct sys_device *);
80 int (*suspend)(struct sys_device *, pm_message_t state);
81 int (*resume)(struct sys_device *);
82}; 74};
83 75
84 76
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 96eb576d82fd..e2696d76a599 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -164,6 +164,10 @@ int sysfs_add_file_to_group(struct kobject *kobj,
164 const struct attribute *attr, const char *group); 164 const struct attribute *attr, const char *group);
165void sysfs_remove_file_from_group(struct kobject *kobj, 165void sysfs_remove_file_from_group(struct kobject *kobj,
166 const struct attribute *attr, const char *group); 166 const struct attribute *attr, const char *group);
167int sysfs_merge_group(struct kobject *kobj,
168 const struct attribute_group *grp);
169void sysfs_unmerge_group(struct kobject *kobj,
170 const struct attribute_group *grp);
167 171
168void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); 172void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
169void sysfs_notify_dirent(struct sysfs_dirent *sd); 173void sysfs_notify_dirent(struct sysfs_dirent *sd);
@@ -172,10 +176,6 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
172 const unsigned char *name); 176 const unsigned char *name);
173struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); 177struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
174void sysfs_put(struct sysfs_dirent *sd); 178void sysfs_put(struct sysfs_dirent *sd);
175void sysfs_printk_last_file(void);
176
177/* Called to clear a ns tag when it is no longer valid */
178void sysfs_exit_ns(enum kobj_ns_type type, const void *tag);
179 179
180int __must_check sysfs_init(void); 180int __must_check sysfs_init(void);
181 181
@@ -302,6 +302,17 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj,
302{ 302{
303} 303}
304 304
305static inline int sysfs_merge_group(struct kobject *kobj,
306 const struct attribute_group *grp)
307{
308 return 0;
309}
310
311static inline void sysfs_unmerge_group(struct kobject *kobj,
312 const struct attribute_group *grp)
313{
314}
315
305static inline void sysfs_notify(struct kobject *kobj, const char *dir, 316static inline void sysfs_notify(struct kobject *kobj, const char *dir,
306 const char *attr) 317 const char *attr)
307{ 318{
@@ -324,19 +335,11 @@ static inline void sysfs_put(struct sysfs_dirent *sd)
324{ 335{
325} 336}
326 337
327static inline void sysfs_exit_ns(int type, const void *tag)
328{
329}
330
331static inline int __must_check sysfs_init(void) 338static inline int __must_check sysfs_init(void)
332{ 339{
333 return 0; 340 return 0;
334} 341}
335 342
336static inline void sysfs_printk_last_file(void)
337{
338}
339
340#endif /* CONFIG_SYSFS */ 343#endif /* CONFIG_SYSFS */
341 344
342#endif /* _SYSFS_H_ */ 345#endif /* _SYSFS_H_ */
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
index 387fa7d05c98..7faf933cced7 100644
--- a/include/linux/sysrq.h
+++ b/include/linux/sysrq.h
@@ -17,6 +17,9 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/types.h> 18#include <linux/types.h>
19 19
20/* Enable/disable SYSRQ support by default (0==no, 1==yes). */
21#define SYSRQ_DEFAULT_ENABLE 1
22
20/* Possible values of bitmask for enabling sysrq functions */ 23/* Possible values of bitmask for enabling sysrq functions */
21/* 0x0001 is reserved for enable everything */ 24/* 0x0001 is reserved for enable everything */
22#define SYSRQ_ENABLE_LOG 0x0002 25#define SYSRQ_ENABLE_LOG 0x0002
diff --git a/include/linux/taskstats.h b/include/linux/taskstats.h
index 341dddb55090..2466e550a41d 100644
--- a/include/linux/taskstats.h
+++ b/include/linux/taskstats.h
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35 35
36#define TASKSTATS_VERSION 7 36#define TASKSTATS_VERSION 8
37#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN 37#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN
38 * in linux/sched.h */ 38 * in linux/sched.h */
39 39
@@ -188,6 +188,7 @@ enum {
188 TASKSTATS_TYPE_STATS, /* taskstats structure */ 188 TASKSTATS_TYPE_STATS, /* taskstats structure */
189 TASKSTATS_TYPE_AGGR_PID, /* contains pid + stats */ 189 TASKSTATS_TYPE_AGGR_PID, /* contains pid + stats */
190 TASKSTATS_TYPE_AGGR_TGID, /* contains tgid + stats */ 190 TASKSTATS_TYPE_AGGR_TGID, /* contains tgid + stats */
191 TASKSTATS_TYPE_NULL, /* contains nothing */
191 __TASKSTATS_TYPE_MAX, 192 __TASKSTATS_TYPE_MAX,
192}; 193};
193 194
diff --git a/include/linux/tc_act/Kbuild b/include/linux/tc_act/Kbuild
index 76990937f4c9..67b501c302b2 100644
--- a/include/linux/tc_act/Kbuild
+++ b/include/linux/tc_act/Kbuild
@@ -4,3 +4,4 @@ header-y += tc_mirred.h
4header-y += tc_pedit.h 4header-y += tc_pedit.h
5header-y += tc_nat.h 5header-y += tc_nat.h
6header-y += tc_skbedit.h 6header-y += tc_skbedit.h
7header-y += tc_csum.h
diff --git a/include/linux/tc_act/tc_csum.h b/include/linux/tc_act/tc_csum.h
new file mode 100644
index 000000000000..a047c49a3153
--- /dev/null
+++ b/include/linux/tc_act/tc_csum.h
@@ -0,0 +1,32 @@
1#ifndef __LINUX_TC_CSUM_H
2#define __LINUX_TC_CSUM_H
3
4#include <linux/types.h>
5#include <linux/pkt_cls.h>
6
7#define TCA_ACT_CSUM 16
8
9enum {
10 TCA_CSUM_UNSPEC,
11 TCA_CSUM_PARMS,
12 TCA_CSUM_TM,
13 __TCA_CSUM_MAX
14};
15#define TCA_CSUM_MAX (__TCA_CSUM_MAX - 1)
16
17enum {
18 TCA_CSUM_UPDATE_FLAG_IPV4HDR = 1,
19 TCA_CSUM_UPDATE_FLAG_ICMP = 2,
20 TCA_CSUM_UPDATE_FLAG_IGMP = 4,
21 TCA_CSUM_UPDATE_FLAG_TCP = 8,
22 TCA_CSUM_UPDATE_FLAG_UDP = 16,
23 TCA_CSUM_UPDATE_FLAG_UDPLITE = 32
24};
25
26struct tc_csum {
27 tc_gen;
28
29 __u32 update_flags;
30};
31
32#endif /* __LINUX_TC_CSUM_H */
diff --git a/include/linux/tc_ematch/tc_em_meta.h b/include/linux/tc_ematch/tc_em_meta.h
index 0864206ec1a3..7138962664f8 100644
--- a/include/linux/tc_ematch/tc_em_meta.h
+++ b/include/linux/tc_ematch/tc_em_meta.h
@@ -79,6 +79,7 @@ enum {
79 TCF_META_ID_SK_SENDMSG_OFF, 79 TCF_META_ID_SK_SENDMSG_OFF,
80 TCF_META_ID_SK_WRITE_PENDING, 80 TCF_META_ID_SK_WRITE_PENDING,
81 TCF_META_ID_VLAN_TAG, 81 TCF_META_ID_VLAN_TAG,
82 TCF_META_ID_RXHASH,
82 __TCF_META_ID_MAX 83 __TCF_META_ID_MAX
83}; 84};
84#define TCF_META_ID_MAX (__TCF_META_ID_MAX - 1) 85#define TCF_META_ID_MAX (__TCF_META_ID_MAX - 1)
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index a778ee024590..e64f4c67d0ef 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -105,6 +105,7 @@ enum {
105#define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */ 105#define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */
106#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/ 106#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/
107#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */ 107#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */
108#define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */
108 109
109/* for TCP_INFO socket option */ 110/* for TCP_INFO socket option */
110#define TCPI_OPT_TIMESTAMPS 1 111#define TCPI_OPT_TIMESTAMPS 1
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 1de8b9eb841b..d3ec89fb4122 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -77,7 +77,7 @@ struct thermal_cooling_device {
77 char type[THERMAL_NAME_LENGTH]; 77 char type[THERMAL_NAME_LENGTH];
78 struct device device; 78 struct device device;
79 void *devdata; 79 void *devdata;
80 struct thermal_cooling_device_ops *ops; 80 const struct thermal_cooling_device_ops *ops;
81 struct list_head node; 81 struct list_head node;
82}; 82};
83 83
@@ -114,7 +114,7 @@ struct thermal_zone_device {
114 int last_temperature; 114 int last_temperature;
115 bool passive; 115 bool passive;
116 unsigned int forced_passive; 116 unsigned int forced_passive;
117 struct thermal_zone_device_ops *ops; 117 const struct thermal_zone_device_ops *ops;
118 struct list_head cooling_devices; 118 struct list_head cooling_devices;
119 struct idr idr; 119 struct idr idr;
120 struct mutex lock; /* protect cooling devices list */ 120 struct mutex lock; /* protect cooling devices list */
@@ -127,13 +127,41 @@ struct thermal_zone_device {
127 struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */ 127 struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */
128#endif 128#endif
129}; 129};
130/* Adding event notification support elements */
131#define THERMAL_GENL_FAMILY_NAME "thermal_event"
132#define THERMAL_GENL_VERSION 0x01
133#define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_group"
134
135enum events {
136 THERMAL_AUX0,
137 THERMAL_AUX1,
138 THERMAL_CRITICAL,
139 THERMAL_DEV_FAULT,
140};
141
142struct thermal_genl_event {
143 u32 orig;
144 enum events event;
145};
146/* attributes of thermal_genl_family */
147enum {
148 THERMAL_GENL_ATTR_UNSPEC,
149 THERMAL_GENL_ATTR_EVENT,
150 __THERMAL_GENL_ATTR_MAX,
151};
152#define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1)
153
154/* commands supported by the thermal_genl_family */
155enum {
156 THERMAL_GENL_CMD_UNSPEC,
157 THERMAL_GENL_CMD_EVENT,
158 __THERMAL_GENL_CMD_MAX,
159};
160#define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)
130 161
131struct thermal_zone_device *thermal_zone_device_register(char *, int, void *, 162struct thermal_zone_device *thermal_zone_device_register(char *, int, void *,
132 struct 163 const struct thermal_zone_device_ops *, int tc1, int tc2,
133 thermal_zone_device_ops 164 int passive_freq, int polling_freq);
134 *, int tc1, int tc2,
135 int passive_freq,
136 int polling_freq);
137void thermal_zone_device_unregister(struct thermal_zone_device *); 165void thermal_zone_device_unregister(struct thermal_zone_device *);
138 166
139int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, 167int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
@@ -142,9 +170,16 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
142 struct thermal_cooling_device *); 170 struct thermal_cooling_device *);
143void thermal_zone_device_update(struct thermal_zone_device *); 171void thermal_zone_device_update(struct thermal_zone_device *);
144struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, 172struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
145 struct 173 const struct thermal_cooling_device_ops *);
146 thermal_cooling_device_ops
147 *);
148void thermal_cooling_device_unregister(struct thermal_cooling_device *); 174void thermal_cooling_device_unregister(struct thermal_cooling_device *);
149 175
176#ifdef CONFIG_NET
177extern int generate_netlink_event(u32 orig, enum events event);
178#else
179static inline int generate_netlink_event(u32 orig, enum events event)
180{
181 return 0;
182}
183#endif
184
150#endif /* __THERMAL_H__ */ 185#endif /* __THERMAL_H__ */
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index a8cc4e13434c..8d03f079688c 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -18,21 +18,18 @@ struct compat_timespec;
18struct restart_block { 18struct restart_block {
19 long (*fn)(struct restart_block *); 19 long (*fn)(struct restart_block *);
20 union { 20 union {
21 struct {
22 unsigned long arg0, arg1, arg2, arg3;
23 };
24 /* For futex_wait and futex_wait_requeue_pi */ 21 /* For futex_wait and futex_wait_requeue_pi */
25 struct { 22 struct {
26 u32 *uaddr; 23 u32 __user *uaddr;
27 u32 val; 24 u32 val;
28 u32 flags; 25 u32 flags;
29 u32 bitset; 26 u32 bitset;
30 u64 time; 27 u64 time;
31 u32 *uaddr2; 28 u32 __user *uaddr2;
32 } futex; 29 } futex;
33 /* For nanosleep */ 30 /* For nanosleep */
34 struct { 31 struct {
35 clockid_t index; 32 clockid_t clockid;
36 struct timespec __user *rmtp; 33 struct timespec __user *rmtp;
37#ifdef CONFIG_COMPAT 34#ifdef CONFIG_COMPAT
38 struct compat_timespec __user *compat_rmtp; 35 struct compat_timespec __user *compat_rmtp;
diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
new file mode 100644
index 000000000000..b004e557caa9
--- /dev/null
+++ b/include/linux/ti_wilink_st.h
@@ -0,0 +1,423 @@
1/*
2 * Shared Transport Header file
3 * To be included by the protocol stack drivers for
4 * Texas Instruments BT,FM and GPS combo chip drivers
5 * and also serves the sub-modules of the shared transport driver.
6 *
7 * Copyright (C) 2009-2010 Texas Instruments
8 * Author: Pavan Savoy <pavan_savoy@ti.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifndef TI_WILINK_ST_H
26#define TI_WILINK_ST_H
27
28/**
29 * enum proto-type - The protocol on WiLink chips which share a
30 * common physical interface like UART.
31 */
32enum proto_type {
33 ST_BT,
34 ST_FM,
35 ST_GPS,
36 ST_MAX_CHANNELS = 16,
37};
38
39/**
40 * struct st_proto_s - Per Protocol structure from BT/FM/GPS to ST
41 * @type: type of the protocol being registered among the
42 * available proto_type(BT, FM, GPS the protocol which share TTY).
43 * @recv: the receiver callback pointing to a function in the
44 * protocol drivers called by the ST driver upon receiving
45 * relevant data.
46 * @match_packet: reserved for future use, to make ST more generic
47 * @reg_complete_cb: callback handler pointing to a function in protocol
48 * handler called by ST when the pending registrations are complete.
49 * The registrations are marked pending, in situations when fw
50 * download is in progress.
51 * @write: pointer to function in ST provided to protocol drivers from ST,
52 * to be made use when protocol drivers have data to send to TTY.
53 * @priv_data: privdate data holder for the protocol drivers, sent
54 * from the protocol drivers during registration, and sent back on
55 * reg_complete_cb and recv.
56 * @chnl_id: channel id the protocol driver is interested in, the channel
57 * id is nothing but the 1st byte of the packet in UART frame.
58 * @max_frame_size: size of the largest frame the protocol can receive.
59 * @hdr_len: length of the header structure of the protocol.
60 * @offset_len_in_hdr: this provides the offset of the length field in the
61 * header structure of the protocol header, to assist ST to know
62 * how much to receive, if the data is split across UART frames.
63 * @len_size: whether the length field inside the header is 2 bytes
64 * or 1 byte.
65 * @reserve: the number of bytes ST needs to reserve in the skb being
66 * prepared for the protocol driver.
67 */
68struct st_proto_s {
69 enum proto_type type;
70 long (*recv) (void *, struct sk_buff *);
71 unsigned char (*match_packet) (const unsigned char *data);
72 void (*reg_complete_cb) (void *, char data);
73 long (*write) (struct sk_buff *skb);
74 void *priv_data;
75
76 unsigned char chnl_id;
77 unsigned short max_frame_size;
78 unsigned char hdr_len;
79 unsigned char offset_len_in_hdr;
80 unsigned char len_size;
81 unsigned char reserve;
82};
83
84extern long st_register(struct st_proto_s *);
85extern long st_unregister(struct st_proto_s *);
86
87
88/*
89 * header information used by st_core.c
90 */
91
92/* states of protocol list */
93#define ST_NOTEMPTY 1
94#define ST_EMPTY 0
95
96/*
97 * possible st_states
98 */
99#define ST_INITIALIZING 1
100#define ST_REG_IN_PROGRESS 2
101#define ST_REG_PENDING 3
102#define ST_WAITING_FOR_RESP 4
103
104/**
105 * struct st_data_s - ST core internal structure
106 * @st_state: different states of ST like initializing, registration
107 * in progress, this is mainly used to return relevant err codes
108 * when protocol drivers are registering. It is also used to track
109 * the recv function, as in during fw download only HCI events
110 * can occur , where as during other times other events CH8, CH9
111 * can occur.
112 * @tty: tty provided by the TTY core for line disciplines.
113 * @tx_skb: If for some reason the tty's write returns lesser bytes written
114 * then to maintain the rest of data to be written on next instance.
115 * This needs to be protected, hence the lock inside wakeup func.
116 * @tx_state: if the data is being written onto the TTY and protocol driver
117 * wants to send more, queue up data and mark that there is
118 * more data to send.
119 * @list: the list of protocols registered, only MAX can exist, one protocol
120 * can register only once.
121 * @rx_state: states to be maintained inside st's tty receive
122 * @rx_count: count to be maintained inside st's tty receieve
123 * @rx_skb: the skb where all data for a protocol gets accumulated,
124 * since tty might not call receive when a complete event packet
125 * is received, the states, count and the skb needs to be maintained.
126 * @rx_chnl: the channel ID for which the data is getting accumalated for.
127 * @txq: the list of skbs which needs to be sent onto the TTY.
128 * @tx_waitq: if the chip is not in AWAKE state, the skbs needs to be queued
129 * up in here, PM(WAKEUP_IND) data needs to be sent and then the skbs
130 * from waitq can be moved onto the txq.
131 * Needs locking too.
132 * @lock: the lock to protect skbs, queues, and ST states.
133 * @protos_registered: count of the protocols registered, also when 0 the
134 * chip enable gpio can be toggled, and when it changes to 1 the fw
135 * needs to be downloaded to initialize chip side ST.
136 * @ll_state: the various PM states the chip can be, the states are notified
137 * to us, when the chip sends relevant PM packets(SLEEP_IND, WAKE_IND).
138 * @kim_data: reference to the parent encapsulating structure.
139 *
140 */
141struct st_data_s {
142 unsigned long st_state;
143 struct sk_buff *tx_skb;
144#define ST_TX_SENDING 1
145#define ST_TX_WAKEUP 2
146 unsigned long tx_state;
147 struct st_proto_s *list[ST_MAX_CHANNELS];
148 bool is_registered[ST_MAX_CHANNELS];
149 unsigned long rx_state;
150 unsigned long rx_count;
151 struct sk_buff *rx_skb;
152 unsigned char rx_chnl;
153 struct sk_buff_head txq, tx_waitq;
154 spinlock_t lock;
155 unsigned char protos_registered;
156 unsigned long ll_state;
157 void *kim_data;
158 struct tty_struct *tty;
159};
160
161/*
162 * wrapper around tty->ops->write_room to check
163 * availability during firmware download
164 */
165int st_get_uart_wr_room(struct st_data_s *st_gdata);
166/**
167 * st_int_write -
168 * point this to tty->driver->write or tty->ops->write
169 * depending upon the kernel version
170 */
171int st_int_write(struct st_data_s*, const unsigned char*, int);
172
173/**
174 * st_write -
175 * internal write function, passed onto protocol drivers
176 * via the write function ptr of protocol struct
177 */
178long st_write(struct sk_buff *);
179
180/* function to be called from ST-LL */
181void st_ll_send_frame(enum proto_type, struct sk_buff *);
182
183/* internal wake up function */
184void st_tx_wakeup(struct st_data_s *st_data);
185
186/* init, exit entry funcs called from KIM */
187int st_core_init(struct st_data_s **);
188void st_core_exit(struct st_data_s *);
189
190/* ask for reference from KIM */
191void st_kim_ref(struct st_data_s **, int);
192
193#define GPS_STUB_TEST
194#ifdef GPS_STUB_TEST
195int gps_chrdrv_stub_write(const unsigned char*, int);
196void gps_chrdrv_stub_init(void);
197#endif
198
199/*
200 * header information used by st_kim.c
201 */
202
203/* time in msec to wait for
204 * line discipline to be installed
205 */
206#define LDISC_TIME 1000
207#define CMD_RESP_TIME 800
208#define CMD_WR_TIME 5000
209#define MAKEWORD(a, b) ((unsigned short)(((unsigned char)(a)) \
210 | ((unsigned short)((unsigned char)(b))) << 8))
211
212#define GPIO_HIGH 1
213#define GPIO_LOW 0
214
215/* the Power-On-Reset logic, requires to attempt
216 * to download firmware onto chip more than once
217 * since the self-test for chip takes a while
218 */
219#define POR_RETRY_COUNT 5
220
221/**
222 * struct chip_version - save the chip version
223 */
224struct chip_version {
225 unsigned short full;
226 unsigned short chip;
227 unsigned short min_ver;
228 unsigned short maj_ver;
229};
230
231#define UART_DEV_NAME_LEN 32
232/**
233 * struct kim_data_s - the KIM internal data, embedded as the
234 * platform's drv data. One for each ST device in the system.
235 * @uim_pid: KIM needs to communicate with UIM to request to install
236 * the ldisc by opening UART when protocol drivers register.
237 * @kim_pdev: the platform device added in one of the board-XX.c file
238 * in arch/XX/ directory, 1 for each ST device.
239 * @kim_rcvd: completion handler to notify when data was received,
240 * mainly used during fw download, which involves multiple send/wait
241 * for each of the HCI-VS commands.
242 * @ldisc_installed: completion handler to notify that the UIM accepted
243 * the request to install ldisc, notify from tty_open which suggests
244 * the ldisc was properly installed.
245 * @resp_buffer: data buffer for the .bts fw file name.
246 * @fw_entry: firmware class struct to request/release the fw.
247 * @rx_state: the rx state for kim's receive func during fw download.
248 * @rx_count: the rx count for the kim's receive func during fw download.
249 * @rx_skb: all of fw data might not come at once, and hence data storage for
250 * whole of the fw response, only HCI_EVENTs and hence diff from ST's
251 * response.
252 * @core_data: ST core's data, which mainly is the tty's disc_data
253 * @version: chip version available via a sysfs entry.
254 *
255 */
256struct kim_data_s {
257 long uim_pid;
258 struct platform_device *kim_pdev;
259 struct completion kim_rcvd, ldisc_installed;
260 char resp_buffer[30];
261 const struct firmware *fw_entry;
262 long nshutdown;
263 unsigned long rx_state;
264 unsigned long rx_count;
265 struct sk_buff *rx_skb;
266 struct st_data_s *core_data;
267 struct chip_version version;
268 unsigned char ldisc_install;
269 unsigned char dev_name[UART_DEV_NAME_LEN];
270 unsigned char flow_cntrl;
271 unsigned long baud_rate;
272};
273
274/**
275 * functions called when 1 of the protocol drivers gets
276 * registered, these need to communicate with UIM to request
277 * ldisc installed, read chip_version, download relevant fw
278 */
279long st_kim_start(void *);
280long st_kim_stop(void *);
281
282void st_kim_recv(void *, const unsigned char *, long count);
283void st_kim_complete(void *);
284void kim_st_list_protocols(struct st_data_s *, void *);
285
286/*
287 * BTS headers
288 */
289#define ACTION_SEND_COMMAND 1
290#define ACTION_WAIT_EVENT 2
291#define ACTION_SERIAL 3
292#define ACTION_DELAY 4
293#define ACTION_RUN_SCRIPT 5
294#define ACTION_REMARKS 6
295
296/**
297 * struct bts_header - the fw file is NOT binary which can
298 * be sent onto TTY as is. The .bts is more a script
299 * file which has different types of actions.
300 * Each such action needs to be parsed by the KIM and
301 * relevant procedure to be called.
302 */
303struct bts_header {
304 u32 magic;
305 u32 version;
306 u8 future[24];
307 u8 actions[0];
308} __attribute__ ((packed));
309
310/**
311 * struct bts_action - Each .bts action has its own type of
312 * data.
313 */
314struct bts_action {
315 u16 type;
316 u16 size;
317 u8 data[0];
318} __attribute__ ((packed));
319
320struct bts_action_send {
321 u8 data[0];
322} __attribute__ ((packed));
323
324struct bts_action_wait {
325 u32 msec;
326 u32 size;
327 u8 data[0];
328} __attribute__ ((packed));
329
330struct bts_action_delay {
331 u32 msec;
332} __attribute__ ((packed));
333
334struct bts_action_serial {
335 u32 baud;
336 u32 flow_control;
337} __attribute__ ((packed));
338
339/**
340 * struct hci_command - the HCI-VS for intrepreting
341 * the change baud rate of host-side UART, which
342 * needs to be ignored, since UIM would do that
343 * when it receives request from KIM for ldisc installation.
344 */
345struct hci_command {
346 u8 prefix;
347 u16 opcode;
348 u8 plen;
349 u32 speed;
350} __attribute__ ((packed));
351
352/*
353 * header information used by st_ll.c
354 */
355
356/* ST LL receiver states */
357#define ST_W4_PACKET_TYPE 0
358#define ST_W4_HEADER 1
359#define ST_W4_DATA 2
360
361/* ST LL state machines */
362#define ST_LL_ASLEEP 0
363#define ST_LL_ASLEEP_TO_AWAKE 1
364#define ST_LL_AWAKE 2
365#define ST_LL_AWAKE_TO_ASLEEP 3
366#define ST_LL_INVALID 4
367
368/* different PM notifications coming from chip */
369#define LL_SLEEP_IND 0x30
370#define LL_SLEEP_ACK 0x31
371#define LL_WAKE_UP_IND 0x32
372#define LL_WAKE_UP_ACK 0x33
373
374/* initialize and de-init ST LL */
375long st_ll_init(struct st_data_s *);
376long st_ll_deinit(struct st_data_s *);
377
378/**
379 * enable/disable ST LL along with KIM start/stop
380 * called by ST Core
381 */
382void st_ll_enable(struct st_data_s *);
383void st_ll_disable(struct st_data_s *);
384
385/**
386 * various funcs used by ST core to set/get the various PM states
387 * of the chip.
388 */
389unsigned long st_ll_getstate(struct st_data_s *);
390unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char);
391void st_ll_wakeup(struct st_data_s *);
392
393/*
394 * header information used by st_core.c for FM and GPS
395 * packet parsing, the bluetooth headers are already available
396 * at net/bluetooth/
397 */
398
399struct fm_event_hdr {
400 u8 plen;
401} __attribute__ ((packed));
402
403#define FM_MAX_FRAME_SIZE 0xFF /* TODO: */
404#define FM_EVENT_HDR_SIZE 1 /* size of fm_event_hdr */
405#define ST_FM_CH8_PKT 0x8
406
407/* gps stuff */
408struct gps_event_hdr {
409 u8 opcode;
410 u16 plen;
411} __attribute__ ((packed));
412
413/* platform data */
414struct ti_st_plat_data {
415 long nshutdown_gpio;
416 unsigned char dev_name[UART_DEV_NAME_LEN]; /* uart name */
417 unsigned char flow_cntrl; /* flow control flag */
418 unsigned long baud_rate;
419 int (*suspend)(struct platform_device *, pm_message_t);
420 int (*resume)(struct platform_device *);
421};
422
423#endif /* TI_WILINK_ST_H */
diff --git a/include/linux/time.h b/include/linux/time.h
index 9f15ac7ab92a..b3061782dec3 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -113,8 +113,6 @@ static inline struct timespec timespec_sub(struct timespec lhs,
113#define timespec_valid(ts) \ 113#define timespec_valid(ts) \
114 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC)) 114 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC))
115 115
116extern seqlock_t xtime_lock;
117
118extern void read_persistent_clock(struct timespec *ts); 116extern void read_persistent_clock(struct timespec *ts);
119extern void read_boot_clock(struct timespec *ts); 117extern void read_boot_clock(struct timespec *ts);
120extern int update_persistent_clock(struct timespec now); 118extern int update_persistent_clock(struct timespec now);
@@ -125,8 +123,10 @@ extern int timekeeping_suspended;
125unsigned long get_seconds(void); 123unsigned long get_seconds(void);
126struct timespec current_kernel_time(void); 124struct timespec current_kernel_time(void);
127struct timespec __current_kernel_time(void); /* does not take xtime_lock */ 125struct timespec __current_kernel_time(void); /* does not take xtime_lock */
128struct timespec __get_wall_to_monotonic(void); /* does not take xtime_lock */
129struct timespec get_monotonic_coarse(void); 126struct timespec get_monotonic_coarse(void);
127void get_xtime_and_monotonic_and_sleep_offset(struct timespec *xtim,
128 struct timespec *wtom, struct timespec *sleep);
129void timekeeping_inject_sleeptime(struct timespec *delta);
130 130
131#define CURRENT_TIME (current_kernel_time()) 131#define CURRENT_TIME (current_kernel_time())
132#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) 132#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })
@@ -147,8 +147,9 @@ static inline u32 arch_gettimeoffset(void) { return 0; }
147#endif 147#endif
148 148
149extern void do_gettimeofday(struct timeval *tv); 149extern void do_gettimeofday(struct timeval *tv);
150extern int do_settimeofday(struct timespec *tv); 150extern int do_settimeofday(const struct timespec *tv);
151extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz); 151extern int do_sys_settimeofday(const struct timespec *tv,
152 const struct timezone *tz);
152#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) 153#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts)
153extern long do_utimes(int dfd, const char __user *filename, struct timespec *times, int flags); 154extern long do_utimes(int dfd, const char __user *filename, struct timespec *times, int flags);
154struct itimerval; 155struct itimerval;
@@ -158,14 +159,17 @@ extern unsigned int alarm_setitimer(unsigned int seconds);
158extern int do_getitimer(int which, struct itimerval *value); 159extern int do_getitimer(int which, struct itimerval *value);
159extern void getnstimeofday(struct timespec *tv); 160extern void getnstimeofday(struct timespec *tv);
160extern void getrawmonotonic(struct timespec *ts); 161extern void getrawmonotonic(struct timespec *ts);
162extern void getnstime_raw_and_real(struct timespec *ts_raw,
163 struct timespec *ts_real);
161extern void getboottime(struct timespec *ts); 164extern void getboottime(struct timespec *ts);
162extern void monotonic_to_bootbased(struct timespec *ts); 165extern void monotonic_to_bootbased(struct timespec *ts);
166extern void get_monotonic_boottime(struct timespec *ts);
163 167
164extern struct timespec timespec_trunc(struct timespec t, unsigned gran); 168extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
165extern int timekeeping_valid_for_hres(void); 169extern int timekeeping_valid_for_hres(void);
166extern u64 timekeeping_max_deferment(void); 170extern u64 timekeeping_max_deferment(void);
167extern void update_wall_time(void);
168extern void timekeeping_leap_insert(int leapsecond); 171extern void timekeeping_leap_insert(int leapsecond);
172extern int timekeeping_inject_offset(struct timespec *ts);
169 173
170struct tms; 174struct tms;
171extern void do_sys_times(struct tms *); 175extern void do_sys_times(struct tms *);
@@ -290,6 +294,9 @@ struct itimerval {
290#define CLOCK_MONOTONIC_RAW 4 294#define CLOCK_MONOTONIC_RAW 4
291#define CLOCK_REALTIME_COARSE 5 295#define CLOCK_REALTIME_COARSE 5
292#define CLOCK_MONOTONIC_COARSE 6 296#define CLOCK_MONOTONIC_COARSE 6
297#define CLOCK_BOOTTIME 7
298#define CLOCK_REALTIME_ALARM 8
299#define CLOCK_BOOTTIME_ALARM 9
293 300
294/* 301/*
295 * The IDs of various hardware clocks: 302 * The IDs of various hardware clocks:
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 38cf093ef62c..6abd9138beda 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -24,9 +24,9 @@ struct timer_list {
24 int slack; 24 int slack;
25 25
26#ifdef CONFIG_TIMER_STATS 26#ifdef CONFIG_TIMER_STATS
27 int start_pid;
27 void *start_site; 28 void *start_site;
28 char start_comm[16]; 29 char start_comm[16];
29 int start_pid;
30#endif 30#endif
31#ifdef CONFIG_LOCKDEP 31#ifdef CONFIG_LOCKDEP
32 struct lockdep_map lockdep_map; 32 struct lockdep_map lockdep_map;
@@ -48,12 +48,38 @@ extern struct tvec_base boot_tvec_bases;
48#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn) 48#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
49#endif 49#endif
50 50
51/*
52 * Note that all tvec_bases are 2 byte aligned and lower bit of
53 * base in timer_list is guaranteed to be zero. Use the LSB to
54 * indicate whether the timer is deferrable.
55 *
56 * A deferrable timer will work normally when the system is busy, but
57 * will not cause a CPU to come out of idle just to service it; instead,
58 * the timer will be serviced when the CPU eventually wakes up with a
59 * subsequent non-deferrable timer.
60 */
61#define TBASE_DEFERRABLE_FLAG (0x1)
62
51#define TIMER_INITIALIZER(_function, _expires, _data) { \ 63#define TIMER_INITIALIZER(_function, _expires, _data) { \
52 .entry = { .prev = TIMER_ENTRY_STATIC }, \ 64 .entry = { .prev = TIMER_ENTRY_STATIC }, \
53 .function = (_function), \ 65 .function = (_function), \
54 .expires = (_expires), \ 66 .expires = (_expires), \
55 .data = (_data), \ 67 .data = (_data), \
56 .base = &boot_tvec_bases, \ 68 .base = &boot_tvec_bases, \
69 .slack = -1, \
70 __TIMER_LOCKDEP_MAP_INITIALIZER( \
71 __FILE__ ":" __stringify(__LINE__)) \
72 }
73
74#define TBASE_MAKE_DEFERRED(ptr) ((struct tvec_base *) \
75 ((unsigned char *)(ptr) + TBASE_DEFERRABLE_FLAG))
76
77#define TIMER_DEFERRED_INITIALIZER(_function, _expires, _data) {\
78 .entry = { .prev = TIMER_ENTRY_STATIC }, \
79 .function = (_function), \
80 .expires = (_expires), \
81 .data = (_data), \
82 .base = TBASE_MAKE_DEFERRED(&boot_tvec_bases), \
57 __TIMER_LOCKDEP_MAP_INITIALIZER( \ 83 __TIMER_LOCKDEP_MAP_INITIALIZER( \
58 __FILE__ ":" __stringify(__LINE__)) \ 84 __FILE__ ":" __stringify(__LINE__)) \
59 } 85 }
@@ -248,11 +274,11 @@ static inline void timer_stats_timer_clear_start_info(struct timer_list *timer)
248 274
249extern void add_timer(struct timer_list *timer); 275extern void add_timer(struct timer_list *timer);
250 276
277extern int try_to_del_timer_sync(struct timer_list *timer);
278
251#ifdef CONFIG_SMP 279#ifdef CONFIG_SMP
252 extern int try_to_del_timer_sync(struct timer_list *timer);
253 extern int del_timer_sync(struct timer_list *timer); 280 extern int del_timer_sync(struct timer_list *timer);
254#else 281#else
255# define try_to_del_timer_sync(t) del_timer(t)
256# define del_timer_sync(t) del_timer(t) 282# define del_timer_sync(t) del_timer(t)
257#endif 283#endif
258 284
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
index 2d0792983f8c..d3b57fa12225 100644
--- a/include/linux/timerfd.h
+++ b/include/linux/timerfd.h
@@ -19,6 +19,7 @@
19 * shared O_* flags. 19 * shared O_* flags.
20 */ 20 */
21#define TFD_TIMER_ABSTIME (1 << 0) 21#define TFD_TIMER_ABSTIME (1 << 0)
22#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
22#define TFD_CLOEXEC O_CLOEXEC 23#define TFD_CLOEXEC O_CLOEXEC
23#define TFD_NONBLOCK O_NONBLOCK 24#define TFD_NONBLOCK O_NONBLOCK
24 25
@@ -26,6 +27,6 @@
26/* Flags for timerfd_create. */ 27/* Flags for timerfd_create. */
27#define TFD_CREATE_FLAGS TFD_SHARED_FCNTL_FLAGS 28#define TFD_CREATE_FLAGS TFD_SHARED_FCNTL_FLAGS
28/* Flags for timerfd_settime. */ 29/* Flags for timerfd_settime. */
29#define TFD_SETTIME_FLAGS TFD_TIMER_ABSTIME 30#define TFD_SETTIME_FLAGS (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET)
30 31
31#endif /* _LINUX_TIMERFD_H */ 32#endif /* _LINUX_TIMERFD_H */
diff --git a/include/linux/timerqueue.h b/include/linux/timerqueue.h
new file mode 100644
index 000000000000..5088727478fd
--- /dev/null
+++ b/include/linux/timerqueue.h
@@ -0,0 +1,50 @@
1#ifndef _LINUX_TIMERQUEUE_H
2#define _LINUX_TIMERQUEUE_H
3
4#include <linux/rbtree.h>
5#include <linux/ktime.h>
6
7
8struct timerqueue_node {
9 struct rb_node node;
10 ktime_t expires;
11};
12
13struct timerqueue_head {
14 struct rb_root head;
15 struct timerqueue_node *next;
16};
17
18
19extern void timerqueue_add(struct timerqueue_head *head,
20 struct timerqueue_node *node);
21extern void timerqueue_del(struct timerqueue_head *head,
22 struct timerqueue_node *node);
23extern struct timerqueue_node *timerqueue_iterate_next(
24 struct timerqueue_node *node);
25
26/**
27 * timerqueue_getnext - Returns the timer with the earliest expiration time
28 *
29 * @head: head of timerqueue
30 *
31 * Returns a pointer to the timer node that has the
32 * earliest expiration time.
33 */
34static inline
35struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head)
36{
37 return head->next;
38}
39
40static inline void timerqueue_init(struct timerqueue_node *node)
41{
42 rb_init_node(&node->node);
43}
44
45static inline void timerqueue_init_head(struct timerqueue_head *head)
46{
47 head->head = RB_ROOT;
48 head->next = NULL;
49}
50#endif /* _LINUX_TIMERQUEUE_H */
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 32d852f8cbe4..aa60fe7b6ed6 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -73,7 +73,7 @@ struct timex {
73 long tolerance; /* clock frequency tolerance (ppm) 73 long tolerance; /* clock frequency tolerance (ppm)
74 * (read only) 74 * (read only)
75 */ 75 */
76 struct timeval time; /* (read only) */ 76 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */
77 long tick; /* (modified) usecs between clock ticks */ 77 long tick; /* (modified) usecs between clock ticks */
78 78
79 long ppsfreq; /* pps frequency (scaled ppm) (ro) */ 79 long ppsfreq; /* pps frequency (scaled ppm) (ro) */
@@ -102,6 +102,7 @@ struct timex {
102#define ADJ_STATUS 0x0010 /* clock status */ 102#define ADJ_STATUS 0x0010 /* clock status */
103#define ADJ_TIMECONST 0x0020 /* pll time constant */ 103#define ADJ_TIMECONST 0x0020 /* pll time constant */
104#define ADJ_TAI 0x0080 /* set TAI offset */ 104#define ADJ_TAI 0x0080 /* set TAI offset */
105#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
105#define ADJ_MICRO 0x1000 /* select microsecond resolution */ 106#define ADJ_MICRO 0x1000 /* select microsecond resolution */
106#define ADJ_NANO 0x2000 /* select nanosecond resolution */ 107#define ADJ_NANO 0x2000 /* select nanosecond resolution */
107#define ADJ_TICK 0x4000 /* tick value */ 108#define ADJ_TICK 0x4000 /* tick value */
@@ -268,6 +269,7 @@ extern u64 tick_length;
268extern void second_overflow(void); 269extern void second_overflow(void);
269extern void update_ntp_one_tick(void); 270extern void update_ntp_one_tick(void);
270extern int do_adjtimex(struct timex *); 271extern int do_adjtimex(struct timex *);
272extern void hardpps(const struct timespec *, const struct timespec *);
271 273
272int read_current_timer(unsigned long *timer_val); 274int read_current_timer(unsigned long *timer_val);
273 275
diff --git a/include/linux/tipc.h b/include/linux/tipc.h
index 181c8d0e6f73..f2d90091cc20 100644
--- a/include/linux/tipc.h
+++ b/include/linux/tipc.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * include/linux/tipc.h: Include file for TIPC socket interface 2 * include/linux/tipc.h: Include file for TIPC socket interface
3 * 3 *
4 * Copyright (c) 2003-2006, Ericsson AB 4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005, 2010-2011, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@
42/* 42/*
43 * TIPC addressing primitives 43 * TIPC addressing primitives
44 */ 44 */
45 45
46struct tipc_portid { 46struct tipc_portid {
47 __u32 ref; 47 __u32 ref;
48 __u32 node; 48 __u32 node;
@@ -89,7 +89,7 @@ static inline unsigned int tipc_node(__u32 addr)
89#define TIPC_TOP_SRV 1 /* topology service name type */ 89#define TIPC_TOP_SRV 1 /* topology service name type */
90#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */ 90#define TIPC_RESERVED_TYPES 64 /* lowest user-publishable name type */
91 91
92/* 92/*
93 * Publication scopes when binding port names and port name sequences 93 * Publication scopes when binding port names and port name sequences
94 */ 94 */
95 95
@@ -101,7 +101,7 @@ static inline unsigned int tipc_node(__u32 addr)
101 * Limiting values for messages 101 * Limiting values for messages
102 */ 102 */
103 103
104#define TIPC_MAX_USER_MSG_SIZE 66000 104#define TIPC_MAX_USER_MSG_SIZE 66000U
105 105
106/* 106/*
107 * Message importance levels 107 * Message importance levels
@@ -112,7 +112,7 @@ static inline unsigned int tipc_node(__u32 addr)
112#define TIPC_HIGH_IMPORTANCE 2 112#define TIPC_HIGH_IMPORTANCE 2
113#define TIPC_CRITICAL_IMPORTANCE 3 113#define TIPC_CRITICAL_IMPORTANCE 3
114 114
115/* 115/*
116 * Msg rejection/connection shutdown reasons 116 * Msg rejection/connection shutdown reasons
117 */ 117 */
118 118
@@ -127,17 +127,17 @@ static inline unsigned int tipc_node(__u32 addr)
127 * TIPC topology subscription service definitions 127 * TIPC topology subscription service definitions
128 */ 128 */
129 129
130#define TIPC_SUB_SERVICE 0x00 /* Filter for service availability */ 130#define TIPC_SUB_PORTS 0x01 /* filter for port availability */
131#define TIPC_SUB_PORTS 0x01 /* Filter for port availability */ 131#define TIPC_SUB_SERVICE 0x02 /* filter for service availability */
132#define TIPC_SUB_CANCEL 0x04 /* Cancel a subscription */ 132#define TIPC_SUB_CANCEL 0x04 /* cancel a subscription */
133 133
134#define TIPC_WAIT_FOREVER ~0 /* timeout for permanent subscription */ 134#define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */
135 135
136struct tipc_subscr { 136struct tipc_subscr {
137 struct tipc_name_seq seq; /* NBO. Name sequence of interest */ 137 struct tipc_name_seq seq; /* name sequence of interest */
138 __u32 timeout; /* NBO. Subscription duration (in ms) */ 138 __u32 timeout; /* subscription duration (in ms) */
139 __u32 filter; /* NBO. Bitmask of filter options */ 139 __u32 filter; /* bitmask of filter options */
140 char usr_handle[8]; /* Opaque. Available for subscriber use */ 140 char usr_handle[8]; /* available for subscriber use */
141}; 141};
142 142
143#define TIPC_PUBLISHED 1 /* publication event */ 143#define TIPC_PUBLISHED 1 /* publication event */
@@ -145,11 +145,11 @@ struct tipc_subscr {
145#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */ 145#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */
146 146
147struct tipc_event { 147struct tipc_event {
148 __u32 event; /* NBO. Event type, as defined above */ 148 __u32 event; /* event type */
149 __u32 found_lower; /* NBO. Matching name seq instances */ 149 __u32 found_lower; /* matching name seq instances */
150 __u32 found_upper; /* " " " " " */ 150 __u32 found_upper; /* " " " " */
151 struct tipc_portid port; /* NBO. Associated port */ 151 struct tipc_portid port; /* associated port */
152 struct tipc_subscr s; /* Original, associated subscription */ 152 struct tipc_subscr s; /* associated subscription */
153}; 153};
154 154
155/* 155/*
diff --git a/include/linux/tipc_config.h b/include/linux/tipc_config.h
index 9cde86c32412..0db239590b4d 100644
--- a/include/linux/tipc_config.h
+++ b/include/linux/tipc_config.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * include/linux/tipc_config.h: Include file for TIPC configuration interface 2 * include/linux/tipc_config.h: Include file for TIPC configuration interface
3 * 3 *
4 * Copyright (c) 2003-2006, Ericsson AB 4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005-2007, Wind River Systems 5 * Copyright (c) 2005-2007, 2010-2011, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -54,19 +54,19 @@
54 * which specify parameters or results for the operation. 54 * which specify parameters or results for the operation.
55 * 55 *
56 * For many operations, the request and reply messages have a fixed number 56 * For many operations, the request and reply messages have a fixed number
57 * of TLVs (usually zero or one); however, some reply messages may return 57 * of TLVs (usually zero or one); however, some reply messages may return
58 * a variable number of TLVs. A failed request is denoted by the presence 58 * a variable number of TLVs. A failed request is denoted by the presence
59 * of an "error string" TLV in the reply message instead of the TLV(s) the 59 * of an "error string" TLV in the reply message instead of the TLV(s) the
60 * reply should contain if the request succeeds. 60 * reply should contain if the request succeeds.
61 */ 61 */
62 62
63/* 63/*
64 * Public commands: 64 * Public commands:
65 * May be issued by any process. 65 * May be issued by any process.
66 * Accepted by own node, or by remote node only if remote management enabled. 66 * Accepted by own node, or by remote node only if remote management enabled.
67 */ 67 */
68 68
69#define TIPC_CMD_NOOP 0x0000 /* tx none, rx none */ 69#define TIPC_CMD_NOOP 0x0000 /* tx none, rx none */
70#define TIPC_CMD_GET_NODES 0x0001 /* tx net_addr, rx node_info(s) */ 70#define TIPC_CMD_GET_NODES 0x0001 /* tx net_addr, rx node_info(s) */
71#define TIPC_CMD_GET_MEDIA_NAMES 0x0002 /* tx none, rx media_name(s) */ 71#define TIPC_CMD_GET_MEDIA_NAMES 0x0002 /* tx none, rx media_name(s) */
72#define TIPC_CMD_GET_BEARER_NAMES 0x0003 /* tx none, rx bearer_name(s) */ 72#define TIPC_CMD_GET_BEARER_NAMES 0x0003 /* tx none, rx bearer_name(s) */
@@ -76,28 +76,21 @@
76#define TIPC_CMD_SHOW_LINK_STATS 0x000B /* tx link_name, rx ultra_string */ 76#define TIPC_CMD_SHOW_LINK_STATS 0x000B /* tx link_name, rx ultra_string */
77#define TIPC_CMD_SHOW_STATS 0x000F /* tx unsigned, rx ultra_string */ 77#define TIPC_CMD_SHOW_STATS 0x000F /* tx unsigned, rx ultra_string */
78 78
79#if 0 79/*
80#define TIPC_CMD_SHOW_PORT_STATS 0x0008 /* tx port_ref, rx ultra_string */
81#define TIPC_CMD_RESET_PORT_STATS 0x0009 /* tx port_ref, rx none */
82#define TIPC_CMD_GET_ROUTES 0x000A /* tx ?, rx ? */
83#define TIPC_CMD_GET_LINK_PEER 0x000D /* tx link_name, rx ? */
84#endif
85
86/*
87 * Protected commands: 80 * Protected commands:
88 * May only be issued by "network administration capable" process. 81 * May only be issued by "network administration capable" process.
89 * Accepted by own node, or by remote node only if remote management enabled 82 * Accepted by own node, or by remote node only if remote management enabled
90 * and this node is zone manager. 83 * and this node is zone manager.
91 */ 84 */
92 85
93#define TIPC_CMD_GET_REMOTE_MNG 0x4003 /* tx none, rx unsigned */ 86#define TIPC_CMD_GET_REMOTE_MNG 0x4003 /* tx none, rx unsigned */
94#define TIPC_CMD_GET_MAX_PORTS 0x4004 /* tx none, rx unsigned */ 87#define TIPC_CMD_GET_MAX_PORTS 0x4004 /* tx none, rx unsigned */
95#define TIPC_CMD_GET_MAX_PUBL 0x4005 /* tx none, rx unsigned */ 88#define TIPC_CMD_GET_MAX_PUBL 0x4005 /* tx none, rx unsigned */
96#define TIPC_CMD_GET_MAX_SUBSCR 0x4006 /* tx none, rx unsigned */ 89#define TIPC_CMD_GET_MAX_SUBSCR 0x4006 /* tx none, rx unsigned */
97#define TIPC_CMD_GET_MAX_ZONES 0x4007 /* tx none, rx unsigned */ 90#define TIPC_CMD_GET_MAX_ZONES 0x4007 /* obsoleted */
98#define TIPC_CMD_GET_MAX_CLUSTERS 0x4008 /* tx none, rx unsigned */ 91#define TIPC_CMD_GET_MAX_CLUSTERS 0x4008 /* obsoleted */
99#define TIPC_CMD_GET_MAX_NODES 0x4009 /* tx none, rx unsigned */ 92#define TIPC_CMD_GET_MAX_NODES 0x4009 /* obsoleted */
100#define TIPC_CMD_GET_MAX_SLAVES 0x400A /* tx none, rx unsigned */ 93#define TIPC_CMD_GET_MAX_SLAVES 0x400A /* obsoleted */
101#define TIPC_CMD_GET_NETID 0x400B /* tx none, rx unsigned */ 94#define TIPC_CMD_GET_NETID 0x400B /* tx none, rx unsigned */
102 95
103#define TIPC_CMD_ENABLE_BEARER 0x4101 /* tx bearer_config, rx none */ 96#define TIPC_CMD_ENABLE_BEARER 0x4101 /* tx bearer_config, rx none */
@@ -109,31 +102,21 @@
109#define TIPC_CMD_DUMP_LOG 0x410B /* tx none, rx ultra_string */ 102#define TIPC_CMD_DUMP_LOG 0x410B /* tx none, rx ultra_string */
110#define TIPC_CMD_RESET_LINK_STATS 0x410C /* tx link_name, rx none */ 103#define TIPC_CMD_RESET_LINK_STATS 0x410C /* tx link_name, rx none */
111 104
112#if 0 105/*
113#define TIPC_CMD_CREATE_LINK 0x4103 /* tx link_create, rx none */
114#define TIPC_CMD_REMOVE_LINK 0x4104 /* tx link_name, rx none */
115#define TIPC_CMD_BLOCK_LINK 0x4105 /* tx link_name, rx none */
116#define TIPC_CMD_UNBLOCK_LINK 0x4106 /* tx link_name, rx none */
117#endif
118
119/*
120 * Private commands: 106 * Private commands:
121 * May only be issued by "network administration capable" process. 107 * May only be issued by "network administration capable" process.
122 * Accepted by own node only; cannot be used on a remote node. 108 * Accepted by own node only; cannot be used on a remote node.
123 */ 109 */
124 110
125#define TIPC_CMD_SET_NODE_ADDR 0x8001 /* tx net_addr, rx none */ 111#define TIPC_CMD_SET_NODE_ADDR 0x8001 /* tx net_addr, rx none */
126#if 0
127#define TIPC_CMD_SET_ZONE_MASTER 0x8002 /* tx none, rx none */
128#endif
129#define TIPC_CMD_SET_REMOTE_MNG 0x8003 /* tx unsigned, rx none */ 112#define TIPC_CMD_SET_REMOTE_MNG 0x8003 /* tx unsigned, rx none */
130#define TIPC_CMD_SET_MAX_PORTS 0x8004 /* tx unsigned, rx none */ 113#define TIPC_CMD_SET_MAX_PORTS 0x8004 /* tx unsigned, rx none */
131#define TIPC_CMD_SET_MAX_PUBL 0x8005 /* tx unsigned, rx none */ 114#define TIPC_CMD_SET_MAX_PUBL 0x8005 /* tx unsigned, rx none */
132#define TIPC_CMD_SET_MAX_SUBSCR 0x8006 /* tx unsigned, rx none */ 115#define TIPC_CMD_SET_MAX_SUBSCR 0x8006 /* tx unsigned, rx none */
133#define TIPC_CMD_SET_MAX_ZONES 0x8007 /* tx unsigned, rx none */ 116#define TIPC_CMD_SET_MAX_ZONES 0x8007 /* obsoleted */
134#define TIPC_CMD_SET_MAX_CLUSTERS 0x8008 /* tx unsigned, rx none */ 117#define TIPC_CMD_SET_MAX_CLUSTERS 0x8008 /* obsoleted */
135#define TIPC_CMD_SET_MAX_NODES 0x8009 /* tx unsigned, rx none */ 118#define TIPC_CMD_SET_MAX_NODES 0x8009 /* obsoleted */
136#define TIPC_CMD_SET_MAX_SLAVES 0x800A /* tx unsigned, rx none */ 119#define TIPC_CMD_SET_MAX_SLAVES 0x800A /* obsoleted */
137#define TIPC_CMD_SET_NETID 0x800B /* tx unsigned, rx none */ 120#define TIPC_CMD_SET_NETID 0x800B /* tx unsigned, rx none */
138 121
139/* 122/*
@@ -156,20 +139,20 @@
156#define TIPC_TLV_ULTRA_STRING 5 /* char[32768] (max) */ 139#define TIPC_TLV_ULTRA_STRING 5 /* char[32768] (max) */
157 140
158#define TIPC_TLV_ERROR_STRING 16 /* char[128] containing "error code" */ 141#define TIPC_TLV_ERROR_STRING 16 /* char[128] containing "error code" */
159#define TIPC_TLV_NET_ADDR 17 /* 32-bit integer denoting <Z.C.N> */ 142#define TIPC_TLV_NET_ADDR 17 /* 32-bit integer denoting <Z.C.N> */
160#define TIPC_TLV_MEDIA_NAME 18 /* char[TIPC_MAX_MEDIA_NAME] */ 143#define TIPC_TLV_MEDIA_NAME 18 /* char[TIPC_MAX_MEDIA_NAME] */
161#define TIPC_TLV_BEARER_NAME 19 /* char[TIPC_MAX_BEARER_NAME] */ 144#define TIPC_TLV_BEARER_NAME 19 /* char[TIPC_MAX_BEARER_NAME] */
162#define TIPC_TLV_LINK_NAME 20 /* char[TIPC_MAX_LINK_NAME] */ 145#define TIPC_TLV_LINK_NAME 20 /* char[TIPC_MAX_LINK_NAME] */
163#define TIPC_TLV_NODE_INFO 21 /* struct tipc_node_info */ 146#define TIPC_TLV_NODE_INFO 21 /* struct tipc_node_info */
164#define TIPC_TLV_LINK_INFO 22 /* struct tipc_link_info */ 147#define TIPC_TLV_LINK_INFO 22 /* struct tipc_link_info */
165#define TIPC_TLV_BEARER_CONFIG 23 /* struct tipc_bearer_config */ 148#define TIPC_TLV_BEARER_CONFIG 23 /* struct tipc_bearer_config */
166#define TIPC_TLV_LINK_CONFIG 24 /* struct tipc_link_config */ 149#define TIPC_TLV_LINK_CONFIG 24 /* struct tipc_link_config */
167#define TIPC_TLV_NAME_TBL_QUERY 25 /* struct tipc_name_table_query */ 150#define TIPC_TLV_NAME_TBL_QUERY 25 /* struct tipc_name_table_query */
168#define TIPC_TLV_PORT_REF 26 /* 32-bit port reference */ 151#define TIPC_TLV_PORT_REF 26 /* 32-bit port reference */
169 152
170/* 153/*
171 * Maximum sizes of TIPC bearer-related names (including terminating NUL) 154 * Maximum sizes of TIPC bearer-related names (including terminating NUL)
172 */ 155 */
173 156
174#define TIPC_MAX_MEDIA_NAME 16 /* format = media */ 157#define TIPC_MAX_MEDIA_NAME 16 /* format = media */
175#define TIPC_MAX_IF_NAME 16 /* format = interface */ 158#define TIPC_MAX_IF_NAME 16 /* format = interface */
@@ -193,6 +176,10 @@
193#define TIPC_DEF_LINK_TOL 1500 176#define TIPC_DEF_LINK_TOL 1500
194#define TIPC_MAX_LINK_TOL 30000 177#define TIPC_MAX_LINK_TOL 30000
195 178
179#if (TIPC_MIN_LINK_TOL < 16)
180#error "TIPC_MIN_LINK_TOL is too small (abort limit may be NaN)"
181#endif
182
196/* 183/*
197 * Link window limits (min, default, max), in packets 184 * Link window limits (min, default, max), in packets
198 */ 185 */
@@ -215,7 +202,7 @@ struct tipc_link_info {
215 202
216struct tipc_bearer_config { 203struct tipc_bearer_config {
217 __be32 priority; /* Range [1,31]. Override per link */ 204 __be32 priority; /* Range [1,31]. Override per link */
218 __be32 detect_scope; 205 __be32 disc_domain; /* <Z.C.N> describing desired nodes */
219 char name[TIPC_MAX_BEARER_NAME]; 206 char name[TIPC_MAX_BEARER_NAME];
220}; 207};
221 208
@@ -234,7 +221,7 @@ struct tipc_name_table_query {
234}; 221};
235 222
236/* 223/*
237 * The error string TLV is a null-terminated string describing the cause 224 * The error string TLV is a null-terminated string describing the cause
238 * of the request failure. To simplify error processing (and to save space) 225 * of the request failure. To simplify error processing (and to save space)
239 * the first character of the string can be a special error code character 226 * the first character of the string can be a special error code character
240 * (lying by the range 0x80 to 0xFF) which represents a pre-defined reason. 227 * (lying by the range 0x80 to 0xFF) which represents a pre-defined reason.
@@ -247,23 +234,9 @@ struct tipc_name_table_query {
247#define TIPC_CFG_NOT_SUPPORTED "\x84" /* request is not supported by TIPC */ 234#define TIPC_CFG_NOT_SUPPORTED "\x84" /* request is not supported by TIPC */
248#define TIPC_CFG_INVALID_VALUE "\x85" /* request has invalid argument value */ 235#define TIPC_CFG_INVALID_VALUE "\x85" /* request has invalid argument value */
249 236
250#if 0
251/* prototypes TLV structures for proposed commands */
252struct tipc_link_create {
253 __u32 domain;
254 struct tipc_media_addr peer_addr;
255 char bearer_name[TIPC_MAX_BEARER_NAME];
256};
257
258struct tipc_route_info {
259 __u32 dest;
260 __u32 router;
261};
262#endif
263
264/* 237/*
265 * A TLV consists of a descriptor, followed by the TLV value. 238 * A TLV consists of a descriptor, followed by the TLV value.
266 * TLV descriptor fields are stored in network byte order; 239 * TLV descriptor fields are stored in network byte order;
267 * TLV values must also be stored in network byte order (where applicable). 240 * TLV values must also be stored in network byte order (where applicable).
268 * TLV descriptors must be aligned to addresses which are multiple of 4, 241 * TLV descriptors must be aligned to addresses which are multiple of 4,
269 * so up to 3 bytes of padding may exist at the end of the TLV value area. 242 * so up to 3 bytes of padding may exist at the end of the TLV value area.
@@ -299,7 +272,7 @@ static inline int TLV_OK(const void *tlv, __u16 space)
299 272
300static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type) 273static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)
301{ 274{
302 return TLV_OK(tlv, space) && 275 return TLV_OK(tlv, space) &&
303 (ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type); 276 (ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
304} 277}
305 278
@@ -318,7 +291,7 @@ static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
318} 291}
319 292
320/* 293/*
321 * A TLV list descriptor simplifies processing of messages 294 * A TLV list descriptor simplifies processing of messages
322 * containing multiple TLVs. 295 * containing multiple TLVs.
323 */ 296 */
324 297
@@ -327,15 +300,15 @@ struct tlv_list_desc {
327 __u32 tlv_space; /* # bytes from curr TLV to list end */ 300 __u32 tlv_space; /* # bytes from curr TLV to list end */
328}; 301};
329 302
330static inline void TLV_LIST_INIT(struct tlv_list_desc *list, 303static inline void TLV_LIST_INIT(struct tlv_list_desc *list,
331 void *data, __u32 space) 304 void *data, __u32 space)
332{ 305{
333 list->tlv_ptr = (struct tlv_desc *)data; 306 list->tlv_ptr = (struct tlv_desc *)data;
334 list->tlv_space = space; 307 list->tlv_space = space;
335} 308}
336 309
337static inline int TLV_LIST_EMPTY(struct tlv_list_desc *list) 310static inline int TLV_LIST_EMPTY(struct tlv_list_desc *list)
338{ 311{
339 return (list->tlv_space == 0); 312 return (list->tlv_space == 0);
340} 313}
341 314
@@ -353,7 +326,7 @@ static inline void TLV_LIST_STEP(struct tlv_list_desc *list)
353{ 326{
354 __u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len)); 327 __u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len));
355 328
356 list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space); 329 list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);
357 list->tlv_space -= tlv_space; 330 list->tlv_space -= tlv_space;
358} 331}
359 332
@@ -377,15 +350,14 @@ struct tipc_genlmsghdr {
377#define TIPC_GENL_HDRLEN NLMSG_ALIGN(sizeof(struct tipc_genlmsghdr)) 350#define TIPC_GENL_HDRLEN NLMSG_ALIGN(sizeof(struct tipc_genlmsghdr))
378 351
379/* 352/*
380 * Configuration messages exchanged via TIPC sockets use the TIPC configuration 353 * Configuration messages exchanged via TIPC sockets use the TIPC configuration
381 * message header, which is defined below. This structure is analogous 354 * message header, which is defined below. This structure is analogous
382 * to the Netlink message header, but fields are stored in network byte order 355 * to the Netlink message header, but fields are stored in network byte order
383 * and no padding is permitted between the header and the message data 356 * and no padding is permitted between the header and the message data
384 * that follows. 357 * that follows.
385 */ 358 */
386 359
387struct tipc_cfg_msg_hdr 360struct tipc_cfg_msg_hdr {
388{
389 __be32 tcm_len; /* Message length (including header) */ 361 __be32 tcm_len; /* Message length (including header) */
390 __be16 tcm_type; /* Command type */ 362 __be16 tcm_type; /* Command type */
391 __be16 tcm_flags; /* Additional flags */ 363 __be16 tcm_flags; /* Additional flags */
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 64e084ff5e5c..fc839bfa7935 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -60,7 +60,7 @@ int arch_update_cpu_topology(void);
60 * (in whatever arch specific measurement units returned by node_distance()) 60 * (in whatever arch specific measurement units returned by node_distance())
61 * then switch on zone reclaim on boot. 61 * then switch on zone reclaim on boot.
62 */ 62 */
63#define RECLAIM_DISTANCE 20 63#define RECLAIM_DISTANCE 30
64#endif 64#endif
65#ifndef PENALTY_FOR_NODE_WITH_CPUS 65#ifndef PENALTY_FOR_NODE_WITH_CPUS
66#define PENALTY_FOR_NODE_WITH_CPUS (1) 66#define PENALTY_FOR_NODE_WITH_CPUS (1)
@@ -201,6 +201,12 @@ int arch_update_cpu_topology(void);
201 .balance_interval = 64, \ 201 .balance_interval = 64, \
202} 202}
203 203
204#ifdef CONFIG_SCHED_BOOK
205#ifndef SD_BOOK_INIT
206#error Please define an appropriate SD_BOOK_INIT in include/asm/topology.h!!!
207#endif
208#endif /* CONFIG_SCHED_BOOK */
209
204#ifdef CONFIG_NUMA 210#ifdef CONFIG_NUMA
205#ifndef SD_NODE_INIT 211#ifndef SD_NODE_INIT
206#error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!! 212#error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!!
diff --git a/include/linux/toshiba.h b/include/linux/toshiba.h
index 6a7c4edf0e13..772dedbc3a22 100644
--- a/include/linux/toshiba.h
+++ b/include/linux/toshiba.h
@@ -33,6 +33,8 @@ typedef struct {
33 unsigned int edi __attribute__ ((packed)); 33 unsigned int edi __attribute__ ((packed));
34} SMMRegisters; 34} SMMRegisters;
35 35
36#ifdef __KERNEL__
36int tosh_smm(SMMRegisters *regs); 37int tosh_smm(SMMRegisters *regs);
38#endif /* __KERNEL__ */
37 39
38#endif 40#endif
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index ac5d1c1285d9..fdc718abf83b 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -31,6 +31,7 @@
31 31
32extern int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf); 32extern int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf);
33extern int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash); 33extern int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash);
34extern int tpm_send(u32 chip_num, void *cmd, size_t buflen);
34#else 35#else
35static inline int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf) { 36static inline int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf) {
36 return -ENODEV; 37 return -ENODEV;
@@ -38,5 +39,8 @@ static inline int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf) {
38static inline int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash) { 39static inline int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash) {
39 return -ENODEV; 40 return -ENODEV;
40} 41}
42static inline int tpm_send(u32 chip_num, void *cmd, size_t buflen) {
43 return -ENODEV;
44}
41#endif 45#endif
42#endif 46#endif
diff --git a/include/linux/tpm_command.h b/include/linux/tpm_command.h
new file mode 100644
index 000000000000..727512e249b5
--- /dev/null
+++ b/include/linux/tpm_command.h
@@ -0,0 +1,28 @@
1#ifndef __LINUX_TPM_COMMAND_H__
2#define __LINUX_TPM_COMMAND_H__
3
4/*
5 * TPM Command constants from specifications at
6 * http://www.trustedcomputinggroup.org
7 */
8
9/* Command TAGS */
10#define TPM_TAG_RQU_COMMAND 193
11#define TPM_TAG_RQU_AUTH1_COMMAND 194
12#define TPM_TAG_RQU_AUTH2_COMMAND 195
13#define TPM_TAG_RSP_COMMAND 196
14#define TPM_TAG_RSP_AUTH1_COMMAND 197
15#define TPM_TAG_RSP_AUTH2_COMMAND 198
16
17/* Command Ordinals */
18#define TPM_ORD_GETRANDOM 70
19#define TPM_ORD_OSAP 11
20#define TPM_ORD_OIAP 10
21#define TPM_ORD_SEAL 23
22#define TPM_ORD_UNSEAL 24
23
24/* Other constants */
25#define SRKHANDLE 0x40000000
26#define TPM_NONCE_SIZE 20
27
28#endif
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 10db0102a890..e95f5236611f 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -150,7 +150,7 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
150 * 150 *
151 * Return %LSM_UNSAFE_* bits applied to an exec because of tracing. 151 * Return %LSM_UNSAFE_* bits applied to an exec because of tracing.
152 * 152 *
153 * @task->cred_guard_mutex is held by the caller through the do_execve(). 153 * @task->signal->cred_guard_mutex is held by the caller through the do_execve().
154 */ 154 */
155static inline int tracehook_unsafe_exec(struct task_struct *task) 155static inline int tracehook_unsafe_exec(struct task_struct *task)
156{ 156{
@@ -169,7 +169,7 @@ static inline int tracehook_unsafe_exec(struct task_struct *task)
169 * tracehook_tracer_task - return the task that is tracing the given task 169 * tracehook_tracer_task - return the task that is tracing the given task
170 * @tsk: task to consider 170 * @tsk: task to consider
171 * 171 *
172 * Returns NULL if noone is tracing @task, or the &struct task_struct 172 * Returns NULL if no one is tracing @task, or the &struct task_struct
173 * pointer to its tracer. 173 * pointer to its tracer.
174 * 174 *
175 * Must called under rcu_read_lock(). The pointer returned might be kept 175 * Must called under rcu_read_lock(). The pointer returned might be kept
@@ -448,7 +448,7 @@ static inline int tracehook_force_sigpending(void)
448 * 448 *
449 * Return zero to check for a real pending signal normally. 449 * Return zero to check for a real pending signal normally.
450 * Return -1 after releasing the siglock to repeat the check. 450 * Return -1 after releasing the siglock to repeat the check.
451 * Return a signal number to induce an artifical signal delivery, 451 * Return a signal number to induce an artificial signal delivery,
452 * setting *@info and *@return_ka to specify its details and behavior. 452 * setting *@info and *@return_ka to specify its details and behavior.
453 * 453 *
454 * The @return_ka->sa_handler value controls the disposition of the 454 * The @return_ka->sa_handler value controls the disposition of the
@@ -469,33 +469,6 @@ static inline int tracehook_get_signal(struct task_struct *task,
469} 469}
470 470
471/** 471/**
472 * tracehook_notify_jctl - report about job control stop/continue
473 * @notify: zero, %CLD_STOPPED or %CLD_CONTINUED
474 * @why: %CLD_STOPPED or %CLD_CONTINUED
475 *
476 * This is called when we might call do_notify_parent_cldstop().
477 *
478 * @notify is zero if we would not ordinarily send a %SIGCHLD,
479 * or is the %CLD_STOPPED or %CLD_CONTINUED .si_code for %SIGCHLD.
480 *
481 * @why is %CLD_STOPPED when about to stop for job control;
482 * we are already in %TASK_STOPPED state, about to call schedule().
483 * It might also be that we have just exited (check %PF_EXITING),
484 * but need to report that a group-wide stop is complete.
485 *
486 * @why is %CLD_CONTINUED when waking up after job control stop and
487 * ready to make a delayed @notify report.
488 *
489 * Return the %CLD_* value for %SIGCHLD, or zero to generate no signal.
490 *
491 * Called with the siglock held.
492 */
493static inline int tracehook_notify_jctl(int notify, int why)
494{
495 return notify ?: (current->ptrace & PT_PTRACED) ? why : 0;
496}
497
498/**
499 * tracehook_finish_jctl - report about return from job control stop 472 * tracehook_finish_jctl - report about return from job control stop
500 * 473 *
501 * This is called by do_signal_stop() after wakeup. 474 * This is called by do_signal_stop() after wakeup.
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 103d1b61aacb..d530a4460a0b 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -17,6 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/rcupdate.h> 19#include <linux/rcupdate.h>
20#include <linux/jump_label.h>
20 21
21struct module; 22struct module;
22struct tracepoint; 23struct tracepoint;
@@ -28,16 +29,11 @@ struct tracepoint_func {
28 29
29struct tracepoint { 30struct tracepoint {
30 const char *name; /* Tracepoint name */ 31 const char *name; /* Tracepoint name */
31 int state; /* State. */ 32 struct jump_label_key key;
32 void (*regfunc)(void); 33 void (*regfunc)(void);
33 void (*unregfunc)(void); 34 void (*unregfunc)(void);
34 struct tracepoint_func *funcs; 35 struct tracepoint_func __rcu *funcs;
35} __attribute__((aligned(32))); /* 36};
36 * Aligned on 32 bytes because it is
37 * globally visible and gcc happily
38 * align these on the structure size.
39 * Keep in sync with vmlinux.lds.h.
40 */
41 37
42/* 38/*
43 * Connect a probe to a tracepoint. 39 * Connect a probe to a tracepoint.
@@ -60,15 +56,15 @@ extern void tracepoint_probe_update_all(void);
60 56
61struct tracepoint_iter { 57struct tracepoint_iter {
62 struct module *module; 58 struct module *module;
63 struct tracepoint *tracepoint; 59 struct tracepoint * const *tracepoint;
64}; 60};
65 61
66extern void tracepoint_iter_start(struct tracepoint_iter *iter); 62extern void tracepoint_iter_start(struct tracepoint_iter *iter);
67extern void tracepoint_iter_next(struct tracepoint_iter *iter); 63extern void tracepoint_iter_next(struct tracepoint_iter *iter);
68extern void tracepoint_iter_stop(struct tracepoint_iter *iter); 64extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
69extern void tracepoint_iter_reset(struct tracepoint_iter *iter); 65extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
70extern int tracepoint_get_iter_range(struct tracepoint **tracepoint, 66extern int tracepoint_get_iter_range(struct tracepoint * const **tracepoint,
71 struct tracepoint *begin, struct tracepoint *end); 67 struct tracepoint * const *begin, struct tracepoint * const *end);
72 68
73/* 69/*
74 * tracepoint_synchronize_unregister must be called between the last tracepoint 70 * tracepoint_synchronize_unregister must be called between the last tracepoint
@@ -83,11 +79,13 @@ static inline void tracepoint_synchronize_unregister(void)
83#define PARAMS(args...) args 79#define PARAMS(args...) args
84 80
85#ifdef CONFIG_TRACEPOINTS 81#ifdef CONFIG_TRACEPOINTS
86extern void tracepoint_update_probe_range(struct tracepoint *begin, 82extern
87 struct tracepoint *end); 83void tracepoint_update_probe_range(struct tracepoint * const *begin,
84 struct tracepoint * const *end);
88#else 85#else
89static inline void tracepoint_update_probe_range(struct tracepoint *begin, 86static inline
90 struct tracepoint *end) 87void tracepoint_update_probe_range(struct tracepoint * const *begin,
88 struct tracepoint * const *end)
91{ } 89{ }
92#endif /* CONFIG_TRACEPOINTS */ 90#endif /* CONFIG_TRACEPOINTS */
93 91
@@ -105,6 +103,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
105 103
106#define TP_PROTO(args...) args 104#define TP_PROTO(args...) args
107#define TP_ARGS(args...) args 105#define TP_ARGS(args...) args
106#define TP_CONDITION(args...) args
108 107
109#ifdef CONFIG_TRACEPOINTS 108#ifdef CONFIG_TRACEPOINTS
110 109
@@ -118,12 +117,14 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
118 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just 117 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
119 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto". 118 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
120 */ 119 */
121#define __DO_TRACE(tp, proto, args) \ 120#define __DO_TRACE(tp, proto, args, cond) \
122 do { \ 121 do { \
123 struct tracepoint_func *it_func_ptr; \ 122 struct tracepoint_func *it_func_ptr; \
124 void *it_func; \ 123 void *it_func; \
125 void *__data; \ 124 void *__data; \
126 \ 125 \
126 if (!(cond)) \
127 return; \
127 rcu_read_lock_sched_notrace(); \ 128 rcu_read_lock_sched_notrace(); \
128 it_func_ptr = rcu_dereference_sched((tp)->funcs); \ 129 it_func_ptr = rcu_dereference_sched((tp)->funcs); \
129 if (it_func_ptr) { \ 130 if (it_func_ptr) { \
@@ -141,14 +142,15 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
141 * not add unwanted padding between the beginning of the section and the 142 * not add unwanted padding between the beginning of the section and the
142 * structure. Force alignment to the same alignment as the section start. 143 * structure. Force alignment to the same alignment as the section start.
143 */ 144 */
144#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \ 145#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
145 extern struct tracepoint __tracepoint_##name; \ 146 extern struct tracepoint __tracepoint_##name; \
146 static inline void trace_##name(proto) \ 147 static inline void trace_##name(proto) \
147 { \ 148 { \
148 if (unlikely(__tracepoint_##name.state)) \ 149 if (static_branch(&__tracepoint_##name.key)) \
149 __DO_TRACE(&__tracepoint_##name, \ 150 __DO_TRACE(&__tracepoint_##name, \
150 TP_PROTO(data_proto), \ 151 TP_PROTO(data_proto), \
151 TP_ARGS(data_args)); \ 152 TP_ARGS(data_args), \
153 TP_CONDITION(cond)); \
152 } \ 154 } \
153 static inline int \ 155 static inline int \
154 register_trace_##name(void (*probe)(data_proto), void *data) \ 156 register_trace_##name(void (*probe)(data_proto), void *data) \
@@ -167,12 +169,20 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
167 { \ 169 { \
168 } 170 }
169 171
170#define DEFINE_TRACE_FN(name, reg, unreg) \ 172/*
171 static const char __tpstrtab_##name[] \ 173 * We have no guarantee that gcc and the linker won't up-align the tracepoint
172 __attribute__((section("__tracepoints_strings"))) = #name; \ 174 * structures, so we create an array of pointers that will be used for iteration
173 struct tracepoint __tracepoint_##name \ 175 * on the tracepoints.
174 __attribute__((section("__tracepoints"), aligned(32))) = \ 176 */
175 { __tpstrtab_##name, 0, reg, unreg, NULL } 177#define DEFINE_TRACE_FN(name, reg, unreg) \
178 static const char __tpstrtab_##name[] \
179 __attribute__((section("__tracepoints_strings"))) = #name; \
180 struct tracepoint __tracepoint_##name \
181 __attribute__((section("__tracepoints"))) = \
182 { __tpstrtab_##name, JUMP_LABEL_INIT, reg, unreg, NULL };\
183 static struct tracepoint * const __tracepoint_ptr_##name __used \
184 __attribute__((section("__tracepoints_ptrs"))) = \
185 &__tracepoint_##name;
176 186
177#define DEFINE_TRACE(name) \ 187#define DEFINE_TRACE(name) \
178 DEFINE_TRACE_FN(name, NULL, NULL); 188 DEFINE_TRACE_FN(name, NULL, NULL);
@@ -183,7 +193,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
183 EXPORT_SYMBOL(__tracepoint_##name) 193 EXPORT_SYMBOL(__tracepoint_##name)
184 194
185#else /* !CONFIG_TRACEPOINTS */ 195#else /* !CONFIG_TRACEPOINTS */
186#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \ 196#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
187 static inline void trace_##name(proto) \ 197 static inline void trace_##name(proto) \
188 { } \ 198 { } \
189 static inline int \ 199 static inline int \
@@ -224,13 +234,20 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
224 * "void *__data, proto" as the callback prototype. 234 * "void *__data, proto" as the callback prototype.
225 */ 235 */
226#define DECLARE_TRACE_NOARGS(name) \ 236#define DECLARE_TRACE_NOARGS(name) \
227 __DECLARE_TRACE(name, void, , void *__data, __data) 237 __DECLARE_TRACE(name, void, , 1, void *__data, __data)
228 238
229#define DECLARE_TRACE(name, proto, args) \ 239#define DECLARE_TRACE(name, proto, args) \
230 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \ 240 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \
231 PARAMS(void *__data, proto), \ 241 PARAMS(void *__data, proto), \
232 PARAMS(__data, args)) 242 PARAMS(__data, args))
233 243
244#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \
245 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
246 PARAMS(void *__data, proto), \
247 PARAMS(__data, args))
248
249#define TRACE_EVENT_FLAGS(event, flag)
250
234#endif /* DECLARE_TRACE */ 251#endif /* DECLARE_TRACE */
235 252
236#ifndef TRACE_EVENT 253#ifndef TRACE_EVENT
@@ -312,7 +329,7 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
312 * memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); 329 * memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
313 * __entry->next_pid = next->pid; 330 * __entry->next_pid = next->pid;
314 * __entry->next_prio = next->prio; 331 * __entry->next_prio = next->prio;
315 * ) 332 * ),
316 * 333 *
317 * * 334 * *
318 * * Formatted output of a trace record via TP_printk(). 335 * * Formatted output of a trace record via TP_printk().
@@ -344,11 +361,21 @@ static inline void tracepoint_update_probe_range(struct tracepoint *begin,
344 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 361 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
345#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ 362#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
346 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 363 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
364#define DEFINE_EVENT_CONDITION(template, name, proto, \
365 args, cond) \
366 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
367 PARAMS(args), PARAMS(cond))
347 368
348#define TRACE_EVENT(name, proto, args, struct, assign, print) \ 369#define TRACE_EVENT(name, proto, args, struct, assign, print) \
349 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 370 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
350#define TRACE_EVENT_FN(name, proto, args, struct, \ 371#define TRACE_EVENT_FN(name, proto, args, struct, \
351 assign, print, reg, unreg) \ 372 assign, print, reg, unreg) \
352 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) 373 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
374#define TRACE_EVENT_CONDITION(name, proto, args, cond, \
375 struct, assign, print) \
376 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \
377 PARAMS(args), PARAMS(cond))
378
379#define TRACE_EVENT_FLAGS(event, flag)
353 380
354#endif /* ifdef TRACE_EVENT (see note above) */ 381#endif /* ifdef TRACE_EVENT (see note above) */
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 67d64e6efe7a..d6f05292e456 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -13,7 +13,6 @@
13#include <linux/tty_driver.h> 13#include <linux/tty_driver.h>
14#include <linux/tty_ldisc.h> 14#include <linux/tty_ldisc.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/smp_lock.h>
17 16
18#include <asm/system.h> 17#include <asm/system.h>
19 18
@@ -50,6 +49,9 @@
50#define N_V253 19 /* Codec control over voice modem */ 49#define N_V253 19 /* Codec control over voice modem */
51#define N_CAIF 20 /* CAIF protocol for talking to modems */ 50#define N_CAIF 20 /* CAIF protocol for talking to modems */
52#define N_GSM0710 21 /* GSM 0710 Mux */ 51#define N_GSM0710 21 /* GSM 0710 Mux */
52#define N_TI_WL 22 /* for TI's WL BT, FM, GPS combo chips */
53#define N_TRACESINK 23 /* Trace data routing for MIPI P1149.7 */
54#define N_TRACEROUTER 24 /* Trace data routing for MIPI P1149.7 */
53 55
54/* 56/*
55 * This character is the same as _POSIX_VDISABLE: it cannot be used as 57 * This character is the same as _POSIX_VDISABLE: it cannot be used as
@@ -82,7 +84,7 @@ struct tty_buffer {
82 84
83 85
84struct tty_bufhead { 86struct tty_bufhead {
85 struct delayed_work work; 87 struct work_struct work;
86 spinlock_t lock; 88 spinlock_t lock;
87 struct tty_buffer *head; /* Queue head */ 89 struct tty_buffer *head; /* Queue head */
88 struct tty_buffer *tail; /* Active buffer */ 90 struct tty_buffer *tail; /* Active buffer */
@@ -256,6 +258,7 @@ struct tty_operations;
256struct tty_struct { 258struct tty_struct {
257 int magic; 259 int magic;
258 struct kref kref; 260 struct kref kref;
261 struct device *dev;
259 struct tty_driver *driver; 262 struct tty_driver *driver;
260 const struct tty_operations *ops; 263 const struct tty_operations *ops;
261 int index; 264 int index;
@@ -365,6 +368,7 @@ struct tty_file_private {
365#define TTY_HUPPED 18 /* Post driver->hangup() */ 368#define TTY_HUPPED 18 /* Post driver->hangup() */
366#define TTY_FLUSHING 19 /* Flushing to ldisc in progress */ 369#define TTY_FLUSHING 19 /* Flushing to ldisc in progress */
367#define TTY_FLUSHPENDING 20 /* Queued buffer flush pending */ 370#define TTY_FLUSHPENDING 20 /* Queued buffer flush pending */
371#define TTY_HUPPING 21 /* ->hangup() in progress */
368 372
369#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) 373#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
370 374
@@ -446,6 +450,7 @@ extern void tty_encode_baud_rate(struct tty_struct *tty,
446 speed_t ibaud, speed_t obaud); 450 speed_t ibaud, speed_t obaud);
447extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 451extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old);
448extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b); 452extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b);
453extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
449 454
450extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); 455extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
451extern void tty_ldisc_deref(struct tty_ldisc *); 456extern void tty_ldisc_deref(struct tty_ldisc *);
@@ -465,10 +470,11 @@ extern void proc_clear_tty(struct task_struct *p);
465extern struct tty_struct *get_current_tty(void); 470extern struct tty_struct *get_current_tty(void);
466extern void tty_default_fops(struct file_operations *fops); 471extern void tty_default_fops(struct file_operations *fops);
467extern struct tty_struct *alloc_tty_struct(void); 472extern struct tty_struct *alloc_tty_struct(void);
468extern void tty_add_file(struct tty_struct *tty, struct file *file); 473extern int tty_add_file(struct tty_struct *tty, struct file *file);
469extern void free_tty_struct(struct tty_struct *tty); 474extern void free_tty_struct(struct tty_struct *tty);
470extern void initialize_tty_struct(struct tty_struct *tty, 475extern void initialize_tty_struct(struct tty_struct *tty,
471 struct tty_driver *driver, int idx); 476 struct tty_driver *driver, int idx);
477extern void deinitialize_tty_struct(struct tty_struct *tty);
472extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, 478extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
473 int first_ok); 479 int first_ok);
474extern int tty_release(struct inode *inode, struct file *filp); 480extern int tty_release(struct inode *inode, struct file *filp);
@@ -522,6 +528,7 @@ extern int tty_set_ldisc(struct tty_struct *tty, int ldisc);
522extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty); 528extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
523extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty); 529extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty);
524extern void tty_ldisc_init(struct tty_struct *tty); 530extern void tty_ldisc_init(struct tty_struct *tty);
531extern void tty_ldisc_deinit(struct tty_struct *tty);
525extern void tty_ldisc_begin(void); 532extern void tty_ldisc_begin(void);
526/* This last one is just for the tty layer internals and shouldn't be used elsewhere */ 533/* This last one is just for the tty layer internals and shouldn't be used elsewhere */
527extern void tty_ldisc_enable(struct tty_struct *tty); 534extern void tty_ldisc_enable(struct tty_struct *tty);
@@ -539,8 +546,8 @@ extern void tty_audit_exit(void);
539extern void tty_audit_fork(struct signal_struct *sig); 546extern void tty_audit_fork(struct signal_struct *sig);
540extern void tty_audit_tiocsti(struct tty_struct *tty, char ch); 547extern void tty_audit_tiocsti(struct tty_struct *tty, char ch);
541extern void tty_audit_push(struct tty_struct *tty); 548extern void tty_audit_push(struct tty_struct *tty);
542extern void tty_audit_push_task(struct task_struct *tsk, 549extern int tty_audit_push_task(struct task_struct *tsk,
543 uid_t loginuid, u32 sessionid); 550 uid_t loginuid, u32 sessionid);
544#else 551#else
545static inline void tty_audit_add_data(struct tty_struct *tty, 552static inline void tty_audit_add_data(struct tty_struct *tty,
546 unsigned char *data, size_t size) 553 unsigned char *data, size_t size)
@@ -558,9 +565,10 @@ static inline void tty_audit_fork(struct signal_struct *sig)
558static inline void tty_audit_push(struct tty_struct *tty) 565static inline void tty_audit_push(struct tty_struct *tty)
559{ 566{
560} 567}
561static inline void tty_audit_push_task(struct task_struct *tsk, 568static inline int tty_audit_push_task(struct task_struct *tsk,
562 uid_t loginuid, u32 sessionid) 569 uid_t loginuid, u32 sessionid)
563{ 570{
571 return 0;
564} 572}
565#endif 573#endif
566 574
@@ -581,10 +589,10 @@ extern int pcxe_open(struct tty_struct *tty, struct file *filp);
581 589
582/* vt.c */ 590/* vt.c */
583 591
584extern int vt_ioctl(struct tty_struct *tty, struct file *file, 592extern int vt_ioctl(struct tty_struct *tty,
585 unsigned int cmd, unsigned long arg); 593 unsigned int cmd, unsigned long arg);
586 594
587extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file, 595extern long vt_compat_ioctl(struct tty_struct *tty,
588 unsigned int cmd, unsigned long arg); 596 unsigned int cmd, unsigned long arg);
589 597
590/* tty_mutex.c */ 598/* tty_mutex.c */
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index b08677982525..9deeac855240 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -98,16 +98,15 @@
98 * 98 *
99 * Note: Do not call this function directly, call tty_write_room 99 * Note: Do not call this function directly, call tty_write_room
100 * 100 *
101 * int (*ioctl)(struct tty_struct *tty, struct file * file, 101 * int (*ioctl)(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
102 * unsigned int cmd, unsigned long arg);
103 * 102 *
104 * This routine allows the tty driver to implement 103 * This routine allows the tty driver to implement
105 * device-specific ioctl's. If the ioctl number passed in cmd 104 * device-specific ioctls. If the ioctl number passed in cmd
106 * is not recognized by the driver, it should return ENOIOCTLCMD. 105 * is not recognized by the driver, it should return ENOIOCTLCMD.
107 * 106 *
108 * Optional 107 * Optional
109 * 108 *
110 * long (*compat_ioctl)(struct tty_struct *tty, struct file * file, 109 * long (*compat_ioctl)(struct tty_struct *tty,,
111 * unsigned int cmd, unsigned long arg); 110 * unsigned int cmd, unsigned long arg);
112 * 111 *
113 * implement ioctl processing for 32 bit process on 64 bit system 112 * implement ioctl processing for 32 bit process on 64 bit system
@@ -167,12 +166,12 @@
167 * 166 *
168 * void (*hangup)(struct tty_struct *tty); 167 * void (*hangup)(struct tty_struct *tty);
169 * 168 *
170 * This routine notifies the tty driver that it should hangup the 169 * This routine notifies the tty driver that it should hang up the
171 * tty device. 170 * tty device.
172 * 171 *
173 * Optional: 172 * Optional:
174 * 173 *
175 * int (*break_ctl)(struct tty_stuct *tty, int state); 174 * int (*break_ctl)(struct tty_struct *tty, int state);
176 * 175 *
177 * This optional routine requests the tty driver to turn on or 176 * This optional routine requests the tty driver to turn on or
178 * off BREAK status on the RS-232 port. If state is -1, 177 * off BREAK status on the RS-232 port. If state is -1,
@@ -224,14 +223,22 @@
224 * unless the tty also has a valid tty->termiox pointer. 223 * unless the tty also has a valid tty->termiox pointer.
225 * 224 *
226 * Optional: Called under the termios lock 225 * Optional: Called under the termios lock
226 *
227 * int (*get_icount)(struct tty_struct *tty, struct serial_icounter *icount);
228 *
229 * Called when the device receives a TIOCGICOUNT ioctl. Passed a kernel
230 * structure to complete. This method is optional and will only be called
231 * if provided (otherwise EINVAL will be returned).
227 */ 232 */
228 233
229#include <linux/fs.h> 234#include <linux/fs.h>
230#include <linux/list.h> 235#include <linux/list.h>
231#include <linux/cdev.h> 236#include <linux/cdev.h>
237#include <linux/termios.h>
232 238
233struct tty_struct; 239struct tty_struct;
234struct tty_driver; 240struct tty_driver;
241struct serial_icounter_struct;
235 242
236struct tty_operations { 243struct tty_operations {
237 struct tty_struct * (*lookup)(struct tty_driver *driver, 244 struct tty_struct * (*lookup)(struct tty_driver *driver,
@@ -248,9 +255,9 @@ struct tty_operations {
248 void (*flush_chars)(struct tty_struct *tty); 255 void (*flush_chars)(struct tty_struct *tty);
249 int (*write_room)(struct tty_struct *tty); 256 int (*write_room)(struct tty_struct *tty);
250 int (*chars_in_buffer)(struct tty_struct *tty); 257 int (*chars_in_buffer)(struct tty_struct *tty);
251 int (*ioctl)(struct tty_struct *tty, struct file * file, 258 int (*ioctl)(struct tty_struct *tty,
252 unsigned int cmd, unsigned long arg); 259 unsigned int cmd, unsigned long arg);
253 long (*compat_ioctl)(struct tty_struct *tty, struct file * file, 260 long (*compat_ioctl)(struct tty_struct *tty,
254 unsigned int cmd, unsigned long arg); 261 unsigned int cmd, unsigned long arg);
255 void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 262 void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
256 void (*throttle)(struct tty_struct * tty); 263 void (*throttle)(struct tty_struct * tty);
@@ -263,11 +270,13 @@ struct tty_operations {
263 void (*set_ldisc)(struct tty_struct *tty); 270 void (*set_ldisc)(struct tty_struct *tty);
264 void (*wait_until_sent)(struct tty_struct *tty, int timeout); 271 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
265 void (*send_xchar)(struct tty_struct *tty, char ch); 272 void (*send_xchar)(struct tty_struct *tty, char ch);
266 int (*tiocmget)(struct tty_struct *tty, struct file *file); 273 int (*tiocmget)(struct tty_struct *tty);
267 int (*tiocmset)(struct tty_struct *tty, struct file *file, 274 int (*tiocmset)(struct tty_struct *tty,
268 unsigned int set, unsigned int clear); 275 unsigned int set, unsigned int clear);
269 int (*resize)(struct tty_struct *tty, struct winsize *ws); 276 int (*resize)(struct tty_struct *tty, struct winsize *ws);
270 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); 277 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);
278 int (*get_icount)(struct tty_struct *tty,
279 struct serial_icounter_struct *icount);
271#ifdef CONFIG_CONSOLE_POLL 280#ifdef CONFIG_CONSOLE_POLL
272 int (*poll_init)(struct tty_driver *driver, int line, char *options); 281 int (*poll_init)(struct tty_driver *driver, int line, char *options);
273 int (*poll_get_char)(struct tty_driver *driver, int line); 282 int (*poll_get_char)(struct tty_driver *driver, int line);
@@ -348,7 +357,7 @@ static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
348 * overruns, either.) 357 * overruns, either.)
349 * 358 *
350 * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need 359 * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need
351 * to be registered with a call to tty_register_driver() when the 360 * to be registered with a call to tty_register_device() when the
352 * device is found in the system and unregistered with a call to 361 * device is found in the system and unregistered with a call to
353 * tty_unregister_device() so the devices will be show up 362 * tty_unregister_device() so the devices will be show up
354 * properly in sysfs. If not set, driver->num entries will be 363 * properly in sysfs. If not set, driver->num entries will be
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 526d66f066a3..ff7dc08696a8 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -101,14 +101,15 @@
101 * any pending driver I/O is completed. 101 * any pending driver I/O is completed.
102 * 102 *
103 * void (*dcd_change)(struct tty_struct *tty, unsigned int status, 103 * void (*dcd_change)(struct tty_struct *tty, unsigned int status,
104 * struct timespec *ts) 104 * struct pps_event_time *ts)
105 * 105 *
106 * Tells the discipline that the DCD pin has changed its status and 106 * Tells the discipline that the DCD pin has changed its status and
107 * the relative timestamp. Pointer ts can be NULL. 107 * the relative timestamp. Pointer ts cannot be NULL.
108 */ 108 */
109 109
110#include <linux/fs.h> 110#include <linux/fs.h>
111#include <linux/wait.h> 111#include <linux/wait.h>
112#include <linux/pps_kernel.h>
112 113
113struct tty_ldisc_ops { 114struct tty_ldisc_ops {
114 int magic; 115 int magic;
@@ -143,7 +144,7 @@ struct tty_ldisc_ops {
143 char *fp, int count); 144 char *fp, int count);
144 void (*write_wakeup)(struct tty_struct *); 145 void (*write_wakeup)(struct tty_struct *);
145 void (*dcd_change)(struct tty_struct *, unsigned int, 146 void (*dcd_change)(struct tty_struct *, unsigned int,
146 struct timespec *); 147 struct pps_event_time *);
147 148
148 struct module *owner; 149 struct module *owner;
149 150
diff --git a/include/linux/types.h b/include/linux/types.h
index 357dbc19606f..176da8c1fbb1 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -121,15 +121,7 @@ typedef __u64 u_int64_t;
121typedef __s64 int64_t; 121typedef __s64 int64_t;
122#endif 122#endif
123 123
124/* 124/* this is a special 64bit data type that is 8-byte aligned */
125 * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
126 * common 32/64-bit compat problems.
127 * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
128 * architectures) and to 8-byte boundaries on 64-bit architetures. The new
129 * aligned_64 type enforces 8-byte alignment so that structs containing
130 * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
131 * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
132 */
133#define aligned_u64 __u64 __attribute__((aligned(8))) 125#define aligned_u64 __u64 __attribute__((aligned(8)))
134#define aligned_be64 __be64 __attribute__((aligned(8))) 126#define aligned_be64 __be64 __attribute__((aligned(8)))
135#define aligned_le64 __le64 __attribute__((aligned(8))) 127#define aligned_le64 __le64 __attribute__((aligned(8)))
@@ -158,6 +150,12 @@ typedef unsigned long blkcnt_t;
158#define pgoff_t unsigned long 150#define pgoff_t unsigned long
159#endif 151#endif
160 152
153#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
154typedef u64 dma_addr_t;
155#else
156typedef u32 dma_addr_t;
157#endif /* dma_addr_t */
158
161#endif /* __KERNEL__ */ 159#endif /* __KERNEL__ */
162 160
163/* 161/*
@@ -186,7 +184,15 @@ typedef __u64 __bitwise __be64;
186typedef __u16 __bitwise __sum16; 184typedef __u16 __bitwise __sum16;
187typedef __u32 __bitwise __wsum; 185typedef __u32 __bitwise __wsum;
188 186
189/* this is a special 64bit data type that is 8-byte aligned */ 187/*
188 * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
189 * common 32/64-bit compat problems.
190 * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
191 * architectures) and to 8-byte boundaries on 64-bit architetures. The new
192 * aligned_64 type enforces 8-byte alignment so that structs containing
193 * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
194 * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
195 */
190#define __aligned_u64 __u64 __attribute__((aligned(8))) 196#define __aligned_u64 __u64 __attribute__((aligned(8)))
191#define __aligned_be64 __be64 __attribute__((aligned(8))) 197#define __aligned_be64 __be64 __attribute__((aligned(8)))
192#define __aligned_le64 __le64 __attribute__((aligned(8))) 198#define __aligned_le64 __le64 __attribute__((aligned(8)))
diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h
index fa261a0da280..8da8c4e87da3 100644
--- a/include/linux/u64_stats_sync.h
+++ b/include/linux/u64_stats_sync.h
@@ -67,21 +67,21 @@ struct u64_stats_sync {
67#endif 67#endif
68}; 68};
69 69
70static void inline u64_stats_update_begin(struct u64_stats_sync *syncp) 70static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
71{ 71{
72#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 72#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
73 write_seqcount_begin(&syncp->seq); 73 write_seqcount_begin(&syncp->seq);
74#endif 74#endif
75} 75}
76 76
77static void inline u64_stats_update_end(struct u64_stats_sync *syncp) 77static inline void u64_stats_update_end(struct u64_stats_sync *syncp)
78{ 78{
79#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 79#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
80 write_seqcount_end(&syncp->seq); 80 write_seqcount_end(&syncp->seq);
81#endif 81#endif
82} 82}
83 83
84static unsigned int inline u64_stats_fetch_begin(const struct u64_stats_sync *syncp) 84static inline unsigned int u64_stats_fetch_begin(const struct u64_stats_sync *syncp)
85{ 85{
86#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 86#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
87 return read_seqcount_begin(&syncp->seq); 87 return read_seqcount_begin(&syncp->seq);
@@ -93,7 +93,7 @@ static unsigned int inline u64_stats_fetch_begin(const struct u64_stats_sync *sy
93#endif 93#endif
94} 94}
95 95
96static bool inline u64_stats_fetch_retry(const struct u64_stats_sync *syncp, 96static inline bool u64_stats_fetch_retry(const struct u64_stats_sync *syncp,
97 unsigned int start) 97 unsigned int start)
98{ 98{
99#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 99#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
@@ -112,7 +112,7 @@ static bool inline u64_stats_fetch_retry(const struct u64_stats_sync *syncp,
112 * - UP 32bit must disable BH. 112 * - UP 32bit must disable BH.
113 * - 64bit have no problem atomically reading u64 values, irq safe. 113 * - 64bit have no problem atomically reading u64 values, irq safe.
114 */ 114 */
115static unsigned int inline u64_stats_fetch_begin_bh(const struct u64_stats_sync *syncp) 115static inline unsigned int u64_stats_fetch_begin_bh(const struct u64_stats_sync *syncp)
116{ 116{
117#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 117#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
118 return read_seqcount_begin(&syncp->seq); 118 return read_seqcount_begin(&syncp->seq);
@@ -124,7 +124,7 @@ static unsigned int inline u64_stats_fetch_begin_bh(const struct u64_stats_sync
124#endif 124#endif
125} 125}
126 126
127static bool inline u64_stats_fetch_retry_bh(const struct u64_stats_sync *syncp, 127static inline bool u64_stats_fetch_retry_bh(const struct u64_stats_sync *syncp,
128 unsigned int start) 128 unsigned int start)
129{ 129{
130#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 130#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index d512d98dfb7d..5ca0951e1855 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -93,8 +93,8 @@ static inline unsigned long __copy_from_user_nocache(void *to,
93 * Safely read from address @src to the buffer at @dst. If a kernel fault 93 * Safely read from address @src to the buffer at @dst. If a kernel fault
94 * happens, handle that and return -EFAULT. 94 * happens, handle that and return -EFAULT.
95 */ 95 */
96extern long probe_kernel_read(void *dst, void *src, size_t size); 96extern long probe_kernel_read(void *dst, const void *src, size_t size);
97extern long __probe_kernel_read(void *dst, void *src, size_t size); 97extern long __probe_kernel_read(void *dst, const void *src, size_t size);
98 98
99/* 99/*
100 * probe_kernel_write(): safely attempt to write to a location 100 * probe_kernel_write(): safely attempt to write to a location
@@ -105,7 +105,7 @@ extern long __probe_kernel_read(void *dst, void *src, size_t size);
105 * Safely write to address @dst from the buffer at @src. If a kernel fault 105 * Safely write to address @dst from the buffer at @src. If a kernel fault
106 * happens, handle that and return -EFAULT. 106 * happens, handle that and return -EFAULT.
107 */ 107 */
108extern long notrace probe_kernel_write(void *dst, void *src, size_t size); 108extern long notrace probe_kernel_write(void *dst, const void *src, size_t size);
109extern long notrace __probe_kernel_write(void *dst, void *src, size_t size); 109extern long notrace __probe_kernel_write(void *dst, const void *src, size_t size);
110 110
111#endif /* __LINUX_UACCESS_H__ */ 111#endif /* __LINUX_UACCESS_H__ */
diff --git a/include/linux/ucb1400.h b/include/linux/ucb1400.h
index 1b4790911052..5c75153f9441 100644
--- a/include/linux/ucb1400.h
+++ b/include/linux/ucb1400.h
@@ -8,7 +8,7 @@
8 * Copyright: MontaVista Software, Inc. 8 * Copyright: MontaVista Software, Inc.
9 * 9 *
10 * Spliting done by: Marek Vasut <marek.vasut@gmail.com> 10 * Spliting done by: Marek Vasut <marek.vasut@gmail.com>
11 * If something doesnt work and it worked before spliting, e-mail me, 11 * If something doesn't work and it worked before spliting, e-mail me,
12 * dont bother Nicolas please ;-) 12 * dont bother Nicolas please ;-)
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
diff --git a/include/linux/uinput.h b/include/linux/uinput.h
index 05f7fed2b173..d28c726ede4f 100644
--- a/include/linux/uinput.h
+++ b/include/linux/uinput.h
@@ -104,6 +104,7 @@ struct uinput_ff_erase {
104#define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int) 104#define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int)
105#define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*) 105#define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*)
106#define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int) 106#define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int)
107#define UI_SET_PROPBIT _IOW(UINPUT_IOCTL_BASE, 110, int)
107 108
108#define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload) 109#define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload)
109#define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload) 110#define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload)
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 5dcc9ff72f69..665517c05eaf 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de> 4 * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de>
5 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de> 5 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
6 * Copyright(C) 2006, Hans J. Koch <hjk@linutronix.de> 6 * Copyright(C) 2006, Hans J. Koch <hjk@hansjkoch.de>
7 * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com> 7 * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com>
8 * 8 *
9 * Userspace IO driver. 9 * Userspace IO driver.
@@ -108,7 +108,7 @@ extern void uio_event_notify(struct uio_info *info);
108 108
109/* defines for uio_info->irq */ 109/* defines for uio_info->irq */
110#define UIO_IRQ_CUSTOM -1 110#define UIO_IRQ_CUSTOM -1
111#define UIO_IRQ_NONE -2 111#define UIO_IRQ_NONE 0
112 112
113/* defines for uio_mem->memtype */ 113/* defines for uio_mem->memtype */
114#define UIO_MEM_NONE 0 114#define UIO_MEM_NONE 0
diff --git a/include/linux/unaligned/packed_struct.h b/include/linux/unaligned/packed_struct.h
index 2498bb9fe002..c0d817de4df2 100644
--- a/include/linux/unaligned/packed_struct.h
+++ b/include/linux/unaligned/packed_struct.h
@@ -3,9 +3,9 @@
3 3
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5 5
6struct __una_u16 { u16 x __attribute__((packed)); }; 6struct __una_u16 { u16 x; } __packed;
7struct __una_u32 { u32 x __attribute__((packed)); }; 7struct __una_u32 { u32 x; } __packed;
8struct __una_u64 { u64 x __attribute__((packed)); }; 8struct __una_u64 { u64 x; } __packed;
9 9
10static inline u16 __get_unaligned_cpu16(const void *p) 10static inline u16 __get_unaligned_cpu16(const void *p)
11{ 11{
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 35fe6ab222bb..73c7df489607 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -20,6 +20,7 @@
20#include <linux/completion.h> /* for struct completion */ 20#include <linux/completion.h> /* for struct completion */
21#include <linux/sched.h> /* for current && schedule_timeout */ 21#include <linux/sched.h> /* for current && schedule_timeout */
22#include <linux/mutex.h> /* for struct mutex */ 22#include <linux/mutex.h> /* for struct mutex */
23#include <linux/pm_runtime.h> /* for runtime PM */
23 24
24struct usb_device; 25struct usb_device;
25struct usb_driver; 26struct usb_driver;
@@ -313,6 +314,10 @@ struct usb_bus {
313 int busnum; /* Bus number (in order of reg) */ 314 int busnum; /* Bus number (in order of reg) */
314 const char *bus_name; /* stable id (PCI slot_name etc) */ 315 const char *bus_name; /* stable id (PCI slot_name etc) */
315 u8 uses_dma; /* Does the host controller use DMA? */ 316 u8 uses_dma; /* Does the host controller use DMA? */
317 u8 uses_pio_for_control; /*
318 * Does the host controller use PIO
319 * for control transfers?
320 */
316 u8 otg_port; /* 0, or number of OTG/HNP port */ 321 u8 otg_port; /* 0, or number of OTG/HNP port */
317 unsigned is_b_host:1; /* true during some HNP roleswitches */ 322 unsigned is_b_host:1; /* true during some HNP roleswitches */
318 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ 323 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
@@ -407,8 +412,6 @@ struct usb_tt;
407 * @quirks: quirks of the whole device 412 * @quirks: quirks of the whole device
408 * @urbnum: number of URBs submitted for the whole device 413 * @urbnum: number of URBs submitted for the whole device
409 * @active_duration: total time device is not suspended 414 * @active_duration: total time device is not suspended
410 * @last_busy: time of last use
411 * @autosuspend_delay: in jiffies
412 * @connect_time: time device was first connected 415 * @connect_time: time device was first connected
413 * @do_remote_wakeup: remote wakeup should be enabled 416 * @do_remote_wakeup: remote wakeup should be enabled
414 * @reset_resume: needs reset instead of resume 417 * @reset_resume: needs reset instead of resume
@@ -481,8 +484,6 @@ struct usb_device {
481 unsigned long active_duration; 484 unsigned long active_duration;
482 485
483#ifdef CONFIG_PM 486#ifdef CONFIG_PM
484 unsigned long last_busy;
485 int autosuspend_delay;
486 unsigned long connect_time; 487 unsigned long connect_time;
487 488
488 unsigned do_remote_wakeup:1; 489 unsigned do_remote_wakeup:1;
@@ -527,7 +528,7 @@ extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
527 528
528static inline void usb_mark_last_busy(struct usb_device *udev) 529static inline void usb_mark_last_busy(struct usb_device *udev)
529{ 530{
530 udev->last_busy = jiffies; 531 pm_runtime_mark_last_busy(&udev->dev);
531} 532}
532 533
533#else 534#else
@@ -622,7 +623,7 @@ extern struct usb_host_interface *usb_find_alt_setting(
622 * USB hubs. That makes it stay the same until systems are physically 623 * USB hubs. That makes it stay the same until systems are physically
623 * reconfigured, by re-cabling a tree of USB devices or by moving USB host 624 * reconfigured, by re-cabling a tree of USB devices or by moving USB host
624 * controllers. Adding and removing devices, including virtual root hubs 625 * controllers. Adding and removing devices, including virtual root hubs
625 * in host controller driver modules, does not change these path identifers; 626 * in host controller driver modules, does not change these path identifiers;
626 * neither does rebooting or re-enumerating. These are more useful identifiers 627 * neither does rebooting or re-enumerating. These are more useful identifiers
627 * than changeable ("unstable") ones like bus numbers or device addresses. 628 * than changeable ("unstable") ones like bus numbers or device addresses.
628 * 629 *
@@ -792,12 +793,12 @@ struct usbdrv_wrap {
792 * usb_set_intfdata() to associate driver-specific data with the 793 * usb_set_intfdata() to associate driver-specific data with the
793 * interface. It may also use usb_set_interface() to specify the 794 * interface. It may also use usb_set_interface() to specify the
794 * appropriate altsetting. If unwilling to manage the interface, 795 * appropriate altsetting. If unwilling to manage the interface,
795 * return -ENODEV, if genuine IO errors occured, an appropriate 796 * return -ENODEV, if genuine IO errors occurred, an appropriate
796 * negative errno value. 797 * negative errno value.
797 * @disconnect: Called when the interface is no longer accessible, usually 798 * @disconnect: Called when the interface is no longer accessible, usually
798 * because its device has been (or is being) disconnected or the 799 * because its device has been (or is being) disconnected or the
799 * driver module is being unloaded. 800 * driver module is being unloaded.
800 * @ioctl: Used for drivers that want to talk to userspace through 801 * @unlocked_ioctl: Used for drivers that want to talk to userspace through
801 * the "usbfs" filesystem. This lets devices provide ways to 802 * the "usbfs" filesystem. This lets devices provide ways to
802 * expose information to user space regardless of where they 803 * expose information to user space regardless of where they
803 * do (or don't) show up otherwise in the filesystem. 804 * do (or don't) show up otherwise in the filesystem.
@@ -805,8 +806,10 @@ struct usbdrv_wrap {
805 * @resume: Called when the device is being resumed by the system. 806 * @resume: Called when the device is being resumed by the system.
806 * @reset_resume: Called when the suspended device has been reset instead 807 * @reset_resume: Called when the suspended device has been reset instead
807 * of being resumed. 808 * of being resumed.
808 * @pre_reset: Called by usb_reset_device() when the device 809 * @pre_reset: Called by usb_reset_device() when the device is about to be
809 * is about to be reset. 810 * reset. This routine must not return until the driver has no active
811 * URBs for the device, and no more URBs may be submitted until the
812 * post_reset method is called.
810 * @post_reset: Called by usb_reset_device() after the device 813 * @post_reset: Called by usb_reset_device() after the device
811 * has been reset 814 * has been reset
812 * @id_table: USB drivers use ID table to support hotplugging. 815 * @id_table: USB drivers use ID table to support hotplugging.
@@ -975,6 +978,7 @@ extern int usb_disabled(void);
975#define URB_SETUP_MAP_SINGLE 0x00100000 /* Setup packet DMA mapped */ 978#define URB_SETUP_MAP_SINGLE 0x00100000 /* Setup packet DMA mapped */
976#define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */ 979#define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */
977#define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */ 980#define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */
981#define URB_ALIGNED_TEMP_BUFFER 0x00800000 /* Temp buffer was alloc'd */
978 982
979struct usb_iso_packet_descriptor { 983struct usb_iso_packet_descriptor {
980 unsigned int offset; 984 unsigned int offset;
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
index 51410e0200cf..ed91fb62674b 100644
--- a/include/linux/usb/Kbuild
+++ b/include/linux/usb/Kbuild
@@ -2,6 +2,7 @@ header-y += audio.h
2header-y += cdc.h 2header-y += cdc.h
3header-y += ch9.h 3header-y += ch9.h
4header-y += ch11.h 4header-y += ch11.h
5header-y += functionfs.h
5header-y += gadgetfs.h 6header-y += gadgetfs.h
6header-y += midi.h 7header-y += midi.h
7header-y += g_printer.h 8header-y += g_printer.h
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index c117a68d04a7..81a927930bfd 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -32,6 +32,8 @@
32 32
33#define USB_CDC_PROTO_EEM 7 33#define USB_CDC_PROTO_EEM 7
34 34
35#define USB_CDC_NCM_PROTO_NTB 1
36
35/*-------------------------------------------------------------------------*/ 37/*-------------------------------------------------------------------------*/
36 38
37/* 39/*
@@ -87,7 +89,7 @@ struct usb_cdc_acm_descriptor {
87 89
88#define USB_CDC_COMM_FEATURE 0x01 90#define USB_CDC_COMM_FEATURE 0x01
89#define USB_CDC_CAP_LINE 0x02 91#define USB_CDC_CAP_LINE 0x02
90#define USB_CDC_CAP_BRK 0x04 92#define USB_CDC_CAP_BRK 0x04
91#define USB_CDC_CAP_NOTIFY 0x08 93#define USB_CDC_CAP_NOTIFY 0x08
92 94
93/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */ 95/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
@@ -269,18 +271,23 @@ struct usb_cdc_notification {
269 __le16 wLength; 271 __le16 wLength;
270} __attribute__ ((packed)); 272} __attribute__ ((packed));
271 273
274struct usb_cdc_speed_change {
275 __le32 DLBitRRate; /* contains the downlink bit rate (IN pipe) */
276 __le32 ULBitRate; /* contains the uplink bit rate (OUT pipe) */
277} __attribute__ ((packed));
278
272/*-------------------------------------------------------------------------*/ 279/*-------------------------------------------------------------------------*/
273 280
274/* 281/*
275 * Class Specific structures and constants 282 * Class Specific structures and constants
276 * 283 *
277 * CDC NCM parameter structure, CDC NCM subclass 6.2.1 284 * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1
278 * 285 *
279 */ 286 */
280 287
281struct usb_cdc_ncm_ntb_parameter { 288struct usb_cdc_ncm_ntb_parameters {
282 __le16 wLength; 289 __le16 wLength;
283 __le16 bmNtbFormatSupported; 290 __le16 bmNtbFormatsSupported;
284 __le32 dwNtbInMaxSize; 291 __le32 dwNtbInMaxSize;
285 __le16 wNdpInDivisor; 292 __le16 wNdpInDivisor;
286 __le16 wNdpInPayloadRemainder; 293 __le16 wNdpInPayloadRemainder;
@@ -290,22 +297,22 @@ struct usb_cdc_ncm_ntb_parameter {
290 __le16 wNdpOutDivisor; 297 __le16 wNdpOutDivisor;
291 __le16 wNdpOutPayloadRemainder; 298 __le16 wNdpOutPayloadRemainder;
292 __le16 wNdpOutAlignment; 299 __le16 wNdpOutAlignment;
293 __le16 wPadding2; 300 __le16 wNtbOutMaxDatagrams;
294} __attribute__ ((packed)); 301} __attribute__ ((packed));
295 302
296/* 303/*
297 * CDC NCM transfer headers, CDC NCM subclass 3.2 304 * CDC NCM transfer headers, CDC NCM subclass 3.2
298 */ 305 */
299 306
300#define NCM_NTH16_SIGN 0x484D434E /* NCMH */ 307#define USB_CDC_NCM_NTH16_SIGN 0x484D434E /* NCMH */
301#define NCM_NTH32_SIGN 0x686D636E /* ncmh */ 308#define USB_CDC_NCM_NTH32_SIGN 0x686D636E /* ncmh */
302 309
303struct usb_cdc_ncm_nth16 { 310struct usb_cdc_ncm_nth16 {
304 __le32 dwSignature; 311 __le32 dwSignature;
305 __le16 wHeaderLength; 312 __le16 wHeaderLength;
306 __le16 wSequence; 313 __le16 wSequence;
307 __le16 wBlockLength; 314 __le16 wBlockLength;
308 __le16 wFpIndex; 315 __le16 wNdpIndex;
309} __attribute__ ((packed)); 316} __attribute__ ((packed));
310 317
311struct usb_cdc_ncm_nth32 { 318struct usb_cdc_ncm_nth32 {
@@ -313,32 +320,93 @@ struct usb_cdc_ncm_nth32 {
313 __le16 wHeaderLength; 320 __le16 wHeaderLength;
314 __le16 wSequence; 321 __le16 wSequence;
315 __le32 dwBlockLength; 322 __le32 dwBlockLength;
316 __le32 dwFpIndex; 323 __le32 dwNdpIndex;
317} __attribute__ ((packed)); 324} __attribute__ ((packed));
318 325
319/* 326/*
320 * CDC NCM datagram pointers, CDC NCM subclass 3.3 327 * CDC NCM datagram pointers, CDC NCM subclass 3.3
321 */ 328 */
322 329
323#define NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */ 330#define USB_CDC_NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */
324#define NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */ 331#define USB_CDC_NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */
325#define NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */ 332#define USB_CDC_NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */
326#define NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */ 333#define USB_CDC_NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */
327 334
335/* 16-bit NCM Datagram Pointer Entry */
336struct usb_cdc_ncm_dpe16 {
337 __le16 wDatagramIndex;
338 __le16 wDatagramLength;
339} __attribute__((__packed__));
340
341/* 16-bit NCM Datagram Pointer Table */
328struct usb_cdc_ncm_ndp16 { 342struct usb_cdc_ncm_ndp16 {
329 __le32 dwSignature; 343 __le32 dwSignature;
330 __le16 wLength; 344 __le16 wLength;
331 __le16 wNextFpIndex; 345 __le16 wNextNdpIndex;
332 __u8 data[0]; 346 struct usb_cdc_ncm_dpe16 dpe16[0];
333} __attribute__ ((packed)); 347} __attribute__ ((packed));
334 348
349/* 32-bit NCM Datagram Pointer Entry */
350struct usb_cdc_ncm_dpe32 {
351 __le32 dwDatagramIndex;
352 __le32 dwDatagramLength;
353} __attribute__((__packed__));
354
355/* 32-bit NCM Datagram Pointer Table */
335struct usb_cdc_ncm_ndp32 { 356struct usb_cdc_ncm_ndp32 {
336 __le32 dwSignature; 357 __le32 dwSignature;
337 __le16 wLength; 358 __le16 wLength;
338 __le16 wReserved6; 359 __le16 wReserved6;
339 __le32 dwNextFpIndex; 360 __le32 dwNextNdpIndex;
340 __le32 dwReserved12; 361 __le32 dwReserved12;
341 __u8 data[0]; 362 struct usb_cdc_ncm_dpe32 dpe32[0];
342} __attribute__ ((packed)); 363} __attribute__ ((packed));
343 364
365/* CDC NCM subclass 3.2.1 and 3.2.2 */
366#define USB_CDC_NCM_NDP16_INDEX_MIN 0x000C
367#define USB_CDC_NCM_NDP32_INDEX_MIN 0x0010
368
369/* CDC NCM subclass 3.3.3 Datagram Formatting */
370#define USB_CDC_NCM_DATAGRAM_FORMAT_CRC 0x30
371#define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC 0X31
372
373/* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */
374#define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS 0x00
375#define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO 0xFE
376
377/* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */
378#define USB_CDC_NCM_NCAP_ETH_FILTER (1 << 0)
379#define USB_CDC_NCM_NCAP_NET_ADDRESS (1 << 1)
380#define USB_CDC_NCM_NCAP_ENCAP_COMMAND (1 << 2)
381#define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE (1 << 3)
382#define USB_CDC_NCM_NCAP_CRC_MODE (1 << 4)
383#define USB_CDC_NCM_NCAP_NTB_INPUT_SIZE (1 << 5)
384
385/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
386#define USB_CDC_NCM_NTB16_SUPPORTED (1 << 0)
387#define USB_CDC_NCM_NTB32_SUPPORTED (1 << 1)
388
389/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
390#define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE 0x04
391#define USB_CDC_NCM_NTB_MAX_LENGTH 0x1C
392
393/* CDC NCM subclass 6.2.5 SetNtbFormat */
394#define USB_CDC_NCM_NTB16_FORMAT 0x00
395#define USB_CDC_NCM_NTB32_FORMAT 0x01
396
397/* CDC NCM subclass 6.2.7 SetNtbInputSize */
398#define USB_CDC_NCM_NTB_MIN_IN_SIZE 2048
399#define USB_CDC_NCM_NTB_MIN_OUT_SIZE 2048
400
401/* NTB Input Size Structure */
402struct usb_cdc_ncm_ndp_input_size {
403 __le32 dwNtbInMaxSize;
404 __le16 wNtbInMaxDatagrams;
405 __le16 wReserved;
406} __attribute__ ((packed));
407
408/* CDC NCM subclass 6.2.11 SetCrcMode */
409#define USB_CDC_NCM_CRC_NOT_APPENDED 0x00
410#define USB_CDC_NCM_CRC_APPENDED 0x01
411
344#endif /* __LINUX_USB_CDC_H */ 412#endif /* __LINUX_USB_CDC_H */
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h
index 119194c85d10..4ebaf0824179 100644
--- a/include/linux/usb/ch11.h
+++ b/include/linux/usb/ch11.h
@@ -26,6 +26,14 @@
26#define HUB_RESET_TT 9 26#define HUB_RESET_TT 9
27#define HUB_GET_TT_STATE 10 27#define HUB_GET_TT_STATE 10
28#define HUB_STOP_TT 11 28#define HUB_STOP_TT 11
29#define HUB_SET_DEPTH 12
30
31/*
32 * Hub class additional requests defined by USB 3.0 spec
33 * See USB 3.0 spec Table 10-6
34 */
35#define HUB_SET_DEPTH 12
36#define HUB_GET_PORT_ERR_COUNT 13
29 37
30/* 38/*
31 * Hub Class feature numbers 39 * Hub Class feature numbers
@@ -54,6 +62,26 @@
54#define USB_PORT_FEAT_TEST 21 62#define USB_PORT_FEAT_TEST 21
55#define USB_PORT_FEAT_INDICATOR 22 63#define USB_PORT_FEAT_INDICATOR 22
56#define USB_PORT_FEAT_C_PORT_L1 23 64#define USB_PORT_FEAT_C_PORT_L1 23
65#define USB_PORT_FEAT_C_PORT_LINK_STATE 25
66#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
67#define USB_PORT_FEAT_PORT_REMOTE_WAKE_MASK 27
68#define USB_PORT_FEAT_BH_PORT_RESET 28
69#define USB_PORT_FEAT_C_BH_PORT_RESET 29
70#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
71
72/*
73 * Port feature selectors added by USB 3.0 spec.
74 * See USB 3.0 spec Table 10-7
75 */
76#define USB_PORT_FEAT_LINK_STATE 5
77#define USB_PORT_FEAT_U1_TIMEOUT 23
78#define USB_PORT_FEAT_U2_TIMEOUT 24
79#define USB_PORT_FEAT_C_LINK_STATE 25
80#define USB_PORT_FEAT_C_CONFIG_ERR 26
81#define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
82#define USB_PORT_FEAT_BH_PORT_RESET 28
83#define USB_PORT_FEAT_C_BH_PORT_RESET 29
84#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
57 85
58/* 86/*
59 * Hub Status and Hub Change results 87 * Hub Status and Hub Change results
@@ -81,12 +109,43 @@ struct usb_port_status {
81#define USB_PORT_STAT_TEST 0x0800 109#define USB_PORT_STAT_TEST 0x0800
82#define USB_PORT_STAT_INDICATOR 0x1000 110#define USB_PORT_STAT_INDICATOR 0x1000
83/* bits 13 to 15 are reserved */ 111/* bits 13 to 15 are reserved */
84#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */ 112
113/*
114 * Additions to wPortStatus bit field from USB 3.0
115 * See USB 3.0 spec Table 10-10
116 */
117#define USB_PORT_STAT_LINK_STATE 0x01e0
118#define USB_SS_PORT_STAT_POWER 0x0200
119#define USB_SS_PORT_STAT_SPEED 0x1c00
120#define USB_PORT_STAT_SPEED_5GBPS 0x0000
121/* Valid only if port is enabled */
122/* Bits that are the same from USB 2.0 */
123#define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \
124 USB_PORT_STAT_ENABLE | \
125 USB_PORT_STAT_OVERCURRENT | \
126 USB_PORT_STAT_RESET)
127
128/*
129 * Definitions for PORT_LINK_STATE values
130 * (bits 5-8) in wPortStatus
131 */
132#define USB_SS_PORT_LS_U0 0x0000
133#define USB_SS_PORT_LS_U1 0x0020
134#define USB_SS_PORT_LS_U2 0x0040
135#define USB_SS_PORT_LS_U3 0x0060
136#define USB_SS_PORT_LS_SS_DISABLED 0x0080
137#define USB_SS_PORT_LS_RX_DETECT 0x00a0
138#define USB_SS_PORT_LS_SS_INACTIVE 0x00c0
139#define USB_SS_PORT_LS_POLLING 0x00e0
140#define USB_SS_PORT_LS_RECOVERY 0x0100
141#define USB_SS_PORT_LS_HOT_RESET 0x0120
142#define USB_SS_PORT_LS_COMP_MOD 0x0140
143#define USB_SS_PORT_LS_LOOPBACK 0x0160
85 144
86/* 145/*
87 * wPortChange bit field 146 * wPortChange bit field
88 * See USB 2.0 spec Table 11-22 147 * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
89 * Bits 0 to 4 shown, bits 5 to 15 are reserved 148 * Bits 0 to 5 shown, bits 6 to 15 are reserved
90 */ 149 */
91#define USB_PORT_STAT_C_CONNECTION 0x0001 150#define USB_PORT_STAT_C_CONNECTION 0x0001
92#define USB_PORT_STAT_C_ENABLE 0x0002 151#define USB_PORT_STAT_C_ENABLE 0x0002
@@ -94,6 +153,13 @@ struct usb_port_status {
94#define USB_PORT_STAT_C_OVERCURRENT 0x0008 153#define USB_PORT_STAT_C_OVERCURRENT 0x0008
95#define USB_PORT_STAT_C_RESET 0x0010 154#define USB_PORT_STAT_C_RESET 0x0010
96#define USB_PORT_STAT_C_L1 0x0020 155#define USB_PORT_STAT_C_L1 0x0020
156/*
157 * USB 3.0 wPortChange bit fields
158 * See USB 3.0 spec Table 10-11
159 */
160#define USB_PORT_STAT_C_BH_RESET 0x0020
161#define USB_PORT_STAT_C_LINK_STATE 0x0040
162#define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
97 163
98/* 164/*
99 * wHubCharacteristics (masks) 165 * wHubCharacteristics (masks)
@@ -128,7 +194,9 @@ struct usb_hub_status {
128 */ 194 */
129 195
130#define USB_DT_HUB (USB_TYPE_CLASS | 0x09) 196#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
197#define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)
131#define USB_DT_HUB_NONVAR_SIZE 7 198#define USB_DT_HUB_NONVAR_SIZE 7
199#define USB_DT_SS_HUB_SIZE 12
132 200
133struct usb_hub_descriptor { 201struct usb_hub_descriptor {
134 __u8 bDescLength; 202 __u8 bDescLength;
@@ -137,11 +205,22 @@ struct usb_hub_descriptor {
137 __le16 wHubCharacteristics; 205 __le16 wHubCharacteristics;
138 __u8 bPwrOn2PwrGood; 206 __u8 bPwrOn2PwrGood;
139 __u8 bHubContrCurrent; 207 __u8 bHubContrCurrent;
140 /* add 1 bit for hub status change; round to bytes */
141 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
142 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
143} __attribute__ ((packed));
144 208
209 /* 2.0 and 3.0 hubs differ here */
210 union {
211 struct {
212 /* add 1 bit for hub status change; round to bytes */
213 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
214 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
215 } __attribute__ ((packed)) hs;
216
217 struct {
218 __u8 bHubHdrDecLat;
219 __u16 wHubDelay;
220 __u16 DeviceRemovable;
221 } __attribute__ ((packed)) ss;
222 } u;
223} __attribute__ ((packed));
145 224
146/* port indicator status selectors, tables 11-7 and 11-25 */ 225/* port indicator status selectors, tables 11-7 and 11-25 */
147#define HUB_LED_AUTO 0 226#define HUB_LED_AUTO 0
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index da2ed77d3e8d..0fd3fbdd8283 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -123,8 +123,33 @@
123#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ 123#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
124#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ 124#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
125 125
126/*
127 * Test Mode Selectors
128 * See USB 2.0 spec Table 9-7
129 */
130#define TEST_J 1
131#define TEST_K 2
132#define TEST_SE0_NAK 3
133#define TEST_PACKET 4
134#define TEST_FORCE_EN 5
135
136/*
137 * New Feature Selectors as added by USB 3.0
138 * See USB 3.0 spec Table 9-6
139 */
140#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
141#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
142#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
143#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
144
145#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
146
126#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ 147#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
127 148
149/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
150#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
151#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
152#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
128 153
129/** 154/**
130 * struct usb_ctrlrequest - SETUP data for a USB device control request 155 * struct usb_ctrlrequest - SETUP data for a USB device control request
@@ -554,12 +579,14 @@ struct usb_ss_ep_comp_descriptor {
554 579
555 __u8 bMaxBurst; 580 __u8 bMaxBurst;
556 __u8 bmAttributes; 581 __u8 bmAttributes;
557 __u16 wBytesPerInterval; 582 __le16 wBytesPerInterval;
558} __attribute__ ((packed)); 583} __attribute__ ((packed));
559 584
560#define USB_DT_SS_EP_COMP_SIZE 6 585#define USB_DT_SS_EP_COMP_SIZE 6
561/* Bits 4:0 of bmAttributes if this is a bulk endpoint */ 586/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
562#define USB_SS_MAX_STREAMS(p) (1 << (p & 0x1f)) 587#define USB_SS_MAX_STREAMS(p) (1 << ((p) & 0x1f))
588/* Bits 1:0 of bmAttributes if this is an isoc endpoint */
589#define USB_SS_MULT(p) (1 + ((p) & 0x3))
563 590
564/*-------------------------------------------------------------------------*/ 591/*-------------------------------------------------------------------------*/
565 592
@@ -675,6 +702,7 @@ struct usb_bos_descriptor {
675 __u8 bNumDeviceCaps; 702 __u8 bNumDeviceCaps;
676} __attribute__((packed)); 703} __attribute__((packed));
677 704
705#define USB_DT_BOS_SIZE 5
678/*-------------------------------------------------------------------------*/ 706/*-------------------------------------------------------------------------*/
679 707
680/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */ 708/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
@@ -712,16 +740,56 @@ struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
712 __u8 bReserved; 740 __u8 bReserved;
713} __attribute__((packed)); 741} __attribute__((packed));
714 742
743/* USB 2.0 Extension descriptor */
715#define USB_CAP_TYPE_EXT 2 744#define USB_CAP_TYPE_EXT 2
716 745
717struct usb_ext_cap_descriptor { /* Link Power Management */ 746struct usb_ext_cap_descriptor { /* Link Power Management */
718 __u8 bLength; 747 __u8 bLength;
719 __u8 bDescriptorType; 748 __u8 bDescriptorType;
720 __u8 bDevCapabilityType; 749 __u8 bDevCapabilityType;
721 __u8 bmAttributes; 750 __le32 bmAttributes;
722#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ 751#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
723} __attribute__((packed)); 752} __attribute__((packed));
724 753
754#define USB_DT_USB_EXT_CAP_SIZE 7
755
756/*
757 * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
758 * specific device level capabilities
759 */
760#define USB_SS_CAP_TYPE 3
761struct usb_ss_cap_descriptor { /* Link Power Management */
762 __u8 bLength;
763 __u8 bDescriptorType;
764 __u8 bDevCapabilityType;
765 __u8 bmAttributes;
766#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
767 __le16 wSpeedSupported;
768#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
769#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
770#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
771#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
772 __u8 bFunctionalitySupport;
773 __u8 bU1devExitLat;
774 __le16 bU2DevExitLat;
775} __attribute__((packed));
776
777#define USB_DT_USB_SS_CAP_SIZE 10
778
779/*
780 * Container ID Capability descriptor: Defines the instance unique ID used to
781 * identify the instance across all operating modes
782 */
783#define CONTAINER_ID_TYPE 4
784struct usb_ss_container_id_descriptor {
785 __u8 bLength;
786 __u8 bDescriptorType;
787 __u8 bDevCapabilityType;
788 __u8 bReserved;
789 __u8 ContainerID[16]; /* 128-bit number */
790} __attribute__((packed));
791
792#define USB_DT_USB_SS_CONTN_ID_SIZE 20
725/*-------------------------------------------------------------------------*/ 793/*-------------------------------------------------------------------------*/
726 794
727/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with 795/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
@@ -808,4 +876,14 @@ enum usb_device_state {
808 */ 876 */
809}; 877};
810 878
879/*-------------------------------------------------------------------------*/
880
881/*
882 * As per USB compliance update, a device that is actively drawing
883 * more than 100mA from USB must report itself as bus-powered in
884 * the GetStatus(DEVICE) call.
885 * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
886 */
887#define USB_SELF_POWER_VBUS_MAX_DRAW 100
888
811#endif /* __LINUX_USB_CH9_H */ 889#endif /* __LINUX_USB_CH9_H */
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 617068134ae8..b78cba466d3d 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -37,6 +37,14 @@
37#include <linux/usb/ch9.h> 37#include <linux/usb/ch9.h>
38#include <linux/usb/gadget.h> 38#include <linux/usb/gadget.h>
39 39
40/*
41 * USB function drivers should return USB_GADGET_DELAYED_STATUS if they
42 * wish to delay the data/status stages of the control transfer till they
43 * are ready. The control transfer will then be kept from completing till
44 * all the function drivers that requested for USB_GADGET_DELAYED_STAUS
45 * invoke usb_composite_setup_continue().
46 */
47#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */
40 48
41struct usb_configuration; 49struct usb_configuration;
42 50
@@ -161,8 +169,6 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
161 * and by language IDs provided in control requests. 169 * and by language IDs provided in control requests.
162 * @descriptors: Table of descriptors preceding all function descriptors. 170 * @descriptors: Table of descriptors preceding all function descriptors.
163 * Examples include OTG and vendor-specific descriptors. 171 * Examples include OTG and vendor-specific descriptors.
164 * @bind: Called from @usb_add_config() to allocate resources unique to this
165 * configuration and to call @usb_add_function() for each function used.
166 * @unbind: Reverses @bind; called as a side effect of unregistering the 172 * @unbind: Reverses @bind; called as a side effect of unregistering the
167 * driver which added this configuration. 173 * driver which added this configuration.
168 * @setup: Used to delegate control requests that aren't handled by standard 174 * @setup: Used to delegate control requests that aren't handled by standard
@@ -190,7 +196,7 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
190 * @bind() method is then used to initialize all the functions and then 196 * @bind() method is then used to initialize all the functions and then
191 * call @usb_add_function() for them. 197 * call @usb_add_function() for them.
192 * 198 *
193 * Those functions would normally be independant of each other, but that's 199 * Those functions would normally be independent of each other, but that's
194 * not mandatory. CDC WMC devices are an example where functions often 200 * not mandatory. CDC WMC devices are an example where functions often
195 * depend on other functions, with some functions subsidiary to others. 201 * depend on other functions, with some functions subsidiary to others.
196 * Such interdependency may be managed in any way, so long as all of the 202 * Such interdependency may be managed in any way, so long as all of the
@@ -207,8 +213,7 @@ struct usb_configuration {
207 * we can't restructure things to avoid mismatching... 213 * we can't restructure things to avoid mismatching...
208 */ 214 */
209 215
210 /* configuration management: bind/unbind */ 216 /* configuration management: unbind/setup */
211 int (*bind)(struct usb_configuration *);
212 void (*unbind)(struct usb_configuration *); 217 void (*unbind)(struct usb_configuration *);
213 int (*setup)(struct usb_configuration *, 218 int (*setup)(struct usb_configuration *,
214 const struct usb_ctrlrequest *); 219 const struct usb_ctrlrequest *);
@@ -232,20 +237,24 @@ struct usb_configuration {
232}; 237};
233 238
234int usb_add_config(struct usb_composite_dev *, 239int usb_add_config(struct usb_composite_dev *,
235 struct usb_configuration *); 240 struct usb_configuration *,
241 int (*)(struct usb_configuration *));
236 242
237/** 243/**
238 * struct usb_composite_driver - groups configurations into a gadget 244 * struct usb_composite_driver - groups configurations into a gadget
239 * @name: For diagnostics, identifies the driver. 245 * @name: For diagnostics, identifies the driver.
246 * @iProduct: Used as iProduct override if @dev->iProduct is not set.
247 * If NULL value of @name is taken.
248 * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
249 * not set. If NULL a default "<system> <release> with <udc>" value
250 * will be used.
240 * @dev: Template descriptor for the device, including default device 251 * @dev: Template descriptor for the device, including default device
241 * identifiers. 252 * identifiers.
242 * @strings: tables of strings, keyed by identifiers assigned during bind() 253 * @strings: tables of strings, keyed by identifiers assigned during bind()
243 * and language IDs provided in control requests 254 * and language IDs provided in control requests
244 * @bind: (REQUIRED) Used to allocate resources that are shared across the 255 * @needs_serial: set to 1 if the gadget needs userspace to provide
245 * whole device, such as string IDs, and add its configurations using 256 * a serial number. If one is not provided, warning will be printed.
246 * @usb_add_config(). This may fail by returning a negative errno 257 * @unbind: Reverses bind; called as a side effect of unregistering
247 * value; it should return zero on successful initialization.
248 * @unbind: Reverses @bind(); called as a side effect of unregistering
249 * this driver. 258 * this driver.
250 * @disconnect: optional driver disconnect method 259 * @disconnect: optional driver disconnect method
251 * @suspend: Notifies when the host stops sending USB traffic, 260 * @suspend: Notifies when the host stops sending USB traffic,
@@ -256,7 +265,7 @@ int usb_add_config(struct usb_composite_dev *,
256 * Devices default to reporting self powered operation. Devices which rely 265 * Devices default to reporting self powered operation. Devices which rely
257 * on bus powered operation should report this in their @bind() method. 266 * on bus powered operation should report this in their @bind() method.
258 * 267 *
259 * Before returning from @bind, various fields in the template descriptor 268 * Before returning from bind, various fields in the template descriptor
260 * may be overridden. These include the idVendor/idProduct/bcdDevice values 269 * may be overridden. These include the idVendor/idProduct/bcdDevice values
261 * normally to bind the appropriate host side driver, and the three strings 270 * normally to bind the appropriate host side driver, and the three strings
262 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user 271 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
@@ -266,15 +275,12 @@ int usb_add_config(struct usb_composite_dev *,
266 */ 275 */
267struct usb_composite_driver { 276struct usb_composite_driver {
268 const char *name; 277 const char *name;
278 const char *iProduct;
279 const char *iManufacturer;
269 const struct usb_device_descriptor *dev; 280 const struct usb_device_descriptor *dev;
270 struct usb_gadget_strings **strings; 281 struct usb_gadget_strings **strings;
282 unsigned needs_serial:1;
271 283
272 /* REVISIT: bind() functions can be marked __init, which
273 * makes trouble for section mismatch analysis. See if
274 * we can't restructure things to avoid mismatching...
275 */
276
277 int (*bind)(struct usb_composite_dev *);
278 int (*unbind)(struct usb_composite_dev *); 284 int (*unbind)(struct usb_composite_dev *);
279 285
280 void (*disconnect)(struct usb_composite_dev *); 286 void (*disconnect)(struct usb_composite_dev *);
@@ -284,8 +290,10 @@ struct usb_composite_driver {
284 void (*resume)(struct usb_composite_dev *); 290 void (*resume)(struct usb_composite_dev *);
285}; 291};
286 292
287extern int usb_composite_register(struct usb_composite_driver *); 293extern int usb_composite_probe(struct usb_composite_driver *driver,
288extern void usb_composite_unregister(struct usb_composite_driver *); 294 int (*bind)(struct usb_composite_dev *cdev));
295extern void usb_composite_unregister(struct usb_composite_driver *driver);
296extern void usb_composite_setup_continue(struct usb_composite_dev *cdev);
289 297
290 298
291/** 299/**
@@ -334,13 +342,21 @@ struct usb_composite_dev {
334 struct list_head configs; 342 struct list_head configs;
335 struct usb_composite_driver *driver; 343 struct usb_composite_driver *driver;
336 u8 next_string_id; 344 u8 next_string_id;
345 u8 manufacturer_override;
346 u8 product_override;
347 u8 serial_override;
337 348
338 /* the gadget driver won't enable the data pullup 349 /* the gadget driver won't enable the data pullup
339 * while the deactivation count is nonzero. 350 * while the deactivation count is nonzero.
340 */ 351 */
341 unsigned deactivations; 352 unsigned deactivations;
342 353
343 /* protects at least deactivation count */ 354 /* the composite driver won't complete the control transfer's
355 * data/status stages till delayed_status is zero.
356 */
357 int delayed_status;
358
359 /* protects deactivations and delayed_status counts*/
344 spinlock_t lock; 360 spinlock_t lock;
345}; 361};
346 362
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
index 2e262cb15425..7cc95ee3606b 100644
--- a/include/linux/usb/ehci_def.h
+++ b/include/linux/usb/ehci_def.h
@@ -25,10 +25,15 @@
25struct ehci_caps { 25struct ehci_caps {
26 /* these fields are specified as 8 and 16 bit registers, 26 /* these fields are specified as 8 and 16 bit registers,
27 * but some hosts can't perform 8 or 16 bit PCI accesses. 27 * but some hosts can't perform 8 or 16 bit PCI accesses.
28 * some hosts treat caplength and hciversion as parts of a 32-bit
29 * register, others treat them as two separate registers, this
30 * affects the memory map for big endian controllers.
28 */ 31 */
29 u32 hc_capbase; 32 u32 hc_capbase;
30#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */ 33#define HC_LENGTH(ehci, p) (0x00ff&((p) >> /* bits 7:0 / offset 00h */ \
31#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */ 34 (ehci_big_endian_capbase(ehci) ? 24 : 0)))
35#define HC_VERSION(ehci, p) (0xffff&((p) >> /* bits 31:16 / offset 02h */ \
36 (ehci_big_endian_capbase(ehci) ? 0 : 16)))
32 u32 hcs_params; /* HCSPARAMS - offset 0x4 */ 37 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
33#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */ 38#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */
34#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */ 39#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
@@ -52,7 +57,7 @@ struct ehci_caps {
52#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/ 57#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
53#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */ 58#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
54 u8 portroute[8]; /* nibbles for routing - offset 0xC */ 59 u8 portroute[8]; /* nibbles for routing - offset 0xC */
55} __attribute__ ((packed)); 60};
56 61
57 62
58/* Section 2.3 Host Controller Operational Registers */ 63/* Section 2.3 Host Controller Operational Registers */
@@ -127,7 +132,9 @@ struct ehci_regs {
127#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */ 132#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
128#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */ 133#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */
129/* 19:16 for port testing */ 134/* 19:16 for port testing */
130#define PORT_TEST_PKT (0x4<<16) /* Port Test Control - packet test */ 135#define PORT_TEST(x) (((x)&0xf)<<16) /* Port Test Control */
136#define PORT_TEST_PKT PORT_TEST(0x4) /* Port Test Control - packet test */
137#define PORT_TEST_FORCE PORT_TEST(0x5) /* Port Test Control - force enable */
131#define PORT_LED_OFF (0<<14) 138#define PORT_LED_OFF (0<<14)
132#define PORT_LED_AMBER (1<<14) 139#define PORT_LED_AMBER (1<<14)
133#define PORT_LED_GREEN (2<<14) 140#define PORT_LED_GREEN (2<<14)
@@ -148,7 +155,7 @@ struct ehci_regs {
148#define PORT_CSC (1<<1) /* connect status change */ 155#define PORT_CSC (1<<1) /* connect status change */
149#define PORT_CONNECT (1<<0) /* device connected */ 156#define PORT_CONNECT (1<<0) /* device connected */
150#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) 157#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
151} __attribute__ ((packed)); 158};
152 159
153#define USBMODE 0x68 /* USB Device mode */ 160#define USBMODE 0x68 /* USB Device mode */
154#define USBMODE_SDIS (1<<3) /* Stream disable */ 161#define USBMODE_SDIS (1<<3) /* Stream disable */
@@ -157,7 +164,7 @@ struct ehci_regs {
157#define USBMODE_CM_IDLE (0<<0) /* idle state */ 164#define USBMODE_CM_IDLE (0<<0) /* idle state */
158 165
159/* Moorestown has some non-standard registers, partially due to the fact that 166/* Moorestown has some non-standard registers, partially due to the fact that
160 * its EHCI controller has both TT and LPM support. HOSTPCx are extentions to 167 * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to
161 * PORTSCx 168 * PORTSCx
162 */ 169 */
163#define HOSTPC0 0x84 /* HOSTPC extension */ 170#define HOSTPC0 0x84 /* HOSTPC extension */
@@ -192,7 +199,7 @@ struct ehci_dbg_port {
192 u32 data47; 199 u32 data47;
193 u32 address; 200 u32 address;
194#define DBGP_EPADDR(dev, ep) (((dev)<<8)|(ep)) 201#define DBGP_EPADDR(dev, ep) (((dev)<<8)|(ep))
195} __attribute__ ((packed)); 202};
196 203
197#ifdef CONFIG_EARLY_PRINTK_DBGP 204#ifdef CONFIG_EARLY_PRINTK_DBGP
198#include <linux/init.h> 205#include <linux/init.h>
diff --git a/include/linux/usb/functionfs.h b/include/linux/usb/functionfs.h
index 6f649c13193b..7587ef934ba8 100644
--- a/include/linux/usb/functionfs.h
+++ b/include/linux/usb/functionfs.h
@@ -45,7 +45,7 @@ struct usb_functionfs_descs_head {
45 * | off | name | type | description | 45 * | off | name | type | description |
46 * |-----+-----------+--------------+--------------------------------------| 46 * |-----+-----------+--------------+--------------------------------------|
47 * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC | 47 * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
48 * | 4 | lenght | LE32 | length of the whole data chunk | 48 * | 4 | length | LE32 | length of the whole data chunk |
49 * | 8 | fs_count | LE32 | number of full-speed descriptors | 49 * | 8 | fs_count | LE32 | number of full-speed descriptors |
50 * | 12 | hs_count | LE32 | number of high-speed descriptors | 50 * | 12 | hs_count | LE32 | number of high-speed descriptors |
51 * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors | 51 * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
@@ -86,7 +86,7 @@ struct usb_functionfs_strings_head {
86 * | 0 | lang | LE16 | language code | 86 * | 0 | lang | LE16 | language code |
87 * | 2 | strings | String[str_count] | array of strings in given language | 87 * | 2 | strings | String[str_count] | array of strings in given language |
88 * 88 *
89 * For each string ther is one strings entry (ie. there are str_count 89 * For each string there is one strings entry (ie. there are str_count
90 * string entries). Each String is a NUL terminated string encoded in 90 * string entries). Each String is a NUL terminated string encoded in
91 * UTF-8. 91 * UTF-8.
92 */ 92 */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index d3ef42d7d2f0..dd1571db55e7 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -72,7 +72,7 @@ struct usb_ep;
72 * Bulk endpoints can use any size buffers, and can also be used for interrupt 72 * Bulk endpoints can use any size buffers, and can also be used for interrupt
73 * transfers. interrupt-only endpoints can be much less functional. 73 * transfers. interrupt-only endpoints can be much less functional.
74 * 74 *
75 * NOTE: this is analagous to 'struct urb' on the host side, except that 75 * NOTE: this is analogous to 'struct urb' on the host side, except that
76 * it's thinner and promotes more pre-allocation. 76 * it's thinner and promotes more pre-allocation.
77 */ 77 */
78 78
@@ -269,7 +269,7 @@ static inline void usb_ep_free_request(struct usb_ep *ep,
269 * 269 *
270 * Control endpoints ... after getting a setup() callback, the driver queues 270 * Control endpoints ... after getting a setup() callback, the driver queues
271 * one response (even if it would be zero length). That enables the 271 * one response (even if it would be zero length). That enables the
272 * status ack, after transfering data as specified in the response. Setup 272 * status ack, after transferring data as specified in the response. Setup
273 * functions may return negative error codes to generate protocol stalls. 273 * functions may return negative error codes to generate protocol stalls.
274 * (Note that some USB device controllers disallow protocol stall responses 274 * (Note that some USB device controllers disallow protocol stall responses
275 * in some cases.) When control responses are deferred (the response is 275 * in some cases.) When control responses are deferred (the response is
@@ -705,11 +705,6 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
705 * struct usb_gadget_driver - driver for usb 'slave' devices 705 * struct usb_gadget_driver - driver for usb 'slave' devices
706 * @function: String describing the gadget's function 706 * @function: String describing the gadget's function
707 * @speed: Highest speed the driver handles. 707 * @speed: Highest speed the driver handles.
708 * @bind: Invoked when the driver is bound to a gadget, usually
709 * after registering the driver.
710 * At that point, ep0 is fully initialized, and ep_list holds
711 * the currently-available endpoints.
712 * Called in a context that permits sleeping.
713 * @setup: Invoked for ep0 control requests that aren't handled by 708 * @setup: Invoked for ep0 control requests that aren't handled by
714 * the hardware level driver. Most calls must be handled by 709 * the hardware level driver. Most calls must be handled by
715 * the gadget driver, including descriptor and configuration 710 * the gadget driver, including descriptor and configuration
@@ -774,7 +769,6 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
774struct usb_gadget_driver { 769struct usb_gadget_driver {
775 char *function; 770 char *function;
776 enum usb_device_speed speed; 771 enum usb_device_speed speed;
777 int (*bind)(struct usb_gadget *);
778 void (*unbind)(struct usb_gadget *); 772 void (*unbind)(struct usb_gadget *);
779 int (*setup)(struct usb_gadget *, 773 int (*setup)(struct usb_gadget *,
780 const struct usb_ctrlrequest *); 774 const struct usb_ctrlrequest *);
@@ -798,17 +792,19 @@ struct usb_gadget_driver {
798 */ 792 */
799 793
800/** 794/**
801 * usb_gadget_register_driver - register a gadget driver 795 * usb_gadget_probe_driver - probe a gadget driver
802 * @driver:the driver being registered 796 * @driver: the driver being registered
797 * @bind: the driver's bind callback
803 * Context: can sleep 798 * Context: can sleep
804 * 799 *
805 * Call this in your gadget driver's module initialization function, 800 * Call this in your gadget driver's module initialization function,
806 * to tell the underlying usb controller driver about your driver. 801 * to tell the underlying usb controller driver about your driver.
807 * The driver's bind() function will be called to bind it to a 802 * The @bind() function will be called to bind it to a gadget before this
808 * gadget before this registration call returns. It's expected that 803 * registration call returns. It's expected that the @bind() function will
809 * the bind() functions will be in init sections. 804 * be in init sections.
810 */ 805 */
811int usb_gadget_register_driver(struct usb_gadget_driver *driver); 806int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
807 int (*bind)(struct usb_gadget *));
812 808
813/** 809/**
814 * usb_gadget_unregister_driver - unregister a gadget driver 810 * usb_gadget_unregister_driver - unregister a gadget driver
@@ -894,8 +890,8 @@ static inline void usb_free_descriptors(struct usb_descriptor_header **v)
894/* utility wrapping a simple endpoint selection policy */ 890/* utility wrapping a simple endpoint selection policy */
895 891
896extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *, 892extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
897 struct usb_endpoint_descriptor *) __devinit; 893 struct usb_endpoint_descriptor *);
898 894
899extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit; 895extern void usb_ep_autoconfig_reset(struct usb_gadget *);
900 896
901#endif /* __LINUX_USB_GADGET_H */ 897#endif /* __LINUX_USB_GADGET_H */
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 3b571f1ffbb3..0097136ba45d 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -76,6 +76,10 @@ struct usb_hcd {
76 struct kref kref; /* reference counter */ 76 struct kref kref; /* reference counter */
77 77
78 const char *product_desc; /* product/vendor string */ 78 const char *product_desc; /* product/vendor string */
79 int speed; /* Speed for this roothub.
80 * May be different from
81 * hcd->driver->flags & HCD_MASK
82 */
79 char irq_descr[24]; /* driver + bus # */ 83 char irq_descr[24]; /* driver + bus # */
80 84
81 struct timer_list rh_timer; /* drives root-hub polling */ 85 struct timer_list rh_timer; /* drives root-hub polling */
@@ -99,6 +103,8 @@ struct usb_hcd {
99#define HCD_FLAG_POLL_RH 2 /* poll for rh status? */ 103#define HCD_FLAG_POLL_RH 2 /* poll for rh status? */
100#define HCD_FLAG_POLL_PENDING 3 /* status has changed? */ 104#define HCD_FLAG_POLL_PENDING 3 /* status has changed? */
101#define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */ 105#define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */
106#define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
107#define HCD_FLAG_DEAD 6 /* controller has died? */
102 108
103 /* The flags can be tested using these macros; they are likely to 109 /* The flags can be tested using these macros; they are likely to
104 * be slightly faster than test_bit(). 110 * be slightly faster than test_bit().
@@ -108,10 +114,13 @@ struct usb_hcd {
108#define HCD_POLL_RH(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_RH)) 114#define HCD_POLL_RH(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_RH))
109#define HCD_POLL_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_PENDING)) 115#define HCD_POLL_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_PENDING))
110#define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING)) 116#define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING))
117#define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
118#define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD))
111 119
112 /* Flags that get set only during HCD registration or removal. */ 120 /* Flags that get set only during HCD registration or removal. */
113 unsigned rh_registered:1;/* is root hub registered? */ 121 unsigned rh_registered:1;/* is root hub registered? */
114 unsigned rh_pollable:1; /* may we poll the root hub? */ 122 unsigned rh_pollable:1; /* may we poll the root hub? */
123 unsigned msix_enabled:1; /* driver has MSI-X enabled? */
115 124
116 /* The next flag is a stopgap, to be removed when all the HCDs 125 /* The next flag is a stopgap, to be removed when all the HCDs
117 * support the new root-hub polling mechanism. */ 126 * support the new root-hub polling mechanism. */
@@ -137,7 +146,9 @@ struct usb_hcd {
137 * bandwidth_mutex should be dropped after a successful control message 146 * bandwidth_mutex should be dropped after a successful control message
138 * to the device, or resetting the bandwidth after a failed attempt. 147 * to the device, or resetting the bandwidth after a failed attempt.
139 */ 148 */
140 struct mutex bandwidth_mutex; 149 struct mutex *bandwidth_mutex;
150 struct usb_hcd *shared_hcd;
151 struct usb_hcd *primary_hcd;
141 152
142 153
143#define HCD_BUFFER_POOLS 4 154#define HCD_BUFFER_POOLS 4
@@ -200,6 +211,7 @@ struct hc_driver {
200 int flags; 211 int flags;
201#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ 212#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
202#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */ 213#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */
214#define HCD_SHARED 0x0004 /* Two (or more) usb_hcds share HW */
203#define HCD_USB11 0x0010 /* USB 1.1 */ 215#define HCD_USB11 0x0010 /* USB 1.1 */
204#define HCD_USB2 0x0020 /* USB 2.0 */ 216#define HCD_USB2 0x0020 /* USB 2.0 */
205#define HCD_USB3 0x0040 /* USB 3.0 */ 217#define HCD_USB3 0x0040 /* USB 3.0 */
@@ -233,6 +245,19 @@ struct hc_driver {
233 int (*urb_dequeue)(struct usb_hcd *hcd, 245 int (*urb_dequeue)(struct usb_hcd *hcd,
234 struct urb *urb, int status); 246 struct urb *urb, int status);
235 247
248 /*
249 * (optional) these hooks allow an HCD to override the default DMA
250 * mapping and unmapping routines. In general, they shouldn't be
251 * necessary unless the host controller has special DMA requirements,
252 * such as alignment contraints. If these are not specified, the
253 * general usb_hcd_(un)?map_urb_for_dma functions will be used instead
254 * (and it may be a good idea to call these functions in your HCD
255 * implementation)
256 */
257 int (*map_urb_for_dma)(struct usb_hcd *hcd, struct urb *urb,
258 gfp_t mem_flags);
259 void (*unmap_urb_for_dma)(struct usb_hcd *hcd, struct urb *urb);
260
236 /* hw synch, freeing endpoint resources that urb_dequeue can't */ 261 /* hw synch, freeing endpoint resources that urb_dequeue can't */
237 void (*endpoint_disable)(struct usb_hcd *hcd, 262 void (*endpoint_disable)(struct usb_hcd *hcd,
238 struct usb_host_endpoint *ep); 263 struct usb_host_endpoint *ep);
@@ -329,6 +354,10 @@ extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags);
329extern int usb_hcd_unlink_urb(struct urb *urb, int status); 354extern int usb_hcd_unlink_urb(struct urb *urb, int status);
330extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, 355extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb,
331 int status); 356 int status);
357extern int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
358 gfp_t mem_flags);
359extern void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *, struct urb *);
360extern void usb_hcd_unmap_urb_for_dma(struct usb_hcd *, struct urb *);
332extern void usb_hcd_flush_endpoint(struct usb_device *udev, 361extern void usb_hcd_flush_endpoint(struct usb_device *udev,
333 struct usb_host_endpoint *ep); 362 struct usb_host_endpoint *ep);
334extern void usb_hcd_disable_endpoint(struct usb_device *udev, 363extern void usb_hcd_disable_endpoint(struct usb_device *udev,
@@ -344,8 +373,12 @@ extern int usb_hcd_get_frame_number(struct usb_device *udev);
344 373
345extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver, 374extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver,
346 struct device *dev, const char *bus_name); 375 struct device *dev, const char *bus_name);
376extern struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
377 struct device *dev, const char *bus_name,
378 struct usb_hcd *shared_hcd);
347extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd); 379extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd);
348extern void usb_put_hcd(struct usb_hcd *hcd); 380extern void usb_put_hcd(struct usb_hcd *hcd);
381extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd);
349extern int usb_add_hcd(struct usb_hcd *hcd, 382extern int usb_add_hcd(struct usb_hcd *hcd,
350 unsigned int irqnum, unsigned long irqflags); 383 unsigned int irqnum, unsigned long irqflags);
351extern void usb_remove_hcd(struct usb_hcd *hcd); 384extern void usb_remove_hcd(struct usb_hcd *hcd);
@@ -469,6 +502,10 @@ extern void usb_ep0_reinit(struct usb_device *);
469 502
470/*-------------------------------------------------------------------------*/ 503/*-------------------------------------------------------------------------*/
471 504
505/* class requests from USB 3.0 hub spec, table 10-5 */
506#define SetHubDepth (0x3000 | HUB_SET_DEPTH)
507#define GetPortErrorCount (0x8000 | HUB_GET_PORT_ERR_COUNT)
508
472/* 509/*
473 * Generic bandwidth allocation constants/support 510 * Generic bandwidth allocation constants/support
474 */ 511 */
@@ -615,13 +652,6 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
615 652
616/*-------------------------------------------------------------------------*/ 653/*-------------------------------------------------------------------------*/
617 654
618/* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */
619/* bleech -- resurfaced in 2.4.11 or 2.4.12 */
620#define bitmap DeviceRemovable
621
622
623/*-------------------------------------------------------------------------*/
624
625/* random stuff */ 655/* random stuff */
626 656
627#define RUN_CONTEXT (in_irq() ? "in_irq" \ 657#define RUN_CONTEXT (in_irq() ? "in_irq" \
diff --git a/include/linux/usb/intel_mid_otg.h b/include/linux/usb/intel_mid_otg.h
new file mode 100644
index 000000000000..a0ccf795f362
--- /dev/null
+++ b/include/linux/usb/intel_mid_otg.h
@@ -0,0 +1,180 @@
1/*
2 * Intel MID (Langwell/Penwell) USB OTG Transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#ifndef __INTEL_MID_OTG_H
21#define __INTEL_MID_OTG_H
22
23#include <linux/pm.h>
24#include <linux/usb/otg.h>
25#include <linux/notifier.h>
26
27struct intel_mid_otg_xceiv;
28
29/* This is a common data structure for Intel MID platform to
30 * save values of the OTG state machine */
31struct otg_hsm {
32 /* Input */
33 int a_bus_resume;
34 int a_bus_suspend;
35 int a_conn;
36 int a_sess_vld;
37 int a_srp_det;
38 int a_vbus_vld;
39 int b_bus_resume;
40 int b_bus_suspend;
41 int b_conn;
42 int b_se0_srp;
43 int b_ssend_srp;
44 int b_sess_end;
45 int b_sess_vld;
46 int id;
47/* id values */
48#define ID_B 0x05
49#define ID_A 0x04
50#define ID_ACA_C 0x03
51#define ID_ACA_B 0x02
52#define ID_ACA_A 0x01
53 int power_up;
54 int adp_change;
55 int test_device;
56
57 /* Internal variables */
58 int a_set_b_hnp_en;
59 int b_srp_done;
60 int b_hnp_enable;
61 int hnp_poll_enable;
62
63 /* Timeout indicator for timers */
64 int a_wait_vrise_tmout;
65 int a_wait_bcon_tmout;
66 int a_aidl_bdis_tmout;
67 int a_bidl_adis_tmout;
68 int a_bidl_adis_tmr;
69 int a_wait_vfall_tmout;
70 int b_ase0_brst_tmout;
71 int b_bus_suspend_tmout;
72 int b_srp_init_tmout;
73 int b_srp_fail_tmout;
74 int b_srp_fail_tmr;
75 int b_adp_sense_tmout;
76
77 /* Informative variables */
78 int a_bus_drop;
79 int a_bus_req;
80 int a_clr_err;
81 int b_bus_req;
82 int a_suspend_req;
83 int b_bus_suspend_vld;
84
85 /* Output */
86 int drv_vbus;
87 int loc_conn;
88 int loc_sof;
89
90 /* Others */
91 int vbus_srp_up;
92};
93
94/* must provide ULPI access function to read/write registers implemented in
95 * ULPI address space */
96struct iotg_ulpi_access_ops {
97 int (*read)(struct intel_mid_otg_xceiv *iotg, u8 reg, u8 *val);
98 int (*write)(struct intel_mid_otg_xceiv *iotg, u8 reg, u8 val);
99};
100
101#define OTG_A_DEVICE 0x0
102#define OTG_B_DEVICE 0x1
103
104/*
105 * the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact
106 * with device and host drivers to implement the USB OTG related feature. More
107 * function members are added based on otg_transceiver data structure for this
108 * purpose.
109 */
110struct intel_mid_otg_xceiv {
111 struct otg_transceiver otg;
112 struct otg_hsm hsm;
113
114 /* base address */
115 void __iomem *base;
116
117 /* ops to access ulpi */
118 struct iotg_ulpi_access_ops ulpi_ops;
119
120 /* atomic notifier for interrupt context */
121 struct atomic_notifier_head iotg_notifier;
122
123 /* start/stop USB Host function */
124 int (*start_host)(struct intel_mid_otg_xceiv *iotg);
125 int (*stop_host)(struct intel_mid_otg_xceiv *iotg);
126
127 /* start/stop USB Peripheral function */
128 int (*start_peripheral)(struct intel_mid_otg_xceiv *iotg);
129 int (*stop_peripheral)(struct intel_mid_otg_xceiv *iotg);
130
131 /* start/stop ADP sense/probe function */
132 int (*set_adp_probe)(struct intel_mid_otg_xceiv *iotg,
133 bool enabled, int dev);
134 int (*set_adp_sense)(struct intel_mid_otg_xceiv *iotg,
135 bool enabled);
136
137#ifdef CONFIG_PM
138 /* suspend/resume USB host function */
139 int (*suspend_host)(struct intel_mid_otg_xceiv *iotg,
140 pm_message_t message);
141 int (*resume_host)(struct intel_mid_otg_xceiv *iotg);
142
143 int (*suspend_peripheral)(struct intel_mid_otg_xceiv *iotg,
144 pm_message_t message);
145 int (*resume_peripheral)(struct intel_mid_otg_xceiv *iotg);
146#endif
147
148};
149static inline
150struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct otg_transceiver *otg)
151{
152 return container_of(otg, struct intel_mid_otg_xceiv, otg);
153}
154
155#define MID_OTG_NOTIFY_CONNECT 0x0001
156#define MID_OTG_NOTIFY_DISCONN 0x0002
157#define MID_OTG_NOTIFY_HSUSPEND 0x0003
158#define MID_OTG_NOTIFY_HRESUME 0x0004
159#define MID_OTG_NOTIFY_CSUSPEND 0x0005
160#define MID_OTG_NOTIFY_CRESUME 0x0006
161#define MID_OTG_NOTIFY_HOSTADD 0x0007
162#define MID_OTG_NOTIFY_HOSTREMOVE 0x0008
163#define MID_OTG_NOTIFY_CLIENTADD 0x0009
164#define MID_OTG_NOTIFY_CLIENTREMOVE 0x000a
165
166static inline int
167intel_mid_otg_register_notifier(struct intel_mid_otg_xceiv *iotg,
168 struct notifier_block *nb)
169{
170 return atomic_notifier_chain_register(&iotg->iotg_notifier, nb);
171}
172
173static inline void
174intel_mid_otg_unregister_notifier(struct intel_mid_otg_xceiv *iotg,
175 struct notifier_block *nb)
176{
177 atomic_notifier_chain_unregister(&iotg->iotg_notifier, nb);
178}
179
180#endif /* __INTEL_MID_OTG_H */
diff --git a/include/linux/usb/langwell_otg.h b/include/linux/usb/langwell_otg.h
new file mode 100644
index 000000000000..51f17b16d312
--- /dev/null
+++ b/include/linux/usb/langwell_otg.h
@@ -0,0 +1,139 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#ifndef __LANGWELL_OTG_H
21#define __LANGWELL_OTG_H
22
23#include <linux/usb/intel_mid_otg.h>
24
25#define CI_USBCMD 0x30
26# define USBCMD_RST BIT(1)
27# define USBCMD_RS BIT(0)
28#define CI_USBSTS 0x34
29# define USBSTS_SLI BIT(8)
30# define USBSTS_URI BIT(6)
31# define USBSTS_PCI BIT(2)
32#define CI_PORTSC1 0x74
33# define PORTSC_PP BIT(12)
34# define PORTSC_LS (BIT(11) | BIT(10))
35# define PORTSC_SUSP BIT(7)
36# define PORTSC_CCS BIT(0)
37#define CI_HOSTPC1 0xb4
38# define HOSTPC1_PHCD BIT(22)
39#define CI_OTGSC 0xf4
40# define OTGSC_DPIE BIT(30)
41# define OTGSC_1MSE BIT(29)
42# define OTGSC_BSEIE BIT(28)
43# define OTGSC_BSVIE BIT(27)
44# define OTGSC_ASVIE BIT(26)
45# define OTGSC_AVVIE BIT(25)
46# define OTGSC_IDIE BIT(24)
47# define OTGSC_DPIS BIT(22)
48# define OTGSC_1MSS BIT(21)
49# define OTGSC_BSEIS BIT(20)
50# define OTGSC_BSVIS BIT(19)
51# define OTGSC_ASVIS BIT(18)
52# define OTGSC_AVVIS BIT(17)
53# define OTGSC_IDIS BIT(16)
54# define OTGSC_DPS BIT(14)
55# define OTGSC_1MST BIT(13)
56# define OTGSC_BSE BIT(12)
57# define OTGSC_BSV BIT(11)
58# define OTGSC_ASV BIT(10)
59# define OTGSC_AVV BIT(9)
60# define OTGSC_ID BIT(8)
61# define OTGSC_HABA BIT(7)
62# define OTGSC_HADP BIT(6)
63# define OTGSC_IDPU BIT(5)
64# define OTGSC_DP BIT(4)
65# define OTGSC_OT BIT(3)
66# define OTGSC_HAAR BIT(2)
67# define OTGSC_VC BIT(1)
68# define OTGSC_VD BIT(0)
69# define OTGSC_INTEN_MASK (0x7f << 24)
70# define OTGSC_INT_MASK (0x5f << 24)
71# define OTGSC_INTSTS_MASK (0x7f << 16)
72#define CI_USBMODE 0xf8
73# define USBMODE_CM (BIT(1) | BIT(0))
74# define USBMODE_IDLE 0
75# define USBMODE_DEVICE 0x2
76# define USBMODE_HOST 0x3
77#define USBCFG_ADDR 0xff10801c
78#define USBCFG_LEN 4
79# define USBCFG_VBUSVAL BIT(14)
80# define USBCFG_AVALID BIT(13)
81# define USBCFG_BVALID BIT(12)
82# define USBCFG_SESEND BIT(11)
83
84#define INTR_DUMMY_MASK (USBSTS_SLI | USBSTS_URI | USBSTS_PCI)
85
86enum langwell_otg_timer_type {
87 TA_WAIT_VRISE_TMR,
88 TA_WAIT_BCON_TMR,
89 TA_AIDL_BDIS_TMR,
90 TB_ASE0_BRST_TMR,
91 TB_SE0_SRP_TMR,
92 TB_SRP_INIT_TMR,
93 TB_SRP_FAIL_TMR,
94 TB_BUS_SUSPEND_TMR
95};
96
97#define TA_WAIT_VRISE 100
98#define TA_WAIT_BCON 30000
99#define TA_AIDL_BDIS 15000
100#define TB_ASE0_BRST 5000
101#define TB_SE0_SRP 2
102#define TB_SRP_INIT 100
103#define TB_SRP_FAIL 5500
104#define TB_BUS_SUSPEND 500
105
106struct langwell_otg_timer {
107 unsigned long expires; /* Number of count increase to timeout */
108 unsigned long count; /* Tick counter */
109 void (*function)(unsigned long); /* Timeout function */
110 unsigned long data; /* Data passed to function */
111 struct list_head list;
112};
113
114struct langwell_otg {
115 struct intel_mid_otg_xceiv iotg;
116 struct device *dev;
117
118 void __iomem *usbcfg; /* SCCBUSB config Reg */
119
120 unsigned region;
121 unsigned cfg_region;
122
123 struct work_struct work;
124 struct workqueue_struct *qwork;
125 struct timer_list hsm_timer;
126
127 spinlock_t lock;
128 spinlock_t wq_lock;
129
130 struct notifier_block iotg_notifier;
131};
132
133static inline
134struct langwell_otg *mid_xceiv_to_lnw(struct intel_mid_otg_xceiv *iotg)
135{
136 return container_of(iotg, struct langwell_otg, iotg);
137}
138
139#endif /* __LANGWELL_OTG_H__ */
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h
index 1d1040865661..c8c52e3c91de 100644
--- a/include/linux/usb/midi.h
+++ b/include/linux/usb/midi.h
@@ -70,7 +70,7 @@ struct usb_midi_out_jack_descriptor {
70 __u8 bJackID; 70 __u8 bJackID;
71 __u8 bNrInputPins; /* p */ 71 __u8 bNrInputPins; /* p */
72 struct usb_midi_source_pin pins[]; /* [p] */ 72 struct usb_midi_source_pin pins[]; /* [p] */
73 /*__u8 iJack; -- ommitted due to variable-sized pins[] */ 73 /*__u8 iJack; -- omitted due to variable-sized pins[] */
74} __attribute__ ((packed)); 74} __attribute__ ((packed));
75 75
76#define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p)) 76#define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p))
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
new file mode 100644
index 000000000000..00311fe9d0df
--- /dev/null
+++ b/include/linux/usb/msm_hsusb.h
@@ -0,0 +1,185 @@
1/* linux/include/asm-arm/arch-msm/hsusb.h
2 *
3 * Copyright (C) 2008 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef __ASM_ARCH_MSM_HSUSB_H
19#define __ASM_ARCH_MSM_HSUSB_H
20
21#include <linux/types.h>
22#include <linux/usb/otg.h>
23
24/**
25 * Supported USB modes
26 *
27 * USB_PERIPHERAL Only peripheral mode is supported.
28 * USB_HOST Only host mode is supported.
29 * USB_OTG OTG mode is supported.
30 *
31 */
32enum usb_mode_type {
33 USB_NONE = 0,
34 USB_PERIPHERAL,
35 USB_HOST,
36 USB_OTG,
37};
38
39/**
40 * OTG control
41 *
42 * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host
43 * only configuration.
44 * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY.
45 * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware.
46 * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs.
47 *
48 */
49enum otg_control_type {
50 OTG_NO_CONTROL = 0,
51 OTG_PHY_CONTROL,
52 OTG_PMIC_CONTROL,
53 OTG_USER_CONTROL,
54};
55
56/**
57 * PHY used in
58 *
59 * INVALID_PHY Unsupported PHY
60 * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY
61 * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY
62 *
63 */
64enum msm_usb_phy_type {
65 INVALID_PHY = 0,
66 CI_45NM_INTEGRATED_PHY,
67 SNPS_28NM_INTEGRATED_PHY,
68};
69
70#define IDEV_CHG_MAX 1500
71#define IUNIT 100
72
73/**
74 * Different states involved in USB charger detection.
75 *
76 * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
77 * process is not yet started.
78 * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
79 * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
80 * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
81 * between SDP and DCP/CDP).
82 * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
83 * between DCP and CDP).
84 * USB_CHG_STATE_DETECTED USB charger type is determined.
85 *
86 */
87enum usb_chg_state {
88 USB_CHG_STATE_UNDEFINED = 0,
89 USB_CHG_STATE_WAIT_FOR_DCD,
90 USB_CHG_STATE_DCD_DONE,
91 USB_CHG_STATE_PRIMARY_DONE,
92 USB_CHG_STATE_SECONDARY_DONE,
93 USB_CHG_STATE_DETECTED,
94};
95
96/**
97 * USB charger types
98 *
99 * USB_INVALID_CHARGER Invalid USB charger.
100 * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
101 * on USB2.0 compliant host/hub.
102 * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
103 * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
104 * IDEV_CHG_MAX can be drawn irrespective of USB state.
105 *
106 */
107enum usb_chg_type {
108 USB_INVALID_CHARGER = 0,
109 USB_SDP_CHARGER,
110 USB_DCP_CHARGER,
111 USB_CDP_CHARGER,
112};
113
114/**
115 * struct msm_otg_platform_data - platform device data
116 * for msm_otg driver.
117 * @phy_init_seq: PHY configuration sequence. val, reg pairs
118 * terminated by -1.
119 * @vbus_power: VBUS power on/off routine.
120 * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
121 * @mode: Supported mode (OTG/peripheral/host).
122 * @otg_control: OTG switch controlled by user/Id pin
123 * @default_mode: Default operational mode. Applicable only if
124 * OTG switch is controller by user.
125 * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
126 * dfab_usb_hs_clk in case of 8660 and 8960.
127 */
128struct msm_otg_platform_data {
129 int *phy_init_seq;
130 void (*vbus_power)(bool on);
131 unsigned power_budget;
132 enum usb_mode_type mode;
133 enum otg_control_type otg_control;
134 enum usb_mode_type default_mode;
135 enum msm_usb_phy_type phy_type;
136 void (*setup_gpio)(enum usb_otg_state state);
137 char *pclk_src_name;
138};
139
140/**
141 * struct msm_otg: OTG driver data. Shared by HCD and DCD.
142 * @otg: USB OTG Transceiver structure.
143 * @pdata: otg device platform data.
144 * @irq: IRQ number assigned for HSUSB controller.
145 * @clk: clock struct of usb_hs_clk.
146 * @pclk: clock struct of usb_hs_pclk.
147 * @pclk_src: pclk source for voting.
148 * @phy_reset_clk: clock struct of usb_phy_clk.
149 * @core_clk: clock struct of usb_hs_core_clk.
150 * @regs: ioremapped register base address.
151 * @inputs: OTG state machine inputs(Id, SessValid etc).
152 * @sm_work: OTG state machine work.
153 * @in_lpm: indicates low power mode (LPM) state.
154 * @async_int: Async interrupt arrived.
155 * @cur_power: The amount of mA available from downstream port.
156 * @chg_work: Charger detection work.
157 * @chg_state: The state of charger detection process.
158 * @chg_type: The type of charger attached.
159 * @dcd_retires: The retry count used to track Data contact
160 * detection process.
161 */
162struct msm_otg {
163 struct otg_transceiver otg;
164 struct msm_otg_platform_data *pdata;
165 int irq;
166 struct clk *clk;
167 struct clk *pclk;
168 struct clk *pclk_src;
169 struct clk *phy_reset_clk;
170 struct clk *core_clk;
171 void __iomem *regs;
172#define ID 0
173#define B_SESS_VLD 1
174 unsigned long inputs;
175 struct work_struct sm_work;
176 atomic_t in_lpm;
177 int async_int;
178 unsigned cur_power;
179 struct delayed_work chg_work;
180 enum usb_chg_state chg_state;
181 enum usb_chg_type chg_type;
182 u8 dcd_retries;
183};
184
185#endif
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
new file mode 100644
index 000000000000..6e97a2d3d39f
--- /dev/null
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -0,0 +1,57 @@
1/*
2 * Copyright (C) 2007 Google, Inc.
3 * Author: Brian Swetland <swetland@google.com>
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__
17#define __LINUX_USB_GADGET_MSM72K_UDC_H__
18
19#define USB_AHBBURST (MSM_USB_BASE + 0x0090)
20#define USB_AHBMODE (MSM_USB_BASE + 0x0098)
21#define USB_CAPLENGTH (MSM_USB_BASE + 0x0100) /* 8 bit */
22
23#define USB_USBCMD (MSM_USB_BASE + 0x0140)
24#define USB_PORTSC (MSM_USB_BASE + 0x0184)
25#define USB_OTGSC (MSM_USB_BASE + 0x01A4)
26#define USB_USBMODE (MSM_USB_BASE + 0x01A8)
27#define USB_PHY_CTRL (MSM_USB_BASE + 0x0240)
28
29#define USBCMD_RESET 2
30#define USB_USBINTR (MSM_USB_BASE + 0x0148)
31
32#define PORTSC_PHCD (1 << 23) /* phy suspend mode */
33#define PORTSC_PTS_MASK (3 << 30)
34#define PORTSC_PTS_ULPI (3 << 30)
35
36#define USB_ULPI_VIEWPORT (MSM_USB_BASE + 0x0170)
37#define ULPI_RUN (1 << 30)
38#define ULPI_WRITE (1 << 29)
39#define ULPI_READ (0 << 29)
40#define ULPI_ADDR(n) (((n) & 255) << 16)
41#define ULPI_DATA(n) ((n) & 255)
42#define ULPI_DATA_READ(n) (((n) >> 8) & 255)
43
44#define ASYNC_INTR_CTRL (1 << 29) /* Enable async interrupt */
45#define ULPI_STP_CTRL (1 << 30) /* Block communication with PHY */
46#define PHY_RETEN (1 << 1) /* PHY retention enable/disable */
47
48/* OTG definitions */
49#define OTGSC_INTSTS_MASK (0x7f << 16)
50#define OTGSC_ID (1 << 8)
51#define OTGSC_BSV (1 << 11)
52#define OTGSC_IDIS (1 << 16)
53#define OTGSC_BSVIS (1 << 19)
54#define OTGSC_IDIE (1 << 24)
55#define OTGSC_BSVIE (1 << 27)
56
57#endif /* __LINUX_USB_GADGET_MSM72K_UDC_H__ */
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index ee2dd1d506ed..eb505250940a 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -3,7 +3,7 @@
3 * Inventra (Multidrop) Highspeed Dual-Role Controllers: (M)HDRC. 3 * Inventra (Multidrop) Highspeed Dual-Role Controllers: (M)HDRC.
4 * 4 *
5 * Board initialization should put one of these into dev->platform_data, 5 * Board initialization should put one of these into dev->platform_data,
6 * probably on some platform_device named "musb_hdrc". It encapsulates 6 * probably on some platform_device named "musb-hdrc". It encapsulates
7 * key configuration differences between boards. 7 * key configuration differences between boards.
8 */ 8 */
9 9
@@ -89,6 +89,8 @@ struct musb_hdrc_config {
89 /* A GPIO controlling VRSEL in Blackfin */ 89 /* A GPIO controlling VRSEL in Blackfin */
90 unsigned int gpio_vrsel; 90 unsigned int gpio_vrsel;
91 unsigned int gpio_vrsel_active; 91 unsigned int gpio_vrsel_active;
92 /* musb CLKIN in Blackfin in MHZ */
93 unsigned char clkin;
92#endif 94#endif
93 95
94}; 96};
@@ -118,14 +120,14 @@ struct musb_hdrc_platform_data {
118 /* Power the device on or off */ 120 /* Power the device on or off */
119 int (*set_power)(int state); 121 int (*set_power)(int state);
120 122
121 /* Turn device clock on or off */
122 int (*set_clock)(struct clk *clock, int is_on);
123
124 /* MUSB configuration-specific details */ 123 /* MUSB configuration-specific details */
125 struct musb_hdrc_config *config; 124 struct musb_hdrc_config *config;
126 125
127 /* Architecture specific board data */ 126 /* Architecture specific board data */
128 void *board_data; 127 void *board_data;
128
129 /* Platform specific struct musb_ops pointer */
130 const void *platform_ops;
129}; 131};
130 132
131 133
diff --git a/include/linux/usb/ncm.h b/include/linux/usb/ncm.h
deleted file mode 100644
index 006d1064c8b2..000000000000
--- a/include/linux/usb/ncm.h
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 * USB CDC NCM auxiliary definitions
3 */
4
5#ifndef __LINUX_USB_NCM_H
6#define __LINUX_USB_NCM_H
7
8#include <linux/types.h>
9#include <linux/usb/cdc.h>
10#include <asm/unaligned.h>
11
12#define NCM_NTB_MIN_IN_SIZE 2048
13#define NCM_NTB_MIN_OUT_SIZE 2048
14
15#define NCM_CONTROL_TIMEOUT (5 * 1000)
16
17/* bmNetworkCapabilities */
18
19#define NCM_NCAP_ETH_FILTER (1 << 0)
20#define NCM_NCAP_NET_ADDRESS (1 << 1)
21#define NCM_NCAP_ENCAP_COMM (1 << 2)
22#define NCM_NCAP_MAX_DGRAM (1 << 3)
23#define NCM_NCAP_CRC_MODE (1 << 4)
24
25/*
26 * Here are options for NCM Datagram Pointer table (NDP) parser.
27 * There are 2 different formats: NDP16 and NDP32 in the spec (ch. 3),
28 * in NDP16 offsets and sizes fields are 1 16bit word wide,
29 * in NDP32 -- 2 16bit words wide. Also signatures are different.
30 * To make the parser code the same, put the differences in the structure,
31 * and switch pointers to the structures when the format is changed.
32 */
33
34struct ndp_parser_opts {
35 u32 nth_sign;
36 u32 ndp_sign;
37 unsigned nth_size;
38 unsigned ndp_size;
39 unsigned ndplen_align;
40 /* sizes in u16 units */
41 unsigned dgram_item_len; /* index or length */
42 unsigned block_length;
43 unsigned fp_index;
44 unsigned reserved1;
45 unsigned reserved2;
46 unsigned next_fp_index;
47};
48
49#define INIT_NDP16_OPTS { \
50 .nth_sign = NCM_NTH16_SIGN, \
51 .ndp_sign = NCM_NDP16_NOCRC_SIGN, \
52 .nth_size = sizeof(struct usb_cdc_ncm_nth16), \
53 .ndp_size = sizeof(struct usb_cdc_ncm_ndp16), \
54 .ndplen_align = 4, \
55 .dgram_item_len = 1, \
56 .block_length = 1, \
57 .fp_index = 1, \
58 .reserved1 = 0, \
59 .reserved2 = 0, \
60 .next_fp_index = 1, \
61 }
62
63
64#define INIT_NDP32_OPTS { \
65 .nth_sign = NCM_NTH32_SIGN, \
66 .ndp_sign = NCM_NDP32_NOCRC_SIGN, \
67 .nth_size = sizeof(struct usb_cdc_ncm_nth32), \
68 .ndp_size = sizeof(struct usb_cdc_ncm_ndp32), \
69 .ndplen_align = 8, \
70 .dgram_item_len = 2, \
71 .block_length = 2, \
72 .fp_index = 2, \
73 .reserved1 = 1, \
74 .reserved2 = 2, \
75 .next_fp_index = 2, \
76 }
77
78static inline void put_ncm(__le16 **p, unsigned size, unsigned val)
79{
80 switch (size) {
81 case 1:
82 put_unaligned_le16((u16)val, *p);
83 break;
84 case 2:
85 put_unaligned_le32((u32)val, *p);
86
87 break;
88 default:
89 BUG();
90 }
91
92 *p += size;
93}
94
95static inline unsigned get_ncm(__le16 **p, unsigned size)
96{
97 unsigned tmp;
98
99 switch (size) {
100 case 1:
101 tmp = get_unaligned_le16(*p);
102 break;
103 case 2:
104 tmp = get_unaligned_le32(*p);
105 break;
106 default:
107 BUG();
108 }
109
110 *p += size;
111 return tmp;
112}
113
114#endif /* __LINUX_USB_NCM_H */
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 545cba73ccaf..d87f44f5b04e 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -66,6 +66,7 @@ struct otg_transceiver {
66 66
67 u8 default_a; 67 u8 default_a;
68 enum usb_otg_state state; 68 enum usb_otg_state state;
69 enum usb_xceiv_events last_event;
69 70
70 struct usb_bus *host; 71 struct usb_bus *host;
71 struct usb_gadget *gadget; 72 struct usb_gadget *gadget;
@@ -74,7 +75,7 @@ struct otg_transceiver {
74 void __iomem *io_priv; 75 void __iomem *io_priv;
75 76
76 /* for notification of usb_xceiv_events */ 77 /* for notification of usb_xceiv_events */
77 struct blocking_notifier_head notifier; 78 struct atomic_notifier_head notifier;
78 79
79 /* to pass extra port status to the root hub */ 80 /* to pass extra port status to the root hub */
80 u16 port_status; 81 u16 port_status;
@@ -116,7 +117,7 @@ struct otg_transceiver {
116/* for board-specific init logic */ 117/* for board-specific init logic */
117extern int otg_set_transceiver(struct otg_transceiver *); 118extern int otg_set_transceiver(struct otg_transceiver *);
118 119
119#if defined(CONFIG_NOP_USB_XCEIV) || defined(CONFIG_NOP_USB_XCEIV_MODULE) 120#if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE))
120/* sometimes transceivers are accessed only through e.g. ULPI */ 121/* sometimes transceivers are accessed only through e.g. ULPI */
121extern void usb_nop_xceiv_register(void); 122extern void usb_nop_xceiv_register(void);
122extern void usb_nop_xceiv_unregister(void); 123extern void usb_nop_xceiv_unregister(void);
@@ -164,8 +165,25 @@ otg_shutdown(struct otg_transceiver *otg)
164} 165}
165 166
166/* for usb host and peripheral controller drivers */ 167/* for usb host and peripheral controller drivers */
168#ifdef CONFIG_USB_OTG_UTILS
167extern struct otg_transceiver *otg_get_transceiver(void); 169extern struct otg_transceiver *otg_get_transceiver(void);
168extern void otg_put_transceiver(struct otg_transceiver *); 170extern void otg_put_transceiver(struct otg_transceiver *);
171extern const char *otg_state_string(enum usb_otg_state state);
172#else
173static inline struct otg_transceiver *otg_get_transceiver(void)
174{
175 return NULL;
176}
177
178static inline void otg_put_transceiver(struct otg_transceiver *x)
179{
180}
181
182static inline const char *otg_state_string(enum usb_otg_state state)
183{
184 return NULL;
185}
186#endif
169 187
170/* Context: can sleep */ 188/* Context: can sleep */
171static inline int 189static inline int
@@ -223,13 +241,13 @@ otg_start_srp(struct otg_transceiver *otg)
223static inline int 241static inline int
224otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb) 242otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
225{ 243{
226 return blocking_notifier_chain_register(&otg->notifier, nb); 244 return atomic_notifier_chain_register(&otg->notifier, nb);
227} 245}
228 246
229static inline void 247static inline void
230otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb) 248otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
231{ 249{
232 blocking_notifier_chain_unregister(&otg->notifier, nb); 250 atomic_notifier_chain_unregister(&otg->notifier, nb);
233} 251}
234 252
235/* for OTG controller drivers (and maybe other stuff) */ 253/* for OTG controller drivers (and maybe other stuff) */
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
new file mode 100644
index 000000000000..3a7f1d982dd6
--- /dev/null
+++ b/include/linux/usb/renesas_usbhs.h
@@ -0,0 +1,156 @@
1/*
2 * Renesas USB
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */
17#ifndef RENESAS_USB_H
18#define RENESAS_USB_H
19#include <linux/platform_device.h>
20#include <linux/usb/ch9.h>
21
22/*
23 * module type
24 *
25 * it will be return value from get_id
26 */
27enum {
28 USBHS_HOST = 0,
29 USBHS_GADGET,
30 USBHS_MAX,
31};
32
33/*
34 * callback functions table for driver
35 *
36 * These functions are called from platform for driver.
37 * Callback function's pointer will be set before
38 * renesas_usbhs_platform_callback :: hardware_init was called
39 */
40struct renesas_usbhs_driver_callback {
41 int (*notify_hotplug)(struct platform_device *pdev);
42};
43
44/*
45 * callback functions for platform
46 *
47 * These functions are called from driver for platform
48 */
49struct renesas_usbhs_platform_callback {
50
51 /*
52 * option:
53 *
54 * Hardware init function for platform.
55 * it is called when driver was probed.
56 */
57 int (*hardware_init)(struct platform_device *pdev);
58
59 /*
60 * option:
61 *
62 * Hardware exit function for platform.
63 * it is called when driver was removed
64 */
65 void (*hardware_exit)(struct platform_device *pdev);
66
67 /*
68 * option:
69 *
70 * Phy reset for platform
71 */
72 void (*phy_reset)(struct platform_device *pdev);
73
74 /*
75 * get USB ID function
76 * - USBHS_HOST
77 * - USBHS_GADGET
78 */
79 int (*get_id)(struct platform_device *pdev);
80
81 /*
82 * get VBUS status function.
83 */
84 int (*get_vbus)(struct platform_device *pdev);
85};
86
87/*
88 * parameters for renesas usbhs
89 *
90 * some register needs USB chip specific parameters.
91 * This struct show it to driver
92 */
93struct renesas_usbhs_driver_param {
94 /*
95 * pipe settings
96 */
97 u32 *pipe_type; /* array of USB_ENDPOINT_XFER_xxx (from ep0) */
98 int pipe_size; /* pipe_type array size */
99
100 /*
101 * option:
102 *
103 * for BUSWAIT :: BWAIT
104 * */
105 int buswait_bwait;
106
107 /*
108 * option:
109 *
110 * delay time from notify_hotplug callback
111 */
112 int detection_delay;
113};
114
115/*
116 * option:
117 *
118 * platform information for renesas_usbhs driver.
119 */
120struct renesas_usbhs_platform_info {
121 /*
122 * option:
123 *
124 * platform set these functions before
125 * call platform_add_devices if needed
126 */
127 struct renesas_usbhs_platform_callback platform_callback;
128
129 /*
130 * driver set these callback functions pointer.
131 * platform can use it on callback functions
132 */
133 struct renesas_usbhs_driver_callback driver_callback;
134
135 /*
136 * option:
137 *
138 * driver use these param for some register
139 */
140 struct renesas_usbhs_driver_param driver_param;
141};
142
143/*
144 * macro for platform
145 */
146#define renesas_usbhs_get_info(pdev)\
147 ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
148
149#define renesas_usbhs_call_notify_hotplug(pdev) \
150 ({ \
151 struct renesas_usbhs_driver_callback *dc; \
152 dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \
153 if (dc && dc->notify_hotplug) \
154 dc->notify_hotplug(pdev); \
155 })
156#endif /* RENESAS_USB_H */
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index 05ef52861988..88fceb718c77 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -256,6 +256,8 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */
256#define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001 256#define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001
257#define FLAG_RNDIS_PHYM_WIRELESS 0x0002 257#define FLAG_RNDIS_PHYM_WIRELESS 0x0002
258 258
259/* Flags for driver_info::data */
260#define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */
259 261
260extern void rndis_status(struct usbnet *dev, struct urb *urb); 262extern void rndis_status(struct usbnet *dev, struct urb *urb);
261extern int 263extern int
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 55675b1efb28..b29f70b2ecae 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -191,7 +191,8 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
191 * @id_table: pointer to a list of usb_device_id structures that define all 191 * @id_table: pointer to a list of usb_device_id structures that define all
192 * of the devices this structure can support. 192 * of the devices this structure can support.
193 * @num_ports: the number of different ports this device will have. 193 * @num_ports: the number of different ports this device will have.
194 * @bulk_in_size: bytes to allocate for bulk-in buffer (0 = end-point size) 194 * @bulk_in_size: minimum number of bytes to allocate for bulk-in buffer
195 * (0 = end-point size)
195 * @bulk_out_size: bytes to allocate for bulk-out buffer (0 = end-point size) 196 * @bulk_out_size: bytes to allocate for bulk-out buffer (0 = end-point size)
196 * @calc_num_ports: pointer to a function to determine how many ports this 197 * @calc_num_ports: pointer to a function to determine how many ports this
197 * device has dynamically. It will be called after the probe() 198 * device has dynamically. It will be called after the probe()
@@ -260,7 +261,7 @@ struct usb_serial_driver {
260 const unsigned char *buf, int count); 261 const unsigned char *buf, int count);
261 /* Called only by the tty layer */ 262 /* Called only by the tty layer */
262 int (*write_room)(struct tty_struct *tty); 263 int (*write_room)(struct tty_struct *tty);
263 int (*ioctl)(struct tty_struct *tty, struct file *file, 264 int (*ioctl)(struct tty_struct *tty,
264 unsigned int cmd, unsigned long arg); 265 unsigned int cmd, unsigned long arg);
265 void (*set_termios)(struct tty_struct *tty, 266 void (*set_termios)(struct tty_struct *tty,
266 struct usb_serial_port *port, struct ktermios *old); 267 struct usb_serial_port *port, struct ktermios *old);
@@ -268,9 +269,11 @@ struct usb_serial_driver {
268 int (*chars_in_buffer)(struct tty_struct *tty); 269 int (*chars_in_buffer)(struct tty_struct *tty);
269 void (*throttle)(struct tty_struct *tty); 270 void (*throttle)(struct tty_struct *tty);
270 void (*unthrottle)(struct tty_struct *tty); 271 void (*unthrottle)(struct tty_struct *tty);
271 int (*tiocmget)(struct tty_struct *tty, struct file *file); 272 int (*tiocmget)(struct tty_struct *tty);
272 int (*tiocmset)(struct tty_struct *tty, struct file *file, 273 int (*tiocmset)(struct tty_struct *tty,
273 unsigned int set, unsigned int clear); 274 unsigned int set, unsigned int clear);
275 int (*get_icount)(struct tty_struct *tty,
276 struct serial_icounter_struct *icount);
274 /* Called by the tty layer for port level work. There may or may not 277 /* Called by the tty layer for port level work. There may or may not
275 be an attached tty at this point */ 278 be an attached tty at this point */
276 void (*dtr_rts)(struct usb_serial_port *port, int on); 279 void (*dtr_rts)(struct usb_serial_port *port, int on);
@@ -345,6 +348,9 @@ extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port,
345extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port, 348extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port,
346 unsigned int ch); 349 unsigned int ch);
347extern int usb_serial_handle_break(struct usb_serial_port *port); 350extern int usb_serial_handle_break(struct usb_serial_port *port);
351extern void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
352 struct tty_struct *tty,
353 unsigned int status);
348 354
349 355
350extern int usb_serial_bus_register(struct usb_serial_driver *device); 356extern int usb_serial_bus_register(struct usb_serial_driver *device);
diff --git a/include/linux/usb/storage.h b/include/linux/usb/storage.h
new file mode 100644
index 000000000000..d7fc910f1dc4
--- /dev/null
+++ b/include/linux/usb/storage.h
@@ -0,0 +1,48 @@
1#ifndef __LINUX_USB_STORAGE_H
2#define __LINUX_USB_STORAGE_H
3
4/*
5 * linux/usb/storage.h
6 *
7 * Copyright Matthew Wilcox for Intel Corp, 2010
8 *
9 * This file contains definitions taken from the
10 * USB Mass Storage Class Specification Overview
11 *
12 * Distributed under the terms of the GNU GPL, version two.
13 */
14
15/* Storage subclass codes */
16
17#define USB_SC_RBC 0x01 /* Typically, flash devices */
18#define USB_SC_8020 0x02 /* CD-ROM */
19#define USB_SC_QIC 0x03 /* QIC-157 Tapes */
20#define USB_SC_UFI 0x04 /* Floppy */
21#define USB_SC_8070 0x05 /* Removable media */
22#define USB_SC_SCSI 0x06 /* Transparent */
23#define USB_SC_LOCKABLE 0x07 /* Password-protected */
24
25#define USB_SC_ISD200 0xf0 /* ISD200 ATA */
26#define USB_SC_CYP_ATACB 0xf1 /* Cypress ATACB */
27#define USB_SC_DEVICE 0xff /* Use device's value */
28
29/* Storage protocol codes */
30
31#define USB_PR_CBI 0x00 /* Control/Bulk/Interrupt */
32#define USB_PR_CB 0x01 /* Control/Bulk w/o interrupt */
33#define USB_PR_BULK 0x50 /* bulk only */
34#define USB_PR_UAS 0x62 /* USB Attached SCSI */
35
36#define USB_PR_USBAT 0x80 /* SCM-ATAPI bridge */
37#define USB_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */
38#define USB_PR_SDDR55 0x82 /* SDDR-55 (made up) */
39#define USB_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
40#define USB_PR_FREECOM 0xf1 /* Freecom */
41#define USB_PR_DATAFAB 0xf2 /* Datafab chipsets */
42#define USB_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */
43#define USB_PR_ALAUDA 0xf4 /* Alauda chipsets */
44#define USB_PR_KARMA 0xf5 /* Rio Karma */
45
46#define USB_PR_DEVICE 0xff /* Use device's value */
47
48#endif
diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h
index 82b1507f4735..9595796d62ed 100644
--- a/include/linux/usb/ulpi.h
+++ b/include/linux/usb/ulpi.h
@@ -184,4 +184,9 @@
184struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops, 184struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops,
185 unsigned int flags); 185 unsigned int flags);
186 186
187#ifdef CONFIG_USB_ULPI_VIEWPORT
188/* access ops for controllers with a viewport register */
189extern struct otg_io_access_ops ulpi_viewport_access_ops;
190#endif
191
187#endif /* __LINUX_USB_ULPI_H */ 192#endif /* __LINUX_USB_ULPI_H */
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 7ae27a473818..605b0aa8d852 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -68,6 +68,7 @@ struct usbnet {
68# define EVENT_RX_PAUSED 5 68# define EVENT_RX_PAUSED 5
69# define EVENT_DEV_WAKING 6 69# define EVENT_DEV_WAKING 6
70# define EVENT_DEV_ASLEEP 7 70# define EVENT_DEV_ASLEEP 7
71# define EVENT_DEV_OPEN 8
71}; 72};
72 73
73static inline struct usb_driver *driver_of(struct usb_interface *intf) 74static inline struct usb_driver *driver_of(struct usb_interface *intf)
@@ -97,6 +98,15 @@ struct driver_info {
97 98
98#define FLAG_LINK_INTR 0x0800 /* updates link (carrier) status */ 99#define FLAG_LINK_INTR 0x0800 /* updates link (carrier) status */
99 100
101#define FLAG_POINTTOPOINT 0x1000 /* possibly use "usb%d" names */
102
103/*
104 * Indicates to usbnet, that USB driver accumulates multiple IP packets.
105 * Affects statistic (counters) and short packet handling.
106 */
107#define FLAG_MULTI_PACKET 0x2000
108#define FLAG_RX_ASSEMBLE 0x4000 /* rx packets may span >1 frames */
109
100 /* init device ... can sleep, or cause probe() failure */ 110 /* init device ... can sleep, or cause probe() failure */
101 int (*bind)(struct usbnet *, struct usb_interface *); 111 int (*bind)(struct usbnet *, struct usb_interface *);
102 112
@@ -166,7 +176,9 @@ struct cdc_state {
166}; 176};
167 177
168extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *); 178extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
179extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *);
169extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *); 180extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *);
181extern void usbnet_cdc_status(struct usbnet *, struct urb *);
170 182
171/* CDC and RNDIS support the same host-chosen packet filters for IN transfers */ 183/* CDC and RNDIS support the same host-chosen packet filters for IN transfers */
172#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ 184#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \
diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
index 63ebdcc5dda6..0c4d4ca370ec 100644
--- a/include/linux/usb/wusb.h
+++ b/include/linux/usb/wusb.h
@@ -126,7 +126,7 @@ enum {
126/** 126/**
127 * WUSB IE: Channel Stop (WUSB1.0[7.5.8]) 127 * WUSB IE: Channel Stop (WUSB1.0[7.5.8])
128 * 128 *
129 * Tells devices the host is going to stop sending MMCs and will dissapear. 129 * Tells devices the host is going to stop sending MMCs and will disappear.
130 */ 130 */
131struct wuie_channel_stop { 131struct wuie_channel_stop {
132 struct wuie_hdr hdr; 132 struct wuie_hdr hdr;
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index a4b947e470a5..17df3600bcef 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -58,7 +58,13 @@
58 US_FLAG(CAPACITY_OK, 0x00010000) \ 58 US_FLAG(CAPACITY_OK, 0x00010000) \
59 /* READ CAPACITY response is correct */ \ 59 /* READ CAPACITY response is correct */ \
60 US_FLAG(BAD_SENSE, 0x00020000) \ 60 US_FLAG(BAD_SENSE, 0x00020000) \
61 /* Bad Sense (never more than 18 bytes) */ 61 /* Bad Sense (never more than 18 bytes) */ \
62 US_FLAG(NO_READ_DISC_INFO, 0x00040000) \
63 /* cannot handle READ_DISC_INFO */ \
64 US_FLAG(NO_READ_CAPACITY_16, 0x00080000) \
65 /* cannot handle READ_CAPACITY_16 */ \
66 US_FLAG(INITIAL_READ10, 0x00100000) \
67 /* Initial READ(10) (and others) must be retried */
62 68
63#define US_FLAG(name, value) US_FL_##name = value , 69#define US_FLAG(name, value) US_FL_##name = value ,
64enum { US_DO_ALL_FLAGS }; 70enum { US_DO_ALL_FLAGS };
@@ -74,42 +80,7 @@ enum { US_DO_ALL_FLAGS };
74#define USB_US_TYPE(flags) (((flags) >> 24) & 0xFF) 80#define USB_US_TYPE(flags) (((flags) >> 24) & 0xFF)
75#define USB_US_ORIG_FLAGS(flags) ((flags) & 0x00FFFFFF) 81#define USB_US_ORIG_FLAGS(flags) ((flags) & 0x00FFFFFF)
76 82
77/* 83#include <linux/usb/storage.h>
78 * This is probably not the best place to keep these constants, conceptually.
79 * But it's the only header included into all places which need them.
80 */
81
82/* Sub Classes */
83
84#define US_SC_RBC 0x01 /* Typically, flash devices */
85#define US_SC_8020 0x02 /* CD-ROM */
86#define US_SC_QIC 0x03 /* QIC-157 Tapes */
87#define US_SC_UFI 0x04 /* Floppy */
88#define US_SC_8070 0x05 /* Removable media */
89#define US_SC_SCSI 0x06 /* Transparent */
90#define US_SC_LOCKABLE 0x07 /* Password-protected */
91
92#define US_SC_ISD200 0xf0 /* ISD200 ATA */
93#define US_SC_CYP_ATACB 0xf1 /* Cypress ATACB */
94#define US_SC_DEVICE 0xff /* Use device's value */
95
96/* Protocols */
97
98#define US_PR_CBI 0x00 /* Control/Bulk/Interrupt */
99#define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */
100#define US_PR_BULK 0x50 /* bulk only */
101
102#define US_PR_USBAT 0x80 /* SCM-ATAPI bridge */
103#define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */
104#define US_PR_SDDR55 0x82 /* SDDR-55 (made up) */
105#define US_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
106#define US_PR_FREECOM 0xf1 /* Freecom */
107#define US_PR_DATAFAB 0xf2 /* Datafab chipsets */
108#define US_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */
109#define US_PR_ALAUDA 0xf4 /* Alauda chipsets */
110#define US_PR_KARMA 0xf5 /* Rio Karma */
111
112#define US_PR_DEVICE 0xff /* Use device's value */
113 84
114/* 85/*
115 */ 86 */
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index 8178156711f9..faf467944baf 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -6,7 +6,7 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/err.h> 7#include <linux/err.h>
8 8
9#define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 8) 9#define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 7)
10#define UIDHASH_SZ (1 << UIDHASH_BITS) 10#define UIDHASH_SZ (1 << UIDHASH_BITS)
11 11
12struct user_namespace { 12struct user_namespace {
diff --git a/include/linux/uts.h b/include/linux/uts.h
index 73eb1ed36ec4..6ddbd86377de 100644
--- a/include/linux/uts.h
+++ b/include/linux/uts.h
@@ -9,7 +9,7 @@
9#endif 9#endif
10 10
11#ifndef UTS_NODENAME 11#ifndef UTS_NODENAME
12#define UTS_NODENAME "(none)" /* set by sethostname() */ 12#define UTS_NODENAME CONFIG_DEFAULT_HOSTNAME /* set by sethostname() */
13#endif 13#endif
14 14
15#ifndef UTS_DOMAINNAME 15#ifndef UTS_DOMAINNAME
diff --git a/include/linux/utsname.h b/include/linux/utsname.h
index 69f39974c041..4e5b0213fdc1 100644
--- a/include/linux/utsname.h
+++ b/include/linux/utsname.h
@@ -37,9 +37,13 @@ struct new_utsname {
37#include <linux/nsproxy.h> 37#include <linux/nsproxy.h>
38#include <linux/err.h> 38#include <linux/err.h>
39 39
40struct user_namespace;
41extern struct user_namespace init_user_ns;
42
40struct uts_namespace { 43struct uts_namespace {
41 struct kref kref; 44 struct kref kref;
42 struct new_utsname name; 45 struct new_utsname name;
46 struct user_namespace *user_ns;
43}; 47};
44extern struct uts_namespace init_uts_ns; 48extern struct uts_namespace init_uts_ns;
45 49
@@ -50,7 +54,7 @@ static inline void get_uts_ns(struct uts_namespace *ns)
50} 54}
51 55
52extern struct uts_namespace *copy_utsname(unsigned long flags, 56extern struct uts_namespace *copy_utsname(unsigned long flags,
53 struct uts_namespace *ns); 57 struct task_struct *tsk);
54extern void free_uts_ns(struct kref *kref); 58extern void free_uts_ns(struct kref *kref);
55 59
56static inline void put_uts_ns(struct uts_namespace *ns) 60static inline void put_uts_ns(struct uts_namespace *ns)
@@ -67,12 +71,12 @@ static inline void put_uts_ns(struct uts_namespace *ns)
67} 71}
68 72
69static inline struct uts_namespace *copy_utsname(unsigned long flags, 73static inline struct uts_namespace *copy_utsname(unsigned long flags,
70 struct uts_namespace *ns) 74 struct task_struct *tsk)
71{ 75{
72 if (flags & CLONE_NEWUTS) 76 if (flags & CLONE_NEWUTS)
73 return ERR_PTR(-EINVAL); 77 return ERR_PTR(-EINVAL);
74 78
75 return ns; 79 return tsk->nsproxy->uts_ns;
76} 80}
77#endif 81#endif
78 82
diff --git a/include/linux/uvcvideo.h b/include/linux/uvcvideo.h
new file mode 100644
index 000000000000..f46a53f060d7
--- /dev/null
+++ b/include/linux/uvcvideo.h
@@ -0,0 +1,69 @@
1#ifndef __LINUX_UVCVIDEO_H_
2#define __LINUX_UVCVIDEO_H_
3
4#include <linux/ioctl.h>
5#include <linux/types.h>
6
7/*
8 * Dynamic controls
9 */
10
11/* Data types for UVC control data */
12#define UVC_CTRL_DATA_TYPE_RAW 0
13#define UVC_CTRL_DATA_TYPE_SIGNED 1
14#define UVC_CTRL_DATA_TYPE_UNSIGNED 2
15#define UVC_CTRL_DATA_TYPE_BOOLEAN 3
16#define UVC_CTRL_DATA_TYPE_ENUM 4
17#define UVC_CTRL_DATA_TYPE_BITMASK 5
18
19/* Control flags */
20#define UVC_CTRL_FLAG_SET_CUR (1 << 0)
21#define UVC_CTRL_FLAG_GET_CUR (1 << 1)
22#define UVC_CTRL_FLAG_GET_MIN (1 << 2)
23#define UVC_CTRL_FLAG_GET_MAX (1 << 3)
24#define UVC_CTRL_FLAG_GET_RES (1 << 4)
25#define UVC_CTRL_FLAG_GET_DEF (1 << 5)
26/* Control should be saved at suspend and restored at resume. */
27#define UVC_CTRL_FLAG_RESTORE (1 << 6)
28/* Control can be updated by the camera. */
29#define UVC_CTRL_FLAG_AUTO_UPDATE (1 << 7)
30
31#define UVC_CTRL_FLAG_GET_RANGE \
32 (UVC_CTRL_FLAG_GET_CUR | UVC_CTRL_FLAG_GET_MIN | \
33 UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \
34 UVC_CTRL_FLAG_GET_DEF)
35
36struct uvc_menu_info {
37 __u32 value;
38 __u8 name[32];
39};
40
41struct uvc_xu_control_mapping {
42 __u32 id;
43 __u8 name[32];
44 __u8 entity[16];
45 __u8 selector;
46
47 __u8 size;
48 __u8 offset;
49 __u32 v4l2_type;
50 __u32 data_type;
51
52 struct uvc_menu_info __user *menu_info;
53 __u32 menu_count;
54
55 __u32 reserved[4];
56};
57
58struct uvc_xu_control_query {
59 __u8 unit;
60 __u8 selector;
61 __u8 query;
62 __u16 size;
63 __u8 __user *data;
64};
65
66#define UVCIOC_CTRL_MAP _IOWR('u', 0x20, struct uvc_xu_control_mapping)
67#define UVCIOC_CTRL_QUERY _IOWR('u', 0x21, struct uvc_xu_control_query)
68
69#endif
diff --git a/include/linux/uwb.h b/include/linux/uwb.h
index 7fc9746f22cd..b0c564ec2160 100644
--- a/include/linux/uwb.h
+++ b/include/linux/uwb.h
@@ -274,7 +274,7 @@ static inline void uwb_mas_bm_copy_le(void *dst, const struct uwb_mas_bm *mas)
274 274
275/** 275/**
276 * struct uwb_drp_avail - a radio controller's view of MAS usage 276 * struct uwb_drp_avail - a radio controller's view of MAS usage
277 * @global: MAS unused by neighbors (excluding reservations targetted 277 * @global: MAS unused by neighbors (excluding reservations targeted
278 * or owned by the local radio controller) or the beaon period 278 * or owned by the local radio controller) or the beaon period
279 * @local: MAS unused by local established reservations 279 * @local: MAS unused by local established reservations
280 * @pending: MAS unused by local pending reservations 280 * @pending: MAS unused by local pending reservations
@@ -702,10 +702,10 @@ void edc_init(struct edc *edc)
702 edc->timestart = jiffies; 702 edc->timestart = jiffies;
703} 703}
704 704
705/* Called when an error occured. 705/* Called when an error occurred.
706 * This is way to determine if the number of acceptable errors per time 706 * This is way to determine if the number of acceptable errors per time
707 * period has been exceeded. It is not accurate as there are cases in which 707 * period has been exceeded. It is not accurate as there are cases in which
708 * this scheme will not work, for example if there are periodic occurences 708 * this scheme will not work, for example if there are periodic occurrences
709 * of errors that straddle updates to the start time. This scheme is 709 * of errors that straddle updates to the start time. This scheme is
710 * sufficient for our usage. 710 * sufficient for our usage.
711 * 711 *
diff --git a/include/linux/uwb/umc.h b/include/linux/uwb/umc.h
index 4b4fc0f43855..7b4842028ca7 100644
--- a/include/linux/uwb/umc.h
+++ b/include/linux/uwb/umc.h
@@ -132,7 +132,7 @@ int umc_match_pci_id(struct umc_driver *umc_drv, struct umc_dev *umc);
132 * 132 *
133 * FIXME: This is as dirty as it gets, but we need some way to check 133 * FIXME: This is as dirty as it gets, but we need some way to check
134 * the correct type of umc_dev->parent (so that for example, we can 134 * the correct type of umc_dev->parent (so that for example, we can
135 * cast to pci_dev). Casting to pci_dev is necesary because at some 135 * cast to pci_dev). Casting to pci_dev is necessary because at some
136 * point we need to request resources from the device. Mapping is 136 * point we need to request resources from the device. Mapping is
137 * easily over come (ioremap and stuff are bus agnostic), but hooking 137 * easily over come (ioremap and stuff are bus agnostic), but hooking
138 * up to some error handlers (such as pci error handlers) might need 138 * up to some error handlers (such as pci error handlers) might need
diff --git a/include/linux/v4l2-mediabus.h b/include/linux/v4l2-mediabus.h
new file mode 100644
index 000000000000..5ea7f753a348
--- /dev/null
+++ b/include/linux/v4l2-mediabus.h
@@ -0,0 +1,114 @@
1/*
2 * Media Bus API header
3 *
4 * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __LINUX_V4L2_MEDIABUS_H
12#define __LINUX_V4L2_MEDIABUS_H
13
14#include <linux/types.h>
15#include <linux/videodev2.h>
16
17/*
18 * These pixel codes uniquely identify data formats on the media bus. Mostly
19 * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
20 * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
21 * data format is fixed. Additionally, "2X8" means that one pixel is transferred
22 * in two 8-bit samples, "BE" or "LE" specify in which order those samples are
23 * transferred over the bus: "LE" means that the least significant bits are
24 * transferred first, "BE" means that the most significant bits are transferred
25 * first, and "PADHI" and "PADLO" define which bits - low or high, in the
26 * incomplete high byte, are filled with padding bits.
27 *
28 * The pixel codes are grouped by type, bus_width, bits per component, samples
29 * per pixel and order of subsamples. Numerical values are sorted using generic
30 * numerical sort order (8 thus comes before 10).
31 *
32 * As their value can't change when a new pixel code is inserted in the
33 * enumeration, the pixel codes are explicitly given a numerical value. The next
34 * free values for each category are listed below, update them when inserting
35 * new pixel codes.
36 */
37enum v4l2_mbus_pixelcode {
38 V4L2_MBUS_FMT_FIXED = 0x0001,
39
40 /* RGB - next is 0x1009 */
41 V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE = 0x1001,
42 V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE = 0x1002,
43 V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE = 0x1003,
44 V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE = 0x1004,
45 V4L2_MBUS_FMT_BGR565_2X8_BE = 0x1005,
46 V4L2_MBUS_FMT_BGR565_2X8_LE = 0x1006,
47 V4L2_MBUS_FMT_RGB565_2X8_BE = 0x1007,
48 V4L2_MBUS_FMT_RGB565_2X8_LE = 0x1008,
49
50 /* YUV (including grey) - next is 0x2014 */
51 V4L2_MBUS_FMT_Y8_1X8 = 0x2001,
52 V4L2_MBUS_FMT_UYVY8_1_5X8 = 0x2002,
53 V4L2_MBUS_FMT_VYUY8_1_5X8 = 0x2003,
54 V4L2_MBUS_FMT_YUYV8_1_5X8 = 0x2004,
55 V4L2_MBUS_FMT_YVYU8_1_5X8 = 0x2005,
56 V4L2_MBUS_FMT_UYVY8_2X8 = 0x2006,
57 V4L2_MBUS_FMT_VYUY8_2X8 = 0x2007,
58 V4L2_MBUS_FMT_YUYV8_2X8 = 0x2008,
59 V4L2_MBUS_FMT_YVYU8_2X8 = 0x2009,
60 V4L2_MBUS_FMT_Y10_1X10 = 0x200a,
61 V4L2_MBUS_FMT_YUYV10_2X10 = 0x200b,
62 V4L2_MBUS_FMT_YVYU10_2X10 = 0x200c,
63 V4L2_MBUS_FMT_Y12_1X12 = 0x2013,
64 V4L2_MBUS_FMT_UYVY8_1X16 = 0x200f,
65 V4L2_MBUS_FMT_VYUY8_1X16 = 0x2010,
66 V4L2_MBUS_FMT_YUYV8_1X16 = 0x2011,
67 V4L2_MBUS_FMT_YVYU8_1X16 = 0x2012,
68 V4L2_MBUS_FMT_YUYV10_1X20 = 0x200d,
69 V4L2_MBUS_FMT_YVYU10_1X20 = 0x200e,
70
71 /* Bayer - next is 0x3015 */
72 V4L2_MBUS_FMT_SBGGR8_1X8 = 0x3001,
73 V4L2_MBUS_FMT_SGBRG8_1X8 = 0x3013,
74 V4L2_MBUS_FMT_SGRBG8_1X8 = 0x3002,
75 V4L2_MBUS_FMT_SRGGB8_1X8 = 0x3014,
76 V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8 = 0x300b,
77 V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8 = 0x300c,
78 V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8 = 0x3009,
79 V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8 = 0x300d,
80 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE = 0x3003,
81 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE = 0x3004,
82 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE = 0x3005,
83 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE = 0x3006,
84 V4L2_MBUS_FMT_SBGGR10_1X10 = 0x3007,
85 V4L2_MBUS_FMT_SGBRG10_1X10 = 0x300e,
86 V4L2_MBUS_FMT_SGRBG10_1X10 = 0x300a,
87 V4L2_MBUS_FMT_SRGGB10_1X10 = 0x300f,
88 V4L2_MBUS_FMT_SBGGR12_1X12 = 0x3008,
89 V4L2_MBUS_FMT_SGBRG12_1X12 = 0x3010,
90 V4L2_MBUS_FMT_SGRBG12_1X12 = 0x3011,
91 V4L2_MBUS_FMT_SRGGB12_1X12 = 0x3012,
92
93 /* JPEG compressed formats - next is 0x4002 */
94 V4L2_MBUS_FMT_JPEG_1X8 = 0x4001,
95};
96
97/**
98 * struct v4l2_mbus_framefmt - frame format on the media bus
99 * @width: frame width
100 * @height: frame height
101 * @code: data format code (from enum v4l2_mbus_pixelcode)
102 * @field: used interlacing type (from enum v4l2_field)
103 * @colorspace: colorspace of the data (from enum v4l2_colorspace)
104 */
105struct v4l2_mbus_framefmt {
106 __u32 width;
107 __u32 height;
108 __u32 code;
109 __u32 field;
110 __u32 colorspace;
111 __u32 reserved[7];
112};
113
114#endif
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
new file mode 100644
index 000000000000..ed29cbbebfef
--- /dev/null
+++ b/include/linux/v4l2-subdev.h
@@ -0,0 +1,141 @@
1/*
2 * V4L2 subdev userspace API
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef __LINUX_V4L2_SUBDEV_H
24#define __LINUX_V4L2_SUBDEV_H
25
26#include <linux/ioctl.h>
27#include <linux/types.h>
28#include <linux/v4l2-mediabus.h>
29
30/**
31 * enum v4l2_subdev_format_whence - Media bus format type
32 * @V4L2_SUBDEV_FORMAT_TRY: try format, for negotiation only
33 * @V4L2_SUBDEV_FORMAT_ACTIVE: active format, applied to the device
34 */
35enum v4l2_subdev_format_whence {
36 V4L2_SUBDEV_FORMAT_TRY = 0,
37 V4L2_SUBDEV_FORMAT_ACTIVE = 1,
38};
39
40/**
41 * struct v4l2_subdev_format - Pad-level media bus format
42 * @which: format type (from enum v4l2_subdev_format_whence)
43 * @pad: pad number, as reported by the media API
44 * @format: media bus format (format code and frame size)
45 */
46struct v4l2_subdev_format {
47 __u32 which;
48 __u32 pad;
49 struct v4l2_mbus_framefmt format;
50 __u32 reserved[8];
51};
52
53/**
54 * struct v4l2_subdev_crop - Pad-level crop settings
55 * @which: format type (from enum v4l2_subdev_format_whence)
56 * @pad: pad number, as reported by the media API
57 * @rect: pad crop rectangle boundaries
58 */
59struct v4l2_subdev_crop {
60 __u32 which;
61 __u32 pad;
62 struct v4l2_rect rect;
63 __u32 reserved[8];
64};
65
66/**
67 * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
68 * @pad: pad number, as reported by the media API
69 * @index: format index during enumeration
70 * @code: format code (from enum v4l2_mbus_pixelcode)
71 */
72struct v4l2_subdev_mbus_code_enum {
73 __u32 pad;
74 __u32 index;
75 __u32 code;
76 __u32 reserved[9];
77};
78
79/**
80 * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
81 * @pad: pad number, as reported by the media API
82 * @index: format index during enumeration
83 * @code: format code (from enum v4l2_mbus_pixelcode)
84 */
85struct v4l2_subdev_frame_size_enum {
86 __u32 index;
87 __u32 pad;
88 __u32 code;
89 __u32 min_width;
90 __u32 max_width;
91 __u32 min_height;
92 __u32 max_height;
93 __u32 reserved[9];
94};
95
96/**
97 * struct v4l2_subdev_frame_interval - Pad-level frame rate
98 * @pad: pad number, as reported by the media API
99 * @interval: frame interval in seconds
100 */
101struct v4l2_subdev_frame_interval {
102 __u32 pad;
103 struct v4l2_fract interval;
104 __u32 reserved[9];
105};
106
107/**
108 * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
109 * @pad: pad number, as reported by the media API
110 * @index: frame interval index during enumeration
111 * @code: format code (from enum v4l2_mbus_pixelcode)
112 * @width: frame width in pixels
113 * @height: frame height in pixels
114 * @interval: frame interval in seconds
115 */
116struct v4l2_subdev_frame_interval_enum {
117 __u32 index;
118 __u32 pad;
119 __u32 code;
120 __u32 width;
121 __u32 height;
122 struct v4l2_fract interval;
123 __u32 reserved[9];
124};
125
126#define VIDIOC_SUBDEV_G_FMT _IOWR('V', 4, struct v4l2_subdev_format)
127#define VIDIOC_SUBDEV_S_FMT _IOWR('V', 5, struct v4l2_subdev_format)
128#define VIDIOC_SUBDEV_G_FRAME_INTERVAL \
129 _IOWR('V', 21, struct v4l2_subdev_frame_interval)
130#define VIDIOC_SUBDEV_S_FRAME_INTERVAL \
131 _IOWR('V', 22, struct v4l2_subdev_frame_interval)
132#define VIDIOC_SUBDEV_ENUM_MBUS_CODE \
133 _IOWR('V', 2, struct v4l2_subdev_mbus_code_enum)
134#define VIDIOC_SUBDEV_ENUM_FRAME_SIZE \
135 _IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
136#define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL \
137 _IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
138#define VIDIOC_SUBDEV_G_CROP _IOWR('V', 59, struct v4l2_subdev_crop)
139#define VIDIOC_SUBDEV_S_CROP _IOWR('V', 60, struct v4l2_subdev_crop)
140
141#endif
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index ae9ab13b963d..4b9a7f596f92 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -33,6 +33,7 @@ struct vga_switcheroo_handler {
33void vga_switcheroo_unregister_client(struct pci_dev *dev); 33void vga_switcheroo_unregister_client(struct pci_dev *dev);
34int vga_switcheroo_register_client(struct pci_dev *dev, 34int vga_switcheroo_register_client(struct pci_dev *dev,
35 void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state), 35 void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state),
36 void (*reprobe)(struct pci_dev *dev),
36 bool (*can_switch)(struct pci_dev *dev)); 37 bool (*can_switch)(struct pci_dev *dev));
37 38
38void vga_switcheroo_client_fb_set(struct pci_dev *dev, 39void vga_switcheroo_client_fb_set(struct pci_dev *dev,
@@ -48,6 +49,7 @@ int vga_switcheroo_process_delayed_switch(void);
48static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} 49static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
49static inline int vga_switcheroo_register_client(struct pci_dev *dev, 50static inline int vga_switcheroo_register_client(struct pci_dev *dev,
50 void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state), 51 void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state),
52 void (*reprobe)(struct pci_dev *dev),
51 bool (*can_switch)(struct pci_dev *dev)) { return 0; } 53 bool (*can_switch)(struct pci_dev *dev)) { return 0; }
52static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {} 54static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}
53static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; } 55static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; }
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index e9e1524b582c..9c3120dca294 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -78,7 +78,7 @@ extern void vga_set_legacy_decoding(struct pci_dev *pdev,
78 * wether the card is doing legacy decoding for that type of resource. If 78 * wether the card is doing legacy decoding for that type of resource. If
79 * yes, the lock is "converted" into a legacy resource lock. 79 * yes, the lock is "converted" into a legacy resource lock.
80 * The arbiter will first look for all VGA cards that might conflict 80 * The arbiter will first look for all VGA cards that might conflict
81 * and disable their IOs and/or Memory access, inlcuding VGA forwarding 81 * and disable their IOs and/or Memory access, including VGA forwarding
82 * on P2P bridges if necessary, so that the requested resources can 82 * on P2P bridges if necessary, so that the requested resources can
83 * be used. Then, the card is marked as locking these resources and 83 * be used. Then, the card is marked as locking these resources and
84 * the IO and/or Memory accesse are enabled on the card (including 84 * the IO and/or Memory accesse are enabled on the card (including
@@ -187,7 +187,7 @@ extern struct pci_dev *vga_default_device(void);
187 * vga_conflicts 187 * vga_conflicts
188 * 188 *
189 * Architectures should define this if they have several 189 * Architectures should define this if they have several
190 * independant PCI domains that can afford concurrent VGA 190 * independent PCI domains that can afford concurrent VGA
191 * decoding 191 * decoding
192 */ 192 */
193 193
diff --git a/include/linux/via-core.h b/include/linux/via-core.h
index 7ffb521e1a7a..9c21cdf3e3b3 100644
--- a/include/linux/via-core.h
+++ b/include/linux/via-core.h
@@ -60,6 +60,21 @@ struct via_port_cfg {
60}; 60};
61 61
62/* 62/*
63 * Allow subdevs to register suspend/resume hooks.
64 */
65#ifdef CONFIG_PM
66struct viafb_pm_hooks {
67 struct list_head list;
68 int (*suspend)(void *private);
69 int (*resume)(void *private);
70 void *private;
71};
72
73void viafb_pm_register(struct viafb_pm_hooks *hooks);
74void viafb_pm_unregister(struct viafb_pm_hooks *hooks);
75#endif /* CONFIG_PM */
76
77/*
63 * This is the global viafb "device" containing stuff needed by 78 * This is the global viafb "device" containing stuff needed by
64 * all subdevs. 79 * all subdevs.
65 */ 80 */
@@ -81,7 +96,7 @@ struct viafb_dev {
81 unsigned long fbmem_start; 96 unsigned long fbmem_start;
82 long fbmem_len; 97 long fbmem_len;
83 void __iomem *fbmem; 98 void __iomem *fbmem;
84#if defined(CONFIG_FB_VIA_CAMERA) || defined(CONFIG_FB_VIA_CAMERA_MODULE) 99#if defined(CONFIG_VIDEO_VIA_CAMERA) || defined(CONFIG_VIDEO_VIA_CAMERA_MODULE)
85 long camera_fbmem_offset; 100 long camera_fbmem_offset;
86 long camera_fbmem_size; 101 long camera_fbmem_size;
87#endif 102#endif
@@ -138,6 +153,7 @@ void viafb_irq_disable(u32 mask);
138#define VDE_I_LVDSSIEN 0x40000000 /* LVDS Sense enable */ 153#define VDE_I_LVDSSIEN 0x40000000 /* LVDS Sense enable */
139#define VDE_I_ENABLE 0x80000000 /* Global interrupt enable */ 154#define VDE_I_ENABLE 0x80000000 /* Global interrupt enable */
140 155
156#if defined(CONFIG_VIDEO_VIA_CAMERA) || defined(CONFIG_VIDEO_VIA_CAMERA_MODULE)
141/* 157/*
142 * DMA management. 158 * DMA management.
143 */ 159 */
@@ -172,6 +188,7 @@ int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg);
172 */ 188 */
173#define VGA_WIDTH 640 189#define VGA_WIDTH 640
174#define VGA_HEIGHT 480 190#define VGA_HEIGHT 480
191#endif /* CONFIG_VIDEO_VIA_CAMERA */
175 192
176/* 193/*
177 * Indexed port operations. Note that these are all multi-op 194 * Indexed port operations. Note that these are all multi-op
diff --git a/include/linux/video_output.h b/include/linux/video_output.h
index 2fb46bc9340d..ed5cdeb3604d 100644
--- a/include/linux/video_output.h
+++ b/include/linux/video_output.h
@@ -23,6 +23,7 @@
23#ifndef _LINUX_VIDEO_OUTPUT_H 23#ifndef _LINUX_VIDEO_OUTPUT_H
24#define _LINUX_VIDEO_OUTPUT_H 24#define _LINUX_VIDEO_OUTPUT_H
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/err.h>
26struct output_device; 27struct output_device;
27struct output_properties { 28struct output_properties {
28 int (*set_state)(struct output_device *); 29 int (*set_state)(struct output_device *);
@@ -34,9 +35,23 @@ struct output_device {
34 struct device dev; 35 struct device dev;
35}; 36};
36#define to_output_device(obj) container_of(obj, struct output_device, dev) 37#define to_output_device(obj) container_of(obj, struct output_device, dev)
38#if defined(CONFIG_VIDEO_OUTPUT_CONTROL) || defined(CONFIG_VIDEO_OUTPUT_CONTROL_MODULE)
37struct output_device *video_output_register(const char *name, 39struct output_device *video_output_register(const char *name,
38 struct device *dev, 40 struct device *dev,
39 void *devdata, 41 void *devdata,
40 struct output_properties *op); 42 struct output_properties *op);
41void video_output_unregister(struct output_device *dev); 43void video_output_unregister(struct output_device *dev);
44#else
45static struct output_device *video_output_register(const char *name,
46 struct device *dev,
47 void *devdata,
48 struct output_properties *op)
49{
50 return ERR_PTR(-ENODEV);
51}
52static void video_output_unregister(struct output_device *dev)
53{
54 return;
55}
56#endif
42#endif 57#endif
diff --git a/include/linux/videodev.h b/include/linux/videodev.h
deleted file mode 100644
index b19eab140977..000000000000
--- a/include/linux/videodev.h
+++ /dev/null
@@ -1,340 +0,0 @@
1/*
2 * Video for Linux version 1 - OBSOLETE
3 *
4 * Header file for v4l1 drivers and applications, for
5 * Linux kernels 2.2.x or 2.4.x.
6 *
7 * Provides header for legacy drivers and applications
8 *
9 * See http://linuxtv.org for more info
10 *
11 */
12#ifndef __LINUX_VIDEODEV_H
13#define __LINUX_VIDEODEV_H
14
15#include <linux/types.h>
16#include <linux/ioctl.h>
17#include <linux/videodev2.h>
18
19#if defined(__MIN_V4L1) && defined (__KERNEL__)
20
21/*
22 * Used by those V4L2 core functions that need a minimum V4L1 support,
23 * in order to allow V4L1 Compatibilty code compilation.
24 */
25
26struct video_mbuf
27{
28 int size; /* Total memory to map */
29 int frames; /* Frames */
30 int offsets[VIDEO_MAX_FRAME];
31};
32
33#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */
34
35#else
36#if defined(CONFIG_VIDEO_V4L1_COMPAT) || !defined (__KERNEL__)
37
38#define VID_TYPE_CAPTURE 1 /* Can capture */
39#define VID_TYPE_TUNER 2 /* Can tune */
40#define VID_TYPE_TELETEXT 4 /* Does teletext */
41#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
42#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
43#define VID_TYPE_CLIPPING 32 /* Can clip */
44#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
45#define VID_TYPE_SCALES 128 /* Scalable */
46#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
47#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
48#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
49#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
50#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
51#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
52
53struct video_capability
54{
55 char name[32];
56 int type;
57 int channels; /* Num channels */
58 int audios; /* Num audio devices */
59 int maxwidth; /* Supported width */
60 int maxheight; /* And height */
61 int minwidth; /* Supported width */
62 int minheight; /* And height */
63};
64
65
66struct video_channel
67{
68 int channel;
69 char name[32];
70 int tuners;
71 __u32 flags;
72#define VIDEO_VC_TUNER 1 /* Channel has a tuner */
73#define VIDEO_VC_AUDIO 2 /* Channel has audio */
74 __u16 type;
75#define VIDEO_TYPE_TV 1
76#define VIDEO_TYPE_CAMERA 2
77 __u16 norm; /* Norm set by channel */
78};
79
80struct video_tuner
81{
82 int tuner;
83 char name[32];
84 unsigned long rangelow, rangehigh; /* Tuner range */
85 __u32 flags;
86#define VIDEO_TUNER_PAL 1
87#define VIDEO_TUNER_NTSC 2
88#define VIDEO_TUNER_SECAM 4
89#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
90#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */
91#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
92#define VIDEO_TUNER_RDS_ON 256 /* Tuner is seeing an RDS datastream */
93#define VIDEO_TUNER_MBS_ON 512 /* Tuner is seeing an MBS datastream */
94 __u16 mode; /* PAL/NTSC/SECAM/OTHER */
95#define VIDEO_MODE_PAL 0
96#define VIDEO_MODE_NTSC 1
97#define VIDEO_MODE_SECAM 2
98#define VIDEO_MODE_AUTO 3
99 __u16 signal; /* Signal strength 16bit scale */
100};
101
102struct video_picture
103{
104 __u16 brightness;
105 __u16 hue;
106 __u16 colour;
107 __u16 contrast;
108 __u16 whiteness; /* Black and white only */
109 __u16 depth; /* Capture depth */
110 __u16 palette; /* Palette in use */
111#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
112#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
113#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
114#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
115#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
116#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
117#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
118#define VIDEO_PALETTE_YUYV 8
119#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */
120#define VIDEO_PALETTE_YUV420 10
121#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */
122#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */
123#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */
124#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */
125#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */
126#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */
127#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */
128#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */
129};
130
131struct video_audio
132{
133 int audio; /* Audio channel */
134 __u16 volume; /* If settable */
135 __u16 bass, treble;
136 __u32 flags;
137#define VIDEO_AUDIO_MUTE 1
138#define VIDEO_AUDIO_MUTABLE 2
139#define VIDEO_AUDIO_VOLUME 4
140#define VIDEO_AUDIO_BASS 8
141#define VIDEO_AUDIO_TREBLE 16
142#define VIDEO_AUDIO_BALANCE 32
143 char name[16];
144#define VIDEO_SOUND_MONO 1
145#define VIDEO_SOUND_STEREO 2
146#define VIDEO_SOUND_LANG1 4
147#define VIDEO_SOUND_LANG2 8
148 __u16 mode;
149 __u16 balance; /* Stereo balance */
150 __u16 step; /* Step actual volume uses */
151};
152
153struct video_clip
154{
155 __s32 x,y;
156 __s32 width, height;
157 struct video_clip *next; /* For user use/driver use only */
158};
159
160struct video_window
161{
162 __u32 x,y; /* Position of window */
163 __u32 width,height; /* Its size */
164 __u32 chromakey;
165 __u32 flags;
166 struct video_clip __user *clips; /* Set only */
167 int clipcount;
168#define VIDEO_WINDOW_INTERLACE 1
169#define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */
170#define VIDEO_CLIP_BITMAP -1
171/* bitmap is 1024x625, a '1' bit represents a clipped pixel */
172#define VIDEO_CLIPMAP_SIZE (128 * 625)
173};
174
175struct video_capture
176{
177 __u32 x,y; /* Offsets into image */
178 __u32 width, height; /* Area to capture */
179 __u16 decimation; /* Decimation divider */
180 __u16 flags; /* Flags for capture */
181#define VIDEO_CAPTURE_ODD 0 /* Temporal */
182#define VIDEO_CAPTURE_EVEN 1
183};
184
185struct video_buffer
186{
187 void *base;
188 int height,width;
189 int depth;
190 int bytesperline;
191};
192
193struct video_mmap
194{
195 unsigned int frame; /* Frame (0 - n) for double buffer */
196 int height,width;
197 unsigned int format; /* should be VIDEO_PALETTE_* */
198};
199
200struct video_key
201{
202 __u8 key[8];
203 __u32 flags;
204};
205
206struct video_mbuf
207{
208 int size; /* Total memory to map */
209 int frames; /* Frames */
210 int offsets[VIDEO_MAX_FRAME];
211};
212
213#define VIDEO_NO_UNIT (-1)
214
215struct video_unit
216{
217 int video; /* Video minor */
218 int vbi; /* VBI minor */
219 int radio; /* Radio minor */
220 int audio; /* Audio minor */
221 int teletext; /* Teletext minor */
222};
223
224struct vbi_format {
225 __u32 sampling_rate; /* in Hz */
226 __u32 samples_per_line;
227 __u32 sample_format; /* VIDEO_PALETTE_RAW only (1 byte) */
228 __s32 start[2]; /* starting line for each frame */
229 __u32 count[2]; /* count of lines for each frame */
230 __u32 flags;
231#define VBI_UNSYNC 1 /* can distingues between top/bottom field */
232#define VBI_INTERLACED 2 /* lines are interlaced */
233};
234
235/* video_info is biased towards hardware mpeg encode/decode */
236/* but it could apply generically to any hardware compressor/decompressor */
237struct video_info
238{
239 __u32 frame_count; /* frames output since decode/encode began */
240 __u32 h_size; /* current unscaled horizontal size */
241 __u32 v_size; /* current unscaled veritcal size */
242 __u32 smpte_timecode; /* current SMPTE timecode (for current GOP) */
243 __u32 picture_type; /* current picture type */
244 __u32 temporal_reference; /* current temporal reference */
245 __u8 user_data[256]; /* user data last found in compressed stream */
246 /* user_data[0] contains user data flags, user_data[1] has count */
247};
248
249/* generic structure for setting playback modes */
250struct video_play_mode
251{
252 int mode;
253 int p1;
254 int p2;
255};
256
257/* for loading microcode / fpga programming */
258struct video_code
259{
260 char loadwhat[16]; /* name or tag of file being passed */
261 int datasize;
262 __u8 *data;
263};
264
265#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
266#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
267#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */
268#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
269#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
270#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
271#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
272#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
273#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */
274#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
275#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
276#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
277#define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */
278#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
279#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
280#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
281#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
282#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
283#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
284#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */
285#define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */
286#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */
287#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */
288#define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */
289#define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */
290#define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */
291#define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */
292#define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */
293#define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */
294
295
296#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */
297
298/* VIDIOCSWRITEMODE */
299#define VID_WRITE_MPEG_AUD 0
300#define VID_WRITE_MPEG_VID 1
301#define VID_WRITE_OSD 2
302#define VID_WRITE_TTX 3
303#define VID_WRITE_CC 4
304#define VID_WRITE_MJPEG 5
305
306/* VIDIOCSPLAYMODE */
307#define VID_PLAY_VID_OUT_MODE 0
308 /* p1: = VIDEO_MODE_PAL, VIDEO_MODE_NTSC, etc ... */
309#define VID_PLAY_GENLOCK 1
310 /* p1: 0 = OFF, 1 = ON */
311 /* p2: GENLOCK FINE DELAY value */
312#define VID_PLAY_NORMAL 2
313#define VID_PLAY_PAUSE 3
314#define VID_PLAY_SINGLE_FRAME 4
315#define VID_PLAY_FAST_FORWARD 5
316#define VID_PLAY_SLOW_MOTION 6
317#define VID_PLAY_IMMEDIATE_NORMAL 7
318#define VID_PLAY_SWITCH_CHANNELS 8
319#define VID_PLAY_FREEZE_FRAME 9
320#define VID_PLAY_STILL_MODE 10
321#define VID_PLAY_MASTER_MODE 11
322 /* p1: see below */
323#define VID_PLAY_MASTER_NONE 1
324#define VID_PLAY_MASTER_VIDEO 2
325#define VID_PLAY_MASTER_AUDIO 3
326#define VID_PLAY_ACTIVE_SCANLINES 12
327 /* p1 = first active; p2 = last active */
328#define VID_PLAY_RESET 13
329#define VID_PLAY_END_MARK 14
330
331#endif /* CONFIG_VIDEO_V4L1_COMPAT */
332#endif /* __MIN_V4L1 */
333
334#endif /* __LINUX_VIDEODEV_H */
335
336/*
337 * Local variables:
338 * c-basic-offset: 8
339 * End:
340 */
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 61490c6dcdbd..8a4c309d2344 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -70,6 +70,7 @@
70 * Moved from videodev.h 70 * Moved from videodev.h
71 */ 71 */
72#define VIDEO_MAX_FRAME 32 72#define VIDEO_MAX_FRAME 32
73#define VIDEO_MAX_PLANES 8
73 74
74#ifndef __KERNEL__ 75#ifndef __KERNEL__
75 76
@@ -157,9 +158,23 @@ enum v4l2_buf_type {
157 /* Experimental */ 158 /* Experimental */
158 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8, 159 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
159#endif 160#endif
161 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
162 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
160 V4L2_BUF_TYPE_PRIVATE = 0x80, 163 V4L2_BUF_TYPE_PRIVATE = 0x80,
161}; 164};
162 165
166#define V4L2_TYPE_IS_MULTIPLANAR(type) \
167 ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \
168 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
169
170#define V4L2_TYPE_IS_OUTPUT(type) \
171 ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT \
172 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE \
173 || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY \
174 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY \
175 || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \
176 || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
177
163enum v4l2_tuner_type { 178enum v4l2_tuner_type {
164 V4L2_TUNER_RADIO = 1, 179 V4L2_TUNER_RADIO = 1,
165 V4L2_TUNER_ANALOG_TV = 2, 180 V4L2_TUNER_ANALOG_TV = 2,
@@ -245,6 +260,11 @@ struct v4l2_capability {
245#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */ 260#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */
246#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */ 261#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */
247 262
263/* Is a video capture device that supports multiplanar formats */
264#define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000
265/* Is a video output device that supports multiplanar formats */
266#define V4L2_CAP_VIDEO_OUTPUT_MPLANE 0x00002000
267
248#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ 268#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
249#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ 269#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
250#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ 270#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
@@ -288,8 +308,12 @@ struct v4l2_pix_format {
288#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */ 308#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */
289#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */ 309#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */
290#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */ 310#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */
311#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale */
291#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */ 312#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
292 313
314/* Grey bit-packed formats */
315#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */
316
293/* Palette formats */ 317/* Palette formats */
294#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */ 318#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
295 319
@@ -312,6 +336,7 @@ struct v4l2_pix_format {
312#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */ 336#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
313#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ 337#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
314#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ 338#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
339#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
315 340
316/* two planes -- one Y, one Cr + Cb interleaved */ 341/* two planes -- one Y, one Cr + Cb interleaved */
317#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ 342#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
@@ -319,6 +344,13 @@ struct v4l2_pix_format {
319#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */ 344#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
320#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ 345#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
321 346
347/* two non contiguous planes - one Y, one Cr + Cb interleaved */
348#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */
349#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */
350
351/* three non contiguous planes - Y, Cb, Cr */
352#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */
353
322/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */ 354/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
323#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */ 355#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
324#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */ 356#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
@@ -328,6 +360,10 @@ struct v4l2_pix_format {
328#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10 GBGB.. RGRG.. */ 360#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10 GBGB.. RGRG.. */
329#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10 GRGR.. BGBG.. */ 361#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10 GRGR.. BGBG.. */
330#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10 RGRG.. GBGB.. */ 362#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10 RGRG.. GBGB.. */
363#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2') /* 12 BGBG.. GRGR.. */
364#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12 GBGB.. RGRG.. */
365#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */
366#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */
331 /* 10bit raw bayer DPCM compressed to 8 bits */ 367 /* 10bit raw bayer DPCM compressed to 8 bits */
332#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0') 368#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
333 /* 369 /*
@@ -363,6 +399,9 @@ struct v4l2_pix_format {
363#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */ 399#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */
364#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0') /* stv0680 bayer */ 400#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0') /* stv0680 bayer */
365#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0') /* tm5600/tm60x0 */ 401#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0') /* tm5600/tm60x0 */
402#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V') /* one line of Y then 1 line of VYUY */
403#define V4L2_PIX_FMT_KONICA420 v4l2_fourcc('K', 'O', 'N', 'I') /* YUV420 planar in blocks of 256 pixels */
404#define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */
366 405
367/* 406/*
368 * F O R M A T E N U M E R A T I O N 407 * F O R M A T E N U M E R A T I O N
@@ -515,6 +554,62 @@ struct v4l2_requestbuffers {
515 __u32 reserved[2]; 554 __u32 reserved[2];
516}; 555};
517 556
557/**
558 * struct v4l2_plane - plane info for multi-planar buffers
559 * @bytesused: number of bytes occupied by data in the plane (payload)
560 * @length: size of this plane (NOT the payload) in bytes
561 * @mem_offset: when memory in the associated struct v4l2_buffer is
562 * V4L2_MEMORY_MMAP, equals the offset from the start of
563 * the device memory for this plane (or is a "cookie" that
564 * should be passed to mmap() called on the video node)
565 * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
566 * pointing to this plane
567 * @data_offset: offset in the plane to the start of data; usually 0,
568 * unless there is a header in front of the data
569 *
570 * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
571 * with two planes can have one plane for Y, and another for interleaved CbCr
572 * components. Each plane can reside in a separate memory buffer, or even in
573 * a completely separate memory node (e.g. in embedded devices).
574 */
575struct v4l2_plane {
576 __u32 bytesused;
577 __u32 length;
578 union {
579 __u32 mem_offset;
580 unsigned long userptr;
581 } m;
582 __u32 data_offset;
583 __u32 reserved[11];
584};
585
586/**
587 * struct v4l2_buffer - video buffer info
588 * @index: id number of the buffer
589 * @type: buffer type (type == *_MPLANE for multiplanar buffers)
590 * @bytesused: number of bytes occupied by data in the buffer (payload);
591 * unused (set to 0) for multiplanar buffers
592 * @flags: buffer informational flags
593 * @field: field order of the image in the buffer
594 * @timestamp: frame timestamp
595 * @timecode: frame timecode
596 * @sequence: sequence count of this frame
597 * @memory: the method, in which the actual video data is passed
598 * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
599 * offset from the start of the device memory for this plane,
600 * (or a "cookie" that should be passed to mmap() as offset)
601 * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
602 * a userspace pointer pointing to this buffer
603 * @planes: for multiplanar buffers; userspace pointer to the array of plane
604 * info structs for this buffer
605 * @length: size in bytes of the buffer (NOT its payload) for single-plane
606 * buffers (when type != *_MPLANE); number of elements in the
607 * planes array for multi-plane buffers
608 * @input: input number from which the video data has has been captured
609 *
610 * Contains data exchanged by application and driver using one of the Streaming
611 * I/O methods.
612 */
518struct v4l2_buffer { 613struct v4l2_buffer {
519 __u32 index; 614 __u32 index;
520 enum v4l2_buf_type type; 615 enum v4l2_buf_type type;
@@ -530,6 +625,7 @@ struct v4l2_buffer {
530 union { 625 union {
531 __u32 offset; 626 __u32 offset;
532 unsigned long userptr; 627 unsigned long userptr;
628 struct v4l2_plane *planes;
533 } m; 629 } m;
534 __u32 length; 630 __u32 length;
535 __u32 input; 631 __u32 input;
@@ -1045,8 +1141,11 @@ enum v4l2_colorfx {
1045 1141
1046#define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36) 1142#define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
1047 1143
1144#define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+37)
1145#define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+38)
1146
1048/* last CID + 1 */ 1147/* last CID + 1 */
1049#define V4L2_CID_LASTP1 (V4L2_CID_BASE+37) 1148#define V4L2_CID_LASTP1 (V4L2_CID_BASE+39)
1050 1149
1051/* MPEG-class control IDs defined by V4L2 */ 1150/* MPEG-class control IDs defined by V4L2 */
1052#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) 1151#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
@@ -1363,6 +1462,8 @@ struct v4l2_modulator {
1363#define V4L2_TUNER_CAP_SAP 0x0020 1462#define V4L2_TUNER_CAP_SAP 0x0020
1364#define V4L2_TUNER_CAP_LANG1 0x0040 1463#define V4L2_TUNER_CAP_LANG1 0x0040
1365#define V4L2_TUNER_CAP_RDS 0x0080 1464#define V4L2_TUNER_CAP_RDS 0x0080
1465#define V4L2_TUNER_CAP_RDS_BLOCK_IO 0x0100
1466#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200
1366 1467
1367/* Flags for the 'rxsubchans' field */ 1468/* Flags for the 'rxsubchans' field */
1368#define V4L2_TUNER_SUB_MONO 0x0001 1469#define V4L2_TUNER_SUB_MONO 0x0001
@@ -1392,7 +1493,8 @@ struct v4l2_hw_freq_seek {
1392 enum v4l2_tuner_type type; 1493 enum v4l2_tuner_type type;
1393 __u32 seek_upward; 1494 __u32 seek_upward;
1394 __u32 wrap_around; 1495 __u32 wrap_around;
1395 __u32 reserved[8]; 1496 __u32 spacing;
1497 __u32 reserved[7];
1396}; 1498};
1397 1499
1398/* 1500/*
@@ -1614,12 +1716,56 @@ struct v4l2_mpeg_vbi_fmt_ivtv {
1614 * A G G R E G A T E S T R U C T U R E S 1716 * A G G R E G A T E S T R U C T U R E S
1615 */ 1717 */
1616 1718
1617/* Stream data format 1719/**
1720 * struct v4l2_plane_pix_format - additional, per-plane format definition
1721 * @sizeimage: maximum size in bytes required for data, for which
1722 * this plane will be used
1723 * @bytesperline: distance in bytes between the leftmost pixels in two
1724 * adjacent lines
1725 */
1726struct v4l2_plane_pix_format {
1727 __u32 sizeimage;
1728 __u16 bytesperline;
1729 __u16 reserved[7];
1730} __attribute__ ((packed));
1731
1732/**
1733 * struct v4l2_pix_format_mplane - multiplanar format definition
1734 * @width: image width in pixels
1735 * @height: image height in pixels
1736 * @pixelformat: little endian four character code (fourcc)
1737 * @field: field order (for interlaced video)
1738 * @colorspace: supplemental to pixelformat
1739 * @plane_fmt: per-plane information
1740 * @num_planes: number of planes for this format
1741 */
1742struct v4l2_pix_format_mplane {
1743 __u32 width;
1744 __u32 height;
1745 __u32 pixelformat;
1746 enum v4l2_field field;
1747 enum v4l2_colorspace colorspace;
1748
1749 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
1750 __u8 num_planes;
1751 __u8 reserved[11];
1752} __attribute__ ((packed));
1753
1754/**
1755 * struct v4l2_format - stream data format
1756 * @type: type of the data stream
1757 * @pix: definition of an image format
1758 * @pix_mp: definition of a multiplanar image format
1759 * @win: definition of an overlaid image
1760 * @vbi: raw VBI capture or output parameters
1761 * @sliced: sliced VBI capture or output parameters
1762 * @raw_data: placeholder for future extensions and custom formats
1618 */ 1763 */
1619struct v4l2_format { 1764struct v4l2_format {
1620 enum v4l2_buf_type type; 1765 enum v4l2_buf_type type;
1621 union { 1766 union {
1622 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */ 1767 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
1768 struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
1623 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */ 1769 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
1624 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */ 1770 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
1625 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ 1771 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
@@ -1627,7 +1773,6 @@ struct v4l2_format {
1627 } fmt; 1773 } fmt;
1628}; 1774};
1629 1775
1630
1631/* Stream type-dependent parameters 1776/* Stream type-dependent parameters
1632 */ 1777 */
1633struct v4l2_streamparm { 1778struct v4l2_streamparm {
@@ -1800,16 +1945,6 @@ struct v4l2_dbg_chip_ident {
1800/* Reminder: when adding new ioctls please add support for them to 1945/* Reminder: when adding new ioctls please add support for them to
1801 drivers/media/video/v4l2-compat-ioctl32.c as well! */ 1946 drivers/media/video/v4l2-compat-ioctl32.c as well! */
1802 1947
1803#ifdef __OLD_VIDIOC_
1804/* for compatibility, will go away some day */
1805#define VIDIOC_OVERLAY_OLD _IOWR('V', 14, int)
1806#define VIDIOC_S_PARM_OLD _IOW('V', 22, struct v4l2_streamparm)
1807#define VIDIOC_S_CTRL_OLD _IOW('V', 28, struct v4l2_control)
1808#define VIDIOC_G_AUDIO_OLD _IOWR('V', 33, struct v4l2_audio)
1809#define VIDIOC_G_AUDOUT_OLD _IOWR('V', 49, struct v4l2_audioout)
1810#define VIDIOC_CROPCAP_OLD _IOR('V', 58, struct v4l2_cropcap)
1811#endif
1812
1813#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ 1948#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
1814 1949
1815#endif /* __LINUX_VIDEODEV2_H */ 1950#endif /* __LINUX_VIDEODEV2_H */
diff --git a/include/linux/videotext.h b/include/linux/videotext.h
deleted file mode 100644
index 3e68c8d1c7f7..000000000000
--- a/include/linux/videotext.h
+++ /dev/null
@@ -1,125 +0,0 @@
1#ifndef _VTX_H
2#define _VTX_H
3
4/*
5 * Teletext (=Videotext) hardware decoders using interface /dev/vtx
6 * Do not confuse with drivers using /dev/vbi which decode videotext by software
7 *
8 * Videotext IOCTLs changed in order to use _IO() macros defined in <linux/ioctl.h>,
9 * unused tuner IOCTLs cleaned up by
10 * Michael Geng <linux@MichaelGeng.de>
11 *
12 * Copyright (c) 1994-97 Martin Buck <martin-2.buck@student.uni-ulm.de>
13 * Read COPYING for more information
14 *
15 */
16
17
18/*
19 * Videotext ioctls
20 */
21#define VTXIOCGETINFO _IOR (0x81, 1, vtx_info_t)
22#define VTXIOCCLRPAGE _IOW (0x81, 2, vtx_pagereq_t)
23#define VTXIOCCLRFOUND _IOW (0x81, 3, vtx_pagereq_t)
24#define VTXIOCPAGEREQ _IOW (0x81, 4, vtx_pagereq_t)
25#define VTXIOCGETSTAT _IOW (0x81, 5, vtx_pagereq_t)
26#define VTXIOCGETPAGE _IOW (0x81, 6, vtx_pagereq_t)
27#define VTXIOCSTOPDAU _IOW (0x81, 7, vtx_pagereq_t)
28#define VTXIOCPUTPAGE _IO (0x81, 8)
29#define VTXIOCSETDISP _IO (0x81, 9)
30#define VTXIOCPUTSTAT _IO (0x81, 10)
31#define VTXIOCCLRCACHE _IO (0x81, 11)
32#define VTXIOCSETVIRT _IOW (0x81, 12, long)
33
34/* for compatibility, will go away some day */
35#define VTXIOCGETINFO_OLD 0x7101 /* get version of driver & capabilities of vtx-chipset */
36#define VTXIOCCLRPAGE_OLD 0x7102 /* clear page-buffer */
37#define VTXIOCCLRFOUND_OLD 0x7103 /* clear bits indicating that page was found */
38#define VTXIOCPAGEREQ_OLD 0x7104 /* search for page */
39#define VTXIOCGETSTAT_OLD 0x7105 /* get status of page-buffer */
40#define VTXIOCGETPAGE_OLD 0x7106 /* get contents of page-buffer */
41#define VTXIOCSTOPDAU_OLD 0x7107 /* stop data acquisition unit */
42#define VTXIOCPUTPAGE_OLD 0x7108 /* display page on TV-screen */
43#define VTXIOCSETDISP_OLD 0x7109 /* set TV-mode */
44#define VTXIOCPUTSTAT_OLD 0x710a /* set status of TV-output-buffer */
45#define VTXIOCCLRCACHE_OLD 0x710b /* clear cache on VTX-interface (if avail.) */
46#define VTXIOCSETVIRT_OLD 0x710c /* turn on virtual mode (this disables TV-display) */
47
48/*
49 * Definitions for VTXIOCGETINFO
50 */
51
52#define SAA5243 0
53#define SAA5246 1
54#define SAA5249 2
55#define SAA5248 3
56#define XSTV5346 4
57
58typedef struct {
59 int version_major, version_minor; /* version of driver; if version_major changes, driver */
60 /* is not backward compatible!!! CHECK THIS!!! */
61 int numpages; /* number of page-buffers of vtx-chipset */
62 int cct_type; /* type of vtx-chipset (SAA5243, SAA5246, SAA5248 or
63 * SAA5249) */
64}
65vtx_info_t;
66
67
68/*
69 * Definitions for VTXIOC{CLRPAGE,CLRFOUND,PAGEREQ,GETSTAT,GETPAGE,STOPDAU,PUTPAGE,SETDISP}
70 */
71
72#define MIN_UNIT (1<<0)
73#define MIN_TEN (1<<1)
74#define HR_UNIT (1<<2)
75#define HR_TEN (1<<3)
76#define PG_UNIT (1<<4)
77#define PG_TEN (1<<5)
78#define PG_HUND (1<<6)
79#define PGMASK_MAX (1<<7)
80#define PGMASK_PAGE (PG_HUND | PG_TEN | PG_UNIT)
81#define PGMASK_HOUR (HR_TEN | HR_UNIT)
82#define PGMASK_MINUTE (MIN_TEN | MIN_UNIT)
83
84typedef struct
85{
86 int page; /* number of requested page (hexadecimal) */
87 int hour; /* requested hour (hexadecimal) */
88 int minute; /* requested minute (hexadecimal) */
89 int pagemask; /* mask defining which values of the above are set */
90 int pgbuf; /* buffer where page will be stored */
91 int start; /* start of requested part of page */
92 int end; /* end of requested part of page */
93 void __user *buffer; /* pointer to beginning of destination buffer */
94}
95vtx_pagereq_t;
96
97
98/*
99 * Definitions for VTXIOC{GETSTAT,PUTSTAT}
100 */
101
102#define VTX_PAGESIZE (40 * 24)
103#define VTX_VIRTUALSIZE (40 * 49)
104
105typedef struct
106{
107 int pagenum; /* number of page (hexadecimal) */
108 int hour; /* hour (hexadecimal) */
109 int minute; /* minute (hexadecimal) */
110 int charset; /* national charset */
111 unsigned delete : 1; /* delete page (C4) */
112 unsigned headline : 1; /* insert headline (C5) */
113 unsigned subtitle : 1; /* insert subtitle (C6) */
114 unsigned supp_header : 1; /* suppress header (C7) */
115 unsigned update : 1; /* update page (C8) */
116 unsigned inter_seq : 1; /* interrupted sequence (C9) */
117 unsigned dis_disp : 1; /* disable/suppress display (C10) */
118 unsigned serial : 1; /* serial mode (C11) */
119 unsigned notfound : 1; /* /FOUND */
120 unsigned pblf : 1; /* PBLF */
121 unsigned hamming : 1; /* hamming-error occurred */
122}
123vtx_pageinfo_t;
124
125#endif /* _VTX_H */
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index aff5b4f74041..710885749605 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -51,6 +51,13 @@ struct virtqueue {
51 * This re-enables callbacks; it returns "false" if there are pending 51 * This re-enables callbacks; it returns "false" if there are pending
52 * buffers in the queue, to detect a possible race between the driver 52 * buffers in the queue, to detect a possible race between the driver
53 * checking for more work, and enabling callbacks. 53 * checking for more work, and enabling callbacks.
54 * virtqueue_enable_cb_delayed: restart callbacks after disable_cb.
55 * vq: the struct virtqueue we're talking about.
56 * This re-enables callbacks but hints to the other side to delay
57 * interrupts until most of the available buffers have been processed;
58 * it returns "false" if there are many pending buffers in the queue,
59 * to detect a possible race between the driver checking for more work,
60 * and enabling callbacks.
54 * virtqueue_detach_unused_buf: detach first unused buffer 61 * virtqueue_detach_unused_buf: detach first unused buffer
55 * vq: the struct virtqueue we're talking about. 62 * vq: the struct virtqueue we're talking about.
56 * Returns NULL or the "data" token handed to add_buf 63 * Returns NULL or the "data" token handed to add_buf
@@ -86,6 +93,8 @@ void virtqueue_disable_cb(struct virtqueue *vq);
86 93
87bool virtqueue_enable_cb(struct virtqueue *vq); 94bool virtqueue_enable_cb(struct virtqueue *vq);
88 95
96bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
97
89void *virtqueue_detach_unused_buf(struct virtqueue *vq); 98void *virtqueue_detach_unused_buf(struct virtqueue *vq);
90 99
91/** 100/**
diff --git a/include/linux/virtio_9p.h b/include/linux/virtio_9p.h
index 1faa80d92f05..277c4ad44e84 100644
--- a/include/linux/virtio_9p.h
+++ b/include/linux/virtio_9p.h
@@ -1,11 +1,33 @@
1#ifndef _LINUX_VIRTIO_9P_H 1#ifndef _LINUX_VIRTIO_9P_H
2#define _LINUX_VIRTIO_9P_H 2#define _LINUX_VIRTIO_9P_H
3/* This header is BSD licensed so anyone can use the definitions to implement 3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */ 4 * compatible drivers/servers.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of IBM nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. */
5#include <linux/types.h> 28#include <linux/types.h>
6#include <linux/virtio_ids.h> 29#include <linux/virtio_ids.h>
7#include <linux/virtio_config.h> 30#include <linux/virtio_config.h>
8#include <linux/types.h>
9 31
10/* The feature bitmap for virtio 9P */ 32/* The feature bitmap for virtio 9P */
11 33
diff --git a/include/linux/virtio_balloon.h b/include/linux/virtio_balloon.h
index a50ecd1b81a2..652dc8bea921 100644
--- a/include/linux/virtio_balloon.h
+++ b/include/linux/virtio_balloon.h
@@ -1,7 +1,30 @@
1#ifndef _LINUX_VIRTIO_BALLOON_H 1#ifndef _LINUX_VIRTIO_BALLOON_H
2#define _LINUX_VIRTIO_BALLOON_H 2#define _LINUX_VIRTIO_BALLOON_H
3/* This header is BSD licensed so anyone can use the definitions to implement 3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */ 4 * compatible drivers/servers.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of IBM nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. */
5#include <linux/virtio_ids.h> 28#include <linux/virtio_ids.h>
6#include <linux/virtio_config.h> 29#include <linux/virtio_config.h>
7 30
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
index 167720d695ed..e0edb40ca7aa 100644
--- a/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h
@@ -1,7 +1,30 @@
1#ifndef _LINUX_VIRTIO_BLK_H 1#ifndef _LINUX_VIRTIO_BLK_H
2#define _LINUX_VIRTIO_BLK_H 2#define _LINUX_VIRTIO_BLK_H
3/* This header is BSD licensed so anyone can use the definitions to implement 3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */ 4 * compatible drivers/servers.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of IBM nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. */
5#include <linux/types.h> 28#include <linux/types.h>
6#include <linux/virtio_ids.h> 29#include <linux/virtio_ids.h>
7#include <linux/virtio_config.h> 30#include <linux/virtio_config.h>
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 0093dd7c1d6f..39c88c5ad19d 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -1,7 +1,30 @@
1#ifndef _LINUX_VIRTIO_CONFIG_H 1#ifndef _LINUX_VIRTIO_CONFIG_H
2#define _LINUX_VIRTIO_CONFIG_H 2#define _LINUX_VIRTIO_CONFIG_H
3/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so 3/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
4 * anyone can use the definitions to implement compatible drivers/servers. */ 4 * anyone can use the definitions to implement compatible drivers/servers.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of IBM nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. */
5 28
6/* Virtio devices use a standardized configuration space to define their 29/* Virtio devices use a standardized configuration space to define their
7 * features and pass configuration information, but each implementation can 30 * features and pass configuration information, but each implementation can
@@ -109,7 +132,10 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
109 unsigned int fbit) 132 unsigned int fbit)
110{ 133{
111 /* Did you forget to fix assumptions on max features? */ 134 /* Did you forget to fix assumptions on max features? */
112 MAYBE_BUILD_BUG_ON(fbit >= 32); 135 if (__builtin_constant_p(fbit))
136 BUILD_BUG_ON(fbit >= 32);
137 else
138 BUG_ON(fbit >= 32);
113 139
114 if (fbit < VIRTIO_TRANSPORT_F_START) 140 if (fbit < VIRTIO_TRANSPORT_F_START)
115 virtio_check_driver_offered_feature(vdev, fbit); 141 virtio_check_driver_offered_feature(vdev, fbit);
diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h
index a85064db8f94..bdf4b0034739 100644
--- a/include/linux/virtio_console.h
+++ b/include/linux/virtio_console.h
@@ -5,9 +5,34 @@
5#include <linux/virtio_config.h> 5#include <linux/virtio_config.h>
6/* 6/*
7 * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so 7 * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
8 * anyone can use the definitions to implement compatible drivers/servers. 8 * anyone can use the definitions to implement compatible drivers/servers:
9 * 9 *
10 * Copyright (C) Red Hat, Inc., 2009, 2010 10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of IBM nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * Copyright (C) Red Hat, Inc., 2009, 2010, 2011
35 * Copyright (C) Amit Shah <amit.shah@redhat.com>, 2009, 2010, 2011
11 */ 36 */
12 37
13/* Feature bits */ 38/* Feature bits */
diff --git a/include/linux/virtio_ids.h b/include/linux/virtio_ids.h
index 06660c0a78d7..85bb0bb66ffc 100644
--- a/include/linux/virtio_ids.h
+++ b/include/linux/virtio_ids.h
@@ -5,7 +5,29 @@
5 * 5 *
6 * This header is BSD licensed so anyone can use the definitions to implement 6 * This header is BSD licensed so anyone can use the definitions to implement
7 * compatible drivers/servers. 7 * compatible drivers/servers.
8 */ 8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of IBM nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. */
9 31
10#define VIRTIO_ID_NET 1 /* virtio net */ 32#define VIRTIO_ID_NET 1 /* virtio net */
11#define VIRTIO_ID_BLOCK 2 /* virtio block */ 33#define VIRTIO_ID_BLOCK 2 /* virtio block */
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 085e42298ce5..136040bba3e3 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -1,7 +1,30 @@
1#ifndef _LINUX_VIRTIO_NET_H 1#ifndef _LINUX_VIRTIO_NET_H
2#define _LINUX_VIRTIO_NET_H 2#define _LINUX_VIRTIO_NET_H
3/* This header is BSD licensed so anyone can use the definitions to implement 3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */ 4 * compatible drivers/servers.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of IBM nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. */
5#include <linux/types.h> 28#include <linux/types.h>
6#include <linux/virtio_ids.h> 29#include <linux/virtio_ids.h>
7#include <linux/virtio_config.h> 30#include <linux/virtio_config.h>
diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
index 9a3d7c48c622..ea66f3f60d63 100644
--- a/include/linux/virtio_pci.h
+++ b/include/linux/virtio_pci.h
@@ -11,6 +11,29 @@
11 * 11 *
12 * This header is BSD licensed so anyone can use the definitions to implement 12 * This header is BSD licensed so anyone can use the definitions to implement
13 * compatible drivers/servers. 13 * compatible drivers/servers.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of IBM nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
14 */ 37 */
15 38
16#ifndef _LINUX_VIRTIO_PCI_H 39#ifndef _LINUX_VIRTIO_PCI_H
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index e4d144b132b5..4a32cb6da425 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -7,6 +7,29 @@
7 * This header is BSD licensed so anyone can use the definitions to implement 7 * This header is BSD licensed so anyone can use the definitions to implement
8 * compatible drivers/servers. 8 * compatible drivers/servers.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of IBM nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
10 * Copyright Rusty Russell IBM Corporation 2007. */ 33 * Copyright Rusty Russell IBM Corporation 2007. */
11#include <linux/types.h> 34#include <linux/types.h>
12 35
@@ -29,6 +52,12 @@
29/* We support indirect buffer descriptors */ 52/* We support indirect buffer descriptors */
30#define VIRTIO_RING_F_INDIRECT_DESC 28 53#define VIRTIO_RING_F_INDIRECT_DESC 28
31 54
55/* The Guest publishes the used index for which it expects an interrupt
56 * at the end of the avail ring. Host should ignore the avail->flags field. */
57/* The Host publishes the avail index for which it expects a kick
58 * at the end of the used ring. Guest should ignore the used->flags field. */
59#define VIRTIO_RING_F_EVENT_IDX 29
60
32/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ 61/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
33struct vring_desc { 62struct vring_desc {
34 /* Address (guest-physical). */ 63 /* Address (guest-physical). */
@@ -83,6 +112,7 @@ struct vring {
83 * __u16 avail_flags; 112 * __u16 avail_flags;
84 * __u16 avail_idx; 113 * __u16 avail_idx;
85 * __u16 available[num]; 114 * __u16 available[num];
115 * __u16 used_event_idx;
86 * 116 *
87 * // Padding to the next align boundary. 117 * // Padding to the next align boundary.
88 * char pad[]; 118 * char pad[];
@@ -91,8 +121,14 @@ struct vring {
91 * __u16 used_flags; 121 * __u16 used_flags;
92 * __u16 used_idx; 122 * __u16 used_idx;
93 * struct vring_used_elem used[num]; 123 * struct vring_used_elem used[num];
124 * __u16 avail_event_idx;
94 * }; 125 * };
95 */ 126 */
127/* We publish the used event index at the end of the available ring, and vice
128 * versa. They are at the end for backwards compatibility. */
129#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
130#define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num])
131
96static inline void vring_init(struct vring *vr, unsigned int num, void *p, 132static inline void vring_init(struct vring *vr, unsigned int num, void *p,
97 unsigned long align) 133 unsigned long align)
98{ 134{
@@ -107,7 +143,21 @@ static inline unsigned vring_size(unsigned int num, unsigned long align)
107{ 143{
108 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) 144 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
109 + align - 1) & ~(align - 1)) 145 + align - 1) & ~(align - 1))
110 + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; 146 + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
147}
148
149/* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */
150/* Assuming a given event_idx value from the other size, if
151 * we have just incremented index from old to new_idx,
152 * should we trigger an event? */
153static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)
154{
155 /* Note: Xen has similar logic for notification hold-off
156 * in include/xen/interface/io/ring.h with req_event and req_prod
157 * corresponding to event_idx + 1 and new_idx respectively.
158 * Note also that req_event and req_prod in Xen start at 1,
159 * event indexes in virtio start at 0. */
160 return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old);
111} 161}
112 162
113#ifdef __KERNEL__ 163#ifdef __KERNEL__
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
new file mode 100644
index 000000000000..03b90cdc1921
--- /dev/null
+++ b/include/linux/vm_event_item.h
@@ -0,0 +1,64 @@
1#ifndef VM_EVENT_ITEM_H_INCLUDED
2#define VM_EVENT_ITEM_H_INCLUDED
3
4#ifdef CONFIG_ZONE_DMA
5#define DMA_ZONE(xx) xx##_DMA,
6#else
7#define DMA_ZONE(xx)
8#endif
9
10#ifdef CONFIG_ZONE_DMA32
11#define DMA32_ZONE(xx) xx##_DMA32,
12#else
13#define DMA32_ZONE(xx)
14#endif
15
16#ifdef CONFIG_HIGHMEM
17#define HIGHMEM_ZONE(xx) , xx##_HIGH
18#else
19#define HIGHMEM_ZONE(xx)
20#endif
21
22#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) , xx##_MOVABLE
23
24enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
25 FOR_ALL_ZONES(PGALLOC),
26 PGFREE, PGACTIVATE, PGDEACTIVATE,
27 PGFAULT, PGMAJFAULT,
28 FOR_ALL_ZONES(PGREFILL),
29 FOR_ALL_ZONES(PGSTEAL),
30 FOR_ALL_ZONES(PGSCAN_KSWAPD),
31 FOR_ALL_ZONES(PGSCAN_DIRECT),
32#ifdef CONFIG_NUMA
33 PGSCAN_ZONE_RECLAIM_FAILED,
34#endif
35 PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
36 KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY,
37 KSWAPD_SKIP_CONGESTION_WAIT,
38 PAGEOUTRUN, ALLOCSTALL, PGROTATED,
39#ifdef CONFIG_COMPACTION
40 COMPACTBLOCKS, COMPACTPAGES, COMPACTPAGEFAILED,
41 COMPACTSTALL, COMPACTFAIL, COMPACTSUCCESS,
42#endif
43#ifdef CONFIG_HUGETLB_PAGE
44 HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
45#endif
46 UNEVICTABLE_PGCULLED, /* culled to noreclaim list */
47 UNEVICTABLE_PGSCANNED, /* scanned for reclaimability */
48 UNEVICTABLE_PGRESCUED, /* rescued from noreclaim list */
49 UNEVICTABLE_PGMLOCKED,
50 UNEVICTABLE_PGMUNLOCKED,
51 UNEVICTABLE_PGCLEARED, /* on COW, page truncate */
52 UNEVICTABLE_PGSTRANDED, /* unable to isolate on unlock */
53 UNEVICTABLE_MLOCKFREED,
54#ifdef CONFIG_TRANSPARENT_HUGEPAGE
55 THP_FAULT_ALLOC,
56 THP_FAULT_FALLBACK,
57 THP_COLLAPSE_ALLOC,
58 THP_COLLAPSE_ALLOC_FAILED,
59 THP_SPLIT,
60#endif
61 NR_VM_EVENT_ITEMS
62};
63
64#endif /* VM_EVENT_ITEM_H_INCLUDED */
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 01c2145118dc..9332e52ea8c2 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -7,8 +7,6 @@
7 7
8struct vm_area_struct; /* vma defining user mapping in mm_types.h */ 8struct vm_area_struct; /* vma defining user mapping in mm_types.h */
9 9
10extern bool vmap_lazy_unmap;
11
12/* bits in flags of vmalloc's vm_struct below */ 10/* bits in flags of vmalloc's vm_struct below */
13#define VM_IOREMAP 0x00000001 /* ioremap() and friends */ 11#define VM_IOREMAP 0x00000001 /* ioremap() and friends */
14#define VM_ALLOC 0x00000002 /* vmalloc() */ 12#define VM_ALLOC 0x00000002 /* vmalloc() */
@@ -53,14 +51,17 @@ static inline void vmalloc_init(void)
53#endif 51#endif
54 52
55extern void *vmalloc(unsigned long size); 53extern void *vmalloc(unsigned long size);
54extern void *vzalloc(unsigned long size);
56extern void *vmalloc_user(unsigned long size); 55extern void *vmalloc_user(unsigned long size);
57extern void *vmalloc_node(unsigned long size, int node); 56extern void *vmalloc_node(unsigned long size, int node);
57extern void *vzalloc_node(unsigned long size, int node);
58extern void *vmalloc_exec(unsigned long size); 58extern void *vmalloc_exec(unsigned long size);
59extern void *vmalloc_32(unsigned long size); 59extern void *vmalloc_32(unsigned long size);
60extern void *vmalloc_32_user(unsigned long size); 60extern void *vmalloc_32_user(unsigned long size);
61extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot); 61extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
62extern void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask, 62extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
63 pgprot_t prot); 63 unsigned long start, unsigned long end, gfp_t gfp_mask,
64 pgprot_t prot, int node, void *caller);
64extern void vfree(const void *addr); 65extern void vfree(const void *addr);
65 66
66extern void *vmap(struct page **pages, unsigned int count, 67extern void *vmap(struct page **pages, unsigned int count,
@@ -90,17 +91,31 @@ extern struct vm_struct *__get_vm_area_caller(unsigned long size,
90 unsigned long flags, 91 unsigned long flags,
91 unsigned long start, unsigned long end, 92 unsigned long start, unsigned long end,
92 void *caller); 93 void *caller);
93extern struct vm_struct *get_vm_area_node(unsigned long size,
94 unsigned long flags, int node,
95 gfp_t gfp_mask);
96extern struct vm_struct *remove_vm_area(const void *addr); 94extern struct vm_struct *remove_vm_area(const void *addr);
97 95
98extern int map_vm_area(struct vm_struct *area, pgprot_t prot, 96extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
99 struct page ***pages); 97 struct page ***pages);
98#ifdef CONFIG_MMU
100extern int map_kernel_range_noflush(unsigned long start, unsigned long size, 99extern int map_kernel_range_noflush(unsigned long start, unsigned long size,
101 pgprot_t prot, struct page **pages); 100 pgprot_t prot, struct page **pages);
102extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size); 101extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size);
103extern void unmap_kernel_range(unsigned long addr, unsigned long size); 102extern void unmap_kernel_range(unsigned long addr, unsigned long size);
103#else
104static inline int
105map_kernel_range_noflush(unsigned long start, unsigned long size,
106 pgprot_t prot, struct page **pages)
107{
108 return size >> PAGE_SHIFT;
109}
110static inline void
111unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
112{
113}
114static inline void
115unmap_kernel_range(unsigned long addr, unsigned long size)
116{
117}
118#endif
104 119
105/* Allocate/destroy a 'vmalloc' VM area. */ 120/* Allocate/destroy a 'vmalloc' VM area. */
106extern struct vm_struct *alloc_vm_area(size_t size); 121extern struct vm_struct *alloc_vm_area(size_t size);
@@ -117,10 +132,27 @@ extern rwlock_t vmlist_lock;
117extern struct vm_struct *vmlist; 132extern struct vm_struct *vmlist;
118extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); 133extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
119 134
135#ifdef CONFIG_SMP
136# ifdef CONFIG_MMU
120struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets, 137struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
121 const size_t *sizes, int nr_vms, 138 const size_t *sizes, int nr_vms,
122 size_t align, gfp_t gfp_mask); 139 size_t align);
123 140
124void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms); 141void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms);
142# else
143static inline struct vm_struct **
144pcpu_get_vm_areas(const unsigned long *offsets,
145 const size_t *sizes, int nr_vms,
146 size_t align)
147{
148 return NULL;
149}
150
151static inline void
152pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
153{
154}
155# endif
156#endif
125 157
126#endif /* _LINUX_VMALLOC_H */ 158#endif /* _LINUX_VMALLOC_H */
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index eaaea37b3b75..bcd942fa611c 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -5,62 +5,9 @@
5#include <linux/percpu.h> 5#include <linux/percpu.h>
6#include <linux/mm.h> 6#include <linux/mm.h>
7#include <linux/mmzone.h> 7#include <linux/mmzone.h>
8#include <linux/vm_event_item.h>
8#include <asm/atomic.h> 9#include <asm/atomic.h>
9 10
10#ifdef CONFIG_ZONE_DMA
11#define DMA_ZONE(xx) xx##_DMA,
12#else
13#define DMA_ZONE(xx)
14#endif
15
16#ifdef CONFIG_ZONE_DMA32
17#define DMA32_ZONE(xx) xx##_DMA32,
18#else
19#define DMA32_ZONE(xx)
20#endif
21
22#ifdef CONFIG_HIGHMEM
23#define HIGHMEM_ZONE(xx) , xx##_HIGH
24#else
25#define HIGHMEM_ZONE(xx)
26#endif
27
28
29#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) , xx##_MOVABLE
30
31enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
32 FOR_ALL_ZONES(PGALLOC),
33 PGFREE, PGACTIVATE, PGDEACTIVATE,
34 PGFAULT, PGMAJFAULT,
35 FOR_ALL_ZONES(PGREFILL),
36 FOR_ALL_ZONES(PGSTEAL),
37 FOR_ALL_ZONES(PGSCAN_KSWAPD),
38 FOR_ALL_ZONES(PGSCAN_DIRECT),
39#ifdef CONFIG_NUMA
40 PGSCAN_ZONE_RECLAIM_FAILED,
41#endif
42 PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
43 KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY,
44 KSWAPD_SKIP_CONGESTION_WAIT,
45 PAGEOUTRUN, ALLOCSTALL, PGROTATED,
46#ifdef CONFIG_COMPACTION
47 COMPACTBLOCKS, COMPACTPAGES, COMPACTPAGEFAILED,
48 COMPACTSTALL, COMPACTFAIL, COMPACTSUCCESS,
49#endif
50#ifdef CONFIG_HUGETLB_PAGE
51 HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
52#endif
53 UNEVICTABLE_PGCULLED, /* culled to noreclaim list */
54 UNEVICTABLE_PGSCANNED, /* scanned for reclaimability */
55 UNEVICTABLE_PGRESCUED, /* rescued from noreclaim list */
56 UNEVICTABLE_PGMLOCKED,
57 UNEVICTABLE_PGMUNLOCKED,
58 UNEVICTABLE_PGCLEARED, /* on COW, page truncate */
59 UNEVICTABLE_PGSTRANDED, /* unable to isolate on unlock */
60 UNEVICTABLE_MLOCKFREED,
61 NR_VM_EVENT_ITEMS
62};
63
64extern int sysctl_stat_interval; 11extern int sysctl_stat_interval;
65 12
66#ifdef CONFIG_VM_EVENT_COUNTERS 13#ifdef CONFIG_VM_EVENT_COUNTERS
@@ -220,12 +167,12 @@ static inline unsigned long node_page_state(int node,
220 zone_page_state(&zones[ZONE_MOVABLE], item); 167 zone_page_state(&zones[ZONE_MOVABLE], item);
221} 168}
222 169
223extern void zone_statistics(struct zone *, struct zone *); 170extern void zone_statistics(struct zone *, struct zone *, gfp_t gfp);
224 171
225#else 172#else
226 173
227#define node_page_state(node, item) global_page_state(item) 174#define node_page_state(node, item) global_page_state(item)
228#define zone_statistics(_zl,_z) do { } while (0) 175#define zone_statistics(_zl, _z, gfp) do { } while (0)
229 176
230#endif /* CONFIG_NUMA */ 177#endif /* CONFIG_NUMA */
231 178
@@ -254,6 +201,12 @@ extern void dec_zone_state(struct zone *, enum zone_stat_item);
254extern void __dec_zone_state(struct zone *, enum zone_stat_item); 201extern void __dec_zone_state(struct zone *, enum zone_stat_item);
255 202
256void refresh_cpu_vm_stats(int); 203void refresh_cpu_vm_stats(int);
204void refresh_zone_stat_thresholds(void);
205
206int calculate_pressure_threshold(struct zone *zone);
207int calculate_normal_threshold(struct zone *zone);
208void set_pgdat_percpu_threshold(pg_data_t *pgdat,
209 int (*calculate_pressure)(struct zone *));
257#else /* CONFIG_SMP */ 210#else /* CONFIG_SMP */
258 211
259/* 212/*
@@ -298,7 +251,13 @@ static inline void __dec_zone_page_state(struct page *page,
298#define dec_zone_page_state __dec_zone_page_state 251#define dec_zone_page_state __dec_zone_page_state
299#define mod_zone_page_state __mod_zone_page_state 252#define mod_zone_page_state __mod_zone_page_state
300 253
254#define set_pgdat_percpu_threshold(pgdat, callback) { }
255
301static inline void refresh_cpu_vm_stats(int cpu) { } 256static inline void refresh_cpu_vm_stats(int cpu) { }
302#endif 257static inline void refresh_zone_stat_thresholds(void) { }
258
259#endif /* CONFIG_SMP */
260
261extern const char * const vmstat_text[];
303 262
304#endif /* _LINUX_VMSTAT_H */ 263#endif /* _LINUX_VMSTAT_H */
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index 6625cc1ab758..4d05e14ea60c 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -142,14 +142,6 @@ static inline bool vt_force_oops_output(struct vc_data *vc)
142 return false; 142 return false;
143} 143}
144 144
145/*
146 * vc_screen.c shares this temporary buffer with the console write code so that
147 * we can easily avoid touching user space while holding the console spinlock.
148 */
149
150#define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE)
151extern char con_buf[CON_BUF_SIZE];
152extern struct mutex con_buf_mtx;
153extern char vt_dont_switch; 145extern char vt_dont_switch;
154extern int default_utf8; 146extern int default_utf8;
155extern int global_cursor_default; 147extern int global_cursor_default;
diff --git a/include/linux/wimax.h b/include/linux/wimax.h
index 4fdcc5635518..9f6b77af2f6d 100644
--- a/include/linux/wimax.h
+++ b/include/linux/wimax.h
@@ -114,7 +114,7 @@ enum {
114 WIMAX_GNL_RESET_IFIDX = 1, 114 WIMAX_GNL_RESET_IFIDX = 1,
115}; 115};
116 116
117/* Atributes for wimax_state_get() */ 117/* Attributes for wimax_state_get() */
118enum { 118enum {
119 WIMAX_GNL_STGET_IFIDX = 1, 119 WIMAX_GNL_STGET_IFIDX = 1,
120}; 120};
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index e6827eedf18b..4395b28bb86c 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -1157,6 +1157,6 @@ struct __compat_iw_event {
1157#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param)) 1157#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
1158#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr)) 1158#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
1159#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality)) 1159#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
1160#define IW_EV_POINT_PK_LEN (IW_EV_LCP_LEN + 4) 1160#define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4)
1161 1161
1162#endif /* _LINUX_WIRELESS_H */ 1162#endif /* _LINUX_WIRELESS_H */
diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
new file mode 100644
index 000000000000..4b697395326e
--- /dev/null
+++ b/include/linux/wl12xx.h
@@ -0,0 +1,78 @@
1/*
2 * This file is part of wl12xx
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 *
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef _LINUX_WL12XX_H
25#define _LINUX_WL12XX_H
26
27/* Reference clock values */
28enum {
29 WL12XX_REFCLOCK_19 = 0, /* 19.2 MHz */
30 WL12XX_REFCLOCK_26 = 1, /* 26 MHz */
31 WL12XX_REFCLOCK_38 = 2, /* 38.4 MHz */
32 WL12XX_REFCLOCK_52 = 3, /* 52 MHz */
33 WL12XX_REFCLOCK_38_XTAL = 4, /* 38.4 MHz, XTAL */
34 WL12XX_REFCLOCK_26_XTAL = 5, /* 26 MHz, XTAL */
35};
36
37/* TCXO clock values */
38enum {
39 WL12XX_TCXOCLOCK_19_2 = 0, /* 19.2MHz */
40 WL12XX_TCXOCLOCK_26 = 1, /* 26 MHz */
41 WL12XX_TCXOCLOCK_38_4 = 2, /* 38.4MHz */
42 WL12XX_TCXOCLOCK_52 = 3, /* 52 MHz */
43 WL12XX_TCXOCLOCK_16_368 = 4, /* 16.368 MHz */
44 WL12XX_TCXOCLOCK_32_736 = 5, /* 32.736 MHz */
45 WL12XX_TCXOCLOCK_16_8 = 6, /* 16.8 MHz */
46 WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
47};
48
49struct wl12xx_platform_data {
50 void (*set_power)(bool enable);
51 /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
52 int irq;
53 bool use_eeprom;
54 int board_ref_clock;
55 int board_tcxo_clock;
56 unsigned long platform_quirks;
57};
58
59/* Platform does not support level trigger interrupts */
60#define WL12XX_PLATFORM_QUIRK_EDGE_IRQ BIT(0)
61
62#ifdef CONFIG_WL12XX_PLATFORM_DATA
63
64int wl12xx_set_platform_data(const struct wl12xx_platform_data *data);
65
66#else
67
68static inline
69int wl12xx_set_platform_data(const struct wl12xx_platform_data *data)
70{
71 return -ENOSYS;
72}
73
74#endif
75
76const struct wl12xx_platform_data *wl12xx_get_platform_data(void);
77
78#endif
diff --git a/include/linux/wlp.h b/include/linux/wlp.h
deleted file mode 100644
index c76fe2392506..000000000000
--- a/include/linux/wlp.h
+++ /dev/null
@@ -1,736 +0,0 @@
1/*
2 * WiMedia Logical Link Control Protocol (WLP)
3 *
4 * Copyright (C) 2005-2006 Intel Corporation
5 * Reinette Chatre <reinette.chatre@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 *
22 * FIXME: docs
23 *
24 * - Does not (yet) include support for WLP control frames
25 * WLP Draft 0.99 [6.5].
26 *
27 * A visual representation of the data structures.
28 *
29 * wssidB wssidB
30 * ^ ^
31 * | |
32 * wssidA wssidA
33 * wlp interface { ^ ^
34 * ... | |
35 * ... ... wssid wssid ...
36 * wlp --- ... | |
37 * }; neighbors --> neighbA --> neighbB
38 * ...
39 * wss
40 * ...
41 * eda cache --> neighborA --> neighborB --> neighborC ...
42 */
43
44#ifndef __LINUX__WLP_H_
45#define __LINUX__WLP_H_
46
47#include <linux/netdevice.h>
48#include <linux/skbuff.h>
49#include <linux/list.h>
50#include <linux/uwb.h>
51
52/**
53 * WLP Protocol ID
54 * WLP Draft 0.99 [6.2]
55 *
56 * The MUX header for all WLP frames
57 */
58#define WLP_PROTOCOL_ID 0x0100
59
60/**
61 * WLP Version
62 * WLP version placed in the association frames (WLP 0.99 [6.6])
63 */
64#define WLP_VERSION 0x10
65
66/**
67 * Bytes needed to print UUID as string
68 */
69#define WLP_WSS_UUID_STRSIZE 48
70
71/**
72 * Bytes needed to print nonce as string
73 */
74#define WLP_WSS_NONCE_STRSIZE 48
75
76
77/**
78 * Size used for WLP name size
79 *
80 * The WSS name is set to 65 bytes, 1 byte larger than the maximum
81 * allowed by the WLP spec. This is to have a null terminated string
82 * for display to the user. A maximum of 64 bytes will still be used
83 * when placing the WSS name field in association frames.
84 */
85#define WLP_WSS_NAME_SIZE 65
86
87/**
88 * Number of bytes added by WLP to data frame
89 *
90 * A data frame transmitted from a host will be placed in a Standard or
91 * Abbreviated WLP frame. These have an extra 4 bytes of header (struct
92 * wlp_frame_std_abbrv_hdr).
93 * When the stack sends this data frame for transmission it needs to ensure
94 * there is enough headroom for this header.
95 */
96#define WLP_DATA_HLEN 4
97
98/**
99 * State of device regarding WLP Service Set
100 *
101 * WLP_WSS_STATE_NONE: the host does not participate in any WSS
102 * WLP_WSS_STATE_PART_ENROLLED: used as part of the enrollment sequence
103 * ("Partial Enroll"). This state is used to
104 * indicate the first part of enrollment that is
105 * unsecure. If the WSS is unsecure then the
106 * state will promptly go to WLP_WSS_STATE_ENROLLED,
107 * if the WSS is not secure then the enrollment
108 * procedure is a few more steps before we are
109 * enrolled.
110 * WLP_WSS_STATE_ENROLLED: the host is enrolled in a WSS
111 * WLP_WSS_STATE_ACTIVE: WSS is activated
112 * WLP_WSS_STATE_CONNECTED: host is connected to neighbor in WSS
113 *
114 */
115enum wlp_wss_state {
116 WLP_WSS_STATE_NONE = 0,
117 WLP_WSS_STATE_PART_ENROLLED,
118 WLP_WSS_STATE_ENROLLED,
119 WLP_WSS_STATE_ACTIVE,
120 WLP_WSS_STATE_CONNECTED,
121};
122
123/**
124 * WSS Secure status
125 * WLP 0.99 Table 6
126 *
127 * Set to one if the WSS is secure, zero if it is not secure
128 */
129enum wlp_wss_sec_status {
130 WLP_WSS_UNSECURE = 0,
131 WLP_WSS_SECURE,
132};
133
134/**
135 * WLP frame type
136 * WLP Draft 0.99 [6.2 Table 1]
137 */
138enum wlp_frame_type {
139 WLP_FRAME_STANDARD = 0,
140 WLP_FRAME_ABBREVIATED,
141 WLP_FRAME_CONTROL,
142 WLP_FRAME_ASSOCIATION,
143};
144
145/**
146 * WLP Association Message Type
147 * WLP Draft 0.99 [6.6.1.2 Table 8]
148 */
149enum wlp_assoc_type {
150 WLP_ASSOC_D1 = 2,
151 WLP_ASSOC_D2 = 3,
152 WLP_ASSOC_M1 = 4,
153 WLP_ASSOC_M2 = 5,
154 WLP_ASSOC_M3 = 7,
155 WLP_ASSOC_M4 = 8,
156 WLP_ASSOC_M5 = 9,
157 WLP_ASSOC_M6 = 10,
158 WLP_ASSOC_M7 = 11,
159 WLP_ASSOC_M8 = 12,
160 WLP_ASSOC_F0 = 14,
161 WLP_ASSOC_E1 = 32,
162 WLP_ASSOC_E2 = 33,
163 WLP_ASSOC_C1 = 34,
164 WLP_ASSOC_C2 = 35,
165 WLP_ASSOC_C3 = 36,
166 WLP_ASSOC_C4 = 37,
167};
168
169/**
170 * WLP Attribute Type
171 * WLP Draft 0.99 [6.6.1 Table 6]
172 */
173enum wlp_attr_type {
174 WLP_ATTR_AUTH = 0x1005, /* Authenticator */
175 WLP_ATTR_DEV_NAME = 0x1011, /* Device Name */
176 WLP_ATTR_DEV_PWD_ID = 0x1012, /* Device Password ID */
177 WLP_ATTR_E_HASH1 = 0x1014, /* E-Hash1 */
178 WLP_ATTR_E_HASH2 = 0x1015, /* E-Hash2 */
179 WLP_ATTR_E_SNONCE1 = 0x1016, /* E-SNonce1 */
180 WLP_ATTR_E_SNONCE2 = 0x1017, /* E-SNonce2 */
181 WLP_ATTR_ENCR_SET = 0x1018, /* Encrypted Settings */
182 WLP_ATTR_ENRL_NONCE = 0x101A, /* Enrollee Nonce */
183 WLP_ATTR_KEYWRAP_AUTH = 0x101E, /* Key Wrap Authenticator */
184 WLP_ATTR_MANUF = 0x1021, /* Manufacturer */
185 WLP_ATTR_MSG_TYPE = 0x1022, /* Message Type */
186 WLP_ATTR_MODEL_NAME = 0x1023, /* Model Name */
187 WLP_ATTR_MODEL_NR = 0x1024, /* Model Number */
188 WLP_ATTR_PUB_KEY = 0x1032, /* Public Key */
189 WLP_ATTR_REG_NONCE = 0x1039, /* Registrar Nonce */
190 WLP_ATTR_R_HASH1 = 0x103D, /* R-Hash1 */
191 WLP_ATTR_R_HASH2 = 0x103E, /* R-Hash2 */
192 WLP_ATTR_R_SNONCE1 = 0x103F, /* R-SNonce1 */
193 WLP_ATTR_R_SNONCE2 = 0x1040, /* R-SNonce2 */
194 WLP_ATTR_SERIAL = 0x1042, /* Serial number */
195 WLP_ATTR_UUID_E = 0x1047, /* UUID-E */
196 WLP_ATTR_UUID_R = 0x1048, /* UUID-R */
197 WLP_ATTR_PRI_DEV_TYPE = 0x1054, /* Primary Device Type */
198 WLP_ATTR_SEC_DEV_TYPE = 0x1055, /* Secondary Device Type */
199 WLP_ATTR_PORT_DEV = 0x1056, /* Portable Device */
200 WLP_ATTR_APP_EXT = 0x1058, /* Application Extension */
201 WLP_ATTR_WLP_VER = 0x2000, /* WLP Version */
202 WLP_ATTR_WSSID = 0x2001, /* WSSID */
203 WLP_ATTR_WSS_NAME = 0x2002, /* WSS Name */
204 WLP_ATTR_WSS_SEC_STAT = 0x2003, /* WSS Secure Status */
205 WLP_ATTR_WSS_BCAST = 0x2004, /* WSS Broadcast Address */
206 WLP_ATTR_WSS_M_KEY = 0x2005, /* WSS Master Key */
207 WLP_ATTR_ACC_ENRL = 0x2006, /* Accepting Enrollment */
208 WLP_ATTR_WSS_INFO = 0x2007, /* WSS Information */
209 WLP_ATTR_WSS_SEL_MTHD = 0x2008, /* WSS Selection Method */
210 WLP_ATTR_ASSC_MTHD_LIST = 0x2009, /* Association Methods List */
211 WLP_ATTR_SEL_ASSC_MTHD = 0x200A, /* Selected Association Method */
212 WLP_ATTR_ENRL_HASH_COMM = 0x200B, /* Enrollee Hash Commitment */
213 WLP_ATTR_WSS_TAG = 0x200C, /* WSS Tag */
214 WLP_ATTR_WSS_VIRT = 0x200D, /* WSS Virtual EUI-48 */
215 WLP_ATTR_WLP_ASSC_ERR = 0x200E, /* WLP Association Error */
216 WLP_ATTR_VNDR_EXT = 0x200F, /* Vendor Extension */
217};
218
219/**
220 * WLP Category ID of primary/secondary device
221 * WLP Draft 0.99 [6.6.1.8 Table 12]
222 */
223enum wlp_dev_category_id {
224 WLP_DEV_CAT_COMPUTER = 1,
225 WLP_DEV_CAT_INPUT,
226 WLP_DEV_CAT_PRINT_SCAN_FAX_COPIER,
227 WLP_DEV_CAT_CAMERA,
228 WLP_DEV_CAT_STORAGE,
229 WLP_DEV_CAT_INFRASTRUCTURE,
230 WLP_DEV_CAT_DISPLAY,
231 WLP_DEV_CAT_MULTIM,
232 WLP_DEV_CAT_GAMING,
233 WLP_DEV_CAT_TELEPHONE,
234 WLP_DEV_CAT_OTHER = 65535,
235};
236
237/**
238 * WLP WSS selection method
239 * WLP Draft 0.99 [6.6.1.6 Table 10]
240 */
241enum wlp_wss_sel_mthd {
242 WLP_WSS_ENRL_SELECT = 1, /* Enrollee selects */
243 WLP_WSS_REG_SELECT, /* Registrar selects */
244};
245
246/**
247 * WLP association error values
248 * WLP Draft 0.99 [6.6.1.5 Table 9]
249 */
250enum wlp_assc_error {
251 WLP_ASSOC_ERROR_NONE,
252 WLP_ASSOC_ERROR_AUTH, /* Authenticator Failure */
253 WLP_ASSOC_ERROR_ROGUE, /* Rogue activity suspected */
254 WLP_ASSOC_ERROR_BUSY, /* Device busy */
255 WLP_ASSOC_ERROR_LOCK, /* Setup Locked */
256 WLP_ASSOC_ERROR_NOT_READY, /* Registrar not ready */
257 WLP_ASSOC_ERROR_INV, /* Invalid WSS selection */
258 WLP_ASSOC_ERROR_MSG_TIME, /* Message timeout */
259 WLP_ASSOC_ERROR_ENR_TIME, /* Enrollment session timeout */
260 WLP_ASSOC_ERROR_PW, /* Device password invalid */
261 WLP_ASSOC_ERROR_VER, /* Unsupported version */
262 WLP_ASSOC_ERROR_INT, /* Internal error */
263 WLP_ASSOC_ERROR_UNDEF, /* Undefined error */
264 WLP_ASSOC_ERROR_NUM, /* Numeric comparison failure */
265 WLP_ASSOC_ERROR_WAIT, /* Waiting for user input */
266};
267
268/**
269 * WLP Parameters
270 * WLP 0.99 [7.7]
271 */
272enum wlp_parameters {
273 WLP_PER_MSG_TIMEOUT = 15, /* Seconds to wait for response to
274 association message. */
275};
276
277/**
278 * WLP IE
279 *
280 * The WLP IE should be included in beacons by all devices.
281 *
282 * The driver can set only a few of the fields in this information element,
283 * most fields are managed by the device self. When the driver needs to set
284 * a field it will only provide values for the fields of interest, the rest
285 * will be filled with zeroes. The fields of interest are:
286 *
287 * Element ID
288 * Length
289 * Capabilities (only to include WSSID Hash list length)
290 * WSSID Hash List fields
291 *
292 * WLP 0.99 [6.7]
293 *
294 * Only the fields that will be used are detailed in this structure, rest
295 * are not detailed or marked as "notused".
296 */
297struct wlp_ie {
298 struct uwb_ie_hdr hdr;
299 __le16 capabilities;
300 __le16 cycle_param;
301 __le16 acw_anchor_addr;
302 u8 wssid_hash_list[];
303} __packed;
304
305static inline int wlp_ie_hash_length(struct wlp_ie *ie)
306{
307 return (le16_to_cpu(ie->capabilities) >> 12) & 0xf;
308}
309
310static inline void wlp_ie_set_hash_length(struct wlp_ie *ie, int hash_length)
311{
312 u16 caps = le16_to_cpu(ie->capabilities);
313 caps = (caps & ~(0xf << 12)) | (hash_length << 12);
314 ie->capabilities = cpu_to_le16(caps);
315}
316
317/**
318 * WLP nonce
319 * WLP Draft 0.99 [6.6.1 Table 6]
320 *
321 * A 128-bit random number often used (E-SNonce1, E-SNonce2, Enrollee
322 * Nonce, Registrar Nonce, R-SNonce1, R-SNonce2). It is passed to HW so
323 * it is packed.
324 */
325struct wlp_nonce {
326 u8 data[16];
327} __packed;
328
329/**
330 * WLP UUID
331 * WLP Draft 0.99 [6.6.1 Table 6]
332 *
333 * Universally Unique Identifier (UUID) encoded as an octet string in the
334 * order the octets are shown in string representation in RFC4122. A UUID
335 * is often used (UUID-E, UUID-R, WSSID). It is passed to HW so it is packed.
336 */
337struct wlp_uuid {
338 u8 data[16];
339} __packed;
340
341
342/**
343 * Primary and secondary device type attributes
344 * WLP Draft 0.99 [6.6.1.8]
345 */
346struct wlp_dev_type {
347 enum wlp_dev_category_id category:16;
348 u8 OUI[3];
349 u8 OUIsubdiv;
350 __le16 subID;
351} __packed;
352
353/**
354 * WLP frame header
355 * WLP Draft 0.99 [6.2]
356 */
357struct wlp_frame_hdr {
358 __le16 mux_hdr; /* WLP_PROTOCOL_ID */
359 enum wlp_frame_type type:8;
360} __packed;
361
362/**
363 * WLP attribute field header
364 * WLP Draft 0.99 [6.6.1]
365 *
366 * Header of each attribute found in an association frame
367 */
368struct wlp_attr_hdr {
369 __le16 type;
370 __le16 length;
371} __packed;
372
373/**
374 * Device information commonly used together
375 *
376 * Each of these device information elements has a specified range in which it
377 * should fit (WLP 0.99 [Table 6]). This range provided in the spec does not
378 * include the termination null '\0' character (when used in the
379 * association protocol the attribute fields are accompanied
380 * with a "length" field so the full range from the spec can be used for
381 * the value). We thus allocate an extra byte to be able to store a string
382 * of max length with a terminating '\0'.
383 */
384struct wlp_device_info {
385 char name[33];
386 char model_name[33];
387 char manufacturer[65];
388 char model_nr[33];
389 char serial[33];
390 struct wlp_dev_type prim_dev_type;
391};
392
393/**
394 * Macros for the WLP attributes
395 *
396 * There are quite a few attributes (total is 43). The attribute layout can be
397 * in one of three categories: one value, an array, an enum forced to 8 bits.
398 * These macros help with their definitions.
399 */
400#define wlp_attr(type, name) \
401struct wlp_attr_##name { \
402 struct wlp_attr_hdr hdr; \
403 type name; \
404} __packed;
405
406#define wlp_attr_array(type, name) \
407struct wlp_attr_##name { \
408 struct wlp_attr_hdr hdr; \
409 type name[]; \
410} __packed;
411
412/**
413 * WLP association attribute fields
414 * WLP Draft 0.99 [6.6.1 Table 6]
415 *
416 * Attributes appear in same order as the Table in the spec
417 * FIXME Does not define all attributes yet
418 */
419
420/* Device name: Friendly name of sending device */
421wlp_attr_array(u8, dev_name)
422
423/* Enrollee Nonce: Random number generated by enrollee for an enrollment
424 * session */
425wlp_attr(struct wlp_nonce, enonce)
426
427/* Manufacturer name: Name of manufacturer of the sending device */
428wlp_attr_array(u8, manufacturer)
429
430/* WLP Message Type */
431wlp_attr(u8, msg_type)
432
433/* WLP Model name: Model name of sending device */
434wlp_attr_array(u8, model_name)
435
436/* WLP Model number: Model number of sending device */
437wlp_attr_array(u8, model_nr)
438
439/* Registrar Nonce: Random number generated by registrar for an enrollment
440 * session */
441wlp_attr(struct wlp_nonce, rnonce)
442
443/* Serial number of device */
444wlp_attr_array(u8, serial)
445
446/* UUID of enrollee */
447wlp_attr(struct wlp_uuid, uuid_e)
448
449/* UUID of registrar */
450wlp_attr(struct wlp_uuid, uuid_r)
451
452/* WLP Primary device type */
453wlp_attr(struct wlp_dev_type, prim_dev_type)
454
455/* WLP Secondary device type */
456wlp_attr(struct wlp_dev_type, sec_dev_type)
457
458/* WLP protocol version */
459wlp_attr(u8, version)
460
461/* WLP service set identifier */
462wlp_attr(struct wlp_uuid, wssid)
463
464/* WLP WSS name */
465wlp_attr_array(u8, wss_name)
466
467/* WLP WSS Secure Status */
468wlp_attr(u8, wss_sec_status)
469
470/* WSS Broadcast Address */
471wlp_attr(struct uwb_mac_addr, wss_bcast)
472
473/* WLP Accepting Enrollment */
474wlp_attr(u8, accept_enrl)
475
476/**
477 * WSS information attributes
478 * WLP Draft 0.99 [6.6.3 Table 15]
479 */
480struct wlp_wss_info {
481 struct wlp_attr_wssid wssid;
482 struct wlp_attr_wss_name name;
483 struct wlp_attr_accept_enrl accept;
484 struct wlp_attr_wss_sec_status sec_stat;
485 struct wlp_attr_wss_bcast bcast;
486} __packed;
487
488/* WLP WSS Information */
489wlp_attr_array(struct wlp_wss_info, wss_info)
490
491/* WLP WSS Selection method */
492wlp_attr(u8, wss_sel_mthd)
493
494/* WLP WSS tag */
495wlp_attr(u8, wss_tag)
496
497/* WSS Virtual Address */
498wlp_attr(struct uwb_mac_addr, wss_virt)
499
500/* WLP association error */
501wlp_attr(u8, wlp_assc_err)
502
503/**
504 * WLP standard and abbreviated frames
505 *
506 * WLP Draft 0.99 [6.3] and [6.4]
507 *
508 * The difference between the WLP standard frame and the WLP
509 * abbreviated frame is that the standard frame includes the src
510 * and dest addresses from the Ethernet header, the abbreviated frame does
511 * not.
512 * The src/dest (as well as the type/length and client data) are already
513 * defined as part of the Ethernet header, we do not do this here.
514 * From this perspective the standard and abbreviated frames appear the
515 * same - they will be treated differently though.
516 *
517 * The size of this header is also captured in WLP_DATA_HLEN to enable
518 * interfaces to prepare their headroom.
519 */
520struct wlp_frame_std_abbrv_hdr {
521 struct wlp_frame_hdr hdr;
522 u8 tag;
523} __packed;
524
525/**
526 * WLP association frames
527 *
528 * WLP Draft 0.99 [6.6]
529 */
530struct wlp_frame_assoc {
531 struct wlp_frame_hdr hdr;
532 enum wlp_assoc_type type:8;
533 struct wlp_attr_version version;
534 struct wlp_attr_msg_type msg_type;
535 u8 attr[];
536} __packed;
537
538/* Ethernet to dev address mapping */
539struct wlp_eda {
540 spinlock_t lock;
541 struct list_head cache; /* Eth<->Dev Addr cache */
542};
543
544/**
545 * WSS information temporary storage
546 *
547 * This information is only stored temporarily during discovery. It should
548 * not be stored unless the device is enrolled in the advertised WSS. This
549 * is done mainly because we follow the letter of the spec in this regard.
550 * See WLP 0.99 [7.2.3].
551 * When the device does become enrolled in a WSS the WSS information will
552 * be stored as part of the more comprehensive struct wlp_wss.
553 */
554struct wlp_wss_tmp_info {
555 char name[WLP_WSS_NAME_SIZE];
556 u8 accept_enroll;
557 u8 sec_status;
558 struct uwb_mac_addr bcast;
559};
560
561struct wlp_wssid_e {
562 struct list_head node;
563 struct wlp_uuid wssid;
564 struct wlp_wss_tmp_info *info;
565};
566
567/**
568 * A cache entry of WLP neighborhood
569 *
570 * @node: head of list is wlp->neighbors
571 * @wssid: list of wssids of this neighbor, element is wlp_wssid_e
572 * @info: temporary storage for information learned during discovery. This
573 * storage is used together with the wssid_e temporary storage
574 * during discovery.
575 */
576struct wlp_neighbor_e {
577 struct list_head node;
578 struct wlp_uuid uuid;
579 struct uwb_dev *uwb_dev;
580 struct list_head wssid; /* Elements are wlp_wssid_e */
581 struct wlp_device_info *info;
582};
583
584struct wlp;
585/**
586 * Information for an association session in progress.
587 *
588 * @exp_message: The type of the expected message. Both this message and a
589 * F0 message (which can be sent in response to any
590 * association frame) will be accepted as a valid message for
591 * this session.
592 * @cb: The function that will be called upon receipt of this
593 * message.
594 * @cb_priv: Private data of callback
595 * @data: Data used in association process (always a sk_buff?)
596 * @neighbor: Address of neighbor with which association session is in
597 * progress.
598 */
599struct wlp_session {
600 enum wlp_assoc_type exp_message;
601 void (*cb)(struct wlp *);
602 void *cb_priv;
603 void *data;
604 struct uwb_dev_addr neighbor_addr;
605};
606
607/**
608 * WLP Service Set
609 *
610 * @mutex: used to protect entire WSS structure.
611 *
612 * @name: The WSS name is set to 65 bytes, 1 byte larger than the maximum
613 * allowed by the WLP spec. This is to have a null terminated string
614 * for display to the user. A maximum of 64 bytes will still be used
615 * when placing the WSS name field in association frames.
616 *
617 * @accept_enroll: Accepting enrollment: Set to one if registrar is
618 * accepting enrollment in WSS, or zero otherwise.
619 *
620 * Global and local information for each WSS in which we are enrolled.
621 * WLP 0.99 Section 7.2.1 and Section 7.2.2
622 */
623struct wlp_wss {
624 struct mutex mutex;
625 struct kobject kobj;
626 /* Global properties. */
627 struct wlp_uuid wssid;
628 u8 hash;
629 char name[WLP_WSS_NAME_SIZE];
630 struct uwb_mac_addr bcast;
631 u8 secure_status:1;
632 u8 master_key[16];
633 /* Local properties. */
634 u8 tag;
635 struct uwb_mac_addr virtual_addr;
636 /* Extra */
637 u8 accept_enroll:1;
638 enum wlp_wss_state state;
639};
640
641/**
642 * WLP main structure
643 * @mutex: protect changes to WLP structure. We only allow changes to the
644 * uuid, so currently this mutex only protects this field.
645 */
646struct wlp {
647 struct mutex mutex;
648 struct uwb_rc *rc; /* UWB radio controller */
649 struct net_device *ndev;
650 struct uwb_pal pal;
651 struct wlp_eda eda;
652 struct wlp_uuid uuid;
653 struct wlp_session *session;
654 struct wlp_wss wss;
655 struct mutex nbmutex; /* Neighbor mutex protects neighbors list */
656 struct list_head neighbors; /* Elements are wlp_neighbor_e */
657 struct uwb_notifs_handler uwb_notifs_handler;
658 struct wlp_device_info *dev_info;
659 void (*fill_device_info)(struct wlp *wlp, struct wlp_device_info *info);
660 int (*xmit_frame)(struct wlp *, struct sk_buff *,
661 struct uwb_dev_addr *);
662 void (*stop_queue)(struct wlp *);
663 void (*start_queue)(struct wlp *);
664};
665
666/* sysfs */
667
668
669struct wlp_wss_attribute {
670 struct attribute attr;
671 ssize_t (*show)(struct wlp_wss *wss, char *buf);
672 ssize_t (*store)(struct wlp_wss *wss, const char *buf, size_t count);
673};
674
675#define WSS_ATTR(_name, _mode, _show, _store) \
676static struct wlp_wss_attribute wss_attr_##_name = __ATTR(_name, _mode, \
677 _show, _store)
678
679extern int wlp_setup(struct wlp *, struct uwb_rc *, struct net_device *ndev);
680extern void wlp_remove(struct wlp *);
681extern ssize_t wlp_neighborhood_show(struct wlp *, char *);
682extern int wlp_wss_setup(struct net_device *, struct wlp_wss *);
683extern void wlp_wss_remove(struct wlp_wss *);
684extern ssize_t wlp_wss_activate_show(struct wlp_wss *, char *);
685extern ssize_t wlp_wss_activate_store(struct wlp_wss *, const char *, size_t);
686extern ssize_t wlp_eda_show(struct wlp *, char *);
687extern ssize_t wlp_eda_store(struct wlp *, const char *, size_t);
688extern ssize_t wlp_uuid_show(struct wlp *, char *);
689extern ssize_t wlp_uuid_store(struct wlp *, const char *, size_t);
690extern ssize_t wlp_dev_name_show(struct wlp *, char *);
691extern ssize_t wlp_dev_name_store(struct wlp *, const char *, size_t);
692extern ssize_t wlp_dev_manufacturer_show(struct wlp *, char *);
693extern ssize_t wlp_dev_manufacturer_store(struct wlp *, const char *, size_t);
694extern ssize_t wlp_dev_model_name_show(struct wlp *, char *);
695extern ssize_t wlp_dev_model_name_store(struct wlp *, const char *, size_t);
696extern ssize_t wlp_dev_model_nr_show(struct wlp *, char *);
697extern ssize_t wlp_dev_model_nr_store(struct wlp *, const char *, size_t);
698extern ssize_t wlp_dev_serial_show(struct wlp *, char *);
699extern ssize_t wlp_dev_serial_store(struct wlp *, const char *, size_t);
700extern ssize_t wlp_dev_prim_category_show(struct wlp *, char *);
701extern ssize_t wlp_dev_prim_category_store(struct wlp *, const char *,
702 size_t);
703extern ssize_t wlp_dev_prim_OUI_show(struct wlp *, char *);
704extern ssize_t wlp_dev_prim_OUI_store(struct wlp *, const char *, size_t);
705extern ssize_t wlp_dev_prim_OUI_sub_show(struct wlp *, char *);
706extern ssize_t wlp_dev_prim_OUI_sub_store(struct wlp *, const char *,
707 size_t);
708extern ssize_t wlp_dev_prim_subcat_show(struct wlp *, char *);
709extern ssize_t wlp_dev_prim_subcat_store(struct wlp *, const char *,
710 size_t);
711extern int wlp_receive_frame(struct device *, struct wlp *, struct sk_buff *,
712 struct uwb_dev_addr *);
713extern int wlp_prepare_tx_frame(struct device *, struct wlp *,
714 struct sk_buff *, struct uwb_dev_addr *);
715void wlp_reset_all(struct wlp *wlp);
716
717/**
718 * Initialize WSS
719 */
720static inline
721void wlp_wss_init(struct wlp_wss *wss)
722{
723 mutex_init(&wss->mutex);
724}
725
726static inline
727void wlp_init(struct wlp *wlp)
728{
729 INIT_LIST_HEAD(&wlp->neighbors);
730 mutex_init(&wlp->mutex);
731 mutex_init(&wlp->nbmutex);
732 wlp_wss_init(&wlp->wss);
733}
734
735
736#endif /* #ifndef __LINUX__WLP_H_ */
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 25e02c941bac..f584aba78ca9 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -127,12 +127,20 @@ struct execute_work {
127 .timer = TIMER_INITIALIZER(NULL, 0, 0), \ 127 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
128 } 128 }
129 129
130#define __DEFERRED_WORK_INITIALIZER(n, f) { \
131 .work = __WORK_INITIALIZER((n).work, (f)), \
132 .timer = TIMER_DEFERRED_INITIALIZER(NULL, 0, 0), \
133 }
134
130#define DECLARE_WORK(n, f) \ 135#define DECLARE_WORK(n, f) \
131 struct work_struct n = __WORK_INITIALIZER(n, f) 136 struct work_struct n = __WORK_INITIALIZER(n, f)
132 137
133#define DECLARE_DELAYED_WORK(n, f) \ 138#define DECLARE_DELAYED_WORK(n, f) \
134 struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f) 139 struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f)
135 140
141#define DECLARE_DEFERRED_WORK(n, f) \
142 struct delayed_work n = __DEFERRED_WORK_INITIALIZER(n, f)
143
136/* 144/*
137 * initialize a work item's function pointer 145 * initialize a work item's function pointer
138 */ 146 */
@@ -190,7 +198,7 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
190 __INIT_WORK((_work), (_func), 0); \ 198 __INIT_WORK((_work), (_func), 0); \
191 } while (0) 199 } while (0)
192 200
193#define INIT_WORK_ON_STACK(_work, _func) \ 201#define INIT_WORK_ONSTACK(_work, _func) \
194 do { \ 202 do { \
195 __INIT_WORK((_work), (_func), 1); \ 203 __INIT_WORK((_work), (_func), 1); \
196 } while (0) 204 } while (0)
@@ -201,9 +209,9 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
201 init_timer(&(_work)->timer); \ 209 init_timer(&(_work)->timer); \
202 } while (0) 210 } while (0)
203 211
204#define INIT_DELAYED_WORK_ON_STACK(_work, _func) \ 212#define INIT_DELAYED_WORK_ONSTACK(_work, _func) \
205 do { \ 213 do { \
206 INIT_WORK_ON_STACK(&(_work)->work, (_func)); \ 214 INIT_WORK_ONSTACK(&(_work)->work, (_func)); \
207 init_timer_on_stack(&(_work)->timer); \ 215 init_timer_on_stack(&(_work)->timer); \
208 } while (0) 216 } while (0)
209 217
@@ -242,12 +250,13 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
242enum { 250enum {
243 WQ_NON_REENTRANT = 1 << 0, /* guarantee non-reentrance */ 251 WQ_NON_REENTRANT = 1 << 0, /* guarantee non-reentrance */
244 WQ_UNBOUND = 1 << 1, /* not bound to any cpu */ 252 WQ_UNBOUND = 1 << 1, /* not bound to any cpu */
245 WQ_FREEZEABLE = 1 << 2, /* freeze during suspend */ 253 WQ_FREEZABLE = 1 << 2, /* freeze during suspend */
246 WQ_RESCUER = 1 << 3, /* has an rescue worker */ 254 WQ_MEM_RECLAIM = 1 << 3, /* may be used for memory reclaim */
247 WQ_HIGHPRI = 1 << 4, /* high priority */ 255 WQ_HIGHPRI = 1 << 4, /* high priority */
248 WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */ 256 WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */
249 257
250 WQ_DYING = 1 << 6, /* internal: workqueue is dying */ 258 WQ_DYING = 1 << 6, /* internal: workqueue is dying */
259 WQ_RESCUER = 1 << 7, /* internal: workqueue has rescuer */
251 260
252 WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ 261 WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */
253 WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */ 262 WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */
@@ -277,11 +286,15 @@ enum {
277 * any specific CPU, not concurrency managed, and all queued works are 286 * any specific CPU, not concurrency managed, and all queued works are
278 * executed immediately as long as max_active limit is not reached and 287 * executed immediately as long as max_active limit is not reached and
279 * resources are available. 288 * resources are available.
289 *
290 * system_freezable_wq is equivalent to system_wq except that it's
291 * freezable.
280 */ 292 */
281extern struct workqueue_struct *system_wq; 293extern struct workqueue_struct *system_wq;
282extern struct workqueue_struct *system_long_wq; 294extern struct workqueue_struct *system_long_wq;
283extern struct workqueue_struct *system_nrt_wq; 295extern struct workqueue_struct *system_nrt_wq;
284extern struct workqueue_struct *system_unbound_wq; 296extern struct workqueue_struct *system_unbound_wq;
297extern struct workqueue_struct *system_freezable_wq;
285 298
286extern struct workqueue_struct * 299extern struct workqueue_struct *
287__alloc_workqueue_key(const char *name, unsigned int flags, int max_active, 300__alloc_workqueue_key(const char *name, unsigned int flags, int max_active,
@@ -306,12 +319,30 @@ __alloc_workqueue_key(const char *name, unsigned int flags, int max_active,
306 __alloc_workqueue_key((name), (flags), (max_active), NULL, NULL) 319 __alloc_workqueue_key((name), (flags), (max_active), NULL, NULL)
307#endif 320#endif
308 321
322/**
323 * alloc_ordered_workqueue - allocate an ordered workqueue
324 * @name: name of the workqueue
325 * @flags: WQ_* flags (only WQ_FREEZABLE and WQ_MEM_RECLAIM are meaningful)
326 *
327 * Allocate an ordered workqueue. An ordered workqueue executes at
328 * most one work item at any given time in the queued order. They are
329 * implemented as unbound workqueues with @max_active of one.
330 *
331 * RETURNS:
332 * Pointer to the allocated workqueue on success, %NULL on failure.
333 */
334static inline struct workqueue_struct *
335alloc_ordered_workqueue(const char *name, unsigned int flags)
336{
337 return alloc_workqueue(name, WQ_UNBOUND | flags, 1);
338}
339
309#define create_workqueue(name) \ 340#define create_workqueue(name) \
310 alloc_workqueue((name), WQ_RESCUER, 1) 341 alloc_workqueue((name), WQ_MEM_RECLAIM, 1)
311#define create_freezeable_workqueue(name) \ 342#define create_freezable_workqueue(name) \
312 alloc_workqueue((name), WQ_FREEZEABLE | WQ_UNBOUND | WQ_RESCUER, 1) 343 alloc_workqueue((name), WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
313#define create_singlethread_workqueue(name) \ 344#define create_singlethread_workqueue(name) \
314 alloc_workqueue((name), WQ_UNBOUND | WQ_RESCUER, 1) 345 alloc_workqueue((name), WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
315 346
316extern void destroy_workqueue(struct workqueue_struct *wq); 347extern void destroy_workqueue(struct workqueue_struct *wq);
317 348
@@ -325,7 +356,6 @@ extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
325 356
326extern void flush_workqueue(struct workqueue_struct *wq); 357extern void flush_workqueue(struct workqueue_struct *wq);
327extern void flush_scheduled_work(void); 358extern void flush_scheduled_work(void);
328extern void flush_delayed_work(struct delayed_work *work);
329 359
330extern int schedule_work(struct work_struct *work); 360extern int schedule_work(struct work_struct *work);
331extern int schedule_work_on(int cpu, struct work_struct *work); 361extern int schedule_work_on(int cpu, struct work_struct *work);
@@ -337,8 +367,13 @@ extern int keventd_up(void);
337 367
338int execute_in_process_context(work_func_t fn, struct execute_work *); 368int execute_in_process_context(work_func_t fn, struct execute_work *);
339 369
340extern int flush_work(struct work_struct *work); 370extern bool flush_work(struct work_struct *work);
341extern int cancel_work_sync(struct work_struct *work); 371extern bool flush_work_sync(struct work_struct *work);
372extern bool cancel_work_sync(struct work_struct *work);
373
374extern bool flush_delayed_work(struct delayed_work *dwork);
375extern bool flush_delayed_work_sync(struct delayed_work *work);
376extern bool cancel_delayed_work_sync(struct delayed_work *dwork);
342 377
343extern void workqueue_set_max_active(struct workqueue_struct *wq, 378extern void workqueue_set_max_active(struct workqueue_struct *wq,
344 int max_active); 379 int max_active);
@@ -352,9 +387,9 @@ extern unsigned int work_busy(struct work_struct *work);
352 * it returns 1 and the work doesn't re-arm itself. Run flush_workqueue() or 387 * it returns 1 and the work doesn't re-arm itself. Run flush_workqueue() or
353 * cancel_work_sync() to wait on it. 388 * cancel_work_sync() to wait on it.
354 */ 389 */
355static inline int cancel_delayed_work(struct delayed_work *work) 390static inline bool cancel_delayed_work(struct delayed_work *work)
356{ 391{
357 int ret; 392 bool ret;
358 393
359 ret = del_timer_sync(&work->timer); 394 ret = del_timer_sync(&work->timer);
360 if (ret) 395 if (ret)
@@ -367,9 +402,9 @@ static inline int cancel_delayed_work(struct delayed_work *work)
367 * if it returns 0 the timer function may be running and the queueing is in 402 * if it returns 0 the timer function may be running and the queueing is in
368 * progress. 403 * progress.
369 */ 404 */
370static inline int __cancel_delayed_work(struct delayed_work *work) 405static inline bool __cancel_delayed_work(struct delayed_work *work)
371{ 406{
372 int ret; 407 bool ret;
373 408
374 ret = del_timer(&work->timer); 409 ret = del_timer(&work->timer);
375 if (ret) 410 if (ret)
@@ -377,10 +412,8 @@ static inline int __cancel_delayed_work(struct delayed_work *work)
377 return ret; 412 return ret;
378} 413}
379 414
380extern int cancel_delayed_work_sync(struct delayed_work *work);
381
382/* Obsolete. use cancel_delayed_work_sync() */ 415/* Obsolete. use cancel_delayed_work_sync() */
383static inline 416static inline __deprecated
384void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq, 417void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
385 struct delayed_work *work) 418 struct delayed_work *work)
386{ 419{
@@ -388,7 +421,7 @@ void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
388} 421}
389 422
390/* Obsolete. use cancel_delayed_work_sync() */ 423/* Obsolete. use cancel_delayed_work_sync() */
391static inline 424static inline __deprecated
392void cancel_rearming_delayed_work(struct delayed_work *work) 425void cancel_rearming_delayed_work(struct delayed_work *work)
393{ 426{
394 cancel_delayed_work_sync(work); 427 cancel_delayed_work_sync(work);
@@ -409,8 +442,4 @@ extern bool freeze_workqueues_busy(void);
409extern void thaw_workqueues(void); 442extern void thaw_workqueues(void);
410#endif /* CONFIG_FREEZER */ 443#endif /* CONFIG_FREEZER */
411 444
412#ifdef CONFIG_LOCKDEP
413int in_workqueue_context(struct workqueue_struct *wq);
414#endif
415
416#endif 445#endif
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index 72a5d647a5f2..17e7ccc322a5 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -9,9 +9,7 @@
9 9
10struct backing_dev_info; 10struct backing_dev_info;
11 11
12extern spinlock_t inode_lock; 12extern spinlock_t inode_wb_list_lock;
13extern struct list_head inode_in_use;
14extern struct list_head inode_unused;
15 13
16/* 14/*
17 * fs/fs-writeback.c 15 * fs/fs-writeback.c
@@ -60,7 +58,9 @@ struct writeback_control {
60struct bdi_writeback; 58struct bdi_writeback;
61int inode_wait(void *); 59int inode_wait(void *);
62void writeback_inodes_sb(struct super_block *); 60void writeback_inodes_sb(struct super_block *);
61void writeback_inodes_sb_nr(struct super_block *, unsigned long nr);
63int writeback_inodes_sb_if_idle(struct super_block *); 62int writeback_inodes_sb_if_idle(struct super_block *);
63int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr);
64void sync_inodes_sb(struct super_block *); 64void sync_inodes_sb(struct super_block *);
65void writeback_inodes_wb(struct bdi_writeback *wb, 65void writeback_inodes_wb(struct bdi_writeback *wb,
66 struct writeback_control *wbc); 66 struct writeback_control *wbc);
@@ -143,12 +143,16 @@ typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
143 143
144int generic_writepages(struct address_space *mapping, 144int generic_writepages(struct address_space *mapping,
145 struct writeback_control *wbc); 145 struct writeback_control *wbc);
146void tag_pages_for_writeback(struct address_space *mapping,
147 pgoff_t start, pgoff_t end);
146int write_cache_pages(struct address_space *mapping, 148int write_cache_pages(struct address_space *mapping,
147 struct writeback_control *wbc, writepage_t writepage, 149 struct writeback_control *wbc, writepage_t writepage,
148 void *data); 150 void *data);
149int do_writepages(struct address_space *mapping, struct writeback_control *wbc); 151int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
150void set_page_dirty_balance(struct page *page, int page_mkwrite); 152void set_page_dirty_balance(struct page *page, int page_mkwrite);
151void writeback_set_ratelimit(void); 153void writeback_set_ratelimit(void);
154void tag_pages_for_writeback(struct address_space *mapping,
155 pgoff_t start, pgoff_t end);
152 156
153/* pdflush.c */ 157/* pdflush.c */
154extern int nr_pdflush_threads; /* Global so it can be exported to sysctl 158extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index f1e5bde4b35a..aed54c50aa66 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -13,10 +13,6 @@
13#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ 13#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
14#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ 14#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
15 15
16#ifdef __KERNEL__
17
18#include <linux/types.h>
19
20/* Namespaces */ 16/* Namespaces */
21#define XATTR_OS2_PREFIX "os2." 17#define XATTR_OS2_PREFIX "os2."
22#define XATTR_OS2_PREFIX_LEN (sizeof (XATTR_OS2_PREFIX) - 1) 18#define XATTR_OS2_PREFIX_LEN (sizeof (XATTR_OS2_PREFIX) - 1)
@@ -40,13 +36,23 @@
40#define XATTR_SMACK_SUFFIX "SMACK64" 36#define XATTR_SMACK_SUFFIX "SMACK64"
41#define XATTR_SMACK_IPIN "SMACK64IPIN" 37#define XATTR_SMACK_IPIN "SMACK64IPIN"
42#define XATTR_SMACK_IPOUT "SMACK64IPOUT" 38#define XATTR_SMACK_IPOUT "SMACK64IPOUT"
39#define XATTR_SMACK_EXEC "SMACK64EXEC"
40#define XATTR_SMACK_TRANSMUTE "SMACK64TRANSMUTE"
41#define XATTR_SMACK_MMAP "SMACK64MMAP"
43#define XATTR_NAME_SMACK XATTR_SECURITY_PREFIX XATTR_SMACK_SUFFIX 42#define XATTR_NAME_SMACK XATTR_SECURITY_PREFIX XATTR_SMACK_SUFFIX
44#define XATTR_NAME_SMACKIPIN XATTR_SECURITY_PREFIX XATTR_SMACK_IPIN 43#define XATTR_NAME_SMACKIPIN XATTR_SECURITY_PREFIX XATTR_SMACK_IPIN
45#define XATTR_NAME_SMACKIPOUT XATTR_SECURITY_PREFIX XATTR_SMACK_IPOUT 44#define XATTR_NAME_SMACKIPOUT XATTR_SECURITY_PREFIX XATTR_SMACK_IPOUT
45#define XATTR_NAME_SMACKEXEC XATTR_SECURITY_PREFIX XATTR_SMACK_EXEC
46#define XATTR_NAME_SMACKTRANSMUTE XATTR_SECURITY_PREFIX XATTR_SMACK_TRANSMUTE
47#define XATTR_NAME_SMACKMMAP XATTR_SECURITY_PREFIX XATTR_SMACK_MMAP
46 48
47#define XATTR_CAPS_SUFFIX "capability" 49#define XATTR_CAPS_SUFFIX "capability"
48#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX 50#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX
49 51
52#ifdef __KERNEL__
53
54#include <linux/types.h>
55
50struct inode; 56struct inode;
51struct dentry; 57struct dentry;
52 58
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index b971e3848493..22e61fdf75a2 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -84,6 +84,16 @@ struct xfrm_replay_state {
84 __u32 bitmap; 84 __u32 bitmap;
85}; 85};
86 86
87struct xfrm_replay_state_esn {
88 unsigned int bmp_len;
89 __u32 oseq;
90 __u32 seq;
91 __u32 oseq_hi;
92 __u32 seq_hi;
93 __u32 replay_window;
94 __u32 bmp[0];
95};
96
87struct xfrm_algo { 97struct xfrm_algo {
88 char alg_name[64]; 98 char alg_name[64];
89 unsigned int alg_key_len; /* in bits */ 99 unsigned int alg_key_len; /* in bits */
@@ -283,6 +293,8 @@ enum xfrm_attr_type_t {
283 XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */ 293 XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */
284 XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */ 294 XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */
285 XFRMA_MARK, /* struct xfrm_mark */ 295 XFRMA_MARK, /* struct xfrm_mark */
296 XFRMA_TFCPAD, /* __u32 */
297 XFRMA_REPLAY_ESN_VAL, /* struct xfrm_replay_esn */
286 __XFRMA_MAX 298 __XFRMA_MAX
287 299
288#define XFRMA_MAX (__XFRMA_MAX - 1) 300#define XFRMA_MAX (__XFRMA_MAX - 1)
@@ -349,6 +361,8 @@ struct xfrm_usersa_info {
349#define XFRM_STATE_WILDRECV 8 361#define XFRM_STATE_WILDRECV 8
350#define XFRM_STATE_ICMP 16 362#define XFRM_STATE_ICMP 16
351#define XFRM_STATE_AF_UNSPEC 32 363#define XFRM_STATE_AF_UNSPEC 32
364#define XFRM_STATE_ALIGN4 64
365#define XFRM_STATE_ESN 128
352}; 366};
353 367
354struct xfrm_usersa_id { 368struct xfrm_usersa_id {
diff --git a/include/linux/xilinxfb.h b/include/linux/xilinxfb.h
index f2463f559fb9..5a155a968054 100644
--- a/include/linux/xilinxfb.h
+++ b/include/linux/xilinxfb.h
@@ -16,7 +16,7 @@
16/* ML300/403 reference design framebuffer driver platform data struct */ 16/* ML300/403 reference design framebuffer driver platform data struct */
17struct xilinxfb_platform_data { 17struct xilinxfb_platform_data {
18 u32 rotate_screen; /* Flag to rotate display 180 degrees */ 18 u32 rotate_screen; /* Flag to rotate display 180 degrees */
19 u32 screen_height_mm; /* Physical dimentions of screen in mm */ 19 u32 screen_height_mm; /* Physical dimensions of screen in mm */
20 u32 screen_width_mm; 20 u32 screen_width_mm;
21 u32 xres, yres; /* resolution of screen in pixels */ 21 u32 xres, yres; /* resolution of screen in pixels */
22 u32 xvirt, yvirt; /* resolution of memory buffer */ 22 u32 xvirt, yvirt; /* resolution of memory buffer */
diff --git a/include/linux/xz.h b/include/linux/xz.h
new file mode 100644
index 000000000000..64cffa6ddfce
--- /dev/null
+++ b/include/linux/xz.h
@@ -0,0 +1,264 @@
1/*
2 * XZ decompressor
3 *
4 * Authors: Lasse Collin <lasse.collin@tukaani.org>
5 * Igor Pavlov <http://7-zip.org/>
6 *
7 * This file has been put into the public domain.
8 * You can do whatever you want with this file.
9 */
10
11#ifndef XZ_H
12#define XZ_H
13
14#ifdef __KERNEL__
15# include <linux/stddef.h>
16# include <linux/types.h>
17#else
18# include <stddef.h>
19# include <stdint.h>
20#endif
21
22/* In Linux, this is used to make extern functions static when needed. */
23#ifndef XZ_EXTERN
24# define XZ_EXTERN extern
25#endif
26
27/**
28 * enum xz_mode - Operation mode
29 *
30 * @XZ_SINGLE: Single-call mode. This uses less RAM than
31 * than multi-call modes, because the LZMA2
32 * dictionary doesn't need to be allocated as
33 * part of the decoder state. All required data
34 * structures are allocated at initialization,
35 * so xz_dec_run() cannot return XZ_MEM_ERROR.
36 * @XZ_PREALLOC: Multi-call mode with preallocated LZMA2
37 * dictionary buffer. All data structures are
38 * allocated at initialization, so xz_dec_run()
39 * cannot return XZ_MEM_ERROR.
40 * @XZ_DYNALLOC: Multi-call mode. The LZMA2 dictionary is
41 * allocated once the required size has been
42 * parsed from the stream headers. If the
43 * allocation fails, xz_dec_run() will return
44 * XZ_MEM_ERROR.
45 *
46 * It is possible to enable support only for a subset of the above
47 * modes at compile time by defining XZ_DEC_SINGLE, XZ_DEC_PREALLOC,
48 * or XZ_DEC_DYNALLOC. The xz_dec kernel module is always compiled
49 * with support for all operation modes, but the preboot code may
50 * be built with fewer features to minimize code size.
51 */
52enum xz_mode {
53 XZ_SINGLE,
54 XZ_PREALLOC,
55 XZ_DYNALLOC
56};
57
58/**
59 * enum xz_ret - Return codes
60 * @XZ_OK: Everything is OK so far. More input or more
61 * output space is required to continue. This
62 * return code is possible only in multi-call mode
63 * (XZ_PREALLOC or XZ_DYNALLOC).
64 * @XZ_STREAM_END: Operation finished successfully.
65 * @XZ_UNSUPPORTED_CHECK: Integrity check type is not supported. Decoding
66 * is still possible in multi-call mode by simply
67 * calling xz_dec_run() again.
68 * Note that this return value is used only if
69 * XZ_DEC_ANY_CHECK was defined at build time,
70 * which is not used in the kernel. Unsupported
71 * check types return XZ_OPTIONS_ERROR if
72 * XZ_DEC_ANY_CHECK was not defined at build time.
73 * @XZ_MEM_ERROR: Allocating memory failed. This return code is
74 * possible only if the decoder was initialized
75 * with XZ_DYNALLOC. The amount of memory that was
76 * tried to be allocated was no more than the
77 * dict_max argument given to xz_dec_init().
78 * @XZ_MEMLIMIT_ERROR: A bigger LZMA2 dictionary would be needed than
79 * allowed by the dict_max argument given to
80 * xz_dec_init(). This return value is possible
81 * only in multi-call mode (XZ_PREALLOC or
82 * XZ_DYNALLOC); the single-call mode (XZ_SINGLE)
83 * ignores the dict_max argument.
84 * @XZ_FORMAT_ERROR: File format was not recognized (wrong magic
85 * bytes).
86 * @XZ_OPTIONS_ERROR: This implementation doesn't support the requested
87 * compression options. In the decoder this means
88 * that the header CRC32 matches, but the header
89 * itself specifies something that we don't support.
90 * @XZ_DATA_ERROR: Compressed data is corrupt.
91 * @XZ_BUF_ERROR: Cannot make any progress. Details are slightly
92 * different between multi-call and single-call
93 * mode; more information below.
94 *
95 * In multi-call mode, XZ_BUF_ERROR is returned when two consecutive calls
96 * to XZ code cannot consume any input and cannot produce any new output.
97 * This happens when there is no new input available, or the output buffer
98 * is full while at least one output byte is still pending. Assuming your
99 * code is not buggy, you can get this error only when decoding a compressed
100 * stream that is truncated or otherwise corrupt.
101 *
102 * In single-call mode, XZ_BUF_ERROR is returned only when the output buffer
103 * is too small or the compressed input is corrupt in a way that makes the
104 * decoder produce more output than the caller expected. When it is
105 * (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR
106 * is used instead of XZ_BUF_ERROR.
107 */
108enum xz_ret {
109 XZ_OK,
110 XZ_STREAM_END,
111 XZ_UNSUPPORTED_CHECK,
112 XZ_MEM_ERROR,
113 XZ_MEMLIMIT_ERROR,
114 XZ_FORMAT_ERROR,
115 XZ_OPTIONS_ERROR,
116 XZ_DATA_ERROR,
117 XZ_BUF_ERROR
118};
119
120/**
121 * struct xz_buf - Passing input and output buffers to XZ code
122 * @in: Beginning of the input buffer. This may be NULL if and only
123 * if in_pos is equal to in_size.
124 * @in_pos: Current position in the input buffer. This must not exceed
125 * in_size.
126 * @in_size: Size of the input buffer
127 * @out: Beginning of the output buffer. This may be NULL if and only
128 * if out_pos is equal to out_size.
129 * @out_pos: Current position in the output buffer. This must not exceed
130 * out_size.
131 * @out_size: Size of the output buffer
132 *
133 * Only the contents of the output buffer from out[out_pos] onward, and
134 * the variables in_pos and out_pos are modified by the XZ code.
135 */
136struct xz_buf {
137 const uint8_t *in;
138 size_t in_pos;
139 size_t in_size;
140
141 uint8_t *out;
142 size_t out_pos;
143 size_t out_size;
144};
145
146/**
147 * struct xz_dec - Opaque type to hold the XZ decoder state
148 */
149struct xz_dec;
150
151/**
152 * xz_dec_init() - Allocate and initialize a XZ decoder state
153 * @mode: Operation mode
154 * @dict_max: Maximum size of the LZMA2 dictionary (history buffer) for
155 * multi-call decoding. This is ignored in single-call mode
156 * (mode == XZ_SINGLE). LZMA2 dictionary is always 2^n bytes
157 * or 2^n + 2^(n-1) bytes (the latter sizes are less common
158 * in practice), so other values for dict_max don't make sense.
159 * In the kernel, dictionary sizes of 64 KiB, 128 KiB, 256 KiB,
160 * 512 KiB, and 1 MiB are probably the only reasonable values,
161 * except for kernel and initramfs images where a bigger
162 * dictionary can be fine and useful.
163 *
164 * Single-call mode (XZ_SINGLE): xz_dec_run() decodes the whole stream at
165 * once. The caller must provide enough output space or the decoding will
166 * fail. The output space is used as the dictionary buffer, which is why
167 * there is no need to allocate the dictionary as part of the decoder's
168 * internal state.
169 *
170 * Because the output buffer is used as the workspace, streams encoded using
171 * a big dictionary are not a problem in single-call mode. It is enough that
172 * the output buffer is big enough to hold the actual uncompressed data; it
173 * can be smaller than the dictionary size stored in the stream headers.
174 *
175 * Multi-call mode with preallocated dictionary (XZ_PREALLOC): dict_max bytes
176 * of memory is preallocated for the LZMA2 dictionary. This way there is no
177 * risk that xz_dec_run() could run out of memory, since xz_dec_run() will
178 * never allocate any memory. Instead, if the preallocated dictionary is too
179 * small for decoding the given input stream, xz_dec_run() will return
180 * XZ_MEMLIMIT_ERROR. Thus, it is important to know what kind of data will be
181 * decoded to avoid allocating excessive amount of memory for the dictionary.
182 *
183 * Multi-call mode with dynamically allocated dictionary (XZ_DYNALLOC):
184 * dict_max specifies the maximum allowed dictionary size that xz_dec_run()
185 * may allocate once it has parsed the dictionary size from the stream
186 * headers. This way excessive allocations can be avoided while still
187 * limiting the maximum memory usage to a sane value to prevent running the
188 * system out of memory when decompressing streams from untrusted sources.
189 *
190 * On success, xz_dec_init() returns a pointer to struct xz_dec, which is
191 * ready to be used with xz_dec_run(). If memory allocation fails,
192 * xz_dec_init() returns NULL.
193 */
194XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max);
195
196/**
197 * xz_dec_run() - Run the XZ decoder
198 * @s: Decoder state allocated using xz_dec_init()
199 * @b: Input and output buffers
200 *
201 * The possible return values depend on build options and operation mode.
202 * See enum xz_ret for details.
203 *
204 * Note that if an error occurs in single-call mode (return value is not
205 * XZ_STREAM_END), b->in_pos and b->out_pos are not modified and the
206 * contents of the output buffer from b->out[b->out_pos] onward are
207 * undefined. This is true even after XZ_BUF_ERROR, because with some filter
208 * chains, there may be a second pass over the output buffer, and this pass
209 * cannot be properly done if the output buffer is truncated. Thus, you
210 * cannot give the single-call decoder a too small buffer and then expect to
211 * get that amount valid data from the beginning of the stream. You must use
212 * the multi-call decoder if you don't want to uncompress the whole stream.
213 */
214XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b);
215
216/**
217 * xz_dec_reset() - Reset an already allocated decoder state
218 * @s: Decoder state allocated using xz_dec_init()
219 *
220 * This function can be used to reset the multi-call decoder state without
221 * freeing and reallocating memory with xz_dec_end() and xz_dec_init().
222 *
223 * In single-call mode, xz_dec_reset() is always called in the beginning of
224 * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in
225 * multi-call mode.
226 */
227XZ_EXTERN void xz_dec_reset(struct xz_dec *s);
228
229/**
230 * xz_dec_end() - Free the memory allocated for the decoder state
231 * @s: Decoder state allocated using xz_dec_init(). If s is NULL,
232 * this function does nothing.
233 */
234XZ_EXTERN void xz_dec_end(struct xz_dec *s);
235
236/*
237 * Standalone build (userspace build or in-kernel build for boot time use)
238 * needs a CRC32 implementation. For normal in-kernel use, kernel's own
239 * CRC32 module is used instead, and users of this module don't need to
240 * care about the functions below.
241 */
242#ifndef XZ_INTERNAL_CRC32
243# ifdef __KERNEL__
244# define XZ_INTERNAL_CRC32 0
245# else
246# define XZ_INTERNAL_CRC32 1
247# endif
248#endif
249
250#if XZ_INTERNAL_CRC32
251/*
252 * This must be called before any other xz_* function to initialize
253 * the CRC32 lookup table.
254 */
255XZ_EXTERN void xz_crc32_init(void);
256
257/*
258 * Update CRC32 value using the polynomial from IEEE-802.3. To start a new
259 * calculation, the third argument must be zero. To continue the calculation,
260 * the previously returned value is passed as the third argument.
261 */
262XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc);
263#endif
264#endif
diff --git a/include/linux/zlib.h b/include/linux/zlib.h
index 40c49cb3eb51..9c5a6b4de0a3 100644
--- a/include/linux/zlib.h
+++ b/include/linux/zlib.h
@@ -179,11 +179,16 @@ typedef z_stream *z_streamp;
179 179
180 /* basic functions */ 180 /* basic functions */
181 181
182extern int zlib_deflate_workspacesize (void); 182extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
183/* 183/*
184 Returns the number of bytes that needs to be allocated for a per- 184 Returns the number of bytes that needs to be allocated for a per-
185 stream workspace. A pointer to this number of bytes should be 185 stream workspace with the specified parameters. A pointer to this
186 returned in stream->workspace before calling zlib_deflateInit(). 186 number of bytes should be returned in stream->workspace before
187 you call zlib_deflateInit() or zlib_deflateInit2(). If you call
188 zlib_deflateInit(), specify windowBits = MAX_WBITS and memLevel =
189 MAX_MEM_LEVEL here. If you call zlib_deflateInit2(), the windowBits
190 and memLevel parameters passed to zlib_deflateInit2() must not
191 exceed those passed here.
187*/ 192*/
188 193
189/* 194/*
diff --git a/include/media/bt819.h b/include/media/bt819.h
index 38f666bde77a..8025f4bc2bb6 100644
--- a/include/media/bt819.h
+++ b/include/media/bt819.h
@@ -26,7 +26,10 @@
26/* v4l2_device notifications. */ 26/* v4l2_device notifications. */
27 27
28/* Needed to reset the FIFO buffer when changing the input 28/* Needed to reset the FIFO buffer when changing the input
29 or the video standard. */ 29 or the video standard.
30
31 Note: these ioctls that internal to the kernel and are never called
32 from userspace. */
30#define BT819_FIFO_RESET_LOW _IO('b', 0) 33#define BT819_FIFO_RESET_LOW _IO('b', 0)
31#define BT819_FIFO_RESET_HIGH _IO('b', 1) 34#define BT819_FIFO_RESET_HIGH _IO('b', 1)
32 35
diff --git a/include/media/cx2341x.h b/include/media/cx2341x.h
index 8d08ebfe20b7..9635eebaab09 100644
--- a/include/media/cx2341x.h
+++ b/include/media/cx2341x.h
@@ -95,7 +95,7 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
95 const struct cx2341x_mpeg_params *new); 95 const struct cx2341x_mpeg_params *new);
96int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params, 96int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params,
97 struct v4l2_queryctrl *qctrl); 97 struct v4l2_queryctrl *qctrl);
98const char **cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id); 98const char * const *cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id);
99int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, 99int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy,
100 struct v4l2_ext_controls *ctrls, unsigned int cmd); 100 struct v4l2_ext_controls *ctrls, unsigned int cmd);
101void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p); 101void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p);
diff --git a/include/media/davinci/dm355_ccdc.h b/include/media/davinci/dm355_ccdc.h
index df8a7b107477..adf2fe4bf0bb 100644
--- a/include/media/davinci/dm355_ccdc.h
+++ b/include/media/davinci/dm355_ccdc.h
@@ -193,7 +193,7 @@ struct ccdc_dft_corr_mem_ctl {
193#define CCDC_DFT_TABLE_SIZE 16 193#define CCDC_DFT_TABLE_SIZE 16
194/* 194/*
195 * Main Structure for vertical defect correction. Vertical defect 195 * Main Structure for vertical defect correction. Vertical defect
196 * correction can correct upto 16 defects if defects less than 16 196 * correction can correct up to 16 defects if defects less than 16
197 * then pad the rest with 0 197 * then pad the rest with 0
198 */ 198 */
199struct ccdc_vertical_dft { 199struct ccdc_vertical_dft {
diff --git a/include/media/davinci/isif.h b/include/media/davinci/isif.h
index b0b74ad618cc..7f3d76a4b9e3 100644
--- a/include/media/davinci/isif.h
+++ b/include/media/davinci/isif.h
@@ -199,7 +199,7 @@ struct isif_black_clamp {
199}; 199};
200 200
201/************************************************************************* 201/*************************************************************************
202** Color Space Convertion (CSC) 202** Color Space Conversion (CSC)
203*************************************************************************/ 203*************************************************************************/
204#define ISIF_CSC_NUM_COEFF 16 204#define ISIF_CSC_NUM_COEFF 16
205struct isif_color_space_conv { 205struct isif_color_space_conv {
diff --git a/include/media/davinci/vpss.h b/include/media/davinci/vpss.h
index c59cc029c74a..b586495bcd53 100644
--- a/include/media/davinci/vpss.h
+++ b/include/media/davinci/vpss.h
@@ -44,7 +44,7 @@ struct vpss_pg_frame_size {
44 short pplen; 44 short pplen;
45}; 45};
46 46
47/* Used for enable/diable VPSS Clock */ 47/* Used for enable/disable VPSS Clock */
48enum vpss_clock_sel { 48enum vpss_clock_sel {
49 /* DM355/DM365 */ 49 /* DM355/DM365 */
50 VPSS_CCDC_CLOCK, 50 VPSS_CCDC_CLOCK,
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
deleted file mode 100644
index 528050e39ad9..000000000000
--- a/include/media/ir-common.h
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 *
3 * some common structs and functions to handle infrared remotes via
4 * input layer ...
5 *
6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef _IR_COMMON
24#define _IR_COMMON
25
26#include <linux/input.h>
27#include <linux/workqueue.h>
28#include <linux/interrupt.h>
29#include <media/ir-core.h>
30
31#define RC5_START(x) (((x)>>12)&3)
32#define RC5_TOGGLE(x) (((x)>>11)&1)
33#define RC5_ADDR(x) (((x)>>6)&31)
34#define RC5_INSTR(x) ((x)&63)
35
36struct ir_input_state {
37 /* configuration */
38 u64 ir_type;
39
40 /* key info */
41 u32 ir_key; /* ir scancode */
42 u32 keycode; /* linux key code */
43 int keypressed; /* current state */
44};
45
46/* this was saa7134_ir and bttv_ir, moved here for
47 * rc5 decoding. */
48struct card_ir {
49 struct input_dev *dev;
50 struct ir_input_state ir;
51 char name[32];
52 char phys[32];
53 int users;
54
55 u32 running:1;
56 struct ir_dev_props props;
57
58 /* Usual gpio signalling */
59
60 u32 mask_keycode;
61 u32 mask_keydown;
62 u32 mask_keyup;
63 u32 polling;
64 u32 last_gpio;
65 int shift_by;
66 int start; // What should RC5_START() be
67 int addr; // What RC5_ADDR() should be.
68 int rc5_key_timeout;
69 int rc5_remote_gap;
70 struct work_struct work;
71 struct timer_list timer;
72
73 /* RC5 gpio */
74 u32 rc5_gpio;
75 struct timer_list timer_end; /* timer_end for code completion */
76 struct timer_list timer_keyup; /* timer_end for key release */
77 u32 last_rc5; /* last good rc5 code */
78 u32 last_bit; /* last raw bit seen */
79 u32 code; /* raw code under construction */
80 struct timeval base_time; /* time of last seen code */
81 int active; /* building raw code */
82
83 /* NEC decoding */
84 u32 nec_gpio;
85 struct tasklet_struct tlet;
86
87 /* IR core raw decoding */
88 u32 raw_decode;
89};
90
91/* Routines from ir-functions.c */
92
93int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
94 const u64 ir_type);
95void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
96void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
97 u32 ir_key);
98u32 ir_extract_bits(u32 data, u32 mask);
99int ir_dump_samples(u32 *samples, int count);
100int ir_decode_biphase(u32 *samples, int count, int low, int high);
101int ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
102u32 ir_rc5_decode(unsigned int code);
103
104void ir_rc5_timer_end(unsigned long data);
105void ir_rc5_timer_keyup(unsigned long data);
106
107#endif
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
deleted file mode 100644
index eb7fddf8f607..000000000000
--- a/include/media/ir-core.h
+++ /dev/null
@@ -1,185 +0,0 @@
1/*
2 * Remote Controller core header
3 *
4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _IR_CORE
17#define _IR_CORE
18
19#include <linux/spinlock.h>
20#include <linux/kfifo.h>
21#include <linux/time.h>
22#include <linux/timer.h>
23#include <media/rc-map.h>
24
25extern int ir_core_debug;
26#define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \
27 printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
28
29enum rc_driver_type {
30 RC_DRIVER_SCANCODE = 0, /* Driver or hardware generates a scancode */
31 RC_DRIVER_IR_RAW, /* Needs a Infra-Red pulse/space decoder */
32};
33
34/**
35 * struct ir_dev_props - Allow caller drivers to set special properties
36 * @driver_type: specifies if the driver or hardware have already a decoder,
37 * or if it needs to use the IR raw event decoders to produce a scancode
38 * @allowed_protos: bitmask with the supported IR_TYPE_* protocols
39 * @scanmask: some hardware decoders are not capable of providing the full
40 * scancode to the application. As this is a hardware limit, we can't do
41 * anything with it. Yet, as the same keycode table can be used with other
42 * devices, a mask is provided to allow its usage. Drivers should generally
43 * leave this field in blank
44 * @timeout: optional time after which device stops sending data
45 * @min_timeout: minimum timeout supported by device
46 * @max_timeout: maximum timeout supported by device
47 * @rx_resolution : resolution (in ns) of input sampler
48 * @tx_resolution: resolution (in ns) of output sampler
49 * @priv: driver-specific data, to be used on the callbacks
50 * @change_protocol: allow changing the protocol used on hardware decoders
51 * @open: callback to allow drivers to enable polling/irq when IR input device
52 * is opened.
53 * @close: callback to allow drivers to disable polling/irq when IR input device
54 * is opened.
55 * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs)
56 * @s_tx_carrier: set transmit carrier frequency
57 * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%)
58 * @s_rx_carrier: inform driver about carrier it is expected to handle
59 * @tx_ir: transmit IR
60 * @s_idle: optional: enable/disable hardware idle mode, upon which,
61 device doesn't interrupt host until it sees IR pulses
62 * @s_learning_mode: enable wide band receiver used for learning
63 */
64struct ir_dev_props {
65 enum rc_driver_type driver_type;
66 unsigned long allowed_protos;
67 u32 scanmask;
68
69 u32 timeout;
70 u32 min_timeout;
71 u32 max_timeout;
72
73 u32 rx_resolution;
74 u32 tx_resolution;
75
76 void *priv;
77 int (*change_protocol)(void *priv, u64 ir_type);
78 int (*open)(void *priv);
79 void (*close)(void *priv);
80 int (*s_tx_mask)(void *priv, u32 mask);
81 int (*s_tx_carrier)(void *priv, u32 carrier);
82 int (*s_tx_duty_cycle)(void *priv, u32 duty_cycle);
83 int (*s_rx_carrier_range)(void *priv, u32 min, u32 max);
84 int (*tx_ir)(void *priv, int *txbuf, u32 n);
85 void (*s_idle)(void *priv, int enable);
86 int (*s_learning_mode)(void *priv, int enable);
87};
88
89struct ir_input_dev {
90 struct device dev; /* device */
91 char *driver_name; /* Name of the driver module */
92 struct ir_scancode_table rc_tab; /* scan/key table */
93 unsigned long devno; /* device number */
94 struct ir_dev_props *props; /* Device properties */
95 struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */
96 struct input_dev *input_dev; /* the input device associated with this device */
97 bool idle;
98
99 /* key info - needed by IR keycode handlers */
100 spinlock_t keylock; /* protects the below members */
101 bool keypressed; /* current state */
102 unsigned long keyup_jiffies; /* when should the current keypress be released? */
103 struct timer_list timer_keyup; /* timer for releasing a keypress */
104 u32 last_keycode; /* keycode of last command */
105 u32 last_scancode; /* scancode of last command */
106 u8 last_toggle; /* toggle of last command */
107};
108
109enum raw_event_type {
110 IR_SPACE = (1 << 0),
111 IR_PULSE = (1 << 1),
112 IR_START_EVENT = (1 << 2),
113 IR_STOP_EVENT = (1 << 3),
114};
115
116#define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr)
117
118/* From ir-keytable.c */
119int __ir_input_register(struct input_dev *dev,
120 const struct ir_scancode_table *ir_codes,
121 struct ir_dev_props *props,
122 const char *driver_name);
123
124static inline int ir_input_register(struct input_dev *dev,
125 const char *map_name,
126 struct ir_dev_props *props,
127 const char *driver_name) {
128 struct ir_scancode_table *ir_codes;
129 struct ir_input_dev *ir_dev;
130 int rc;
131
132 if (!map_name)
133 return -EINVAL;
134
135 ir_codes = get_rc_map(map_name);
136 if (!ir_codes) {
137 ir_codes = get_rc_map(RC_MAP_EMPTY);
138
139 if (!ir_codes)
140 return -EINVAL;
141 }
142
143 rc = __ir_input_register(dev, ir_codes, props, driver_name);
144 if (rc < 0)
145 return -EINVAL;
146
147 ir_dev = input_get_drvdata(dev);
148
149 if (!rc && ir_dev->props && ir_dev->props->change_protocol)
150 rc = ir_dev->props->change_protocol(ir_dev->props->priv,
151 ir_codes->ir_type);
152
153 return rc;
154}
155
156void ir_input_unregister(struct input_dev *input_dev);
157
158void ir_repeat(struct input_dev *dev);
159void ir_keydown(struct input_dev *dev, int scancode, u8 toggle);
160u32 ir_g_keycode_from_table(struct input_dev *input_dev, u32 scancode);
161
162/* From ir-raw-event.c */
163
164struct ir_raw_event {
165 unsigned pulse:1;
166 unsigned duration:31;
167};
168
169#define IR_MAX_DURATION 0x7FFFFFFF /* a bit more than 2 seconds */
170
171void ir_raw_event_handle(struct input_dev *input_dev);
172int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev);
173int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type);
174int ir_raw_event_store_with_filter(struct input_dev *input_dev,
175 struct ir_raw_event *ev);
176void ir_raw_event_set_idle(struct input_dev *input_dev, int idle);
177
178static inline void ir_raw_event_reset(struct input_dev *input_dev)
179{
180 struct ir_raw_event ev = { .pulse = false, .duration = 0 };
181 ir_raw_event_store(input_dev, &ev);
182 ir_raw_event_handle(input_dev);
183}
184
185#endif /* _IR_CORE */
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 5e96d7a430be..768aa77925cd 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -1,20 +1,22 @@
1#ifndef _IR_I2C 1#ifndef _IR_I2C
2#define _IR_I2C 2#define _IR_I2C
3 3
4#include <media/ir-common.h> 4#include <media/rc-core.h>
5
6#define DEFAULT_POLLING_INTERVAL 100 /* ms */
5 7
6struct IR_i2c; 8struct IR_i2c;
7 9
8struct IR_i2c { 10struct IR_i2c {
9 char *ir_codes; 11 char *ir_codes;
10
11 struct i2c_client *c; 12 struct i2c_client *c;
12 struct input_dev *input; 13 struct rc_dev *rc;
13 struct ir_input_state ir; 14
14 u64 ir_type;
15 /* Used to avoid fast repeating */ 15 /* Used to avoid fast repeating */
16 unsigned char old; 16 unsigned char old;
17 17
18 u32 polling_interval; /* in ms */
19
18 struct delayed_work work; 20 struct delayed_work work;
19 char name[32]; 21 char name[32];
20 char phys[32]; 22 char phys[32];
@@ -24,7 +26,6 @@ struct IR_i2c {
24enum ir_kbd_get_key_fn { 26enum ir_kbd_get_key_fn {
25 IR_KBD_GET_KEY_CUSTOM = 0, 27 IR_KBD_GET_KEY_CUSTOM = 0,
26 IR_KBD_GET_KEY_PIXELVIEW, 28 IR_KBD_GET_KEY_PIXELVIEW,
27 IR_KBD_GET_KEY_PV951,
28 IR_KBD_GET_KEY_HAUP, 29 IR_KBD_GET_KEY_HAUP,
29 IR_KBD_GET_KEY_KNC1, 30 IR_KBD_GET_KEY_KNC1,
30 IR_KBD_GET_KEY_FUSIONHDTV, 31 IR_KBD_GET_KEY_FUSIONHDTV,
@@ -35,13 +36,17 @@ enum ir_kbd_get_key_fn {
35/* Can be passed when instantiating an ir_video i2c device */ 36/* Can be passed when instantiating an ir_video i2c device */
36struct IR_i2c_init_data { 37struct IR_i2c_init_data {
37 char *ir_codes; 38 char *ir_codes;
38 const char *name; 39 const char *name;
39 u64 type; /* IR_TYPE_RC5, etc */ 40 u64 type; /* RC_TYPE_RC5, etc */
41 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */
42
40 /* 43 /*
41 * Specify either a function pointer or a value indicating one of 44 * Specify either a function pointer or a value indicating one of
42 * ir_kbd_i2c's internal get_key functions 45 * ir_kbd_i2c's internal get_key functions
43 */ 46 */
44 int (*get_key)(struct IR_i2c*, u32*, u32*); 47 int (*get_key)(struct IR_i2c*, u32*, u32*);
45 enum ir_kbd_get_key_fn internal_get_key_func; 48 enum ir_kbd_get_key_fn internal_get_key_func;
49
50 struct rc_dev *rc_dev;
46}; 51};
47#endif 52#endif
diff --git a/include/media/lirc.h b/include/media/lirc.h
index 6678a169fd9e..4b3ab2966b5a 100644
--- a/include/media/lirc.h
+++ b/include/media/lirc.h
@@ -137,7 +137,7 @@
137 */ 137 */
138#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, __u32) 138#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, __u32)
139/* 139/*
140 * if filter cannot be set independantly for pulse/space, this should 140 * if filter cannot be set independently for pulse/space, this should
141 * be used 141 * be used
142 */ 142 */
143#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, __u32) 143#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, __u32)
diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h
index b1f60663cb39..168dd0b1bae2 100644
--- a/include/media/lirc_dev.h
+++ b/include/media/lirc_dev.h
@@ -9,7 +9,7 @@
9#ifndef _LINUX_LIRC_DEV_H 9#ifndef _LINUX_LIRC_DEV_H
10#define _LINUX_LIRC_DEV_H 10#define _LINUX_LIRC_DEV_H
11 11
12#define MAX_IRCTL_DEVICES 4 12#define MAX_IRCTL_DEVICES 8
13#define BUFLEN 16 13#define BUFLEN 16
14 14
15#define mod(n, div) ((n) % (div)) 15#define mod(n, div) ((n) % (div))
@@ -125,10 +125,10 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf,
125struct lirc_driver { 125struct lirc_driver {
126 char name[40]; 126 char name[40];
127 int minor; 127 int minor;
128 unsigned long code_length; 128 __u32 code_length;
129 unsigned int buffer_size; /* in chunks holding one code each */ 129 unsigned int buffer_size; /* in chunks holding one code each */
130 int sample_rate; 130 int sample_rate;
131 unsigned long features; 131 __u32 features;
132 132
133 unsigned int chunk_size; 133 unsigned int chunk_size;
134 134
@@ -139,7 +139,7 @@ struct lirc_driver {
139 struct lirc_buffer *rbuf; 139 struct lirc_buffer *rbuf;
140 int (*set_use_inc) (void *data); 140 int (*set_use_inc) (void *data);
141 void (*set_use_dec) (void *data); 141 void (*set_use_dec) (void *data);
142 struct file_operations *fops; 142 const struct file_operations *fops;
143 struct device *dev; 143 struct device *dev;
144 struct module *owner; 144 struct module *owner;
145}; 145};
@@ -217,9 +217,9 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file);
217int lirc_dev_fop_close(struct inode *inode, struct file *file); 217int lirc_dev_fop_close(struct inode *inode, struct file *file);
218unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait); 218unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait);
219long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 219long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
220ssize_t lirc_dev_fop_read(struct file *file, char *buffer, size_t length, 220ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length,
221 loff_t *ppos); 221 loff_t *ppos);
222ssize_t lirc_dev_fop_write(struct file *file, const char *buffer, size_t length, 222ssize_t lirc_dev_fop_write(struct file *file, const char __user *buffer,
223 loff_t *ppos); 223 size_t length, loff_t *ppos);
224 224
225#endif 225#endif
diff --git a/include/media/m5mols.h b/include/media/m5mols.h
new file mode 100644
index 000000000000..aac2c0e06d5e
--- /dev/null
+++ b/include/media/m5mols.h
@@ -0,0 +1,35 @@
1/*
2 * Driver header for M-5MOLS 8M Pixel camera sensor with ISP
3 *
4 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5 * Author: HeungJun Kim <riverful.kim@samsung.com>
6 *
7 * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef MEDIA_M5MOLS_H
17#define MEDIA_M5MOLS_H
18
19/**
20 * struct m5mols_platform_data - platform data for M-5MOLS driver
21 * @irq: GPIO getting the irq pin of M-5MOLS
22 * @gpio_reset: GPIO driving the reset pin of M-5MOLS
23 * @reset_polarity: active state for gpio_rst pin, 0 or 1
24 * @set_power: an additional callback to the board setup code
25 * to be called after enabling and before disabling
26 * the sensor's supply regulators
27 */
28struct m5mols_platform_data {
29 int irq;
30 int gpio_reset;
31 u8 reset_polarity;
32 int (*set_power)(struct device *dev, int on);
33};
34
35#endif /* MEDIA_M5MOLS_H */
diff --git a/include/media/media-device.h b/include/media/media-device.h
new file mode 100644
index 000000000000..6a27d916c250
--- /dev/null
+++ b/include/media/media-device.h
@@ -0,0 +1,95 @@
1/*
2 * Media device
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef _MEDIA_DEVICE_H
24#define _MEDIA_DEVICE_H
25
26#include <linux/device.h>
27#include <linux/list.h>
28#include <linux/mutex.h>
29#include <linux/spinlock.h>
30
31#include <media/media-devnode.h>
32#include <media/media-entity.h>
33
34/**
35 * struct media_device - Media device
36 * @dev: Parent device
37 * @devnode: Media device node
38 * @model: Device model name
39 * @serial: Device serial number (optional)
40 * @bus_info: Unique and stable device location identifier
41 * @hw_revision: Hardware device revision
42 * @driver_version: Device driver version
43 * @entity_id: ID of the next entity to be registered
44 * @entities: List of registered entities
45 * @lock: Entities list lock
46 * @graph_mutex: Entities graph operation lock
47 *
48 * This structure represents an abstract high-level media device. It allows easy
49 * access to entities and provides basic media device-level support. The
50 * structure can be allocated directly or embedded in a larger structure.
51 *
52 * The parent @dev is a physical device. It must be set before registering the
53 * media device.
54 *
55 * @model is a descriptive model name exported through sysfs. It doesn't have to
56 * be unique.
57 */
58struct media_device {
59 /* dev->driver_data points to this struct. */
60 struct device *dev;
61 struct media_devnode devnode;
62
63 char model[32];
64 char serial[40];
65 char bus_info[32];
66 u32 hw_revision;
67 u32 driver_version;
68
69 u32 entity_id;
70 struct list_head entities;
71
72 /* Protects the entities list */
73 spinlock_t lock;
74 /* Serializes graph operations. */
75 struct mutex graph_mutex;
76
77 int (*link_notify)(struct media_pad *source,
78 struct media_pad *sink, u32 flags);
79};
80
81/* media_devnode to media_device */
82#define to_media_device(node) container_of(node, struct media_device, devnode)
83
84int __must_check media_device_register(struct media_device *mdev);
85void media_device_unregister(struct media_device *mdev);
86
87int __must_check media_device_register_entity(struct media_device *mdev,
88 struct media_entity *entity);
89void media_device_unregister_entity(struct media_entity *entity);
90
91/* Iterate over all entities. */
92#define media_device_for_each_entity(entity, mdev) \
93 list_for_each_entry(entity, &(mdev)->entities, list)
94
95#endif
diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h
new file mode 100644
index 000000000000..f6caafc874cb
--- /dev/null
+++ b/include/media/media-devnode.h
@@ -0,0 +1,97 @@
1/*
2 * Media device node
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * --
23 *
24 * Common functions for media-related drivers to register and unregister media
25 * device nodes.
26 */
27
28#ifndef _MEDIA_DEVNODE_H
29#define _MEDIA_DEVNODE_H
30
31#include <linux/poll.h>
32#include <linux/fs.h>
33#include <linux/device.h>
34#include <linux/cdev.h>
35
36/*
37 * Flag to mark the media_devnode struct as registered. Drivers must not touch
38 * this flag directly, it will be set and cleared by media_devnode_register and
39 * media_devnode_unregister.
40 */
41#define MEDIA_FLAG_REGISTERED 0
42
43struct media_file_operations {
44 struct module *owner;
45 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
46 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
47 unsigned int (*poll) (struct file *, struct poll_table_struct *);
48 long (*ioctl) (struct file *, unsigned int, unsigned long);
49 int (*open) (struct file *);
50 int (*release) (struct file *);
51};
52
53/**
54 * struct media_devnode - Media device node
55 * @parent: parent device
56 * @minor: device node minor number
57 * @flags: flags, combination of the MEDIA_FLAG_* constants
58 *
59 * This structure represents a media-related device node.
60 *
61 * The @parent is a physical device. It must be set by core or device drivers
62 * before registering the node.
63 */
64struct media_devnode {
65 /* device ops */
66 const struct media_file_operations *fops;
67
68 /* sysfs */
69 struct device dev; /* media device */
70 struct cdev cdev; /* character device */
71 struct device *parent; /* device parent */
72
73 /* device info */
74 int minor;
75 unsigned long flags; /* Use bitops to access flags */
76
77 /* callbacks */
78 void (*release)(struct media_devnode *mdev);
79};
80
81/* dev to media_devnode */
82#define to_media_devnode(cd) container_of(cd, struct media_devnode, dev)
83
84int __must_check media_devnode_register(struct media_devnode *mdev);
85void media_devnode_unregister(struct media_devnode *mdev);
86
87static inline struct media_devnode *media_devnode_data(struct file *filp)
88{
89 return filp->private_data;
90}
91
92static inline int media_devnode_is_registered(struct media_devnode *mdev)
93{
94 return test_bit(MEDIA_FLAG_REGISTERED, &mdev->flags);
95}
96
97#endif /* _MEDIA_DEVNODE_H */
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
new file mode 100644
index 000000000000..cd8bca63a502
--- /dev/null
+++ b/include/media/media-entity.h
@@ -0,0 +1,151 @@
1/*
2 * Media entity
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#ifndef _MEDIA_ENTITY_H
24#define _MEDIA_ENTITY_H
25
26#include <linux/list.h>
27#include <linux/media.h>
28
29struct media_pipeline {
30};
31
32struct media_link {
33 struct media_pad *source; /* Source pad */
34 struct media_pad *sink; /* Sink pad */
35 struct media_link *reverse; /* Link in the reverse direction */
36 unsigned long flags; /* Link flags (MEDIA_LNK_FL_*) */
37};
38
39struct media_pad {
40 struct media_entity *entity; /* Entity this pad belongs to */
41 u16 index; /* Pad index in the entity pads array */
42 unsigned long flags; /* Pad flags (MEDIA_PAD_FL_*) */
43};
44
45struct media_entity_operations {
46 int (*link_setup)(struct media_entity *entity,
47 const struct media_pad *local,
48 const struct media_pad *remote, u32 flags);
49};
50
51struct media_entity {
52 struct list_head list;
53 struct media_device *parent; /* Media device this entity belongs to*/
54 u32 id; /* Entity ID, unique in the parent media
55 * device context */
56 const char *name; /* Entity name */
57 u32 type; /* Entity type (MEDIA_ENT_T_*) */
58 u32 revision; /* Entity revision, driver specific */
59 unsigned long flags; /* Entity flags (MEDIA_ENT_FL_*) */
60 u32 group_id; /* Entity group ID */
61
62 u16 num_pads; /* Number of sink and source pads */
63 u16 num_links; /* Number of existing links, both
64 * enabled and disabled */
65 u16 num_backlinks; /* Number of backlinks */
66 u16 max_links; /* Maximum number of links */
67
68 struct media_pad *pads; /* Pads array (num_pads elements) */
69 struct media_link *links; /* Links array (max_links elements)*/
70
71 const struct media_entity_operations *ops; /* Entity operations */
72
73 /* Reference counts must never be negative, but are signed integers on
74 * purpose: a simple WARN_ON(<0) check can be used to detect reference
75 * count bugs that would make them negative.
76 */
77 int stream_count; /* Stream count for the entity. */
78 int use_count; /* Use count for the entity. */
79
80 struct media_pipeline *pipe; /* Pipeline this entity belongs to. */
81
82 union {
83 /* Node specifications */
84 struct {
85 u32 major;
86 u32 minor;
87 } v4l;
88 struct {
89 u32 major;
90 u32 minor;
91 } fb;
92 struct {
93 u32 card;
94 u32 device;
95 u32 subdevice;
96 } alsa;
97 int dvb;
98
99 /* Sub-device specifications */
100 /* Nothing needed yet */
101 };
102};
103
104static inline u32 media_entity_type(struct media_entity *entity)
105{
106 return entity->type & MEDIA_ENT_TYPE_MASK;
107}
108
109static inline u32 media_entity_subtype(struct media_entity *entity)
110{
111 return entity->type & MEDIA_ENT_SUBTYPE_MASK;
112}
113
114#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
115
116struct media_entity_graph {
117 struct {
118 struct media_entity *entity;
119 int link;
120 } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
121 int top;
122};
123
124int media_entity_init(struct media_entity *entity, u16 num_pads,
125 struct media_pad *pads, u16 extra_links);
126void media_entity_cleanup(struct media_entity *entity);
127
128int media_entity_create_link(struct media_entity *source, u16 source_pad,
129 struct media_entity *sink, u16 sink_pad, u32 flags);
130int __media_entity_setup_link(struct media_link *link, u32 flags);
131int media_entity_setup_link(struct media_link *link, u32 flags);
132struct media_link *media_entity_find_link(struct media_pad *source,
133 struct media_pad *sink);
134struct media_pad *media_entity_remote_source(struct media_pad *pad);
135
136struct media_entity *media_entity_get(struct media_entity *entity);
137void media_entity_put(struct media_entity *entity);
138
139void media_entity_graph_walk_start(struct media_entity_graph *graph,
140 struct media_entity *entity);
141struct media_entity *
142media_entity_graph_walk_next(struct media_entity_graph *graph);
143void media_entity_pipeline_start(struct media_entity *entity,
144 struct media_pipeline *pipe);
145void media_entity_pipeline_stop(struct media_entity *entity);
146
147#define media_entity_call(entity, operation, args...) \
148 (((entity)->ops && (entity)->ops->operation) ? \
149 (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
150
151#endif
diff --git a/include/media/mt9v011.h b/include/media/mt9v011.h
new file mode 100644
index 000000000000..ea29fc74cd06
--- /dev/null
+++ b/include/media/mt9v011.h
@@ -0,0 +1,17 @@
1/* mt9v011 sensor
2 *
3 * Copyright (C) 2011 Hans Verkuil <hverkuil@xs4all.nl>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#ifndef __MT9V011_H__
11#define __MT9V011_H__
12
13struct mt9v011_platform_data {
14 unsigned xtal; /* Hz */
15};
16
17#endif
diff --git a/include/media/mt9v032.h b/include/media/mt9v032.h
new file mode 100644
index 000000000000..5e27f9be6b95
--- /dev/null
+++ b/include/media/mt9v032.h
@@ -0,0 +1,12 @@
1#ifndef _MEDIA_MT9V032_H
2#define _MEDIA_MT9V032_H
3
4struct v4l2_subdev;
5
6struct mt9v032_platform_data {
7 unsigned int clk_pol:1;
8
9 void (*set_clock)(struct v4l2_subdev *subdev, unsigned int rate);
10};
11
12#endif
diff --git a/include/media/noon010pc30.h b/include/media/noon010pc30.h
new file mode 100644
index 000000000000..58eafee36b30
--- /dev/null
+++ b/include/media/noon010pc30.h
@@ -0,0 +1,28 @@
1/*
2 * Driver header for NOON010PC30L camera sensor chip.
3 *
4 * Copyright (c) 2010 Samsung Electronics, Co. Ltd
5 * Contact: Sylwester Nawrocki <s.nawrocki@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef NOON010PC30_H
14#define NOON010PC30_H
15
16/**
17 * @clk_rate: the clock frequency in Hz
18 * @gpio_nreset: GPIO driving nRESET pin
19 * @gpio_nstby: GPIO driving nSTBY pin
20 */
21
22struct noon010pc30_platform_data {
23 unsigned long clk_rate;
24 int gpio_nreset;
25 int gpio_nstby;
26};
27
28#endif /* NOON010PC30_H */
diff --git a/include/media/omap1_camera.h b/include/media/omap1_camera.h
new file mode 100644
index 000000000000..819767cf04d4
--- /dev/null
+++ b/include/media/omap1_camera.h
@@ -0,0 +1,35 @@
1/*
2 * Header for V4L2 SoC Camera driver for OMAP1 Camera Interface
3 *
4 * Copyright (C) 2010, Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __MEDIA_OMAP1_CAMERA_H_
12#define __MEDIA_OMAP1_CAMERA_H_
13
14#include <linux/bitops.h>
15
16#define OMAP1_CAMERA_IOSIZE 0x1c
17
18enum omap1_cam_vb_mode {
19 OMAP1_CAM_DMA_CONTIG = 0,
20 OMAP1_CAM_DMA_SG,
21};
22
23#define OMAP1_CAMERA_MIN_BUF_COUNT(x) ((x) == OMAP1_CAM_DMA_CONTIG ? 3 : 2)
24
25struct omap1_cam_platform_data {
26 unsigned long camexclk_khz;
27 unsigned long lclk_khz_max;
28 unsigned long flags;
29};
30
31#define OMAP1_CAMERA_LCLK_RISING BIT(0)
32#define OMAP1_CAMERA_RST_LOW BIT(1)
33#define OMAP1_CAMERA_RST_HIGH BIT(2)
34
35#endif /* __MEDIA_OMAP1_CAMERA_H_ */
diff --git a/include/media/ovcamchip.h b/include/media/ovcamchip.h
deleted file mode 100644
index 05b9569ef1c8..000000000000
--- a/include/media/ovcamchip.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/* OmniVision* camera chip driver API
2 *
3 * Copyright (c) 1999-2004 Mark McClelland
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
9 *
10 * * OmniVision is a trademark of OmniVision Technologies, Inc. This driver
11 * is not sponsored or developed by them.
12 */
13
14#ifndef __LINUX_OVCAMCHIP_H
15#define __LINUX_OVCAMCHIP_H
16
17#include <linux/videodev.h>
18#include <media/v4l2-common.h>
19
20/* --------------------------------- */
21/* ENUMERATIONS */
22/* --------------------------------- */
23
24/* Controls */
25enum {
26 OVCAMCHIP_CID_CONT, /* Contrast */
27 OVCAMCHIP_CID_BRIGHT, /* Brightness */
28 OVCAMCHIP_CID_SAT, /* Saturation */
29 OVCAMCHIP_CID_HUE, /* Hue */
30 OVCAMCHIP_CID_EXP, /* Exposure */
31 OVCAMCHIP_CID_FREQ, /* Light frequency */
32 OVCAMCHIP_CID_BANDFILT, /* Banding filter */
33 OVCAMCHIP_CID_AUTOBRIGHT, /* Auto brightness */
34 OVCAMCHIP_CID_AUTOEXP, /* Auto exposure */
35 OVCAMCHIP_CID_BACKLIGHT, /* Back light compensation */
36 OVCAMCHIP_CID_MIRROR, /* Mirror horizontally */
37};
38
39/* Chip types */
40#define NUM_CC_TYPES 9
41enum {
42 CC_UNKNOWN,
43 CC_OV76BE,
44 CC_OV7610,
45 CC_OV7620,
46 CC_OV7620AE,
47 CC_OV6620,
48 CC_OV6630,
49 CC_OV6630AE,
50 CC_OV6630AF,
51};
52
53/* --------------------------------- */
54/* I2C ADDRESSES */
55/* --------------------------------- */
56
57#define OV7xx0_SID (0x42 >> 1)
58#define OV6xx0_SID (0xC0 >> 1)
59
60/* --------------------------------- */
61/* API */
62/* --------------------------------- */
63
64struct ovcamchip_control {
65 __u32 id;
66 __s32 value;
67};
68
69struct ovcamchip_window {
70 int x;
71 int y;
72 int width;
73 int height;
74 int format;
75 int quarter; /* Scale width and height down 2x */
76
77 /* This stuff will be removed eventually */
78 int clockdiv; /* Clock divisor setting */
79};
80
81/* Commands */
82#define OVCAMCHIP_CMD_Q_SUBTYPE _IOR (0x88, 0x00, int)
83#define OVCAMCHIP_CMD_INITIALIZE _IOW (0x88, 0x01, int)
84/* You must call OVCAMCHIP_CMD_INITIALIZE before any of commands below! */
85#define OVCAMCHIP_CMD_S_CTRL _IOW (0x88, 0x02, struct ovcamchip_control)
86#define OVCAMCHIP_CMD_G_CTRL _IOWR (0x88, 0x03, struct ovcamchip_control)
87#define OVCAMCHIP_CMD_S_MODE _IOW (0x88, 0x04, struct ovcamchip_window)
88#define OVCAMCHIP_MAX_CMD _IO (0x88, 0x3f)
89
90#endif
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
new file mode 100644
index 000000000000..60536c74c1ea
--- /dev/null
+++ b/include/media/rc-core.h
@@ -0,0 +1,226 @@
1/*
2 * Remote Controller core header
3 *
4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _RC_CORE
17#define _RC_CORE
18
19#include <linux/spinlock.h>
20#include <linux/kfifo.h>
21#include <linux/time.h>
22#include <linux/timer.h>
23#include <media/rc-map.h>
24
25extern int rc_core_debug;
26#define IR_dprintk(level, fmt, arg...) if (rc_core_debug >= level) \
27 printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
28
29enum rc_driver_type {
30 RC_DRIVER_SCANCODE = 0, /* Driver or hardware generates a scancode */
31 RC_DRIVER_IR_RAW, /* Needs a Infra-Red pulse/space decoder */
32};
33
34/**
35 * struct rc_dev - represents a remote control device
36 * @dev: driver model's view of this device
37 * @input_name: name of the input child device
38 * @input_phys: physical path to the input child device
39 * @input_id: id of the input child device (struct input_id)
40 * @driver_name: name of the hardware driver which registered this device
41 * @map_name: name of the default keymap
42 * @rc_map: current scan/key table
43 * @lock: used to ensure we've filled in all protocol details before
44 * anyone can call show_protocols or store_protocols
45 * @devno: unique remote control device number
46 * @raw: additional data for raw pulse/space devices
47 * @input_dev: the input child device used to communicate events to userspace
48 * @driver_type: specifies if protocol decoding is done in hardware or software
49 * @idle: used to keep track of RX state
50 * @allowed_protos: bitmask with the supported RC_TYPE_* protocols
51 * @scanmask: some hardware decoders are not capable of providing the full
52 * scancode to the application. As this is a hardware limit, we can't do
53 * anything with it. Yet, as the same keycode table can be used with other
54 * devices, a mask is provided to allow its usage. Drivers should generally
55 * leave this field in blank
56 * @priv: driver-specific data
57 * @keylock: protects the remaining members of the struct
58 * @keypressed: whether a key is currently pressed
59 * @keyup_jiffies: time (in jiffies) when the current keypress should be released
60 * @timer_keyup: timer for releasing a keypress
61 * @last_keycode: keycode of last keypress
62 * @last_scancode: scancode of last keypress
63 * @last_toggle: toggle value of last command
64 * @timeout: optional time after which device stops sending data
65 * @min_timeout: minimum timeout supported by device
66 * @max_timeout: maximum timeout supported by device
67 * @rx_resolution : resolution (in ns) of input sampler
68 * @tx_resolution: resolution (in ns) of output sampler
69 * @change_protocol: allow changing the protocol used on hardware decoders
70 * @open: callback to allow drivers to enable polling/irq when IR input device
71 * is opened.
72 * @close: callback to allow drivers to disable polling/irq when IR input device
73 * is opened.
74 * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs)
75 * @s_tx_carrier: set transmit carrier frequency
76 * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%)
77 * @s_rx_carrier: inform driver about carrier it is expected to handle
78 * @tx_ir: transmit IR
79 * @s_idle: enable/disable hardware idle mode, upon which,
80 * device doesn't interrupt host until it sees IR pulses
81 * @s_learning_mode: enable wide band receiver used for learning
82 * @s_carrier_report: enable carrier reports
83 */
84struct rc_dev {
85 struct device dev;
86 const char *input_name;
87 const char *input_phys;
88 struct input_id input_id;
89 char *driver_name;
90 const char *map_name;
91 struct rc_map rc_map;
92 struct mutex lock;
93 unsigned long devno;
94 struct ir_raw_event_ctrl *raw;
95 struct input_dev *input_dev;
96 enum rc_driver_type driver_type;
97 bool idle;
98 u64 allowed_protos;
99 u32 scanmask;
100 void *priv;
101 spinlock_t keylock;
102 bool keypressed;
103 unsigned long keyup_jiffies;
104 struct timer_list timer_keyup;
105 u32 last_keycode;
106 u32 last_scancode;
107 u8 last_toggle;
108 u32 timeout;
109 u32 min_timeout;
110 u32 max_timeout;
111 u32 rx_resolution;
112 u32 tx_resolution;
113 int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
114 int (*open)(struct rc_dev *dev);
115 void (*close)(struct rc_dev *dev);
116 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
117 int (*s_tx_carrier)(struct rc_dev *dev, u32 carrier);
118 int (*s_tx_duty_cycle)(struct rc_dev *dev, u32 duty_cycle);
119 int (*s_rx_carrier_range)(struct rc_dev *dev, u32 min, u32 max);
120 int (*tx_ir)(struct rc_dev *dev, int *txbuf, u32 n);
121 void (*s_idle)(struct rc_dev *dev, bool enable);
122 int (*s_learning_mode)(struct rc_dev *dev, int enable);
123 int (*s_carrier_report) (struct rc_dev *dev, int enable);
124};
125
126#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
127
128/*
129 * From rc-main.c
130 * Those functions can be used on any type of Remote Controller. They
131 * basically creates an input_dev and properly reports the device as a
132 * Remote Controller, at sys/class/rc.
133 */
134
135struct rc_dev *rc_allocate_device(void);
136void rc_free_device(struct rc_dev *dev);
137int rc_register_device(struct rc_dev *dev);
138void rc_unregister_device(struct rc_dev *dev);
139
140void rc_repeat(struct rc_dev *dev);
141void rc_keydown(struct rc_dev *dev, int scancode, u8 toggle);
142void rc_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle);
143void rc_keyup(struct rc_dev *dev);
144u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode);
145
146/*
147 * From rc-raw.c
148 * The Raw interface is specific to InfraRed. It may be a good idea to
149 * split it later into a separate header.
150 */
151
152enum raw_event_type {
153 IR_SPACE = (1 << 0),
154 IR_PULSE = (1 << 1),
155 IR_START_EVENT = (1 << 2),
156 IR_STOP_EVENT = (1 << 3),
157};
158
159struct ir_raw_event {
160 union {
161 u32 duration;
162
163 struct {
164 u32 carrier;
165 u8 duty_cycle;
166 };
167 };
168
169 unsigned pulse:1;
170 unsigned reset:1;
171 unsigned timeout:1;
172 unsigned carrier_report:1;
173};
174
175#define DEFINE_IR_RAW_EVENT(event) \
176 struct ir_raw_event event = { \
177 { .duration = 0 } , \
178 .pulse = 0, \
179 .reset = 0, \
180 .timeout = 0, \
181 .carrier_report = 0 }
182
183static inline void init_ir_raw_event(struct ir_raw_event *ev)
184{
185 memset(ev, 0, sizeof(*ev));
186}
187
188#define IR_MAX_DURATION 0xFFFFFFFF /* a bit more than 4 seconds */
189#define US_TO_NS(usec) ((usec) * 1000)
190#define MS_TO_US(msec) ((msec) * 1000)
191#define MS_TO_NS(msec) ((msec) * 1000 * 1000)
192
193void ir_raw_event_handle(struct rc_dev *dev);
194int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);
195int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type);
196int ir_raw_event_store_with_filter(struct rc_dev *dev,
197 struct ir_raw_event *ev);
198void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
199
200static inline void ir_raw_event_reset(struct rc_dev *dev)
201{
202 DEFINE_IR_RAW_EVENT(ev);
203 ev.reset = true;
204
205 ir_raw_event_store(dev, &ev);
206 ir_raw_event_handle(dev);
207}
208
209/* extract mask bits out of data and pack them into the result */
210static inline u32 ir_extract_bits(u32 data, u32 mask)
211{
212 u32 vbit = 1, value = 0;
213
214 do {
215 if (mask & 1) {
216 if (data & 1)
217 value |= vbit;
218 vbit <<= 1;
219 }
220 data >>= 1;
221 } while (mask >>= 1);
222
223 return value;
224}
225
226#endif /* _RC_CORE */
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index a9c041d49662..4e1409ec2613 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -11,49 +11,52 @@
11 11
12#include <linux/input.h> 12#include <linux/input.h>
13 13
14#define IR_TYPE_UNKNOWN 0 14#define RC_TYPE_UNKNOWN 0
15#define IR_TYPE_RC5 (1 << 0) /* Philips RC5 protocol */ 15#define RC_TYPE_RC5 (1 << 0) /* Philips RC5 protocol */
16#define IR_TYPE_NEC (1 << 1) 16#define RC_TYPE_NEC (1 << 1)
17#define IR_TYPE_RC6 (1 << 2) /* Philips RC6 protocol */ 17#define RC_TYPE_RC6 (1 << 2) /* Philips RC6 protocol */
18#define IR_TYPE_JVC (1 << 3) /* JVC protocol */ 18#define RC_TYPE_JVC (1 << 3) /* JVC protocol */
19#define IR_TYPE_SONY (1 << 4) /* Sony12/15/20 protocol */ 19#define RC_TYPE_SONY (1 << 4) /* Sony12/15/20 protocol */
20#define IR_TYPE_LIRC (1 << 30) /* Pass raw IR to lirc userspace */ 20#define RC_TYPE_RC5_SZ (1 << 5) /* RC5 variant used by Streamzap */
21#define IR_TYPE_OTHER (1u << 31) 21#define RC_TYPE_LIRC (1 << 30) /* Pass raw IR to lirc userspace */
22#define RC_TYPE_OTHER (1u << 31)
22 23
23#define IR_TYPE_ALL (IR_TYPE_RC5 | IR_TYPE_NEC | IR_TYPE_RC6 | \ 24#define RC_TYPE_ALL (RC_TYPE_RC5 | RC_TYPE_NEC | RC_TYPE_RC6 | \
24 IR_TYPE_JVC | IR_TYPE_SONY | IR_TYPE_LIRC | \ 25 RC_TYPE_JVC | RC_TYPE_SONY | RC_TYPE_LIRC | \
25 IR_TYPE_OTHER) 26 RC_TYPE_RC5_SZ | RC_TYPE_OTHER)
26 27
27struct ir_scancode { 28struct rc_map_table {
28 u32 scancode; 29 u32 scancode;
29 u32 keycode; 30 u32 keycode;
30}; 31};
31 32
32struct ir_scancode_table { 33struct rc_map {
33 struct ir_scancode *scan; 34 struct rc_map_table *scan;
34 unsigned int size; /* Max number of entries */ 35 unsigned int size; /* Max number of entries */
35 unsigned int len; /* Used number of entries */ 36 unsigned int len; /* Used number of entries */
36 unsigned int alloc; /* Size of *scan in bytes */ 37 unsigned int alloc; /* Size of *scan in bytes */
37 u64 ir_type; 38 u64 rc_type;
38 char *name; 39 const char *name;
39 spinlock_t lock; 40 spinlock_t lock;
40}; 41};
41 42
42struct rc_keymap { 43struct rc_map_list {
43 struct list_head list; 44 struct list_head list;
44 struct ir_scancode_table map; 45 struct rc_map map;
45}; 46};
46 47
47/* Routines from rc-map.c */ 48/* Routines from rc-map.c */
48 49
49int ir_register_map(struct rc_keymap *map); 50int rc_map_register(struct rc_map_list *map);
50void ir_unregister_map(struct rc_keymap *map); 51void rc_map_unregister(struct rc_map_list *map);
51struct ir_scancode_table *get_rc_map(const char *name); 52struct rc_map *rc_map_get(const char *name);
52void rc_map_init(void); 53void rc_map_init(void);
53 54
54/* Names of the several keytables defined in-kernel */ 55/* Names of the several keytables defined in-kernel */
55 56
56#define RC_MAP_ADSTECH_DVB_T_PCI "rc-adstech-dvb-t-pci" 57#define RC_MAP_ADSTECH_DVB_T_PCI "rc-adstech-dvb-t-pci"
58#define RC_MAP_ALINK_DTU_M "rc-alink-dtu-m"
59#define RC_MAP_ANYSEE "rc-anysee"
57#define RC_MAP_APAC_VIEWCOMP "rc-apac-viewcomp" 60#define RC_MAP_APAC_VIEWCOMP "rc-apac-viewcomp"
58#define RC_MAP_ASUS_PC39 "rc-asus-pc39" 61#define RC_MAP_ASUS_PC39 "rc-asus-pc39"
59#define RC_MAP_ATI_TV_WONDER_HD_600 "rc-ati-tv-wonder-hd-600" 62#define RC_MAP_ATI_TV_WONDER_HD_600 "rc-ati-tv-wonder-hd-600"
@@ -62,8 +65,10 @@ void rc_map_init(void);
62#define RC_MAP_AVERMEDIA_DVBT "rc-avermedia-dvbt" 65#define RC_MAP_AVERMEDIA_DVBT "rc-avermedia-dvbt"
63#define RC_MAP_AVERMEDIA_M135A "rc-avermedia-m135a" 66#define RC_MAP_AVERMEDIA_M135A "rc-avermedia-m135a"
64#define RC_MAP_AVERMEDIA_M733A_RM_K6 "rc-avermedia-m733a-rm-k6" 67#define RC_MAP_AVERMEDIA_M733A_RM_K6 "rc-avermedia-m733a-rm-k6"
68#define RC_MAP_AVERMEDIA_RM_KS "rc-avermedia-rm-ks"
65#define RC_MAP_AVERMEDIA "rc-avermedia" 69#define RC_MAP_AVERMEDIA "rc-avermedia"
66#define RC_MAP_AVERTV_303 "rc-avertv-303" 70#define RC_MAP_AVERTV_303 "rc-avertv-303"
71#define RC_MAP_AZUREWAVE_AD_TU700 "rc-azurewave-ad-tu700"
67#define RC_MAP_BEHOLD_COLUMBUS "rc-behold-columbus" 72#define RC_MAP_BEHOLD_COLUMBUS "rc-behold-columbus"
68#define RC_MAP_BEHOLD "rc-behold" 73#define RC_MAP_BEHOLD "rc-behold"
69#define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old" 74#define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old"
@@ -71,6 +76,8 @@ void rc_map_init(void);
71#define RC_MAP_CINERGY "rc-cinergy" 76#define RC_MAP_CINERGY "rc-cinergy"
72#define RC_MAP_DIB0700_NEC_TABLE "rc-dib0700-nec" 77#define RC_MAP_DIB0700_NEC_TABLE "rc-dib0700-nec"
73#define RC_MAP_DIB0700_RC5_TABLE "rc-dib0700-rc5" 78#define RC_MAP_DIB0700_RC5_TABLE "rc-dib0700-rc5"
79#define RC_MAP_DIGITALNOW_TINYTWIN "rc-digitalnow-tinytwin"
80#define RC_MAP_DIGITTRADE "rc-digittrade"
74#define RC_MAP_DM1105_NEC "rc-dm1105-nec" 81#define RC_MAP_DM1105_NEC "rc-dm1105-nec"
75#define RC_MAP_DNTV_LIVE_DVBT_PRO "rc-dntv-live-dvbt-pro" 82#define RC_MAP_DNTV_LIVE_DVBT_PRO "rc-dntv-live-dvbt-pro"
76#define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t" 83#define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t"
@@ -87,15 +94,19 @@ void rc_map_init(void);
87#define RC_MAP_GADMEI_RM008Z "rc-gadmei-rm008z" 94#define RC_MAP_GADMEI_RM008Z "rc-gadmei-rm008z"
88#define RC_MAP_GENIUS_TVGO_A11MCE "rc-genius-tvgo-a11mce" 95#define RC_MAP_GENIUS_TVGO_A11MCE "rc-genius-tvgo-a11mce"
89#define RC_MAP_GOTVIEW7135 "rc-gotview7135" 96#define RC_MAP_GOTVIEW7135 "rc-gotview7135"
90#define RC_MAP_HAUPPAUGE_NEW "rc-hauppauge-new" 97#define RC_MAP_HAUPPAUGE_NEW "rc-hauppauge"
91#define RC_MAP_IMON_MCE "rc-imon-mce" 98#define RC_MAP_IMON_MCE "rc-imon-mce"
92#define RC_MAP_IMON_PAD "rc-imon-pad" 99#define RC_MAP_IMON_PAD "rc-imon-pad"
93#define RC_MAP_IODATA_BCTV7E "rc-iodata-bctv7e" 100#define RC_MAP_IODATA_BCTV7E "rc-iodata-bctv7e"
94#define RC_MAP_KAIOMY "rc-kaiomy" 101#define RC_MAP_KAIOMY "rc-kaiomy"
95#define RC_MAP_KWORLD_315U "rc-kworld-315u" 102#define RC_MAP_KWORLD_315U "rc-kworld-315u"
96#define RC_MAP_KWORLD_PLUS_TV_ANALOG "rc-kworld-plus-tv-analog" 103#define RC_MAP_KWORLD_PLUS_TV_ANALOG "rc-kworld-plus-tv-analog"
104#define RC_MAP_LEADTEK_Y04G0051 "rc-leadtek-y04g0051"
97#define RC_MAP_LIRC "rc-lirc" 105#define RC_MAP_LIRC "rc-lirc"
106#define RC_MAP_LME2510 "rc-lme2510"
98#define RC_MAP_MANLI "rc-manli" 107#define RC_MAP_MANLI "rc-manli"
108#define RC_MAP_MSI_DIGIVOX_II "rc-msi-digivox-ii"
109#define RC_MAP_MSI_DIGIVOX_III "rc-msi-digivox-iii"
99#define RC_MAP_MSI_TVANYWHERE_PLUS "rc-msi-tvanywhere-plus" 110#define RC_MAP_MSI_TVANYWHERE_PLUS "rc-msi-tvanywhere-plus"
100#define RC_MAP_MSI_TVANYWHERE "rc-msi-tvanywhere" 111#define RC_MAP_MSI_TVANYWHERE "rc-msi-tvanywhere"
101#define RC_MAP_NEBULA "rc-nebula" 112#define RC_MAP_NEBULA "rc-nebula"
@@ -108,20 +119,29 @@ void rc_map_init(void);
108#define RC_MAP_PINNACLE_PCTV_HD "rc-pinnacle-pctv-hd" 119#define RC_MAP_PINNACLE_PCTV_HD "rc-pinnacle-pctv-hd"
109#define RC_MAP_PIXELVIEW_NEW "rc-pixelview-new" 120#define RC_MAP_PIXELVIEW_NEW "rc-pixelview-new"
110#define RC_MAP_PIXELVIEW "rc-pixelview" 121#define RC_MAP_PIXELVIEW "rc-pixelview"
122#define RC_MAP_PIXELVIEW_002T "rc-pixelview-002t"
111#define RC_MAP_PIXELVIEW_MK12 "rc-pixelview-mk12" 123#define RC_MAP_PIXELVIEW_MK12 "rc-pixelview-mk12"
112#define RC_MAP_POWERCOLOR_REAL_ANGEL "rc-powercolor-real-angel" 124#define RC_MAP_POWERCOLOR_REAL_ANGEL "rc-powercolor-real-angel"
113#define RC_MAP_PROTEUS_2309 "rc-proteus-2309" 125#define RC_MAP_PROTEUS_2309 "rc-proteus-2309"
114#define RC_MAP_PURPLETV "rc-purpletv" 126#define RC_MAP_PURPLETV "rc-purpletv"
115#define RC_MAP_PV951 "rc-pv951" 127#define RC_MAP_PV951 "rc-pv951"
116#define RC_MAP_RC5_HAUPPAUGE_NEW "rc-rc5-hauppauge-new" 128#define RC_MAP_HAUPPAUGE "rc-hauppauge"
117#define RC_MAP_RC5_STREAMZAP "rc-rc5-streamzap"
118#define RC_MAP_RC5_TV "rc-rc5-tv" 129#define RC_MAP_RC5_TV "rc-rc5-tv"
119#define RC_MAP_RC6_MCE "rc-rc6-mce" 130#define RC_MAP_RC6_MCE "rc-rc6-mce"
120#define RC_MAP_REAL_AUDIO_220_32_KEYS "rc-real-audio-220-32-keys" 131#define RC_MAP_REAL_AUDIO_220_32_KEYS "rc-real-audio-220-32-keys"
132#define RC_MAP_STREAMZAP "rc-streamzap"
121#define RC_MAP_TBS_NEC "rc-tbs-nec" 133#define RC_MAP_TBS_NEC "rc-tbs-nec"
134#define RC_MAP_TECHNISAT_USB2 "rc-technisat-usb2"
122#define RC_MAP_TERRATEC_CINERGY_XS "rc-terratec-cinergy-xs" 135#define RC_MAP_TERRATEC_CINERGY_XS "rc-terratec-cinergy-xs"
136#define RC_MAP_TERRATEC_SLIM "rc-terratec-slim"
137#define RC_MAP_TERRATEC_SLIM_2 "rc-terratec-slim-2"
123#define RC_MAP_TEVII_NEC "rc-tevii-nec" 138#define RC_MAP_TEVII_NEC "rc-tevii-nec"
139#define RC_MAP_TIVO "rc-tivo"
140#define RC_MAP_TOTAL_MEDIA_IN_HAND "rc-total-media-in-hand"
141#define RC_MAP_TREKSTOR "rc-trekstor"
124#define RC_MAP_TT_1500 "rc-tt-1500" 142#define RC_MAP_TT_1500 "rc-tt-1500"
143#define RC_MAP_TWINHAN_VP1027_DVBS "rc-twinhan1027"
144#define RC_MAP_VIDEOMATE_M1F "rc-videomate-m1f"
125#define RC_MAP_VIDEOMATE_S350 "rc-videomate-s350" 145#define RC_MAP_VIDEOMATE_S350 "rc-videomate-s350"
126#define RC_MAP_VIDEOMATE_TV_PVR "rc-videomate-tv-pvr" 146#define RC_MAP_VIDEOMATE_TV_PVR "rc-videomate-tv-pvr"
127#define RC_MAP_WINFAST "rc-winfast" 147#define RC_MAP_WINFAST "rc-winfast"
diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h
new file mode 100644
index 000000000000..9fdff8a4ed26
--- /dev/null
+++ b/include/media/s5p_fimc.h
@@ -0,0 +1,61 @@
1/*
2 * Samsung S5P SoC camera interface driver header
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd
5 * Author: Sylwester Nawrocki, <s.nawrocki@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef S5P_FIMC_H_
13#define S5P_FIMC_H_
14
15enum cam_bus_type {
16 FIMC_ITU_601 = 1,
17 FIMC_ITU_656,
18 FIMC_MIPI_CSI2,
19 FIMC_LCD_WB, /* FIFO link from LCD mixer */
20};
21
22#define FIMC_CLK_INV_PCLK (1 << 0)
23#define FIMC_CLK_INV_VSYNC (1 << 1)
24#define FIMC_CLK_INV_HREF (1 << 2)
25#define FIMC_CLK_INV_HSYNC (1 << 3)
26
27struct i2c_board_info;
28
29/**
30 * struct s5p_fimc_isp_info - image sensor information required for host
31 * interace configuration.
32 *
33 * @board_info: pointer to I2C subdevice's board info
34 * @clk_frequency: frequency of the clock the host interface provides to sensor
35 * @bus_type: determines bus type, MIPI, ITU-R BT.601 etc.
36 * @csi_data_align: MIPI-CSI interface data alignment in bits
37 * @i2c_bus_num: i2c control bus id the sensor is attached to
38 * @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
39 * @flags: flags defining bus signals polarity inversion (High by default)
40 */
41struct s5p_fimc_isp_info {
42 struct i2c_board_info *board_info;
43 unsigned long clk_frequency;
44 enum cam_bus_type bus_type;
45 u16 csi_data_align;
46 u16 i2c_bus_num;
47 u16 mux_id;
48 u16 flags;
49};
50
51/**
52 * struct s5p_platform_fimc - camera host interface platform data
53 *
54 * @isp_info: properties of camera sensor required for host interface setup
55 * @num_clients: the number of attached image sensors
56 */
57struct s5p_platform_fimc {
58 struct s5p_fimc_isp_info *isp_info;
59 int num_clients;
60};
61#endif /* S5P_FIMC_H_ */
diff --git a/include/media/rds.h b/include/media/saa6588.h
index a89426667618..2c3c4420a4eb 100644
--- a/include/media/rds.h
+++ b/include/media/saa6588.h
@@ -4,9 +4,6 @@
4 saa6588.c and every driver (e.g. bttv-driver.c) that wants 4 saa6588.c and every driver (e.g. bttv-driver.c) that wants
5 to use the saa6588 module. 5 to use the saa6588 module.
6 6
7 Instead of having a separate rds.h, I'd prefer to include
8 this stuff in one of the already existing files like tuner.h
9
10 (c) 2005 by Hans J. Koch 7 (c) 2005 by Hans J. Koch
11 8
12 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
@@ -25,10 +22,10 @@
25 22
26*/ 23*/
27 24
28#ifndef _RDS_H 25#ifndef _SAA6588_H
29#define _RDS_H 26#define _SAA6588_H
30 27
31struct rds_command { 28struct saa6588_command {
32 unsigned int block_count; 29 unsigned int block_count;
33 int result; 30 int result;
34 unsigned char __user *buffer; 31 unsigned char __user *buffer;
@@ -36,9 +33,10 @@ struct rds_command {
36 poll_table *event_list; 33 poll_table *event_list;
37}; 34};
38 35
39#define RDS_CMD_OPEN _IOW('R',1,int) 36/* These ioctls are internal to the kernel */
40#define RDS_CMD_CLOSE _IOW('R',2,int) 37#define SAA6588_CMD_OPEN _IOW('R', 1, int)
41#define RDS_CMD_READ _IOR('R',3,int) 38#define SAA6588_CMD_CLOSE _IOW('R', 2, int)
42#define RDS_CMD_POLL _IOR('R',4,int) 39#define SAA6588_CMD_READ _IOR('R', 3, int)
40#define SAA6588_CMD_POLL _IOR('R', 4, int)
43 41
44#endif 42#endif
diff --git a/include/media/saa7146.h b/include/media/saa7146.h
index 7a9f76ecbbbd..79827143d5ac 100644
--- a/include/media/saa7146.h
+++ b/include/media/saa7146.h
@@ -115,7 +115,7 @@ struct saa7146_dev
115 115
116 /* different device locks */ 116 /* different device locks */
117 spinlock_t slock; 117 spinlock_t slock;
118 struct mutex lock; 118 struct mutex v4l2_lock;
119 119
120 unsigned char __iomem *mem; /* pointer to mapped IO memory */ 120 unsigned char __iomem *mem; /* pointer to mapped IO memory */
121 u32 revision; /* chip revision; needed for bug-workarounds*/ 121 u32 revision; /* chip revision; needed for bug-workarounds*/
@@ -161,7 +161,7 @@ extern struct list_head saa7146_devices;
161extern struct mutex saa7146_devices_lock; 161extern struct mutex saa7146_devices_lock;
162int saa7146_register_extension(struct saa7146_extension*); 162int saa7146_register_extension(struct saa7146_extension*);
163int saa7146_unregister_extension(struct saa7146_extension*); 163int saa7146_unregister_extension(struct saa7146_extension*);
164struct saa7146_format* format_by_fourcc(struct saa7146_dev *dev, int fourcc); 164struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc);
165int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt); 165int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt);
166void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt); 166void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt);
167int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length ); 167int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length );
diff --git a/include/media/sh_vou.h b/include/media/sh_vou.h
index a3ef30242b00..ec3ba9a597a2 100644
--- a/include/media/sh_vou.h
+++ b/include/media/sh_vou.h
@@ -28,7 +28,6 @@ struct sh_vou_pdata {
28 int i2c_adap; 28 int i2c_adap;
29 struct i2c_board_info *board_info; 29 struct i2c_board_info *board_info;
30 unsigned long flags; 30 unsigned long flags;
31 char *module_name;
32}; 31};
33 32
34#endif 33#endif
diff --git a/include/media/si4713.h b/include/media/si4713.h
index 99850a54ed09..ed7353e8a982 100644
--- a/include/media/si4713.h
+++ b/include/media/si4713.h
@@ -23,8 +23,7 @@
23 * Platform dependent definition 23 * Platform dependent definition
24 */ 24 */
25struct si4713_platform_data { 25struct si4713_platform_data {
26 /* Set power state, zero is off, non-zero is on. */ 26 int gpio_reset; /* < 0 if not used */
27 int (*set_power)(int power);
28}; 27};
29 28
30/* 29/*
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2ce957301f77..238bd334fd83 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -17,16 +17,21 @@
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/videodev2.h> 18#include <linux/videodev2.h>
19#include <media/videobuf-core.h> 19#include <media/videobuf-core.h>
20#include <media/videobuf2-core.h>
20#include <media/v4l2-device.h> 21#include <media/v4l2-device.h>
21 22
22extern struct bus_type soc_camera_bus_type; 23extern struct bus_type soc_camera_bus_type;
23 24
25struct file;
26
24struct soc_camera_device { 27struct soc_camera_device {
25 struct list_head list; 28 struct list_head list;
26 struct device dev; 29 struct device dev;
27 struct device *pdev; /* Platform device */ 30 struct device *pdev; /* Platform device */
28 s32 user_width; 31 s32 user_width;
29 s32 user_height; 32 s32 user_height;
33 u32 bytesperline; /* for padding, zero if unused */
34 u32 sizeimage;
30 enum v4l2_colorspace colorspace; 35 enum v4l2_colorspace colorspace;
31 unsigned char iface; /* Host number */ 36 unsigned char iface; /* Host number */
32 unsigned char devnum; /* Device number per host */ 37 unsigned char devnum; /* Device number per host */
@@ -41,11 +46,11 @@ struct soc_camera_device {
41 /* soc_camera.c private count. Only accessed with .video_lock held */ 46 /* soc_camera.c private count. Only accessed with .video_lock held */
42 int use_count; 47 int use_count;
43 struct mutex video_lock; /* Protects device data */ 48 struct mutex video_lock; /* Protects device data */
44}; 49 struct file *streamer; /* stream owner */
45 50 union {
46struct soc_camera_file { 51 struct videobuf_queue vb_vidq;
47 struct soc_camera_device *icd; 52 struct vb2_queue vb2_vidq;
48 struct videobuf_queue vb_vidq; 53 };
49}; 54};
50 55
51struct soc_camera_host { 56struct soc_camera_host {
@@ -75,17 +80,25 @@ struct soc_camera_host_ops {
75 int (*cropcap)(struct soc_camera_device *, struct v4l2_cropcap *); 80 int (*cropcap)(struct soc_camera_device *, struct v4l2_cropcap *);
76 int (*get_crop)(struct soc_camera_device *, struct v4l2_crop *); 81 int (*get_crop)(struct soc_camera_device *, struct v4l2_crop *);
77 int (*set_crop)(struct soc_camera_device *, struct v4l2_crop *); 82 int (*set_crop)(struct soc_camera_device *, struct v4l2_crop *);
83 /*
84 * The difference to .set_crop() is, that .set_livecrop is not allowed
85 * to change the output sizes
86 */
87 int (*set_livecrop)(struct soc_camera_device *, struct v4l2_crop *);
78 int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *); 88 int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *);
79 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *); 89 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
80 void (*init_videobuf)(struct videobuf_queue *, 90 void (*init_videobuf)(struct videobuf_queue *,
81 struct soc_camera_device *); 91 struct soc_camera_device *);
82 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); 92 int (*init_videobuf2)(struct vb2_queue *,
93 struct soc_camera_device *);
94 int (*reqbufs)(struct soc_camera_device *, struct v4l2_requestbuffers *);
83 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); 95 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
84 int (*set_bus_param)(struct soc_camera_device *, __u32); 96 int (*set_bus_param)(struct soc_camera_device *, __u32);
85 int (*get_ctrl)(struct soc_camera_device *, struct v4l2_control *); 97 int (*get_ctrl)(struct soc_camera_device *, struct v4l2_control *);
86 int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *); 98 int (*set_ctrl)(struct soc_camera_device *, struct v4l2_control *);
87 int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *); 99 int (*get_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
88 int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *); 100 int (*set_parm)(struct soc_camera_device *, struct v4l2_streamparm *);
101 int (*enum_fsizes)(struct soc_camera_device *, struct v4l2_frmsizeenum *);
89 unsigned int (*poll)(struct file *, poll_table *); 102 unsigned int (*poll)(struct file *, poll_table *);
90 const struct v4l2_queryctrl *controls; 103 const struct v4l2_queryctrl *controls;
91 int num_controls; 104 int num_controls;
@@ -96,8 +109,15 @@ struct soc_camera_host_ops {
96#define SOCAM_SENSOR_INVERT_HSYNC (1 << 2) 109#define SOCAM_SENSOR_INVERT_HSYNC (1 << 2)
97#define SOCAM_SENSOR_INVERT_VSYNC (1 << 3) 110#define SOCAM_SENSOR_INVERT_VSYNC (1 << 3)
98#define SOCAM_SENSOR_INVERT_DATA (1 << 4) 111#define SOCAM_SENSOR_INVERT_DATA (1 << 4)
112#define SOCAM_MIPI_1LANE (1 << 5)
113#define SOCAM_MIPI_2LANE (1 << 6)
114#define SOCAM_MIPI_3LANE (1 << 7)
115#define SOCAM_MIPI_4LANE (1 << 8)
116#define SOCAM_MIPI (SOCAM_MIPI_1LANE | SOCAM_MIPI_2LANE | \
117 SOCAM_MIPI_3LANE | SOCAM_MIPI_4LANE)
99 118
100struct i2c_board_info; 119struct i2c_board_info;
120struct regulator_bulk_data;
101 121
102struct soc_camera_link { 122struct soc_camera_link {
103 /* Camera bus id, used to match a camera and a bus */ 123 /* Camera bus id, used to match a camera and a bus */
@@ -109,6 +129,10 @@ struct soc_camera_link {
109 const char *module_name; 129 const char *module_name;
110 void *priv; 130 void *priv;
111 131
132 /* Optional regulators that have to be managed on power on/off events */
133 struct regulator_bulk_data *regulators;
134 int num_regulators;
135
112 /* 136 /*
113 * For non-I2C devices platform platform has to provide methods to 137 * For non-I2C devices platform platform has to provide methods to
114 * add a device to the system and to remove 138 * add a device to the system and to remove
@@ -255,6 +279,7 @@ static inline unsigned long soc_camera_bus_param_compatible(
255 unsigned long camera_flags, unsigned long bus_flags) 279 unsigned long camera_flags, unsigned long bus_flags)
256{ 280{
257 unsigned long common_flags, hsync, vsync, pclk, data, buswidth, mode; 281 unsigned long common_flags, hsync, vsync, pclk, data, buswidth, mode;
282 unsigned long mipi;
258 283
259 common_flags = camera_flags & bus_flags; 284 common_flags = camera_flags & bus_flags;
260 285
@@ -264,8 +289,9 @@ static inline unsigned long soc_camera_bus_param_compatible(
264 data = common_flags & (SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW); 289 data = common_flags & (SOCAM_DATA_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_LOW);
265 mode = common_flags & (SOCAM_MASTER | SOCAM_SLAVE); 290 mode = common_flags & (SOCAM_MASTER | SOCAM_SLAVE);
266 buswidth = common_flags & SOCAM_DATAWIDTH_MASK; 291 buswidth = common_flags & SOCAM_DATAWIDTH_MASK;
292 mipi = common_flags & SOCAM_MIPI;
267 293
268 return (!hsync || !vsync || !pclk || !data || !mode || !buswidth) ? 0 : 294 return ((!hsync || !vsync || !pclk || !data || !mode || !buswidth) && !mipi) ? 0 :
269 common_flags; 295 common_flags;
270} 296}
271 297
@@ -295,4 +321,17 @@ static inline struct video_device *soc_camera_i2c_to_vdev(struct i2c_client *cli
295 return icd->vdev; 321 return icd->vdev;
296} 322}
297 323
324static inline struct soc_camera_device *soc_camera_from_vb2q(struct vb2_queue *vq)
325{
326 return container_of(vq, struct soc_camera_device, vb2_vidq);
327}
328
329static inline struct soc_camera_device *soc_camera_from_vbq(struct videobuf_queue *vq)
330{
331 return container_of(vq, struct soc_camera_device, vb_vidq);
332}
333
334void soc_camera_lock(struct vb2_queue *vq);
335void soc_camera_unlock(struct vb2_queue *vq);
336
298#endif 337#endif
diff --git a/include/media/soc_camera_platform.h b/include/media/soc_camera_platform.h
index 0ecefe227b76..6d7a4fd00fc0 100644
--- a/include/media/soc_camera_platform.h
+++ b/include/media/soc_camera_platform.h
@@ -25,4 +25,54 @@ struct soc_camera_platform_info {
25 int (*set_capture)(struct soc_camera_platform_info *info, int enable); 25 int (*set_capture)(struct soc_camera_platform_info *info, int enable);
26}; 26};
27 27
28static inline void soc_camera_platform_release(struct platform_device **pdev)
29{
30 *pdev = NULL;
31}
32
33static inline int soc_camera_platform_add(const struct soc_camera_link *icl,
34 struct device *dev,
35 struct platform_device **pdev,
36 struct soc_camera_link *plink,
37 void (*release)(struct device *dev),
38 int id)
39{
40 struct soc_camera_platform_info *info = plink->priv;
41 int ret;
42
43 if (icl != plink)
44 return -ENODEV;
45
46 if (*pdev)
47 return -EBUSY;
48
49 *pdev = platform_device_alloc("soc_camera_platform", id);
50 if (!*pdev)
51 return -ENOMEM;
52
53 info->dev = dev;
54
55 (*pdev)->dev.platform_data = info;
56 (*pdev)->dev.release = release;
57
58 ret = platform_device_add(*pdev);
59 if (ret < 0) {
60 platform_device_put(*pdev);
61 *pdev = NULL;
62 info->dev = NULL;
63 }
64
65 return ret;
66}
67
68static inline void soc_camera_platform_del(const struct soc_camera_link *icl,
69 struct platform_device *pdev,
70 const struct soc_camera_link *plink)
71{
72 if (icl != plink || !pdev)
73 return;
74
75 platform_device_unregister(pdev);
76}
77
28#endif /* __SOC_CAMERA_H__ */ 78#endif /* __SOC_CAMERA_H__ */
diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h
index 037cd7be001e..fae432544b41 100644
--- a/include/media/soc_mediabus.h
+++ b/include/media/soc_mediabus.h
@@ -12,23 +12,28 @@
12#define SOC_MEDIABUS_H 12#define SOC_MEDIABUS_H
13 13
14#include <linux/videodev2.h> 14#include <linux/videodev2.h>
15 15#include <linux/v4l2-mediabus.h>
16#include <media/v4l2-mediabus.h>
17 16
18/** 17/**
19 * enum soc_mbus_packing - data packing types on the media-bus 18 * enum soc_mbus_packing - data packing types on the media-bus
20 * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM 19 * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one
20 * sample represents one pixel
21 * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the 21 * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the
22 * possibly incomplete byte high bits are padding 22 * possibly incomplete byte high bits are padding
23 * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding 23 * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding
24 * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended 24 * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended
25 * to 16 bits 25 * to 16 bits
26 * @SOC_MBUS_PACKING_VARIABLE: compressed formats with variable packing
27 * @SOC_MBUS_PACKING_1_5X8: used for packed YUV 4:2:0 formats, where 4
28 * pixels occupy 6 bytes in RAM
26 */ 29 */
27enum soc_mbus_packing { 30enum soc_mbus_packing {
28 SOC_MBUS_PACKING_NONE, 31 SOC_MBUS_PACKING_NONE,
29 SOC_MBUS_PACKING_2X8_PADHI, 32 SOC_MBUS_PACKING_2X8_PADHI,
30 SOC_MBUS_PACKING_2X8_PADLO, 33 SOC_MBUS_PACKING_2X8_PADLO,
31 SOC_MBUS_PACKING_EXTEND16, 34 SOC_MBUS_PACKING_EXTEND16,
35 SOC_MBUS_PACKING_VARIABLE,
36 SOC_MBUS_PACKING_1_5X8,
32}; 37};
33 38
34/** 39/**
@@ -58,8 +63,24 @@ struct soc_mbus_pixelfmt {
58 u8 bits_per_sample; 63 u8 bits_per_sample;
59}; 64};
60 65
66/**
67 * struct soc_mbus_lookup - Lookup FOURCC IDs by mediabus codes for pass-through
68 * @code: mediabus pixel-code
69 * @fmt: pixel format description
70 */
71struct soc_mbus_lookup {
72 enum v4l2_mbus_pixelcode code;
73 struct soc_mbus_pixelfmt fmt;
74};
75
76const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc(
77 enum v4l2_mbus_pixelcode code,
78 const struct soc_mbus_lookup *lookup,
79 int n);
61const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( 80const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
62 enum v4l2_mbus_pixelcode code); 81 enum v4l2_mbus_pixelcode code);
63s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); 82s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
83int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf,
84 unsigned int *numerator, unsigned int *denominator);
64 85
65#endif 86#endif
diff --git a/include/media/sr030pc30.h b/include/media/sr030pc30.h
new file mode 100644
index 000000000000..6f901a653ba2
--- /dev/null
+++ b/include/media/sr030pc30.h
@@ -0,0 +1,21 @@
1/*
2 * Driver header for SR030PC30 camera sensor
3 *
4 * Copyright (c) 2010 Samsung Electronics, Co. Ltd
5 * Contact: Sylwester Nawrocki <s.nawrocki@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef SR030PC30_H
14#define SR030PC30_H
15
16struct sr030pc30_platform_data {
17 unsigned long clk_rate; /* master clock frequency in Hz */
18 int (*set_power)(struct device *dev, int on);
19};
20
21#endif /* SR030PC30_H */
diff --git a/include/media/timb_radio.h b/include/media/timb_radio.h
index fcd32a3696ba..a59a84854dc1 100644
--- a/include/media/timb_radio.h
+++ b/include/media/timb_radio.h
@@ -24,7 +24,6 @@
24struct timb_radio_platform_data { 24struct timb_radio_platform_data {
25 int i2c_adapter; /* I2C adapter where the tuner and dsp are attached */ 25 int i2c_adapter; /* I2C adapter where the tuner and dsp are attached */
26 struct { 26 struct {
27 const char *module_name;
28 struct i2c_board_info *info; 27 struct i2c_board_info *info;
29 } tuner; 28 } tuner;
30 struct { 29 struct {
diff --git a/include/media/timb_video.h b/include/media/timb_video.h
new file mode 100644
index 000000000000..70ae43970a49
--- /dev/null
+++ b/include/media/timb_video.h
@@ -0,0 +1,33 @@
1/*
2 * timb_video.h Platform struct for the Timberdale video driver
3 * Copyright (c) 2009-2010 Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef _TIMB_VIDEO_
20#define _TIMB_VIDEO_ 1
21
22#include <linux/i2c.h>
23
24struct timb_video_platform_data {
25 int dma_channel;
26 int i2c_adapter; /* The I2C adapter where the encoder is attached */
27 struct {
28 const char *module_name;
29 struct i2c_board_info *info;
30 } encoder;
31};
32
33#endif
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 51811eac46f1..963e33471835 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -21,6 +21,7 @@
21 21
22#ifndef _TUNER_H 22#ifndef _TUNER_H
23#define _TUNER_H 23#define _TUNER_H
24#ifdef __KERNEL__
24 25
25#include <linux/videodev2.h> 26#include <linux/videodev2.h>
26 27
@@ -131,6 +132,7 @@
131#define TUNER_NXP_TDA18271 83 132#define TUNER_NXP_TDA18271 83
132#define TUNER_SONY_BTF_PXN01Z 84 133#define TUNER_SONY_BTF_PXN01Z 84
133#define TUNER_PHILIPS_FQ1236_MK5 85 /* NTSC, TDA9885, no FM radio */ 134#define TUNER_PHILIPS_FQ1236_MK5 85 /* NTSC, TDA9885, no FM radio */
135#define TUNER_TENA_TNF_5337 86
134 136
135/* tv card specific */ 137/* tv card specific */
136#define TDA9887_PRESENT (1<<0) 138#define TDA9887_PRESENT (1<<0)
@@ -156,14 +158,10 @@
156#define TDA9887_GAIN_NORMAL (1<<20) 158#define TDA9887_GAIN_NORMAL (1<<20)
157#define TDA9887_RIF_41_3 (1<<21) /* radio IF1 41.3 vs 33.3 */ 159#define TDA9887_RIF_41_3 (1<<21) /* radio IF1 41.3 vs 33.3 */
158 160
159#ifdef __KERNEL__
160
161enum tuner_mode { 161enum tuner_mode {
162 T_UNINITIALIZED = 0,
163 T_RADIO = 1 << V4L2_TUNER_RADIO, 162 T_RADIO = 1 << V4L2_TUNER_RADIO,
164 T_ANALOG_TV = 1 << V4L2_TUNER_ANALOG_TV, 163 T_ANALOG_TV = 1 << V4L2_TUNER_ANALOG_TV,
165 T_DIGITAL_TV = 1 << V4L2_TUNER_DIGITAL_TV, 164 /* Don't need to map V4L2_TUNER_DIGITAL_TV, as tuner-core won't use it */
166 T_STANDBY = 1 << 31
167}; 165};
168 166
169/* Older boards only had a single tuner device. Nowadays multiple tuner 167/* Older boards only had a single tuner device. Nowadays multiple tuner
@@ -193,11 +191,3 @@ struct tuner_setup {
193#endif /* __KERNEL__ */ 191#endif /* __KERNEL__ */
194 192
195#endif /* _TUNER_H */ 193#endif /* _TUNER_H */
196
197/*
198 * Overrides for Emacs so that we follow Linus's tabbing style.
199 * ---------------------------------------------------------------------------
200 * Local variables:
201 * c-basic-offset: 8
202 * End:
203 */
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 21b4428c12ab..b3edb67a8311 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -38,6 +38,9 @@ enum {
38 /* module tvaudio: reserved range 50-99 */ 38 /* module tvaudio: reserved range 50-99 */
39 V4L2_IDENT_TVAUDIO = 50, /* A tvaudio chip, unknown which it is exactly */ 39 V4L2_IDENT_TVAUDIO = 50, /* A tvaudio chip, unknown which it is exactly */
40 40
41 /* Sony IMX074 */
42 V4L2_IDENT_IMX074 = 74,
43
41 /* module saa7110: just ident 100 */ 44 /* module saa7110: just ident 100 */
42 V4L2_IDENT_SAA7110 = 100, 45 V4L2_IDENT_SAA7110 = 100,
43 46
@@ -70,6 +73,9 @@ enum {
70 V4L2_IDENT_OV9655 = 255, 73 V4L2_IDENT_OV9655 = 255,
71 V4L2_IDENT_SOI968 = 256, 74 V4L2_IDENT_SOI968 = 256,
72 V4L2_IDENT_OV9640 = 257, 75 V4L2_IDENT_OV9640 = 257,
76 V4L2_IDENT_OV6650 = 258,
77 V4L2_IDENT_OV2640 = 259,
78 V4L2_IDENT_OV9740 = 260,
73 79
74 /* module saa7146: reserved range 300-309 */ 80 /* module saa7146: reserved range 300-309 */
75 V4L2_IDENT_SAA7146 = 300, 81 V4L2_IDENT_SAA7146 = 300,
@@ -111,6 +117,10 @@ enum {
111 V4L2_IDENT_VPX3216B = 3216, 117 V4L2_IDENT_VPX3216B = 3216,
112 V4L2_IDENT_VPX3220A = 3220, 118 V4L2_IDENT_VPX3220A = 3220,
113 119
120 /* VX855 just ident 3409 */
121 /* Other via devs could use 3314, 3324, 3327, 3336, 3364, 3353 */
122 V4L2_IDENT_VIA_VX855 = 3409,
123
114 /* module tvp5150 */ 124 /* module tvp5150 */
115 V4L2_IDENT_TVP5150 = 5150, 125 V4L2_IDENT_TVP5150 = 5150,
116 126
@@ -200,6 +210,9 @@ enum {
200 /* module sn9c20x: just ident 10000 */ 210 /* module sn9c20x: just ident 10000 */
201 V4L2_IDENT_SN9C20X = 10000, 211 V4L2_IDENT_SN9C20X = 10000,
202 212
213 /* Siliconfile sensors: reserved range 10100 - 10199 */
214 V4L2_IDENT_NOON010PC30 = 10100,
215
203 /* module cx231xx and cx25840 */ 216 /* module cx231xx and cx25840 */
204 V4L2_IDENT_CX2310X_AV = 23099, /* Integrated A/V decoder; not in '100 */ 217 V4L2_IDENT_CX2310X_AV = 23099, /* Integrated A/V decoder; not in '100 */
205 V4L2_IDENT_CX23100 = 23100, 218 V4L2_IDENT_CX23100 = 23100,
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 98b32645e5a7..a298ec49ddc4 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -80,30 +80,15 @@
80 80
81/* ------------------------------------------------------------------------- */ 81/* ------------------------------------------------------------------------- */
82 82
83/* Priority helper functions */
84
85struct v4l2_prio_state {
86 atomic_t prios[4];
87};
88void v4l2_prio_init(struct v4l2_prio_state *global);
89int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
90 enum v4l2_priority new);
91void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
92void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
93enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
94int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
95
96/* ------------------------------------------------------------------------- */
97
98/* Control helper functions */ 83/* Control helper functions */
99 84
100int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, 85int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
101 const char **menu_items); 86 const char * const *menu_items);
102const char *v4l2_ctrl_get_name(u32 id); 87const char *v4l2_ctrl_get_name(u32 id);
103const char **v4l2_ctrl_get_menu(u32 id); 88const char * const *v4l2_ctrl_get_menu(u32 id);
104int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def); 89int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def);
105int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, 90int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu,
106 struct v4l2_queryctrl *qctrl, const char **menu_items); 91 struct v4l2_queryctrl *qctrl, const char * const *menu_items);
107#define V4L2_CTRL_MENU_IDS_END (0xffffffff) 92#define V4L2_CTRL_MENU_IDS_END (0xffffffff)
108int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids); 93int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids);
109 94
@@ -137,31 +122,16 @@ struct v4l2_subdev_ops;
137 122
138 123
139/* Load an i2c module and return an initialized v4l2_subdev struct. 124/* Load an i2c module and return an initialized v4l2_subdev struct.
140 Only call request_module if module_name != NULL.
141 The client_type argument is the name of the chip that's on the adapter. */ 125 The client_type argument is the name of the chip that's on the adapter. */
142struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, 126struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
143 struct i2c_adapter *adapter, 127 struct i2c_adapter *adapter, const char *client_type,
144 const char *module_name, const char *client_type,
145 int irq, void *platform_data,
146 u8 addr, const unsigned short *probe_addrs); 128 u8 addr, const unsigned short *probe_addrs);
147 129
148/* Load an i2c module and return an initialized v4l2_subdev struct.
149 Only call request_module if module_name != NULL.
150 The client_type argument is the name of the chip that's on the adapter. */
151static inline struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
152 struct i2c_adapter *adapter,
153 const char *module_name, const char *client_type,
154 u8 addr, const unsigned short *probe_addrs)
155{
156 return v4l2_i2c_new_subdev_cfg(v4l2_dev, adapter, module_name,
157 client_type, 0, NULL, addr, probe_addrs);
158}
159
160struct i2c_board_info; 130struct i2c_board_info;
161 131
162struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, 132struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
163 struct i2c_adapter *adapter, const char *module_name, 133 struct i2c_adapter *adapter, struct i2c_board_info *info,
164 struct i2c_board_info *info, const unsigned short *probe_addrs); 134 const unsigned short *probe_addrs);
165 135
166/* Initialize an v4l2_subdev with data from an i2c_client struct */ 136/* Initialize an v4l2_subdev with data from an i2c_client struct */
167void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, 137void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
@@ -232,4 +202,14 @@ void v4l_bound_align_image(unsigned int *w, unsigned int wmin,
232 unsigned int hmax, unsigned int halign, 202 unsigned int hmax, unsigned int halign,
233 unsigned int salign); 203 unsigned int salign);
234int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info); 204int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info);
205
206struct v4l2_discrete_probe {
207 const struct v4l2_frmsize_discrete *sizes;
208 int num_sizes;
209};
210
211const struct v4l2_frmsize_discrete *v4l2_find_nearest_format(
212 const struct v4l2_discrete_probe *probe,
213 s32 width, s32 height);
214
235#endif /* V4L2_COMMON_H_ */ 215#endif /* V4L2_COMMON_H_ */
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 9b7bea928a88..97d063837b61 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -23,6 +23,7 @@
23 23
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/videodev2.h>
26 27
27/* forward references */ 28/* forward references */
28struct v4l2_ctrl_handler; 29struct v4l2_ctrl_handler;
@@ -53,8 +54,10 @@ struct v4l2_ctrl_ops {
53 * @handler: The handler that owns the control. 54 * @handler: The handler that owns the control.
54 * @cluster: Point to start of cluster array. 55 * @cluster: Point to start of cluster array.
55 * @ncontrols: Number of controls in cluster array. 56 * @ncontrols: Number of controls in cluster array.
56 * @has_new: Internal flag: set when there is a valid new value.
57 * @done: Internal flag: set for each processed control. 57 * @done: Internal flag: set for each processed control.
58 * @is_new: Set when the user specified a new value for this control. It
59 * is also set when called from v4l2_ctrl_handler_setup. Drivers
60 * should never set this flag.
58 * @is_private: If set, then this control is private to its handler and it 61 * @is_private: If set, then this control is private to its handler and it
59 * will not be added to any other handlers. Drivers can set 62 * will not be added to any other handlers. Drivers can set
60 * this flag. 63 * this flag.
@@ -97,9 +100,9 @@ struct v4l2_ctrl {
97 struct v4l2_ctrl_handler *handler; 100 struct v4l2_ctrl_handler *handler;
98 struct v4l2_ctrl **cluster; 101 struct v4l2_ctrl **cluster;
99 unsigned ncontrols; 102 unsigned ncontrols;
100 unsigned int has_new:1;
101 unsigned int done:1; 103 unsigned int done:1;
102 104
105 unsigned int is_new:1;
103 unsigned int is_private:1; 106 unsigned int is_private:1;
104 unsigned int is_volatile:1; 107 unsigned int is_volatile:1;
105 108
@@ -112,7 +115,7 @@ struct v4l2_ctrl {
112 u32 step; 115 u32 step;
113 u32 menu_skip_mask; 116 u32 menu_skip_mask;
114 }; 117 };
115 const char **qmenu; 118 const char * const *qmenu;
116 unsigned long flags; 119 unsigned long flags;
117 union { 120 union {
118 s32 val; 121 s32 val;
@@ -202,7 +205,7 @@ struct v4l2_ctrl_config {
202 s32 def; 205 s32 def;
203 u32 flags; 206 u32 flags;
204 u32 menu_skip_mask; 207 u32 menu_skip_mask;
205 const char **qmenu; 208 const char * const *qmenu;
206 unsigned int is_private:1; 209 unsigned int is_private:1;
207 unsigned int is_volatile:1; 210 unsigned int is_volatile:1;
208}; 211};
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 1efcacbed01a..c7c40f1d2624 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -16,12 +16,14 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18 18
19#include <media/media-entity.h>
20
19#define VIDEO_MAJOR 81 21#define VIDEO_MAJOR 81
20 22
21#define VFL_TYPE_GRABBER 0 23#define VFL_TYPE_GRABBER 0
22#define VFL_TYPE_VBI 1 24#define VFL_TYPE_VBI 1
23#define VFL_TYPE_RADIO 2 25#define VFL_TYPE_RADIO 2
24#define VFL_TYPE_VTX 3 26#define VFL_TYPE_SUBDEV 3
25#define VFL_TYPE_MAX 4 27#define VFL_TYPE_MAX 4
26 28
27struct v4l2_ioctl_callbacks; 29struct v4l2_ioctl_callbacks;
@@ -33,7 +35,25 @@ struct v4l2_ctrl_handler;
33 Drivers can clear this flag if they want to block all future 35 Drivers can clear this flag if they want to block all future
34 device access. It is cleared by video_unregister_device. */ 36 device access. It is cleared by video_unregister_device. */
35#define V4L2_FL_REGISTERED (0) 37#define V4L2_FL_REGISTERED (0)
38/* file->private_data points to struct v4l2_fh */
36#define V4L2_FL_USES_V4L2_FH (1) 39#define V4L2_FL_USES_V4L2_FH (1)
40/* Use the prio field of v4l2_fh for core priority checking */
41#define V4L2_FL_USE_FH_PRIO (2)
42
43/* Priority helper functions */
44
45struct v4l2_prio_state {
46 atomic_t prios[4];
47};
48
49void v4l2_prio_init(struct v4l2_prio_state *global);
50int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
51 enum v4l2_priority new);
52void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
53void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
54enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
55int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
56
37 57
38struct v4l2_file_operations { 58struct v4l2_file_operations {
39 struct module *owner; 59 struct module *owner;
@@ -57,6 +77,9 @@ struct v4l2_file_operations {
57 77
58struct video_device 78struct video_device
59{ 79{
80#if defined(CONFIG_MEDIA_CONTROLLER)
81 struct media_entity entity;
82#endif
60 /* device ops */ 83 /* device ops */
61 const struct v4l2_file_operations *fops; 84 const struct v4l2_file_operations *fops;
62 85
@@ -71,6 +94,9 @@ struct video_device
71 /* Control handler associated with this device node. May be NULL. */ 94 /* Control handler associated with this device node. May be NULL. */
72 struct v4l2_ctrl_handler *ctrl_handler; 95 struct v4l2_ctrl_handler *ctrl_handler;
73 96
97 /* Priority state. If NULL, then v4l2_dev->prio will be used. */
98 struct v4l2_prio_state *prio;
99
74 /* device info */ 100 /* device info */
75 char name[32]; 101 char name[32];
76 int vfl_type; 102 int vfl_type;
@@ -97,20 +123,36 @@ struct video_device
97 123
98 /* ioctl callbacks */ 124 /* ioctl callbacks */
99 const struct v4l2_ioctl_ops *ioctl_ops; 125 const struct v4l2_ioctl_ops *ioctl_ops;
126
127 /* serialization lock */
128 struct mutex *lock;
100}; 129};
101 130
131#define media_entity_to_video_device(__e) \
132 container_of(__e, struct video_device, entity)
102/* dev to video-device */ 133/* dev to video-device */
103#define to_video_device(cd) container_of(cd, struct video_device, dev) 134#define to_video_device(cd) container_of(cd, struct video_device, dev)
104 135
136int __must_check __video_register_device(struct video_device *vdev, int type,
137 int nr, int warn_if_nr_in_use, struct module *owner);
138
105/* Register video devices. Note that if video_register_device fails, 139/* Register video devices. Note that if video_register_device fails,
106 the release() callback of the video_device structure is *not* called, so 140 the release() callback of the video_device structure is *not* called, so
107 the caller is responsible for freeing any data. Usually that means that 141 the caller is responsible for freeing any data. Usually that means that
108 you call video_device_release() on failure. */ 142 you call video_device_release() on failure. */
109int __must_check video_register_device(struct video_device *vdev, int type, int nr); 143static inline int __must_check video_register_device(struct video_device *vdev,
144 int type, int nr)
145{
146 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
147}
110 148
111/* Same as video_register_device, but no warning is issued if the desired 149/* Same as video_register_device, but no warning is issued if the desired
112 device node number was already in use. */ 150 device node number was already in use. */
113int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr); 151static inline int __must_check video_register_device_no_warn(
152 struct video_device *vdev, int type, int nr)
153{
154 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
155}
114 156
115/* Unregister video devices. Will do nothing if vdev == NULL or 157/* Unregister video devices. Will do nothing if vdev == NULL or
116 video_is_registered() returns false. */ 158 video_is_registered() returns false. */
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 8bcbd7a0271c..d61febfb1668 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -21,7 +21,9 @@
21#ifndef _V4L2_DEVICE_H 21#ifndef _V4L2_DEVICE_H
22#define _V4L2_DEVICE_H 22#define _V4L2_DEVICE_H
23 23
24#include <media/media-device.h>
24#include <media/v4l2-subdev.h> 25#include <media/v4l2-subdev.h>
26#include <media/v4l2-dev.h>
25 27
26/* Each instance of a V4L2 device should create the v4l2_device struct, 28/* Each instance of a V4L2 device should create the v4l2_device struct,
27 either stand-alone or embedded in a larger struct. 29 either stand-alone or embedded in a larger struct.
@@ -39,6 +41,9 @@ struct v4l2_device {
39 Note: dev might be NULL if there is no parent device 41 Note: dev might be NULL if there is no parent device
40 as is the case with e.g. ISA devices. */ 42 as is the case with e.g. ISA devices. */
41 struct device *dev; 43 struct device *dev;
44#if defined(CONFIG_MEDIA_CONTROLLER)
45 struct media_device *mdev;
46#endif
42 /* used to keep track of the registered subdevs */ 47 /* used to keep track of the registered subdevs */
43 struct list_head subdevs; 48 struct list_head subdevs;
44 /* lock this struct; can be used by the driver as well if this 49 /* lock this struct; can be used by the driver as well if this
@@ -51,8 +56,23 @@ struct v4l2_device {
51 unsigned int notification, void *arg); 56 unsigned int notification, void *arg);
52 /* The control handler. May be NULL. */ 57 /* The control handler. May be NULL. */
53 struct v4l2_ctrl_handler *ctrl_handler; 58 struct v4l2_ctrl_handler *ctrl_handler;
59 /* Device's priority state */
60 struct v4l2_prio_state prio;
61 /* BKL replacement mutex. Temporary solution only. */
62 struct mutex ioctl_lock;
63 /* Keep track of the references to this struct. */
64 struct kref ref;
65 /* Release function that is called when the ref count goes to 0. */
66 void (*release)(struct v4l2_device *v4l2_dev);
54}; 67};
55 68
69static inline void v4l2_device_get(struct v4l2_device *v4l2_dev)
70{
71 kref_get(&v4l2_dev->ref);
72}
73
74int v4l2_device_put(struct v4l2_device *v4l2_dev);
75
56/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev. 76/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
57 dev may be NULL in rare cases (ISA devices). In that case you 77 dev may be NULL in rare cases (ISA devices). In that case you
58 must fill in the v4l2_dev->name field before calling this function. */ 78 must fill in the v4l2_dev->name field before calling this function. */
@@ -94,6 +114,12 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
94 wasn't registered. In that case it will do nothing. */ 114 wasn't registered. In that case it will do nothing. */
95void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); 115void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
96 116
117/* Register device nodes for all subdev of the v4l2 device that are marked with
118 * the V4L2_SUBDEV_FL_HAS_DEVNODE flag.
119 */
120int __must_check
121v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
122
97/* Iterate over all subdevs. */ 123/* Iterate over all subdevs. */
98#define v4l2_device_for_each_subdev(sd, v4l2_dev) \ 124#define v4l2_device_for_each_subdev(sd, v4l2_dev) \
99 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) 125 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
@@ -101,46 +127,67 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
101/* Call the specified callback for all subdevs matching the condition. 127/* Call the specified callback for all subdevs matching the condition.
102 Ignore any errors. Note that you cannot add or delete a subdev 128 Ignore any errors. Note that you cannot add or delete a subdev
103 while walking the subdevs list. */ 129 while walking the subdevs list. */
104#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ 130#define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \
105 do { \ 131 do { \
106 struct v4l2_subdev *sd; \ 132 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \
133 if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \
134 (sd)->ops->o->f((sd) , ##args); \
135 } while (0)
136
137#define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \
138 do { \
139 struct v4l2_subdev *__sd; \
107 \ 140 \
108 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) \ 141 __v4l2_device_call_subdevs_p(v4l2_dev, __sd, cond, o, \
109 if ((cond) && sd->ops->o && sd->ops->o->f) \ 142 f , ##args); \
110 sd->ops->o->f(sd , ##args); \
111 } while (0) 143 } while (0)
112 144
113/* Call the specified callback for all subdevs matching the condition. 145/* Call the specified callback for all subdevs matching the condition.
114 If the callback returns an error other than 0 or -ENOIOCTLCMD, then 146 If the callback returns an error other than 0 or -ENOIOCTLCMD, then
115 return with that error code. Note that you cannot add or delete a 147 return with that error code. Note that you cannot add or delete a
116 subdev while walking the subdevs list. */ 148 subdev while walking the subdevs list. */
117#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ 149#define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \
118({ \ 150({ \
119 struct v4l2_subdev *sd; \ 151 long __err = 0; \
120 long err = 0; \
121 \ 152 \
122 list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) { \ 153 list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) { \
123 if ((cond) && sd->ops->o && sd->ops->o->f) \ 154 if ((cond) && (sd)->ops->o && (sd)->ops->o->f) \
124 err = sd->ops->o->f(sd , ##args); \ 155 __err = (sd)->ops->o->f((sd) , ##args); \
125 if (err && err != -ENOIOCTLCMD) \ 156 if (__err && __err != -ENOIOCTLCMD) \
126 break; \ 157 break; \
127 } \ 158 } \
128 (err == -ENOIOCTLCMD) ? 0 : err; \ 159 (__err == -ENOIOCTLCMD) ? 0 : __err; \
160})
161
162#define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \
163({ \
164 struct v4l2_subdev *__sd; \
165 __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, cond, o, \
166 f , ##args); \
129}) 167})
130 168
131/* Call the specified callback for all subdevs matching grp_id (if 0, then 169/* Call the specified callback for all subdevs matching grp_id (if 0, then
132 match them all). Ignore any errors. Note that you cannot add or delete 170 match them all). Ignore any errors. Note that you cannot add or delete
133 a subdev while walking the subdevs list. */ 171 a subdev while walking the subdevs list. */
134#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ 172#define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \
135 __v4l2_device_call_subdevs(v4l2_dev, \ 173 do { \
136 !(grpid) || sd->grp_id == (grpid), o, f , ##args) 174 struct v4l2_subdev *__sd; \
175 \
176 __v4l2_device_call_subdevs_p(v4l2_dev, __sd, \
177 !(grpid) || __sd->grp_id == (grpid), o, f , \
178 ##args); \
179 } while (0)
137 180
138/* Call the specified callback for all subdevs matching grp_id (if 0, then 181/* Call the specified callback for all subdevs matching grp_id (if 0, then
139 match them all). If the callback returns an error other than 0 or 182 match them all). If the callback returns an error other than 0 or
140 -ENOIOCTLCMD, then return with that error code. Note that you cannot 183 -ENOIOCTLCMD, then return with that error code. Note that you cannot
141 add or delete a subdev while walking the subdevs list. */ 184 add or delete a subdev while walking the subdevs list. */
142#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ 185#define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \
143 __v4l2_device_call_subdevs_until_err(v4l2_dev, \ 186({ \
144 !(grpid) || sd->grp_id == (grpid), o, f , ##args) 187 struct v4l2_subdev *__sd; \
188 __v4l2_device_call_subdevs_until_err_p(v4l2_dev, __sd, \
189 !(grpid) || __sd->grp_id == (grpid), o, f , \
190 ##args); \
191})
145 192
146#endif 193#endif
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index 1d72dde320bf..0206aa55be24 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -35,6 +35,7 @@ struct v4l2_fh {
35 struct list_head list; 35 struct list_head list;
36 struct video_device *vdev; 36 struct video_device *vdev;
37 struct v4l2_events *events; /* events, pending and subscribed */ 37 struct v4l2_events *events; /* events, pending and subscribed */
38 enum v4l2_priority prio;
38}; 39};
39 40
40/* 41/*
@@ -50,8 +51,16 @@ int v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev);
50 */ 51 */
51void v4l2_fh_add(struct v4l2_fh *fh); 52void v4l2_fh_add(struct v4l2_fh *fh);
52/* 53/*
54 * Can be used as the open() op of v4l2_file_operations.
55 * It allocates a v4l2_fh and inits and adds it to the video_device associated
56 * with the file pointer.
57 */
58int v4l2_fh_open(struct file *filp);
59/*
53 * Remove file handle from the list of file handles. Must be called in 60 * Remove file handle from the list of file handles. Must be called in
54 * v4l2_file_operations->release() handler if the driver uses v4l2_fh. 61 * v4l2_file_operations->release() handler if the driver uses v4l2_fh.
62 * On error filp->private_data will be NULL, otherwise it will point to
63 * the v4l2_fh struct.
55 */ 64 */
56void v4l2_fh_del(struct v4l2_fh *fh); 65void v4l2_fh_del(struct v4l2_fh *fh);
57/* 66/*
@@ -61,5 +70,25 @@ void v4l2_fh_del(struct v4l2_fh *fh);
61 * driver uses v4l2_fh. 70 * driver uses v4l2_fh.
62 */ 71 */
63void v4l2_fh_exit(struct v4l2_fh *fh); 72void v4l2_fh_exit(struct v4l2_fh *fh);
73/*
74 * Can be used as the release() op of v4l2_file_operations.
75 * It deletes and exits the v4l2_fh associated with the file pointer and
76 * frees it. It will do nothing if filp->private_data (the pointer to the
77 * v4l2_fh struct) is NULL. This function always returns 0.
78 */
79int v4l2_fh_release(struct file *filp);
80/*
81 * Returns 1 if this filehandle is the only filehandle opened for the
82 * associated video_device. If fh is NULL, then it returns 0.
83 */
84int v4l2_fh_is_singular(struct v4l2_fh *fh);
85/*
86 * Helper function with struct file as argument. If filp->private_data is
87 * NULL, then it will return 0.
88 */
89static inline int v4l2_fh_is_singular_file(struct file *filp)
90{
91 return v4l2_fh_is_singular(filp->private_data);
92}
64 93
65#endif /* V4L2_EVENT_H */ 94#endif /* V4L2_EVENT_H */
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h
deleted file mode 100644
index 74bf741d1a9b..000000000000
--- a/include/media/v4l2-i2c-drv.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * v4l2-i2c-drv.h - contains I2C handling code that's identical for
3 * all V4L2 I2C drivers. Use this header if the
4 * I2C driver is only used by drivers converted
5 * to the bus-based I2C API.
6 *
7 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24/* NOTE: the full version of this header is in the v4l-dvb repository
25 * and allows v4l i2c drivers to be compiled on pre-2.6.26 kernels.
26 * The version of this header as it appears in the kernel is a stripped
27 * version (without all the backwards compatibility stuff) and so it
28 * looks a bit odd.
29 *
30 * If you look at the full version then you will understand the reason
31 * for introducing this header since you really don't want to have all
32 * the tricky backwards compatibility code in each and every i2c driver.
33 *
34 * If the i2c driver will never be compiled for pre-2.6.26 kernels, then
35 * DO NOT USE this header! Just write it as a regular i2c driver.
36 */
37
38#ifndef __V4L2_I2C_DRV_H__
39#define __V4L2_I2C_DRV_H__
40
41#include <media/v4l2-common.h>
42
43struct v4l2_i2c_driver_data {
44 const char * const name;
45 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
46 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
47 int (*remove)(struct i2c_client *client);
48 int (*suspend)(struct i2c_client *client, pm_message_t state);
49 int (*resume)(struct i2c_client *client);
50 const struct i2c_device_id *id_table;
51};
52
53static struct v4l2_i2c_driver_data v4l2_i2c_data;
54static struct i2c_driver v4l2_i2c_driver;
55
56
57/* Bus-based I2C implementation for kernels >= 2.6.26 */
58
59static int __init v4l2_i2c_drv_init(void)
60{
61 v4l2_i2c_driver.driver.name = v4l2_i2c_data.name;
62 v4l2_i2c_driver.command = v4l2_i2c_data.command;
63 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
64 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
65 v4l2_i2c_driver.suspend = v4l2_i2c_data.suspend;
66 v4l2_i2c_driver.resume = v4l2_i2c_data.resume;
67 v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table;
68 return i2c_add_driver(&v4l2_i2c_driver);
69}
70
71
72static void __exit v4l2_i2c_drv_cleanup(void)
73{
74 i2c_del_driver(&v4l2_i2c_driver);
75}
76
77module_init(v4l2_i2c_drv_init);
78module_exit(v4l2_i2c_drv_cleanup);
79
80#endif /* __V4L2_I2C_DRV_H__ */
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 06daa6e8e051..dd9f1e7b8ff7 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -14,12 +14,7 @@
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/compiler.h> /* need __user */ 16#include <linux/compiler.h> /* need __user */
17#ifdef CONFIG_VIDEO_V4L1_COMPAT
18#define __MIN_V4L1
19#include <linux/videodev.h>
20#else
21#include <linux/videodev2.h> 17#include <linux/videodev2.h>
22#endif
23 18
24struct v4l2_fh; 19struct v4l2_fh;
25 20
@@ -42,6 +37,10 @@ struct v4l2_ioctl_ops {
42 struct v4l2_fmtdesc *f); 37 struct v4l2_fmtdesc *f);
43 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh, 38 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
44 struct v4l2_fmtdesc *f); 39 struct v4l2_fmtdesc *f);
40 int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file, void *fh,
41 struct v4l2_fmtdesc *f);
42 int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
43 struct v4l2_fmtdesc *f);
45 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, 44 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
46 struct v4l2_fmtdesc *f); 45 struct v4l2_fmtdesc *f);
47 46
@@ -62,6 +61,10 @@ struct v4l2_ioctl_ops {
62 struct v4l2_format *f); 61 struct v4l2_format *f);
63 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh, 62 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
64 struct v4l2_format *f); 63 struct v4l2_format *f);
64 int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
65 struct v4l2_format *f);
66 int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
67 struct v4l2_format *f);
65 int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, 68 int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
66 struct v4l2_format *f); 69 struct v4l2_format *f);
67 70
@@ -82,6 +85,10 @@ struct v4l2_ioctl_ops {
82 struct v4l2_format *f); 85 struct v4l2_format *f);
83 int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh, 86 int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
84 struct v4l2_format *f); 87 struct v4l2_format *f);
88 int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
89 struct v4l2_format *f);
90 int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
91 struct v4l2_format *f);
85 int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, 92 int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
86 struct v4l2_format *f); 93 struct v4l2_format *f);
87 94
@@ -102,6 +109,10 @@ struct v4l2_ioctl_ops {
102 struct v4l2_format *f); 109 struct v4l2_format *f);
103 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh, 110 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
104 struct v4l2_format *f); 111 struct v4l2_format *f);
112 int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
113 struct v4l2_format *f);
114 int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
115 struct v4l2_format *f);
105 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, 116 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
106 struct v4l2_format *f); 117 struct v4l2_format *f);
107 118
@@ -113,10 +124,6 @@ struct v4l2_ioctl_ops {
113 124
114 125
115 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); 126 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
116#ifdef CONFIG_VIDEO_V4L1_COMPAT
117 /* buffer type is struct vidio_mbuf * */
118 int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p);
119#endif
120 int (*vidioc_g_fbuf) (struct file *file, void *fh, 127 int (*vidioc_g_fbuf) (struct file *file, void *fh,
121 struct v4l2_framebuffer *a); 128 struct v4l2_framebuffer *a);
122 int (*vidioc_s_fbuf) (struct file *file, void *fh, 129 int (*vidioc_s_fbuf) (struct file *file, void *fh,
@@ -263,7 +270,7 @@ struct v4l2_ioctl_ops {
263 270
264 /* For other private ioctls */ 271 /* For other private ioctls */
265 long (*vidioc_default) (struct file *file, void *fh, 272 long (*vidioc_default) (struct file *file, void *fh,
266 int cmd, void *arg); 273 bool valid_prio, int cmd, void *arg);
267}; 274};
268 275
269 276
@@ -300,22 +307,15 @@ extern void v4l_printk_ioctl(unsigned int cmd);
300extern const char *v4l2_field_names[]; 307extern const char *v4l2_field_names[];
301extern const char *v4l2_type_names[]; 308extern const char *v4l2_type_names[];
302 309
303/* Compatibility layer interface -- v4l1-compat module */
304typedef long (*v4l2_kioctl)(struct file *file,
305 unsigned int cmd, void *arg);
306#ifdef CONFIG_VIDEO_V4L1_COMPAT
307long v4l_compat_translate_ioctl(struct file *file,
308 int cmd, void *arg, v4l2_kioctl driver_ioctl);
309#else
310#define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL)
311#endif
312
313#ifdef CONFIG_COMPAT 310#ifdef CONFIG_COMPAT
314/* 32 Bits compatibility layer for 64 bits processors */ 311/* 32 Bits compatibility layer for 64 bits processors */
315extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, 312extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
316 unsigned long arg); 313 unsigned long arg);
317#endif 314#endif
318 315
316typedef long (*v4l2_kioctl)(struct file *file,
317 unsigned int cmd, void *arg);
318
319/* Include support for obsoleted stuff */ 319/* Include support for obsoleted stuff */
320extern long video_usercopy(struct file *file, unsigned int cmd, 320extern long video_usercopy(struct file *file, unsigned int cmd,
321 unsigned long arg, v4l2_kioctl func); 321 unsigned long arg, v4l2_kioctl func);
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index f0cf2e7def06..971c7fa29614 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -11,58 +11,7 @@
11#ifndef V4L2_MEDIABUS_H 11#ifndef V4L2_MEDIABUS_H
12#define V4L2_MEDIABUS_H 12#define V4L2_MEDIABUS_H
13 13
14/* 14#include <linux/v4l2-mediabus.h>
15 * These pixel codes uniquely identify data formats on the media bus. Mostly
16 * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
17 * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
18 * data format is fixed. Additionally, "2X8" means that one pixel is transferred
19 * in two 8-bit samples, "BE" or "LE" specify in which order those samples are
20 * transferred over the bus: "LE" means that the least significant bits are
21 * transferred first, "BE" means that the most significant bits are transferred
22 * first, and "PADHI" and "PADLO" define which bits - low or high, in the
23 * incomplete high byte, are filled with padding bits.
24 */
25enum v4l2_mbus_pixelcode {
26 V4L2_MBUS_FMT_FIXED = 1,
27 V4L2_MBUS_FMT_YUYV8_2X8,
28 V4L2_MBUS_FMT_YVYU8_2X8,
29 V4L2_MBUS_FMT_UYVY8_2X8,
30 V4L2_MBUS_FMT_VYUY8_2X8,
31 V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
32 V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
33 V4L2_MBUS_FMT_RGB565_2X8_LE,
34 V4L2_MBUS_FMT_RGB565_2X8_BE,
35 V4L2_MBUS_FMT_SBGGR8_1X8,
36 V4L2_MBUS_FMT_SBGGR10_1X10,
37 V4L2_MBUS_FMT_GREY8_1X8,
38 V4L2_MBUS_FMT_Y10_1X10,
39 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE,
40 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE,
41 V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE,
42 V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE,
43 V4L2_MBUS_FMT_SGRBG8_1X8,
44 V4L2_MBUS_FMT_SBGGR12_1X12,
45 V4L2_MBUS_FMT_YUYV8_1_5X8,
46 V4L2_MBUS_FMT_YVYU8_1_5X8,
47 V4L2_MBUS_FMT_UYVY8_1_5X8,
48 V4L2_MBUS_FMT_VYUY8_1_5X8,
49};
50
51/**
52 * struct v4l2_mbus_framefmt - frame format on the media bus
53 * @width: frame width
54 * @height: frame height
55 * @code: data format code
56 * @field: used interlacing type
57 * @colorspace: colorspace of the data
58 */
59struct v4l2_mbus_framefmt {
60 __u32 width;
61 __u32 height;
62 enum v4l2_mbus_pixelcode code;
63 enum v4l2_field field;
64 enum v4l2_colorspace colorspace;
65};
66 15
67static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, 16static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt,
68 const struct v4l2_mbus_framefmt *mbus_fmt) 17 const struct v4l2_mbus_framefmt *mbus_fmt)
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index 8d149f1c58d0..16ac4733e80d 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -5,7 +5,7 @@
5 * and destination. 5 * and destination.
6 * 6 *
7 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 7 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
8 * Pawel Osciak, <p.osciak@samsung.com> 8 * Pawel Osciak, <pawel@osciak.com>
9 * Marek Szyprowski, <m.szyprowski@samsung.com> 9 * Marek Szyprowski, <m.szyprowski@samsung.com>
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@
17#ifndef _MEDIA_V4L2_MEM2MEM_H 17#ifndef _MEDIA_V4L2_MEM2MEM_H
18#define _MEDIA_V4L2_MEM2MEM_H 18#define _MEDIA_V4L2_MEM2MEM_H
19 19
20#include <media/videobuf-core.h> 20#include <media/videobuf2-core.h>
21 21
22/** 22/**
23 * struct v4l2_m2m_ops - mem-to-mem device driver callbacks 23 * struct v4l2_m2m_ops - mem-to-mem device driver callbacks
@@ -45,17 +45,20 @@ struct v4l2_m2m_ops {
45 void (*device_run)(void *priv); 45 void (*device_run)(void *priv);
46 int (*job_ready)(void *priv); 46 int (*job_ready)(void *priv);
47 void (*job_abort)(void *priv); 47 void (*job_abort)(void *priv);
48 void (*lock)(void *priv);
49 void (*unlock)(void *priv);
48}; 50};
49 51
50struct v4l2_m2m_dev; 52struct v4l2_m2m_dev;
51 53
52struct v4l2_m2m_queue_ctx { 54struct v4l2_m2m_queue_ctx {
53/* private: internal use only */ 55/* private: internal use only */
54 struct videobuf_queue q; 56 struct vb2_queue q;
55 57
56 /* Queue for buffers ready to be processed as soon as this 58 /* Queue for buffers ready to be processed as soon as this
57 * instance receives access to the device */ 59 * instance receives access to the device */
58 struct list_head rdy_queue; 60 struct list_head rdy_queue;
61 spinlock_t rdy_spinlock;
59 u8 num_rdy; 62 u8 num_rdy;
60}; 63};
61 64
@@ -72,19 +75,31 @@ struct v4l2_m2m_ctx {
72 /* For device job queue */ 75 /* For device job queue */
73 struct list_head queue; 76 struct list_head queue;
74 unsigned long job_flags; 77 unsigned long job_flags;
78 wait_queue_head_t finished;
75 79
76 /* Instance private data */ 80 /* Instance private data */
77 void *priv; 81 void *priv;
78}; 82};
79 83
84struct v4l2_m2m_buffer {
85 struct vb2_buffer vb;
86 struct list_head list;
87};
88
80void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev); 89void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev);
81 90
82struct videobuf_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, 91struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx,
83 enum v4l2_buf_type type); 92 enum v4l2_buf_type type);
84 93
85void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, 94void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev,
86 struct v4l2_m2m_ctx *m2m_ctx); 95 struct v4l2_m2m_ctx *m2m_ctx);
87 96
97static inline void
98v4l2_m2m_buf_done(struct vb2_buffer *buf, enum vb2_buffer_state state)
99{
100 vb2_buffer_done(buf, state);
101}
102
88int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 103int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
89 struct v4l2_requestbuffers *reqbufs); 104 struct v4l2_requestbuffers *reqbufs);
90 105
@@ -110,13 +125,13 @@ int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
110struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops); 125struct v4l2_m2m_dev *v4l2_m2m_init(struct v4l2_m2m_ops *m2m_ops);
111void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev); 126void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev);
112 127
113struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(void *priv, struct v4l2_m2m_dev *m2m_dev, 128struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev,
114 void (*vq_init)(void *priv, struct videobuf_queue *, 129 void *drv_priv,
115 enum v4l2_buf_type)); 130 int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq));
131
116void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx); 132void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx);
117 133
118void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct videobuf_queue *vq, 134void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_buffer *vb);
119 struct videobuf_buffer *vb);
120 135
121/** 136/**
122 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for 137 * v4l2_m2m_num_src_bufs_ready() - return the number of source buffers ready for
@@ -138,7 +153,7 @@ unsigned int v4l2_m2m_num_dst_bufs_ready(struct v4l2_m2m_ctx *m2m_ctx)
138 return m2m_ctx->out_q_ctx.num_rdy; 153 return m2m_ctx->out_q_ctx.num_rdy;
139} 154}
140 155
141void *v4l2_m2m_next_buf(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type); 156void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx);
142 157
143/** 158/**
144 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready 159 * v4l2_m2m_next_src_buf() - return next source buffer from the list of ready
@@ -146,7 +161,7 @@ void *v4l2_m2m_next_buf(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type);
146 */ 161 */
147static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx) 162static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx)
148{ 163{
149 return v4l2_m2m_next_buf(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 164 return v4l2_m2m_next_buf(&m2m_ctx->out_q_ctx);
150} 165}
151 166
152/** 167/**
@@ -155,29 +170,28 @@ static inline void *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx)
155 */ 170 */
156static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx) 171static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx)
157{ 172{
158 return v4l2_m2m_next_buf(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 173 return v4l2_m2m_next_buf(&m2m_ctx->cap_q_ctx);
159} 174}
160 175
161/** 176/**
162 * v4l2_m2m_get_src_vq() - return videobuf_queue for source buffers 177 * v4l2_m2m_get_src_vq() - return vb2_queue for source buffers
163 */ 178 */
164static inline 179static inline
165struct videobuf_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx) 180struct vb2_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx)
166{ 181{
167 return v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 182 return &m2m_ctx->out_q_ctx.q;
168} 183}
169 184
170/** 185/**
171 * v4l2_m2m_get_dst_vq() - return videobuf_queue for destination buffers 186 * v4l2_m2m_get_dst_vq() - return vb2_queue for destination buffers
172 */ 187 */
173static inline 188static inline
174struct videobuf_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx) 189struct vb2_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx)
175{ 190{
176 return v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 191 return &m2m_ctx->cap_q_ctx.q;
177} 192}
178 193
179void *v4l2_m2m_buf_remove(struct v4l2_m2m_ctx *m2m_ctx, 194void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx);
180 enum v4l2_buf_type type);
181 195
182/** 196/**
183 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready 197 * v4l2_m2m_src_buf_remove() - take off a source buffer from the list of ready
@@ -185,7 +199,7 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_ctx *m2m_ctx,
185 */ 199 */
186static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) 200static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
187{ 201{
188 return v4l2_m2m_buf_remove(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 202 return v4l2_m2m_buf_remove(&m2m_ctx->out_q_ctx);
189} 203}
190 204
191/** 205/**
@@ -194,7 +208,7 @@ static inline void *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
194 */ 208 */
195static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) 209static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)
196{ 210{
197 return v4l2_m2m_buf_remove(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); 211 return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx);
198} 212}
199 213
200#endif /* _MEDIA_V4L2_MEM2MEM_H */ 214#endif /* _MEDIA_V4L2_MEM2MEM_H */
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 4a97d7341a94..2884e3e69cb1 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -21,7 +21,11 @@
21#ifndef _V4L2_SUBDEV_H 21#ifndef _V4L2_SUBDEV_H
22#define _V4L2_SUBDEV_H 22#define _V4L2_SUBDEV_H
23 23
24#include <linux/v4l2-subdev.h>
25#include <media/media-entity.h>
24#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27#include <media/v4l2-dev.h>
28#include <media/v4l2-fh.h>
25#include <media/v4l2-mediabus.h> 29#include <media/v4l2-mediabus.h>
26 30
27/* generic v4l2_device notify callback notification values */ 31/* generic v4l2_device notify callback notification values */
@@ -36,7 +40,10 @@
36 40
37struct v4l2_device; 41struct v4l2_device;
38struct v4l2_ctrl_handler; 42struct v4l2_ctrl_handler;
43struct v4l2_event_subscription;
44struct v4l2_fh;
39struct v4l2_subdev; 45struct v4l2_subdev;
46struct v4l2_subdev_fh;
40struct tuner_setup; 47struct tuner_setup;
41 48
42/* decode_vbi_line */ 49/* decode_vbi_line */
@@ -106,10 +113,7 @@ struct v4l2_subdev_io_pin_config {
106 u8 strength; /* Pin drive strength */ 113 u8 strength; /* Pin drive strength */
107}; 114};
108 115
109/* s_config: if set, then it is always called by the v4l2_i2c_new_subdev* 116/*
110 functions after the v4l2_subdev was registered. It is used to pass
111 platform data to the subdev which can be used during initialization.
112
113 s_io_pin_config: configure one or more chip I/O pins for chips that 117 s_io_pin_config: configure one or more chip I/O pins for chips that
114 multiplex different internal signal pads out to IO pins. This function 118 multiplex different internal signal pads out to IO pins. This function
115 takes a pointer to an array of 'n' pin configuration entries, one for 119 takes a pointer to an array of 'n' pin configuration entries, one for
@@ -141,7 +145,6 @@ struct v4l2_subdev_io_pin_config {
141struct v4l2_subdev_core_ops { 145struct v4l2_subdev_core_ops {
142 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); 146 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
143 int (*log_status)(struct v4l2_subdev *sd); 147 int (*log_status)(struct v4l2_subdev *sd);
144 int (*s_config)(struct v4l2_subdev *sd, int irq, void *platform_data);
145 int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n, 148 int (*s_io_pin_config)(struct v4l2_subdev *sd, size_t n,
146 struct v4l2_subdev_io_pin_config *pincfg); 149 struct v4l2_subdev_io_pin_config *pincfg);
147 int (*init)(struct v4l2_subdev *sd, u32 val); 150 int (*init)(struct v4l2_subdev *sd, u32 val);
@@ -164,18 +167,26 @@ struct v4l2_subdev_core_ops {
164 int (*s_power)(struct v4l2_subdev *sd, int on); 167 int (*s_power)(struct v4l2_subdev *sd, int on);
165 int (*interrupt_service_routine)(struct v4l2_subdev *sd, 168 int (*interrupt_service_routine)(struct v4l2_subdev *sd,
166 u32 status, bool *handled); 169 u32 status, bool *handled);
170 int (*subscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
171 struct v4l2_event_subscription *sub);
172 int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
173 struct v4l2_event_subscription *sub);
167}; 174};
168 175
169/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. 176/* s_radio: v4l device was opened in radio mode.
170 177
171 s_radio: v4l device was opened in Radio mode, to be replaced by s_mode. 178 g_frequency: freq->type must be filled in. Normally done by video_ioctl2
179 or the bridge driver.
180
181 g_tuner:
182 s_tuner: vt->type must be filled in. Normally done by video_ioctl2 or the
183 bridge driver.
172 184
173 s_type_addr: sets tuner type and its I2C addr. 185 s_type_addr: sets tuner type and its I2C addr.
174 186
175 s_config: sets tda9887 specific stuff, like port1, port2 and qss 187 s_config: sets tda9887 specific stuff, like port1, port2 and qss
176 */ 188 */
177struct v4l2_subdev_tuner_ops { 189struct v4l2_subdev_tuner_ops {
178 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
179 int (*s_radio)(struct v4l2_subdev *sd); 190 int (*s_radio)(struct v4l2_subdev *sd);
180 int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 191 int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
181 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 192 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
@@ -256,15 +267,15 @@ struct v4l2_subdev_video_ops {
256 int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std); 267 int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std);
257 int (*g_input_status)(struct v4l2_subdev *sd, u32 *status); 268 int (*g_input_status)(struct v4l2_subdev *sd, u32 *status);
258 int (*s_stream)(struct v4l2_subdev *sd, int enable); 269 int (*s_stream)(struct v4l2_subdev *sd, int enable);
259 int (*enum_fmt)(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmtdesc);
260 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
261 int (*try_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
262 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
263 int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc); 270 int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc);
264 int (*g_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop); 271 int (*g_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
265 int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop); 272 int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
266 int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 273 int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
267 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 274 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
275 int (*g_frame_interval)(struct v4l2_subdev *sd,
276 struct v4l2_subdev_frame_interval *interval);
277 int (*s_frame_interval)(struct v4l2_subdev *sd,
278 struct v4l2_subdev_frame_interval *interval);
268 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); 279 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
269 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival); 280 int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
270 int (*enum_dv_presets) (struct v4l2_subdev *sd, 281 int (*enum_dv_presets) (struct v4l2_subdev *sd,
@@ -279,6 +290,8 @@ struct v4l2_subdev_video_ops {
279 struct v4l2_dv_timings *timings); 290 struct v4l2_dv_timings *timings);
280 int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index, 291 int (*enum_mbus_fmt)(struct v4l2_subdev *sd, unsigned int index,
281 enum v4l2_mbus_pixelcode *code); 292 enum v4l2_mbus_pixelcode *code);
293 int (*enum_mbus_fsizes)(struct v4l2_subdev *sd,
294 struct v4l2_frmsizeenum *fsize);
282 int (*g_mbus_fmt)(struct v4l2_subdev *sd, 295 int (*g_mbus_fmt)(struct v4l2_subdev *sd,
283 struct v4l2_mbus_framefmt *fmt); 296 struct v4l2_mbus_framefmt *fmt);
284 int (*try_mbus_fmt)(struct v4l2_subdev *sd, 297 int (*try_mbus_fmt)(struct v4l2_subdev *sd,
@@ -332,9 +345,13 @@ struct v4l2_subdev_vbi_ops {
332 * This is needed for some sensors, which always corrupt 345 * This is needed for some sensors, which always corrupt
333 * several top lines of the output image, or which send their 346 * several top lines of the output image, or which send their
334 * metadata in them. 347 * metadata in them.
348 * @g_skip_frames: number of frames to skip at stream start. This is needed for
349 * buggy sensors that generate faulty frames when they are
350 * turned on.
335 */ 351 */
336struct v4l2_subdev_sensor_ops { 352struct v4l2_subdev_sensor_ops {
337 int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines); 353 int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
354 int (*g_skip_frames)(struct v4l2_subdev *sd, u32 *frames);
338}; 355};
339 356
340/* 357/*
@@ -409,6 +426,25 @@ struct v4l2_subdev_ir_ops {
409 struct v4l2_subdev_ir_parameters *params); 426 struct v4l2_subdev_ir_parameters *params);
410}; 427};
411 428
429struct v4l2_subdev_pad_ops {
430 int (*enum_mbus_code)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
431 struct v4l2_subdev_mbus_code_enum *code);
432 int (*enum_frame_size)(struct v4l2_subdev *sd,
433 struct v4l2_subdev_fh *fh,
434 struct v4l2_subdev_frame_size_enum *fse);
435 int (*enum_frame_interval)(struct v4l2_subdev *sd,
436 struct v4l2_subdev_fh *fh,
437 struct v4l2_subdev_frame_interval_enum *fie);
438 int (*get_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
439 struct v4l2_subdev_format *format);
440 int (*set_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
441 struct v4l2_subdev_format *format);
442 int (*set_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
443 struct v4l2_subdev_crop *crop);
444 int (*get_crop)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
445 struct v4l2_subdev_crop *crop);
446};
447
412struct v4l2_subdev_ops { 448struct v4l2_subdev_ops {
413 const struct v4l2_subdev_core_ops *core; 449 const struct v4l2_subdev_core_ops *core;
414 const struct v4l2_subdev_tuner_ops *tuner; 450 const struct v4l2_subdev_tuner_ops *tuner;
@@ -417,24 +453,55 @@ struct v4l2_subdev_ops {
417 const struct v4l2_subdev_vbi_ops *vbi; 453 const struct v4l2_subdev_vbi_ops *vbi;
418 const struct v4l2_subdev_ir_ops *ir; 454 const struct v4l2_subdev_ir_ops *ir;
419 const struct v4l2_subdev_sensor_ops *sensor; 455 const struct v4l2_subdev_sensor_ops *sensor;
456 const struct v4l2_subdev_pad_ops *pad;
457};
458
459/*
460 * Internal ops. Never call this from drivers, only the v4l2 framework can call
461 * these ops.
462 *
463 * registered: called when this subdev is registered. When called the v4l2_dev
464 * field is set to the correct v4l2_device.
465 *
466 * unregistered: called when this subdev is unregistered. When called the
467 * v4l2_dev field is still set to the correct v4l2_device.
468 *
469 * open: called when the subdev device node is opened by an application.
470 *
471 * close: called when the subdev device node is closed.
472 */
473struct v4l2_subdev_internal_ops {
474 int (*registered)(struct v4l2_subdev *sd);
475 void (*unregistered)(struct v4l2_subdev *sd);
476 int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
477 int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
420}; 478};
421 479
422#define V4L2_SUBDEV_NAME_SIZE 32 480#define V4L2_SUBDEV_NAME_SIZE 32
423 481
424/* Set this flag if this subdev is a i2c device. */ 482/* Set this flag if this subdev is a i2c device. */
425#define V4L2_SUBDEV_FL_IS_I2C (1U << 0) 483#define V4L2_SUBDEV_FL_IS_I2C (1U << 0)
426/* Set this flag if this subdev is a spi device. */ 484/* Set this flag if this subdev is a spi device. */
427#define V4L2_SUBDEV_FL_IS_SPI (1U << 1) 485#define V4L2_SUBDEV_FL_IS_SPI (1U << 1)
486/* Set this flag if this subdev needs a device node. */
487#define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2)
488/* Set this flag if this subdev generates events. */
489#define V4L2_SUBDEV_FL_HAS_EVENTS (1U << 3)
428 490
429/* Each instance of a subdev driver should create this struct, either 491/* Each instance of a subdev driver should create this struct, either
430 stand-alone or embedded in a larger struct. 492 stand-alone or embedded in a larger struct.
431 */ 493 */
432struct v4l2_subdev { 494struct v4l2_subdev {
495#if defined(CONFIG_MEDIA_CONTROLLER)
496 struct media_entity entity;
497#endif
433 struct list_head list; 498 struct list_head list;
434 struct module *owner; 499 struct module *owner;
435 u32 flags; 500 u32 flags;
436 struct v4l2_device *v4l2_dev; 501 struct v4l2_device *v4l2_dev;
437 const struct v4l2_subdev_ops *ops; 502 const struct v4l2_subdev_ops *ops;
503 /* Never call these internal ops from within a driver! */
504 const struct v4l2_subdev_internal_ops *internal_ops;
438 /* The control handler of this subdev. May be NULL. */ 505 /* The control handler of this subdev. May be NULL. */
439 struct v4l2_ctrl_handler *ctrl_handler; 506 struct v4l2_ctrl_handler *ctrl_handler;
440 /* name must be unique */ 507 /* name must be unique */
@@ -442,33 +509,72 @@ struct v4l2_subdev {
442 /* can be used to group similar subdevs, value is driver-specific */ 509 /* can be used to group similar subdevs, value is driver-specific */
443 u32 grp_id; 510 u32 grp_id;
444 /* pointer to private data */ 511 /* pointer to private data */
445 void *priv; 512 void *dev_priv;
513 void *host_priv;
514 /* subdev device node */
515 struct video_device devnode;
516 /* number of events to be allocated on open */
517 unsigned int nevents;
446}; 518};
447 519
520#define media_entity_to_v4l2_subdev(ent) \
521 container_of(ent, struct v4l2_subdev, entity)
522#define vdev_to_v4l2_subdev(vdev) \
523 container_of(vdev, struct v4l2_subdev, devnode)
524
525/*
526 * Used for storing subdev information per file handle
527 */
528struct v4l2_subdev_fh {
529 struct v4l2_fh vfh;
530#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
531 struct v4l2_mbus_framefmt *try_fmt;
532 struct v4l2_rect *try_crop;
533#endif
534};
535
536#define to_v4l2_subdev_fh(fh) \
537 container_of(fh, struct v4l2_subdev_fh, vfh)
538
539#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
540static inline struct v4l2_mbus_framefmt *
541v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad)
542{
543 return &fh->try_fmt[pad];
544}
545
546static inline struct v4l2_rect *
547v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad)
548{
549 return &fh->try_crop[pad];
550}
551#endif
552
553extern const struct v4l2_file_operations v4l2_subdev_fops;
554
448static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p) 555static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
449{ 556{
450 sd->priv = p; 557 sd->dev_priv = p;
451} 558}
452 559
453static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd) 560static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
454{ 561{
455 return sd->priv; 562 return sd->dev_priv;
456} 563}
457 564
458static inline void v4l2_subdev_init(struct v4l2_subdev *sd, 565static inline void v4l2_set_subdev_hostdata(struct v4l2_subdev *sd, void *p)
459 const struct v4l2_subdev_ops *ops)
460{ 566{
461 INIT_LIST_HEAD(&sd->list); 567 sd->host_priv = p;
462 /* ops->core MUST be set */
463 BUG_ON(!ops || !ops->core);
464 sd->ops = ops;
465 sd->v4l2_dev = NULL;
466 sd->flags = 0;
467 sd->name[0] = '\0';
468 sd->grp_id = 0;
469 sd->priv = NULL;
470} 568}
471 569
570static inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd)
571{
572 return sd->host_priv;
573}
574
575void v4l2_subdev_init(struct v4l2_subdev *sd,
576 const struct v4l2_subdev_ops *ops);
577
472/* Call an ops of a v4l2_subdev, doing the right checks against 578/* Call an ops of a v4l2_subdev, doing the right checks against
473 NULL pointers. 579 NULL pointers.
474 580
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h
index f2c41cebf453..90ed895e217d 100644
--- a/include/media/videobuf-core.h
+++ b/include/media/videobuf-core.h
@@ -17,10 +17,6 @@
17#define _VIDEOBUF_CORE_H 17#define _VIDEOBUF_CORE_H
18 18
19#include <linux/poll.h> 19#include <linux/poll.h>
20#ifdef CONFIG_VIDEO_V4L1_COMPAT
21#define __MIN_V4L1
22#include <linux/videodev.h>
23#endif
24#include <linux/videodev2.h> 20#include <linux/videodev2.h>
25 21
26#define UNSET (-1U) 22#define UNSET (-1U)
@@ -139,6 +135,7 @@ struct videobuf_qtype_ops {
139 135
140struct videobuf_queue { 136struct videobuf_queue {
141 struct mutex vb_lock; 137 struct mutex vb_lock;
138 struct mutex *ext_lock;
142 spinlock_t *irqlock; 139 spinlock_t *irqlock;
143 struct device *dev; 140 struct device *dev;
144 141
@@ -167,7 +164,20 @@ struct videobuf_queue {
167 void *priv_data; 164 void *priv_data;
168}; 165};
169 166
170int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); 167static inline void videobuf_queue_lock(struct videobuf_queue *q)
168{
169 if (!q->ext_lock)
170 mutex_lock(&q->vb_lock);
171}
172
173static inline void videobuf_queue_unlock(struct videobuf_queue *q)
174{
175 if (!q->ext_lock)
176 mutex_unlock(&q->vb_lock);
177}
178
179int videobuf_waiton(struct videobuf_queue *q, struct videobuf_buffer *vb,
180 int non_blocking, int intr);
171int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, 181int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
172 struct v4l2_framebuffer *fbuf); 182 struct v4l2_framebuffer *fbuf);
173 183
@@ -185,7 +195,8 @@ void videobuf_queue_core_init(struct videobuf_queue *q,
185 enum v4l2_field field, 195 enum v4l2_field field,
186 unsigned int msize, 196 unsigned int msize,
187 void *priv, 197 void *priv,
188 struct videobuf_qtype_ops *int_ops); 198 struct videobuf_qtype_ops *int_ops,
199 struct mutex *ext_lock);
189int videobuf_queue_is_busy(struct videobuf_queue *q); 200int videobuf_queue_is_busy(struct videobuf_queue *q);
190void videobuf_queue_cancel(struct videobuf_queue *q); 201void videobuf_queue_cancel(struct videobuf_queue *q);
191 202
@@ -197,10 +208,6 @@ int videobuf_qbuf(struct videobuf_queue *q,
197 struct v4l2_buffer *b); 208 struct v4l2_buffer *b);
198int videobuf_dqbuf(struct videobuf_queue *q, 209int videobuf_dqbuf(struct videobuf_queue *q,
199 struct v4l2_buffer *b, int nonblocking); 210 struct v4l2_buffer *b, int nonblocking);
200#ifdef CONFIG_VIDEO_V4L1_COMPAT
201int videobuf_cgmbuf(struct videobuf_queue *q,
202 struct video_mbuf *mbuf, int count);
203#endif
204int videobuf_streamon(struct videobuf_queue *q); 211int videobuf_streamon(struct videobuf_queue *q);
205int videobuf_streamoff(struct videobuf_queue *q); 212int videobuf_streamoff(struct videobuf_queue *q);
206 213
diff --git a/include/media/videobuf-dma-contig.h b/include/media/videobuf-dma-contig.h
index ebaa9bc1ee8d..f0ed82543d9f 100644
--- a/include/media/videobuf-dma-contig.h
+++ b/include/media/videobuf-dma-contig.h
@@ -23,7 +23,8 @@ void videobuf_queue_dma_contig_init(struct videobuf_queue *q,
23 enum v4l2_buf_type type, 23 enum v4l2_buf_type type,
24 enum v4l2_field field, 24 enum v4l2_field field,
25 unsigned int msize, 25 unsigned int msize,
26 void *priv); 26 void *priv,
27 struct mutex *ext_lock);
27 28
28dma_addr_t videobuf_to_dma_contig(struct videobuf_buffer *buf); 29dma_addr_t videobuf_to_dma_contig(struct videobuf_buffer *buf);
29void videobuf_dma_contig_free(struct videobuf_queue *q, 30void videobuf_dma_contig_free(struct videobuf_queue *q,
diff --git a/include/media/videobuf-dma-sg.h b/include/media/videobuf-dma-sg.h
index aa4ebb42a565..1c647e8148c4 100644
--- a/include/media/videobuf-dma-sg.h
+++ b/include/media/videobuf-dma-sg.h
@@ -103,7 +103,8 @@ void videobuf_queue_sg_init(struct videobuf_queue *q,
103 enum v4l2_buf_type type, 103 enum v4l2_buf_type type,
104 enum v4l2_field field, 104 enum v4l2_field field,
105 unsigned int msize, 105 unsigned int msize,
106 void *priv); 106 void *priv,
107 struct mutex *ext_lock);
107 108
108#endif /* _VIDEOBUF_DMA_SG_H */ 109#endif /* _VIDEOBUF_DMA_SG_H */
109 110
diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h
index 07cf4b9d0a65..bf365721d6b0 100644
--- a/include/media/videobuf-dvb.h
+++ b/include/media/videobuf-dvb.h
@@ -4,6 +4,9 @@
4#include <dvb_net.h> 4#include <dvb_net.h>
5#include <dvb_frontend.h> 5#include <dvb_frontend.h>
6 6
7#ifndef _VIDEOBUF_DVB_H_
8#define _VIDEOBUF_DVB_H_
9
7struct videobuf_dvb { 10struct videobuf_dvb {
8 /* filling that the job of the driver */ 11 /* filling that the job of the driver */
9 char *name; 12 char *name;
@@ -54,6 +57,7 @@ void videobuf_dvb_dealloc_frontends(struct videobuf_dvb_frontends *f);
54struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id); 57struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id);
55int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p); 58int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p);
56 59
60#endif /* _VIDEOBUF_DVB_H_ */
57 61
58/* 62/*
59 * Local variables: 63 * Local variables:
diff --git a/include/media/videobuf-vmalloc.h b/include/media/videobuf-vmalloc.h
index e19403c18dae..486a97efdb56 100644
--- a/include/media/videobuf-vmalloc.h
+++ b/include/media/videobuf-vmalloc.h
@@ -36,7 +36,8 @@ void videobuf_queue_vmalloc_init(struct videobuf_queue *q,
36 enum v4l2_buf_type type, 36 enum v4l2_buf_type type,
37 enum v4l2_field field, 37 enum v4l2_field field,
38 unsigned int msize, 38 unsigned int msize,
39 void *priv); 39 void *priv,
40 struct mutex *ext_lock);
40 41
41void *videobuf_to_vmalloc(struct videobuf_buffer *buf); 42void *videobuf_to_vmalloc(struct videobuf_buffer *buf);
42 43
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
new file mode 100644
index 000000000000..f87472acbc51
--- /dev/null
+++ b/include/media/videobuf2-core.h
@@ -0,0 +1,380 @@
1/*
2 * videobuf2-core.h - V4L2 driver helper framework
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12#ifndef _MEDIA_VIDEOBUF2_CORE_H
13#define _MEDIA_VIDEOBUF2_CORE_H
14
15#include <linux/mm_types.h>
16#include <linux/mutex.h>
17#include <linux/poll.h>
18#include <linux/videodev2.h>
19
20struct vb2_alloc_ctx;
21struct vb2_fileio_data;
22
23/**
24 * struct vb2_mem_ops - memory handling/memory allocator operations
25 * @alloc: allocate video memory and, optionally, allocator private data,
26 * return NULL on failure or a pointer to allocator private,
27 * per-buffer data on success; the returned private structure
28 * will then be passed as buf_priv argument to other ops in this
29 * structure
30 * @put: inform the allocator that the buffer will no longer be used;
31 * usually will result in the allocator freeing the buffer (if
32 * no other users of this buffer are present); the buf_priv
33 * argument is the allocator private per-buffer structure
34 * previously returned from the alloc callback
35 * @get_userptr: acquire userspace memory for a hardware operation; used for
36 * USERPTR memory types; vaddr is the address passed to the
37 * videobuf layer when queuing a video buffer of USERPTR type;
38 * should return an allocator private per-buffer structure
39 * associated with the buffer on success, NULL on failure;
40 * the returned private structure will then be passed as buf_priv
41 * argument to other ops in this structure
42 * @put_userptr: inform the allocator that a USERPTR buffer will no longer
43 * be used
44 * @vaddr: return a kernel virtual address to a given memory buffer
45 * associated with the passed private structure or NULL if no
46 * such mapping exists
47 * @cookie: return allocator specific cookie for a given memory buffer
48 * associated with the passed private structure or NULL if not
49 * available
50 * @num_users: return the current number of users of a memory buffer;
51 * return 1 if the videobuf layer (or actually the driver using
52 * it) is the only user
53 * @mmap: setup a userspace mapping for a given memory buffer under
54 * the provided virtual memory region
55 *
56 * Required ops for USERPTR types: get_userptr, put_userptr.
57 * Required ops for MMAP types: alloc, put, num_users, mmap.
58 * Required ops for read/write access types: alloc, put, num_users, vaddr
59 */
60struct vb2_mem_ops {
61 void *(*alloc)(void *alloc_ctx, unsigned long size);
62 void (*put)(void *buf_priv);
63
64 void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr,
65 unsigned long size, int write);
66 void (*put_userptr)(void *buf_priv);
67
68 void *(*vaddr)(void *buf_priv);
69 void *(*cookie)(void *buf_priv);
70
71 unsigned int (*num_users)(void *buf_priv);
72
73 int (*mmap)(void *buf_priv, struct vm_area_struct *vma);
74};
75
76struct vb2_plane {
77 void *mem_priv;
78 int mapped:1;
79};
80
81/**
82 * enum vb2_io_modes - queue access methods
83 * @VB2_MMAP: driver supports MMAP with streaming API
84 * @VB2_USERPTR: driver supports USERPTR with streaming API
85 * @VB2_READ: driver supports read() style access
86 * @VB2_WRITE: driver supports write() style access
87 */
88enum vb2_io_modes {
89 VB2_MMAP = (1 << 0),
90 VB2_USERPTR = (1 << 1),
91 VB2_READ = (1 << 2),
92 VB2_WRITE = (1 << 3),
93};
94
95/**
96 * enum vb2_fileio_flags - flags for selecting a mode of the file io emulator,
97 * by default the 'streaming' style is used by the file io emulator
98 * @VB2_FILEIO_READ_ONCE: report EOF after reading the first buffer
99 * @VB2_FILEIO_WRITE_IMMEDIATELY: queue buffer after each write() call
100 */
101enum vb2_fileio_flags {
102 VB2_FILEIO_READ_ONCE = (1 << 0),
103 VB2_FILEIO_WRITE_IMMEDIATELY = (1 << 1),
104};
105
106/**
107 * enum vb2_buffer_state - current video buffer state
108 * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control
109 * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver
110 * @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used
111 * in a hardware operation
112 * @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but
113 * not yet dequeued to userspace
114 * @VB2_BUF_STATE_ERROR: same as above, but the operation on the buffer
115 * has ended with an error, which will be reported
116 * to the userspace when it is dequeued
117 */
118enum vb2_buffer_state {
119 VB2_BUF_STATE_DEQUEUED,
120 VB2_BUF_STATE_QUEUED,
121 VB2_BUF_STATE_ACTIVE,
122 VB2_BUF_STATE_DONE,
123 VB2_BUF_STATE_ERROR,
124};
125
126struct vb2_queue;
127
128/**
129 * struct vb2_buffer - represents a video buffer
130 * @v4l2_buf: struct v4l2_buffer associated with this buffer; can
131 * be read by the driver and relevant entries can be
132 * changed by the driver in case of CAPTURE types
133 * (such as timestamp)
134 * @v4l2_planes: struct v4l2_planes associated with this buffer; can
135 * be read by the driver and relevant entries can be
136 * changed by the driver in case of CAPTURE types
137 * (such as bytesused); NOTE that even for single-planar
138 * types, the v4l2_planes[0] struct should be used
139 * instead of v4l2_buf for filling bytesused - drivers
140 * should use the vb2_set_plane_payload() function for that
141 * @vb2_queue: the queue to which this driver belongs
142 * @num_planes: number of planes in the buffer
143 * on an internal driver queue
144 * @state: current buffer state; do not change
145 * @queued_entry: entry on the queued buffers list, which holds all
146 * buffers queued from userspace
147 * @done_entry: entry on the list that stores all buffers ready to
148 * be dequeued to userspace
149 * @planes: private per-plane information; do not change
150 * @num_planes_mapped: number of mapped planes; do not change
151 */
152struct vb2_buffer {
153 struct v4l2_buffer v4l2_buf;
154 struct v4l2_plane v4l2_planes[VIDEO_MAX_PLANES];
155
156 struct vb2_queue *vb2_queue;
157
158 unsigned int num_planes;
159
160/* Private: internal use only */
161 enum vb2_buffer_state state;
162
163 struct list_head queued_entry;
164 struct list_head done_entry;
165
166 struct vb2_plane planes[VIDEO_MAX_PLANES];
167 unsigned int num_planes_mapped;
168};
169
170/**
171 * struct vb2_ops - driver-specific callbacks
172 *
173 * @queue_setup: called from a VIDIOC_REQBUFS handler, before
174 * memory allocation; driver should return the required
175 * number of buffers in num_buffers, the required number
176 * of planes per buffer in num_planes; the size of each
177 * plane should be set in the sizes[] array and optional
178 * per-plane allocator specific context in alloc_ctxs[]
179 * array
180 * @wait_prepare: release any locks taken while calling vb2 functions;
181 * it is called before an ioctl needs to wait for a new
182 * buffer to arrive; required to avoid a deadlock in
183 * blocking access type
184 * @wait_finish: reacquire all locks released in the previous callback;
185 * required to continue operation after sleeping while
186 * waiting for a new buffer to arrive
187 * @buf_init: called once after allocating a buffer (in MMAP case)
188 * or after acquiring a new USERPTR buffer; drivers may
189 * perform additional buffer-related initialization;
190 * initialization failure (return != 0) will prevent
191 * queue setup from completing successfully; optional
192 * @buf_prepare: called every time the buffer is queued from userspace;
193 * drivers may perform any initialization required before
194 * each hardware operation in this callback;
195 * if an error is returned, the buffer will not be queued
196 * in driver; optional
197 * @buf_finish: called before every dequeue of the buffer back to
198 * userspace; drivers may perform any operations required
199 * before userspace accesses the buffer; optional
200 * @buf_cleanup: called once before the buffer is freed; drivers may
201 * perform any additional cleanup; optional
202 * @start_streaming: called once before entering 'streaming' state; enables
203 * driver to receive buffers over buf_queue() callback
204 * @stop_streaming: called when 'streaming' state must be disabled; driver
205 * should stop any DMA transactions or wait until they
206 * finish and give back all buffers it got from buf_queue()
207 * callback; may use vb2_wait_for_all_buffers() function
208 * @buf_queue: passes buffer vb to the driver; driver may start
209 * hardware operation on this buffer; driver should give
210 * the buffer back by calling vb2_buffer_done() function
211 */
212struct vb2_ops {
213 int (*queue_setup)(struct vb2_queue *q, unsigned int *num_buffers,
214 unsigned int *num_planes, unsigned long sizes[],
215 void *alloc_ctxs[]);
216
217 void (*wait_prepare)(struct vb2_queue *q);
218 void (*wait_finish)(struct vb2_queue *q);
219
220 int (*buf_init)(struct vb2_buffer *vb);
221 int (*buf_prepare)(struct vb2_buffer *vb);
222 int (*buf_finish)(struct vb2_buffer *vb);
223 void (*buf_cleanup)(struct vb2_buffer *vb);
224
225 int (*start_streaming)(struct vb2_queue *q);
226 int (*stop_streaming)(struct vb2_queue *q);
227
228 void (*buf_queue)(struct vb2_buffer *vb);
229};
230
231/**
232 * struct vb2_queue - a videobuf queue
233 *
234 * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h
235 * @io_modes: supported io methods (see vb2_io_modes enum)
236 * @io_flags: additional io flags (see vb2_fileio_flags enum)
237 * @ops: driver-specific callbacks
238 * @mem_ops: memory allocator specific callbacks
239 * @drv_priv: driver private data
240 * @buf_struct_size: size of the driver-specific buffer structure;
241 * "0" indicates the driver doesn't want to use a custom buffer
242 * structure type, so sizeof(struct vb2_buffer) will is used
243 *
244 * @memory: current memory type used
245 * @bufs: videobuf buffer structures
246 * @num_buffers: number of allocated/used buffers
247 * @queued_list: list of buffers currently queued from userspace
248 * @queued_count: number of buffers owned by the driver
249 * @done_list: list of buffers ready to be dequeued to userspace
250 * @done_lock: lock to protect done_list list
251 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued
252 * @alloc_ctx: memory type/allocator-specific contexts for each plane
253 * @streaming: current streaming state
254 * @fileio: file io emulator internal data, used only if emulator is active
255 */
256struct vb2_queue {
257 enum v4l2_buf_type type;
258 unsigned int io_modes;
259 unsigned int io_flags;
260
261 const struct vb2_ops *ops;
262 const struct vb2_mem_ops *mem_ops;
263 void *drv_priv;
264 unsigned int buf_struct_size;
265
266/* private: internal use only */
267 enum v4l2_memory memory;
268 struct vb2_buffer *bufs[VIDEO_MAX_FRAME];
269 unsigned int num_buffers;
270
271 struct list_head queued_list;
272
273 atomic_t queued_count;
274 struct list_head done_list;
275 spinlock_t done_lock;
276 wait_queue_head_t done_wq;
277
278 void *alloc_ctx[VIDEO_MAX_PLANES];
279
280 unsigned int streaming:1;
281
282 struct vb2_fileio_data *fileio;
283};
284
285void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);
286void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no);
287
288void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
289int vb2_wait_for_all_buffers(struct vb2_queue *q);
290
291int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
292int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
293
294int vb2_queue_init(struct vb2_queue *q);
295
296void vb2_queue_release(struct vb2_queue *q);
297
298int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
299int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
300
301int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
302int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
303
304int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma);
305unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
306size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
307 loff_t *ppos, int nonblock);
308size_t vb2_write(struct vb2_queue *q, char __user *data, size_t count,
309 loff_t *ppos, int nonblock);
310
311/**
312 * vb2_is_streaming() - return streaming status of the queue
313 * @q: videobuf queue
314 */
315static inline bool vb2_is_streaming(struct vb2_queue *q)
316{
317 return q->streaming;
318}
319
320/**
321 * vb2_is_busy() - return busy status of the queue
322 * @q: videobuf queue
323 *
324 * This function checks if queue has any buffers allocated.
325 */
326static inline bool vb2_is_busy(struct vb2_queue *q)
327{
328 return (q->num_buffers > 0);
329}
330
331/**
332 * vb2_get_drv_priv() - return driver private data associated with the queue
333 * @q: videobuf queue
334 */
335static inline void *vb2_get_drv_priv(struct vb2_queue *q)
336{
337 return q->drv_priv;
338}
339
340/**
341 * vb2_set_plane_payload() - set bytesused for the plane plane_no
342 * @vb: buffer for which plane payload should be set
343 * @plane_no: plane number for which payload should be set
344 * @size: payload in bytes
345 */
346static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
347 unsigned int plane_no, unsigned long size)
348{
349 if (plane_no < vb->num_planes)
350 vb->v4l2_planes[plane_no].bytesused = size;
351}
352
353/**
354 * vb2_get_plane_payload() - get bytesused for the plane plane_no
355 * @vb: buffer for which plane payload should be set
356 * @plane_no: plane number for which payload should be set
357 * @size: payload in bytes
358 */
359static inline unsigned long vb2_get_plane_payload(struct vb2_buffer *vb,
360 unsigned int plane_no)
361{
362 if (plane_no < vb->num_planes)
363 return vb->v4l2_planes[plane_no].bytesused;
364 return 0;
365}
366
367/**
368 * vb2_plane_size() - return plane size in bytes
369 * @vb: buffer for which plane size should be returned
370 * @plane_no: plane number for which size should be returned
371 */
372static inline unsigned long
373vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no)
374{
375 if (plane_no < vb->num_planes)
376 return vb->v4l2_planes[plane_no].length;
377 return 0;
378}
379
380#endif /* _MEDIA_VIDEOBUF2_CORE_H */
diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
new file mode 100644
index 000000000000..7e6c68b23773
--- /dev/null
+++ b/include/media/videobuf2-dma-contig.h
@@ -0,0 +1,32 @@
1/*
2 * videobuf2-dma-coherent.h - DMA coherent memory allocator for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12
13#ifndef _MEDIA_VIDEOBUF2_DMA_COHERENT_H
14#define _MEDIA_VIDEOBUF2_DMA_COHERENT_H
15
16#include <media/videobuf2-core.h>
17#include <linux/dma-mapping.h>
18
19static inline dma_addr_t
20vb2_dma_contig_plane_paddr(struct vb2_buffer *vb, unsigned int plane_no)
21{
22 dma_addr_t *paddr = vb2_plane_cookie(vb, plane_no);
23
24 return *paddr;
25}
26
27void *vb2_dma_contig_init_ctx(struct device *dev);
28void vb2_dma_contig_cleanup_ctx(void *alloc_ctx);
29
30extern const struct vb2_mem_ops vb2_dma_contig_memops;
31
32#endif
diff --git a/include/media/videobuf2-dma-sg.h b/include/media/videobuf2-dma-sg.h
new file mode 100644
index 000000000000..0038526b8ef7
--- /dev/null
+++ b/include/media/videobuf2-dma-sg.h
@@ -0,0 +1,32 @@
1/*
2 * videobuf2-dma-sg.h - DMA scatter/gather memory allocator for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12
13#ifndef _MEDIA_VIDEOBUF2_DMA_SG_H
14#define _MEDIA_VIDEOBUF2_DMA_SG_H
15
16#include <media/videobuf2-core.h>
17
18struct vb2_dma_sg_desc {
19 unsigned long size;
20 unsigned int num_pages;
21 struct scatterlist *sglist;
22};
23
24static inline struct vb2_dma_sg_desc *vb2_dma_sg_plane_desc(
25 struct vb2_buffer *vb, unsigned int plane_no)
26{
27 return (struct vb2_dma_sg_desc *)vb2_plane_cookie(vb, plane_no);
28}
29
30extern const struct vb2_mem_ops vb2_dma_sg_memops;
31
32#endif
diff --git a/include/media/videobuf2-memops.h b/include/media/videobuf2-memops.h
new file mode 100644
index 000000000000..84e1f6c031c5
--- /dev/null
+++ b/include/media/videobuf2-memops.h
@@ -0,0 +1,45 @@
1/*
2 * videobuf2-memops.h - generic memory handling routines for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 * Marek Szyprowski <m.szyprowski@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation.
12 */
13
14#ifndef _MEDIA_VIDEOBUF2_MEMOPS_H
15#define _MEDIA_VIDEOBUF2_MEMOPS_H
16
17#include <media/videobuf2-core.h>
18
19/**
20 * vb2_vmarea_handler - common vma refcount tracking handler
21 * @refcount: pointer to refcount entry in the buffer
22 * @put: callback to function that decreases buffer refcount
23 * @arg: argument for @put callback
24 */
25struct vb2_vmarea_handler {
26 atomic_t *refcount;
27 void (*put)(void *arg);
28 void *arg;
29};
30
31extern const struct vm_operations_struct vb2_common_vm_ops;
32
33int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size,
34 struct vm_area_struct **res_vma, dma_addr_t *res_pa);
35
36int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,
37 unsigned long size,
38 const struct vm_operations_struct *vm_ops,
39 void *priv);
40
41struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma);
42void vb2_put_vma(struct vm_area_struct *vma);
43
44
45#endif
diff --git a/include/media/videobuf2-vmalloc.h b/include/media/videobuf2-vmalloc.h
new file mode 100644
index 000000000000..93a76b43038d
--- /dev/null
+++ b/include/media/videobuf2-vmalloc.h
@@ -0,0 +1,20 @@
1/*
2 * videobuf2-vmalloc.h - vmalloc memory allocator for videobuf2
3 *
4 * Copyright (C) 2010 Samsung Electronics
5 *
6 * Author: Pawel Osciak <pawel@osciak.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
11 */
12
13#ifndef _MEDIA_VIDEOBUF2_VMALLOC_H
14#define _MEDIA_VIDEOBUF2_VMALLOC_H
15
16#include <media/videobuf2-core.h>
17
18extern const struct vb2_mem_ops vb2_vmalloc_memops;
19
20#endif
diff --git a/include/media/wm8775.h b/include/media/wm8775.h
index 60739c5a23ae..d0e801a9935c 100644
--- a/include/media/wm8775.h
+++ b/include/media/wm8775.h
@@ -32,4 +32,13 @@
32#define WM8775_AIN3 4 32#define WM8775_AIN3 4
33#define WM8775_AIN4 8 33#define WM8775_AIN4 8
34 34
35
36struct wm8775_platform_data {
37 /*
38 * FIXME: Instead, we should parametrize the params
39 * that need different settings between ivtv, pvrusb2, and Nova-S
40 */
41 bool is_nova_s;
42};
43
35#endif 44#endif
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index 4debb4514634..2f7d45bcbd24 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -52,6 +52,7 @@ struct mtd_oob_buf64 {
52#define MTD_NANDFLASH 4 52#define MTD_NANDFLASH 4
53#define MTD_DATAFLASH 6 53#define MTD_DATAFLASH 6
54#define MTD_UBIVOLUME 7 54#define MTD_UBIVOLUME 7
55#define MTD_MLCNANDFLASH 8
55 56
56#define MTD_WRITEABLE 0x400 /* Device is writeable */ 57#define MTD_WRITEABLE 0x400 /* Device is writeable */
57#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */ 58#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */
@@ -119,7 +120,7 @@ struct otp_info {
119#define OTPGETREGIONCOUNT _IOW('M', 14, int) 120#define OTPGETREGIONCOUNT _IOW('M', 14, int)
120#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) 121#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)
121#define OTPLOCK _IOR('M', 16, struct otp_info) 122#define OTPLOCK _IOR('M', 16, struct otp_info)
122#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout) 123#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user)
123#define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) 124#define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats)
124#define MTDFILEMODE _IO('M', 19) 125#define MTDFILEMODE _IO('M', 19)
125#define MEMERASE64 _IOW('M', 20, struct erase_info_user64) 126#define MEMERASE64 _IOW('M', 20, struct erase_info_user64)
@@ -144,13 +145,18 @@ struct nand_oobfree {
144}; 145};
145 146
146#define MTD_MAX_OOBFREE_ENTRIES 8 147#define MTD_MAX_OOBFREE_ENTRIES 8
148#define MTD_MAX_ECCPOS_ENTRIES 64
147/* 149/*
148 * ECC layout control structure. Exported to userspace for 150 * OBSOLETE: ECC layout control structure. Exported to user-space via ioctl
149 * diagnosis and to allow creation of raw images 151 * ECCGETLAYOUT for backwards compatbility and should not be mistaken as a
152 * complete set of ECC information. The ioctl truncates the larger internal
153 * structure to retain binary compatibility with the static declaration of the
154 * ioctl. Note that the "MTD_MAX_..._ENTRIES" macros represent the max size of
155 * the user struct, not the MAX size of the internal struct nand_ecclayout.
150 */ 156 */
151struct nand_ecclayout { 157struct nand_ecclayout_user {
152 __u32 eccbytes; 158 __u32 eccbytes;
153 __u32 eccpos[64]; 159 __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
154 __u32 oobavail; 160 __u32 oobavail;
155 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; 161 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
156}; 162};
diff --git a/include/mtd/mtd-user.h b/include/mtd/mtd-user.h
index aa3c2f86a913..83327c808c86 100644
--- a/include/mtd/mtd-user.h
+++ b/include/mtd/mtd-user.h
@@ -29,6 +29,6 @@ typedef struct mtd_info_user mtd_info_t;
29typedef struct erase_info_user erase_info_t; 29typedef struct erase_info_user erase_info_t;
30typedef struct region_info_user region_info_t; 30typedef struct region_info_user region_info_t;
31typedef struct nand_oobinfo nand_oobinfo_t; 31typedef struct nand_oobinfo nand_oobinfo_t;
32typedef struct nand_ecclayout nand_ecclayout_t; 32typedef struct nand_ecclayout_user nand_ecclayout_t;
33 33
34#endif /* __MTD_USER_H__ */ 34#endif /* __MTD_USER_H__ */
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h
index c0d47ad4b103..3c4109777aff 100644
--- a/include/mtd/ubi-user.h
+++ b/include/mtd/ubi-user.h
@@ -131,7 +131,7 @@
131 * ~~~~~~~~~~~~~~~~~~~~~~~~~ 131 * ~~~~~~~~~~~~~~~~~~~~~~~~~
132 * 132 *
133 * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be 133 * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be
134 * used. A pointer to a &struct ubi_set_prop_req object is expected to be 134 * used. A pointer to a &struct ubi_set_vol_prop_req object is expected to be
135 * passed. The object describes which property should be set, and to which value 135 * passed. The object describes which property should be set, and to which value
136 * it should be set. 136 * it should be set.
137 */ 137 */
@@ -186,7 +186,8 @@
186/* Check if LEB is mapped command */ 186/* Check if LEB is mapped command */
187#define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, __s32) 187#define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, __s32)
188/* Set an UBI volume property */ 188/* Set an UBI volume property */
189#define UBI_IOCSETPROP _IOW(UBI_VOL_IOC_MAGIC, 6, struct ubi_set_prop_req) 189#define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \
190 struct ubi_set_vol_prop_req)
190 191
191/* Maximum MTD device name length supported by UBI */ 192/* Maximum MTD device name length supported by UBI */
192#define MAX_UBI_MTD_NAME_LEN 127 193#define MAX_UBI_MTD_NAME_LEN 127
@@ -223,13 +224,14 @@ enum {
223}; 224};
224 225
225/* 226/*
226 * UBI set property ioctl constants 227 * UBI set volume property ioctl constants.
227 * 228 *
228 * @UBI_PROP_DIRECT_WRITE: allow / disallow user to directly write and 229 * @UBI_VOL_PROP_DIRECT_WRITE: allow (any non-zero value) or disallow (value 0)
229 * erase individual eraseblocks on dynamic volumes 230 * user to directly write and erase individual
231 * eraseblocks on dynamic volumes
230 */ 232 */
231enum { 233enum {
232 UBI_PROP_DIRECT_WRITE = 1, 234 UBI_VOL_PROP_DIRECT_WRITE = 1,
233}; 235};
234 236
235/** 237/**
@@ -308,7 +310,7 @@ struct ubi_mkvol_req {
308 __s16 name_len; 310 __s16 name_len;
309 __s8 padding2[4]; 311 __s8 padding2[4];
310 char name[UBI_MAX_VOLUME_NAME + 1]; 312 char name[UBI_MAX_VOLUME_NAME + 1];
311} __attribute__ ((packed)); 313} __packed;
312 314
313/** 315/**
314 * struct ubi_rsvol_req - a data structure used in volume re-size requests. 316 * struct ubi_rsvol_req - a data structure used in volume re-size requests.
@@ -324,7 +326,7 @@ struct ubi_mkvol_req {
324struct ubi_rsvol_req { 326struct ubi_rsvol_req {
325 __s64 bytes; 327 __s64 bytes;
326 __s32 vol_id; 328 __s32 vol_id;
327} __attribute__ ((packed)); 329} __packed;
328 330
329/** 331/**
330 * struct ubi_rnvol_req - volumes re-name request. 332 * struct ubi_rnvol_req - volumes re-name request.
@@ -366,7 +368,7 @@ struct ubi_rnvol_req {
366 __s8 padding2[2]; 368 __s8 padding2[2];
367 char name[UBI_MAX_VOLUME_NAME + 1]; 369 char name[UBI_MAX_VOLUME_NAME + 1];
368 } ents[UBI_MAX_RNVOL]; 370 } ents[UBI_MAX_RNVOL];
369} __attribute__ ((packed)); 371} __packed;
370 372
371/** 373/**
372 * struct ubi_leb_change_req - a data structure used in atomic LEB change 374 * struct ubi_leb_change_req - a data structure used in atomic LEB change
@@ -381,7 +383,7 @@ struct ubi_leb_change_req {
381 __s32 bytes; 383 __s32 bytes;
382 __s8 dtype; 384 __s8 dtype;
383 __s8 padding[7]; 385 __s8 padding[7];
384} __attribute__ ((packed)); 386} __packed;
385 387
386/** 388/**
387 * struct ubi_map_req - a data structure used in map LEB requests. 389 * struct ubi_map_req - a data structure used in map LEB requests.
@@ -393,20 +395,20 @@ struct ubi_map_req {
393 __s32 lnum; 395 __s32 lnum;
394 __s8 dtype; 396 __s8 dtype;
395 __s8 padding[3]; 397 __s8 padding[3];
396} __attribute__ ((packed)); 398} __packed;
397 399
398 400
399/** 401/**
400 * struct ubi_set_prop_req - a data structure used to set an ubi volume 402 * struct ubi_set_vol_prop_req - a data structure used to set an UBI volume
401 * property. 403 * property.
402 * @property: property to set (%UBI_PROP_DIRECT_WRITE) 404 * @property: property to set (%UBI_VOL_PROP_DIRECT_WRITE)
403 * @padding: reserved for future, not used, has to be zeroed 405 * @padding: reserved for future, not used, has to be zeroed
404 * @value: value to set 406 * @value: value to set
405 */ 407 */
406struct ubi_set_prop_req { 408struct ubi_set_vol_prop_req {
407 __u8 property; 409 __u8 property;
408 __u8 padding[7]; 410 __u8 padding[7];
409 __u64 value; 411 __u64 value;
410} __attribute__ ((packed)); 412} __packed;
411 413
412#endif /* __UBI_USER_H__ */ 414#endif /* __UBI_USER_H__ */
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index a8de812ccbc8..008711e8e78f 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -86,6 +86,8 @@ do { \
86 86
87/** 87/**
88 * enum p9_msg_t - 9P message types 88 * enum p9_msg_t - 9P message types
89 * @P9_TLERROR: not used
90 * @P9_RLERROR: response for any failed request for 9P2000.L
89 * @P9_TSTATFS: file system status request 91 * @P9_TSTATFS: file system status request
90 * @P9_RSTATFS: file system status response 92 * @P9_RSTATFS: file system status response
91 * @P9_TSYMLINK: make symlink request 93 * @P9_TSYMLINK: make symlink request
@@ -117,7 +119,7 @@ do { \
117 * @P9_TREAD: request to transfer data from a file or directory 119 * @P9_TREAD: request to transfer data from a file or directory
118 * @P9_RREAD: response with data requested 120 * @P9_RREAD: response with data requested
119 * @P9_TWRITE: reuqest to transfer data to a file 121 * @P9_TWRITE: reuqest to transfer data to a file
120 * @P9_RWRITE: response with out much data was transfered to file 122 * @P9_RWRITE: response with out much data was transferred to file
121 * @P9_TCLUNK: forget about a handle to an entity within the file system 123 * @P9_TCLUNK: forget about a handle to an entity within the file system
122 * @P9_RCLUNK: response when server has forgotten about the handle 124 * @P9_RCLUNK: response when server has forgotten about the handle
123 * @P9_TREMOVE: request to remove an entity from the hierarchy 125 * @P9_TREMOVE: request to remove an entity from the hierarchy
@@ -137,6 +139,8 @@ do { \
137 */ 139 */
138 140
139enum p9_msg_t { 141enum p9_msg_t {
142 P9_TLERROR = 6,
143 P9_RLERROR,
140 P9_TSTATFS = 8, 144 P9_TSTATFS = 8,
141 P9_RSTATFS, 145 P9_RSTATFS,
142 P9_TLOPEN = 12, 146 P9_TLOPEN = 12,
@@ -149,6 +153,8 @@ enum p9_msg_t {
149 P9_RMKNOD, 153 P9_RMKNOD,
150 P9_TRENAME = 20, 154 P9_TRENAME = 20,
151 P9_RRENAME, 155 P9_RRENAME,
156 P9_TREADLINK = 22,
157 P9_RREADLINK,
152 P9_TGETATTR = 24, 158 P9_TGETATTR = 24,
153 P9_RGETATTR, 159 P9_RGETATTR,
154 P9_TSETATTR = 26, 160 P9_TSETATTR = 26,
@@ -159,6 +165,12 @@ enum p9_msg_t {
159 P9_RXATTRCREATE, 165 P9_RXATTRCREATE,
160 P9_TREADDIR = 40, 166 P9_TREADDIR = 40,
161 P9_RREADDIR, 167 P9_RREADDIR,
168 P9_TFSYNC = 50,
169 P9_RFSYNC,
170 P9_TLOCK = 52,
171 P9_RLOCK,
172 P9_TGETLOCK = 54,
173 P9_RGETLOCK,
162 P9_TLINK = 70, 174 P9_TLINK = 70,
163 P9_RLINK, 175 P9_RLINK,
164 P9_TMKDIR = 72, 176 P9_TMKDIR = 72,
@@ -229,10 +241,10 @@ enum p9_open_mode_t {
229 241
230/** 242/**
231 * enum p9_perm_t - 9P permissions 243 * enum p9_perm_t - 9P permissions
232 * @P9_DMDIR: mode bite for directories 244 * @P9_DMDIR: mode bit for directories
233 * @P9_DMAPPEND: mode bit for is append-only 245 * @P9_DMAPPEND: mode bit for is append-only
234 * @P9_DMEXCL: mode bit for excluse use (only one open handle allowed) 246 * @P9_DMEXCL: mode bit for excluse use (only one open handle allowed)
235 * @P9_DMMOUNT: mode bite for mount points 247 * @P9_DMMOUNT: mode bit for mount points
236 * @P9_DMAUTH: mode bit for authentication file 248 * @P9_DMAUTH: mode bit for authentication file
237 * @P9_DMTMP: mode bit for non-backed-up files 249 * @P9_DMTMP: mode bit for non-backed-up files
238 * @P9_DMSYMLINK: mode bit for symbolic links (9P2000.u) 250 * @P9_DMSYMLINK: mode bit for symbolic links (9P2000.u)
@@ -280,7 +292,7 @@ enum p9_perm_t {
280 * 292 *
281 * QID types are a subset of permissions - they are primarily 293 * QID types are a subset of permissions - they are primarily
282 * used to differentiate semantics for a file system entity via 294 * used to differentiate semantics for a file system entity via
283 * a jump-table. Their value is also the most signifigant 16 bits 295 * a jump-table. Their value is also the most significant 16 bits
284 * of the permission_t 296 * of the permission_t
285 * 297 *
286 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat 298 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
@@ -350,10 +362,10 @@ struct p9_qid {
350}; 362};
351 363
352/** 364/**
353 * struct p9_stat - file system metadata information 365 * struct p9_wstat - file system metadata information
354 * @size: length prefix for this stat structure instance 366 * @size: length prefix for this stat structure instance
355 * @type: the type of the server (equivilent to a major number) 367 * @type: the type of the server (equivalent to a major number)
356 * @dev: the sub-type of the server (equivilent to a minor number) 368 * @dev: the sub-type of the server (equivalent to a minor number)
357 * @qid: unique id from the server of type &p9_qid 369 * @qid: unique id from the server of type &p9_qid
358 * @mode: Plan 9 format permissions of type &p9_perm_t 370 * @mode: Plan 9 format permissions of type &p9_perm_t
359 * @atime: Last access/read time 371 * @atime: Last access/read time
@@ -458,6 +470,48 @@ struct p9_iattr_dotl {
458 u64 mtime_nsec; 470 u64 mtime_nsec;
459}; 471};
460 472
473#define P9_LOCK_SUCCESS 0
474#define P9_LOCK_BLOCKED 1
475#define P9_LOCK_ERROR 2
476#define P9_LOCK_GRACE 3
477
478#define P9_LOCK_FLAGS_BLOCK 1
479#define P9_LOCK_FLAGS_RECLAIM 2
480
481/* struct p9_flock: POSIX lock structure
482 * @type - type of lock
483 * @flags - lock flags
484 * @start - starting offset of the lock
485 * @length - number of bytes
486 * @proc_id - process id which wants to take lock
487 * @client_id - client id
488 */
489
490struct p9_flock {
491 u8 type;
492 u32 flags;
493 u64 start;
494 u64 length;
495 u32 proc_id;
496 char *client_id;
497};
498
499/* struct p9_getlock: getlock structure
500 * @type - type of lock
501 * @start - starting offset of the lock
502 * @length - number of bytes
503 * @proc_id - process id which wants to take lock
504 * @client_id - client id
505 */
506
507struct p9_getlock {
508 u8 type;
509 u64 start;
510 u64 length;
511 u32 proc_id;
512 char *client_id;
513};
514
461/* Structures for Protocol Operations */ 515/* Structures for Protocol Operations */
462struct p9_tstatfs { 516struct p9_tstatfs {
463 u32 fid; 517 u32 fid;
@@ -633,8 +687,12 @@ struct p9_rwstat {
633 * @size: prefixed length of the structure 687 * @size: prefixed length of the structure
634 * @id: protocol operating identifier of type &p9_msg_t 688 * @id: protocol operating identifier of type &p9_msg_t
635 * @tag: transaction id of the request 689 * @tag: transaction id of the request
636 * @offset: used by marshalling routines to track currentposition in buffer 690 * @offset: used by marshalling routines to track current position in buffer
637 * @capacity: used by marshalling routines to track total capacity 691 * @capacity: used by marshalling routines to track total malloc'd capacity
692 * @pubuf: Payload user buffer given by the caller
693 * @pkbuf: Payload kernel buffer given by the caller
694 * @pbuf_size: pubuf/pkbuf(only one will be !NULL) size to be read/write.
695 * @private: For transport layer's use.
638 * @sdata: payload 696 * @sdata: payload
639 * 697 *
640 * &p9_fcall represents the structure for all 9P RPC 698 * &p9_fcall represents the structure for all 9P RPC
@@ -651,8 +709,12 @@ struct p9_fcall {
651 709
652 size_t offset; 710 size_t offset;
653 size_t capacity; 711 size_t capacity;
712 char __user *pubuf;
713 char *pkbuf;
714 size_t pbuf_size;
715 void *private;
654 716
655 uint8_t *sdata; 717 u8 *sdata;
656}; 718};
657 719
658struct p9_idpool; 720struct p9_idpool;
@@ -666,7 +728,6 @@ void p9_idpool_put(int id, struct p9_idpool *p);
666int p9_idpool_check(int id, struct p9_idpool *p); 728int p9_idpool_check(int id, struct p9_idpool *p);
667 729
668int p9_error_init(void); 730int p9_error_init(void);
669int p9_errstr2errno(char *, int);
670int p9_trans_fd_init(void); 731int p9_trans_fd_init(void);
671void p9_trans_fd_exit(void); 732void p9_trans_fd_exit(void);
672#endif /* NET_9P_H */ 733#endif /* NET_9P_H */
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index d1aa2cfb30f0..d26d5e98a173 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -60,7 +60,7 @@ enum p9_trans_status {
60}; 60};
61 61
62/** 62/**
63 * enum p9_req_status_t - virtio request status 63 * enum p9_req_status_t - status of a request
64 * @REQ_STATUS_IDLE: request slot unused 64 * @REQ_STATUS_IDLE: request slot unused
65 * @REQ_STATUS_ALLOC: request has been allocated but not sent 65 * @REQ_STATUS_ALLOC: request has been allocated but not sent
66 * @REQ_STATUS_UNSENT: request waiting to be sent 66 * @REQ_STATUS_UNSENT: request waiting to be sent
@@ -101,7 +101,7 @@ enum p9_req_status_t {
101 * Transport use an array to track outstanding requests 101 * Transport use an array to track outstanding requests
102 * instead of a list. While this may incurr overhead during initial 102 * instead of a list. While this may incurr overhead during initial
103 * allocation or expansion, it makes request lookup much easier as the 103 * allocation or expansion, it makes request lookup much easier as the
104 * tag id is a index into an array. (We use tag+1 so that we can accomodate 104 * tag id is a index into an array. (We use tag+1 so that we can accommodate
105 * the -1 tag for the T_VERSION request). 105 * the -1 tag for the T_VERSION request).
106 * This also has the nice effect of only having to allocate wait_queues 106 * This also has the nice effect of only having to allocate wait_queues
107 * once, instead of constantly allocating and freeing them. Its possible 107 * once, instead of constantly allocating and freeing them. Its possible
@@ -212,17 +212,14 @@ struct p9_dirent {
212 212
213int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb); 213int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb);
214int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name); 214int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name);
215int p9_client_version(struct p9_client *);
216struct p9_client *p9_client_create(const char *dev_name, char *options); 215struct p9_client *p9_client_create(const char *dev_name, char *options);
217void p9_client_destroy(struct p9_client *clnt); 216void p9_client_destroy(struct p9_client *clnt);
218void p9_client_disconnect(struct p9_client *clnt); 217void p9_client_disconnect(struct p9_client *clnt);
219void p9_client_begin_disconnect(struct p9_client *clnt); 218void p9_client_begin_disconnect(struct p9_client *clnt);
220struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, 219struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
221 char *uname, u32 n_uname, char *aname); 220 char *uname, u32 n_uname, char *aname);
222struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname, 221struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
223 u32 n_uname, char *aname); 222 char **wnames, int clone);
224struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
225 int clone);
226int p9_client_open(struct p9_fid *fid, int mode); 223int p9_client_open(struct p9_fid *fid, int mode);
227int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, 224int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
228 char *extension); 225 char *extension);
@@ -232,6 +229,7 @@ int p9_client_symlink(struct p9_fid *fid, char *name, char *symname, gid_t gid,
232int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode, 229int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode,
233 gid_t gid, struct p9_qid *qid); 230 gid_t gid, struct p9_qid *qid);
234int p9_client_clunk(struct p9_fid *fid); 231int p9_client_clunk(struct p9_fid *fid);
232int p9_client_fsync(struct p9_fid *fid, int datasync);
235int p9_client_remove(struct p9_fid *fid); 233int p9_client_remove(struct p9_fid *fid);
236int p9_client_read(struct p9_fid *fid, char *data, char __user *udata, 234int p9_client_read(struct p9_fid *fid, char *data, char __user *udata,
237 u64 offset, u32 count); 235 u64 offset, u32 count);
@@ -251,6 +249,8 @@ int p9_client_mknod_dotl(struct p9_fid *oldfid, char *name, int mode,
251 dev_t rdev, gid_t gid, struct p9_qid *); 249 dev_t rdev, gid_t gid, struct p9_qid *);
252int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode, 250int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode,
253 gid_t gid, struct p9_qid *); 251 gid_t gid, struct p9_qid *);
252int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status);
253int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl);
254struct p9_req_t *p9_tag_lookup(struct p9_client *, u16); 254struct p9_req_t *p9_tag_lookup(struct p9_client *, u16);
255void p9_client_cb(struct p9_client *c, struct p9_req_t *req); 255void p9_client_cb(struct p9_client *c, struct p9_req_t *req);
256 256
@@ -262,5 +262,6 @@ int p9_is_proto_dotu(struct p9_client *clnt);
262int p9_is_proto_dotl(struct p9_client *clnt); 262int p9_is_proto_dotl(struct p9_client *clnt);
263struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *); 263struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *);
264int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int); 264int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int);
265int p9_client_readlink(struct p9_fid *fid, char **target);
265 266
266#endif /* NET_9P_CLIENT_H */ 267#endif /* NET_9P_CLIENT_H */
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index 6d5886efb102..d8549fb9c742 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -26,13 +26,22 @@
26#ifndef NET_9P_TRANSPORT_H 26#ifndef NET_9P_TRANSPORT_H
27#define NET_9P_TRANSPORT_H 27#define NET_9P_TRANSPORT_H
28 28
29#define P9_TRANS_PREF_PAYLOAD_MASK 0x1
30
31/* Default. Add Payload to PDU before sending it down to transport layer */
32#define P9_TRANS_PREF_PAYLOAD_DEF 0x0
33/* Send pay load separately to transport layer along with PDU.*/
34#define P9_TRANS_PREF_PAYLOAD_SEP 0x1
35
29/** 36/**
30 * struct p9_trans_module - transport module interface 37 * struct p9_trans_module - transport module interface
31 * @list: used to maintain a list of currently available transports 38 * @list: used to maintain a list of currently available transports
32 * @name: the human-readable name of the transport 39 * @name: the human-readable name of the transport
33 * @maxsize: transport provided maximum packet size 40 * @maxsize: transport provided maximum packet size
41 * @pref: Preferences of this transport
34 * @def: set if this transport should be considered the default 42 * @def: set if this transport should be considered the default
35 * @create: member function to create a new connection on this transport 43 * @create: member function to create a new connection on this transport
44 * @close: member function to discard a connection on this transport
36 * @request: member function to issue a request to the transport 45 * @request: member function to issue a request to the transport
37 * @cancel: member function to cancel a request (if it hasn't been sent) 46 * @cancel: member function to cancel a request (if it hasn't been sent)
38 * 47 *
@@ -40,13 +49,14 @@
40 * transport module with the 9P core network module and used by the client 49 * transport module with the 9P core network module and used by the client
41 * to instantiate a new connection on a transport. 50 * to instantiate a new connection on a transport.
42 * 51 *
43 * BUGS: the transport module list isn't protected. 52 * The transport module list is protected by v9fs_trans_lock.
44 */ 53 */
45 54
46struct p9_trans_module { 55struct p9_trans_module {
47 struct list_head list; 56 struct list_head list;
48 char *name; /* name of transport */ 57 char *name; /* name of transport */
49 int maxsize; /* max message size of transport */ 58 int maxsize; /* max message size of transport */
59 int pref; /* Preferences of this transport */
50 int def; /* this transport should be default */ 60 int def; /* this transport should be default */
51 struct module *owner; 61 struct module *owner;
52 int (*create)(struct p9_client *, const char *, char *); 62 int (*create)(struct p9_client *, const char *, char *);
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 4d40c4d0230b..582e4ae70753 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -1,8 +1,6 @@
1#ifndef _ADDRCONF_H 1#ifndef _ADDRCONF_H
2#define _ADDRCONF_H 2#define _ADDRCONF_H
3 3
4#define RETRANS_TIMER HZ
5
6#define MAX_RTR_SOLICITATIONS 3 4#define MAX_RTR_SOLICITATIONS 3
7#define RTR_SOLICITATION_INTERVAL (4*HZ) 5#define RTR_SOLICITATION_INTERVAL (4*HZ)
8 6
@@ -44,8 +42,6 @@ struct prefix_info {
44}; 42};
45 43
46 44
47#ifdef __KERNEL__
48
49#include <linux/netdevice.h> 45#include <linux/netdevice.h>
50#include <net/if_inet6.h> 46#include <net/if_inet6.h>
51#include <net/ipv6.h> 47#include <net/ipv6.h>
@@ -63,16 +59,16 @@ extern int addrconf_set_dstaddr(struct net *net,
63 void __user *arg); 59 void __user *arg);
64 60
65extern int ipv6_chk_addr(struct net *net, 61extern int ipv6_chk_addr(struct net *net,
66 struct in6_addr *addr, 62 const struct in6_addr *addr,
67 struct net_device *dev, 63 struct net_device *dev,
68 int strict); 64 int strict);
69 65
70#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 66#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
71extern int ipv6_chk_home_addr(struct net *net, 67extern int ipv6_chk_home_addr(struct net *net,
72 struct in6_addr *addr); 68 const struct in6_addr *addr);
73#endif 69#endif
74 70
75extern int ipv6_chk_prefix(struct in6_addr *addr, 71extern int ipv6_chk_prefix(const struct in6_addr *addr,
76 struct net_device *dev); 72 struct net_device *dev);
77 73
78extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, 74extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
@@ -91,9 +87,9 @@ extern int ipv6_get_lladdr(struct net_device *dev,
91extern int ipv6_rcv_saddr_equal(const struct sock *sk, 87extern int ipv6_rcv_saddr_equal(const struct sock *sk,
92 const struct sock *sk2); 88 const struct sock *sk2);
93extern void addrconf_join_solict(struct net_device *dev, 89extern void addrconf_join_solict(struct net_device *dev,
94 struct in6_addr *addr); 90 const struct in6_addr *addr);
95extern void addrconf_leave_solict(struct inet6_dev *idev, 91extern void addrconf_leave_solict(struct inet6_dev *idev,
96 struct in6_addr *addr); 92 const struct in6_addr *addr);
97 93
98static inline unsigned long addrconf_timeout_fixup(u32 timeout, 94static inline unsigned long addrconf_timeout_fixup(u32 timeout,
99 unsigned unit) 95 unsigned unit)
@@ -160,35 +156,47 @@ extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len);
160/* 156/*
161 * anycast prototypes (anycast.c) 157 * anycast prototypes (anycast.c)
162 */ 158 */
163extern int ipv6_sock_ac_join(struct sock *sk,int ifindex,struct in6_addr *addr); 159extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr);
164extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex,struct in6_addr *addr); 160extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr);
165extern void ipv6_sock_ac_close(struct sock *sk); 161extern void ipv6_sock_ac_close(struct sock *sk);
166extern int inet6_ac_check(struct sock *sk, struct in6_addr *addr, int ifindex); 162extern int inet6_ac_check(struct sock *sk, const struct in6_addr *addr, int ifindex);
167 163
168extern int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr); 164extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
169extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, struct in6_addr *addr); 165extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
170extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev, 166extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
171 struct in6_addr *addr); 167 const struct in6_addr *addr);
172 168
173 169
174/* Device notifier */ 170/* Device notifier */
175extern int register_inet6addr_notifier(struct notifier_block *nb); 171extern int register_inet6addr_notifier(struct notifier_block *nb);
176extern int unregister_inet6addr_notifier(struct notifier_block *nb); 172extern int unregister_inet6addr_notifier(struct notifier_block *nb);
177 173
178static inline struct inet6_dev * 174/**
179__in6_dev_get(struct net_device *dev) 175 * __in6_dev_get - get inet6_dev pointer from netdevice
176 * @dev: network device
177 *
178 * Caller must hold rcu_read_lock or RTNL, because this function
179 * does not take a reference on the inet6_dev.
180 */
181static inline struct inet6_dev *__in6_dev_get(const struct net_device *dev)
180{ 182{
181 return rcu_dereference_check(dev->ip6_ptr, 183 return rcu_dereference_rtnl(dev->ip6_ptr);
182 rcu_read_lock_held() ||
183 lockdep_rtnl_is_held());
184} 184}
185 185
186static inline struct inet6_dev * 186/**
187in6_dev_get(struct net_device *dev) 187 * in6_dev_get - get inet6_dev pointer from netdevice
188 * @dev: network device
189 *
190 * This version can be used in any context, and takes a reference
191 * on the inet6_dev. Callers must use in6_dev_put() later to
192 * release this reference.
193 */
194static inline struct inet6_dev *in6_dev_get(const struct net_device *dev)
188{ 195{
189 struct inet6_dev *idev = NULL; 196 struct inet6_dev *idev;
197
190 rcu_read_lock(); 198 rcu_read_lock();
191 idev = __in6_dev_get(dev); 199 idev = rcu_dereference(dev->ip6_ptr);
192 if (idev) 200 if (idev)
193 atomic_inc(&idev->refcnt); 201 atomic_inc(&idev->refcnt);
194 rcu_read_unlock(); 202 rcu_read_unlock();
@@ -197,16 +205,21 @@ in6_dev_get(struct net_device *dev)
197 205
198extern void in6_dev_finish_destroy(struct inet6_dev *idev); 206extern void in6_dev_finish_destroy(struct inet6_dev *idev);
199 207
200static inline void 208static inline void in6_dev_put(struct inet6_dev *idev)
201in6_dev_put(struct inet6_dev *idev)
202{ 209{
203 if (atomic_dec_and_test(&idev->refcnt)) 210 if (atomic_dec_and_test(&idev->refcnt))
204 in6_dev_finish_destroy(idev); 211 in6_dev_finish_destroy(idev);
205} 212}
206 213
207#define __in6_dev_put(idev) atomic_dec(&(idev)->refcnt) 214static inline void __in6_dev_put(struct inet6_dev *idev)
208#define in6_dev_hold(idev) atomic_inc(&(idev)->refcnt) 215{
216 atomic_dec(&idev->refcnt);
217}
209 218
219static inline void in6_dev_hold(struct inet6_dev *idev)
220{
221 atomic_inc(&idev->refcnt);
222}
210 223
211extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp); 224extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
212 225
@@ -216,9 +229,15 @@ static inline void in6_ifa_put(struct inet6_ifaddr *ifp)
216 inet6_ifa_finish_destroy(ifp); 229 inet6_ifa_finish_destroy(ifp);
217} 230}
218 231
219#define __in6_ifa_put(ifp) atomic_dec(&(ifp)->refcnt) 232static inline void __in6_ifa_put(struct inet6_ifaddr *ifp)
220#define in6_ifa_hold(ifp) atomic_inc(&(ifp)->refcnt) 233{
234 atomic_dec(&ifp->refcnt);
235}
221 236
237static inline void in6_ifa_hold(struct inet6_ifaddr *ifp)
238{
239 atomic_inc(&ifp->refcnt);
240}
222 241
223 242
224/* 243/*
@@ -241,23 +260,21 @@ static inline int ipv6_addr_is_multicast(const struct in6_addr *addr)
241 260
242static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) 261static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr)
243{ 262{
244 return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | 263 return ((addr->s6_addr32[0] ^ htonl(0xff020000)) |
245 addr->s6_addr32[1] | addr->s6_addr32[2] | 264 addr->s6_addr32[1] | addr->s6_addr32[2] |
246 (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0); 265 (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0;
247} 266}
248 267
249static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) 268static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr)
250{ 269{
251 return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | 270 return ((addr->s6_addr32[0] ^ htonl(0xff020000)) |
252 addr->s6_addr32[1] | addr->s6_addr32[2] | 271 addr->s6_addr32[1] | addr->s6_addr32[2] |
253 (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0); 272 (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0;
254} 273}
255 274
256extern int __ipv6_isatap_ifid(u8 *eui, __be32 addr);
257
258static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) 275static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
259{ 276{
260 return ((addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE)); 277 return (addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE);
261} 278}
262 279
263#ifdef CONFIG_PROC_FS 280#ifdef CONFIG_PROC_FS
@@ -266,4 +283,3 @@ extern void if6_proc_exit(void);
266#endif 283#endif
267 284
268#endif 285#endif
269#endif
diff --git a/include/net/af_rxrpc.h b/include/net/af_rxrpc.h
index 00c2eaa07c25..03e6e9453623 100644
--- a/include/net/af_rxrpc.h
+++ b/include/net/af_rxrpc.h
@@ -12,8 +12,6 @@
12#ifndef _NET_RXRPC_H 12#ifndef _NET_RXRPC_H
13#define _NET_RXRPC_H 13#define _NET_RXRPC_H
14 14
15#ifdef __KERNEL__
16
17#include <linux/rxrpc.h> 15#include <linux/rxrpc.h>
18 16
19struct rxrpc_call; 17struct rxrpc_call;
@@ -53,5 +51,4 @@ extern struct rxrpc_call *rxrpc_kernel_accept_call(struct socket *,
53 unsigned long); 51 unsigned long);
54extern int rxrpc_kernel_reject_call(struct socket *); 52extern int rxrpc_kernel_reject_call(struct socket *);
55 53
56#endif /* __KERNEL__ */
57#endif /* _NET_RXRPC_H */ 54#endif /* _NET_RXRPC_H */
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 90c9e2872f27..91ab5b01678a 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -10,6 +10,7 @@ extern void unix_inflight(struct file *fp);
10extern void unix_notinflight(struct file *fp); 10extern void unix_notinflight(struct file *fp);
11extern void unix_gc(void); 11extern void unix_gc(void);
12extern void wait_for_unix_gc(void); 12extern void wait_for_unix_gc(void);
13extern struct sock *unix_get_socket(struct file *filp);
13 14
14#define UNIX_HASH_SIZE 256 15#define UNIX_HASH_SIZE 256
15 16
@@ -40,7 +41,6 @@ struct unix_skb_parms {
40 spin_lock_nested(&unix_sk(s)->lock, \ 41 spin_lock_nested(&unix_sk(s)->lock, \
41 SINGLE_DEPTH_NESTING) 42 SINGLE_DEPTH_NESTING)
42 43
43#ifdef __KERNEL__
44/* The AF_UNIX socket */ 44/* The AF_UNIX socket */
45struct unix_sock { 45struct unix_sock {
46 /* WARNING: sk has to be the first member */ 46 /* WARNING: sk has to be the first member */
@@ -56,6 +56,7 @@ struct unix_sock {
56 spinlock_t lock; 56 spinlock_t lock;
57 unsigned int gc_candidate : 1; 57 unsigned int gc_candidate : 1;
58 unsigned int gc_maybe_cycle : 1; 58 unsigned int gc_maybe_cycle : 1;
59 unsigned char recursion_level;
59 struct socket_wq peer_wq; 60 struct socket_wq peer_wq;
60}; 61};
61#define unix_sk(__sk) ((struct unix_sock *)__sk) 62#define unix_sk(__sk) ((struct unix_sock *)__sk)
@@ -70,4 +71,3 @@ static inline int unix_sysctl_register(struct net *net) { return 0; }
70static inline void unix_sysctl_unregister(struct net *net) {} 71static inline void unix_sysctl_unregister(struct net *net) {}
71#endif 72#endif
72#endif 73#endif
73#endif
diff --git a/include/net/ah.h b/include/net/ah.h
index f0129f79a31a..ca95b98969dd 100644
--- a/include/net/ah.h
+++ b/include/net/ah.h
@@ -4,7 +4,7 @@
4#include <linux/skbuff.h> 4#include <linux/skbuff.h>
5 5
6/* This is the maximum truncated ICV length that we know of. */ 6/* This is the maximum truncated ICV length that we know of. */
7#define MAX_AH_AUTH_LEN 12 7#define MAX_AH_AUTH_LEN 64
8 8
9struct crypto_ahash; 9struct crypto_ahash;
10 10
diff --git a/include/net/arp.h b/include/net/arp.h
index 716f43c5c98e..91f0568a04ef 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -25,7 +25,6 @@ extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
25 const unsigned char *src_hw, 25 const unsigned char *src_hw,
26 const unsigned char *target_hw); 26 const unsigned char *target_hw);
27extern void arp_xmit(struct sk_buff *skb); 27extern void arp_xmit(struct sk_buff *skb);
28 28int arp_invalidate(struct net_device *dev, __be32 ip);
29extern const struct neigh_ops arp_broken_ops;
30 29
31#endif /* _ARP_H */ 30#endif /* _ARP_H */
diff --git a/include/net/atmclip.h b/include/net/atmclip.h
index 467c531b8a7e..497ef6444a7a 100644
--- a/include/net/atmclip.h
+++ b/include/net/atmclip.h
@@ -54,8 +54,6 @@ struct clip_priv {
54}; 54};
55 55
56 56
57#ifdef __KERNEL__
58extern struct neigh_table *clip_tbl_hook; 57extern struct neigh_table *clip_tbl_hook;
59#endif
60 58
61#endif 59#endif
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 30fce0128dd7..43750439c521 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -64,6 +64,11 @@ struct bt_security {
64 64
65#define BT_DEFER_SETUP 7 65#define BT_DEFER_SETUP 7
66 66
67#define BT_FLUSHABLE 8
68
69#define BT_FLUSHABLE_OFF 0
70#define BT_FLUSHABLE_ON 1
71
67#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg) 72#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
68#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg) 73#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
69#define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg) 74#define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg)
@@ -126,6 +131,8 @@ int bt_sock_unregister(int proto);
126void bt_sock_link(struct bt_sock_list *l, struct sock *s); 131void bt_sock_link(struct bt_sock_list *l, struct sock *s);
127void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); 132void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
128int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags); 133int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags);
134int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
135 struct msghdr *msg, size_t len, int flags);
129uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); 136uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait);
130int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 137int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
131int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); 138int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
@@ -142,6 +149,7 @@ struct bt_skb_cb {
142 __u8 tx_seq; 149 __u8 tx_seq;
143 __u8 retries; 150 __u8 retries;
144 __u8 sar; 151 __u8 sar;
152 unsigned short channel;
145}; 153};
146#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) 154#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
147 155
@@ -197,4 +205,32 @@ extern void bt_sysfs_cleanup(void);
197 205
198extern struct dentry *bt_debugfs; 206extern struct dentry *bt_debugfs;
199 207
208#ifdef CONFIG_BT_L2CAP
209int l2cap_init(void);
210void l2cap_exit(void);
211#else
212static inline int l2cap_init(void)
213{
214 return 0;
215}
216
217static inline void l2cap_exit(void)
218{
219}
220#endif
221
222#ifdef CONFIG_BT_SCO
223int sco_init(void);
224void sco_exit(void);
225#else
226static inline int sco_init(void)
227{
228 return 0;
229}
230
231static inline void sco_exit(void)
232{
233}
234#endif
235
200#endif /* __BLUETOOTH_H */ 236#endif /* __BLUETOOTH_H */
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index bcbdd6d4e6dd..0c20227e57f6 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1,4 +1,4 @@
1/* 1/*
2 BlueZ - Bluetooth protocol stack for Linux 2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated 3 Copyright (C) 2000-2001 Qualcomm Incorporated
4 4
@@ -12,13 +12,13 @@
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED. 22 SOFTWARE IS DISCLAIMED.
23*/ 23*/
24 24
@@ -54,7 +54,7 @@
54 54
55/* HCI controller types */ 55/* HCI controller types */
56#define HCI_BREDR 0x00 56#define HCI_BREDR 0x00
57#define HCI_80211 0x01 57#define HCI_AMP 0x01
58 58
59/* HCI device quirks */ 59/* HCI device quirks */
60enum { 60enum {
@@ -76,6 +76,16 @@ enum {
76 HCI_INQUIRY, 76 HCI_INQUIRY,
77 77
78 HCI_RAW, 78 HCI_RAW,
79
80 HCI_SETUP,
81 HCI_AUTO_OFF,
82 HCI_MGMT,
83 HCI_PAIRABLE,
84 HCI_SERVICE_CACHE,
85 HCI_LINK_KEYS,
86 HCI_DEBUG_KEYS,
87
88 HCI_RESET,
79}; 89};
80 90
81/* HCI ioctl defines */ 91/* HCI ioctl defines */
@@ -111,6 +121,7 @@ enum {
111#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ 121#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
112#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ 122#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
113#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ 123#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
124#define HCI_CMD_TIMEOUT (1000) /* 1 seconds */
114 125
115/* HCI data types */ 126/* HCI data types */
116#define HCI_COMMAND_PKT 0x01 127#define HCI_COMMAND_PKT 0x01
@@ -150,6 +161,7 @@ enum {
150#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) 161#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
151 162
152/* ACL flags */ 163/* ACL flags */
164#define ACL_START_NO_FLUSH 0x00
153#define ACL_CONT 0x01 165#define ACL_CONT 0x01
154#define ACL_START 0x02 166#define ACL_START 0x02
155#define ACL_ACTIVE_BCAST 0x04 167#define ACL_ACTIVE_BCAST 0x04
@@ -159,6 +171,8 @@ enum {
159#define SCO_LINK 0x00 171#define SCO_LINK 0x00
160#define ACL_LINK 0x01 172#define ACL_LINK 0x01
161#define ESCO_LINK 0x02 173#define ESCO_LINK 0x02
174/* Low Energy links do not have defined link type. Use invented one */
175#define LE_LINK 0x80
162 176
163/* LMP features */ 177/* LMP features */
164#define LMP_3SLOT 0x01 178#define LMP_3SLOT 0x01
@@ -183,17 +197,25 @@ enum {
183#define LMP_PSCHEME 0x02 197#define LMP_PSCHEME 0x02
184#define LMP_PCONTROL 0x04 198#define LMP_PCONTROL 0x04
185 199
200#define LMP_RSSI_INQ 0x40
186#define LMP_ESCO 0x80 201#define LMP_ESCO 0x80
187 202
188#define LMP_EV4 0x01 203#define LMP_EV4 0x01
189#define LMP_EV5 0x02 204#define LMP_EV5 0x02
205#define LMP_LE 0x40
190 206
191#define LMP_SNIFF_SUBR 0x02 207#define LMP_SNIFF_SUBR 0x02
208#define LMP_PAUSE_ENC 0x04
192#define LMP_EDR_ESCO_2M 0x20 209#define LMP_EDR_ESCO_2M 0x20
193#define LMP_EDR_ESCO_3M 0x40 210#define LMP_EDR_ESCO_3M 0x40
194#define LMP_EDR_3S_ESCO 0x80 211#define LMP_EDR_3S_ESCO 0x80
195 212
213#define LMP_EXT_INQ 0x01
196#define LMP_SIMPLE_PAIR 0x08 214#define LMP_SIMPLE_PAIR 0x08
215#define LMP_NO_FLUSH 0x40
216
217#define LMP_LSTO 0x01
218#define LMP_INQ_TX_PWR 0x02
197 219
198/* Connection modes */ 220/* Connection modes */
199#define HCI_CM_ACTIVE 0x0000 221#define HCI_CM_ACTIVE 0x0000
@@ -224,7 +246,18 @@ enum {
224#define HCI_AT_GENERAL_BONDING 0x04 246#define HCI_AT_GENERAL_BONDING 0x04
225#define HCI_AT_GENERAL_BONDING_MITM 0x05 247#define HCI_AT_GENERAL_BONDING_MITM 0x05
226 248
249/* Link Key types */
250#define HCI_LK_COMBINATION 0x00
251#define HCI_LK_LOCAL_UNIT 0x01
252#define HCI_LK_REMOTE_UNIT 0x02
253#define HCI_LK_DEBUG_COMBINATION 0x03
254#define HCI_LK_UNAUTH_COMBINATION 0x04
255#define HCI_LK_AUTH_COMBINATION 0x05
256#define HCI_LK_CHANGED_COMBINATION 0x06
257
227/* ----- HCI Commands ---- */ 258/* ----- HCI Commands ---- */
259#define HCI_OP_NOP 0x0000
260
228#define HCI_OP_INQUIRY 0x0401 261#define HCI_OP_INQUIRY 0x0401
229struct hci_cp_inquiry { 262struct hci_cp_inquiry {
230 __u8 lap[3]; 263 __u8 lap[3];
@@ -292,11 +325,19 @@ struct hci_cp_pin_code_reply {
292 __u8 pin_len; 325 __u8 pin_len;
293 __u8 pin_code[16]; 326 __u8 pin_code[16];
294} __packed; 327} __packed;
328struct hci_rp_pin_code_reply {
329 __u8 status;
330 bdaddr_t bdaddr;
331} __packed;
295 332
296#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e 333#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
297struct hci_cp_pin_code_neg_reply { 334struct hci_cp_pin_code_neg_reply {
298 bdaddr_t bdaddr; 335 bdaddr_t bdaddr;
299} __packed; 336} __packed;
337struct hci_rp_pin_code_neg_reply {
338 __u8 status;
339 bdaddr_t bdaddr;
340} __packed;
300 341
301#define HCI_OP_CHANGE_CONN_PTYPE 0x040f 342#define HCI_OP_CHANGE_CONN_PTYPE 0x040f
302struct hci_cp_change_conn_ptype { 343struct hci_cp_change_conn_ptype {
@@ -377,6 +418,43 @@ struct hci_cp_reject_sync_conn_req {
377 __u8 reason; 418 __u8 reason;
378} __packed; 419} __packed;
379 420
421#define HCI_OP_IO_CAPABILITY_REPLY 0x042b
422struct hci_cp_io_capability_reply {
423 bdaddr_t bdaddr;
424 __u8 capability;
425 __u8 oob_data;
426 __u8 authentication;
427} __packed;
428
429#define HCI_OP_USER_CONFIRM_REPLY 0x042c
430struct hci_cp_user_confirm_reply {
431 bdaddr_t bdaddr;
432} __packed;
433struct hci_rp_user_confirm_reply {
434 __u8 status;
435 bdaddr_t bdaddr;
436} __packed;
437
438#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
439
440#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
441struct hci_cp_remote_oob_data_reply {
442 bdaddr_t bdaddr;
443 __u8 hash[16];
444 __u8 randomizer[16];
445} __packed;
446
447#define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
448struct hci_cp_remote_oob_data_neg_reply {
449 bdaddr_t bdaddr;
450} __packed;
451
452#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
453struct hci_cp_io_capability_neg_reply {
454 bdaddr_t bdaddr;
455 __u8 reason;
456} __packed;
457
380#define HCI_OP_SNIFF_MODE 0x0803 458#define HCI_OP_SNIFF_MODE 0x0803
381struct hci_cp_sniff_mode { 459struct hci_cp_sniff_mode {
382 __le16 handle; 460 __le16 handle;
@@ -474,22 +552,30 @@ struct hci_cp_set_event_flt {
474#define HCI_CONN_SETUP_AUTO_OFF 0x01 552#define HCI_CONN_SETUP_AUTO_OFF 0x01
475#define HCI_CONN_SETUP_AUTO_ON 0x02 553#define HCI_CONN_SETUP_AUTO_ON 0x02
476 554
555#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
556struct hci_cp_delete_stored_link_key {
557 bdaddr_t bdaddr;
558 __u8 delete_all;
559} __packed;
560
561#define HCI_MAX_NAME_LENGTH 248
562
477#define HCI_OP_WRITE_LOCAL_NAME 0x0c13 563#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
478struct hci_cp_write_local_name { 564struct hci_cp_write_local_name {
479 __u8 name[248]; 565 __u8 name[HCI_MAX_NAME_LENGTH];
480} __packed; 566} __packed;
481 567
482#define HCI_OP_READ_LOCAL_NAME 0x0c14 568#define HCI_OP_READ_LOCAL_NAME 0x0c14
483struct hci_rp_read_local_name { 569struct hci_rp_read_local_name {
484 __u8 status; 570 __u8 status;
485 __u8 name[248]; 571 __u8 name[HCI_MAX_NAME_LENGTH];
486} __packed; 572} __packed;
487 573
488#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16 574#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
489 575
490#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18 576#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
491 577
492#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a 578#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
493 #define SCAN_DISABLED 0x00 579 #define SCAN_DISABLED 0x00
494 #define SCAN_INQUIRY 0x01 580 #define SCAN_INQUIRY 0x01
495 #define SCAN_PAGE 0x02 581 #define SCAN_PAGE 0x02
@@ -537,6 +623,16 @@ struct hci_cp_host_buffer_size {
537 __le16 sco_max_pkt; 623 __le16 sco_max_pkt;
538} __packed; 624} __packed;
539 625
626#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
627
628#define HCI_MAX_EIR_LENGTH 240
629
630#define HCI_OP_WRITE_EIR 0x0c52
631struct hci_cp_write_eir {
632 uint8_t fec;
633 uint8_t data[HCI_MAX_EIR_LENGTH];
634} __packed;
635
540#define HCI_OP_READ_SSP_MODE 0x0c55 636#define HCI_OP_READ_SSP_MODE 0x0c55
541struct hci_rp_read_ssp_mode { 637struct hci_rp_read_ssp_mode {
542 __u8 status; 638 __u8 status;
@@ -548,6 +644,15 @@ struct hci_cp_write_ssp_mode {
548 __u8 mode; 644 __u8 mode;
549} __packed; 645} __packed;
550 646
647#define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
648struct hci_rp_read_local_oob_data {
649 __u8 status;
650 __u8 hash[16];
651 __u8 randomizer[16];
652} __packed;
653
654#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
655
551#define HCI_OP_READ_LOCAL_VERSION 0x1001 656#define HCI_OP_READ_LOCAL_VERSION 0x1001
552struct hci_rp_read_local_version { 657struct hci_rp_read_local_version {
553 __u8 status; 658 __u8 status;
@@ -593,6 +698,47 @@ struct hci_rp_read_bd_addr {
593 bdaddr_t bdaddr; 698 bdaddr_t bdaddr;
594} __packed; 699} __packed;
595 700
701#define HCI_OP_LE_SET_EVENT_MASK 0x2001
702struct hci_cp_le_set_event_mask {
703 __u8 mask[8];
704} __packed;
705
706#define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
707struct hci_rp_le_read_buffer_size {
708 __u8 status;
709 __le16 le_mtu;
710 __u8 le_max_pkt;
711} __packed;
712
713#define HCI_OP_LE_CREATE_CONN 0x200d
714struct hci_cp_le_create_conn {
715 __le16 scan_interval;
716 __le16 scan_window;
717 __u8 filter_policy;
718 __u8 peer_addr_type;
719 bdaddr_t peer_addr;
720 __u8 own_address_type;
721 __le16 conn_interval_min;
722 __le16 conn_interval_max;
723 __le16 conn_latency;
724 __le16 supervision_timeout;
725 __le16 min_ce_len;
726 __le16 max_ce_len;
727} __packed;
728
729#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
730
731#define HCI_OP_LE_CONN_UPDATE 0x2013
732struct hci_cp_le_conn_update {
733 __le16 handle;
734 __le16 conn_interval_min;
735 __le16 conn_interval_max;
736 __le16 conn_latency;
737 __le16 supervision_timeout;
738 __le16 min_ce_len;
739 __le16 max_ce_len;
740} __packed;
741
596/* ---- HCI Events ---- */ 742/* ---- HCI Events ---- */
597#define HCI_EV_INQUIRY_COMPLETE 0x01 743#define HCI_EV_INQUIRY_COMPLETE 0x01
598 744
@@ -639,7 +785,7 @@ struct hci_ev_auth_complete {
639struct hci_ev_remote_name { 785struct hci_ev_remote_name {
640 __u8 status; 786 __u8 status;
641 bdaddr_t bdaddr; 787 bdaddr_t bdaddr;
642 __u8 name[248]; 788 __u8 name[HCI_MAX_NAME_LENGTH];
643} __packed; 789} __packed;
644 790
645#define HCI_EV_ENCRYPT_CHANGE 0x08 791#define HCI_EV_ENCRYPT_CHANGE 0x08
@@ -833,6 +979,25 @@ struct hci_ev_io_capa_request {
833 bdaddr_t bdaddr; 979 bdaddr_t bdaddr;
834} __packed; 980} __packed;
835 981
982#define HCI_EV_IO_CAPA_REPLY 0x32
983struct hci_ev_io_capa_reply {
984 bdaddr_t bdaddr;
985 __u8 capability;
986 __u8 oob_data;
987 __u8 authentication;
988} __packed;
989
990#define HCI_EV_USER_CONFIRM_REQUEST 0x33
991struct hci_ev_user_confirm_req {
992 bdaddr_t bdaddr;
993 __le32 passkey;
994} __packed;
995
996#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
997struct hci_ev_remote_oob_data_request {
998 bdaddr_t bdaddr;
999} __packed;
1000
836#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36 1001#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
837struct hci_ev_simple_pair_complete { 1002struct hci_ev_simple_pair_complete {
838 __u8 status; 1003 __u8 status;
@@ -845,6 +1010,25 @@ struct hci_ev_remote_host_features {
845 __u8 features[8]; 1010 __u8 features[8];
846} __packed; 1011} __packed;
847 1012
1013#define HCI_EV_LE_META 0x3e
1014struct hci_ev_le_meta {
1015 __u8 subevent;
1016} __packed;
1017
1018/* Low energy meta events */
1019#define HCI_EV_LE_CONN_COMPLETE 0x01
1020struct hci_ev_le_conn_complete {
1021 __u8 status;
1022 __le16 handle;
1023 __u8 role;
1024 __u8 bdaddr_type;
1025 bdaddr_t bdaddr;
1026 __le16 interval;
1027 __le16 latency;
1028 __le16 supervision_timeout;
1029 __u8 clk_accurancy;
1030} __packed;
1031
848/* Internal events generated by Bluetooth stack */ 1032/* Internal events generated by Bluetooth stack */
849#define HCI_EV_STACK_INTERNAL 0xfd 1033#define HCI_EV_STACK_INTERNAL 0xfd
850struct hci_ev_stack_internal { 1034struct hci_ev_stack_internal {
@@ -874,7 +1058,7 @@ struct hci_ev_si_security {
874 1058
875struct hci_command_hdr { 1059struct hci_command_hdr {
876 __le16 opcode; /* OCF & OGF */ 1060 __le16 opcode; /* OCF & OGF */
877 __u8 plen; 1061 __u8 plen;
878} __packed; 1062} __packed;
879 1063
880struct hci_event_hdr { 1064struct hci_event_hdr {
@@ -892,7 +1076,6 @@ struct hci_sco_hdr {
892 __u8 dlen; 1076 __u8 dlen;
893} __packed; 1077} __packed;
894 1078
895#ifdef __KERNEL__
896#include <linux/skbuff.h> 1079#include <linux/skbuff.h>
897static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) 1080static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
898{ 1081{
@@ -908,7 +1091,6 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
908{ 1091{
909 return (struct hci_sco_hdr *) skb->data; 1092 return (struct hci_sco_hdr *) skb->data;
910} 1093}
911#endif
912 1094
913/* Command opcode pack/unpack */ 1095/* Command opcode pack/unpack */
914#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) 1096#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
@@ -934,9 +1116,13 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
934struct sockaddr_hci { 1116struct sockaddr_hci {
935 sa_family_t hci_family; 1117 sa_family_t hci_family;
936 unsigned short hci_dev; 1118 unsigned short hci_dev;
1119 unsigned short hci_channel;
937}; 1120};
938#define HCI_DEV_NONE 0xffff 1121#define HCI_DEV_NONE 0xffff
939 1122
1123#define HCI_CHANNEL_RAW 0
1124#define HCI_CHANNEL_CONTROL 1
1125
940struct hci_filter { 1126struct hci_filter {
941 unsigned long type_mask; 1127 unsigned long type_mask;
942 unsigned long event_mask[2]; 1128 unsigned long event_mask[2];
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 4568b938ca35..6c994c004d15 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -44,15 +44,15 @@ struct inquiry_data {
44}; 44};
45 45
46struct inquiry_entry { 46struct inquiry_entry {
47 struct inquiry_entry *next; 47 struct inquiry_entry *next;
48 __u32 timestamp; 48 __u32 timestamp;
49 struct inquiry_data data; 49 struct inquiry_data data;
50}; 50};
51 51
52struct inquiry_cache { 52struct inquiry_cache {
53 spinlock_t lock; 53 spinlock_t lock;
54 __u32 timestamp; 54 __u32 timestamp;
55 struct inquiry_entry *list; 55 struct inquiry_entry *list;
56}; 56};
57 57
58struct hci_conn_hash { 58struct hci_conn_hash {
@@ -60,12 +60,35 @@ struct hci_conn_hash {
60 spinlock_t lock; 60 spinlock_t lock;
61 unsigned int acl_num; 61 unsigned int acl_num;
62 unsigned int sco_num; 62 unsigned int sco_num;
63 unsigned int le_num;
63}; 64};
64 65
65struct bdaddr_list { 66struct bdaddr_list {
66 struct list_head list; 67 struct list_head list;
67 bdaddr_t bdaddr; 68 bdaddr_t bdaddr;
68}; 69};
70
71struct bt_uuid {
72 struct list_head list;
73 u8 uuid[16];
74 u8 svc_hint;
75};
76
77struct link_key {
78 struct list_head list;
79 bdaddr_t bdaddr;
80 u8 type;
81 u8 val[16];
82 u8 pin_len;
83};
84
85struct oob_data {
86 struct list_head list;
87 bdaddr_t bdaddr;
88 u8 hash[16];
89 u8 randomizer[16];
90};
91
69#define NUM_REASSEMBLY 4 92#define NUM_REASSEMBLY 4
70struct hci_dev { 93struct hci_dev {
71 struct list_head list; 94 struct list_head list;
@@ -78,15 +101,21 @@ struct hci_dev {
78 __u8 bus; 101 __u8 bus;
79 __u8 dev_type; 102 __u8 dev_type;
80 bdaddr_t bdaddr; 103 bdaddr_t bdaddr;
81 __u8 dev_name[248]; 104 __u8 dev_name[HCI_MAX_NAME_LENGTH];
105 __u8 eir[HCI_MAX_EIR_LENGTH];
82 __u8 dev_class[3]; 106 __u8 dev_class[3];
107 __u8 major_class;
108 __u8 minor_class;
83 __u8 features[8]; 109 __u8 features[8];
84 __u8 commands[64]; 110 __u8 commands[64];
85 __u8 ssp_mode; 111 __u8 ssp_mode;
86 __u8 hci_ver; 112 __u8 hci_ver;
87 __u16 hci_rev; 113 __u16 hci_rev;
114 __u8 lmp_ver;
88 __u16 manufacturer; 115 __u16 manufacturer;
116 __le16 lmp_subver;
89 __u16 voice_setting; 117 __u16 voice_setting;
118 __u8 io_capability;
90 119
91 __u16 pkt_type; 120 __u16 pkt_type;
92 __u16 esco_type; 121 __u16 esco_type;
@@ -97,23 +126,33 @@ struct hci_dev {
97 __u16 sniff_min_interval; 126 __u16 sniff_min_interval;
98 __u16 sniff_max_interval; 127 __u16 sniff_max_interval;
99 128
129 unsigned int auto_accept_delay;
130
100 unsigned long quirks; 131 unsigned long quirks;
101 132
102 atomic_t cmd_cnt; 133 atomic_t cmd_cnt;
103 unsigned int acl_cnt; 134 unsigned int acl_cnt;
104 unsigned int sco_cnt; 135 unsigned int sco_cnt;
136 unsigned int le_cnt;
105 137
106 unsigned int acl_mtu; 138 unsigned int acl_mtu;
107 unsigned int sco_mtu; 139 unsigned int sco_mtu;
140 unsigned int le_mtu;
108 unsigned int acl_pkts; 141 unsigned int acl_pkts;
109 unsigned int sco_pkts; 142 unsigned int sco_pkts;
143 unsigned int le_pkts;
110 144
111 unsigned long cmd_last_tx;
112 unsigned long acl_last_tx; 145 unsigned long acl_last_tx;
113 unsigned long sco_last_tx; 146 unsigned long sco_last_tx;
147 unsigned long le_last_tx;
114 148
115 struct workqueue_struct *workqueue; 149 struct workqueue_struct *workqueue;
116 150
151 struct work_struct power_on;
152 struct work_struct power_off;
153 struct timer_list off_timer;
154
155 struct timer_list cmd_timer;
117 struct tasklet_struct cmd_task; 156 struct tasklet_struct cmd_task;
118 struct tasklet_struct rx_task; 157 struct tasklet_struct rx_task;
119 struct tasklet_struct tx_task; 158 struct tasklet_struct tx_task;
@@ -130,10 +169,18 @@ struct hci_dev {
130 __u32 req_status; 169 __u32 req_status;
131 __u32 req_result; 170 __u32 req_result;
132 171
172 __u16 init_last_cmd;
173
133 struct inquiry_cache inq_cache; 174 struct inquiry_cache inq_cache;
134 struct hci_conn_hash conn_hash; 175 struct hci_conn_hash conn_hash;
135 struct list_head blacklist; 176 struct list_head blacklist;
136 177
178 struct list_head uuids;
179
180 struct list_head link_keys;
181
182 struct list_head remote_oob_data;
183
137 struct hci_dev_stats stat; 184 struct hci_dev_stats stat;
138 185
139 struct sk_buff_head driver_init; 186 struct sk_buff_head driver_init;
@@ -141,7 +188,7 @@ struct hci_dev {
141 void *driver_data; 188 void *driver_data;
142 void *core_data; 189 void *core_data;
143 190
144 atomic_t promisc; 191 atomic_t promisc;
145 192
146 struct dentry *debugfs; 193 struct dentry *debugfs;
147 194
@@ -150,7 +197,7 @@ struct hci_dev {
150 197
151 struct rfkill *rfkill; 198 struct rfkill *rfkill;
152 199
153 struct module *owner; 200 struct module *owner;
154 201
155 int (*open)(struct hci_dev *hdev); 202 int (*open)(struct hci_dev *hdev);
156 int (*close)(struct hci_dev *hdev); 203 int (*close)(struct hci_dev *hdev);
@@ -164,35 +211,44 @@ struct hci_dev {
164struct hci_conn { 211struct hci_conn {
165 struct list_head list; 212 struct list_head list;
166 213
167 atomic_t refcnt; 214 atomic_t refcnt;
168 spinlock_t lock; 215 spinlock_t lock;
169 216
170 bdaddr_t dst; 217 bdaddr_t dst;
171 __u16 handle; 218 __u16 handle;
172 __u16 state; 219 __u16 state;
173 __u8 mode; 220 __u8 mode;
174 __u8 type; 221 __u8 type;
175 __u8 out; 222 __u8 out;
176 __u8 attempt; 223 __u8 attempt;
177 __u8 dev_class[3]; 224 __u8 dev_class[3];
178 __u8 features[8]; 225 __u8 features[8];
179 __u8 ssp_mode; 226 __u8 ssp_mode;
180 __u16 interval; 227 __u16 interval;
181 __u16 pkt_type; 228 __u16 pkt_type;
182 __u16 link_policy; 229 __u16 link_policy;
183 __u32 link_mode; 230 __u32 link_mode;
184 __u8 auth_type; 231 __u8 key_type;
185 __u8 sec_level; 232 __u8 auth_type;
186 __u8 power_save; 233 __u8 sec_level;
187 __u16 disc_timeout; 234 __u8 pending_sec_level;
188 unsigned long pend; 235 __u8 pin_length;
189 236 __u8 io_capability;
190 unsigned int sent; 237 __u8 power_save;
238 __u16 disc_timeout;
239 unsigned long pend;
240
241 __u8 remote_cap;
242 __u8 remote_oob;
243 __u8 remote_auth;
244
245 unsigned int sent;
191 246
192 struct sk_buff_head data_q; 247 struct sk_buff_head data_q;
193 248
194 struct timer_list disc_timer; 249 struct timer_list disc_timer;
195 struct timer_list idle_timer; 250 struct timer_list idle_timer;
251 struct timer_list auto_accept_timer;
196 252
197 struct work_struct work_add; 253 struct work_struct work_add;
198 struct work_struct work_del; 254 struct work_struct work_del;
@@ -206,6 +262,10 @@ struct hci_conn {
206 void *priv; 262 void *priv;
207 263
208 struct hci_conn *link; 264 struct hci_conn *link;
265
266 void (*connect_cfm_cb) (struct hci_conn *conn, u8 status);
267 void (*security_cfm_cb) (struct hci_conn *conn, u8 status);
268 void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason);
209}; 269};
210 270
211extern struct hci_proto *hci_proto[]; 271extern struct hci_proto *hci_proto[];
@@ -215,8 +275,8 @@ extern rwlock_t hci_dev_list_lock;
215extern rwlock_t hci_cb_list_lock; 275extern rwlock_t hci_cb_list_lock;
216 276
217/* ----- Inquiry cache ----- */ 277/* ----- Inquiry cache ----- */
218#define INQUIRY_CACHE_AGE_MAX (HZ*30) // 30 seconds 278#define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */
219#define INQUIRY_ENTRY_AGE_MAX (HZ*60) // 60 seconds 279#define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */
220 280
221#define inquiry_cache_lock(c) spin_lock(&c->lock) 281#define inquiry_cache_lock(c) spin_lock(&c->lock)
222#define inquiry_cache_unlock(c) spin_unlock(&c->lock) 282#define inquiry_cache_unlock(c) spin_unlock(&c->lock)
@@ -233,7 +293,7 @@ static inline void inquiry_cache_init(struct hci_dev *hdev)
233static inline int inquiry_cache_empty(struct hci_dev *hdev) 293static inline int inquiry_cache_empty(struct hci_dev *hdev)
234{ 294{
235 struct inquiry_cache *c = &hdev->inq_cache; 295 struct inquiry_cache *c = &hdev->inq_cache;
236 return (c->list == NULL); 296 return c->list == NULL;
237} 297}
238 298
239static inline long inquiry_cache_age(struct hci_dev *hdev) 299static inline long inquiry_cache_age(struct hci_dev *hdev)
@@ -272,24 +332,40 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
272{ 332{
273 struct hci_conn_hash *h = &hdev->conn_hash; 333 struct hci_conn_hash *h = &hdev->conn_hash;
274 list_add(&c->list, &h->list); 334 list_add(&c->list, &h->list);
275 if (c->type == ACL_LINK) 335 switch (c->type) {
336 case ACL_LINK:
276 h->acl_num++; 337 h->acl_num++;
277 else 338 break;
339 case LE_LINK:
340 h->le_num++;
341 break;
342 case SCO_LINK:
343 case ESCO_LINK:
278 h->sco_num++; 344 h->sco_num++;
345 break;
346 }
279} 347}
280 348
281static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) 349static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
282{ 350{
283 struct hci_conn_hash *h = &hdev->conn_hash; 351 struct hci_conn_hash *h = &hdev->conn_hash;
284 list_del(&c->list); 352 list_del(&c->list);
285 if (c->type == ACL_LINK) 353 switch (c->type) {
354 case ACL_LINK:
286 h->acl_num--; 355 h->acl_num--;
287 else 356 break;
357 case LE_LINK:
358 h->le_num--;
359 break;
360 case SCO_LINK:
361 case ESCO_LINK:
288 h->sco_num--; 362 h->sco_num--;
363 break;
364 }
289} 365}
290 366
291static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, 367static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
292 __u16 handle) 368 __u16 handle)
293{ 369{
294 struct hci_conn_hash *h = &hdev->conn_hash; 370 struct hci_conn_hash *h = &hdev->conn_hash;
295 struct list_head *p; 371 struct list_head *p;
@@ -304,7 +380,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
304} 380}
305 381
306static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, 382static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,
307 __u8 type, bdaddr_t *ba) 383 __u8 type, bdaddr_t *ba)
308{ 384{
309 struct hci_conn_hash *h = &hdev->conn_hash; 385 struct hci_conn_hash *h = &hdev->conn_hash;
310 struct list_head *p; 386 struct list_head *p;
@@ -319,7 +395,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,
319} 395}
320 396
321static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, 397static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
322 __u8 type, __u16 state) 398 __u8 type, __u16 state)
323{ 399{
324 struct hci_conn_hash *h = &hdev->conn_hash; 400 struct hci_conn_hash *h = &hdev->conn_hash;
325 struct list_head *p; 401 struct list_head *p;
@@ -346,6 +422,7 @@ void hci_conn_check_pending(struct hci_dev *hdev);
346 422
347struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); 423struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type);
348int hci_conn_check_link_mode(struct hci_conn *conn); 424int hci_conn_check_link_mode(struct hci_conn *conn);
425int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level);
349int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); 426int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type);
350int hci_conn_change_link_key(struct hci_conn *conn); 427int hci_conn_change_link_key(struct hci_conn *conn);
351int hci_conn_switch_role(struct hci_conn *conn, __u8 role); 428int hci_conn_switch_role(struct hci_conn *conn, __u8 role);
@@ -435,6 +512,23 @@ int hci_inquiry(void __user *arg);
435struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); 512struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);
436int hci_blacklist_clear(struct hci_dev *hdev); 513int hci_blacklist_clear(struct hci_dev *hdev);
437 514
515int hci_uuids_clear(struct hci_dev *hdev);
516
517int hci_link_keys_clear(struct hci_dev *hdev);
518struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
519int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
520 bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len);
521int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
522
523int hci_remote_oob_data_clear(struct hci_dev *hdev);
524struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
525 bdaddr_t *bdaddr);
526int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
527 u8 *randomizer);
528int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
529
530void hci_del_off_timer(struct hci_dev *hdev);
531
438void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 532void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
439 533
440int hci_recv_frame(struct sk_buff *skb); 534int hci_recv_frame(struct sk_buff *skb);
@@ -456,6 +550,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
456#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) 550#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
457#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) 551#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)
458#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) 552#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)
553#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
554#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE)
459 555
460/* ----- HCI protocols ----- */ 556/* ----- HCI protocols ----- */
461struct hci_proto { 557struct hci_proto {
@@ -501,6 +597,9 @@ static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status)
501 hp = hci_proto[HCI_PROTO_SCO]; 597 hp = hci_proto[HCI_PROTO_SCO];
502 if (hp && hp->connect_cfm) 598 if (hp && hp->connect_cfm)
503 hp->connect_cfm(conn, status); 599 hp->connect_cfm(conn, status);
600
601 if (conn->connect_cfm_cb)
602 conn->connect_cfm_cb(conn, status);
504} 603}
505 604
506static inline int hci_proto_disconn_ind(struct hci_conn *conn) 605static inline int hci_proto_disconn_ind(struct hci_conn *conn)
@@ -530,6 +629,9 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason)
530 hp = hci_proto[HCI_PROTO_SCO]; 629 hp = hci_proto[HCI_PROTO_SCO];
531 if (hp && hp->disconn_cfm) 630 if (hp && hp->disconn_cfm)
532 hp->disconn_cfm(conn, reason); 631 hp->disconn_cfm(conn, reason);
632
633 if (conn->disconn_cfm_cb)
634 conn->disconn_cfm_cb(conn, reason);
533} 635}
534 636
535static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) 637static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status)
@@ -549,6 +651,9 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status)
549 hp = hci_proto[HCI_PROTO_SCO]; 651 hp = hci_proto[HCI_PROTO_SCO];
550 if (hp && hp->security_cfm) 652 if (hp && hp->security_cfm)
551 hp->security_cfm(conn, status, encrypt); 653 hp->security_cfm(conn, status, encrypt);
654
655 if (conn->security_cfm_cb)
656 conn->security_cfm_cb(conn, status);
552} 657}
553 658
554static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt) 659static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt)
@@ -562,6 +667,9 @@ static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u
562 hp = hci_proto[HCI_PROTO_SCO]; 667 hp = hci_proto[HCI_PROTO_SCO];
563 if (hp && hp->security_cfm) 668 if (hp && hp->security_cfm)
564 hp->security_cfm(conn, status, encrypt); 669 hp->security_cfm(conn, status, encrypt);
670
671 if (conn->security_cfm_cb)
672 conn->security_cfm_cb(conn, status);
565} 673}
566 674
567int hci_register_proto(struct hci_proto *hproto); 675int hci_register_proto(struct hci_proto *hproto);
@@ -658,7 +766,37 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode);
658void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); 766void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data);
659 767
660/* ----- HCI Sockets ----- */ 768/* ----- HCI Sockets ----- */
661void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); 769void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb,
770 struct sock *skip_sk);
771
772/* Management interface */
773int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
774int mgmt_index_added(u16 index);
775int mgmt_index_removed(u16 index);
776int mgmt_powered(u16 index, u8 powered);
777int mgmt_discoverable(u16 index, u8 discoverable);
778int mgmt_connectable(u16 index, u8 connectable);
779int mgmt_new_key(u16 index, struct link_key *key, u8 persistent);
780int mgmt_connected(u16 index, bdaddr_t *bdaddr);
781int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
782int mgmt_disconnect_failed(u16 index);
783int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status);
784int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure);
785int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
786int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
787int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value,
788 u8 confirm_hint);
789int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
790int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr,
791 u8 status);
792int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);
793int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status);
794int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
795 u8 status);
796int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
797 u8 *eir);
798int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name);
799int mgmt_discovering(u16 index, u8 discovering);
662 800
663/* HCI info for socket */ 801/* HCI info for socket */
664#define hci_pi(sk) ((struct hci_pinfo *) sk) 802#define hci_pi(sk) ((struct hci_pinfo *) sk)
@@ -668,6 +806,7 @@ struct hci_pinfo {
668 struct hci_dev *hdev; 806 struct hci_dev *hdev;
669 struct hci_filter filter; 807 struct hci_filter filter;
670 __u32 cmsg_mask; 808 __u32 cmsg_mask;
809 unsigned short channel;
671}; 810};
672 811
673/* HCI security filter */ 812/* HCI security filter */
@@ -687,6 +826,8 @@ struct hci_sec_filter {
687#define hci_req_lock(d) mutex_lock(&d->req_lock) 826#define hci_req_lock(d) mutex_lock(&d->req_lock)
688#define hci_req_unlock(d) mutex_unlock(&d->req_lock) 827#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
689 828
690void hci_req_complete(struct hci_dev *hdev, int result); 829void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
691 830
831void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
832 u16 latency, u16 to_multiplier);
692#endif /* __HCI_CORE_H */ 833#endif /* __HCI_CORE_H */
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 6c241444f902..d09c9b1118e3 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -1,4 +1,4 @@
1/* 1/*
2 BlueZ - Bluetooth protocol stack for Linux 2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated 3 Copyright (C) 2000-2001 Qualcomm Incorporated
4 Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> 4 Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org>
@@ -14,13 +14,13 @@
14 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
16 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 16 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
17 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 17 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
18 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 21
22 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 22 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
23 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 23 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
24 SOFTWARE IS DISCLAIMED. 24 SOFTWARE IS DISCLAIMED.
25*/ 25*/
26 26
@@ -38,6 +38,7 @@
38#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ 38#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */
39#define L2CAP_DEFAULT_ACK_TO 200 39#define L2CAP_DEFAULT_ACK_TO 200
40#define L2CAP_LOCAL_BUSY_TRIES 12 40#define L2CAP_LOCAL_BUSY_TRIES 12
41#define L2CAP_LE_DEFAULT_MTU 23
41 42
42#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 43#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */
43#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ 44#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */
@@ -88,6 +89,8 @@ struct l2cap_conninfo {
88#define L2CAP_ECHO_RSP 0x09 89#define L2CAP_ECHO_RSP 0x09
89#define L2CAP_INFO_REQ 0x0a 90#define L2CAP_INFO_REQ 0x0a
90#define L2CAP_INFO_RSP 0x0b 91#define L2CAP_INFO_RSP 0x0b
92#define L2CAP_CONN_PARAM_UPDATE_REQ 0x12
93#define L2CAP_CONN_PARAM_UPDATE_RSP 0x13
91 94
92/* L2CAP feature mask */ 95/* L2CAP feature mask */
93#define L2CAP_FEAT_FLOWCTL 0x00000001 96#define L2CAP_FEAT_FLOWCTL 0x00000001
@@ -160,6 +163,9 @@ struct l2cap_conn_rsp {
160/* channel indentifier */ 163/* channel indentifier */
161#define L2CAP_CID_SIGNALING 0x0001 164#define L2CAP_CID_SIGNALING 0x0001
162#define L2CAP_CID_CONN_LESS 0x0002 165#define L2CAP_CID_CONN_LESS 0x0002
166#define L2CAP_CID_LE_DATA 0x0004
167#define L2CAP_CID_LE_SIGNALING 0x0005
168#define L2CAP_CID_SMP 0x0006
163#define L2CAP_CID_DYN_START 0x0040 169#define L2CAP_CID_DYN_START 0x0040
164#define L2CAP_CID_DYN_END 0xffff 170#define L2CAP_CID_DYN_END 0xffff
165 171
@@ -255,63 +261,32 @@ struct l2cap_info_rsp {
255#define L2CAP_IR_SUCCESS 0x0000 261#define L2CAP_IR_SUCCESS 0x0000
256#define L2CAP_IR_NOTSUPP 0x0001 262#define L2CAP_IR_NOTSUPP 0x0001
257 263
258/* ----- L2CAP connections ----- */ 264struct l2cap_conn_param_update_req {
259struct l2cap_chan_list { 265 __le16 min;
260 struct sock *head; 266 __le16 max;
261 rwlock_t lock; 267 __le16 latency;
262 long num; 268 __le16 to_multiplier;
263}; 269} __packed;
264
265struct l2cap_conn {
266 struct hci_conn *hcon;
267
268 bdaddr_t *dst;
269 bdaddr_t *src;
270
271 unsigned int mtu;
272
273 __u32 feat_mask;
274
275 __u8 info_state;
276 __u8 info_ident;
277
278 struct timer_list info_timer;
279
280 spinlock_t lock;
281
282 struct sk_buff *rx_skb;
283 __u32 rx_len;
284 __u8 rx_ident;
285 __u8 tx_ident;
286
287 __u8 disc_reason;
288
289 struct l2cap_chan_list chan_list;
290};
291
292struct sock_del_list {
293 struct sock *sk;
294 struct list_head list;
295};
296 270
297#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 271struct l2cap_conn_param_update_rsp {
298#define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 272 __le16 result;
299#define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 273} __packed;
300 274
301/* ----- L2CAP channel and socket info ----- */ 275/* Connection Parameters result */
302#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) 276#define L2CAP_CONN_PARAM_ACCEPTED 0x0000
303#define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) 277#define L2CAP_CONN_PARAM_REJECTED 0x0001
304#define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue)
305#define BUSY_QUEUE(sk) (&l2cap_pi(sk)->busy_queue)
306#define SREJ_LIST(sk) (&l2cap_pi(sk)->srej_l.list)
307 278
279/* ----- L2CAP channels and connections ----- */
308struct srej_list { 280struct srej_list {
309 __u8 tx_seq; 281 __u8 tx_seq;
310 struct list_head list; 282 struct list_head list;
311}; 283};
312 284
313struct l2cap_pinfo { 285struct l2cap_chan {
314 struct bt_sock bt; 286 struct sock *sk;
287
288 struct l2cap_conn *conn;
289
315 __le16 psm; 290 __le16 psm;
316 __u16 dcid; 291 __u16 dcid;
317 __u16 scid; 292 __u16 scid;
@@ -320,16 +295,29 @@ struct l2cap_pinfo {
320 __u16 omtu; 295 __u16 omtu;
321 __u16 flush_to; 296 __u16 flush_to;
322 __u8 mode; 297 __u8 mode;
323 __u8 num_conf_req;
324 __u8 num_conf_rsp;
325 298
326 __u8 fcs; 299 __le16 sport;
300
327 __u8 sec_level; 301 __u8 sec_level;
328 __u8 role_switch; 302 __u8 role_switch;
329 __u8 force_reliable; 303 __u8 force_reliable;
304 __u8 flushable;
305
306 __u8 ident;
330 307
331 __u8 conf_req[64]; 308 __u8 conf_req[64];
332 __u8 conf_len; 309 __u8 conf_len;
310 __u8 num_conf_req;
311 __u8 num_conf_rsp;
312
313 __u8 fcs;
314
315 __u8 tx_win;
316 __u8 max_tx;
317 __u16 retrans_timeout;
318 __u16 monitor_timeout;
319 __u16 mps;
320
333 __u8 conf_state; 321 __u8 conf_state;
334 __u16 conn_state; 322 __u16 conn_state;
335 323
@@ -347,30 +335,61 @@ struct l2cap_pinfo {
347 __u16 partial_sdu_len; 335 __u16 partial_sdu_len;
348 struct sk_buff *sdu; 336 struct sk_buff *sdu;
349 337
350 __u8 ident;
351
352 __u8 tx_win;
353 __u8 max_tx;
354 __u8 remote_tx_win; 338 __u8 remote_tx_win;
355 __u8 remote_max_tx; 339 __u8 remote_max_tx;
356 __u16 retrans_timeout;
357 __u16 monitor_timeout;
358 __u16 remote_mps; 340 __u16 remote_mps;
359 __u16 mps;
360
361 __le16 sport;
362 341
363 struct timer_list retrans_timer; 342 struct timer_list retrans_timer;
364 struct timer_list monitor_timer; 343 struct timer_list monitor_timer;
365 struct timer_list ack_timer; 344 struct timer_list ack_timer;
366 struct sk_buff_head tx_queue; 345 struct sk_buff *tx_send_head;
367 struct sk_buff_head srej_queue; 346 struct sk_buff_head tx_q;
368 struct sk_buff_head busy_queue; 347 struct sk_buff_head srej_q;
348 struct sk_buff_head busy_q;
369 struct work_struct busy_work; 349 struct work_struct busy_work;
370 struct srej_list srej_l; 350 struct list_head srej_l;
371 struct l2cap_conn *conn; 351
372 struct sock *next_c; 352 struct list_head list;
373 struct sock *prev_c; 353 struct list_head global_l;
354};
355
356struct l2cap_conn {
357 struct hci_conn *hcon;
358
359 bdaddr_t *dst;
360 bdaddr_t *src;
361
362 unsigned int mtu;
363
364 __u32 feat_mask;
365
366 __u8 info_state;
367 __u8 info_ident;
368
369 struct timer_list info_timer;
370
371 spinlock_t lock;
372
373 struct sk_buff *rx_skb;
374 __u32 rx_len;
375 __u8 tx_ident;
376
377 __u8 disc_reason;
378
379 struct list_head chan_l;
380 rwlock_t chan_lock;
381};
382
383#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01
384#define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04
385#define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08
386
387/* ----- L2CAP socket info ----- */
388#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
389
390struct l2cap_pinfo {
391 struct bt_sock bt;
392 struct l2cap_chan *chan;
374}; 393};
375 394
376#define L2CAP_CONF_REQ_SENT 0x01 395#define L2CAP_CONF_REQ_SENT 0x01
@@ -397,32 +416,62 @@ struct l2cap_pinfo {
397#define L2CAP_CONN_RNR_SENT 0x0200 416#define L2CAP_CONN_RNR_SENT 0x0200
398#define L2CAP_CONN_SAR_RETRY 0x0400 417#define L2CAP_CONN_SAR_RETRY 0x0400
399 418
400#define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ 419#define __mod_retrans_timer() mod_timer(&chan->retrans_timer, \
401 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); 420 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO));
402#define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ 421#define __mod_monitor_timer() mod_timer(&chan->monitor_timer, \
403 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); 422 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO));
404#define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \ 423#define __mod_ack_timer() mod_timer(&chan->ack_timer, \
405 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); 424 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
406 425
407static inline int l2cap_tx_window_full(struct sock *sk) 426static inline int l2cap_tx_window_full(struct l2cap_chan *ch)
408{ 427{
409 struct l2cap_pinfo *pi = l2cap_pi(sk);
410 int sub; 428 int sub;
411 429
412 sub = (pi->next_tx_seq - pi->expected_ack_seq) % 64; 430 sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64;
413 431
414 if (sub < 0) 432 if (sub < 0)
415 sub += 64; 433 sub += 64;
416 434
417 return (sub == pi->remote_tx_win); 435 return sub == ch->remote_tx_win;
418} 436}
419 437
420#define __get_txseq(ctrl) ((ctrl) & L2CAP_CTRL_TXSEQ) >> 1 438#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1)
421#define __get_reqseq(ctrl) ((ctrl) & L2CAP_CTRL_REQSEQ) >> 8 439#define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8)
422#define __is_iframe(ctrl) !((ctrl) & L2CAP_CTRL_FRAME_TYPE) 440#define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE))
423#define __is_sframe(ctrl) (ctrl) & L2CAP_CTRL_FRAME_TYPE 441#define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE)
424#define __is_sar_start(ctrl) ((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START 442#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START)
425 443
426void l2cap_load(void); 444extern int disable_ertm;
445
446int l2cap_init_sockets(void);
447void l2cap_cleanup_sockets(void);
448
449void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
450void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
451int __l2cap_wait_ack(struct sock *sk);
452
453struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
454struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
455struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen);
456int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
457void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb);
458void l2cap_streaming_send(struct l2cap_chan *chan);
459int l2cap_ertm_send(struct l2cap_chan *chan);
460
461int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
462int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);
463
464void l2cap_sock_set_timer(struct sock *sk, long timeout);
465void l2cap_sock_clear_timer(struct sock *sk);
466void __l2cap_sock_close(struct sock *sk, int reason);
467void l2cap_sock_kill(struct sock *sk);
468void l2cap_sock_init(struct sock *sk, struct sock *parent);
469struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
470 int proto, gfp_t prio);
471void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err);
472struct l2cap_chan *l2cap_chan_create(struct sock *sk);
473void l2cap_chan_del(struct l2cap_chan *chan, int err);
474void l2cap_chan_destroy(struct l2cap_chan *chan);
475int l2cap_chan_connect(struct l2cap_chan *chan);
427 476
428#endif /* __L2CAP_H */ 477#endif /* __L2CAP_H */
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
new file mode 100644
index 000000000000..4899286ed4e4
--- /dev/null
+++ b/include/net/bluetooth/mgmt.h
@@ -0,0 +1,291 @@
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3
4 Copyright (C) 2010 Nokia Corporation
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation;
9
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
21 SOFTWARE IS DISCLAIMED.
22*/
23
24#define MGMT_INDEX_NONE 0xFFFF
25
26struct mgmt_hdr {
27 __le16 opcode;
28 __le16 index;
29 __le16 len;
30} __packed;
31
32#define MGMT_OP_READ_VERSION 0x0001
33struct mgmt_rp_read_version {
34 __u8 version;
35 __le16 revision;
36} __packed;
37
38#define MGMT_OP_READ_INDEX_LIST 0x0003
39struct mgmt_rp_read_index_list {
40 __le16 num_controllers;
41 __le16 index[0];
42} __packed;
43
44/* Reserve one extra byte for names in management messages so that they
45 * are always guaranteed to be nul-terminated */
46#define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1)
47
48#define MGMT_OP_READ_INFO 0x0004
49struct mgmt_rp_read_info {
50 __u8 type;
51 __u8 powered;
52 __u8 connectable;
53 __u8 discoverable;
54 __u8 pairable;
55 __u8 sec_mode;
56 bdaddr_t bdaddr;
57 __u8 dev_class[3];
58 __u8 features[8];
59 __u16 manufacturer;
60 __u8 hci_ver;
61 __u16 hci_rev;
62 __u8 name[MGMT_MAX_NAME_LENGTH];
63} __packed;
64
65struct mgmt_mode {
66 __u8 val;
67} __packed;
68
69#define MGMT_OP_SET_POWERED 0x0005
70
71#define MGMT_OP_SET_DISCOVERABLE 0x0006
72
73#define MGMT_OP_SET_CONNECTABLE 0x0007
74
75#define MGMT_OP_SET_PAIRABLE 0x0008
76
77#define MGMT_OP_ADD_UUID 0x0009
78struct mgmt_cp_add_uuid {
79 __u8 uuid[16];
80 __u8 svc_hint;
81} __packed;
82
83#define MGMT_OP_REMOVE_UUID 0x000A
84struct mgmt_cp_remove_uuid {
85 __u8 uuid[16];
86} __packed;
87
88#define MGMT_OP_SET_DEV_CLASS 0x000B
89struct mgmt_cp_set_dev_class {
90 __u8 major;
91 __u8 minor;
92} __packed;
93
94#define MGMT_OP_SET_SERVICE_CACHE 0x000C
95struct mgmt_cp_set_service_cache {
96 __u8 enable;
97} __packed;
98
99struct mgmt_key_info {
100 bdaddr_t bdaddr;
101 u8 type;
102 u8 val[16];
103 u8 pin_len;
104} __packed;
105
106#define MGMT_OP_LOAD_KEYS 0x000D
107struct mgmt_cp_load_keys {
108 __u8 debug_keys;
109 __le16 key_count;
110 struct mgmt_key_info keys[0];
111} __packed;
112
113#define MGMT_OP_REMOVE_KEY 0x000E
114struct mgmt_cp_remove_key {
115 bdaddr_t bdaddr;
116 __u8 disconnect;
117} __packed;
118
119#define MGMT_OP_DISCONNECT 0x000F
120struct mgmt_cp_disconnect {
121 bdaddr_t bdaddr;
122} __packed;
123struct mgmt_rp_disconnect {
124 bdaddr_t bdaddr;
125} __packed;
126
127#define MGMT_OP_GET_CONNECTIONS 0x0010
128struct mgmt_rp_get_connections {
129 __le16 conn_count;
130 bdaddr_t conn[0];
131} __packed;
132
133#define MGMT_OP_PIN_CODE_REPLY 0x0011
134struct mgmt_cp_pin_code_reply {
135 bdaddr_t bdaddr;
136 __u8 pin_len;
137 __u8 pin_code[16];
138} __packed;
139struct mgmt_rp_pin_code_reply {
140 bdaddr_t bdaddr;
141 uint8_t status;
142} __packed;
143
144#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012
145struct mgmt_cp_pin_code_neg_reply {
146 bdaddr_t bdaddr;
147} __packed;
148
149#define MGMT_OP_SET_IO_CAPABILITY 0x0013
150struct mgmt_cp_set_io_capability {
151 __u8 io_capability;
152} __packed;
153
154#define MGMT_OP_PAIR_DEVICE 0x0014
155struct mgmt_cp_pair_device {
156 bdaddr_t bdaddr;
157 __u8 io_cap;
158} __packed;
159struct mgmt_rp_pair_device {
160 bdaddr_t bdaddr;
161 __u8 status;
162} __packed;
163
164#define MGMT_OP_USER_CONFIRM_REPLY 0x0015
165struct mgmt_cp_user_confirm_reply {
166 bdaddr_t bdaddr;
167} __packed;
168struct mgmt_rp_user_confirm_reply {
169 bdaddr_t bdaddr;
170 __u8 status;
171} __packed;
172
173#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016
174
175#define MGMT_OP_SET_LOCAL_NAME 0x0017
176struct mgmt_cp_set_local_name {
177 __u8 name[MGMT_MAX_NAME_LENGTH];
178} __packed;
179
180#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018
181struct mgmt_rp_read_local_oob_data {
182 __u8 hash[16];
183 __u8 randomizer[16];
184} __packed;
185
186#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019
187struct mgmt_cp_add_remote_oob_data {
188 bdaddr_t bdaddr;
189 __u8 hash[16];
190 __u8 randomizer[16];
191} __packed;
192
193#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A
194struct mgmt_cp_remove_remote_oob_data {
195 bdaddr_t bdaddr;
196} __packed;
197
198#define MGMT_OP_START_DISCOVERY 0x001B
199
200#define MGMT_OP_STOP_DISCOVERY 0x001C
201
202#define MGMT_EV_CMD_COMPLETE 0x0001
203struct mgmt_ev_cmd_complete {
204 __le16 opcode;
205 __u8 data[0];
206} __packed;
207
208#define MGMT_EV_CMD_STATUS 0x0002
209struct mgmt_ev_cmd_status {
210 __u8 status;
211 __le16 opcode;
212} __packed;
213
214#define MGMT_EV_CONTROLLER_ERROR 0x0003
215struct mgmt_ev_controller_error {
216 __u8 error_code;
217} __packed;
218
219#define MGMT_EV_INDEX_ADDED 0x0004
220
221#define MGMT_EV_INDEX_REMOVED 0x0005
222
223#define MGMT_EV_POWERED 0x0006
224
225#define MGMT_EV_DISCOVERABLE 0x0007
226
227#define MGMT_EV_CONNECTABLE 0x0008
228
229#define MGMT_EV_PAIRABLE 0x0009
230
231#define MGMT_EV_NEW_KEY 0x000A
232struct mgmt_ev_new_key {
233 __u8 store_hint;
234 struct mgmt_key_info key;
235} __packed;
236
237#define MGMT_EV_CONNECTED 0x000B
238struct mgmt_ev_connected {
239 bdaddr_t bdaddr;
240} __packed;
241
242#define MGMT_EV_DISCONNECTED 0x000C
243struct mgmt_ev_disconnected {
244 bdaddr_t bdaddr;
245} __packed;
246
247#define MGMT_EV_CONNECT_FAILED 0x000D
248struct mgmt_ev_connect_failed {
249 bdaddr_t bdaddr;
250 __u8 status;
251} __packed;
252
253#define MGMT_EV_PIN_CODE_REQUEST 0x000E
254struct mgmt_ev_pin_code_request {
255 bdaddr_t bdaddr;
256 __u8 secure;
257} __packed;
258
259#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
260struct mgmt_ev_user_confirm_request {
261 bdaddr_t bdaddr;
262 __u8 confirm_hint;
263 __le32 value;
264} __packed;
265
266#define MGMT_EV_AUTH_FAILED 0x0010
267struct mgmt_ev_auth_failed {
268 bdaddr_t bdaddr;
269 __u8 status;
270} __packed;
271
272#define MGMT_EV_LOCAL_NAME_CHANGED 0x0011
273struct mgmt_ev_local_name_changed {
274 __u8 name[MGMT_MAX_NAME_LENGTH];
275} __packed;
276
277#define MGMT_EV_DEVICE_FOUND 0x0012
278struct mgmt_ev_device_found {
279 bdaddr_t bdaddr;
280 __u8 dev_class[3];
281 __s8 rssi;
282 __u8 eir[HCI_MAX_EIR_LENGTH];
283} __packed;
284
285#define MGMT_EV_REMOTE_NAME 0x0013
286struct mgmt_ev_remote_name {
287 bdaddr_t bdaddr;
288 __u8 name[MGMT_MAX_NAME_LENGTH];
289} __packed;
290
291#define MGMT_EV_DISCOVERING 0x0014
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index a140847d622c..6eac4a760c3b 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -1,5 +1,5 @@
1/* 1/*
2 RFCOMM implementation for Linux Bluetooth stack (BlueZ). 2 RFCOMM implementation for Linux Bluetooth stack (BlueZ)
3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> 3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> 4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
5 5
@@ -11,13 +11,13 @@
11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 18
19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
21 SOFTWARE IS DISCLAIMED. 21 SOFTWARE IS DISCLAIMED.
22*/ 22*/
23 23
@@ -105,7 +105,7 @@
105struct rfcomm_hdr { 105struct rfcomm_hdr {
106 u8 addr; 106 u8 addr;
107 u8 ctrl; 107 u8 ctrl;
108 u8 len; // Actual size can be 2 bytes 108 u8 len; /* Actual size can be 2 bytes */
109} __packed; 109} __packed;
110 110
111struct rfcomm_cmd { 111struct rfcomm_cmd {
@@ -213,11 +213,6 @@ struct rfcomm_dlc {
213#define RFCOMM_DEFER_SETUP 8 213#define RFCOMM_DEFER_SETUP 8
214 214
215/* Scheduling flags and events */ 215/* Scheduling flags and events */
216#define RFCOMM_SCHED_STATE 0
217#define RFCOMM_SCHED_RX 1
218#define RFCOMM_SCHED_TX 2
219#define RFCOMM_SCHED_TIMEO 3
220#define RFCOMM_SCHED_AUTH 4
221#define RFCOMM_SCHED_WAKEUP 31 216#define RFCOMM_SCHED_WAKEUP 31
222 217
223/* MSC exchange flags */ 218/* MSC exchange flags */
@@ -233,7 +228,7 @@ struct rfcomm_dlc {
233/* ---- RFCOMM SEND RPN ---- */ 228/* ---- RFCOMM SEND RPN ---- */
234int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, 229int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
235 u8 bit_rate, u8 data_bits, u8 stop_bits, 230 u8 bit_rate, u8 data_bits, u8 stop_bits,
236 u8 parity, u8 flow_ctrl_settings, 231 u8 parity, u8 flow_ctrl_settings,
237 u8 xon_char, u8 xoff_char, u16 param_mask); 232 u8 xon_char, u8 xoff_char, u16 param_mask);
238 233
239/* ---- RFCOMM DLCs (channels) ---- */ 234/* ---- RFCOMM DLCs (channels) ---- */
diff --git a/include/net/bluetooth/sco.h b/include/net/bluetooth/sco.h
index e28a2a771471..1e35c43657c8 100644
--- a/include/net/bluetooth/sco.h
+++ b/include/net/bluetooth/sco.h
@@ -1,4 +1,4 @@
1/* 1/*
2 BlueZ - Bluetooth protocol stack for Linux 2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated 3 Copyright (C) 2000-2001 Qualcomm Incorporated
4 4
@@ -12,13 +12,13 @@
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED. 22 SOFTWARE IS DISCLAIMED.
23*/ 23*/
24 24
@@ -55,11 +55,11 @@ struct sco_conninfo {
55struct sco_conn { 55struct sco_conn {
56 struct hci_conn *hcon; 56 struct hci_conn *hcon;
57 57
58 bdaddr_t *dst; 58 bdaddr_t *dst;
59 bdaddr_t *src; 59 bdaddr_t *src;
60 60
61 spinlock_t lock; 61 spinlock_t lock;
62 struct sock *sk; 62 struct sock *sk;
63 63
64 unsigned int mtu; 64 unsigned int mtu;
65}; 65};
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h
new file mode 100644
index 000000000000..8f2edbf979dc
--- /dev/null
+++ b/include/net/bluetooth/smp.h
@@ -0,0 +1,76 @@
1#ifndef __SMP_H
2#define __SMP_H
3
4struct smp_command_hdr {
5 __u8 code;
6} __packed;
7
8#define SMP_CMD_PAIRING_REQ 0x01
9#define SMP_CMD_PAIRING_RSP 0x02
10struct smp_cmd_pairing {
11 __u8 io_capability;
12 __u8 oob_flag;
13 __u8 auth_req;
14 __u8 max_key_size;
15 __u8 init_key_dist;
16 __u8 resp_key_dist;
17} __packed;
18
19#define SMP_CMD_PAIRING_CONFIRM 0x03
20struct smp_cmd_pairing_confirm {
21 __u8 confirm_val[16];
22} __packed;
23
24#define SMP_CMD_PAIRING_RANDOM 0x04
25struct smp_cmd_pairing_random {
26 __u8 rand_val[16];
27} __packed;
28
29#define SMP_CMD_PAIRING_FAIL 0x05
30struct smp_cmd_pairing_fail {
31 __u8 reason;
32} __packed;
33
34#define SMP_CMD_ENCRYPT_INFO 0x06
35struct smp_cmd_encrypt_info {
36 __u8 ltk[16];
37} __packed;
38
39#define SMP_CMD_MASTER_IDENT 0x07
40struct smp_cmd_master_ident {
41 __u16 ediv;
42 __u8 rand[8];
43} __packed;
44
45#define SMP_CMD_IDENT_INFO 0x08
46struct smp_cmd_ident_info {
47 __u8 irk[16];
48} __packed;
49
50#define SMP_CMD_IDENT_ADDR_INFO 0x09
51struct smp_cmd_ident_addr_info {
52 __u8 addr_type;
53 bdaddr_t bdaddr;
54} __packed;
55
56#define SMP_CMD_SIGN_INFO 0x0a
57struct smp_cmd_sign_info {
58 __u8 csrk[16];
59} __packed;
60
61#define SMP_CMD_SECURITY_REQ 0x0b
62struct smp_cmd_security_req {
63 __u8 auth_req;
64} __packed;
65
66#define SMP_PASSKEY_ENTRY_FAILED 0x01
67#define SMP_OOB_NOT_AVAIL 0x02
68#define SMP_AUTH_REQUIREMENTS 0x03
69#define SMP_CONFIRM_FAILED 0x04
70#define SMP_PAIRING_NOTSUPP 0x05
71#define SMP_ENC_KEY_SIZE 0x06
72#define SMP_CMD_NOTSUPP 0x07
73#define SMP_UNSPECIFIED 0x08
74#define SMP_REPEATED_ATTEMPTS 0x09
75
76#endif /* __SMP_H */
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h
index 6da573c75d54..c011281d92c0 100644
--- a/include/net/caif/caif_dev.h
+++ b/include/net/caif/caif_dev.h
@@ -11,6 +11,7 @@
11#include <net/caif/cfcnfg.h> 11#include <net/caif/cfcnfg.h>
12#include <linux/caif/caif_socket.h> 12#include <linux/caif/caif_socket.h>
13#include <linux/if.h> 13#include <linux/if.h>
14#include <linux/net.h>
14 15
15/** 16/**
16 * struct caif_param - CAIF parameters. 17 * struct caif_param - CAIF parameters.
@@ -28,7 +29,7 @@ struct caif_param {
28 * @sockaddr: Socket address to connect. 29 * @sockaddr: Socket address to connect.
29 * @priority: Priority of the connection. 30 * @priority: Priority of the connection.
30 * @link_selector: Link selector (high bandwidth or low latency) 31 * @link_selector: Link selector (high bandwidth or low latency)
31 * @link_name: Name of the CAIF Link Layer to use. 32 * @ifindex: kernel index of the interface.
32 * @param: Connect Request parameters (CAIF_SO_REQ_PARAM). 33 * @param: Connect Request parameters (CAIF_SO_REQ_PARAM).
33 * 34 *
34 * This struct is used when connecting a CAIF channel. 35 * This struct is used when connecting a CAIF channel.
@@ -39,7 +40,7 @@ struct caif_connect_request {
39 struct sockaddr_caif sockaddr; 40 struct sockaddr_caif sockaddr;
40 enum caif_channel_priority priority; 41 enum caif_channel_priority priority;
41 enum caif_link_selector link_selector; 42 enum caif_link_selector link_selector;
42 char link_name[16]; 43 int ifindex;
43 struct caif_param param; 44 struct caif_param param;
44}; 45};
45 46
@@ -62,46 +63,45 @@ struct caif_connect_request {
62 * E.g. CAIF Socket will call this function for each socket it connects 63 * E.g. CAIF Socket will call this function for each socket it connects
63 * and have one client_layer instance for each socket. 64 * and have one client_layer instance for each socket.
64 */ 65 */
65int caif_connect_client(struct caif_connect_request *conn_req, 66int caif_connect_client(struct net *net,
67 struct caif_connect_request *conn_req,
66 struct cflayer *client_layer, int *ifindex, 68 struct cflayer *client_layer, int *ifindex,
67 int *headroom, int *tailroom); 69 int *headroom, int *tailroom);
68 70
69/** 71/**
70 * caif_disconnect_client - Disconnects a client from the CAIF stack. 72 * caif_disconnect_client - Disconnects a client from the CAIF stack.
71 * 73 *
72 * @client_layer: Client layer to be removed. 74 * @client_layer: Client layer to be disconnected.
73 */ 75 */
74int caif_disconnect_client(struct cflayer *client_layer); 76int caif_disconnect_client(struct net *net, struct cflayer *client_layer);
77
75 78
76/** 79/**
77 * caif_release_client - Release adaptation layer reference to client. 80 * caif_client_register_refcnt - register ref-count functions provided by client.
78 * 81 *
79 * @client_layer: Client layer. 82 * @adapt_layer: Client layer using CAIF Stack.
83 * @hold: Function provided by client layer increasing ref-count
84 * @put: Function provided by client layer decreasing ref-count
80 * 85 *
81 * Releases a client/adaptation layer use of the caif stack. 86 * Client of the CAIF Stack must register functions for reference counting.
82 * This function must be used after caif_disconnect_client to 87 * These functions are called by the CAIF Stack for every upstream packet,
83 * decrease the reference count of the service layer. 88 * and must therefore be implemented efficiently.
84 */
85void caif_release_client(struct cflayer *client_layer);
86
87/**
88 * connect_req_to_link_param - Translate configuration parameters
89 * from socket format to internal format.
90 * @cnfg: Pointer to configuration handler
91 * @con_req: Configuration parameters supplied in function
92 * caif_connect_client
93 * @channel_setup_param: Parameters supplied to the CAIF Core stack for
94 * setting up channels.
95 * 89 *
90 * Client should call caif_free_client when reference count degrease to zero.
96 */ 91 */
97int connect_req_to_link_param(struct cfcnfg *cnfg,
98 struct caif_connect_request *con_req,
99 struct cfctrl_link_param *channel_setup_param);
100 92
93void caif_client_register_refcnt(struct cflayer *adapt_layer,
94 void (*hold)(struct cflayer *lyr),
95 void (*put)(struct cflayer *lyr));
101/** 96/**
102 * get_caif_conf() - Get the configuration handler. 97 * caif_free_client - Free memory used to manage the client in the CAIF Stack.
98 *
99 * @client_layer: Client layer to be removed.
100 *
101 * This function must be called from client layer in order to free memory.
102 * Caller must guarantee that no packets are in flight upstream when calling
103 * this function.
103 */ 104 */
104struct cfcnfg *get_caif_conf(void); 105void caif_free_client(struct cflayer *adap_layer);
105
106 106
107#endif /* CAIF_DEV_H_ */ 107#endif /* CAIF_DEV_H_ */
diff --git a/include/net/caif/caif_layer.h b/include/net/caif/caif_layer.h
index c8b07a904e78..35bc7883cf97 100644
--- a/include/net/caif/caif_layer.h
+++ b/include/net/caif/caif_layer.h
@@ -15,7 +15,6 @@ struct cfpktq;
15struct caif_payload_info; 15struct caif_payload_info;
16struct caif_packet_funcs; 16struct caif_packet_funcs;
17 17
18
19#define CAIF_LAYER_NAME_SZ 16 18#define CAIF_LAYER_NAME_SZ 16
20 19
21/** 20/**
@@ -33,7 +32,6 @@ do { \
33 } \ 32 } \
34} while (0) 33} while (0)
35 34
36
37/** 35/**
38 * enum caif_ctrlcmd - CAIF Stack Control Signaling sent in layer.ctrlcmd(). 36 * enum caif_ctrlcmd - CAIF Stack Control Signaling sent in layer.ctrlcmd().
39 * 37 *
@@ -141,7 +139,7 @@ enum caif_direction {
141 * - All layers must use this structure. If embedding it, then place this 139 * - All layers must use this structure. If embedding it, then place this
142 * structure first in the layer specific structure. 140 * structure first in the layer specific structure.
143 * 141 *
144 * - Each layer should not depend on any others layer private data. 142 * - Each layer should not depend on any others layer's private data.
145 * 143 *
146 * - In order to send data upwards do 144 * - In order to send data upwards do
147 * layer->up->receive(layer->up, packet); 145 * layer->up->receive(layer->up, packet);
@@ -155,16 +153,23 @@ struct cflayer {
155 struct list_head node; 153 struct list_head node;
156 154
157 /* 155 /*
158 * receive() - Receive Function. 156 * receive() - Receive Function (non-blocking).
159 * Contract: Each layer must implement a receive function passing the 157 * Contract: Each layer must implement a receive function passing the
160 * CAIF packets upwards in the stack. 158 * CAIF packets upwards in the stack.
161 * Packet handling rules: 159 * Packet handling rules:
162 * - The CAIF packet (cfpkt) cannot be accessed after 160 * - The CAIF packet (cfpkt) ownership is passed to the
163 * passing it to the next layer using up->receive(). 161 * called receive function. This means that the the
162 * packet cannot be accessed after passing it to the
163 * above layer using up->receive().
164 *
164 * - If parsing of the packet fails, the packet must be 165 * - If parsing of the packet fails, the packet must be
165 * destroyed and -1 returned from the function. 166 * destroyed and negative error code returned
167 * from the function.
168 * EXCEPTION: If the framing layer (cffrml) returns
169 * -EILSEQ, the packet is not freed.
170 *
166 * - If parsing succeeds (and above layers return OK) then 171 * - If parsing succeeds (and above layers return OK) then
167 * the function must return a value > 0. 172 * the function must return a value >= 0.
168 * 173 *
169 * Returns result < 0 indicates an error, 0 or positive value 174 * Returns result < 0 indicates an error, 0 or positive value
170 * indicates success. 175 * indicates success.
@@ -176,7 +181,7 @@ struct cflayer {
176 int (*receive)(struct cflayer *layr, struct cfpkt *cfpkt); 181 int (*receive)(struct cflayer *layr, struct cfpkt *cfpkt);
177 182
178 /* 183 /*
179 * transmit() - Transmit Function. 184 * transmit() - Transmit Function (non-blocking).
180 * Contract: Each layer must implement a transmit function passing the 185 * Contract: Each layer must implement a transmit function passing the
181 * CAIF packet downwards in the stack. 186 * CAIF packet downwards in the stack.
182 * Packet handling rules: 187 * Packet handling rules:
@@ -185,15 +190,16 @@ struct cflayer {
185 * cannot be accessed after passing it to the below 190 * cannot be accessed after passing it to the below
186 * layer using dn->transmit(). 191 * layer using dn->transmit().
187 * 192 *
188 * - If transmit fails, however, the ownership is returned 193 * - Upon error the packet ownership is still passed on,
189 * to thecaller. The caller of "dn->transmit()" must 194 * so the packet shall be freed where error is detected.
190 * destroy or resend packet. 195 * Callers of the transmit function shall not free packets,
196 * but errors shall be returned.
191 * 197 *
192 * - Return value less than zero means error, zero or 198 * - Return value less than zero means error, zero or
193 * greater than zero means OK. 199 * greater than zero means OK.
194 * 200 *
195 * result < 0 indicates an error, 0 or positive value 201 * Returns result < 0 indicates an error, 0 or positive value
196 * indicate success. 202 * indicates success.
197 * 203 *
198 * @layr: Pointer to the current layer the receive function 204 * @layr: Pointer to the current layer the receive function
199 * isimplemented for (this pointer). 205 * isimplemented for (this pointer).
@@ -202,7 +208,7 @@ struct cflayer {
202 int (*transmit) (struct cflayer *layr, struct cfpkt *cfpkt); 208 int (*transmit) (struct cflayer *layr, struct cfpkt *cfpkt);
203 209
204 /* 210 /*
205 * cttrlcmd() - Control Function upwards in CAIF Stack. 211 * cttrlcmd() - Control Function upwards in CAIF Stack (non-blocking).
206 * Used for signaling responses (CAIF_CTRLCMD_*_RSP) 212 * Used for signaling responses (CAIF_CTRLCMD_*_RSP)
207 * and asynchronous events from the modem (CAIF_CTRLCMD_*_IND) 213 * and asynchronous events from the modem (CAIF_CTRLCMD_*_IND)
208 * 214 *
diff --git a/include/net/caif/caif_shm.h b/include/net/caif/caif_shm.h
new file mode 100644
index 000000000000..5bcce55438cf
--- /dev/null
+++ b/include/net/caif/caif_shm.h
@@ -0,0 +1,26 @@
1/*
2 * Copyright (C) ST-Ericsson AB 2010
3 * Contact: Sjur Brendeland / sjur.brandeland@stericsson.com
4 * Author: Amarnath Revanna / amarnath.bangalore.revanna@stericsson.com
5 * License terms: GNU General Public License (GPL) version 2
6 */
7
8#ifndef CAIF_SHM_H_
9#define CAIF_SHM_H_
10
11struct shmdev_layer {
12 u32 shm_base_addr;
13 u32 shm_total_sz;
14 u32 shm_id;
15 u32 shm_loopback;
16 void *hmbx;
17 int (*pshmdev_mbxsend) (u32 shm_id, u32 mbx_msg);
18 int (*pshmdev_mbxsetup) (void *pshmdrv_cb,
19 struct shmdev_layer *pshm_dev, void *pshm_drv);
20 struct net_device *pshm_netdev;
21};
22
23extern int caif_shmcore_probe(struct shmdev_layer *pshm_dev);
24extern void caif_shmcore_remove(struct net_device *pshm_netdev);
25
26#endif
diff --git a/include/net/caif/caif_spi.h b/include/net/caif/caif_spi.h
index ce4570dff020..87c3d11b8e55 100644
--- a/include/net/caif/caif_spi.h
+++ b/include/net/caif/caif_spi.h
@@ -121,6 +121,8 @@ struct cfspi {
121 wait_queue_head_t wait; 121 wait_queue_head_t wait;
122 spinlock_t lock; 122 spinlock_t lock;
123 bool flow_stop; 123 bool flow_stop;
124 bool slave;
125 bool slave_talked;
124#ifdef CONFIG_DEBUG_FS 126#ifdef CONFIG_DEBUG_FS
125 enum cfspi_state dbg_state; 127 enum cfspi_state dbg_state;
126 u16 pcmd; 128 u16 pcmd;
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h
index bd646faffa47..3e93a4a4b677 100644
--- a/include/net/caif/cfcnfg.h
+++ b/include/net/caif/cfcnfg.h
@@ -46,6 +46,12 @@ enum cfcnfg_phy_preference {
46}; 46};
47 47
48/** 48/**
49 * cfcnfg_create() - Get the CAIF configuration object given network.
50 * @net: Network for the CAIF configuration object.
51 */
52struct cfcnfg *get_cfcnfg(struct net *net);
53
54/**
49 * cfcnfg_create() - Create the CAIF configuration object. 55 * cfcnfg_create() - Create the CAIF configuration object.
50 */ 56 */
51struct cfcnfg *cfcnfg_create(void); 57struct cfcnfg *cfcnfg_create(void);
@@ -65,8 +71,6 @@ void cfcnfg_remove(struct cfcnfg *cfg);
65 * @dev: Pointer to link layer device 71 * @dev: Pointer to link layer device
66 * @phy_layer: Specify the physical layer. The transmit function 72 * @phy_layer: Specify the physical layer. The transmit function
67 * MUST be set in the structure. 73 * MUST be set in the structure.
68 * @phyid: The assigned physical ID for this layer, used in
69 * cfcnfg_add_adapt_layer to specify PHY for the link.
70 * @pref: The phy (link layer) preference. 74 * @pref: The phy (link layer) preference.
71 * @fcs: Specify if checksum is used in CAIF Framing Layer. 75 * @fcs: Specify if checksum is used in CAIF Framing Layer.
72 * @stx: Specify if Start Of Frame eXtention is used. 76 * @stx: Specify if Start Of Frame eXtention is used.
@@ -75,7 +79,7 @@ void cfcnfg_remove(struct cfcnfg *cfg);
75void 79void
76cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, 80cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
77 struct net_device *dev, struct cflayer *phy_layer, 81 struct net_device *dev, struct cflayer *phy_layer,
78 u16 *phyid, enum cfcnfg_phy_preference pref, 82 enum cfcnfg_phy_preference pref,
79 bool fcs, bool stx); 83 bool fcs, bool stx);
80 84
81/** 85/**
@@ -88,61 +92,12 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
88int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer); 92int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer);
89 93
90/** 94/**
91 * cfcnfg_disconn_adapt_layer - Disconnects an adaptation layer. 95 * cfcnfg_set_phy_state() - Set the state of the physical interface device.
92 *
93 * @cnfg: Pointer to a CAIF configuration object, created by
94 * cfcnfg_create().
95 * @adap_layer: Adaptation layer to be removed.
96 */
97int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg,
98 struct cflayer *adap_layer);
99
100/**
101 * cfcnfg_release_adap_layer - Used by client to release the adaptation layer.
102 *
103 * @adap_layer: Adaptation layer.
104 */
105void cfcnfg_release_adap_layer(struct cflayer *adap_layer);
106
107/**
108 * cfcnfg_add_adaptation_layer - Add an adaptation layer to the CAIF stack.
109 *
110 * The adaptation Layer is where the interface to application or higher-level
111 * driver functionality is implemented.
112 *
113 * @cnfg: Pointer to a CAIF configuration object, created by
114 * cfcnfg_create().
115 * @param: Link setup parameters.
116 * @adap_layer: Specify the adaptation layer; the receive and
117 * flow-control functions MUST be set in the structure.
118 * @ifindex: Link layer interface index used for this connection.
119 * @proto_head: Protocol head-space needed by CAIF protocol,
120 * excluding link layer.
121 * @proto_tail: Protocol tail-space needed by CAIF protocol,
122 * excluding link layer.
123 */
124int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg,
125 struct cfctrl_link_param *param,
126 struct cflayer *adap_layer,
127 int *ifindex,
128 int *proto_head,
129 int *proto_tail);
130
131/**
132 * cfcnfg_get_phyid() - Get physical ID, given type.
133 * Returns one of the physical interfaces matching the given type.
134 * Zero if no match is found.
135 * @cnfg: Configuration object
136 * @phy_pref: Caif Link Layer preference
137 */
138struct dev_info *cfcnfg_get_phyid(struct cfcnfg *cnfg,
139 enum cfcnfg_phy_preference phy_pref);
140
141/**
142 * cfcnfg_get_named() - Get the Physical Identifier of CAIF Link Layer
143 * @cnfg: Configuration object 96 * @cnfg: Configuration object
144 * @name: Name of the Physical Layer (Caif Link Layer) 97 * @phy_layer: Physical Layer representation
98 * @up: State of device
145 */ 99 */
146int cfcnfg_get_named(struct cfcnfg *cnfg, char *name); 100int cfcnfg_set_phy_state(struct cfcnfg *cnfg, struct cflayer *phy_layer,
101 bool up);
147 102
148#endif /* CFCNFG_H_ */ 103#endif /* CFCNFG_H_ */
diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
index 9402543fc20d..9e5425b4a1d7 100644
--- a/include/net/caif/cfctrl.h
+++ b/include/net/caif/cfctrl.h
@@ -51,7 +51,7 @@ struct cfctrl_rsp {
51 void (*restart_rsp)(void); 51 void (*restart_rsp)(void);
52 void (*radioset_rsp)(void); 52 void (*radioset_rsp)(void);
53 void (*reject_rsp)(struct cflayer *layer, u8 linkid, 53 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
54 struct cflayer *client_layer);; 54 struct cflayer *client_layer);
55}; 55};
56 56
57/* Link Setup Parameters for CAIF-Links. */ 57/* Link Setup Parameters for CAIF-Links. */
@@ -121,19 +121,10 @@ int cfctrl_linkup_request(struct cflayer *cfctrl,
121 struct cflayer *user_layer); 121 struct cflayer *user_layer);
122int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid, 122int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid,
123 struct cflayer *client); 123 struct cflayer *client);
124void cfctrl_sleep_req(struct cflayer *cfctrl); 124
125void cfctrl_wake_req(struct cflayer *cfctrl);
126void cfctrl_getstartreason_req(struct cflayer *cfctrl);
127struct cflayer *cfctrl_create(void); 125struct cflayer *cfctrl_create(void);
128void cfctrl_set_dnlayer(struct cflayer *this, struct cflayer *dn);
129void cfctrl_set_uplayer(struct cflayer *this, struct cflayer *up);
130struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer); 126struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer);
131bool cfctrl_req_eq(struct cfctrl_request_info *r1, 127int cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer);
132 struct cfctrl_request_info *r2); 128void cfctrl_remove(struct cflayer *layr);
133void cfctrl_insert_req(struct cfctrl *ctrl,
134 struct cfctrl_request_info *req);
135struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
136 struct cfctrl_request_info *req);
137void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer);
138 129
139#endif /* CFCTRL_H_ */ 130#endif /* CFCTRL_H_ */
diff --git a/include/net/caif/cffrml.h b/include/net/caif/cffrml.h
index 3f14d2e1ce61..afac1a48cce7 100644
--- a/include/net/caif/cffrml.h
+++ b/include/net/caif/cffrml.h
@@ -7,10 +7,15 @@
7#ifndef CFFRML_H_ 7#ifndef CFFRML_H_
8#define CFFRML_H_ 8#define CFFRML_H_
9#include <net/caif/caif_layer.h> 9#include <net/caif/caif_layer.h>
10#include <linux/netdevice.h>
10 11
11struct cffrml; 12struct cffrml;
12struct cflayer *cffrml_create(u16 phyid, bool DoFCS); 13struct cflayer *cffrml_create(u16 phyid, bool use_fcs);
14void cffrml_free(struct cflayer *layr);
13void cffrml_set_uplayer(struct cflayer *this, struct cflayer *up); 15void cffrml_set_uplayer(struct cflayer *this, struct cflayer *up);
14void cffrml_set_dnlayer(struct cflayer *this, struct cflayer *dn); 16void cffrml_set_dnlayer(struct cflayer *this, struct cflayer *dn);
17void cffrml_put(struct cflayer *layr);
18void cffrml_hold(struct cflayer *layr);
19int cffrml_refcnt_read(struct cflayer *layr);
15 20
16#endif /* CFFRML_H_ */ 21#endif /* CFFRML_H_ */
diff --git a/include/net/caif/cfmuxl.h b/include/net/caif/cfmuxl.h
index 4e1b4f33423e..5847a196b8ad 100644
--- a/include/net/caif/cfmuxl.h
+++ b/include/net/caif/cfmuxl.h
@@ -16,7 +16,5 @@ int cfmuxl_set_uplayer(struct cflayer *layr, struct cflayer *up, u8 linkid);
16struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid); 16struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid);
17int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid); 17int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid);
18struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid); 18struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid);
19bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid);
20u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id);
21 19
22#endif /* CFMUXL_H_ */ 20#endif /* CFMUXL_H_ */
diff --git a/include/net/caif/cfpkt.h b/include/net/caif/cfpkt.h
index fbc681beff52..6bd200a4754a 100644
--- a/include/net/caif/cfpkt.h
+++ b/include/net/caif/cfpkt.h
@@ -16,12 +16,6 @@ struct cfpkt;
16 */ 16 */
17struct cfpkt *cfpkt_create(u16 len); 17struct cfpkt *cfpkt_create(u16 len);
18 18
19/* Create a CAIF packet.
20 * data Data to copy.
21 * len Length of packet to be created
22 * @return New packet.
23 */
24struct cfpkt *cfpkt_create_uplink(const unsigned char *data, unsigned int len);
25/* 19/*
26 * Destroy a CAIF Packet. 20 * Destroy a CAIF Packet.
27 * pkt Packet to be destoyed. 21 * pkt Packet to be destoyed.
@@ -181,22 +175,6 @@ u16 cfpkt_iterate(struct cfpkt *pkt,
181 u16 (*iter_func)(u16 chks, void *buf, u16 len), 175 u16 (*iter_func)(u16 chks, void *buf, u16 len),
182 u16 data); 176 u16 data);
183 177
184/* Append by giving user access to packet buffer
185 * cfpkt Packet to append to
186 * buf Buffer inside pkt that user shall copy data into
187 * buflen Length of buffer and number of bytes added to packet
188 * @return 0 on error, 1 on success
189 */
190int cfpkt_raw_append(struct cfpkt *cfpkt, void **buf, unsigned int buflen);
191
192/* Extract by giving user access to packet buffer
193 * cfpkt Packet to extract from
194 * buf Buffer inside pkt that user shall copy data from
195 * buflen Length of buffer and number of bytes removed from packet
196 * @return 0 on error, 1 on success
197 */
198int cfpkt_raw_extract(struct cfpkt *cfpkt, void **buf, unsigned int buflen);
199
200/* Map from a "native" packet (e.g. Linux Socket Buffer) to a CAIF packet. 178/* Map from a "native" packet (e.g. Linux Socket Buffer) to a CAIF packet.
201 * dir - Direction indicating whether this packet is to be sent or received. 179 * dir - Direction indicating whether this packet is to be sent or received.
202 * nativepkt - The native packet to be transformed to a CAIF packet 180 * nativepkt - The native packet to be transformed to a CAIF packet
@@ -210,59 +188,6 @@ struct cfpkt *cfpkt_fromnative(enum caif_direction dir, void *nativepkt);
210 */ 188 */
211void *cfpkt_tonative(struct cfpkt *pkt); 189void *cfpkt_tonative(struct cfpkt *pkt);
212 190
213/*
214 * Insert a packet in the packet queue.
215 * pktq Packet queue to insert into
216 * pkt Packet to be inserted in queue
217 * prio Priority of packet
218 */
219void cfpkt_queue(struct cfpktq *pktq, struct cfpkt *pkt,
220 unsigned short prio);
221
222/*
223 * Remove a packet from the packet queue.
224 * pktq Packet queue to fetch packets from.
225 * @return Dequeued packet.
226 */
227struct cfpkt *cfpkt_dequeue(struct cfpktq *pktq);
228
229/*
230 * Peek into a packet from the packet queue.
231 * pktq Packet queue to fetch packets from.
232 * @return Peeked packet.
233 */
234struct cfpkt *cfpkt_qpeek(struct cfpktq *pktq);
235
236/*
237 * Initiates the packet queue.
238 * @return Pointer to new packet queue.
239 */
240struct cfpktq *cfpktq_create(void);
241
242/*
243 * Get the number of packets in the queue.
244 * pktq Packet queue to fetch count from.
245 * @return Number of packets in queue.
246 */
247int cfpkt_qcount(struct cfpktq *pktq);
248
249/*
250 * Put content of packet into buffer for debuging purposes.
251 * pkt Packet to copy data from
252 * buf Buffer to copy data into
253 * buflen Length of data to copy
254 * @return Pointer to copied data
255 */
256char *cfpkt_log_pkt(struct cfpkt *pkt, char *buf, int buflen);
257
258/*
259 * Clones a packet and releases the original packet.
260 * This is used for taking ownership of a packet e.g queueing.
261 * pkt Packet to clone and release.
262 * @return Cloned packet.
263 */
264struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt);
265
266 191
267/* 192/*
268 * Returns packet information for a packet. 193 * Returns packet information for a packet.
@@ -270,5 +195,4 @@ struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt);
270 * @return Packet information 195 * @return Packet information
271 */ 196 */
272struct caif_payload_info *cfpkt_info(struct cfpkt *pkt); 197struct caif_payload_info *cfpkt_info(struct cfpkt *pkt);
273/*! @} */
274#endif /* CFPKT_H_ */ 198#endif /* CFPKT_H_ */
diff --git a/include/net/caif/cfsrvl.h b/include/net/caif/cfsrvl.h
index b1fa87ee0992..0f5905241843 100644
--- a/include/net/caif/cfsrvl.h
+++ b/include/net/caif/cfsrvl.h
@@ -10,6 +10,7 @@
10#include <linux/stddef.h> 10#include <linux/stddef.h>
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/kref.h> 12#include <linux/kref.h>
13#include <linux/rculist.h>
13 14
14struct cfsrvl { 15struct cfsrvl {
15 struct cflayer layer; 16 struct cflayer layer;
@@ -17,12 +18,13 @@ struct cfsrvl {
17 bool phy_flow_on; 18 bool phy_flow_on;
18 bool modem_flow_on; 19 bool modem_flow_on;
19 bool supports_flowctrl; 20 bool supports_flowctrl;
20 void (*release)(struct kref *); 21 void (*release)(struct cflayer *layer);
21 struct dev_info dev_info; 22 struct dev_info dev_info;
22 struct kref ref; 23 void (*hold)(struct cflayer *lyr);
24 void (*put)(struct cflayer *lyr);
25 struct rcu_head rcu;
23}; 26};
24 27
25void cfsrvl_release(struct kref *kref);
26struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); 28struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info);
27struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); 29struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info);
28struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); 30struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info);
@@ -30,8 +32,12 @@ struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info);
30struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, 32struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info,
31 int mtu_size); 33 int mtu_size);
32struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); 34struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
35
36void cfsrvl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
37 int phyid);
38
33bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); 39bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
34void cfservl_destroy(struct cflayer *layer); 40
35void cfsrvl_init(struct cfsrvl *service, 41void cfsrvl_init(struct cfsrvl *service,
36 u8 channel_id, 42 u8 channel_id,
37 struct dev_info *dev_info, 43 struct dev_info *dev_info,
@@ -41,23 +47,19 @@ u8 cfsrvl_getphyid(struct cflayer *layer);
41 47
42static inline void cfsrvl_get(struct cflayer *layr) 48static inline void cfsrvl_get(struct cflayer *layr)
43{ 49{
44 struct cfsrvl *s; 50 struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
45 if (layr == NULL) 51 if (layr == NULL || layr->up == NULL || s->hold == NULL)
46 return; 52 return;
47 s = container_of(layr, struct cfsrvl, layer); 53
48 kref_get(&s->ref); 54 s->hold(layr->up);
49} 55}
50 56
51static inline void cfsrvl_put(struct cflayer *layr) 57static inline void cfsrvl_put(struct cflayer *layr)
52{ 58{
53 struct cfsrvl *s; 59 struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
54 if (layr == NULL) 60 if (layr == NULL || layr->up == NULL || s->hold == NULL)
55 return; 61 return;
56 s = container_of(layr, struct cfsrvl, layer);
57 62
58 WARN_ON(!s->release); 63 s->put(layr->up);
59 if (s->release)
60 kref_put(&s->ref, s->release);
61} 64}
62
63#endif /* CFSRVL_H_ */ 65#endif /* CFSRVL_H_ */
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 2fd06c60ffbb..396e8fc8910e 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -25,6 +25,43 @@
25#include <linux/wireless.h> 25#include <linux/wireless.h>
26 26
27 27
28/**
29 * DOC: Introduction
30 *
31 * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges
32 * userspace and drivers, and offers some utility functionality associated
33 * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used
34 * by all modern wireless drivers in Linux, so that they offer a consistent
35 * API through nl80211. For backward compatibility, cfg80211 also offers
36 * wireless extensions to userspace, but hides them from drivers completely.
37 *
38 * Additionally, cfg80211 contains code to help enforce regulatory spectrum
39 * use restrictions.
40 */
41
42
43/**
44 * DOC: Device registration
45 *
46 * In order for a driver to use cfg80211, it must register the hardware device
47 * with cfg80211. This happens through a number of hardware capability structs
48 * described below.
49 *
50 * The fundamental structure for each device is the 'wiphy', of which each
51 * instance describes a physical wireless device connected to the system. Each
52 * such wiphy can have zero, one, or many virtual interfaces associated with
53 * it, which need to be identified as such by pointing the network interface's
54 * @ieee80211_ptr pointer to a &struct wireless_dev which further describes
55 * the wireless part of the interface, normally this struct is embedded in the
56 * network interface's private data area. Drivers can optionally allow creating
57 * or destroying virtual interfaces on the fly, but without at least one or the
58 * ability to create some the wireless device isn't useful.
59 *
60 * Each wiphy structure contains device capability information, and also has
61 * a pointer to the various operations the driver offers. The definitions and
62 * structures here describe these capabilities in detail.
63 */
64
28/* 65/*
29 * wireless hardware capability structures 66 * wireless hardware capability structures
30 */ 67 */
@@ -205,14 +242,25 @@ struct ieee80211_supported_band {
205 */ 242 */
206 243
207/** 244/**
245 * DOC: Actions and configuration
246 *
247 * Each wireless device and each virtual interface offer a set of configuration
248 * operations and other actions that are invoked by userspace. Each of these
249 * actions is described in the operations structure, and the parameters these
250 * operations use are described separately.
251 *
252 * Additionally, some operations are asynchronous and expect to get status
253 * information via some functions that drivers need to call.
254 *
255 * Scanning and BSS list handling with its associated functionality is described
256 * in a separate chapter.
257 */
258
259/**
208 * struct vif_params - describes virtual interface parameters 260 * struct vif_params - describes virtual interface parameters
209 * @mesh_id: mesh ID to use
210 * @mesh_id_len: length of the mesh ID
211 * @use_4addr: use 4-address frames 261 * @use_4addr: use 4-address frames
212 */ 262 */
213struct vif_params { 263struct vif_params {
214 u8 *mesh_id;
215 int mesh_id_len;
216 int use_4addr; 264 int use_4addr;
217}; 265};
218 266
@@ -241,12 +289,24 @@ struct key_params {
241 * enum survey_info_flags - survey information flags 289 * enum survey_info_flags - survey information flags
242 * 290 *
243 * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in 291 * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
292 * @SURVEY_INFO_IN_USE: channel is currently being used
293 * @SURVEY_INFO_CHANNEL_TIME: channel active time (in ms) was filled in
294 * @SURVEY_INFO_CHANNEL_TIME_BUSY: channel busy time was filled in
295 * @SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: extension channel busy time was filled in
296 * @SURVEY_INFO_CHANNEL_TIME_RX: channel receive time was filled in
297 * @SURVEY_INFO_CHANNEL_TIME_TX: channel transmit time was filled in
244 * 298 *
245 * Used by the driver to indicate which info in &struct survey_info 299 * Used by the driver to indicate which info in &struct survey_info
246 * it has filled in during the get_survey(). 300 * it has filled in during the get_survey().
247 */ 301 */
248enum survey_info_flags { 302enum survey_info_flags {
249 SURVEY_INFO_NOISE_DBM = 1<<0, 303 SURVEY_INFO_NOISE_DBM = 1<<0,
304 SURVEY_INFO_IN_USE = 1<<1,
305 SURVEY_INFO_CHANNEL_TIME = 1<<2,
306 SURVEY_INFO_CHANNEL_TIME_BUSY = 1<<3,
307 SURVEY_INFO_CHANNEL_TIME_EXT_BUSY = 1<<4,
308 SURVEY_INFO_CHANNEL_TIME_RX = 1<<5,
309 SURVEY_INFO_CHANNEL_TIME_TX = 1<<6,
250}; 310};
251 311
252/** 312/**
@@ -256,6 +316,11 @@ enum survey_info_flags {
256 * @filled: bitflag of flags from &enum survey_info_flags 316 * @filled: bitflag of flags from &enum survey_info_flags
257 * @noise: channel noise in dBm. This and all following fields are 317 * @noise: channel noise in dBm. This and all following fields are
258 * optional 318 * optional
319 * @channel_time: amount of time in ms the radio spent on the channel
320 * @channel_time_busy: amount of time the primary channel was sensed busy
321 * @channel_time_ext_busy: amount of time the extension channel was sensed busy
322 * @channel_time_rx: amount of time the radio spent receiving data
323 * @channel_time_tx: amount of time the radio spent transmitting data
259 * 324 *
260 * Used by dump_survey() to report back per-channel survey information. 325 * Used by dump_survey() to report back per-channel survey information.
261 * 326 *
@@ -264,6 +329,11 @@ enum survey_info_flags {
264 */ 329 */
265struct survey_info { 330struct survey_info {
266 struct ieee80211_channel *channel; 331 struct ieee80211_channel *channel;
332 u64 channel_time;
333 u64 channel_time_busy;
334 u64 channel_time_ext_busy;
335 u64 channel_time_rx;
336 u64 channel_time_tx;
267 u32 filled; 337 u32 filled;
268 s8 noise; 338 s8 noise;
269}; 339};
@@ -317,6 +387,7 @@ enum plink_actions {
317 * @listen_interval: listen interval or -1 for no change 387 * @listen_interval: listen interval or -1 for no change
318 * @aid: AID or zero for no change 388 * @aid: AID or zero for no change
319 * @plink_action: plink action to take 389 * @plink_action: plink action to take
390 * @plink_state: set the peer link state for a station
320 * @ht_capa: HT capabilities of station 391 * @ht_capa: HT capabilities of station
321 */ 392 */
322struct station_parameters { 393struct station_parameters {
@@ -327,6 +398,7 @@ struct station_parameters {
327 u16 aid; 398 u16 aid;
328 u8 supported_rates_len; 399 u8 supported_rates_len;
329 u8 plink_action; 400 u8 plink_action;
401 u8 plink_state;
330 struct ieee80211_ht_cap *ht_capa; 402 struct ieee80211_ht_cap *ht_capa;
331}; 403};
332 404
@@ -343,10 +415,17 @@ struct station_parameters {
343 * @STATION_INFO_PLID: @plid filled 415 * @STATION_INFO_PLID: @plid filled
344 * @STATION_INFO_PLINK_STATE: @plink_state filled 416 * @STATION_INFO_PLINK_STATE: @plink_state filled
345 * @STATION_INFO_SIGNAL: @signal filled 417 * @STATION_INFO_SIGNAL: @signal filled
346 * @STATION_INFO_TX_BITRATE: @tx_bitrate fields are filled 418 * @STATION_INFO_TX_BITRATE: @txrate fields are filled
347 * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs) 419 * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs)
348 * @STATION_INFO_RX_PACKETS: @rx_packets filled 420 * @STATION_INFO_RX_PACKETS: @rx_packets filled
349 * @STATION_INFO_TX_PACKETS: @tx_packets filled 421 * @STATION_INFO_TX_PACKETS: @tx_packets filled
422 * @STATION_INFO_TX_RETRIES: @tx_retries filled
423 * @STATION_INFO_TX_FAILED: @tx_failed filled
424 * @STATION_INFO_RX_DROP_MISC: @rx_dropped_misc filled
425 * @STATION_INFO_SIGNAL_AVG: @signal_avg filled
426 * @STATION_INFO_RX_BITRATE: @rxrate fields are filled
427 * @STATION_INFO_BSS_PARAM: @bss_param filled
428 * @STATION_INFO_CONNECTED_TIME: @connected_time filled
350 */ 429 */
351enum station_info_flags { 430enum station_info_flags {
352 STATION_INFO_INACTIVE_TIME = 1<<0, 431 STATION_INFO_INACTIVE_TIME = 1<<0,
@@ -359,6 +438,13 @@ enum station_info_flags {
359 STATION_INFO_TX_BITRATE = 1<<7, 438 STATION_INFO_TX_BITRATE = 1<<7,
360 STATION_INFO_RX_PACKETS = 1<<8, 439 STATION_INFO_RX_PACKETS = 1<<8,
361 STATION_INFO_TX_PACKETS = 1<<9, 440 STATION_INFO_TX_PACKETS = 1<<9,
441 STATION_INFO_TX_RETRIES = 1<<10,
442 STATION_INFO_TX_FAILED = 1<<11,
443 STATION_INFO_RX_DROP_MISC = 1<<12,
444 STATION_INFO_SIGNAL_AVG = 1<<13,
445 STATION_INFO_RX_BITRATE = 1<<14,
446 STATION_INFO_BSS_PARAM = 1<<15,
447 STATION_INFO_CONNECTED_TIME = 1<<16
362}; 448};
363 449
364/** 450/**
@@ -393,11 +479,43 @@ struct rate_info {
393}; 479};
394 480
395/** 481/**
482 * enum station_info_rate_flags - bitrate info flags
483 *
484 * Used by the driver to indicate the specific rate transmission
485 * type for 802.11n transmissions.
486 *
487 * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled
488 * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled
489 * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled
490 */
491enum bss_param_flags {
492 BSS_PARAM_FLAGS_CTS_PROT = 1<<0,
493 BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1,
494 BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2,
495};
496
497/**
498 * struct sta_bss_parameters - BSS parameters for the attached station
499 *
500 * Information about the currently associated BSS
501 *
502 * @flags: bitflag of flags from &enum bss_param_flags
503 * @dtim_period: DTIM period for the BSS
504 * @beacon_interval: beacon interval
505 */
506struct sta_bss_parameters {
507 u8 flags;
508 u8 dtim_period;
509 u16 beacon_interval;
510};
511
512/**
396 * struct station_info - station information 513 * struct station_info - station information
397 * 514 *
398 * Station information filled by driver for get_station() and dump_station. 515 * Station information filled by driver for get_station() and dump_station.
399 * 516 *
400 * @filled: bitflag of flags from &enum station_info_flags 517 * @filled: bitflag of flags from &enum station_info_flags
518 * @connected_time: time(in secs) since a station is last connected
401 * @inactive_time: time since last station activity (tx/rx) in milliseconds 519 * @inactive_time: time since last station activity (tx/rx) in milliseconds
402 * @rx_bytes: bytes received from this station 520 * @rx_bytes: bytes received from this station
403 * @tx_bytes: bytes transmitted to this station 521 * @tx_bytes: bytes transmitted to this station
@@ -405,9 +523,15 @@ struct rate_info {
405 * @plid: mesh peer link id 523 * @plid: mesh peer link id
406 * @plink_state: mesh peer link state 524 * @plink_state: mesh peer link state
407 * @signal: signal strength of last received packet in dBm 525 * @signal: signal strength of last received packet in dBm
408 * @txrate: current unicast bitrate to this station 526 * @signal_avg: signal strength average in dBm
527 * @txrate: current unicast bitrate from this station
528 * @rxrate: current unicast bitrate to this station
409 * @rx_packets: packets received from this station 529 * @rx_packets: packets received from this station
410 * @tx_packets: packets transmitted to this station 530 * @tx_packets: packets transmitted to this station
531 * @tx_retries: cumulative retry counts
532 * @tx_failed: number of failed transmissions (retries exceeded, no ACK)
533 * @rx_dropped_misc: Dropped for un-specified reason.
534 * @bss_param: current BSS parameters
411 * @generation: generation number for nl80211 dumps. 535 * @generation: generation number for nl80211 dumps.
412 * This number should increase every time the list of stations 536 * This number should increase every time the list of stations
413 * changes, i.e. when a station is added or removed, so that 537 * changes, i.e. when a station is added or removed, so that
@@ -415,6 +539,7 @@ struct rate_info {
415 */ 539 */
416struct station_info { 540struct station_info {
417 u32 filled; 541 u32 filled;
542 u32 connected_time;
418 u32 inactive_time; 543 u32 inactive_time;
419 u32 rx_bytes; 544 u32 rx_bytes;
420 u32 tx_bytes; 545 u32 tx_bytes;
@@ -422,9 +547,15 @@ struct station_info {
422 u16 plid; 547 u16 plid;
423 u8 plink_state; 548 u8 plink_state;
424 s8 signal; 549 s8 signal;
550 s8 signal_avg;
425 struct rate_info txrate; 551 struct rate_info txrate;
552 struct rate_info rxrate;
426 u32 rx_packets; 553 u32 rx_packets;
427 u32 tx_packets; 554 u32 tx_packets;
555 u32 tx_retries;
556 u32 tx_failed;
557 u32 rx_dropped_misc;
558 struct sta_bss_parameters bss_param;
428 559
429 int generation; 560 int generation;
430}; 561};
@@ -519,6 +650,8 @@ struct mpath_info {
519 * (or NULL for no change) 650 * (or NULL for no change)
520 * @basic_rates_len: number of basic rates 651 * @basic_rates_len: number of basic rates
521 * @ap_isolate: do not forward packets between connected stations 652 * @ap_isolate: do not forward packets between connected stations
653 * @ht_opmode: HT Operation mode
654 * (u16 = opmode, -1 = do not change)
522 */ 655 */
523struct bss_parameters { 656struct bss_parameters {
524 int use_cts_prot; 657 int use_cts_prot;
@@ -527,8 +660,14 @@ struct bss_parameters {
527 u8 *basic_rates; 660 u8 *basic_rates;
528 u8 basic_rates_len; 661 u8 basic_rates_len;
529 int ap_isolate; 662 int ap_isolate;
663 int ht_opmode;
530}; 664};
531 665
666/*
667 * struct mesh_config - 802.11s mesh configuration
668 *
669 * These parameters can be changed while the mesh is active.
670 */
532struct mesh_config { 671struct mesh_config {
533 /* Timeouts in ms */ 672 /* Timeouts in ms */
534 /* Mesh plink management parameters */ 673 /* Mesh plink management parameters */
@@ -538,6 +677,8 @@ struct mesh_config {
538 u16 dot11MeshMaxPeerLinks; 677 u16 dot11MeshMaxPeerLinks;
539 u8 dot11MeshMaxRetries; 678 u8 dot11MeshMaxRetries;
540 u8 dot11MeshTTL; 679 u8 dot11MeshTTL;
680 /* ttl used in path selection information elements */
681 u8 element_ttl;
541 bool auto_open_plinks; 682 bool auto_open_plinks;
542 /* HWMP parameters */ 683 /* HWMP parameters */
543 u8 dot11MeshHWMPmaxPREQretries; 684 u8 dot11MeshHWMPmaxPREQretries;
@@ -550,6 +691,30 @@ struct mesh_config {
550}; 691};
551 692
552/** 693/**
694 * struct mesh_setup - 802.11s mesh setup configuration
695 * @mesh_id: the mesh ID
696 * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
697 * @path_sel_proto: which path selection protocol to use
698 * @path_metric: which metric to use
699 * @ie: vendor information elements (optional)
700 * @ie_len: length of vendor information elements
701 * @is_authenticated: this mesh requires authentication
702 * @is_secure: this mesh uses security
703 *
704 * These parameters are fixed when the mesh is created.
705 */
706struct mesh_setup {
707 const u8 *mesh_id;
708 u8 mesh_id_len;
709 u8 path_sel_proto;
710 u8 path_metric;
711 const u8 *ie;
712 u8 ie_len;
713 bool is_authenticated;
714 bool is_secure;
715};
716
717/**
553 * struct ieee80211_txq_params - TX queue parameters 718 * struct ieee80211_txq_params - TX queue parameters
554 * @queue: TX queue identifier (NL80211_TXQ_Q_*) 719 * @queue: TX queue identifier (NL80211_TXQ_Q_*)
555 * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled 720 * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
@@ -570,8 +735,28 @@ struct ieee80211_txq_params {
570/* from net/wireless.h */ 735/* from net/wireless.h */
571struct wiphy; 736struct wiphy;
572 737
573/* from net/ieee80211.h */ 738/**
574struct ieee80211_channel; 739 * DOC: Scanning and BSS list handling
740 *
741 * The scanning process itself is fairly simple, but cfg80211 offers quite
742 * a bit of helper functionality. To start a scan, the scan operation will
743 * be invoked with a scan definition. This scan definition contains the
744 * channels to scan, and the SSIDs to send probe requests for (including the
745 * wildcard, if desired). A passive scan is indicated by having no SSIDs to
746 * probe. Additionally, a scan request may contain extra information elements
747 * that should be added to the probe request. The IEs are guaranteed to be
748 * well-formed, and will not exceed the maximum length the driver advertised
749 * in the wiphy structure.
750 *
751 * When scanning finds a BSS, cfg80211 needs to be notified of that, because
752 * it is responsible for maintaining the BSS list; the driver should not
753 * maintain a list itself. For this notification, various functions exist.
754 *
755 * Since drivers do not maintain a BSS list, there are also a number of
756 * functions to search for a BSS and obtain information about it from the
757 * BSS structure cfg80211 maintains. The BSS list is also made available
758 * to userspace.
759 */
575 760
576/** 761/**
577 * struct cfg80211_ssid - SSID description 762 * struct cfg80211_ssid - SSID description
@@ -613,6 +798,35 @@ struct cfg80211_scan_request {
613}; 798};
614 799
615/** 800/**
801 * struct cfg80211_sched_scan_request - scheduled scan request description
802 *
803 * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
804 * @n_ssids: number of SSIDs
805 * @n_channels: total number of channels to scan
806 * @interval: interval between each scheduled scan cycle
807 * @ie: optional information element(s) to add into Probe Request or %NULL
808 * @ie_len: length of ie in octets
809 * @wiphy: the wiphy this was for
810 * @dev: the interface
811 * @channels: channels to scan
812 */
813struct cfg80211_sched_scan_request {
814 struct cfg80211_ssid *ssids;
815 int n_ssids;
816 u32 n_channels;
817 u32 interval;
818 const u8 *ie;
819 size_t ie_len;
820
821 /* internal */
822 struct wiphy *wiphy;
823 struct net_device *dev;
824
825 /* keep last */
826 struct ieee80211_channel *channels[0];
827};
828
829/**
616 * enum cfg80211_signal_type - signal type 830 * enum cfg80211_signal_type - signal type
617 * 831 *
618 * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available 832 * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
@@ -691,6 +905,10 @@ const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie);
691 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is 905 * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
692 * required to assume that the port is unauthorized until authorized by 906 * required to assume that the port is unauthorized until authorized by
693 * user space. Otherwise, port is marked authorized by default. 907 * user space. Otherwise, port is marked authorized by default.
908 * @control_port_ethertype: the control port protocol that should be
909 * allowed through even on unauthorized ports
910 * @control_port_no_encrypt: TRUE to prevent encryption of control port
911 * protocol frames.
694 */ 912 */
695struct cfg80211_crypto_settings { 913struct cfg80211_crypto_settings {
696 u32 wpa_versions; 914 u32 wpa_versions;
@@ -700,6 +918,8 @@ struct cfg80211_crypto_settings {
700 int n_akm_suites; 918 int n_akm_suites;
701 u32 akm_suites[NL80211_MAX_NR_AKM_SUITES]; 919 u32 akm_suites[NL80211_MAX_NR_AKM_SUITES];
702 bool control_port; 920 bool control_port;
921 __be16 control_port_ethertype;
922 bool control_port_no_encrypt;
703}; 923};
704 924
705/** 925/**
@@ -811,6 +1031,7 @@ struct cfg80211_disassoc_request {
811 * @privacy: this is a protected network, keys will be configured 1031 * @privacy: this is a protected network, keys will be configured
812 * after joining 1032 * after joining
813 * @basic_rates: bitmap of basic rates to use when creating the IBSS 1033 * @basic_rates: bitmap of basic rates to use when creating the IBSS
1034 * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
814 */ 1035 */
815struct cfg80211_ibss_params { 1036struct cfg80211_ibss_params {
816 u8 *ssid; 1037 u8 *ssid;
@@ -822,6 +1043,7 @@ struct cfg80211_ibss_params {
822 u32 basic_rates; 1043 u32 basic_rates;
823 bool channel_fixed; 1044 bool channel_fixed;
824 bool privacy; 1045 bool privacy;
1046 int mcast_rate[IEEE80211_NUM_BANDS];
825}; 1047};
826 1048
827/** 1049/**
@@ -900,6 +1122,38 @@ struct cfg80211_pmksa {
900}; 1122};
901 1123
902/** 1124/**
1125 * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern
1126 * @mask: bitmask where to match pattern and where to ignore bytes,
1127 * one bit per byte, in same format as nl80211
1128 * @pattern: bytes to match where bitmask is 1
1129 * @pattern_len: length of pattern (in bytes)
1130 *
1131 * Internal note: @mask and @pattern are allocated in one chunk of
1132 * memory, free @mask only!
1133 */
1134struct cfg80211_wowlan_trig_pkt_pattern {
1135 u8 *mask, *pattern;
1136 int pattern_len;
1137};
1138
1139/**
1140 * struct cfg80211_wowlan - Wake on Wireless-LAN support info
1141 *
1142 * This structure defines the enabled WoWLAN triggers for the device.
1143 * @any: wake up on any activity -- special trigger if device continues
1144 * operating as normal during suspend
1145 * @disconnect: wake up if getting disconnected
1146 * @magic_pkt: wake up on receiving magic packet
1147 * @patterns: wake up on receiving packet matching a pattern
1148 * @n_patterns: number of patterns
1149 */
1150struct cfg80211_wowlan {
1151 bool any, disconnect, magic_pkt;
1152 struct cfg80211_wowlan_trig_pkt_pattern *patterns;
1153 int n_patterns;
1154};
1155
1156/**
903 * struct cfg80211_ops - backend description for wireless configuration 1157 * struct cfg80211_ops - backend description for wireless configuration
904 * 1158 *
905 * This struct is registered by fullmac card drivers and/or wireless stacks 1159 * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -912,12 +1166,15 @@ struct cfg80211_pmksa {
912 * wireless extensions but this is subject to reevaluation as soon as this 1166 * wireless extensions but this is subject to reevaluation as soon as this
913 * code is used more widely and we have a first user without wext. 1167 * code is used more widely and we have a first user without wext.
914 * 1168 *
915 * @suspend: wiphy device needs to be suspended 1169 * @suspend: wiphy device needs to be suspended. The variable @wow will
1170 * be %NULL or contain the enabled Wake-on-Wireless triggers that are
1171 * configured for the device.
916 * @resume: wiphy device needs to be resumed 1172 * @resume: wiphy device needs to be resumed
917 * 1173 *
918 * @add_virtual_intf: create a new virtual interface with the given name, 1174 * @add_virtual_intf: create a new virtual interface with the given name,
919 * must set the struct wireless_dev's iftype. Beware: You must create 1175 * must set the struct wireless_dev's iftype. Beware: You must create
920 * the new netdev in the wiphy's network namespace! 1176 * the new netdev in the wiphy's network namespace! Returns the netdev,
1177 * or an ERR_PTR.
921 * 1178 *
922 * @del_virtual_intf: remove the virtual interface determined by ifindex. 1179 * @del_virtual_intf: remove the virtual interface determined by ifindex.
923 * 1180 *
@@ -958,10 +1215,12 @@ struct cfg80211_pmksa {
958 * @change_mpath: change a given mesh path 1215 * @change_mpath: change a given mesh path
959 * @get_mpath: get a mesh path for the given parameters 1216 * @get_mpath: get a mesh path for the given parameters
960 * @dump_mpath: dump mesh path callback -- resume dump at index @idx 1217 * @dump_mpath: dump mesh path callback -- resume dump at index @idx
1218 * @join_mesh: join the mesh network with the specified parameters
1219 * @leave_mesh: leave the current mesh network
961 * 1220 *
962 * @get_mesh_params: Put the current mesh parameters into *params 1221 * @get_mesh_config: Get the current mesh configuration
963 * 1222 *
964 * @set_mesh_params: Set mesh parameters. 1223 * @update_mesh_config: Update mesh parameters on a running mesh.
965 * The mask is a bitfield which tells us which parameters to 1224 * The mask is a bitfield which tells us which parameters to
966 * set, and which to leave alone. 1225 * set, and which to leave alone.
967 * 1226 *
@@ -1020,7 +1279,9 @@ struct cfg80211_pmksa {
1020 * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation. 1279 * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
1021 * This allows the operation to be terminated prior to timeout based on 1280 * This allows the operation to be terminated prior to timeout based on
1022 * the duration value. 1281 * the duration value.
1023 * @action: Transmit an action frame 1282 * @mgmt_tx: Transmit a management frame.
1283 * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
1284 * frame on another channel
1024 * 1285 *
1025 * @testmode_cmd: run a test mode command 1286 * @testmode_cmd: run a test mode command
1026 * 1287 *
@@ -1034,15 +1295,35 @@ struct cfg80211_pmksa {
1034 * @set_power_mgmt: Configure WLAN power management. A timeout value of -1 1295 * @set_power_mgmt: Configure WLAN power management. A timeout value of -1
1035 * allows the driver to adjust the dynamic ps timeout value. 1296 * allows the driver to adjust the dynamic ps timeout value.
1036 * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold. 1297 * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold.
1298 * @sched_scan_start: Tell the driver to start a scheduled scan.
1299 * @sched_scan_stop: Tell the driver to stop an ongoing scheduled
1300 * scan. The driver_initiated flag specifies whether the driver
1301 * itself has informed that the scan has stopped.
1302 *
1303 * @mgmt_frame_register: Notify driver that a management frame type was
1304 * registered. Note that this callback may not sleep, and cannot run
1305 * concurrently with itself.
1037 * 1306 *
1307 * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
1308 * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
1309 * reject TX/RX mask combinations they cannot support by returning -EINVAL
1310 * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
1311 *
1312 * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
1313 *
1314 * @set_ringparam: Set tx and rx ring sizes.
1315 *
1316 * @get_ringparam: Get tx and rx ring current and maximum sizes.
1038 */ 1317 */
1039struct cfg80211_ops { 1318struct cfg80211_ops {
1040 int (*suspend)(struct wiphy *wiphy); 1319 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
1041 int (*resume)(struct wiphy *wiphy); 1320 int (*resume)(struct wiphy *wiphy);
1042 1321
1043 int (*add_virtual_intf)(struct wiphy *wiphy, char *name, 1322 struct net_device * (*add_virtual_intf)(struct wiphy *wiphy,
1044 enum nl80211_iftype type, u32 *flags, 1323 char *name,
1045 struct vif_params *params); 1324 enum nl80211_iftype type,
1325 u32 *flags,
1326 struct vif_params *params);
1046 int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); 1327 int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev);
1047 int (*change_virtual_intf)(struct wiphy *wiphy, 1328 int (*change_virtual_intf)(struct wiphy *wiphy,
1048 struct net_device *dev, 1329 struct net_device *dev,
@@ -1050,16 +1331,17 @@ struct cfg80211_ops {
1050 struct vif_params *params); 1331 struct vif_params *params);
1051 1332
1052 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev, 1333 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
1053 u8 key_index, const u8 *mac_addr, 1334 u8 key_index, bool pairwise, const u8 *mac_addr,
1054 struct key_params *params); 1335 struct key_params *params);
1055 int (*get_key)(struct wiphy *wiphy, struct net_device *netdev, 1336 int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
1056 u8 key_index, const u8 *mac_addr, void *cookie, 1337 u8 key_index, bool pairwise, const u8 *mac_addr,
1338 void *cookie,
1057 void (*callback)(void *cookie, struct key_params*)); 1339 void (*callback)(void *cookie, struct key_params*));
1058 int (*del_key)(struct wiphy *wiphy, struct net_device *netdev, 1340 int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
1059 u8 key_index, const u8 *mac_addr); 1341 u8 key_index, bool pairwise, const u8 *mac_addr);
1060 int (*set_default_key)(struct wiphy *wiphy, 1342 int (*set_default_key)(struct wiphy *wiphy,
1061 struct net_device *netdev, 1343 struct net_device *netdev,
1062 u8 key_index); 1344 u8 key_index, bool unicast, bool multicast);
1063 int (*set_default_mgmt_key)(struct wiphy *wiphy, 1345 int (*set_default_mgmt_key)(struct wiphy *wiphy,
1064 struct net_device *netdev, 1346 struct net_device *netdev,
1065 u8 key_index); 1347 u8 key_index);
@@ -1094,12 +1376,17 @@ struct cfg80211_ops {
1094 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev, 1376 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
1095 int idx, u8 *dst, u8 *next_hop, 1377 int idx, u8 *dst, u8 *next_hop,
1096 struct mpath_info *pinfo); 1378 struct mpath_info *pinfo);
1097 int (*get_mesh_params)(struct wiphy *wiphy, 1379 int (*get_mesh_config)(struct wiphy *wiphy,
1098 struct net_device *dev, 1380 struct net_device *dev,
1099 struct mesh_config *conf); 1381 struct mesh_config *conf);
1100 int (*set_mesh_params)(struct wiphy *wiphy, 1382 int (*update_mesh_config)(struct wiphy *wiphy,
1101 struct net_device *dev, 1383 struct net_device *dev, u32 mask,
1102 const struct mesh_config *nconf, u32 mask); 1384 const struct mesh_config *nconf);
1385 int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev,
1386 const struct mesh_config *conf,
1387 const struct mesh_setup *setup);
1388 int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
1389
1103 int (*change_bss)(struct wiphy *wiphy, struct net_device *dev, 1390 int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
1104 struct bss_parameters *params); 1391 struct bss_parameters *params);
1105 1392
@@ -1140,7 +1427,7 @@ struct cfg80211_ops {
1140 int (*get_tx_power)(struct wiphy *wiphy, int *dbm); 1427 int (*get_tx_power)(struct wiphy *wiphy, int *dbm);
1141 1428
1142 int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, 1429 int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
1143 u8 *addr); 1430 const u8 *addr);
1144 1431
1145 void (*rfkill_poll)(struct wiphy *wiphy); 1432 void (*rfkill_poll)(struct wiphy *wiphy);
1146 1433
@@ -1172,11 +1459,14 @@ struct cfg80211_ops {
1172 struct net_device *dev, 1459 struct net_device *dev,
1173 u64 cookie); 1460 u64 cookie);
1174 1461
1175 int (*action)(struct wiphy *wiphy, struct net_device *dev, 1462 int (*mgmt_tx)(struct wiphy *wiphy, struct net_device *dev,
1176 struct ieee80211_channel *chan, 1463 struct ieee80211_channel *chan, bool offchan,
1177 enum nl80211_channel_type channel_type, 1464 enum nl80211_channel_type channel_type,
1178 bool channel_type_valid, 1465 bool channel_type_valid, unsigned int wait,
1179 const u8 *buf, size_t len, u64 *cookie); 1466 const u8 *buf, size_t len, u64 *cookie);
1467 int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy,
1468 struct net_device *dev,
1469 u64 cookie);
1180 1470
1181 int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev, 1471 int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
1182 bool enabled, int timeout); 1472 bool enabled, int timeout);
@@ -1184,6 +1474,22 @@ struct cfg80211_ops {
1184 int (*set_cqm_rssi_config)(struct wiphy *wiphy, 1474 int (*set_cqm_rssi_config)(struct wiphy *wiphy,
1185 struct net_device *dev, 1475 struct net_device *dev,
1186 s32 rssi_thold, u32 rssi_hyst); 1476 s32 rssi_thold, u32 rssi_hyst);
1477
1478 void (*mgmt_frame_register)(struct wiphy *wiphy,
1479 struct net_device *dev,
1480 u16 frame_type, bool reg);
1481
1482 int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
1483 int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
1484
1485 int (*set_ringparam)(struct wiphy *wiphy, u32 tx, u32 rx);
1486 void (*get_ringparam)(struct wiphy *wiphy,
1487 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
1488
1489 int (*sched_scan_start)(struct wiphy *wiphy,
1490 struct net_device *dev,
1491 struct cfg80211_sched_scan_request *request);
1492 int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev);
1187}; 1493};
1188 1494
1189/* 1495/*
@@ -1201,19 +1507,24 @@ struct cfg80211_ops {
1201 * initiator is %REGDOM_SET_BY_CORE). 1507 * initiator is %REGDOM_SET_BY_CORE).
1202 * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will 1508 * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will
1203 * ignore regulatory domain settings until it gets its own regulatory 1509 * ignore regulatory domain settings until it gets its own regulatory
1204 * domain via its regulatory_hint(). After its gets its own regulatory 1510 * domain via its regulatory_hint() unless the regulatory hint is
1205 * domain it will only allow further regulatory domain settings to 1511 * from a country IE. After its gets its own regulatory domain it will
1206 * further enhance compliance. For example if channel 13 and 14 are 1512 * only allow further regulatory domain settings to further enhance
1207 * disabled by this regulatory domain no user regulatory domain can 1513 * compliance. For example if channel 13 and 14 are disabled by this
1208 * enable these channels at a later time. This can be used for devices 1514 * regulatory domain no user regulatory domain can enable these channels
1209 * which do not have calibration information gauranteed for frequencies 1515 * at a later time. This can be used for devices which do not have
1210 * or settings outside of its regulatory domain. 1516 * calibration information guaranteed for frequencies or settings
1517 * outside of its regulatory domain.
1211 * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure 1518 * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure
1212 * that passive scan flags and beaconing flags may not be lifted by 1519 * that passive scan flags and beaconing flags may not be lifted by
1213 * cfg80211 due to regulatory beacon hints. For more information on beacon 1520 * cfg80211 due to regulatory beacon hints. For more information on beacon
1214 * hints read the documenation for regulatory_hint_found_beacon() 1521 * hints read the documenation for regulatory_hint_found_beacon()
1215 * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this 1522 * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
1216 * wiphy at all 1523 * wiphy at all
1524 * @WIPHY_FLAG_ENFORCE_COMBINATIONS: Set this flag to enforce interface
1525 * combinations for this device. This flag is used for backward
1526 * compatibility only until all drivers advertise combinations and
1527 * they will always be enforced.
1217 * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled 1528 * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
1218 * by default -- this flag will be set depending on the kernel's default 1529 * by default -- this flag will be set depending on the kernel's default
1219 * on wiphy_new(), but can be changed by the driver if it has a good 1530 * on wiphy_new(), but can be changed by the driver if it has a good
@@ -1221,24 +1532,148 @@ struct cfg80211_ops {
1221 * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station 1532 * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
1222 * on a VLAN interface) 1533 * on a VLAN interface)
1223 * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station 1534 * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
1535 * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
1536 * control port protocol ethertype. The device also honours the
1537 * control_port_no_encrypt flag.
1538 * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
1539 * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
1540 * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
1541 * @WIPHY_FLAG_SUPPORTS_SCHED_SCAN: The device supports scheduled scans.
1224 */ 1542 */
1225enum wiphy_flags { 1543enum wiphy_flags {
1226 WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), 1544 WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0),
1227 WIPHY_FLAG_STRICT_REGULATORY = BIT(1), 1545 WIPHY_FLAG_STRICT_REGULATORY = BIT(1),
1228 WIPHY_FLAG_DISABLE_BEACON_HINTS = BIT(2), 1546 WIPHY_FLAG_DISABLE_BEACON_HINTS = BIT(2),
1229 WIPHY_FLAG_NETNS_OK = BIT(3), 1547 WIPHY_FLAG_NETNS_OK = BIT(3),
1230 WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4), 1548 WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
1231 WIPHY_FLAG_4ADDR_AP = BIT(5), 1549 WIPHY_FLAG_4ADDR_AP = BIT(5),
1232 WIPHY_FLAG_4ADDR_STATION = BIT(6), 1550 WIPHY_FLAG_4ADDR_STATION = BIT(6),
1551 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
1552 WIPHY_FLAG_IBSS_RSN = BIT(8),
1553 WIPHY_FLAG_MESH_AUTH = BIT(10),
1554 WIPHY_FLAG_SUPPORTS_SCHED_SCAN = BIT(11),
1555 WIPHY_FLAG_ENFORCE_COMBINATIONS = BIT(12),
1556};
1557
1558/**
1559 * struct ieee80211_iface_limit - limit on certain interface types
1560 * @max: maximum number of interfaces of these types
1561 * @types: interface types (bits)
1562 */
1563struct ieee80211_iface_limit {
1564 u16 max;
1565 u16 types;
1566};
1567
1568/**
1569 * struct ieee80211_iface_combination - possible interface combination
1570 * @limits: limits for the given interface types
1571 * @n_limits: number of limitations
1572 * @num_different_channels: can use up to this many different channels
1573 * @max_interfaces: maximum number of interfaces in total allowed in this
1574 * group
1575 * @beacon_int_infra_match: In this combination, the beacon intervals
1576 * between infrastructure and AP types must match. This is required
1577 * only in special cases.
1578 *
1579 * These examples can be expressed as follows:
1580 *
1581 * Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
1582 *
1583 * struct ieee80211_iface_limit limits1[] = {
1584 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
1585 * { .max = 1, .types = BIT(NL80211_IFTYPE_AP}, },
1586 * };
1587 * struct ieee80211_iface_combination combination1 = {
1588 * .limits = limits1,
1589 * .n_limits = ARRAY_SIZE(limits1),
1590 * .max_interfaces = 2,
1591 * .beacon_int_infra_match = true,
1592 * };
1593 *
1594 *
1595 * Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
1596 *
1597 * struct ieee80211_iface_limit limits2[] = {
1598 * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
1599 * BIT(NL80211_IFTYPE_P2P_GO), },
1600 * };
1601 * struct ieee80211_iface_combination combination2 = {
1602 * .limits = limits2,
1603 * .n_limits = ARRAY_SIZE(limits2),
1604 * .max_interfaces = 8,
1605 * .num_different_channels = 1,
1606 * };
1607 *
1608 *
1609 * Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
1610 * This allows for an infrastructure connection and three P2P connections.
1611 *
1612 * struct ieee80211_iface_limit limits3[] = {
1613 * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
1614 * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
1615 * BIT(NL80211_IFTYPE_P2P_CLIENT), },
1616 * };
1617 * struct ieee80211_iface_combination combination3 = {
1618 * .limits = limits3,
1619 * .n_limits = ARRAY_SIZE(limits3),
1620 * .max_interfaces = 4,
1621 * .num_different_channels = 2,
1622 * };
1623 */
1624struct ieee80211_iface_combination {
1625 const struct ieee80211_iface_limit *limits;
1626 u32 num_different_channels;
1627 u16 max_interfaces;
1628 u8 n_limits;
1629 bool beacon_int_infra_match;
1233}; 1630};
1234 1631
1235struct mac_address { 1632struct mac_address {
1236 u8 addr[ETH_ALEN]; 1633 u8 addr[ETH_ALEN];
1237}; 1634};
1238 1635
1636struct ieee80211_txrx_stypes {
1637 u16 tx, rx;
1638};
1639
1640/**
1641 * enum wiphy_wowlan_support_flags - WoWLAN support flags
1642 * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any"
1643 * trigger that keeps the device operating as-is and
1644 * wakes up the host on any activity, for example a
1645 * received packet that passed filtering; note that the
1646 * packet should be preserved in that case
1647 * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
1648 * (see nl80211.h)
1649 * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
1650 */
1651enum wiphy_wowlan_support_flags {
1652 WIPHY_WOWLAN_ANY = BIT(0),
1653 WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
1654 WIPHY_WOWLAN_DISCONNECT = BIT(2),
1655};
1656
1657/**
1658 * struct wiphy_wowlan_support - WoWLAN support data
1659 * @flags: see &enum wiphy_wowlan_support_flags
1660 * @n_patterns: number of supported wakeup patterns
1661 * (see nl80211.h for the pattern definition)
1662 * @pattern_max_len: maximum length of each pattern
1663 * @pattern_min_len: minimum length of each pattern
1664 */
1665struct wiphy_wowlan_support {
1666 u32 flags;
1667 int n_patterns;
1668 int pattern_max_len;
1669 int pattern_min_len;
1670};
1671
1239/** 1672/**
1240 * struct wiphy - wireless hardware description 1673 * struct wiphy - wireless hardware description
1241 * @reg_notifier: the driver's regulatory notification callback 1674 * @reg_notifier: the driver's regulatory notification callback,
1675 * note that if your driver uses wiphy_apply_custom_regulatory()
1676 * the reg_notifier's request can be passed as NULL
1242 * @regd: the driver's regulatory domain, if one was requested via 1677 * @regd: the driver's regulatory domain, if one was requested via
1243 * the regulatory_hint() API. This can be used by the driver 1678 * the regulatory_hint() API. This can be used by the driver
1244 * on the reg_notifier() if it chooses to ignore future 1679 * on the reg_notifier() if it chooses to ignore future
@@ -1271,6 +1706,11 @@ struct mac_address {
1271 * @priv: driver private data (sized according to wiphy_new() parameter) 1706 * @priv: driver private data (sized according to wiphy_new() parameter)
1272 * @interface_modes: bitmask of interfaces types valid for this wiphy, 1707 * @interface_modes: bitmask of interfaces types valid for this wiphy,
1273 * must be set by driver 1708 * must be set by driver
1709 * @iface_combinations: Valid interface combinations array, should not
1710 * list single interface types.
1711 * @n_iface_combinations: number of entries in @iface_combinations array.
1712 * @software_iftypes: bitmask of software interface types, these are not
1713 * subject to any restrictions since they are purely managed in SW.
1274 * @flags: wiphy flags, see &enum wiphy_flags 1714 * @flags: wiphy flags, see &enum wiphy_flags
1275 * @bss_priv_size: each BSS struct has private data allocated with it, 1715 * @bss_priv_size: each BSS struct has private data allocated with it,
1276 * this variable determines its size 1716 * this variable determines its size
@@ -1286,6 +1726,23 @@ struct mac_address {
1286 * @privid: a pointer that drivers can use to identify if an arbitrary 1726 * @privid: a pointer that drivers can use to identify if an arbitrary
1287 * wiphy is theirs, e.g. in global notifiers 1727 * wiphy is theirs, e.g. in global notifiers
1288 * @bands: information about bands/channels supported by this device 1728 * @bands: information about bands/channels supported by this device
1729 *
1730 * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
1731 * transmitted through nl80211, points to an array indexed by interface
1732 * type
1733 *
1734 * @available_antennas_tx: bitmap of antennas which are available to be
1735 * configured as TX antennas. Antenna configuration commands will be
1736 * rejected unless this or @available_antennas_rx is set.
1737 *
1738 * @available_antennas_rx: bitmap of antennas which are available to be
1739 * configured as RX antennas. Antenna configuration commands will be
1740 * rejected unless this or @available_antennas_tx is set.
1741 *
1742 * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation
1743 * may request, if implemented.
1744 *
1745 * @wowlan: WoWLAN support information
1289 */ 1746 */
1290struct wiphy { 1747struct wiphy {
1291 /* assign these fields before you register the wiphy */ 1748 /* assign these fields before you register the wiphy */
@@ -1294,9 +1751,16 @@ struct wiphy {
1294 u8 perm_addr[ETH_ALEN]; 1751 u8 perm_addr[ETH_ALEN];
1295 u8 addr_mask[ETH_ALEN]; 1752 u8 addr_mask[ETH_ALEN];
1296 1753
1297 u16 n_addresses;
1298 struct mac_address *addresses; 1754 struct mac_address *addresses;
1299 1755
1756 const struct ieee80211_txrx_stypes *mgmt_stypes;
1757
1758 const struct ieee80211_iface_combination *iface_combinations;
1759 int n_iface_combinations;
1760 u16 software_iftypes;
1761
1762 u16 n_addresses;
1763
1300 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ 1764 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
1301 u16 interface_modes; 1765 u16 interface_modes;
1302 1766
@@ -1320,8 +1784,15 @@ struct wiphy {
1320 char fw_version[ETHTOOL_BUSINFO_LEN]; 1784 char fw_version[ETHTOOL_BUSINFO_LEN];
1321 u32 hw_version; 1785 u32 hw_version;
1322 1786
1787 struct wiphy_wowlan_support wowlan;
1788
1789 u16 max_remain_on_channel_duration;
1790
1323 u8 max_num_pmkids; 1791 u8 max_num_pmkids;
1324 1792
1793 u32 available_antennas_tx;
1794 u32 available_antennas_rx;
1795
1325 /* If multiple wiphys are registered and you're handed e.g. 1796 /* If multiple wiphys are registered and you're handed e.g.
1326 * a regular netdev with assigned ieee80211_ptr, you won't 1797 * a regular netdev with assigned ieee80211_ptr, you won't
1327 * know whether it points to a wiphy your driver has registered 1798 * know whether it points to a wiphy your driver has registered
@@ -1487,15 +1958,19 @@ struct cfg80211_cached_keys;
1487 * @bssid: (private) Used by the internal configuration code 1958 * @bssid: (private) Used by the internal configuration code
1488 * @ssid: (private) Used by the internal configuration code 1959 * @ssid: (private) Used by the internal configuration code
1489 * @ssid_len: (private) Used by the internal configuration code 1960 * @ssid_len: (private) Used by the internal configuration code
1961 * @mesh_id_len: (private) Used by the internal configuration code
1962 * @mesh_id_up_len: (private) Used by the internal configuration code
1490 * @wext: (private) Used by the internal wireless extensions compat code 1963 * @wext: (private) Used by the internal wireless extensions compat code
1491 * @use_4addr: indicates 4addr mode is used on this interface, must be 1964 * @use_4addr: indicates 4addr mode is used on this interface, must be
1492 * set by driver (if supported) on add_interface BEFORE registering the 1965 * set by driver (if supported) on add_interface BEFORE registering the
1493 * netdev and may otherwise be used by driver read-only, will be update 1966 * netdev and may otherwise be used by driver read-only, will be update
1494 * by cfg80211 on change_interface 1967 * by cfg80211 on change_interface
1495 * @action_registrations: list of registrations for action frames 1968 * @mgmt_registrations: list of registrations for management frames
1496 * @action_registrations_lock: lock for the list 1969 * @mgmt_registrations_lock: lock for the list
1497 * @mtx: mutex used to lock data in this struct 1970 * @mtx: mutex used to lock data in this struct
1498 * @cleanup_work: work struct used for cleanup that can't be done directly 1971 * @cleanup_work: work struct used for cleanup that can't be done directly
1972 * @beacon_interval: beacon interval used on this device for transmitting
1973 * beacons, 0 when not valid
1499 */ 1974 */
1500struct wireless_dev { 1975struct wireless_dev {
1501 struct wiphy *wiphy; 1976 struct wiphy *wiphy;
@@ -1505,8 +1980,8 @@ struct wireless_dev {
1505 struct list_head list; 1980 struct list_head list;
1506 struct net_device *netdev; 1981 struct net_device *netdev;
1507 1982
1508 struct list_head action_registrations; 1983 struct list_head mgmt_registrations;
1509 spinlock_t action_registrations_lock; 1984 spinlock_t mgmt_registrations_lock;
1510 1985
1511 struct mutex mtx; 1986 struct mutex mtx;
1512 1987
@@ -1516,7 +1991,7 @@ struct wireless_dev {
1516 1991
1517 /* currently used for IBSS and SME - might be rearranged later */ 1992 /* currently used for IBSS and SME - might be rearranged later */
1518 u8 ssid[IEEE80211_MAX_SSID_LEN]; 1993 u8 ssid[IEEE80211_MAX_SSID_LEN];
1519 u8 ssid_len; 1994 u8 ssid_len, mesh_id_len, mesh_id_up_len;
1520 enum { 1995 enum {
1521 CFG80211_SME_IDLE, 1996 CFG80211_SME_IDLE,
1522 CFG80211_SME_CONNECTING, 1997 CFG80211_SME_CONNECTING,
@@ -1536,6 +2011,8 @@ struct wireless_dev {
1536 bool ps; 2011 bool ps;
1537 int ps_timeout; 2012 int ps_timeout;
1538 2013
2014 int beacon_interval;
2015
1539#ifdef CONFIG_CFG80211_WEXT 2016#ifdef CONFIG_CFG80211_WEXT
1540 /* wext data */ 2017 /* wext data */
1541 struct { 2018 struct {
@@ -1563,15 +2040,18 @@ static inline void *wdev_priv(struct wireless_dev *wdev)
1563 return wiphy_priv(wdev->wiphy); 2040 return wiphy_priv(wdev->wiphy);
1564} 2041}
1565 2042
1566/* 2043/**
1567 * Utility functions 2044 * DOC: Utility functions
2045 *
2046 * cfg80211 offers a number of utility functions that can be useful.
1568 */ 2047 */
1569 2048
1570/** 2049/**
1571 * ieee80211_channel_to_frequency - convert channel number to frequency 2050 * ieee80211_channel_to_frequency - convert channel number to frequency
1572 * @chan: channel number 2051 * @chan: channel number
2052 * @band: band, necessary due to channel number overlap
1573 */ 2053 */
1574extern int ieee80211_channel_to_frequency(int chan); 2054extern int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band);
1575 2055
1576/** 2056/**
1577 * ieee80211_frequency_to_channel - convert frequency to channel number 2057 * ieee80211_frequency_to_channel - convert frequency to channel number
@@ -1715,7 +2195,15 @@ unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
1715 * ieee80211_hdrlen - get header length in bytes from frame control 2195 * ieee80211_hdrlen - get header length in bytes from frame control
1716 * @fc: frame control field in little-endian format 2196 * @fc: frame control field in little-endian format
1717 */ 2197 */
1718unsigned int ieee80211_hdrlen(__le16 fc); 2198unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
2199
2200/**
2201 * DOC: Data path helpers
2202 *
2203 * In addition to generic utilities, cfg80211 also offers
2204 * functions that help implement the data path for devices
2205 * that do not do the 802.11/802.3 conversion on the device.
2206 */
1719 2207
1720/** 2208/**
1721 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 2209 * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
@@ -1750,10 +2238,12 @@ int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
1750 * @addr: The device MAC address. 2238 * @addr: The device MAC address.
1751 * @iftype: The device interface type. 2239 * @iftype: The device interface type.
1752 * @extra_headroom: The hardware extra headroom for SKBs in the @list. 2240 * @extra_headroom: The hardware extra headroom for SKBs in the @list.
2241 * @has_80211_header: Set it true if SKB is with IEEE 802.11 header.
1753 */ 2242 */
1754void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, 2243void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
1755 const u8 *addr, enum nl80211_iftype iftype, 2244 const u8 *addr, enum nl80211_iftype iftype,
1756 const unsigned int extra_headroom); 2245 const unsigned int extra_headroom,
2246 bool has_80211_header);
1757 2247
1758/** 2248/**
1759 * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame 2249 * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
@@ -1777,8 +2267,10 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb);
1777 */ 2267 */
1778const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len); 2268const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len);
1779 2269
1780/* 2270/**
1781 * Regulatory helper functions for wiphys 2271 * DOC: Regulatory enforcement infrastructure
2272 *
2273 * TODO
1782 */ 2274 */
1783 2275
1784/** 2276/**
@@ -1971,6 +2463,24 @@ int cfg80211_wext_siwpmksa(struct net_device *dev,
1971void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted); 2463void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted);
1972 2464
1973/** 2465/**
2466 * cfg80211_sched_scan_results - notify that new scan results are available
2467 *
2468 * @wiphy: the wiphy which got scheduled scan results
2469 */
2470void cfg80211_sched_scan_results(struct wiphy *wiphy);
2471
2472/**
2473 * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
2474 *
2475 * @wiphy: the wiphy on which the scheduled scan stopped
2476 *
2477 * The driver can call this function to inform cfg80211 that the
2478 * scheduled scan had to be stopped, for whatever reason. The driver
2479 * is then called back via the sched_scan_stop operation when done.
2480 */
2481void cfg80211_sched_scan_stopped(struct wiphy *wiphy);
2482
2483/**
1974 * cfg80211_inform_bss_frame - inform cfg80211 of a received BSS frame 2484 * cfg80211_inform_bss_frame - inform cfg80211 of a received BSS frame
1975 * 2485 *
1976 * @wiphy: the wiphy reporting the BSS 2486 * @wiphy: the wiphy reporting the BSS
@@ -2148,11 +2658,37 @@ void __cfg80211_send_disassoc(struct net_device *dev, const u8 *buf,
2148 size_t len); 2658 size_t len);
2149 2659
2150/** 2660/**
2661 * cfg80211_send_unprot_deauth - notification of unprotected deauthentication
2662 * @dev: network device
2663 * @buf: deauthentication frame (header + body)
2664 * @len: length of the frame data
2665 *
2666 * This function is called whenever a received Deauthentication frame has been
2667 * dropped in station mode because of MFP being used but the Deauthentication
2668 * frame was not protected. This function may sleep.
2669 */
2670void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf,
2671 size_t len);
2672
2673/**
2674 * cfg80211_send_unprot_disassoc - notification of unprotected disassociation
2675 * @dev: network device
2676 * @buf: disassociation frame (header + body)
2677 * @len: length of the frame data
2678 *
2679 * This function is called whenever a received Disassociation frame has been
2680 * dropped in station mode because of MFP being used but the Disassociation
2681 * frame was not protected. This function may sleep.
2682 */
2683void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf,
2684 size_t len);
2685
2686/**
2151 * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP) 2687 * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
2152 * @dev: network device 2688 * @dev: network device
2153 * @addr: The source MAC address of the frame 2689 * @addr: The source MAC address of the frame
2154 * @key_type: The key type that the received frame used 2690 * @key_type: The key type that the received frame used
2155 * @key_id: Key identifier (0..3) 2691 * @key_id: Key identifier (0..3). Can be -1 if missing.
2156 * @tsc: The TSC value of the frame that generated the MIC failure (6 octets) 2692 * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
2157 * @gfp: allocation flags 2693 * @gfp: allocation flags
2158 * 2694 *
@@ -2181,6 +2717,36 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
2181void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp); 2717void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp);
2182 2718
2183/** 2719/**
2720 * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
2721 *
2722 * @dev: network device
2723 * @macaddr: the MAC address of the new candidate
2724 * @ie: information elements advertised by the peer candidate
2725 * @ie_len: lenght of the information elements buffer
2726 * @gfp: allocation flags
2727 *
2728 * This function notifies cfg80211 that the mesh peer candidate has been
2729 * detected, most likely via a beacon or, less likely, via a probe response.
2730 * cfg80211 then sends a notification to userspace.
2731 */
2732void cfg80211_notify_new_peer_candidate(struct net_device *dev,
2733 const u8 *macaddr, const u8 *ie, u8 ie_len, gfp_t gfp);
2734
2735/**
2736 * DOC: RFkill integration
2737 *
2738 * RFkill integration in cfg80211 is almost invisible to drivers,
2739 * as cfg80211 automatically registers an rfkill instance for each
2740 * wireless device it knows about. Soft kill is also translated
2741 * into disconnecting and turning all interfaces off, drivers are
2742 * expected to turn off the device when all interfaces are down.
2743 *
2744 * However, devices may have a hard RFkill line, in which case they
2745 * also need to interact with the rfkill subsystem, via cfg80211.
2746 * They can do this with a few helper functions documented here.
2747 */
2748
2749/**
2184 * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state 2750 * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state
2185 * @wiphy: the wiphy 2751 * @wiphy: the wiphy
2186 * @blocked: block status 2752 * @blocked: block status
@@ -2201,6 +2767,17 @@ void wiphy_rfkill_stop_polling(struct wiphy *wiphy);
2201 2767
2202#ifdef CONFIG_NL80211_TESTMODE 2768#ifdef CONFIG_NL80211_TESTMODE
2203/** 2769/**
2770 * DOC: Test mode
2771 *
2772 * Test mode is a set of utility functions to allow drivers to
2773 * interact with driver-specific tools to aid, for instance,
2774 * factory programming.
2775 *
2776 * This chapter describes how drivers interact with it, for more
2777 * information see the nl80211 book's chapter on it.
2778 */
2779
2780/**
2204 * cfg80211_testmode_alloc_reply_skb - allocate testmode reply 2781 * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
2205 * @wiphy: the wiphy 2782 * @wiphy: the wiphy
2206 * @approxlen: an upper bound of the length of the data that will 2783 * @approxlen: an upper bound of the length of the data that will
@@ -2302,6 +2879,7 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
2302 * cfg80211_roamed - notify cfg80211 of roaming 2879 * cfg80211_roamed - notify cfg80211 of roaming
2303 * 2880 *
2304 * @dev: network device 2881 * @dev: network device
2882 * @channel: the channel of the new AP
2305 * @bssid: the BSSID of the new AP 2883 * @bssid: the BSSID of the new AP
2306 * @req_ie: association request IEs (maybe be %NULL) 2884 * @req_ie: association request IEs (maybe be %NULL)
2307 * @req_ie_len: association request IEs length 2885 * @req_ie_len: association request IEs length
@@ -2312,7 +2890,9 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
2312 * It should be called by the underlying driver whenever it roamed 2890 * It should be called by the underlying driver whenever it roamed
2313 * from one AP to another while connected. 2891 * from one AP to another while connected.
2314 */ 2892 */
2315void cfg80211_roamed(struct net_device *dev, const u8 *bssid, 2893void cfg80211_roamed(struct net_device *dev,
2894 struct ieee80211_channel *channel,
2895 const u8 *bssid,
2316 const u8 *req_ie, size_t req_ie_len, 2896 const u8 *req_ie, size_t req_ie_len,
2317 const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); 2897 const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp);
2318 2898
@@ -2373,38 +2953,48 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
2373 struct station_info *sinfo, gfp_t gfp); 2953 struct station_info *sinfo, gfp_t gfp);
2374 2954
2375/** 2955/**
2376 * cfg80211_rx_action - notification of received, unprocessed Action frame 2956 * cfg80211_del_sta - notify userspace about deletion of a station
2957 *
2958 * @dev: the netdev
2959 * @mac_addr: the station's address
2960 * @gfp: allocation flags
2961 */
2962void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp);
2963
2964/**
2965 * cfg80211_rx_mgmt - notification of received, unprocessed management frame
2377 * @dev: network device 2966 * @dev: network device
2378 * @freq: Frequency on which the frame was received in MHz 2967 * @freq: Frequency on which the frame was received in MHz
2379 * @buf: Action frame (header + body) 2968 * @buf: Management frame (header + body)
2380 * @len: length of the frame data 2969 * @len: length of the frame data
2381 * @gfp: context flags 2970 * @gfp: context flags
2382 * Returns %true if a user space application is responsible for rejecting the 2971 *
2383 * unrecognized Action frame; %false if no such application is registered 2972 * Returns %true if a user space application has registered for this frame.
2384 * (i.e., the driver is responsible for rejecting the unrecognized Action 2973 * For action frames, that makes it responsible for rejecting unrecognized
2385 * frame) 2974 * action frames; %false otherwise, in which case for action frames the
2975 * driver is responsible for rejecting the frame.
2386 * 2976 *
2387 * This function is called whenever an Action frame is received for a station 2977 * This function is called whenever an Action frame is received for a station
2388 * mode interface, but is not processed in kernel. 2978 * mode interface, but is not processed in kernel.
2389 */ 2979 */
2390bool cfg80211_rx_action(struct net_device *dev, int freq, const u8 *buf, 2980bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf,
2391 size_t len, gfp_t gfp); 2981 size_t len, gfp_t gfp);
2392 2982
2393/** 2983/**
2394 * cfg80211_action_tx_status - notification of TX status for Action frame 2984 * cfg80211_mgmt_tx_status - notification of TX status for management frame
2395 * @dev: network device 2985 * @dev: network device
2396 * @cookie: Cookie returned by cfg80211_ops::action() 2986 * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
2397 * @buf: Action frame (header + body) 2987 * @buf: Management frame (header + body)
2398 * @len: length of the frame data 2988 * @len: length of the frame data
2399 * @ack: Whether frame was acknowledged 2989 * @ack: Whether frame was acknowledged
2400 * @gfp: context flags 2990 * @gfp: context flags
2401 * 2991 *
2402 * This function is called whenever an Action frame was requested to be 2992 * This function is called whenever a management frame was requested to be
2403 * transmitted with cfg80211_ops::action() to report the TX status of the 2993 * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
2404 * transmission attempt. 2994 * transmission attempt.
2405 */ 2995 */
2406void cfg80211_action_tx_status(struct net_device *dev, u64 cookie, 2996void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie,
2407 const u8 *buf, size_t len, bool ack, gfp_t gfp); 2997 const u8 *buf, size_t len, bool ack, gfp_t gfp);
2408 2998
2409 2999
2410/** 3000/**
@@ -2420,56 +3010,53 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
2420 enum nl80211_cqm_rssi_threshold_event rssi_event, 3010 enum nl80211_cqm_rssi_threshold_event rssi_event,
2421 gfp_t gfp); 3011 gfp_t gfp);
2422 3012
2423#ifdef __KERNEL__ 3013/**
3014 * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
3015 * @dev: network device
3016 * @peer: peer's MAC address
3017 * @num_packets: how many packets were lost -- should be a fixed threshold
3018 * but probably no less than maybe 50, or maybe a throughput dependent
3019 * threshold (to account for temporary interference)
3020 * @gfp: context flags
3021 */
3022void cfg80211_cqm_pktloss_notify(struct net_device *dev,
3023 const u8 *peer, u32 num_packets, gfp_t gfp);
2424 3024
2425/* Logging, debugging and troubleshooting/diagnostic helpers. */ 3025/* Logging, debugging and troubleshooting/diagnostic helpers. */
2426 3026
2427/* wiphy_printk helpers, similar to dev_printk */ 3027/* wiphy_printk helpers, similar to dev_printk */
2428 3028
2429#define wiphy_printk(level, wiphy, format, args...) \ 3029#define wiphy_printk(level, wiphy, format, args...) \
2430 printk(level "%s: " format, wiphy_name(wiphy), ##args) 3030 dev_printk(level, &(wiphy)->dev, format, ##args)
2431#define wiphy_emerg(wiphy, format, args...) \ 3031#define wiphy_emerg(wiphy, format, args...) \
2432 wiphy_printk(KERN_EMERG, wiphy, format, ##args) 3032 dev_emerg(&(wiphy)->dev, format, ##args)
2433#define wiphy_alert(wiphy, format, args...) \ 3033#define wiphy_alert(wiphy, format, args...) \
2434 wiphy_printk(KERN_ALERT, wiphy, format, ##args) 3034 dev_alert(&(wiphy)->dev, format, ##args)
2435#define wiphy_crit(wiphy, format, args...) \ 3035#define wiphy_crit(wiphy, format, args...) \
2436 wiphy_printk(KERN_CRIT, wiphy, format, ##args) 3036 dev_crit(&(wiphy)->dev, format, ##args)
2437#define wiphy_err(wiphy, format, args...) \ 3037#define wiphy_err(wiphy, format, args...) \
2438 wiphy_printk(KERN_ERR, wiphy, format, ##args) 3038 dev_err(&(wiphy)->dev, format, ##args)
2439#define wiphy_warn(wiphy, format, args...) \ 3039#define wiphy_warn(wiphy, format, args...) \
2440 wiphy_printk(KERN_WARNING, wiphy, format, ##args) 3040 dev_warn(&(wiphy)->dev, format, ##args)
2441#define wiphy_notice(wiphy, format, args...) \ 3041#define wiphy_notice(wiphy, format, args...) \
2442 wiphy_printk(KERN_NOTICE, wiphy, format, ##args) 3042 dev_notice(&(wiphy)->dev, format, ##args)
2443#define wiphy_info(wiphy, format, args...) \ 3043#define wiphy_info(wiphy, format, args...) \
2444 wiphy_printk(KERN_INFO, wiphy, format, ##args) 3044 dev_info(&(wiphy)->dev, format, ##args)
2445
2446int wiphy_debug(const struct wiphy *wiphy, const char *format, ...)
2447 __attribute__ ((format (printf, 2, 3)));
2448 3045
2449#if defined(DEBUG) 3046#define wiphy_debug(wiphy, format, args...) \
2450#define wiphy_dbg(wiphy, format, args...) \
2451 wiphy_printk(KERN_DEBUG, wiphy, format, ##args) 3047 wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
2452#elif defined(CONFIG_DYNAMIC_DEBUG) 3048
2453#define wiphy_dbg(wiphy, format, args...) \ 3049#define wiphy_dbg(wiphy, format, args...) \
2454 dynamic_pr_debug("%s: " format, wiphy_name(wiphy), ##args) 3050 dev_dbg(&(wiphy)->dev, format, ##args)
2455#else
2456#define wiphy_dbg(wiphy, format, args...) \
2457({ \
2458 if (0) \
2459 wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
2460 0; \
2461})
2462#endif
2463 3051
2464#if defined(VERBOSE_DEBUG) 3052#if defined(VERBOSE_DEBUG)
2465#define wiphy_vdbg wiphy_dbg 3053#define wiphy_vdbg wiphy_dbg
2466#else 3054#else
2467
2468#define wiphy_vdbg(wiphy, format, args...) \ 3055#define wiphy_vdbg(wiphy, format, args...) \
2469({ \ 3056({ \
2470 if (0) \ 3057 if (0) \
2471 wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \ 3058 wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
2472 0; \ 3059 0; \
2473}) 3060})
2474#endif 3061#endif
2475 3062
@@ -2481,6 +3068,4 @@ int wiphy_debug(const struct wiphy *wiphy, const char *format, ...)
2481#define wiphy_WARN(wiphy, format, args...) \ 3068#define wiphy_WARN(wiphy, format, args...) \
2482 WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args); 3069 WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args);
2483 3070
2484#endif
2485
2486#endif /* __NET_CFG80211_H */ 3071#endif /* __NET_CFG80211_H */
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index ef6c24a529e1..a4dc5b027bd9 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h
@@ -51,7 +51,8 @@ static inline u32 task_cls_classid(struct task_struct *p)
51 return 0; 51 return 0;
52 52
53 rcu_read_lock(); 53 rcu_read_lock();
54 id = rcu_dereference(net_cls_subsys_id); 54 id = rcu_dereference_index_check(net_cls_subsys_id,
55 rcu_read_lock_held());
55 if (id >= 0) 56 if (id >= 0)
56 classid = container_of(task_subsys_state(p, id), 57 classid = container_of(task_subsys_state(p, id),
57 struct cgroup_cls_state, css)->classid; 58 struct cgroup_cls_state, css)->classid;
diff --git a/include/net/compat.h b/include/net/compat.h
index 28d5428ec6a2..9ee75edcc295 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -43,6 +43,8 @@ extern int compat_sock_get_timestampns(struct sock *, struct timespec __user *);
43extern int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *); 43extern int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *);
44extern int verify_compat_iovec(struct msghdr *, struct iovec *, struct sockaddr *, int); 44extern int verify_compat_iovec(struct msghdr *, struct iovec *, struct sockaddr *, int);
45extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsigned); 45extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsigned);
46extern asmlinkage long compat_sys_sendmmsg(int, struct compat_mmsghdr __user *,
47 unsigned, unsigned);
46extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned); 48extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned);
47extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *, 49extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *,
48 unsigned, unsigned, 50 unsigned, unsigned,
diff --git a/include/net/dcbevent.h b/include/net/dcbevent.h
new file mode 100644
index 000000000000..bc1e7ef40171
--- /dev/null
+++ b/include/net/dcbevent.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (c) 2010, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Author: John Fastabend <john.r.fastabend@intel.com>
18 */
19
20#ifndef _DCB_EVENT_H
21#define _DCB_EVENT_H
22
23enum dcbevent_notif_type {
24 DCB_APP_EVENT = 1,
25};
26
27extern int register_dcbevent_notifier(struct notifier_block *nb);
28extern int unregister_dcbevent_notifier(struct notifier_block *nb);
29extern int call_dcbevent_notifiers(unsigned long val, void *v);
30
31#endif
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index b36ac7e0914d..e5983c9053dc 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -20,11 +20,33 @@
20#ifndef __NET_DCBNL_H__ 20#ifndef __NET_DCBNL_H__
21#define __NET_DCBNL_H__ 21#define __NET_DCBNL_H__
22 22
23#include <linux/dcbnl.h>
24
25struct dcb_app_type {
26 char name[IFNAMSIZ];
27 struct dcb_app app;
28 struct list_head list;
29};
30
31u8 dcb_setapp(struct net_device *, struct dcb_app *);
32u8 dcb_getapp(struct net_device *, struct dcb_app *);
33
23/* 34/*
24 * Ops struct for the netlink callbacks. Used by DCB-enabled drivers through 35 * Ops struct for the netlink callbacks. Used by DCB-enabled drivers through
25 * the netdevice struct. 36 * the netdevice struct.
26 */ 37 */
27struct dcbnl_rtnl_ops { 38struct dcbnl_rtnl_ops {
39 /* IEEE 802.1Qaz std */
40 int (*ieee_getets) (struct net_device *, struct ieee_ets *);
41 int (*ieee_setets) (struct net_device *, struct ieee_ets *);
42 int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *);
43 int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *);
44 int (*ieee_getapp) (struct net_device *, struct dcb_app *);
45 int (*ieee_setapp) (struct net_device *, struct dcb_app *);
46 int (*ieee_peer_getets) (struct net_device *, struct ieee_ets *);
47 int (*ieee_peer_getpfc) (struct net_device *, struct ieee_pfc *);
48
49 /* CEE std */
28 u8 (*getstate)(struct net_device *); 50 u8 (*getstate)(struct net_device *);
29 u8 (*setstate)(struct net_device *, u8); 51 u8 (*setstate)(struct net_device *, u8);
30 void (*getpermhwaddr)(struct net_device *, u8 *); 52 void (*getpermhwaddr)(struct net_device *, u8 *);
@@ -50,6 +72,21 @@ struct dcbnl_rtnl_ops {
50 void (*setbcnrp)(struct net_device *, int, u8); 72 void (*setbcnrp)(struct net_device *, int, u8);
51 u8 (*setapp)(struct net_device *, u8, u16, u8); 73 u8 (*setapp)(struct net_device *, u8, u16, u8);
52 u8 (*getapp)(struct net_device *, u8, u16); 74 u8 (*getapp)(struct net_device *, u8, u16);
75 u8 (*getfeatcfg)(struct net_device *, int, u8 *);
76 u8 (*setfeatcfg)(struct net_device *, int, u8);
77
78 /* DCBX configuration */
79 u8 (*getdcbx)(struct net_device *);
80 u8 (*setdcbx)(struct net_device *, u8);
81
82 /* peer apps */
83 int (*peer_getappinfo)(struct net_device *, struct dcb_peer_app_info *,
84 u16 *);
85 int (*peer_getapptable)(struct net_device *, struct dcb_app *);
86
87 /* CEE peer */
88 int (*cee_peer_getpg) (struct net_device *, struct cee_pg *);
89 int (*cee_peer_getpfc) (struct net_device *, struct cee_pfc *);
53}; 90};
54 91
55#endif /* __NET_DCBNL_H__ */ 92#endif /* __NET_DCBNL_H__ */
diff --git a/include/net/dn.h b/include/net/dn.h
index e5469f7b67a3..298521e0d8a2 100644
--- a/include/net/dn.h
+++ b/include/net/dn.h
@@ -192,10 +192,10 @@ static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
192 ethaddr[5] = (__u8)(a >> 8); 192 ethaddr[5] = (__u8)(a >> 8);
193} 193}
194 194
195static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp) 195static inline void dn_sk_ports_copy(struct flowidn *fld, struct dn_scp *scp)
196{ 196{
197 fl->uli_u.dnports.sport = scp->addrloc; 197 fld->fld_sport = scp->addrloc;
198 fl->uli_u.dnports.dport = scp->addrrem; 198 fld->fld_dport = scp->addrrem;
199} 199}
200 200
201extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); 201extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu);
@@ -225,7 +225,7 @@ extern int decnet_di_count;
225extern int decnet_dr_count; 225extern int decnet_dr_count;
226extern int decnet_no_fc_max_cwnd; 226extern int decnet_no_fc_max_cwnd;
227 227
228extern int sysctl_decnet_mem[3]; 228extern long sysctl_decnet_mem[3];
229extern int sysctl_decnet_wmem[3]; 229extern int sysctl_decnet_wmem[3];
230extern int sysctl_decnet_rmem[3]; 230extern int sysctl_decnet_rmem[3];
231 231
diff --git a/include/net/dn_dev.h b/include/net/dn_dev.h
index 0916bbf3bdff..b9e32db03f20 100644
--- a/include/net/dn_dev.h
+++ b/include/net/dn_dev.h
@@ -5,13 +5,14 @@
5struct dn_dev; 5struct dn_dev;
6 6
7struct dn_ifaddr { 7struct dn_ifaddr {
8 struct dn_ifaddr *ifa_next; 8 struct dn_ifaddr __rcu *ifa_next;
9 struct dn_dev *ifa_dev; 9 struct dn_dev *ifa_dev;
10 __le16 ifa_local; 10 __le16 ifa_local;
11 __le16 ifa_address; 11 __le16 ifa_address;
12 __u8 ifa_flags; 12 __u8 ifa_flags;
13 __u8 ifa_scope; 13 __u8 ifa_scope;
14 char ifa_label[IFNAMSIZ]; 14 char ifa_label[IFNAMSIZ];
15 struct rcu_head rcu;
15}; 16};
16 17
17#define DN_DEV_S_RU 0 /* Run - working normally */ 18#define DN_DEV_S_RU 0 /* Run - working normally */
@@ -83,7 +84,7 @@ struct dn_dev_parms {
83 84
84 85
85struct dn_dev { 86struct dn_dev {
86 struct dn_ifaddr *ifa_list; 87 struct dn_ifaddr __rcu *ifa_list;
87 struct net_device *dev; 88 struct net_device *dev;
88 struct dn_dev_parms parms; 89 struct dn_dev_parms parms;
89 char use_long; 90 char use_long;
@@ -171,19 +172,27 @@ extern int unregister_dnaddr_notifier(struct notifier_block *nb);
171 172
172static inline int dn_dev_islocal(struct net_device *dev, __le16 addr) 173static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
173{ 174{
174 struct dn_dev *dn_db = dev->dn_ptr; 175 struct dn_dev *dn_db;
175 struct dn_ifaddr *ifa; 176 struct dn_ifaddr *ifa;
177 int res = 0;
176 178
179 rcu_read_lock();
180 dn_db = rcu_dereference(dev->dn_ptr);
177 if (dn_db == NULL) { 181 if (dn_db == NULL) {
178 printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n"); 182 printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n");
179 return 0; 183 goto out;
180 } 184 }
181 185
182 for(ifa = dn_db->ifa_list; ifa; ifa = ifa->ifa_next) 186 for (ifa = rcu_dereference(dn_db->ifa_list);
183 if ((addr ^ ifa->ifa_local) == 0) 187 ifa != NULL;
184 return 1; 188 ifa = rcu_dereference(ifa->ifa_next))
185 189 if ((addr ^ ifa->ifa_local) == 0) {
186 return 0; 190 res = 1;
191 break;
192 }
193out:
194 rcu_read_unlock();
195 return res;
187} 196}
188 197
189#endif /* _NET_DN_DEV_H */ 198#endif /* _NET_DN_DEV_H */
diff --git a/include/net/dn_fib.h b/include/net/dn_fib.h
index bbcde3238e58..782ef7cb4930 100644
--- a/include/net/dn_fib.h
+++ b/include/net/dn_fib.h
@@ -98,7 +98,7 @@ struct dn_fib_table {
98 int (*delete)(struct dn_fib_table *t, struct rtmsg *r, 98 int (*delete)(struct dn_fib_table *t, struct rtmsg *r,
99 struct dn_kern_rta *rta, struct nlmsghdr *n, 99 struct dn_kern_rta *rta, struct nlmsghdr *n,
100 struct netlink_skb_parms *req); 100 struct netlink_skb_parms *req);
101 int (*lookup)(struct dn_fib_table *t, const struct flowi *fl, 101 int (*lookup)(struct dn_fib_table *t, const struct flowidn *fld,
102 struct dn_fib_res *res); 102 struct dn_fib_res *res);
103 int (*flush)(struct dn_fib_table *t); 103 int (*flush)(struct dn_fib_table *t);
104 int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb); 104 int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
@@ -119,12 +119,12 @@ extern struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r,
119 struct dn_kern_rta *rta, 119 struct dn_kern_rta *rta,
120 const struct nlmsghdr *nlh, int *errp); 120 const struct nlmsghdr *nlh, int *errp);
121extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi, 121extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi,
122 const struct flowi *fl, 122 const struct flowidn *fld,
123 struct dn_fib_res *res); 123 struct dn_fib_res *res);
124extern void dn_fib_release_info(struct dn_fib_info *fi); 124extern void dn_fib_release_info(struct dn_fib_info *fi);
125extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type); 125extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type);
126extern void dn_fib_flush(void); 126extern void dn_fib_flush(void);
127extern void dn_fib_select_multipath(const struct flowi *fl, 127extern void dn_fib_select_multipath(const struct flowidn *fld,
128 struct dn_fib_res *res); 128 struct dn_fib_res *res);
129 129
130/* 130/*
@@ -141,7 +141,7 @@ extern void dn_fib_table_cleanup(void);
141extern void dn_fib_rules_init(void); 141extern void dn_fib_rules_init(void);
142extern void dn_fib_rules_cleanup(void); 142extern void dn_fib_rules_cleanup(void);
143extern unsigned dnet_addr_type(__le16 addr); 143extern unsigned dnet_addr_type(__le16 addr);
144extern int dn_fib_lookup(struct flowi *fl, struct dn_fib_res *res); 144extern int dn_fib_lookup(struct flowidn *fld, struct dn_fib_res *res);
145 145
146extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb); 146extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
147 147
diff --git a/include/net/dn_route.h b/include/net/dn_route.h
index ccadab3aa3f6..81712cfa1ddf 100644
--- a/include/net/dn_route.h
+++ b/include/net/dn_route.h
@@ -16,7 +16,7 @@
16*******************************************************************************/ 16*******************************************************************************/
17 17
18extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); 18extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
19extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags); 19extern int dn_route_output_sock(struct dst_entry **pprt, struct flowidn *, struct sock *sk, int flags);
20extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); 20extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb);
21extern void dn_rt_cache_flush(int delay); 21extern void dn_rt_cache_flush(int delay);
22 22
@@ -67,7 +67,7 @@ extern void dn_rt_cache_flush(int delay);
67struct dn_route { 67struct dn_route {
68 struct dst_entry dst; 68 struct dst_entry dst;
69 69
70 struct flowi fl; 70 struct flowidn fld;
71 71
72 __le16 rt_saddr; 72 __le16 rt_saddr;
73 __le16 rt_daddr; 73 __le16 rt_daddr;
@@ -80,6 +80,16 @@ struct dn_route {
80 unsigned rt_type; 80 unsigned rt_type;
81}; 81};
82 82
83static inline bool dn_is_input_route(struct dn_route *rt)
84{
85 return rt->fld.flowidn_iif != 0;
86}
87
88static inline bool dn_is_output_route(struct dn_route *rt)
89{
90 return rt->fld.flowidn_iif == 0;
91}
92
83extern void dn_route_init(void); 93extern void dn_route_init(void);
84extern void dn_route_cleanup(void); 94extern void dn_route_cleanup(void);
85 95
diff --git a/include/net/dst.h b/include/net/dst.h
index 02386505033d..e12ddfb9eb16 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -16,13 +16,6 @@
16#include <net/neighbour.h> 16#include <net/neighbour.h>
17#include <asm/processor.h> 17#include <asm/processor.h>
18 18
19/*
20 * 0 - no debugging messages
21 * 1 - rare events and bugs (default)
22 * 2 - trace mode.
23 */
24#define RT_CACHE_DEBUG 0
25
26#define DST_GC_MIN (HZ/10) 19#define DST_GC_MIN (HZ/10)
27#define DST_GC_INC (HZ/2) 20#define DST_GC_INC (HZ/2)
28#define DST_GC_MAX (120*HZ) 21#define DST_GC_MAX (120*HZ)
@@ -40,23 +33,10 @@ struct dst_entry {
40 struct rcu_head rcu_head; 33 struct rcu_head rcu_head;
41 struct dst_entry *child; 34 struct dst_entry *child;
42 struct net_device *dev; 35 struct net_device *dev;
43 short error; 36 struct dst_ops *ops;
44 short obsolete; 37 unsigned long _metrics;
45 int flags;
46#define DST_HOST 1
47#define DST_NOXFRM 2
48#define DST_NOPOLICY 4
49#define DST_NOHASH 8
50 unsigned long expires; 38 unsigned long expires;
51
52 unsigned short header_len; /* more space at head required */
53 unsigned short trailer_len; /* space to reserve at tail */
54
55 unsigned int rate_tokens;
56 unsigned long rate_last; /* rate limiting for ICMP */
57
58 struct dst_entry *path; 39 struct dst_entry *path;
59
60 struct neighbour *neighbour; 40 struct neighbour *neighbour;
61 struct hh_cache *hh; 41 struct hh_cache *hh;
62#ifdef CONFIG_XFRM 42#ifdef CONFIG_XFRM
@@ -67,17 +47,16 @@ struct dst_entry {
67 int (*input)(struct sk_buff*); 47 int (*input)(struct sk_buff*);
68 int (*output)(struct sk_buff*); 48 int (*output)(struct sk_buff*);
69 49
70 struct dst_ops *ops; 50 short error;
71 51 short obsolete;
72 u32 metrics[RTAX_MAX]; 52 unsigned short header_len; /* more space at head required */
73 53 unsigned short trailer_len; /* space to reserve at tail */
74#ifdef CONFIG_NET_CLS_ROUTE 54#ifdef CONFIG_IP_ROUTE_CLASSID
75 __u32 tclassid; 55 __u32 tclassid;
76#else 56#else
77 __u32 __pad2; 57 __u32 __pad2;
78#endif 58#endif
79 59
80
81 /* 60 /*
82 * Align __refcnt to a 64 bytes alignment 61 * Align __refcnt to a 64 bytes alignment
83 * (L1_CACHE_SIZE would be too much) 62 * (L1_CACHE_SIZE would be too much)
@@ -92,20 +71,115 @@ struct dst_entry {
92 atomic_t __refcnt; /* client references */ 71 atomic_t __refcnt; /* client references */
93 int __use; 72 int __use;
94 unsigned long lastuse; 73 unsigned long lastuse;
74 int flags;
75#define DST_HOST 0x0001
76#define DST_NOXFRM 0x0002
77#define DST_NOPOLICY 0x0004
78#define DST_NOHASH 0x0008
79#define DST_NOCACHE 0x0010
80#define DST_NOCOUNT 0x0020
95 union { 81 union {
96 struct dst_entry *next; 82 struct dst_entry *next;
97 struct rtable *rt_next; 83 struct rtable __rcu *rt_next;
98 struct rt6_info *rt6_next; 84 struct rt6_info *rt6_next;
99 struct dn_route *dn_next; 85 struct dn_route __rcu *dn_next;
100 }; 86 };
101}; 87};
102 88
103#ifdef __KERNEL__ 89extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
90extern const u32 dst_default_metrics[RTAX_MAX];
91
92#define DST_METRICS_READ_ONLY 0x1UL
93#define __DST_METRICS_PTR(Y) \
94 ((u32 *)((Y) & ~DST_METRICS_READ_ONLY))
95#define DST_METRICS_PTR(X) __DST_METRICS_PTR((X)->_metrics)
96
97static inline bool dst_metrics_read_only(const struct dst_entry *dst)
98{
99 return dst->_metrics & DST_METRICS_READ_ONLY;
100}
101
102extern void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old);
103
104static inline void dst_destroy_metrics_generic(struct dst_entry *dst)
105{
106 unsigned long val = dst->_metrics;
107 if (!(val & DST_METRICS_READ_ONLY))
108 __dst_destroy_metrics_generic(dst, val);
109}
110
111static inline u32 *dst_metrics_write_ptr(struct dst_entry *dst)
112{
113 unsigned long p = dst->_metrics;
114
115 BUG_ON(!p);
116
117 if (p & DST_METRICS_READ_ONLY)
118 return dst->ops->cow_metrics(dst, p);
119 return __DST_METRICS_PTR(p);
120}
121
122/* This may only be invoked before the entry has reached global
123 * visibility.
124 */
125static inline void dst_init_metrics(struct dst_entry *dst,
126 const u32 *src_metrics,
127 bool read_only)
128{
129 dst->_metrics = ((unsigned long) src_metrics) |
130 (read_only ? DST_METRICS_READ_ONLY : 0);
131}
132
133static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
134{
135 u32 *dst_metrics = dst_metrics_write_ptr(dest);
136
137 if (dst_metrics) {
138 u32 *src_metrics = DST_METRICS_PTR(src);
139
140 memcpy(dst_metrics, src_metrics, RTAX_MAX * sizeof(u32));
141 }
142}
143
144static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
145{
146 return DST_METRICS_PTR(dst);
147}
148
149static inline u32
150dst_metric_raw(const struct dst_entry *dst, const int metric)
151{
152 u32 *p = DST_METRICS_PTR(dst);
153
154 return p[metric-1];
155}
156
157static inline u32
158dst_metric(const struct dst_entry *dst, const int metric)
159{
160 WARN_ON_ONCE(metric == RTAX_HOPLIMIT ||
161 metric == RTAX_ADVMSS ||
162 metric == RTAX_MTU);
163 return dst_metric_raw(dst, metric);
164}
104 165
105static inline u32 166static inline u32
106dst_metric(const struct dst_entry *dst, int metric) 167dst_metric_advmss(const struct dst_entry *dst)
107{ 168{
108 return dst->metrics[metric-1]; 169 u32 advmss = dst_metric_raw(dst, RTAX_ADVMSS);
170
171 if (!advmss)
172 advmss = dst->ops->default_advmss(dst);
173
174 return advmss;
175}
176
177static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val)
178{
179 u32 *p = dst_metrics_write_ptr(dst);
180
181 if (p)
182 p[metric-1] = val;
109} 183}
110 184
111static inline u32 185static inline u32
@@ -116,11 +190,11 @@ dst_feature(const struct dst_entry *dst, u32 feature)
116 190
117static inline u32 dst_mtu(const struct dst_entry *dst) 191static inline u32 dst_mtu(const struct dst_entry *dst)
118{ 192{
119 u32 mtu = dst_metric(dst, RTAX_MTU); 193 u32 mtu = dst_metric_raw(dst, RTAX_MTU);
120 /* 194
121 * Alexey put it here, so ask him about it :) 195 if (!mtu)
122 */ 196 mtu = dst->ops->default_mtu(dst);
123 barrier(); 197
124 return mtu; 198 return mtu;
125} 199}
126 200
@@ -133,20 +207,18 @@ static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metr
133static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric, 207static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,
134 unsigned long rtt) 208 unsigned long rtt)
135{ 209{
136 dst->metrics[metric-1] = jiffies_to_msecs(rtt); 210 dst_metric_set(dst, metric, jiffies_to_msecs(rtt));
137} 211}
138 212
139static inline u32 213static inline u32
140dst_allfrag(const struct dst_entry *dst) 214dst_allfrag(const struct dst_entry *dst)
141{ 215{
142 int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG); 216 int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG);
143 /* Yes, _exactly_. This is paranoia. */
144 barrier();
145 return ret; 217 return ret;
146} 218}
147 219
148static inline int 220static inline int
149dst_metric_locked(struct dst_entry *dst, int metric) 221dst_metric_locked(const struct dst_entry *dst, int metric)
150{ 222{
151 return dst_metric(dst, RTAX_LOCK) & (1<<metric); 223 return dst_metric(dst, RTAX_LOCK) & (1<<metric);
152} 224}
@@ -228,23 +300,37 @@ static inline void skb_dst_force(struct sk_buff *skb)
228 300
229 301
230/** 302/**
303 * __skb_tunnel_rx - prepare skb for rx reinsert
304 * @skb: buffer
305 * @dev: tunnel device
306 *
307 * After decapsulation, packet is going to re-enter (netif_rx()) our stack,
308 * so make some cleanups. (no accounting done)
309 */
310static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
311{
312 skb->dev = dev;
313 skb->rxhash = 0;
314 skb_set_queue_mapping(skb, 0);
315 skb_dst_drop(skb);
316 nf_reset(skb);
317}
318
319/**
231 * skb_tunnel_rx - prepare skb for rx reinsert 320 * skb_tunnel_rx - prepare skb for rx reinsert
232 * @skb: buffer 321 * @skb: buffer
233 * @dev: tunnel device 322 * @dev: tunnel device
234 * 323 *
235 * After decapsulation, packet is going to re-enter (netif_rx()) our stack, 324 * After decapsulation, packet is going to re-enter (netif_rx()) our stack,
236 * so make some cleanups, and perform accounting. 325 * so make some cleanups, and perform accounting.
326 * Note: this accounting is not SMP safe.
237 */ 327 */
238static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) 328static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
239{ 329{
240 skb->dev = dev;
241 /* TODO : stats should be SMP safe */ 330 /* TODO : stats should be SMP safe */
242 dev->stats.rx_packets++; 331 dev->stats.rx_packets++;
243 dev->stats.rx_bytes += skb->len; 332 dev->stats.rx_bytes += skb->len;
244 skb->rxhash = 0; 333 __skb_tunnel_rx(skb, dev);
245 skb_set_queue_mapping(skb, 0);
246 skb_dst_drop(skb);
247 nf_reset(skb);
248} 334}
249 335
250/* Children define the path of the packet through the 336/* Children define the path of the packet through the
@@ -253,14 +339,15 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
253 339
254static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb) 340static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb)
255{ 341{
256 struct dst_entry *child = skb_dst(skb)->child; 342 struct dst_entry *child = dst_clone(skb_dst(skb)->child);
257 343
258 skb_dst_drop(skb); 344 skb_dst_drop(skb);
259 return child; 345 return child;
260} 346}
261 347
262extern int dst_discard(struct sk_buff *skb); 348extern int dst_discard(struct sk_buff *skb);
263extern void * dst_alloc(struct dst_ops * ops); 349extern void *dst_alloc(struct dst_ops * ops, struct net_device *dev,
350 int initial_ref, int initial_obsolete, int flags);
264extern void __dst_free(struct dst_entry * dst); 351extern void __dst_free(struct dst_entry * dst);
265extern struct dst_entry *dst_destroy(struct dst_entry * dst); 352extern struct dst_entry *dst_destroy(struct dst_entry * dst);
266 353
@@ -329,28 +416,22 @@ extern void dst_init(void);
329 416
330/* Flags for xfrm_lookup flags argument. */ 417/* Flags for xfrm_lookup flags argument. */
331enum { 418enum {
332 XFRM_LOOKUP_WAIT = 1 << 0, 419 XFRM_LOOKUP_ICMP = 1 << 0,
333 XFRM_LOOKUP_ICMP = 1 << 1,
334}; 420};
335 421
336struct flowi; 422struct flowi;
337#ifndef CONFIG_XFRM 423#ifndef CONFIG_XFRM
338static inline int xfrm_lookup(struct net *net, struct dst_entry **dst_p, 424static inline struct dst_entry *xfrm_lookup(struct net *net,
339 struct flowi *fl, struct sock *sk, int flags) 425 struct dst_entry *dst_orig,
426 const struct flowi *fl, struct sock *sk,
427 int flags)
340{ 428{
341 return 0; 429 return dst_orig;
342} 430}
343static inline int __xfrm_lookup(struct net *net, struct dst_entry **dst_p,
344 struct flowi *fl, struct sock *sk, int flags)
345{
346 return 0;
347}
348#else 431#else
349extern int xfrm_lookup(struct net *net, struct dst_entry **dst_p, 432extern struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
350 struct flowi *fl, struct sock *sk, int flags); 433 const struct flowi *fl, struct sock *sk,
351extern int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, 434 int flags);
352 struct flowi *fl, struct sock *sk, int flags);
353#endif
354#endif 435#endif
355 436
356#endif /* _NET_DST_H */ 437#endif /* _NET_DST_H */
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h
index d1ff9b7e99b8..dc0746328947 100644
--- a/include/net/dst_ops.h
+++ b/include/net/dst_ops.h
@@ -1,6 +1,8 @@
1#ifndef _NET_DST_OPS_H 1#ifndef _NET_DST_OPS_H
2#define _NET_DST_OPS_H 2#define _NET_DST_OPS_H
3#include <linux/types.h> 3#include <linux/types.h>
4#include <linux/percpu_counter.h>
5#include <linux/cache.h>
4 6
5struct dst_entry; 7struct dst_entry;
6struct kmem_cachep; 8struct kmem_cachep;
@@ -14,6 +16,9 @@ struct dst_ops {
14 16
15 int (*gc)(struct dst_ops *ops); 17 int (*gc)(struct dst_ops *ops);
16 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); 18 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie);
19 unsigned int (*default_advmss)(const struct dst_entry *);
20 unsigned int (*default_mtu)(const struct dst_entry *);
21 u32 * (*cow_metrics)(struct dst_entry *, unsigned long);
17 void (*destroy)(struct dst_entry *); 22 void (*destroy)(struct dst_entry *);
18 void (*ifdown)(struct dst_entry *, 23 void (*ifdown)(struct dst_entry *,
19 struct net_device *dev, int how); 24 struct net_device *dev, int how);
@@ -22,7 +27,41 @@ struct dst_ops {
22 void (*update_pmtu)(struct dst_entry *dst, u32 mtu); 27 void (*update_pmtu)(struct dst_entry *dst, u32 mtu);
23 int (*local_out)(struct sk_buff *skb); 28 int (*local_out)(struct sk_buff *skb);
24 29
25 atomic_t entries;
26 struct kmem_cache *kmem_cachep; 30 struct kmem_cache *kmem_cachep;
31
32 struct percpu_counter pcpuc_entries ____cacheline_aligned_in_smp;
27}; 33};
34
35static inline int dst_entries_get_fast(struct dst_ops *dst)
36{
37 return percpu_counter_read_positive(&dst->pcpuc_entries);
38}
39
40static inline int dst_entries_get_slow(struct dst_ops *dst)
41{
42 int res;
43
44 local_bh_disable();
45 res = percpu_counter_sum_positive(&dst->pcpuc_entries);
46 local_bh_enable();
47 return res;
48}
49
50static inline void dst_entries_add(struct dst_ops *dst, int val)
51{
52 local_bh_disable();
53 percpu_counter_add(&dst->pcpuc_entries, val);
54 local_bh_enable();
55}
56
57static inline int dst_entries_init(struct dst_ops *dst)
58{
59 return percpu_counter_init(&dst->pcpuc_entries, 0);
60}
61
62static inline void dst_entries_destroy(struct dst_ops *dst)
63{
64 percpu_counter_destroy(&dst->pcpuc_entries);
65}
66
28#endif 67#endif
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index e8923bc20f9f..075f1e3a0fed 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -20,7 +20,7 @@ struct fib_rule {
20 u32 table; 20 u32 table;
21 u8 action; 21 u8 action;
22 u32 target; 22 u32 target;
23 struct fib_rule * ctarget; 23 struct fib_rule __rcu *ctarget;
24 char iifname[IFNAMSIZ]; 24 char iifname[IFNAMSIZ];
25 char oifname[IFNAMSIZ]; 25 char oifname[IFNAMSIZ];
26 struct rcu_head rcu; 26 struct rcu_head rcu;
@@ -31,6 +31,8 @@ struct fib_lookup_arg {
31 void *lookup_ptr; 31 void *lookup_ptr;
32 void *result; 32 void *result;
33 struct fib_rule *rule; 33 struct fib_rule *rule;
34 int flags;
35#define FIB_LOOKUP_NOREF 1
34}; 36};
35 37
36struct fib_rules_ops { 38struct fib_rules_ops {
@@ -106,7 +108,6 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
106 108
107extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *); 109extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *);
108extern void fib_rules_unregister(struct fib_rules_ops *); 110extern void fib_rules_unregister(struct fib_rules_ops *);
109extern void fib_rules_cleanup_ops(struct fib_rules_ops *);
110 111
111extern int fib_rules_lookup(struct fib_rules_ops *, 112extern int fib_rules_lookup(struct fib_rules_ops *,
112 struct flowi *, int flags, 113 struct flowi *, int flags,
diff --git a/include/net/flow.h b/include/net/flow.h
index bb08692a20b0..c6d5fe5ec1bf 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -10,76 +10,157 @@
10#include <linux/in6.h> 10#include <linux/in6.h>
11#include <asm/atomic.h> 11#include <asm/atomic.h>
12 12
13struct flowi { 13struct flowi_common {
14 int oif; 14 int flowic_oif;
15 int iif; 15 int flowic_iif;
16 __u32 mark; 16 __u32 flowic_mark;
17 __u8 flowic_tos;
18 __u8 flowic_scope;
19 __u8 flowic_proto;
20 __u8 flowic_flags;
21#define FLOWI_FLAG_ANYSRC 0x01
22#define FLOWI_FLAG_PRECOW_METRICS 0x02
23#define FLOWI_FLAG_CAN_SLEEP 0x04
24 __u32 flowic_secid;
25};
17 26
27union flowi_uli {
28 struct {
29 __be16 dport;
30 __be16 sport;
31 } ports;
32
33 struct {
34 __u8 type;
35 __u8 code;
36 } icmpt;
37
38 struct {
39 __le16 dport;
40 __le16 sport;
41 } dnports;
42
43 __be32 spi;
44 __be32 gre_key;
45
46 struct {
47 __u8 type;
48 } mht;
49};
50
51struct flowi4 {
52 struct flowi_common __fl_common;
53#define flowi4_oif __fl_common.flowic_oif
54#define flowi4_iif __fl_common.flowic_iif
55#define flowi4_mark __fl_common.flowic_mark
56#define flowi4_tos __fl_common.flowic_tos
57#define flowi4_scope __fl_common.flowic_scope
58#define flowi4_proto __fl_common.flowic_proto
59#define flowi4_flags __fl_common.flowic_flags
60#define flowi4_secid __fl_common.flowic_secid
61 __be32 daddr;
62 __be32 saddr;
63 union flowi_uli uli;
64#define fl4_sport uli.ports.sport
65#define fl4_dport uli.ports.dport
66#define fl4_icmp_type uli.icmpt.type
67#define fl4_icmp_code uli.icmpt.code
68#define fl4_ipsec_spi uli.spi
69#define fl4_mh_type uli.mht.type
70#define fl4_gre_key uli.gre_key
71};
72
73static inline void flowi4_init_output(struct flowi4 *fl4, int oif,
74 __u32 mark, __u8 tos, __u8 scope,
75 __u8 proto, __u8 flags,
76 __be32 daddr, __be32 saddr,
77 __be16 dport, __be32 sport)
78{
79 fl4->flowi4_oif = oif;
80 fl4->flowi4_iif = 0;
81 fl4->flowi4_mark = mark;
82 fl4->flowi4_tos = tos;
83 fl4->flowi4_scope = scope;
84 fl4->flowi4_proto = proto;
85 fl4->flowi4_flags = flags;
86 fl4->flowi4_secid = 0;
87 fl4->daddr = daddr;
88 fl4->saddr = saddr;
89 fl4->fl4_dport = dport;
90 fl4->fl4_sport = sport;
91}
92
93
94struct flowi6 {
95 struct flowi_common __fl_common;
96#define flowi6_oif __fl_common.flowic_oif
97#define flowi6_iif __fl_common.flowic_iif
98#define flowi6_mark __fl_common.flowic_mark
99#define flowi6_tos __fl_common.flowic_tos
100#define flowi6_scope __fl_common.flowic_scope
101#define flowi6_proto __fl_common.flowic_proto
102#define flowi6_flags __fl_common.flowic_flags
103#define flowi6_secid __fl_common.flowic_secid
104 struct in6_addr daddr;
105 struct in6_addr saddr;
106 __be32 flowlabel;
107 union flowi_uli uli;
108#define fl6_sport uli.ports.sport
109#define fl6_dport uli.ports.dport
110#define fl6_icmp_type uli.icmpt.type
111#define fl6_icmp_code uli.icmpt.code
112#define fl6_ipsec_spi uli.spi
113#define fl6_mh_type uli.mht.type
114#define fl6_gre_key uli.gre_key
115};
116
117struct flowidn {
118 struct flowi_common __fl_common;
119#define flowidn_oif __fl_common.flowic_oif
120#define flowidn_iif __fl_common.flowic_iif
121#define flowidn_mark __fl_common.flowic_mark
122#define flowidn_scope __fl_common.flowic_scope
123#define flowidn_proto __fl_common.flowic_proto
124#define flowidn_flags __fl_common.flowic_flags
125 __le16 daddr;
126 __le16 saddr;
127 union flowi_uli uli;
128#define fld_sport uli.ports.sport
129#define fld_dport uli.ports.dport
130};
131
132struct flowi {
18 union { 133 union {
19 struct { 134 struct flowi_common __fl_common;
20 __be32 daddr; 135 struct flowi4 ip4;
21 __be32 saddr; 136 struct flowi6 ip6;
22 __u8 tos; 137 struct flowidn dn;
23 __u8 scope; 138 } u;
24 } ip4_u; 139#define flowi_oif u.__fl_common.flowic_oif
25 140#define flowi_iif u.__fl_common.flowic_iif
26 struct { 141#define flowi_mark u.__fl_common.flowic_mark
27 struct in6_addr daddr; 142#define flowi_tos u.__fl_common.flowic_tos
28 struct in6_addr saddr; 143#define flowi_scope u.__fl_common.flowic_scope
29 __be32 flowlabel; 144#define flowi_proto u.__fl_common.flowic_proto
30 } ip6_u; 145#define flowi_flags u.__fl_common.flowic_flags
31 146#define flowi_secid u.__fl_common.flowic_secid
32 struct {
33 __le16 daddr;
34 __le16 saddr;
35 __u8 scope;
36 } dn_u;
37 } nl_u;
38#define fld_dst nl_u.dn_u.daddr
39#define fld_src nl_u.dn_u.saddr
40#define fld_scope nl_u.dn_u.scope
41#define fl6_dst nl_u.ip6_u.daddr
42#define fl6_src nl_u.ip6_u.saddr
43#define fl6_flowlabel nl_u.ip6_u.flowlabel
44#define fl4_dst nl_u.ip4_u.daddr
45#define fl4_src nl_u.ip4_u.saddr
46#define fl4_tos nl_u.ip4_u.tos
47#define fl4_scope nl_u.ip4_u.scope
48
49 __u8 proto;
50 __u8 flags;
51#define FLOWI_FLAG_ANYSRC 0x01
52 union {
53 struct {
54 __be16 sport;
55 __be16 dport;
56 } ports;
57
58 struct {
59 __u8 type;
60 __u8 code;
61 } icmpt;
62
63 struct {
64 __le16 sport;
65 __le16 dport;
66 } dnports;
67
68 __be32 spi;
69
70 struct {
71 __u8 type;
72 } mht;
73 } uli_u;
74#define fl_ip_sport uli_u.ports.sport
75#define fl_ip_dport uli_u.ports.dport
76#define fl_icmp_type uli_u.icmpt.type
77#define fl_icmp_code uli_u.icmpt.code
78#define fl_ipsec_spi uli_u.spi
79#define fl_mh_type uli_u.mht.type
80 __u32 secid; /* used by xfrm; see secid.txt */
81} __attribute__((__aligned__(BITS_PER_LONG/8))); 147} __attribute__((__aligned__(BITS_PER_LONG/8)));
82 148
149static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4)
150{
151 return container_of(fl4, struct flowi, u.ip4);
152}
153
154static inline struct flowi *flowi6_to_flowi(struct flowi6 *fl6)
155{
156 return container_of(fl6, struct flowi, u.ip6);
157}
158
159static inline struct flowi *flowidn_to_flowi(struct flowidn *fldn)
160{
161 return container_of(fldn, struct flowi, u.dn);
162}
163
83#define FLOW_DIR_IN 0 164#define FLOW_DIR_IN 0
84#define FLOW_DIR_OUT 1 165#define FLOW_DIR_OUT 1
85#define FLOW_DIR_FWD 2 166#define FLOW_DIR_FWD 2
@@ -99,20 +180,14 @@ struct flow_cache_ops {
99}; 180};
100 181
101typedef struct flow_cache_object *(*flow_resolve_t)( 182typedef struct flow_cache_object *(*flow_resolve_t)(
102 struct net *net, struct flowi *key, u16 family, 183 struct net *net, const struct flowi *key, u16 family,
103 u8 dir, struct flow_cache_object *oldobj, void *ctx); 184 u8 dir, struct flow_cache_object *oldobj, void *ctx);
104 185
105extern struct flow_cache_object *flow_cache_lookup( 186extern struct flow_cache_object *flow_cache_lookup(
106 struct net *net, struct flowi *key, u16 family, 187 struct net *net, const struct flowi *key, u16 family,
107 u8 dir, flow_resolve_t resolver, void *ctx); 188 u8 dir, flow_resolve_t resolver, void *ctx);
108 189
109extern void flow_cache_flush(void); 190extern void flow_cache_flush(void);
110extern atomic_t flow_cache_genid; 191extern atomic_t flow_cache_genid;
111 192
112static inline int flow_cache_uli_match(struct flowi *fl1, struct flowi *fl2)
113{
114 return (fl1->proto == fl2->proto &&
115 !memcmp(&fl1->uli_u, &fl2->uli_u, sizeof(fl1->uli_u)));
116}
117
118#endif 193#endif
diff --git a/include/net/garp.h b/include/net/garp.h
index 825f172caba9..834d8add9e5f 100644
--- a/include/net/garp.h
+++ b/include/net/garp.h
@@ -104,10 +104,12 @@ struct garp_applicant {
104 struct sk_buff_head queue; 104 struct sk_buff_head queue;
105 struct sk_buff *pdu; 105 struct sk_buff *pdu;
106 struct rb_root gid; 106 struct rb_root gid;
107 struct rcu_head rcu;
107}; 108};
108 109
109struct garp_port { 110struct garp_port {
110 struct garp_applicant *applicants[GARP_APPLICATION_MAX + 1]; 111 struct garp_applicant __rcu *applicants[GARP_APPLICATION_MAX + 1];
112 struct rcu_head rcu;
111}; 113};
112 114
113extern int garp_register_application(struct garp_application *app); 115extern int garp_register_application(struct garp_application *app);
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h
index fa157712e982..a79b6cfb02a8 100644
--- a/include/net/gen_stats.h
+++ b/include/net/gen_stats.h
@@ -11,7 +11,7 @@ struct gnet_dump {
11 struct sk_buff * skb; 11 struct sk_buff * skb;
12 struct nlattr * tail; 12 struct nlattr * tail;
13 13
14 /* Backward compatability */ 14 /* Backward compatibility */
15 int compat_tc_stats; 15 int compat_tc_stats;
16 int compat_xstats; 16 int compat_xstats;
17 void * xstats; 17 void * xstats;
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index f7dcd2c70412..d420f28b6d60 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -20,6 +20,9 @@ struct genl_multicast_group {
20 u32 id; 20 u32 id;
21}; 21};
22 22
23struct genl_ops;
24struct genl_info;
25
23/** 26/**
24 * struct genl_family - generic netlink family 27 * struct genl_family - generic netlink family
25 * @id: protocol family idenfitier 28 * @id: protocol family idenfitier
@@ -29,6 +32,10 @@ struct genl_multicast_group {
29 * @maxattr: maximum number of attributes supported 32 * @maxattr: maximum number of attributes supported
30 * @netnsok: set to true if the family can handle network 33 * @netnsok: set to true if the family can handle network
31 * namespaces and should be presented in all of them 34 * namespaces and should be presented in all of them
35 * @pre_doit: called before an operation's doit callback, it may
36 * do additional, common, filtering and return an error
37 * @post_doit: called after an operation's doit callback, it may
38 * undo operations done by pre_doit, for example release locks
32 * @attrbuf: buffer to store parsed attributes 39 * @attrbuf: buffer to store parsed attributes
33 * @ops_list: list of all assigned operations 40 * @ops_list: list of all assigned operations
34 * @family_list: family list 41 * @family_list: family list
@@ -41,6 +48,12 @@ struct genl_family {
41 unsigned int version; 48 unsigned int version;
42 unsigned int maxattr; 49 unsigned int maxattr;
43 bool netnsok; 50 bool netnsok;
51 int (*pre_doit)(struct genl_ops *ops,
52 struct sk_buff *skb,
53 struct genl_info *info);
54 void (*post_doit)(struct genl_ops *ops,
55 struct sk_buff *skb,
56 struct genl_info *info);
44 struct nlattr ** attrbuf; /* private */ 57 struct nlattr ** attrbuf; /* private */
45 struct list_head ops_list; /* private */ 58 struct list_head ops_list; /* private */
46 struct list_head family_list; /* private */ 59 struct list_head family_list; /* private */
@@ -55,6 +68,8 @@ struct genl_family {
55 * @genlhdr: generic netlink message header 68 * @genlhdr: generic netlink message header
56 * @userhdr: user specific header 69 * @userhdr: user specific header
57 * @attrs: netlink attributes 70 * @attrs: netlink attributes
71 * @_net: network namespace
72 * @user_ptr: user pointers
58 */ 73 */
59struct genl_info { 74struct genl_info {
60 u32 snd_seq; 75 u32 snd_seq;
@@ -66,6 +81,7 @@ struct genl_info {
66#ifdef CONFIG_NET_NS 81#ifdef CONFIG_NET_NS
67 struct net * _net; 82 struct net * _net;
68#endif 83#endif
84 void * user_ptr[2];
69}; 85};
70 86
71static inline struct net *genl_info_net(struct genl_info *info) 87static inline struct net *genl_info_net(struct genl_info *info)
@@ -81,6 +97,7 @@ static inline void genl_info_net_set(struct genl_info *info, struct net *net)
81/** 97/**
82 * struct genl_ops - generic netlink operations 98 * struct genl_ops - generic netlink operations
83 * @cmd: command identifier 99 * @cmd: command identifier
100 * @internal_flags: flags used by the family
84 * @flags: flags 101 * @flags: flags
85 * @policy: attribute validation policy 102 * @policy: attribute validation policy
86 * @doit: standard command callback 103 * @doit: standard command callback
@@ -90,6 +107,7 @@ static inline void genl_info_net_set(struct genl_info *info, struct net *net)
90 */ 107 */
91struct genl_ops { 108struct genl_ops {
92 u8 cmd; 109 u8 cmd;
110 u8 internal_flags;
93 unsigned int flags; 111 unsigned int flags;
94 const struct nla_policy *policy; 112 const struct nla_policy *policy;
95 int (*doit)(struct sk_buff *skb, 113 int (*doit)(struct sk_buff *skb,
@@ -177,7 +195,8 @@ static inline int genlmsg_end(struct sk_buff *skb, void *hdr)
177 */ 195 */
178static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) 196static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr)
179{ 197{
180 nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); 198 if (hdr)
199 nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN);
181} 200}
182 201
183/** 202/**
@@ -241,7 +260,7 @@ static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
241 260
242/** 261/**
243 * gennlmsg_data - head of message payload 262 * gennlmsg_data - head of message payload
244 * @gnlh: genetlink messsage header 263 * @gnlh: genetlink message header
245 */ 264 */
246static inline void *genlmsg_data(const struct genlmsghdr *gnlh) 265static inline void *genlmsg_data(const struct genlmsghdr *gnlh)
247{ 266{
diff --git a/include/net/gre.h b/include/net/gre.h
new file mode 100644
index 000000000000..82665474bcb7
--- /dev/null
+++ b/include/net/gre.h
@@ -0,0 +1,18 @@
1#ifndef __LINUX_GRE_H
2#define __LINUX_GRE_H
3
4#include <linux/skbuff.h>
5
6#define GREPROTO_CISCO 0
7#define GREPROTO_PPTP 1
8#define GREPROTO_MAX 2
9
10struct gre_protocol {
11 int (*handler)(struct sk_buff *skb);
12 void (*err_handler)(struct sk_buff *skb, u32 info);
13};
14
15int gre_add_protocol(const struct gre_protocol *proto, u8 version);
16int gre_del_protocol(const struct gre_protocol *proto, u8 version);
17
18#endif
diff --git a/include/net/icmp.h b/include/net/icmp.h
index 6e991e0d0d6f..f0698b955b73 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -45,7 +45,4 @@ extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg);
45extern int icmp_init(void); 45extern int icmp_init(void);
46extern void icmp_out_count(struct net *net, unsigned char type); 46extern void icmp_out_count(struct net *net, unsigned char type);
47 47
48/* Move into dst.h ? */
49extern int xrlim_allow(struct dst_entry *dst, int timeout);
50
51#endif /* _ICMP_H */ 48#endif /* _ICMP_H */
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index af49f8ab7f81..b0be5fb9de19 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -178,6 +178,11 @@ struct ieee80211_radiotap_header {
178 * 178 *
179 * Number of unicast retries a transmitted frame used. 179 * Number of unicast retries a transmitted frame used.
180 * 180 *
181 * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless
182 *
183 * Contains a bitmap of known fields/flags, the flags, and
184 * the MCS index.
185 *
181 */ 186 */
182enum ieee80211_radiotap_type { 187enum ieee80211_radiotap_type {
183 IEEE80211_RADIOTAP_TSFT = 0, 188 IEEE80211_RADIOTAP_TSFT = 0,
@@ -199,6 +204,8 @@ enum ieee80211_radiotap_type {
199 IEEE80211_RADIOTAP_RTS_RETRIES = 16, 204 IEEE80211_RADIOTAP_RTS_RETRIES = 16,
200 IEEE80211_RADIOTAP_DATA_RETRIES = 17, 205 IEEE80211_RADIOTAP_DATA_RETRIES = 17,
201 206
207 IEEE80211_RADIOTAP_MCS = 19,
208
202 /* valid in every it_present bitmap, even vendor namespaces */ 209 /* valid in every it_present bitmap, even vendor namespaces */
203 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, 210 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
204 IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, 211 IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
@@ -245,6 +252,24 @@ enum ieee80211_radiotap_type {
245#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ 252#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
246#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ 253#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
247 254
255
256/* For IEEE80211_RADIOTAP_MCS */
257#define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01
258#define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02
259#define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04
260#define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08
261#define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10
262
263#define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03
264#define IEEE80211_RADIOTAP_MCS_BW_20 0
265#define IEEE80211_RADIOTAP_MCS_BW_40 1
266#define IEEE80211_RADIOTAP_MCS_BW_20L 2
267#define IEEE80211_RADIOTAP_MCS_BW_20U 3
268#define IEEE80211_RADIOTAP_MCS_SGI 0x04
269#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08
270#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
271
272
248/* Ugly macro to convert literal channel numbers into their mhz equivalents 273/* Ugly macro to convert literal channel numbers into their mhz equivalents
249 * There are certianly some conditions that will break this (like feeding it '30') 274 * There are certianly some conditions that will break this (like feeding it '30')
250 * but they shouldn't arise since nothing talks on channel 30. */ 275 * but they shouldn't arise since nothing talks on channel 30. */
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index f95ff8d9aa47..11cf373970a9 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -30,8 +30,6 @@
30#define IF_PREFIX_ONLINK 0x01 30#define IF_PREFIX_ONLINK 0x01
31#define IF_PREFIX_AUTOCONF 0x02 31#define IF_PREFIX_AUTOCONF 0x02
32 32
33#ifdef __KERNEL__
34
35enum { 33enum {
36 INET6_IFADDR_STATE_DAD, 34 INET6_IFADDR_STATE_DAD,
37 INET6_IFADDR_STATE_POSTDAD, 35 INET6_IFADDR_STATE_POSTDAD,
@@ -89,10 +87,11 @@ struct ip6_sf_socklist {
89struct ipv6_mc_socklist { 87struct ipv6_mc_socklist {
90 struct in6_addr addr; 88 struct in6_addr addr;
91 int ifindex; 89 int ifindex;
92 struct ipv6_mc_socklist *next; 90 struct ipv6_mc_socklist __rcu *next;
93 rwlock_t sflock; 91 rwlock_t sflock;
94 unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */ 92 unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */
95 struct ip6_sf_socklist *sflist; 93 struct ip6_sf_socklist *sflist;
94 struct rcu_head rcu;
96}; 95};
97 96
98struct ip6_sf_list { 97struct ip6_sf_list {
@@ -155,8 +154,8 @@ struct ifacaddr6 {
155struct ipv6_devstat { 154struct ipv6_devstat {
156 struct proc_dir_entry *proc_dir_entry; 155 struct proc_dir_entry *proc_dir_entry;
157 DEFINE_SNMP_STAT(struct ipstats_mib, ipv6); 156 DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
158 DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6); 157 DEFINE_SNMP_STAT_ATOMIC(struct icmpv6_mib_device, icmpv6dev);
159 DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg); 158 DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib_device, icmpv6msgdev);
160}; 159};
161 160
162struct inet6_dev { 161struct inet6_dev {
@@ -195,7 +194,7 @@ struct inet6_dev {
195 struct rcu_head rcu; 194 struct rcu_head rcu;
196}; 195};
197 196
198static inline void ipv6_eth_mc_map(struct in6_addr *addr, char *buf) 197static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf)
199{ 198{
200 /* 199 /*
201 * +-------+-------+-------+-------+-------+-------+ 200 * +-------+-------+-------+-------+-------+-------+
@@ -209,7 +208,7 @@ static inline void ipv6_eth_mc_map(struct in6_addr *addr, char *buf)
209 memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32)); 208 memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
210} 209}
211 210
212static inline void ipv6_tr_mc_map(struct in6_addr *addr, char *buf) 211static inline void ipv6_tr_mc_map(const struct in6_addr *addr, char *buf)
213{ 212{
214 /* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */ 213 /* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */
215 214
@@ -285,5 +284,20 @@ static inline void ipv6_ib_mc_map(const struct in6_addr *addr,
285 buf[9] = broadcast[9]; 284 buf[9] = broadcast[9];
286 memcpy(buf + 10, addr->s6_addr + 6, 10); 285 memcpy(buf + 10, addr->s6_addr + 6, 10);
287} 286}
288#endif 287
288static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr,
289 const unsigned char *broadcast, char *buf)
290{
291 if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) {
292 memcpy(buf, broadcast, 4);
293 } else {
294 /* v4mapped? */
295 if ((addr->s6_addr32[0] | addr->s6_addr32[1] |
296 (addr->s6_addr32[2] ^ htonl(0x0000ffff))) != 0)
297 return -EINVAL;
298 memcpy(buf, &addr->s6_addr32[3], 4);
299 }
300 return 0;
301}
302
289#endif 303#endif
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h
index aae08f686633..3207e58ee019 100644
--- a/include/net/inet6_connection_sock.h
+++ b/include/net/inet6_connection_sock.h
@@ -25,6 +25,9 @@ struct sockaddr;
25extern int inet6_csk_bind_conflict(const struct sock *sk, 25extern int inet6_csk_bind_conflict(const struct sock *sk,
26 const struct inet_bind_bucket *tb); 26 const struct inet_bind_bucket *tb);
27 27
28extern struct dst_entry* inet6_csk_route_req(struct sock *sk,
29 const struct request_sock *req);
30
28extern struct request_sock *inet6_csk_search_req(const struct sock *sk, 31extern struct request_sock *inet6_csk_search_req(const struct sock *sk,
29 struct request_sock ***prevp, 32 struct request_sock ***prevp,
30 const __be16 rport, 33 const __be16 rport,
@@ -38,5 +41,5 @@ extern void inet6_csk_reqsk_queue_hash_add(struct sock *sk,
38 41
39extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); 42extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
40 43
41extern int inet6_csk_xmit(struct sk_buff *skb); 44extern int inet6_csk_xmit(struct sk_buff *skb, struct flowi *fl);
42#endif /* _INET6_CONNECTION_SOCK_H */ 45#endif /* _INET6_CONNECTION_SOCK_H */
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index b6d3b55da19b..e6db62e756dc 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -36,14 +36,14 @@ struct tcp_congestion_ops;
36 * (i.e. things that depend on the address family) 36 * (i.e. things that depend on the address family)
37 */ 37 */
38struct inet_connection_sock_af_ops { 38struct inet_connection_sock_af_ops {
39 int (*queue_xmit)(struct sk_buff *skb); 39 int (*queue_xmit)(struct sk_buff *skb, struct flowi *fl);
40 void (*send_check)(struct sock *sk, struct sk_buff *skb); 40 void (*send_check)(struct sock *sk, struct sk_buff *skb);
41 int (*rebuild_header)(struct sock *sk); 41 int (*rebuild_header)(struct sock *sk);
42 int (*conn_request)(struct sock *sk, struct sk_buff *skb); 42 int (*conn_request)(struct sock *sk, struct sk_buff *skb);
43 struct sock *(*syn_recv_sock)(struct sock *sk, struct sk_buff *skb, 43 struct sock *(*syn_recv_sock)(struct sock *sk, struct sk_buff *skb,
44 struct request_sock *req, 44 struct request_sock *req,
45 struct dst_entry *dst); 45 struct dst_entry *dst);
46 int (*remember_stamp)(struct sock *sk); 46 struct inet_peer *(*get_peer)(struct sock *sk, bool *release_it);
47 u16 net_header_len; 47 u16 net_header_len;
48 u16 sockaddr_len; 48 u16 sockaddr_len;
49 int (*setsockopt)(struct sock *sk, int level, int optname, 49 int (*setsockopt)(struct sock *sk, int level, int optname,
@@ -125,13 +125,13 @@ struct inet_connection_sock {
125 int probe_size; 125 int probe_size;
126 } icsk_mtup; 126 } icsk_mtup;
127 u32 icsk_ca_priv[16]; 127 u32 icsk_ca_priv[16];
128 u32 icsk_user_timeout;
128#define ICSK_CA_PRIV_SIZE (16 * sizeof(u32)) 129#define ICSK_CA_PRIV_SIZE (16 * sizeof(u32))
129}; 130};
130 131
131#define ICSK_TIME_RETRANS 1 /* Retransmit timer */ 132#define ICSK_TIME_RETRANS 1 /* Retransmit timer */
132#define ICSK_TIME_DACK 2 /* Delayed ack timer */ 133#define ICSK_TIME_DACK 2 /* Delayed ack timer */
133#define ICSK_TIME_PROBE0 3 /* Zero window probe timer */ 134#define ICSK_TIME_PROBE0 3 /* Zero window probe timer */
134#define ICSK_TIME_KEEPOPEN 4 /* Keepalive timer */
135 135
136static inline struct inet_connection_sock *inet_csk(const struct sock *sk) 136static inline struct inet_connection_sock *inet_csk(const struct sock *sk)
137{ 137{
@@ -249,7 +249,11 @@ extern int inet_csk_bind_conflict(const struct sock *sk,
249extern int inet_csk_get_port(struct sock *sk, unsigned short snum); 249extern int inet_csk_get_port(struct sock *sk, unsigned short snum);
250 250
251extern struct dst_entry* inet_csk_route_req(struct sock *sk, 251extern struct dst_entry* inet_csk_route_req(struct sock *sk,
252 struct flowi4 *fl4,
252 const struct request_sock *req); 253 const struct request_sock *req);
254extern struct dst_entry* inet_csk_route_child_sock(struct sock *sk,
255 struct sock *newsk,
256 const struct request_sock *req);
253 257
254static inline void inet_csk_reqsk_queue_add(struct sock *sk, 258static inline void inet_csk_reqsk_queue_add(struct sock *sk,
255 struct request_sock *req, 259 struct request_sock *req,
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index 9b5d08f4f6e8..2fa8d1341a0a 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -27,7 +27,7 @@ static inline int INET_ECN_is_not_ect(__u8 dsfield)
27 27
28static inline int INET_ECN_is_capable(__u8 dsfield) 28static inline int INET_ECN_is_capable(__u8 dsfield)
29{ 29{
30 return (dsfield & INET_ECN_ECT_0); 30 return dsfield & INET_ECN_ECT_0;
31} 31}
32 32
33static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) 33static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
@@ -38,9 +38,19 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
38 return outer; 38 return outer;
39} 39}
40 40
41#define INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0) 41static inline void INET_ECN_xmit(struct sock *sk)
42#define INET_ECN_dontxmit(sk) \ 42{
43 do { inet_sk(sk)->tos &= ~INET_ECN_MASK; } while (0) 43 inet_sk(sk)->tos |= INET_ECN_ECT_0;
44 if (inet6_sk(sk) != NULL)
45 inet6_sk(sk)->tclass |= INET_ECN_ECT_0;
46}
47
48static inline void INET_ECN_dontxmit(struct sock *sk)
49{
50 inet_sk(sk)->tos &= ~INET_ECN_MASK;
51 if (inet6_sk(sk) != NULL)
52 inet6_sk(sk)->tclass &= ~INET_ECN_MASK;
53}
44 54
45#define IP6_ECN_flow_init(label) do { \ 55#define IP6_ECN_flow_init(label) do { \
46 (label) &= ~htonl(INET_ECN_MASK << 20); \ 56 (label) &= ~htonl(INET_ECN_MASK << 20); \
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 74358d1b3f43..e9c2ed8af864 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -245,7 +245,7 @@ static inline int inet_sk_listen_hashfn(const struct sock *sk)
245} 245}
246 246
247/* Caller must disable local BH processing. */ 247/* Caller must disable local BH processing. */
248extern void __inet_inherit_port(struct sock *sk, struct sock *child); 248extern int __inet_inherit_port(struct sock *sk, struct sock *child);
249 249
250extern void inet_put_port(struct sock *sk); 250extern void inet_put_port(struct sock *sk);
251 251
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 1989cfd7405f..caaff5f5f39f 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -57,7 +57,15 @@ struct ip_options {
57 unsigned char __data[0]; 57 unsigned char __data[0];
58}; 58};
59 59
60#define optlength(opt) (sizeof(struct ip_options) + opt->optlen) 60struct ip_options_rcu {
61 struct rcu_head rcu;
62 struct ip_options opt;
63};
64
65struct ip_options_data {
66 struct ip_options_rcu opt;
67 char data[40];
68};
61 69
62struct inet_request_sock { 70struct inet_request_sock {
63 struct request_sock req; 71 struct request_sock req;
@@ -78,7 +86,7 @@ struct inet_request_sock {
78 acked : 1, 86 acked : 1,
79 no_srccheck: 1; 87 no_srccheck: 1;
80 kmemcheck_bitfield_end(flags); 88 kmemcheck_bitfield_end(flags);
81 struct ip_options *opt; 89 struct ip_options_rcu *opt;
82}; 90};
83 91
84static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) 92static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
@@ -86,6 +94,23 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
86 return (struct inet_request_sock *)sk; 94 return (struct inet_request_sock *)sk;
87} 95}
88 96
97struct inet_cork {
98 unsigned int flags;
99 __be32 addr;
100 struct ip_options *opt;
101 unsigned int fragsize;
102 struct dst_entry *dst;
103 int length; /* Total length of all frames */
104 struct page *page;
105 u32 off;
106 u8 tx_flags;
107};
108
109struct inet_cork_full {
110 struct inet_cork base;
111 struct flowi fl;
112};
113
89struct ip_mc_socklist; 114struct ip_mc_socklist;
90struct ipv6_pinfo; 115struct ipv6_pinfo;
91struct rtable; 116struct rtable;
@@ -116,8 +141,9 @@ struct inet_sock {
116 struct ipv6_pinfo *pinet6; 141 struct ipv6_pinfo *pinet6;
117#endif 142#endif
118 /* Socket demultiplex comparisons on incoming packets. */ 143 /* Socket demultiplex comparisons on incoming packets. */
119 __be32 inet_daddr; 144#define inet_daddr sk.__sk_common.skc_daddr
120 __be32 inet_rcv_saddr; 145#define inet_rcv_saddr sk.__sk_common.skc_rcv_saddr
146
121 __be16 inet_dport; 147 __be16 inet_dport;
122 __u16 inet_num; 148 __u16 inet_num;
123 __be32 inet_saddr; 149 __be32 inet_saddr;
@@ -126,7 +152,7 @@ struct inet_sock {
126 __be16 inet_sport; 152 __be16 inet_sport;
127 __u16 inet_id; 153 __u16 inet_id;
128 154
129 struct ip_options *opt; 155 struct ip_options_rcu __rcu *inet_opt;
130 __u8 tos; 156 __u8 tos;
131 __u8 min_ttl; 157 __u8 min_ttl;
132 __u8 mc_ttl; 158 __u8 mc_ttl;
@@ -141,16 +167,8 @@ struct inet_sock {
141 nodefrag:1; 167 nodefrag:1;
142 int mc_index; 168 int mc_index;
143 __be32 mc_addr; 169 __be32 mc_addr;
144 struct ip_mc_socklist *mc_list; 170 struct ip_mc_socklist __rcu *mc_list;
145 struct { 171 struct inet_cork_full cork;
146 unsigned int flags;
147 unsigned int fragsize;
148 struct ip_options *opt;
149 struct dst_entry *dst;
150 int length; /* Total length of all frames */
151 __be32 addr;
152 struct flowi fl;
153 } cork;
154}; 172};
155 173
156#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */ 174#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */
@@ -218,7 +236,13 @@ static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops
218 236
219static inline __u8 inet_sk_flowi_flags(const struct sock *sk) 237static inline __u8 inet_sk_flowi_flags(const struct sock *sk)
220{ 238{
221 return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0; 239 __u8 flags = 0;
240
241 if (inet_sk(sk)->transparent)
242 flags |= FLOWI_FLAG_ANYSRC;
243 if (sk->sk_protocol == IPPROTO_TCP)
244 flags |= FLOWI_FLAG_PRECOW_METRICS;
245 return flags;
222} 246}
223 247
224#endif /* _INET_SOCK_H */ 248#endif /* _INET_SOCK_H */
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index a066fdd50da6..17404b5388a7 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -88,12 +88,6 @@ extern void inet_twdr_hangman(unsigned long data);
88extern void inet_twdr_twkill_work(struct work_struct *work); 88extern void inet_twdr_twkill_work(struct work_struct *work);
89extern void inet_twdr_twcal_tick(unsigned long data); 89extern void inet_twdr_twcal_tick(unsigned long data);
90 90
91#if (BITS_PER_LONG == 64)
92#define INET_TIMEWAIT_ADDRCMP_ALIGN_BYTES 8
93#else
94#define INET_TIMEWAIT_ADDRCMP_ALIGN_BYTES 4
95#endif
96
97struct inet_bind_bucket; 91struct inet_bind_bucket;
98 92
99/* 93/*
@@ -117,15 +111,15 @@ struct inet_timewait_sock {
117#define tw_hash __tw_common.skc_hash 111#define tw_hash __tw_common.skc_hash
118#define tw_prot __tw_common.skc_prot 112#define tw_prot __tw_common.skc_prot
119#define tw_net __tw_common.skc_net 113#define tw_net __tw_common.skc_net
114#define tw_daddr __tw_common.skc_daddr
115#define tw_rcv_saddr __tw_common.skc_rcv_saddr
120 int tw_timeout; 116 int tw_timeout;
121 volatile unsigned char tw_substate; 117 volatile unsigned char tw_substate;
122 /* 3 bits hole, try to pack */
123 unsigned char tw_rcv_wscale; 118 unsigned char tw_rcv_wscale;
119
124 /* Socket demultiplex comparisons on incoming packets. */ 120 /* Socket demultiplex comparisons on incoming packets. */
125 /* these five are in inet_sock */ 121 /* these three are in inet_sock */
126 __be16 tw_sport; 122 __be16 tw_sport;
127 __be32 tw_daddr __attribute__((aligned(INET_TIMEWAIT_ADDRCMP_ALIGN_BYTES)));
128 __be32 tw_rcv_saddr;
129 __be16 tw_dport; 123 __be16 tw_dport;
130 __u16 tw_num; 124 __u16 tw_num;
131 kmemcheck_bitfield_begin(flags); 125 kmemcheck_bitfield_begin(flags);
@@ -191,10 +185,10 @@ static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk)
191 return (struct inet_timewait_sock *)sk; 185 return (struct inet_timewait_sock *)sk;
192} 186}
193 187
194static inline __be32 inet_rcv_saddr(const struct sock *sk) 188static inline __be32 sk_rcv_saddr(const struct sock *sk)
195{ 189{
196 return likely(sk->sk_state != TCP_TIME_WAIT) ? 190/* both inet_sk() and inet_twsk() store rcv_saddr in skc_rcv_saddr */
197 inet_sk(sk)->inet_rcv_saddr : inet_twsk(sk)->tw_rcv_saddr; 191 return sk->__sk_common.skc_rcv_saddr;
198} 192}
199 193
200extern void inet_twsk_put(struct inet_timewait_sock *tw); 194extern void inet_twsk_put(struct inet_timewait_sock *tw);
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 417d0c894f29..8a159cc3d68b 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -11,12 +11,26 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/jiffies.h> 12#include <linux/jiffies.h>
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/rtnetlink.h>
15#include <net/ipv6.h>
14#include <asm/atomic.h> 16#include <asm/atomic.h>
15 17
18struct inetpeer_addr_base {
19 union {
20 __be32 a4;
21 __be32 a6[4];
22 };
23};
24
25struct inetpeer_addr {
26 struct inetpeer_addr_base addr;
27 __u16 family;
28};
29
16struct inet_peer { 30struct inet_peer {
17 /* group together avl_left,avl_right,v4daddr to speedup lookups */ 31 /* group together avl_left,avl_right,v4daddr to speedup lookups */
18 struct inet_peer *avl_left, *avl_right; 32 struct inet_peer __rcu *avl_left, *avl_right;
19 __be32 v4daddr; /* peer's address */ 33 struct inetpeer_addr daddr;
20 __u32 avl_height; 34 __u32 avl_height;
21 struct list_head unused; 35 struct list_head unused;
22 __u32 dtime; /* the time of last use of not 36 __u32 dtime; /* the time of last use of not
@@ -24,16 +38,22 @@ struct inet_peer {
24 atomic_t refcnt; 38 atomic_t refcnt;
25 /* 39 /*
26 * Once inet_peer is queued for deletion (refcnt == -1), following fields 40 * Once inet_peer is queued for deletion (refcnt == -1), following fields
27 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp 41 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp, metrics
28 * We can share memory with rcu_head to keep inet_peer small 42 * We can share memory with rcu_head to help keep inet_peer small.
29 * (less then 64 bytes)
30 */ 43 */
31 union { 44 union {
32 struct { 45 struct {
33 atomic_t rid; /* Frag reception counter */ 46 atomic_t rid; /* Frag reception counter */
34 atomic_t ip_id_count; /* IP ID for the next packet */ 47 atomic_t ip_id_count; /* IP ID for the next packet */
35 __u32 tcp_ts; 48 __u32 tcp_ts;
36 __u32 tcp_ts_stamp; 49 __u32 tcp_ts_stamp;
50 u32 metrics[RTAX_MAX];
51 u32 rate_tokens; /* rate limiting for ICMP */
52 unsigned long rate_last;
53 unsigned long pmtu_expires;
54 u32 pmtu_orig;
55 u32 pmtu_learned;
56 struct inetpeer_addr_base redirect_learned;
37 }; 57 };
38 struct rcu_head rcu; 58 struct rcu_head rcu;
39 }; 59 };
@@ -41,11 +61,37 @@ struct inet_peer {
41 61
42void inet_initpeers(void) __init; 62void inet_initpeers(void) __init;
43 63
64#define INETPEER_METRICS_NEW (~(u32) 0)
65
66static inline bool inet_metrics_new(const struct inet_peer *p)
67{
68 return p->metrics[RTAX_LOCK-1] == INETPEER_METRICS_NEW;
69}
70
44/* can be called with or without local BH being disabled */ 71/* can be called with or without local BH being disabled */
45struct inet_peer *inet_getpeer(__be32 daddr, int create); 72struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create);
73
74static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create)
75{
76 struct inetpeer_addr daddr;
77
78 daddr.addr.a4 = v4daddr;
79 daddr.family = AF_INET;
80 return inet_getpeer(&daddr, create);
81}
82
83static inline struct inet_peer *inet_getpeer_v6(const struct in6_addr *v6daddr, int create)
84{
85 struct inetpeer_addr daddr;
86
87 ipv6_addr_copy((struct in6_addr *)daddr.addr.a6, v6daddr);
88 daddr.family = AF_INET6;
89 return inet_getpeer(&daddr, create);
90}
46 91
47/* can be called from BH context or outside */ 92/* can be called from BH context or outside */
48extern void inet_putpeer(struct inet_peer *p); 93extern void inet_putpeer(struct inet_peer *p);
94extern bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout);
49 95
50/* 96/*
51 * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, 97 * temporary check to make sure we dont access rid, ip_id_count, tcp_ts,
diff --git a/include/net/ip.h b/include/net/ip.h
index 890f9725d681..66dd49149208 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -52,14 +52,14 @@ static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
52struct ipcm_cookie { 52struct ipcm_cookie {
53 __be32 addr; 53 __be32 addr;
54 int oif; 54 int oif;
55 struct ip_options *opt; 55 struct ip_options_rcu *opt;
56 union skb_shared_tx shtx; 56 __u8 tx_flags;
57}; 57};
58 58
59#define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb)) 59#define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
60 60
61struct ip_ra_chain { 61struct ip_ra_chain {
62 struct ip_ra_chain *next; 62 struct ip_ra_chain __rcu *next;
63 struct sock *sk; 63 struct sock *sk;
64 union { 64 union {
65 void (*destructor)(struct sock *); 65 void (*destructor)(struct sock *);
@@ -68,7 +68,7 @@ struct ip_ra_chain {
68 struct rcu_head rcu; 68 struct rcu_head rcu;
69}; 69};
70 70
71extern struct ip_ra_chain *ip_ra_chain; 71extern struct ip_ra_chain __rcu *ip_ra_chain;
72 72
73/* IP flags. */ 73/* IP flags. */
74#define IP_CE 0x8000 /* Flag: "Congestion" */ 74#define IP_CE 0x8000 /* Flag: "Congestion" */
@@ -92,7 +92,7 @@ extern int igmp_mc_proc_init(void);
92 92
93extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, 93extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
94 __be32 saddr, __be32 daddr, 94 __be32 saddr, __be32 daddr,
95 struct ip_options *opt); 95 struct ip_options_rcu *opt);
96extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, 96extern int ip_rcv(struct sk_buff *skb, struct net_device *dev,
97 struct packet_type *pt, struct net_device *orig_dev); 97 struct packet_type *pt, struct net_device *orig_dev);
98extern int ip_local_deliver(struct sk_buff *skb); 98extern int ip_local_deliver(struct sk_buff *skb);
@@ -104,9 +104,9 @@ extern int ip_do_nat(struct sk_buff *skb);
104extern void ip_send_check(struct iphdr *ip); 104extern void ip_send_check(struct iphdr *ip);
105extern int __ip_local_out(struct sk_buff *skb); 105extern int __ip_local_out(struct sk_buff *skb);
106extern int ip_local_out(struct sk_buff *skb); 106extern int ip_local_out(struct sk_buff *skb);
107extern int ip_queue_xmit(struct sk_buff *skb); 107extern int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl);
108extern void ip_init(void); 108extern void ip_init(void);
109extern int ip_append_data(struct sock *sk, 109extern int ip_append_data(struct sock *sk, struct flowi4 *fl4,
110 int getfrag(void *from, char *to, int offset, int len, 110 int getfrag(void *from, char *to, int offset, int len,
111 int odd, struct sk_buff *skb), 111 int odd, struct sk_buff *skb),
112 void *from, int len, int protolen, 112 void *from, int len, int protolen,
@@ -114,10 +114,28 @@ extern int ip_append_data(struct sock *sk,
114 struct rtable **rt, 114 struct rtable **rt,
115 unsigned int flags); 115 unsigned int flags);
116extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb); 116extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb);
117extern ssize_t ip_append_page(struct sock *sk, struct page *page, 117extern ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
118 int offset, size_t size, int flags); 118 int offset, size_t size, int flags);
119extern int ip_push_pending_frames(struct sock *sk); 119extern struct sk_buff *__ip_make_skb(struct sock *sk,
120 struct flowi4 *fl4,
121 struct sk_buff_head *queue,
122 struct inet_cork *cork);
123extern int ip_send_skb(struct sk_buff *skb);
124extern int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4);
120extern void ip_flush_pending_frames(struct sock *sk); 125extern void ip_flush_pending_frames(struct sock *sk);
126extern struct sk_buff *ip_make_skb(struct sock *sk,
127 struct flowi4 *fl4,
128 int getfrag(void *from, char *to, int offset, int len,
129 int odd, struct sk_buff *skb),
130 void *from, int length, int transhdrlen,
131 struct ipcm_cookie *ipc,
132 struct rtable **rtp,
133 unsigned int flags);
134
135static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4)
136{
137 return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork.base);
138}
121 139
122/* datagram.c */ 140/* datagram.c */
123extern int ip4_datagram_connect(struct sock *sk, 141extern int ip4_datagram_connect(struct sock *sk,
@@ -156,8 +174,8 @@ static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg)
156 return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0; 174 return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0;
157} 175}
158 176
159void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arg, 177void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr,
160 unsigned int len); 178 struct ip_reply_arg *arg, unsigned int len);
161 179
162struct ipv4_config { 180struct ipv4_config {
163 int log_martians; 181 int log_martians;
@@ -201,7 +219,6 @@ static inline int inet_is_reserved_local_port(int port)
201 return test_bit(port, sysctl_local_reserved_ports); 219 return test_bit(port, sysctl_local_reserved_ports);
202} 220}
203 221
204extern int sysctl_ip_default_ttl;
205extern int sysctl_ip_nonlocal_bind; 222extern int sysctl_ip_nonlocal_bind;
206 223
207extern struct ctl_path net_core_path[]; 224extern struct ctl_path net_core_path[];
@@ -238,9 +255,9 @@ int ip_decrease_ttl(struct iphdr *iph)
238static inline 255static inline
239int ip_dont_fragment(struct sock *sk, struct dst_entry *dst) 256int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
240{ 257{
241 return (inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO || 258 return inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO ||
242 (inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT && 259 (inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT &&
243 !(dst_metric_locked(dst, RTAX_MTU)))); 260 !(dst_metric_locked(dst, RTAX_MTU)));
244} 261}
245 262
246extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); 263extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
@@ -324,6 +341,14 @@ static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, ch
324 buf[16] = addr & 0x0f; 341 buf[16] = addr & 0x0f;
325} 342}
326 343
344static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
345{
346 if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0)
347 memcpy(buf, broadcast, 4);
348 else
349 memcpy(buf, &naddr, sizeof(naddr));
350}
351
327#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 352#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
328#include <linux/ipv6.h> 353#include <linux/ipv6.h>
329#endif 354#endif
@@ -393,14 +418,15 @@ extern int ip_forward(struct sk_buff *skb);
393 * Functions provided by ip_options.c 418 * Functions provided by ip_options.c
394 */ 419 */
395 420
396extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, __be32 daddr, struct rtable *rt, int is_frag); 421extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt,
422 __be32 daddr, struct rtable *rt, int is_frag);
397extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); 423extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb);
398extern void ip_options_fragment(struct sk_buff *skb); 424extern void ip_options_fragment(struct sk_buff *skb);
399extern int ip_options_compile(struct net *net, 425extern int ip_options_compile(struct net *net,
400 struct ip_options *opt, struct sk_buff *skb); 426 struct ip_options *opt, struct sk_buff *skb);
401extern int ip_options_get(struct net *net, struct ip_options **optp, 427extern int ip_options_get(struct net *net, struct ip_options_rcu **optp,
402 unsigned char *data, int optlen); 428 unsigned char *data, int optlen);
403extern int ip_options_get_from_user(struct net *net, struct ip_options **optp, 429extern int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp,
404 unsigned char __user *data, int optlen); 430 unsigned char __user *data, int optlen);
405extern void ip_options_undo(struct ip_options * opt); 431extern void ip_options_undo(struct ip_options * opt);
406extern void ip_forward_options(struct sk_buff *skb); 432extern void ip_forward_options(struct sk_buff *skb);
@@ -428,15 +454,6 @@ extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
428extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, 454extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport,
429 u32 info); 455 u32 info);
430 456
431/* sysctl helpers - any sysctl which holds a value that ends up being
432 * fed into the routing cache should use these handlers.
433 */
434int ipv4_doint_and_flush(ctl_table *ctl, int write,
435 void __user *buffer,
436 size_t *lenp, loff_t *ppos);
437int ipv4_doint_and_flush_strategy(ctl_table *table,
438 void __user *oldval, size_t __user *oldlenp,
439 void __user *newval, size_t newlen);
440#ifdef CONFIG_PROC_FS 457#ifdef CONFIG_PROC_FS
441extern int ip_misc_proc_init(void); 458extern int ip_misc_proc_init(void);
442#endif 459#endif
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 062a823d311c..477ef75f3873 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -13,14 +13,13 @@
13#ifndef _IP6_FIB_H 13#ifndef _IP6_FIB_H
14#define _IP6_FIB_H 14#define _IP6_FIB_H
15 15
16#ifdef __KERNEL__
17
18#include <linux/ipv6_route.h> 16#include <linux/ipv6_route.h>
19#include <linux/rtnetlink.h> 17#include <linux/rtnetlink.h>
20#include <linux/spinlock.h> 18#include <linux/spinlock.h>
21#include <net/dst.h> 19#include <net/dst.h>
22#include <net/flow.h> 20#include <net/flow.h>
23#include <net/netlink.h> 21#include <net/netlink.h>
22#include <net/inetpeer.h>
24 23
25#ifdef CONFIG_IPV6_MULTIPLE_TABLES 24#ifdef CONFIG_IPV6_MULTIPLE_TABLES
26#define FIB6_TABLE_HASHSZ 256 25#define FIB6_TABLE_HASHSZ 256
@@ -41,6 +40,7 @@ struct fib6_config {
41 40
42 struct in6_addr fc_dst; 41 struct in6_addr fc_dst;
43 struct in6_addr fc_src; 42 struct in6_addr fc_src;
43 struct in6_addr fc_prefsrc;
44 struct in6_addr fc_gateway; 44 struct in6_addr fc_gateway;
45 45
46 unsigned long fc_expires; 46 unsigned long fc_expires;
@@ -106,9 +106,12 @@ struct rt6_info {
106 struct rt6key rt6i_dst ____cacheline_aligned_in_smp; 106 struct rt6key rt6i_dst ____cacheline_aligned_in_smp;
107 u32 rt6i_flags; 107 u32 rt6i_flags;
108 struct rt6key rt6i_src; 108 struct rt6key rt6i_src;
109 struct rt6key rt6i_prefsrc;
109 u32 rt6i_metric; 110 u32 rt6i_metric;
111 u32 rt6i_peer_genid;
110 112
111 struct inet6_dev *rt6i_idev; 113 struct inet6_dev *rt6i_idev;
114 struct inet_peer *rt6i_peer;
112 115
113#ifdef CONFIG_XFRM 116#ifdef CONFIG_XFRM
114 u32 rt6i_flow_cache_genid; 117 u32 rt6i_flow_cache_genid;
@@ -180,7 +183,7 @@ struct fib6_table {
180 183
181typedef struct rt6_info *(*pol_lookup_t)(struct net *, 184typedef struct rt6_info *(*pol_lookup_t)(struct net *,
182 struct fib6_table *, 185 struct fib6_table *,
183 struct flowi *, int); 186 struct flowi6 *, int);
184 187
185/* 188/*
186 * exported functions 189 * exported functions
@@ -189,16 +192,16 @@ typedef struct rt6_info *(*pol_lookup_t)(struct net *,
189extern struct fib6_table *fib6_get_table(struct net *net, u32 id); 192extern struct fib6_table *fib6_get_table(struct net *net, u32 id);
190extern struct fib6_table *fib6_new_table(struct net *net, u32 id); 193extern struct fib6_table *fib6_new_table(struct net *net, u32 id);
191extern struct dst_entry *fib6_rule_lookup(struct net *net, 194extern struct dst_entry *fib6_rule_lookup(struct net *net,
192 struct flowi *fl, int flags, 195 struct flowi6 *fl6, int flags,
193 pol_lookup_t lookup); 196 pol_lookup_t lookup);
194 197
195extern struct fib6_node *fib6_lookup(struct fib6_node *root, 198extern struct fib6_node *fib6_lookup(struct fib6_node *root,
196 struct in6_addr *daddr, 199 const struct in6_addr *daddr,
197 struct in6_addr *saddr); 200 const struct in6_addr *saddr);
198 201
199struct fib6_node *fib6_locate(struct fib6_node *root, 202struct fib6_node *fib6_locate(struct fib6_node *root,
200 struct in6_addr *daddr, int dst_len, 203 const struct in6_addr *daddr, int dst_len,
201 struct in6_addr *saddr, int src_len); 204 const struct in6_addr *saddr, int src_len);
202 205
203extern void fib6_clean_all(struct net *net, 206extern void fib6_clean_all(struct net *net,
204 int (*func)(struct rt6_info *, void *arg), 207 int (*func)(struct rt6_info *, void *arg),
@@ -235,4 +238,3 @@ static inline void fib6_rules_cleanup(void)
235} 238}
236#endif 239#endif
237#endif 240#endif
238#endif
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 278312c95f96..5e91b72fc718 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -3,7 +3,6 @@
3 3
4#define IP6_RT_PRIO_USER 1024 4#define IP6_RT_PRIO_USER 1024
5#define IP6_RT_PRIO_ADDRCONF 256 5#define IP6_RT_PRIO_ADDRCONF 256
6#define IP6_RT_PRIO_KERN 512
7 6
8struct route_info { 7struct route_info {
9 __u8 type; 8 __u8 type;
@@ -22,8 +21,6 @@ struct route_info {
22 __u8 prefix[0]; /* 0,8 or 16 */ 21 __u8 prefix[0]; /* 0,8 or 16 */
23}; 22};
24 23
25#ifdef __KERNEL__
26
27#include <net/flow.h> 24#include <net/flow.h>
28#include <net/ip6_fib.h> 25#include <net/ip6_fib.h>
29#include <net/sock.h> 26#include <net/sock.h>
@@ -56,11 +53,23 @@ static inline unsigned int rt6_flags2srcprefs(int flags)
56 return (flags >> 3) & 7; 53 return (flags >> 3) & 7;
57} 54}
58 55
56extern void rt6_bind_peer(struct rt6_info *rt,
57 int create);
58
59static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt)
60{
61 if (rt->rt6i_peer)
62 return rt->rt6i_peer;
63
64 rt6_bind_peer(rt, 0);
65 return rt->rt6i_peer;
66}
67
59extern void ip6_route_input(struct sk_buff *skb); 68extern void ip6_route_input(struct sk_buff *skb);
60 69
61extern struct dst_entry * ip6_route_output(struct net *net, 70extern struct dst_entry * ip6_route_output(struct net *net,
62 struct sock *sk, 71 const struct sock *sk,
63 struct flowi *fl); 72 struct flowi6 *fl6);
64 73
65extern int ip6_route_init(void); 74extern int ip6_route_init(void);
66extern void ip6_route_cleanup(void); 75extern void ip6_route_cleanup(void);
@@ -73,6 +82,12 @@ extern int ip6_route_add(struct fib6_config *cfg);
73extern int ip6_ins_rt(struct rt6_info *); 82extern int ip6_ins_rt(struct rt6_info *);
74extern int ip6_del_rt(struct rt6_info *); 83extern int ip6_del_rt(struct rt6_info *);
75 84
85extern int ip6_route_get_saddr(struct net *net,
86 struct rt6_info *rt,
87 const struct in6_addr *daddr,
88 unsigned int prefs,
89 struct in6_addr *saddr);
90
76extern struct rt6_info *rt6_lookup(struct net *net, 91extern struct rt6_info *rt6_lookup(struct net *net,
77 const struct in6_addr *daddr, 92 const struct in6_addr *daddr,
78 const struct in6_addr *saddr, 93 const struct in6_addr *saddr,
@@ -95,9 +110,9 @@ extern int ip6_dst_hoplimit(struct dst_entry *dst);
95 * support functions for ND 110 * support functions for ND
96 * 111 *
97 */ 112 */
98extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr, 113extern struct rt6_info * rt6_get_dflt_router(const struct in6_addr *addr,
99 struct net_device *dev); 114 struct net_device *dev);
100extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr, 115extern struct rt6_info * rt6_add_dflt_router(const struct in6_addr *gwaddr,
101 struct net_device *dev, 116 struct net_device *dev,
102 unsigned int pref); 117 unsigned int pref);
103 118
@@ -105,17 +120,17 @@ extern void rt6_purge_dflt_routers(struct net *net);
105 120
106extern int rt6_route_rcv(struct net_device *dev, 121extern int rt6_route_rcv(struct net_device *dev,
107 u8 *opt, int len, 122 u8 *opt, int len,
108 struct in6_addr *gwaddr); 123 const struct in6_addr *gwaddr);
109 124
110extern void rt6_redirect(struct in6_addr *dest, 125extern void rt6_redirect(const struct in6_addr *dest,
111 struct in6_addr *src, 126 const struct in6_addr *src,
112 struct in6_addr *saddr, 127 const struct in6_addr *saddr,
113 struct neighbour *neigh, 128 struct neighbour *neigh,
114 u8 *lladdr, 129 u8 *lladdr,
115 int on_link); 130 int on_link);
116 131
117extern void rt6_pmtu_discovery(struct in6_addr *daddr, 132extern void rt6_pmtu_discovery(const struct in6_addr *daddr,
118 struct in6_addr *saddr, 133 const struct in6_addr *saddr,
119 struct net_device *dev, 134 struct net_device *dev,
120 u32 pmtu); 135 u32 pmtu);
121 136
@@ -130,6 +145,7 @@ struct rt6_rtnl_dump_arg {
130extern int rt6_dump_route(struct rt6_info *rt, void *p_arg); 145extern int rt6_dump_route(struct rt6_info *rt, void *p_arg);
131extern void rt6_ifdown(struct net *net, struct net_device *dev); 146extern void rt6_ifdown(struct net *net, struct net_device *dev);
132extern void rt6_mtu_change(struct net_device *dev, unsigned mtu); 147extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
148extern void rt6_remove_prefsrc(struct inet6_ifaddr *ifp);
133 149
134 150
135/* 151/*
@@ -164,5 +180,14 @@ static inline int ipv6_unicast_destination(struct sk_buff *skb)
164 return rt->rt6i_flags & RTF_LOCAL; 180 return rt->rt6i_flags & RTF_LOCAL;
165} 181}
166 182
167#endif 183int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
184
185static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
186{
187 struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL;
188
189 return (np && np->pmtudisc == IPV6_PMTUDISC_PROBE) ?
190 skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb));
191}
192
168#endif 193#endif
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index fc94ec568a50..fc73e667b50e 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -13,7 +13,7 @@
13/* IPv6 tunnel */ 13/* IPv6 tunnel */
14 14
15struct ip6_tnl { 15struct ip6_tnl {
16 struct ip6_tnl *next; /* next tunnel in list */ 16 struct ip6_tnl __rcu *next; /* next tunnel in list */
17 struct net_device *dev; /* virtual device associated with tunnel */ 17 struct net_device *dev; /* virtual device associated with tunnel */
18 struct ip6_tnl_parm parms; /* tunnel configuration parameters */ 18 struct ip6_tnl_parm parms; /* tunnel configuration parameters */
19 struct flowi fl; /* flowi template for xmit */ 19 struct flowi fl; /* flowi template for xmit */
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index c93f94edc610..10422ef14e28 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -55,11 +55,13 @@ struct fib_nh {
55 int nh_weight; 55 int nh_weight;
56 int nh_power; 56 int nh_power;
57#endif 57#endif
58#ifdef CONFIG_NET_CLS_ROUTE 58#ifdef CONFIG_IP_ROUTE_CLASSID
59 __u32 nh_tclassid; 59 __u32 nh_tclassid;
60#endif 60#endif
61 int nh_oif; 61 int nh_oif;
62 __be32 nh_gw; 62 __be32 nh_gw;
63 __be32 nh_saddr;
64 int nh_saddr_genid;
63}; 65};
64 66
65/* 67/*
@@ -72,12 +74,13 @@ struct fib_info {
72 struct net *fib_net; 74 struct net *fib_net;
73 int fib_treeref; 75 int fib_treeref;
74 atomic_t fib_clntref; 76 atomic_t fib_clntref;
75 int fib_dead;
76 unsigned fib_flags; 77 unsigned fib_flags;
77 int fib_protocol; 78 unsigned char fib_dead;
79 unsigned char fib_protocol;
80 unsigned char fib_scope;
78 __be32 fib_prefsrc; 81 __be32 fib_prefsrc;
79 u32 fib_priority; 82 u32 fib_priority;
80 u32 fib_metrics[RTAX_MAX]; 83 u32 *fib_metrics;
81#define fib_mtu fib_metrics[RTAX_MTU-1] 84#define fib_mtu fib_metrics[RTAX_MTU-1]
82#define fib_window fib_metrics[RTAX_WINDOW-1] 85#define fib_window fib_metrics[RTAX_WINDOW-1]
83#define fib_rtt fib_metrics[RTAX_RTT-1] 86#define fib_rtt fib_metrics[RTAX_RTT-1]
@@ -86,6 +89,7 @@ struct fib_info {
86#ifdef CONFIG_IP_ROUTE_MULTIPATH 89#ifdef CONFIG_IP_ROUTE_MULTIPATH
87 int fib_power; 90 int fib_power;
88#endif 91#endif
92 struct rcu_head rcu;
89 struct fib_nh fib_nh[0]; 93 struct fib_nh fib_nh[0];
90#define fib_dev fib_nh[0].nh_dev 94#define fib_dev fib_nh[0].nh_dev
91}; 95};
@@ -95,12 +99,15 @@ struct fib_info {
95struct fib_rule; 99struct fib_rule;
96#endif 100#endif
97 101
102struct fib_table;
98struct fib_result { 103struct fib_result {
99 unsigned char prefixlen; 104 unsigned char prefixlen;
100 unsigned char nh_sel; 105 unsigned char nh_sel;
101 unsigned char type; 106 unsigned char type;
102 unsigned char scope; 107 unsigned char scope;
103 struct fib_info *fi; 108 struct fib_info *fi;
109 struct fib_table *table;
110 struct list_head *fa_head;
104#ifdef CONFIG_IP_MULTIPLE_TABLES 111#ifdef CONFIG_IP_MULTIPLE_TABLES
105 struct fib_rule *r; 112 struct fib_rule *r;
106#endif 113#endif
@@ -135,28 +142,37 @@ struct fib_result_nl {
135 142
136#endif /* CONFIG_IP_ROUTE_MULTIPATH */ 143#endif /* CONFIG_IP_ROUTE_MULTIPATH */
137 144
138#define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res)) 145extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
146
147#define FIB_RES_SADDR(net, res) \
148 ((FIB_RES_NH(res).nh_saddr_genid == \
149 atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
150 FIB_RES_NH(res).nh_saddr : \
151 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
139#define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) 152#define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
140#define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) 153#define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev)
141#define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) 154#define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif)
142 155
156#define FIB_RES_PREFSRC(net, res) ((res).fi->fib_prefsrc ? : \
157 FIB_RES_SADDR(net, res))
158
143struct fib_table { 159struct fib_table {
144 struct hlist_node tb_hlist; 160 struct hlist_node tb_hlist;
145 u32 tb_id; 161 u32 tb_id;
146 int tb_default; 162 int tb_default;
147 unsigned char tb_data[0]; 163 int tb_num_default;
164 unsigned long tb_data[0];
148}; 165};
149 166
150extern int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, 167extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
151 struct fib_result *res); 168 struct fib_result *res, int fib_flags);
152extern int fib_table_insert(struct fib_table *, struct fib_config *); 169extern int fib_table_insert(struct fib_table *, struct fib_config *);
153extern int fib_table_delete(struct fib_table *, struct fib_config *); 170extern int fib_table_delete(struct fib_table *, struct fib_config *);
154extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, 171extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
155 struct netlink_callback *cb); 172 struct netlink_callback *cb);
156extern int fib_table_flush(struct fib_table *table); 173extern int fib_table_flush(struct fib_table *table);
157extern void fib_table_select_default(struct fib_table *table, 174extern void fib_free_table(struct fib_table *tb);
158 const struct flowi *flp, 175
159 struct fib_result *res);
160 176
161 177
162#ifndef CONFIG_IP_MULTIPLE_TABLES 178#ifndef CONFIG_IP_MULTIPLE_TABLES
@@ -179,17 +195,17 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id)
179 return fib_get_table(net, id); 195 return fib_get_table(net, id);
180} 196}
181 197
182static inline int fib_lookup(struct net *net, const struct flowi *flp, 198static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
183 struct fib_result *res) 199 struct fib_result *res)
184{ 200{
185 struct fib_table *table; 201 struct fib_table *table;
186 202
187 table = fib_get_table(net, RT_TABLE_LOCAL); 203 table = fib_get_table(net, RT_TABLE_LOCAL);
188 if (!fib_table_lookup(table, flp, res)) 204 if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF))
189 return 0; 205 return 0;
190 206
191 table = fib_get_table(net, RT_TABLE_MAIN); 207 table = fib_get_table(net, RT_TABLE_MAIN);
192 if (!fib_table_lookup(table, flp, res)) 208 if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF))
193 return 0; 209 return 0;
194 return -ENETUNREACH; 210 return -ENETUNREACH;
195} 211}
@@ -198,11 +214,11 @@ static inline int fib_lookup(struct net *net, const struct flowi *flp,
198extern int __net_init fib4_rules_init(struct net *net); 214extern int __net_init fib4_rules_init(struct net *net);
199extern void __net_exit fib4_rules_exit(struct net *net); 215extern void __net_exit fib4_rules_exit(struct net *net);
200 216
201#ifdef CONFIG_NET_CLS_ROUTE 217#ifdef CONFIG_IP_ROUTE_CLASSID
202extern u32 fib_rules_tclass(struct fib_result *res); 218extern u32 fib_rules_tclass(const struct fib_result *res);
203#endif 219#endif
204 220
205extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); 221extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res);
206 222
207extern struct fib_table *fib_new_table(struct net *net, u32 id); 223extern struct fib_table *fib_new_table(struct net *net, u32 id);
208extern struct fib_table *fib_get_table(struct net *net, u32 id); 224extern struct fib_table *fib_get_table(struct net *net, u32 id);
@@ -212,27 +228,26 @@ extern struct fib_table *fib_get_table(struct net *net, u32 id);
212/* Exported by fib_frontend.c */ 228/* Exported by fib_frontend.c */
213extern const struct nla_policy rtm_ipv4_policy[]; 229extern const struct nla_policy rtm_ipv4_policy[];
214extern void ip_fib_init(void); 230extern void ip_fib_init(void);
215extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, 231extern int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
216 struct net_device *dev, __be32 *spec_dst, 232 u8 tos, int oif, struct net_device *dev,
217 u32 *itag, u32 mark); 233 __be32 *spec_dst, u32 *itag);
218extern void fib_select_default(struct net *net, const struct flowi *flp, 234extern void fib_select_default(struct fib_result *res);
219 struct fib_result *res);
220 235
221/* Exported by fib_semantics.c */ 236/* Exported by fib_semantics.c */
222extern int ip_fib_check_default(__be32 gw, struct net_device *dev); 237extern int ip_fib_check_default(__be32 gw, struct net_device *dev);
223extern int fib_sync_down_dev(struct net_device *dev, int force); 238extern int fib_sync_down_dev(struct net_device *dev, int force);
224extern int fib_sync_down_addr(struct net *net, __be32 local); 239extern int fib_sync_down_addr(struct net *net, __be32 local);
240extern void fib_update_nh_saddrs(struct net_device *dev);
225extern int fib_sync_up(struct net_device *dev); 241extern int fib_sync_up(struct net_device *dev);
226extern __be32 __fib_res_prefsrc(struct fib_result *res); 242extern void fib_select_multipath(struct fib_result *res);
227extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res);
228 243
229/* Exported by fib_{hash|trie}.c */ 244/* Exported by fib_trie.c */
230extern void fib_hash_init(void); 245extern void fib_trie_init(void);
231extern struct fib_table *fib_hash_table(u32 id); 246extern struct fib_table *fib_trie_table(u32 id);
232 247
233static inline void fib_combine_itag(u32 *itag, struct fib_result *res) 248static inline void fib_combine_itag(u32 *itag, const struct fib_result *res)
234{ 249{
235#ifdef CONFIG_NET_CLS_ROUTE 250#ifdef CONFIG_IP_ROUTE_CLASSID
236#ifdef CONFIG_IP_MULTIPLE_TABLES 251#ifdef CONFIG_IP_MULTIPLE_TABLES
237 u32 rtag; 252 u32 rtag;
238#endif 253#endif
@@ -254,16 +269,6 @@ static inline void fib_info_put(struct fib_info *fi)
254 free_fib_info(fi); 269 free_fib_info(fi);
255} 270}
256 271
257static inline void fib_res_put(struct fib_result *res)
258{
259 if (res->fi)
260 fib_info_put(res->fi);
261#ifdef CONFIG_IP_MULTIPLE_TABLES
262 if (res->r)
263 fib_rule_put(res->r);
264#endif
265}
266
267#ifdef CONFIG_PROC_FS 272#ifdef CONFIG_PROC_FS
268extern int __net_init fib_proc_init(struct net *net); 273extern int __net_init fib_proc_init(struct net *net);
269extern void __net_exit fib_proc_exit(struct net *net); 274extern void __net_exit fib_proc_exit(struct net *net);
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index f976885f686f..481f856c650f 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -8,9 +8,6 @@
8 8
9#include <linux/ip_vs.h> /* definitions shared with userland */ 9#include <linux/ip_vs.h> /* definitions shared with userland */
10 10
11/* old ipvsadm versions still include this file directly */
12#ifdef __KERNEL__
13
14#include <asm/types.h> /* for __uXX types */ 11#include <asm/types.h> /* for __uXX types */
15 12
16#include <linux/sysctl.h> /* for ctl_path */ 13#include <linux/sysctl.h> /* for ctl_path */
@@ -25,7 +22,83 @@
25#include <linux/ip.h> 22#include <linux/ip.h>
26#include <linux/ipv6.h> /* for struct ipv6hdr */ 23#include <linux/ipv6.h> /* for struct ipv6hdr */
27#include <net/ipv6.h> /* for ipv6_addr_copy */ 24#include <net/ipv6.h> /* for ipv6_addr_copy */
25#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
26#include <net/netfilter/nf_conntrack.h>
27#endif
28#include <net/net_namespace.h> /* Netw namespace */
28 29
30/*
31 * Generic access of ipvs struct
32 */
33static inline struct netns_ipvs *net_ipvs(struct net* net)
34{
35 return net->ipvs;
36}
37/*
38 * Get net ptr from skb in traffic cases
39 * use skb_sknet when call is from userland (ioctl or netlink)
40 */
41static inline struct net *skb_net(const struct sk_buff *skb)
42{
43#ifdef CONFIG_NET_NS
44#ifdef CONFIG_IP_VS_DEBUG
45 /*
46 * This is used for debug only.
47 * Start with the most likely hit
48 * End with BUG
49 */
50 if (likely(skb->dev && skb->dev->nd_net))
51 return dev_net(skb->dev);
52 if (skb_dst(skb) && skb_dst(skb)->dev)
53 return dev_net(skb_dst(skb)->dev);
54 WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n",
55 __func__, __LINE__);
56 if (likely(skb->sk && skb->sk->sk_net))
57 return sock_net(skb->sk);
58 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
59 __func__, __LINE__);
60 BUG();
61#else
62 return dev_net(skb->dev ? : skb_dst(skb)->dev);
63#endif
64#else
65 return &init_net;
66#endif
67}
68
69static inline struct net *skb_sknet(const struct sk_buff *skb)
70{
71#ifdef CONFIG_NET_NS
72#ifdef CONFIG_IP_VS_DEBUG
73 /* Start with the most likely hit */
74 if (likely(skb->sk && skb->sk->sk_net))
75 return sock_net(skb->sk);
76 WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n",
77 __func__, __LINE__);
78 if (likely(skb->dev && skb->dev->nd_net))
79 return dev_net(skb->dev);
80 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
81 __func__, __LINE__);
82 BUG();
83#else
84 return sock_net(skb->sk);
85#endif
86#else
87 return &init_net;
88#endif
89}
90/*
91 * This one needed for single_open_net since net is stored directly in
92 * private not as a struct i.e. seq_file_net can't be used.
93 */
94static inline struct net *seq_file_single_net(struct seq_file *seq)
95{
96#ifdef CONFIG_NET_NS
97 return (struct net *)seq->private;
98#else
99 return &init_net;
100#endif
101}
29 102
30/* Connections' size value needed by ip_vs_ctl.c */ 103/* Connections' size value needed by ip_vs_ctl.c */
31extern int ip_vs_conn_tab_size; 104extern int ip_vs_conn_tab_size;
@@ -134,24 +207,24 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
134 if (net_ratelimit()) \ 207 if (net_ratelimit()) \
135 printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ 208 printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
136 } while (0) 209 } while (0)
137#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) \ 210#define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) \
138 do { \ 211 do { \
139 if (level <= ip_vs_get_debug_level()) \ 212 if (level <= ip_vs_get_debug_level()) \
140 pp->debug_packet(pp, skb, ofs, msg); \ 213 pp->debug_packet(af, pp, skb, ofs, msg); \
141 } while (0) 214 } while (0)
142#define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) \ 215#define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) \
143 do { \ 216 do { \
144 if (level <= ip_vs_get_debug_level() && \ 217 if (level <= ip_vs_get_debug_level() && \
145 net_ratelimit()) \ 218 net_ratelimit()) \
146 pp->debug_packet(pp, skb, ofs, msg); \ 219 pp->debug_packet(af, pp, skb, ofs, msg); \
147 } while (0) 220 } while (0)
148#else /* NO DEBUGGING at ALL */ 221#else /* NO DEBUGGING at ALL */
149#define IP_VS_DBG_BUF(level, msg...) do {} while (0) 222#define IP_VS_DBG_BUF(level, msg...) do {} while (0)
150#define IP_VS_ERR_BUF(msg...) do {} while (0) 223#define IP_VS_ERR_BUF(msg...) do {} while (0)
151#define IP_VS_DBG(level, msg...) do {} while (0) 224#define IP_VS_DBG(level, msg...) do {} while (0)
152#define IP_VS_DBG_RL(msg...) do {} while (0) 225#define IP_VS_DBG_RL(msg...) do {} while (0)
153#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) 226#define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) do {} while (0)
154#define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) do {} while (0) 227#define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) do {} while (0)
155#endif 228#endif
156 229
157#define IP_VS_BUG() BUG() 230#define IP_VS_BUG() BUG()
@@ -256,6 +329,23 @@ struct ip_vs_seq {
256 before last resized pkt */ 329 before last resized pkt */
257}; 330};
258 331
332/*
333 * counters per cpu
334 */
335struct ip_vs_counters {
336 __u32 conns; /* connections scheduled */
337 __u32 inpkts; /* incoming packets */
338 __u32 outpkts; /* outgoing packets */
339 __u64 inbytes; /* incoming bytes */
340 __u64 outbytes; /* outgoing bytes */
341};
342/*
343 * Stats per cpu
344 */
345struct ip_vs_cpu_stats {
346 struct ip_vs_counters ustats;
347 struct u64_stats_sync syncp;
348};
259 349
260/* 350/*
261 * IPVS statistics objects 351 * IPVS statistics objects
@@ -277,10 +367,11 @@ struct ip_vs_estimator {
277}; 367};
278 368
279struct ip_vs_stats { 369struct ip_vs_stats {
280 struct ip_vs_stats_user ustats; /* statistics */ 370 struct ip_vs_stats_user ustats; /* statistics */
281 struct ip_vs_estimator est; /* estimator */ 371 struct ip_vs_estimator est; /* estimator */
282 372 struct ip_vs_cpu_stats *cpustats; /* per cpu counters */
283 spinlock_t lock; /* spin lock */ 373 spinlock_t lock; /* spin lock */
374 struct ip_vs_stats_user ustats0; /* reset values */
284}; 375};
285 376
286struct dst_entry; 377struct dst_entry;
@@ -288,6 +379,7 @@ struct iphdr;
288struct ip_vs_conn; 379struct ip_vs_conn;
289struct ip_vs_app; 380struct ip_vs_app;
290struct sk_buff; 381struct sk_buff;
382struct ip_vs_proto_data;
291 383
292struct ip_vs_protocol { 384struct ip_vs_protocol {
293 struct ip_vs_protocol *next; 385 struct ip_vs_protocol *next;
@@ -295,21 +387,22 @@ struct ip_vs_protocol {
295 u16 protocol; 387 u16 protocol;
296 u16 num_states; 388 u16 num_states;
297 int dont_defrag; 389 int dont_defrag;
298 atomic_t appcnt; /* counter of proto app incs */
299 int *timeout_table; /* protocol timeout table */
300 390
301 void (*init)(struct ip_vs_protocol *pp); 391 void (*init)(struct ip_vs_protocol *pp);
302 392
303 void (*exit)(struct ip_vs_protocol *pp); 393 void (*exit)(struct ip_vs_protocol *pp);
304 394
395 void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
396
397 void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd);
398
305 int (*conn_schedule)(int af, struct sk_buff *skb, 399 int (*conn_schedule)(int af, struct sk_buff *skb,
306 struct ip_vs_protocol *pp, 400 struct ip_vs_proto_data *pd,
307 int *verdict, struct ip_vs_conn **cpp); 401 int *verdict, struct ip_vs_conn **cpp);
308 402
309 struct ip_vs_conn * 403 struct ip_vs_conn *
310 (*conn_in_get)(int af, 404 (*conn_in_get)(int af,
311 const struct sk_buff *skb, 405 const struct sk_buff *skb,
312 struct ip_vs_protocol *pp,
313 const struct ip_vs_iphdr *iph, 406 const struct ip_vs_iphdr *iph,
314 unsigned int proto_off, 407 unsigned int proto_off,
315 int inverse); 408 int inverse);
@@ -317,7 +410,6 @@ struct ip_vs_protocol {
317 struct ip_vs_conn * 410 struct ip_vs_conn *
318 (*conn_out_get)(int af, 411 (*conn_out_get)(int af,
319 const struct sk_buff *skb, 412 const struct sk_buff *skb,
320 struct ip_vs_protocol *pp,
321 const struct ip_vs_iphdr *iph, 413 const struct ip_vs_iphdr *iph,
322 unsigned int proto_off, 414 unsigned int proto_off,
323 int inverse); 415 int inverse);
@@ -335,40 +427,69 @@ struct ip_vs_protocol {
335 427
336 int (*state_transition)(struct ip_vs_conn *cp, int direction, 428 int (*state_transition)(struct ip_vs_conn *cp, int direction,
337 const struct sk_buff *skb, 429 const struct sk_buff *skb,
338 struct ip_vs_protocol *pp); 430 struct ip_vs_proto_data *pd);
339 431
340 int (*register_app)(struct ip_vs_app *inc); 432 int (*register_app)(struct net *net, struct ip_vs_app *inc);
341 433
342 void (*unregister_app)(struct ip_vs_app *inc); 434 void (*unregister_app)(struct net *net, struct ip_vs_app *inc);
343 435
344 int (*app_conn_bind)(struct ip_vs_conn *cp); 436 int (*app_conn_bind)(struct ip_vs_conn *cp);
345 437
346 void (*debug_packet)(struct ip_vs_protocol *pp, 438 void (*debug_packet)(int af, struct ip_vs_protocol *pp,
347 const struct sk_buff *skb, 439 const struct sk_buff *skb,
348 int offset, 440 int offset,
349 const char *msg); 441 const char *msg);
350 442
351 void (*timeout_change)(struct ip_vs_protocol *pp, int flags); 443 void (*timeout_change)(struct ip_vs_proto_data *pd, int flags);
444};
352 445
353 int (*set_state_timeout)(struct ip_vs_protocol *pp, char *sname, int to); 446/*
447 * protocol data per netns
448 */
449struct ip_vs_proto_data {
450 struct ip_vs_proto_data *next;
451 struct ip_vs_protocol *pp;
452 int *timeout_table; /* protocol timeout table */
453 atomic_t appcnt; /* counter of proto app incs. */
454 struct tcp_states_t *tcp_state_table;
354}; 455};
355 456
356extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto); 457extern struct ip_vs_protocol *ip_vs_proto_get(unsigned short proto);
458extern struct ip_vs_proto_data *ip_vs_proto_data_get(struct net *net,
459 unsigned short proto);
460
461struct ip_vs_conn_param {
462 struct net *net;
463 const union nf_inet_addr *caddr;
464 const union nf_inet_addr *vaddr;
465 __be16 cport;
466 __be16 vport;
467 __u16 protocol;
468 u16 af;
469
470 const struct ip_vs_pe *pe;
471 char *pe_data;
472 __u8 pe_data_len;
473};
357 474
358/* 475/*
359 * IP_VS structure allocated for each dynamically scheduled connection 476 * IP_VS structure allocated for each dynamically scheduled connection
360 */ 477 */
361struct ip_vs_conn { 478struct ip_vs_conn {
362 struct list_head c_list; /* hashed list heads */ 479 struct hlist_node c_list; /* hashed list heads */
363 480#ifdef CONFIG_NET_NS
481 struct net *net; /* Name space */
482#endif
364 /* Protocol, addresses and port numbers */ 483 /* Protocol, addresses and port numbers */
365 u16 af; /* address family */ 484 u16 af; /* address family */
366 union nf_inet_addr caddr; /* client address */ 485 __be16 cport;
367 union nf_inet_addr vaddr; /* virtual address */ 486 __be16 vport;
368 union nf_inet_addr daddr; /* destination address */ 487 __be16 dport;
369 __be16 cport; 488 __u32 fwmark; /* Fire wall mark from skb */
370 __be16 vport; 489 union nf_inet_addr caddr; /* client address */
371 __be16 dport; 490 union nf_inet_addr vaddr; /* virtual address */
491 union nf_inet_addr daddr; /* destination address */
492 volatile __u32 flags; /* status flags */
372 __u16 protocol; /* Which protocol (TCP/UDP) */ 493 __u16 protocol; /* Which protocol (TCP/UDP) */
373 494
374 /* counter and timer */ 495 /* counter and timer */
@@ -378,7 +499,6 @@ struct ip_vs_conn {
378 499
379 /* Flags and state transition */ 500 /* Flags and state transition */
380 spinlock_t lock; /* lock for state transition */ 501 spinlock_t lock; /* lock for state transition */
381 volatile __u16 flags; /* status flags */
382 volatile __u16 state; /* state info */ 502 volatile __u16 state; /* state info */
383 volatile __u16 old_state; /* old state, to be used for 503 volatile __u16 old_state; /* old state, to be used for
384 * state transition triggerd 504 * state transition triggerd
@@ -394,6 +514,7 @@ struct ip_vs_conn {
394 /* packet transmitter for different forwarding methods. If it 514 /* packet transmitter for different forwarding methods. If it
395 mangles the packet, it must return NF_DROP or better NF_STOLEN, 515 mangles the packet, it must return NF_DROP or better NF_STOLEN,
396 otherwise this must be changed to a sk_buff **. 516 otherwise this must be changed to a sk_buff **.
517 NF_ACCEPT can be returned when destination is local.
397 */ 518 */
398 int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp, 519 int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp,
399 struct ip_vs_protocol *pp); 520 struct ip_vs_protocol *pp);
@@ -405,8 +526,39 @@ struct ip_vs_conn {
405 void *app_data; /* Application private data */ 526 void *app_data; /* Application private data */
406 struct ip_vs_seq in_seq; /* incoming seq. struct */ 527 struct ip_vs_seq in_seq; /* incoming seq. struct */
407 struct ip_vs_seq out_seq; /* outgoing seq. struct */ 528 struct ip_vs_seq out_seq; /* outgoing seq. struct */
529
530 const struct ip_vs_pe *pe;
531 char *pe_data;
532 __u8 pe_data_len;
408}; 533};
409 534
535/*
536 * To save some memory in conn table when name space is disabled.
537 */
538static inline struct net *ip_vs_conn_net(const struct ip_vs_conn *cp)
539{
540#ifdef CONFIG_NET_NS
541 return cp->net;
542#else
543 return &init_net;
544#endif
545}
546static inline void ip_vs_conn_net_set(struct ip_vs_conn *cp, struct net *net)
547{
548#ifdef CONFIG_NET_NS
549 cp->net = net;
550#endif
551}
552
553static inline int ip_vs_conn_net_eq(const struct ip_vs_conn *cp,
554 struct net *net)
555{
556#ifdef CONFIG_NET_NS
557 return cp->net == net;
558#else
559 return 1;
560#endif
561}
410 562
411/* 563/*
412 * Extended internal versions of struct ip_vs_service_user and 564 * Extended internal versions of struct ip_vs_service_user and
@@ -426,6 +578,7 @@ struct ip_vs_service_user_kern {
426 578
427 /* virtual service options */ 579 /* virtual service options */
428 char *sched_name; 580 char *sched_name;
581 char *pe_name;
429 unsigned flags; /* virtual service flags */ 582 unsigned flags; /* virtual service flags */
430 unsigned timeout; /* persistent timeout in sec */ 583 unsigned timeout; /* persistent timeout in sec */
431 u32 netmask; /* persistent netmask */ 584 u32 netmask; /* persistent netmask */
@@ -465,6 +618,7 @@ struct ip_vs_service {
465 unsigned flags; /* service status flags */ 618 unsigned flags; /* service status flags */
466 unsigned timeout; /* persistent timeout in ticks */ 619 unsigned timeout; /* persistent timeout in ticks */
467 __be32 netmask; /* grouping granularity */ 620 __be32 netmask; /* grouping granularity */
621 struct net *net;
468 622
469 struct list_head destinations; /* real server d-linked list */ 623 struct list_head destinations; /* real server d-linked list */
470 __u32 num_dests; /* number of servers */ 624 __u32 num_dests; /* number of servers */
@@ -475,6 +629,9 @@ struct ip_vs_service {
475 struct ip_vs_scheduler *scheduler; /* bound scheduler object */ 629 struct ip_vs_scheduler *scheduler; /* bound scheduler object */
476 rwlock_t sched_lock; /* lock sched_data */ 630 rwlock_t sched_lock; /* lock sched_data */
477 void *sched_data; /* scheduler application data */ 631 void *sched_data; /* scheduler application data */
632
633 /* alternate persistence engine */
634 struct ip_vs_pe *pe;
478}; 635};
479 636
480 637
@@ -487,8 +644,8 @@ struct ip_vs_dest {
487 struct list_head d_list; /* for table with all the dests */ 644 struct list_head d_list; /* for table with all the dests */
488 645
489 u16 af; /* address family */ 646 u16 af; /* address family */
490 union nf_inet_addr addr; /* IP address of the server */
491 __be16 port; /* port number of the server */ 647 __be16 port; /* port number of the server */
648 union nf_inet_addr addr; /* IP address of the server */
492 volatile unsigned flags; /* dest status flags */ 649 volatile unsigned flags; /* dest status flags */
493 atomic_t conn_flags; /* flags to copy to conn */ 650 atomic_t conn_flags; /* flags to copy to conn */
494 atomic_t weight; /* server weight */ 651 atomic_t weight; /* server weight */
@@ -507,12 +664,14 @@ struct ip_vs_dest {
507 spinlock_t dst_lock; /* lock of dst_cache */ 664 spinlock_t dst_lock; /* lock of dst_cache */
508 struct dst_entry *dst_cache; /* destination cache entry */ 665 struct dst_entry *dst_cache; /* destination cache entry */
509 u32 dst_rtos; /* RT_TOS(tos) for dst */ 666 u32 dst_rtos; /* RT_TOS(tos) for dst */
667 u32 dst_cookie;
668 union nf_inet_addr dst_saddr;
510 669
511 /* for virtual service */ 670 /* for virtual service */
512 struct ip_vs_service *svc; /* service it belongs to */ 671 struct ip_vs_service *svc; /* service it belongs to */
513 __u16 protocol; /* which protocol (TCP/UDP) */ 672 __u16 protocol; /* which protocol (TCP/UDP) */
514 union nf_inet_addr vaddr; /* virtual IP address */
515 __be16 vport; /* virtual port number */ 673 __be16 vport; /* virtual port number */
674 union nf_inet_addr vaddr; /* virtual IP address */
516 __u32 vfwmark; /* firewall mark of service */ 675 __u32 vfwmark; /* firewall mark of service */
517}; 676};
518 677
@@ -538,6 +697,21 @@ struct ip_vs_scheduler {
538 const struct sk_buff *skb); 697 const struct sk_buff *skb);
539}; 698};
540 699
700/* The persistence engine object */
701struct ip_vs_pe {
702 struct list_head n_list; /* d-linked list head */
703 char *name; /* scheduler name */
704 atomic_t refcnt; /* reference counter */
705 struct module *module; /* THIS_MODULE/NULL */
706
707 /* get the connection template, if any */
708 int (*fill_param)(struct ip_vs_conn_param *p, struct sk_buff *skb);
709 bool (*ct_match)(const struct ip_vs_conn_param *p,
710 struct ip_vs_conn *ct);
711 u32 (*hashkey_raw)(const struct ip_vs_conn_param *p, u32 initval,
712 bool inverse);
713 int (*show_pe_data)(const struct ip_vs_conn *cp, char *buf);
714};
541 715
542/* 716/*
543 * The application module object (a.k.a. app incarnation) 717 * The application module object (a.k.a. app incarnation)
@@ -556,11 +730,19 @@ struct ip_vs_app {
556 __be16 port; /* port number in net order */ 730 __be16 port; /* port number in net order */
557 atomic_t usecnt; /* usage counter */ 731 atomic_t usecnt; /* usage counter */
558 732
559 /* output hook: return false if can't linearize. diff set for TCP. */ 733 /*
734 * output hook: Process packet in inout direction, diff set for TCP.
735 * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok,
736 * 2=Mangled but checksum was not updated
737 */
560 int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *, 738 int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *,
561 struct sk_buff *, int *diff); 739 struct sk_buff *, int *diff);
562 740
563 /* input hook: return false if can't linearize. diff set for TCP. */ 741 /*
742 * input hook: Process packet in outin direction, diff set for TCP.
743 * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok,
744 * 2=Mangled but checksum was not updated
745 */
564 int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *, 746 int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *,
565 struct sk_buff *, int *diff); 747 struct sk_buff *, int *diff);
566 748
@@ -601,6 +783,171 @@ struct ip_vs_app {
601 void (*timeout_change)(struct ip_vs_app *app, int flags); 783 void (*timeout_change)(struct ip_vs_app *app, int flags);
602}; 784};
603 785
786/* IPVS in network namespace */
787struct netns_ipvs {
788 int gen; /* Generation */
789 int enable; /* enable like nf_hooks do */
790 /*
791 * Hash table: for real service lookups
792 */
793 #define IP_VS_RTAB_BITS 4
794 #define IP_VS_RTAB_SIZE (1 << IP_VS_RTAB_BITS)
795 #define IP_VS_RTAB_MASK (IP_VS_RTAB_SIZE - 1)
796
797 struct list_head rs_table[IP_VS_RTAB_SIZE];
798 /* ip_vs_app */
799 struct list_head app_list;
800 /* ip_vs_ftp */
801 struct ip_vs_app *ftp_app;
802 /* ip_vs_proto */
803 #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
804 struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
805 /* ip_vs_proto_tcp */
806#ifdef CONFIG_IP_VS_PROTO_TCP
807 #define TCP_APP_TAB_BITS 4
808 #define TCP_APP_TAB_SIZE (1 << TCP_APP_TAB_BITS)
809 #define TCP_APP_TAB_MASK (TCP_APP_TAB_SIZE - 1)
810 struct list_head tcp_apps[TCP_APP_TAB_SIZE];
811 spinlock_t tcp_app_lock;
812#endif
813 /* ip_vs_proto_udp */
814#ifdef CONFIG_IP_VS_PROTO_UDP
815 #define UDP_APP_TAB_BITS 4
816 #define UDP_APP_TAB_SIZE (1 << UDP_APP_TAB_BITS)
817 #define UDP_APP_TAB_MASK (UDP_APP_TAB_SIZE - 1)
818 struct list_head udp_apps[UDP_APP_TAB_SIZE];
819 spinlock_t udp_app_lock;
820#endif
821 /* ip_vs_proto_sctp */
822#ifdef CONFIG_IP_VS_PROTO_SCTP
823 #define SCTP_APP_TAB_BITS 4
824 #define SCTP_APP_TAB_SIZE (1 << SCTP_APP_TAB_BITS)
825 #define SCTP_APP_TAB_MASK (SCTP_APP_TAB_SIZE - 1)
826 /* Hash table for SCTP application incarnations */
827 struct list_head sctp_apps[SCTP_APP_TAB_SIZE];
828 spinlock_t sctp_app_lock;
829#endif
830 /* ip_vs_conn */
831 atomic_t conn_count; /* connection counter */
832
833 /* ip_vs_ctl */
834 struct ip_vs_stats tot_stats; /* Statistics & est. */
835
836 int num_services; /* no of virtual services */
837
838 rwlock_t rs_lock; /* real services table */
839 /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */
840 struct lock_class_key ctl_key; /* ctl_mutex debuging */
841 /* Trash for destinations */
842 struct list_head dest_trash;
843 /* Service counters */
844 atomic_t ftpsvc_counter;
845 atomic_t nullsvc_counter;
846
847#ifdef CONFIG_SYSCTL
848 /* 1/rate drop and drop-entry variables */
849 struct delayed_work defense_work; /* Work handler */
850 int drop_rate;
851 int drop_counter;
852 atomic_t dropentry;
853 /* locks in ctl.c */
854 spinlock_t dropentry_lock; /* drop entry handling */
855 spinlock_t droppacket_lock; /* drop packet handling */
856 spinlock_t securetcp_lock; /* state and timeout tables */
857
858 /* sys-ctl struct */
859 struct ctl_table_header *sysctl_hdr;
860 struct ctl_table *sysctl_tbl;
861#endif
862
863 /* sysctl variables */
864 int sysctl_amemthresh;
865 int sysctl_am_droprate;
866 int sysctl_drop_entry;
867 int sysctl_drop_packet;
868 int sysctl_secure_tcp;
869#ifdef CONFIG_IP_VS_NFCT
870 int sysctl_conntrack;
871#endif
872 int sysctl_snat_reroute;
873 int sysctl_sync_ver;
874 int sysctl_cache_bypass;
875 int sysctl_expire_nodest_conn;
876 int sysctl_expire_quiescent_template;
877 int sysctl_sync_threshold[2];
878 int sysctl_nat_icmp_send;
879
880 /* ip_vs_lblc */
881 int sysctl_lblc_expiration;
882 struct ctl_table_header *lblc_ctl_header;
883 struct ctl_table *lblc_ctl_table;
884 /* ip_vs_lblcr */
885 int sysctl_lblcr_expiration;
886 struct ctl_table_header *lblcr_ctl_header;
887 struct ctl_table *lblcr_ctl_table;
888 /* ip_vs_est */
889 struct list_head est_list; /* estimator list */
890 spinlock_t est_lock;
891 struct timer_list est_timer; /* Estimation timer */
892 /* ip_vs_sync */
893 struct list_head sync_queue;
894 spinlock_t sync_lock;
895 struct ip_vs_sync_buff *sync_buff;
896 spinlock_t sync_buff_lock;
897 struct sockaddr_in sync_mcast_addr;
898 struct task_struct *master_thread;
899 struct task_struct *backup_thread;
900 int send_mesg_maxlen;
901 int recv_mesg_maxlen;
902 volatile int sync_state;
903 volatile int master_syncid;
904 volatile int backup_syncid;
905 /* multicast interface name */
906 char master_mcast_ifn[IP_VS_IFNAME_MAXLEN];
907 char backup_mcast_ifn[IP_VS_IFNAME_MAXLEN];
908 /* net name space ptr */
909 struct net *net; /* Needed by timer routines */
910};
911
912#define DEFAULT_SYNC_THRESHOLD 3
913#define DEFAULT_SYNC_PERIOD 50
914#define DEFAULT_SYNC_VER 1
915
916#ifdef CONFIG_SYSCTL
917
918static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
919{
920 return ipvs->sysctl_sync_threshold[0];
921}
922
923static inline int sysctl_sync_period(struct netns_ipvs *ipvs)
924{
925 return ipvs->sysctl_sync_threshold[1];
926}
927
928static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
929{
930 return ipvs->sysctl_sync_ver;
931}
932
933#else
934
935static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
936{
937 return DEFAULT_SYNC_THRESHOLD;
938}
939
940static inline int sysctl_sync_period(struct netns_ipvs *ipvs)
941{
942 return DEFAULT_SYNC_PERIOD;
943}
944
945static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
946{
947 return DEFAULT_SYNC_VER;
948}
949
950#endif
604 951
605/* 952/*
606 * IPVS core functions 953 * IPVS core functions
@@ -624,26 +971,35 @@ enum {
624 IP_VS_DIR_LAST, 971 IP_VS_DIR_LAST,
625}; 972};
626 973
627extern struct ip_vs_conn *ip_vs_conn_in_get 974static inline void ip_vs_conn_fill_param(struct net *net, int af, int protocol,
628(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, 975 const union nf_inet_addr *caddr,
629 const union nf_inet_addr *d_addr, __be16 d_port); 976 __be16 cport,
977 const union nf_inet_addr *vaddr,
978 __be16 vport,
979 struct ip_vs_conn_param *p)
980{
981 p->net = net;
982 p->af = af;
983 p->protocol = protocol;
984 p->caddr = caddr;
985 p->cport = cport;
986 p->vaddr = vaddr;
987 p->vport = vport;
988 p->pe = NULL;
989 p->pe_data = NULL;
990}
630 991
631extern struct ip_vs_conn *ip_vs_ct_in_get 992struct ip_vs_conn *ip_vs_conn_in_get(const struct ip_vs_conn_param *p);
632(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, 993struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p);
633 const union nf_inet_addr *d_addr, __be16 d_port);
634 994
635struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, 995struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb,
636 struct ip_vs_protocol *pp,
637 const struct ip_vs_iphdr *iph, 996 const struct ip_vs_iphdr *iph,
638 unsigned int proto_off, 997 unsigned int proto_off,
639 int inverse); 998 int inverse);
640 999
641extern struct ip_vs_conn *ip_vs_conn_out_get 1000struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p);
642(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port,
643 const union nf_inet_addr *d_addr, __be16 d_port);
644 1001
645struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, 1002struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb,
646 struct ip_vs_protocol *pp,
647 const struct ip_vs_iphdr *iph, 1003 const struct ip_vs_iphdr *iph,
648 unsigned int proto_off, 1004 unsigned int proto_off,
649 int inverse); 1005 int inverse);
@@ -656,18 +1012,17 @@ static inline void __ip_vs_conn_put(struct ip_vs_conn *cp)
656extern void ip_vs_conn_put(struct ip_vs_conn *cp); 1012extern void ip_vs_conn_put(struct ip_vs_conn *cp);
657extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); 1013extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport);
658 1014
659extern struct ip_vs_conn * 1015struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p,
660ip_vs_conn_new(int af, int proto, const union nf_inet_addr *caddr, __be16 cport, 1016 const union nf_inet_addr *daddr,
661 const union nf_inet_addr *vaddr, __be16 vport, 1017 __be16 dport, unsigned flags,
662 const union nf_inet_addr *daddr, __be16 dport, unsigned flags, 1018 struct ip_vs_dest *dest, __u32 fwmark);
663 struct ip_vs_dest *dest);
664extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); 1019extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp);
665 1020
666extern const char * ip_vs_state_name(__u16 proto, int state); 1021extern const char * ip_vs_state_name(__u16 proto, int state);
667 1022
668extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); 1023extern void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp);
669extern int ip_vs_check_template(struct ip_vs_conn *ct); 1024extern int ip_vs_check_template(struct ip_vs_conn *ct);
670extern void ip_vs_random_dropentry(void); 1025extern void ip_vs_random_dropentry(struct net *net);
671extern int ip_vs_conn_init(void); 1026extern int ip_vs_conn_init(void);
672extern void ip_vs_conn_cleanup(void); 1027extern void ip_vs_conn_cleanup(void);
673 1028
@@ -731,18 +1086,34 @@ ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp)
731 atomic_inc(&ctl_cp->n_control); 1086 atomic_inc(&ctl_cp->n_control);
732} 1087}
733 1088
1089/*
1090 * IPVS netns init & cleanup functions
1091 */
1092extern int __ip_vs_estimator_init(struct net *net);
1093extern int __ip_vs_control_init(struct net *net);
1094extern int __ip_vs_protocol_init(struct net *net);
1095extern int __ip_vs_app_init(struct net *net);
1096extern int __ip_vs_conn_init(struct net *net);
1097extern int __ip_vs_sync_init(struct net *net);
1098extern void __ip_vs_conn_cleanup(struct net *net);
1099extern void __ip_vs_app_cleanup(struct net *net);
1100extern void __ip_vs_protocol_cleanup(struct net *net);
1101extern void __ip_vs_control_cleanup(struct net *net);
1102extern void __ip_vs_estimator_cleanup(struct net *net);
1103extern void __ip_vs_sync_cleanup(struct net *net);
1104extern void __ip_vs_service_cleanup(struct net *net);
734 1105
735/* 1106/*
736 * IPVS application functions 1107 * IPVS application functions
737 * (from ip_vs_app.c) 1108 * (from ip_vs_app.c)
738 */ 1109 */
739#define IP_VS_APP_MAX_PORTS 8 1110#define IP_VS_APP_MAX_PORTS 8
740extern int register_ip_vs_app(struct ip_vs_app *app); 1111extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app);
741extern void unregister_ip_vs_app(struct ip_vs_app *app); 1112extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app);
742extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); 1113extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
743extern void ip_vs_unbind_app(struct ip_vs_conn *cp); 1114extern void ip_vs_unbind_app(struct ip_vs_conn *cp);
744extern int 1115extern int register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app,
745register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port); 1116 __u16 proto, __u16 port);
746extern int ip_vs_app_inc_get(struct ip_vs_app *inc); 1117extern int ip_vs_app_inc_get(struct ip_vs_app *inc);
747extern void ip_vs_app_inc_put(struct ip_vs_app *inc); 1118extern void ip_vs_app_inc_put(struct ip_vs_app *inc);
748 1119
@@ -751,19 +1122,38 @@ extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff *skb);
751extern int ip_vs_app_init(void); 1122extern int ip_vs_app_init(void);
752extern void ip_vs_app_cleanup(void); 1123extern void ip_vs_app_cleanup(void);
753 1124
1125void ip_vs_bind_pe(struct ip_vs_service *svc, struct ip_vs_pe *pe);
1126void ip_vs_unbind_pe(struct ip_vs_service *svc);
1127int register_ip_vs_pe(struct ip_vs_pe *pe);
1128int unregister_ip_vs_pe(struct ip_vs_pe *pe);
1129struct ip_vs_pe *ip_vs_pe_getbyname(const char *name);
1130struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name);
1131
1132static inline void ip_vs_pe_get(const struct ip_vs_pe *pe)
1133{
1134 if (pe && pe->module)
1135 __module_get(pe->module);
1136}
1137
1138static inline void ip_vs_pe_put(const struct ip_vs_pe *pe)
1139{
1140 if (pe && pe->module)
1141 module_put(pe->module);
1142}
754 1143
755/* 1144/*
756 * IPVS protocol functions (from ip_vs_proto.c) 1145 * IPVS protocol functions (from ip_vs_proto.c)
757 */ 1146 */
758extern int ip_vs_protocol_init(void); 1147extern int ip_vs_protocol_init(void);
759extern void ip_vs_protocol_cleanup(void); 1148extern void ip_vs_protocol_cleanup(void);
760extern void ip_vs_protocol_timeout_change(int flags); 1149extern void ip_vs_protocol_timeout_change(struct netns_ipvs *ipvs, int flags);
761extern int *ip_vs_create_timeout_table(int *table, int size); 1150extern int *ip_vs_create_timeout_table(int *table, int size);
762extern int 1151extern int
763ip_vs_set_state_timeout(int *table, int num, const char *const *names, 1152ip_vs_set_state_timeout(int *table, int num, const char *const *names,
764 const char *name, int to); 1153 const char *name, int to);
765extern void 1154extern void
766ip_vs_tcpudp_debug_packet(struct ip_vs_protocol *pp, const struct sk_buff *skb, 1155ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp,
1156 const struct sk_buff *skb,
767 int offset, const char *msg); 1157 int offset, const char *msg);
768 1158
769extern struct ip_vs_protocol ip_vs_protocol_tcp; 1159extern struct ip_vs_protocol ip_vs_protocol_tcp;
@@ -785,24 +1175,24 @@ extern int ip_vs_unbind_scheduler(struct ip_vs_service *svc);
785extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); 1175extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name);
786extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); 1176extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler);
787extern struct ip_vs_conn * 1177extern struct ip_vs_conn *
788ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb); 1178ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
1179 struct ip_vs_proto_data *pd, int *ignored);
789extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, 1180extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
790 struct ip_vs_protocol *pp); 1181 struct ip_vs_proto_data *pd);
1182
1183extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg);
791 1184
792 1185
793/* 1186/*
794 * IPVS control data and functions (from ip_vs_ctl.c) 1187 * IPVS control data and functions (from ip_vs_ctl.c)
795 */ 1188 */
796extern int sysctl_ip_vs_cache_bypass;
797extern int sysctl_ip_vs_expire_nodest_conn;
798extern int sysctl_ip_vs_expire_quiescent_template;
799extern int sysctl_ip_vs_sync_threshold[2];
800extern int sysctl_ip_vs_nat_icmp_send;
801extern struct ip_vs_stats ip_vs_stats; 1189extern struct ip_vs_stats ip_vs_stats;
802extern const struct ctl_path net_vs_ctl_path[]; 1190extern const struct ctl_path net_vs_ctl_path[];
1191extern int sysctl_ip_vs_sync_ver;
803 1192
1193extern void ip_vs_sync_switch_mode(struct net *net, int mode);
804extern struct ip_vs_service * 1194extern struct ip_vs_service *
805ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, 1195ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol,
806 const union nf_inet_addr *vaddr, __be16 vport); 1196 const union nf_inet_addr *vaddr, __be16 vport);
807 1197
808static inline void ip_vs_service_put(struct ip_vs_service *svc) 1198static inline void ip_vs_service_put(struct ip_vs_service *svc)
@@ -811,7 +1201,7 @@ static inline void ip_vs_service_put(struct ip_vs_service *svc)
811} 1201}
812 1202
813extern struct ip_vs_dest * 1203extern struct ip_vs_dest *
814ip_vs_lookup_real_service(int af, __u16 protocol, 1204ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol,
815 const union nf_inet_addr *daddr, __be16 dport); 1205 const union nf_inet_addr *daddr, __be16 dport);
816 1206
817extern int ip_vs_use_count_inc(void); 1207extern int ip_vs_use_count_inc(void);
@@ -819,8 +1209,9 @@ extern void ip_vs_use_count_dec(void);
819extern int ip_vs_control_init(void); 1209extern int ip_vs_control_init(void);
820extern void ip_vs_control_cleanup(void); 1210extern void ip_vs_control_cleanup(void);
821extern struct ip_vs_dest * 1211extern struct ip_vs_dest *
822ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, 1212ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr,
823 const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol); 1213 __be16 dport, const union nf_inet_addr *vaddr, __be16 vport,
1214 __u16 protocol, __u32 fwmark);
824extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); 1215extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
825 1216
826 1217
@@ -828,14 +1219,12 @@ extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
828 * IPVS sync daemon data and function prototypes 1219 * IPVS sync daemon data and function prototypes
829 * (from ip_vs_sync.c) 1220 * (from ip_vs_sync.c)
830 */ 1221 */
831extern volatile int ip_vs_sync_state; 1222extern int start_sync_thread(struct net *net, int state, char *mcast_ifn,
832extern volatile int ip_vs_master_syncid; 1223 __u8 syncid);
833extern volatile int ip_vs_backup_syncid; 1224extern int stop_sync_thread(struct net *net, int state);
834extern char ip_vs_master_mcast_ifn[IP_VS_IFNAME_MAXLEN]; 1225extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp);
835extern char ip_vs_backup_mcast_ifn[IP_VS_IFNAME_MAXLEN]; 1226extern int ip_vs_sync_init(void);
836extern int start_sync_thread(int state, char *mcast_ifn, __u8 syncid); 1227extern void ip_vs_sync_cleanup(void);
837extern int stop_sync_thread(int state);
838extern void ip_vs_sync_conn(struct ip_vs_conn *cp);
839 1228
840 1229
841/* 1230/*
@@ -843,9 +1232,11 @@ extern void ip_vs_sync_conn(struct ip_vs_conn *cp);
843 */ 1232 */
844extern int ip_vs_estimator_init(void); 1233extern int ip_vs_estimator_init(void);
845extern void ip_vs_estimator_cleanup(void); 1234extern void ip_vs_estimator_cleanup(void);
846extern void ip_vs_new_estimator(struct ip_vs_stats *stats); 1235extern void ip_vs_start_estimator(struct net *net, struct ip_vs_stats *stats);
847extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); 1236extern void ip_vs_stop_estimator(struct net *net, struct ip_vs_stats *stats);
848extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); 1237extern void ip_vs_zero_estimator(struct ip_vs_stats *stats);
1238extern void ip_vs_read_estimator(struct ip_vs_stats_user *dst,
1239 struct ip_vs_stats *stats);
849 1240
850/* 1241/*
851 * Various IPVS packet transmitters (from ip_vs_xmit.c) 1242 * Various IPVS packet transmitters (from ip_vs_xmit.c)
@@ -861,7 +1252,8 @@ extern int ip_vs_tunnel_xmit
861extern int ip_vs_dr_xmit 1252extern int ip_vs_dr_xmit
862(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); 1253(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
863extern int ip_vs_icmp_xmit 1254extern int ip_vs_icmp_xmit
864(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset); 1255(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp,
1256 int offset, unsigned int hooknum);
865extern void ip_vs_dst_reset(struct ip_vs_dest *dest); 1257extern void ip_vs_dst_reset(struct ip_vs_dest *dest);
866 1258
867#ifdef CONFIG_IP_VS_IPV6 1259#ifdef CONFIG_IP_VS_IPV6
@@ -875,24 +1267,28 @@ extern int ip_vs_dr_xmit_v6
875(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); 1267(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
876extern int ip_vs_icmp_xmit_v6 1268extern int ip_vs_icmp_xmit_v6
877(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, 1269(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp,
878 int offset); 1270 int offset, unsigned int hooknum);
879#endif 1271#endif
880 1272
1273#ifdef CONFIG_SYSCTL
881/* 1274/*
882 * This is a simple mechanism to ignore packets when 1275 * This is a simple mechanism to ignore packets when
883 * we are loaded. Just set ip_vs_drop_rate to 'n' and 1276 * we are loaded. Just set ip_vs_drop_rate to 'n' and
884 * we start to drop 1/rate of the packets 1277 * we start to drop 1/rate of the packets
885 */ 1278 */
886extern int ip_vs_drop_rate;
887extern int ip_vs_drop_counter;
888 1279
889static __inline__ int ip_vs_todrop(void) 1280static inline int ip_vs_todrop(struct netns_ipvs *ipvs)
890{ 1281{
891 if (!ip_vs_drop_rate) return 0; 1282 if (!ipvs->drop_rate)
892 if (--ip_vs_drop_counter > 0) return 0; 1283 return 0;
893 ip_vs_drop_counter = ip_vs_drop_rate; 1284 if (--ipvs->drop_counter > 0)
1285 return 0;
1286 ipvs->drop_counter = ipvs->drop_rate;
894 return 1; 1287 return 1;
895} 1288}
1289#else
1290static inline int ip_vs_todrop(struct netns_ipvs *ipvs) { return 0; }
1291#endif
896 1292
897/* 1293/*
898 * ip_vs_fwd_tag returns the forwarding tag of the connection 1294 * ip_vs_fwd_tag returns the forwarding tag of the connection
@@ -955,9 +1351,82 @@ static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)
955 return csum_partial(diff, sizeof(diff), oldsum); 1351 return csum_partial(diff, sizeof(diff), oldsum);
956} 1352}
957 1353
1354/*
1355 * Forget current conntrack (unconfirmed) and attach notrack entry
1356 */
1357static inline void ip_vs_notrack(struct sk_buff *skb)
1358{
1359#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
1360 enum ip_conntrack_info ctinfo;
1361 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
1362
1363 if (!ct || !nf_ct_is_untracked(ct)) {
1364 nf_reset(skb);
1365 skb->nfct = &nf_ct_untracked_get()->ct_general;
1366 skb->nfctinfo = IP_CT_NEW;
1367 nf_conntrack_get(skb->nfct);
1368 }
1369#endif
1370}
1371
1372#ifdef CONFIG_IP_VS_NFCT
1373/*
1374 * Netfilter connection tracking
1375 * (from ip_vs_nfct.c)
1376 */
1377static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs)
1378{
1379#ifdef CONFIG_SYSCTL
1380 return ipvs->sysctl_conntrack;
1381#else
1382 return 0;
1383#endif
1384}
1385
958extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, 1386extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp,
959 int outin); 1387 int outin);
1388extern int ip_vs_confirm_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp);
1389extern void ip_vs_nfct_expect_related(struct sk_buff *skb, struct nf_conn *ct,
1390 struct ip_vs_conn *cp, u_int8_t proto,
1391 const __be16 port, int from_rs);
1392extern void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp);
1393
1394#else
1395
1396static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs)
1397{
1398 return 0;
1399}
960 1400
961#endif /* __KERNEL__ */ 1401static inline void ip_vs_update_conntrack(struct sk_buff *skb,
1402 struct ip_vs_conn *cp, int outin)
1403{
1404}
1405
1406static inline int ip_vs_confirm_conntrack(struct sk_buff *skb,
1407 struct ip_vs_conn *cp)
1408{
1409 return NF_ACCEPT;
1410}
1411
1412static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp)
1413{
1414}
1415/* CONFIG_IP_VS_NFCT */
1416#endif
1417
1418static inline unsigned int
1419ip_vs_dest_conn_overhead(struct ip_vs_dest *dest)
1420{
1421 /*
1422 * We think the overhead of processing active connections is 256
1423 * times higher than that of inactive connections in average. (This
1424 * 256 times might not be accurate, we will change it later) We
1425 * use the following formula to estimate the overhead now:
1426 * dest->activeconns*256 + dest->inactconns
1427 */
1428 return (atomic_read(&dest->activeconns) << 8) +
1429 atomic_read(&dest->inactconns);
1430}
962 1431
963#endif /* _NET_IP_VS_H */ 1432#endif /* _NET_IP_VS_H */
diff --git a/include/net/ipip.h b/include/net/ipip.h
index 65caea8b414f..a32654d52730 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -16,7 +16,7 @@ struct ip_tunnel_6rd_parm {
16}; 16};
17 17
18struct ip_tunnel { 18struct ip_tunnel {
19 struct ip_tunnel *next; 19 struct ip_tunnel __rcu *next;
20 struct net_device *dev; 20 struct net_device *dev;
21 21
22 int err_count; /* Number of arrived ICMP errors */ 22 int err_count; /* Number of arrived ICMP errors */
@@ -34,18 +34,18 @@ struct ip_tunnel {
34#ifdef CONFIG_IPV6_SIT_6RD 34#ifdef CONFIG_IPV6_SIT_6RD
35 struct ip_tunnel_6rd_parm ip6rd; 35 struct ip_tunnel_6rd_parm ip6rd;
36#endif 36#endif
37 struct ip_tunnel_prl_entry *prl; /* potential router list */ 37 struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */
38 unsigned int prl_count; /* # of entries in PRL */ 38 unsigned int prl_count; /* # of entries in PRL */
39}; 39};
40 40
41struct ip_tunnel_prl_entry { 41struct ip_tunnel_prl_entry {
42 struct ip_tunnel_prl_entry *next; 42 struct ip_tunnel_prl_entry __rcu *next;
43 __be32 addr; 43 __be32 addr;
44 u16 flags; 44 u16 flags;
45 struct rcu_head rcu_head; 45 struct rcu_head rcu_head;
46}; 46};
47 47
48#define IPTUNNEL_XMIT() do { \ 48#define __IPTUNNEL_XMIT(stats1, stats2) do { \
49 int err; \ 49 int err; \
50 int pkt_len = skb->len - skb_transport_offset(skb); \ 50 int pkt_len = skb->len - skb_transport_offset(skb); \
51 \ 51 \
@@ -54,12 +54,14 @@ struct ip_tunnel_prl_entry {
54 \ 54 \
55 err = ip_local_out(skb); \ 55 err = ip_local_out(skb); \
56 if (likely(net_xmit_eval(err) == 0)) { \ 56 if (likely(net_xmit_eval(err) == 0)) { \
57 txq->tx_bytes += pkt_len; \ 57 (stats1)->tx_bytes += pkt_len; \
58 txq->tx_packets++; \ 58 (stats1)->tx_packets++; \
59 } else { \ 59 } else { \
60 stats->tx_errors++; \ 60 (stats2)->tx_errors++; \
61 stats->tx_aborted_errors++; \ 61 (stats2)->tx_aborted_errors++; \
62 } \ 62 } \
63} while (0) 63} while (0)
64 64
65#define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats)
66
65#endif 67#endif
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 1f8412410998..c033ed00df7d 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -77,11 +77,9 @@
77/* 77/*
78 * Addr scopes 78 * Addr scopes
79 */ 79 */
80#ifdef __KERNEL__
81#define IPV6_ADDR_MC_SCOPE(a) \ 80#define IPV6_ADDR_MC_SCOPE(a) \
82 ((a)->s6_addr[1] & 0x0f) /* nonstandard */ 81 ((a)->s6_addr[1] & 0x0f) /* nonstandard */
83#define __IPV6_ADDR_SCOPE_INVALID -1 82#define __IPV6_ADDR_SCOPE_INVALID -1
84#endif
85#define IPV6_ADDR_SCOPE_NODELOCAL 0x01 83#define IPV6_ADDR_SCOPE_NODELOCAL 0x01
86#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 84#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
87#define IPV6_ADDR_SCOPE_SITELOCAL 0x05 85#define IPV6_ADDR_SCOPE_SITELOCAL 0x05
@@ -89,6 +87,16 @@
89#define IPV6_ADDR_SCOPE_GLOBAL 0x0e 87#define IPV6_ADDR_SCOPE_GLOBAL 0x0e
90 88
91/* 89/*
90 * Addr flags
91 */
92#define IPV6_ADDR_MC_FLAG_TRANSIENT(a) \
93 ((a)->s6_addr[1] & 0x10)
94#define IPV6_ADDR_MC_FLAG_PREFIX(a) \
95 ((a)->s6_addr[1] & 0x20)
96#define IPV6_ADDR_MC_FLAG_RENDEZVOUS(a) \
97 ((a)->s6_addr[1] & 0x40)
98
99/*
92 * fragmentation header 100 * fragmentation header
93 */ 101 */
94 102
@@ -101,8 +109,6 @@ struct frag_hdr {
101 109
102#define IP6_MF 0x0001 110#define IP6_MF 0x0001
103 111
104#ifdef __KERNEL__
105
106#include <net/sock.h> 112#include <net/sock.h>
107 113
108/* sysctls */ 114/* sysctls */
@@ -117,6 +123,15 @@ extern struct ctl_path net_ipv6_ctl_path[];
117 SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ 123 SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\
118}) 124})
119 125
126/* per device counters are atomic_long_t */
127#define _DEVINCATOMIC(net, statname, modifier, idev, field) \
128({ \
129 struct inet6_dev *_idev = (idev); \
130 if (likely(_idev != NULL)) \
131 SNMP_INC_STATS_ATOMIC_LONG((_idev)->stats.statname##dev, (field)); \
132 SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\
133})
134
120#define _DEVADD(net, statname, modifier, idev, field, val) \ 135#define _DEVADD(net, statname, modifier, idev, field, val) \
121({ \ 136({ \
122 struct inet6_dev *_idev = (idev); \ 137 struct inet6_dev *_idev = (idev); \
@@ -148,16 +163,16 @@ extern struct ctl_path net_ipv6_ctl_path[];
148#define IP6_UPD_PO_STATS_BH(net, idev,field,val) \ 163#define IP6_UPD_PO_STATS_BH(net, idev,field,val) \
149 _DEVUPD(net, ipv6, 64_BH, idev, field, val) 164 _DEVUPD(net, ipv6, 64_BH, idev, field, val)
150#define ICMP6_INC_STATS(net, idev, field) \ 165#define ICMP6_INC_STATS(net, idev, field) \
151 _DEVINC(net, icmpv6, , idev, field) 166 _DEVINCATOMIC(net, icmpv6, , idev, field)
152#define ICMP6_INC_STATS_BH(net, idev, field) \ 167#define ICMP6_INC_STATS_BH(net, idev, field) \
153 _DEVINC(net, icmpv6, _BH, idev, field) 168 _DEVINCATOMIC(net, icmpv6, _BH, idev, field)
154 169
155#define ICMP6MSGOUT_INC_STATS(net, idev, field) \ 170#define ICMP6MSGOUT_INC_STATS(net, idev, field) \
156 _DEVINC(net, icmpv6msg, , idev, field +256) 171 _DEVINCATOMIC(net, icmpv6msg, , idev, field +256)
157#define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ 172#define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \
158 _DEVINC(net, icmpv6msg, _BH, idev, field +256) 173 _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field +256)
159#define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ 174#define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \
160 _DEVINC(net, icmpv6msg, _BH, idev, field) 175 _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field)
161 176
162struct ip6_ra_chain { 177struct ip6_ra_chain {
163 struct ip6_ra_chain *next; 178 struct ip6_ra_chain *next;
@@ -262,7 +277,7 @@ static inline int ipv6_addr_scope(const struct in6_addr *addr)
262 277
263static inline int __ipv6_addr_src_scope(int type) 278static inline int __ipv6_addr_src_scope(int type)
264{ 279{
265 return (type == IPV6_ADDR_ANY ? __IPV6_ADDR_SCOPE_INVALID : (type >> 16)); 280 return (type == IPV6_ADDR_ANY) ? __IPV6_ADDR_SCOPE_INVALID : (type >> 16);
266} 281}
267 282
268static inline int ipv6_addr_src_scope(const struct in6_addr *addr) 283static inline int ipv6_addr_src_scope(const struct in6_addr *addr)
@@ -279,10 +294,10 @@ static inline int
279ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m, 294ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m,
280 const struct in6_addr *a2) 295 const struct in6_addr *a2)
281{ 296{
282 return (!!(((a1->s6_addr32[0] ^ a2->s6_addr32[0]) & m->s6_addr32[0]) | 297 return !!(((a1->s6_addr32[0] ^ a2->s6_addr32[0]) & m->s6_addr32[0]) |
283 ((a1->s6_addr32[1] ^ a2->s6_addr32[1]) & m->s6_addr32[1]) | 298 ((a1->s6_addr32[1] ^ a2->s6_addr32[1]) & m->s6_addr32[1]) |
284 ((a1->s6_addr32[2] ^ a2->s6_addr32[2]) & m->s6_addr32[2]) | 299 ((a1->s6_addr32[2] ^ a2->s6_addr32[2]) & m->s6_addr32[2]) |
285 ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3]))); 300 ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3]));
286} 301}
287 302
288static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) 303static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2)
@@ -317,10 +332,10 @@ static inline void ipv6_addr_set(struct in6_addr *addr,
317static inline int ipv6_addr_equal(const struct in6_addr *a1, 332static inline int ipv6_addr_equal(const struct in6_addr *a1,
318 const struct in6_addr *a2) 333 const struct in6_addr *a2)
319{ 334{
320 return (((a1->s6_addr32[0] ^ a2->s6_addr32[0]) | 335 return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) |
321 (a1->s6_addr32[1] ^ a2->s6_addr32[1]) | 336 (a1->s6_addr32[1] ^ a2->s6_addr32[1]) |
322 (a1->s6_addr32[2] ^ a2->s6_addr32[2]) | 337 (a1->s6_addr32[2] ^ a2->s6_addr32[2]) |
323 (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0); 338 (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0;
324} 339}
325 340
326static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, 341static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2,
@@ -364,8 +379,8 @@ enum ip6_defrag_users {
364struct ip6_create_arg { 379struct ip6_create_arg {
365 __be32 id; 380 __be32 id;
366 u32 user; 381 u32 user;
367 struct in6_addr *src; 382 const struct in6_addr *src;
368 struct in6_addr *dst; 383 const struct in6_addr *dst;
369}; 384};
370 385
371void ip6_frag_init(struct inet_frag_queue *q, void *a); 386void ip6_frag_init(struct inet_frag_queue *q, void *a);
@@ -373,20 +388,20 @@ int ip6_frag_match(struct inet_frag_queue *q, void *a);
373 388
374static inline int ipv6_addr_any(const struct in6_addr *a) 389static inline int ipv6_addr_any(const struct in6_addr *a)
375{ 390{
376 return ((a->s6_addr32[0] | a->s6_addr32[1] | 391 return (a->s6_addr32[0] | a->s6_addr32[1] |
377 a->s6_addr32[2] | a->s6_addr32[3] ) == 0); 392 a->s6_addr32[2] | a->s6_addr32[3]) == 0;
378} 393}
379 394
380static inline int ipv6_addr_loopback(const struct in6_addr *a) 395static inline int ipv6_addr_loopback(const struct in6_addr *a)
381{ 396{
382 return ((a->s6_addr32[0] | a->s6_addr32[1] | 397 return (a->s6_addr32[0] | a->s6_addr32[1] |
383 a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0); 398 a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0;
384} 399}
385 400
386static inline int ipv6_addr_v4mapped(const struct in6_addr *a) 401static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
387{ 402{
388 return ((a->s6_addr32[0] | a->s6_addr32[1] | 403 return (a->s6_addr32[0] | a->s6_addr32[1] |
389 (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0); 404 (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0;
390} 405}
391 406
392/* 407/*
@@ -395,8 +410,7 @@ static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
395 */ 410 */
396static inline int ipv6_addr_orchid(const struct in6_addr *a) 411static inline int ipv6_addr_orchid(const struct in6_addr *a)
397{ 412{
398 return ((a->s6_addr32[0] & htonl(0xfffffff0)) 413 return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010);
399 == htonl(0x20010010));
400} 414}
401 415
402static inline void ipv6_addr_set_v4mapped(const __be32 addr, 416static inline void ipv6_addr_set_v4mapped(const __be32 addr,
@@ -441,7 +455,7 @@ static inline int __ipv6_addr_diff(const void *token1, const void *token2, int a
441 * if returned value is greater than prefix length. 455 * if returned value is greater than prefix length.
442 * --ANK (980803) 456 * --ANK (980803)
443 */ 457 */
444 return (addrlen << 5); 458 return addrlen << 5;
445} 459}
446 460
447static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2) 461static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2)
@@ -481,7 +495,7 @@ extern int ip6_rcv_finish(struct sk_buff *skb);
481 */ 495 */
482extern int ip6_xmit(struct sock *sk, 496extern int ip6_xmit(struct sock *sk,
483 struct sk_buff *skb, 497 struct sk_buff *skb,
484 struct flowi *fl, 498 struct flowi6 *fl6,
485 struct ipv6_txoptions *opt); 499 struct ipv6_txoptions *opt);
486 500
487extern int ip6_nd_hdr(struct sock *sk, 501extern int ip6_nd_hdr(struct sock *sk,
@@ -501,7 +515,7 @@ extern int ip6_append_data(struct sock *sk,
501 int hlimit, 515 int hlimit,
502 int tclass, 516 int tclass,
503 struct ipv6_txoptions *opt, 517 struct ipv6_txoptions *opt,
504 struct flowi *fl, 518 struct flowi6 *fl6,
505 struct rt6_info *rt, 519 struct rt6_info *rt,
506 unsigned int flags, 520 unsigned int flags,
507 int dontfrag); 521 int dontfrag);
@@ -512,13 +526,17 @@ extern void ip6_flush_pending_frames(struct sock *sk);
512 526
513extern int ip6_dst_lookup(struct sock *sk, 527extern int ip6_dst_lookup(struct sock *sk,
514 struct dst_entry **dst, 528 struct dst_entry **dst,
515 struct flowi *fl); 529 struct flowi6 *fl6);
516extern int ip6_dst_blackhole(struct sock *sk, 530extern struct dst_entry * ip6_dst_lookup_flow(struct sock *sk,
517 struct dst_entry **dst, 531 struct flowi6 *fl6,
518 struct flowi *fl); 532 const struct in6_addr *final_dst,
519extern int ip6_sk_dst_lookup(struct sock *sk, 533 bool can_sleep);
520 struct dst_entry **dst, 534extern struct dst_entry * ip6_sk_dst_lookup_flow(struct sock *sk,
521 struct flowi *fl); 535 struct flowi6 *fl6,
536 const struct in6_addr *final_dst,
537 bool can_sleep);
538extern struct dst_entry * ip6_blackhole_route(struct net *net,
539 struct dst_entry *orig_dst);
522 540
523/* 541/*
524 * skb processing functions 542 * skb processing functions
@@ -551,7 +569,7 @@ extern int ipv6_ext_hdr(u8 nexthdr);
551 569
552extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type); 570extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type);
553 571
554extern struct in6_addr *fl6_update_dst(struct flowi *fl, 572extern struct in6_addr *fl6_update_dst(struct flowi6 *fl6,
555 const struct ipv6_txoptions *opt, 573 const struct ipv6_txoptions *opt,
556 struct in6_addr *orig); 574 struct in6_addr *orig);
557 575
@@ -585,8 +603,8 @@ extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len);
585extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len); 603extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len);
586extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port, 604extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,
587 u32 info, u8 *payload); 605 u32 info, u8 *payload);
588extern void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info); 606extern void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info);
589extern void ipv6_local_rxpmtu(struct sock *sk, struct flowi *fl, u32 mtu); 607extern void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu);
590 608
591extern int inet6_release(struct socket *sock); 609extern int inet6_release(struct socket *sock);
592extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr, 610extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr,
@@ -652,5 +670,4 @@ extern int ipv6_static_sysctl_register(void);
652extern void ipv6_static_sysctl_unregister(void); 670extern void ipv6_static_sysctl_unregister(void);
653#endif 671#endif
654 672
655#endif /* __KERNEL__ */
656#endif /* _NET_IPV6_H */ 673#endif /* _NET_IPV6_H */
diff --git a/include/net/ipx.h b/include/net/ipx.h
index 05d7e4a88b49..c1fec6b464cc 100644
--- a/include/net/ipx.h
+++ b/include/net/ipx.h
@@ -80,7 +80,6 @@ struct ipx_route {
80 atomic_t refcnt; 80 atomic_t refcnt;
81}; 81};
82 82
83#ifdef __KERNEL__
84struct ipx_cb { 83struct ipx_cb {
85 u8 ipx_tctrl; 84 u8 ipx_tctrl;
86 __be32 ipx_dest_net; 85 __be32 ipx_dest_net;
@@ -116,7 +115,6 @@ static inline struct ipx_sock *ipx_sk(struct sock *sk)
116} 115}
117 116
118#define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0])) 117#define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0]))
119#endif
120 118
121#define IPX_MIN_EPHEMERAL_SOCKET 0x4000 119#define IPX_MIN_EPHEMERAL_SOCKET 0x4000
122#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff 120#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff
diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
index eea2e6152389..59ba38bc400f 100644
--- a/include/net/irda/ircomm_tty.h
+++ b/include/net/irda/ircomm_tty.h
@@ -120,10 +120,10 @@ struct ircomm_tty_cb {
120void ircomm_tty_start(struct tty_struct *tty); 120void ircomm_tty_start(struct tty_struct *tty);
121void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self); 121void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self);
122 122
123extern int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file); 123extern int ircomm_tty_tiocmget(struct tty_struct *tty);
124extern int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file, 124extern int ircomm_tty_tiocmset(struct tty_struct *tty,
125 unsigned int set, unsigned int clear); 125 unsigned int set, unsigned int clear);
126extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, 126extern int ircomm_tty_ioctl(struct tty_struct *tty,
127 unsigned int cmd, unsigned long arg); 127 unsigned int cmd, unsigned long arg);
128extern void ircomm_tty_set_termios(struct tty_struct *tty, 128extern void ircomm_tty_set_termios(struct tty_struct *tty,
129 struct ktermios *old_termios); 129 struct ktermios *old_termios);
diff --git a/include/net/irda/irlan_common.h b/include/net/irda/irlan_common.h
index 73cacb3ac16c..0af8b8dfbc22 100644
--- a/include/net/irda/irlan_common.h
+++ b/include/net/irda/irlan_common.h
@@ -171,7 +171,6 @@ struct irlan_cb {
171 int magic; 171 int magic;
172 struct list_head dev_list; 172 struct list_head dev_list;
173 struct net_device *dev; /* Ethernet device structure*/ 173 struct net_device *dev; /* Ethernet device structure*/
174 struct net_device_stats stats;
175 174
176 __u32 saddr; /* Source device address */ 175 __u32 saddr; /* Source device address */
177 __u32 daddr; /* Destination device address */ 176 __u32 daddr; /* Destination device address */
diff --git a/include/net/irda/irlan_event.h b/include/net/irda/irlan_event.h
index 6d9539f05806..018b5a77e610 100644
--- a/include/net/irda/irlan_event.h
+++ b/include/net/irda/irlan_event.h
@@ -67,7 +67,7 @@ typedef enum {
67 IRLAN_WATCHDOG_TIMEOUT, 67 IRLAN_WATCHDOG_TIMEOUT,
68} IRLAN_EVENT; 68} IRLAN_EVENT;
69 69
70extern char *irlan_state[]; 70extern const char * const irlan_state[];
71 71
72void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event, 72void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event,
73 struct sk_buff *skb); 73 struct sk_buff *skb);
diff --git a/include/net/irda/irlap.h b/include/net/irda/irlap.h
index 9d0c78ea92f5..fb4b76d5d7f1 100644
--- a/include/net/irda/irlap.h
+++ b/include/net/irda/irlap.h
@@ -204,7 +204,7 @@ struct irlap_cb {
204 204
205 notify_t notify; /* Callbacks to IrLMP */ 205 notify_t notify; /* Callbacks to IrLMP */
206 206
207 int mtt_required; /* Minumum turnaround time required */ 207 int mtt_required; /* Minimum turnaround time required */
208 int xbofs_delay; /* Nr of XBOF's used to MTT */ 208 int xbofs_delay; /* Nr of XBOF's used to MTT */
209 int bofs_count; /* Negotiated extra BOFs */ 209 int bofs_count; /* Negotiated extra BOFs */
210 int next_bofs; /* Negotiated extra BOFs after next frame */ 210 int next_bofs; /* Negotiated extra BOFs after next frame */
@@ -282,7 +282,7 @@ static inline int irlap_is_primary(struct irlap_cb *self)
282 default: 282 default:
283 ret = -1; 283 ret = -1;
284 } 284 }
285 return(ret); 285 return ret;
286} 286}
287 287
288/* Clear a pending IrLAP disconnect. - Jean II */ 288/* Clear a pending IrLAP disconnect. - Jean II */
diff --git a/include/net/irda/irlmp.h b/include/net/irda/irlmp.h
index 3ffc1d0f93d6..fff11b7fe8a4 100644
--- a/include/net/irda/irlmp.h
+++ b/include/net/irda/irlmp.h
@@ -274,7 +274,7 @@ static inline int irlmp_lap_tx_queue_full(struct lsap_cb *self)
274 if (self->lap->irlap == NULL) 274 if (self->lap->irlap == NULL)
275 return 0; 275 return 0;
276 276
277 return(IRLAP_GET_TX_QUEUE_LEN(self->lap->irlap) >= LAP_HIGH_THRESHOLD); 277 return IRLAP_GET_TX_QUEUE_LEN(self->lap->irlap) >= LAP_HIGH_THRESHOLD;
278} 278}
279 279
280/* After doing a irlmp_dup(), this get one of the two socket back into 280/* After doing a irlmp_dup(), this get one of the two socket back into
diff --git a/include/net/irda/irttp.h b/include/net/irda/irttp.h
index 11aee7a2972a..af4b87721d13 100644
--- a/include/net/irda/irttp.h
+++ b/include/net/irda/irttp.h
@@ -204,7 +204,7 @@ static inline int irttp_is_primary(struct tsap_cb *self)
204 (self->lsap->lap == NULL) || 204 (self->lsap->lap == NULL) ||
205 (self->lsap->lap->irlap == NULL)) 205 (self->lsap->lap->irlap == NULL))
206 return -2; 206 return -2;
207 return(irlap_is_primary(self->lsap->lap->irlap)); 207 return irlap_is_primary(self->lsap->lap->irlap);
208} 208}
209 209
210#endif /* IRTTP_H */ 210#endif /* IRTTP_H */
diff --git a/include/net/irda/wrapper.h b/include/net/irda/wrapper.h
index 2942ad6ab932..eef53ebe3d76 100644
--- a/include/net/irda/wrapper.h
+++ b/include/net/irda/wrapper.h
@@ -42,7 +42,7 @@
42 42
43#define IRDA_TRANS 0x20 /* Asynchronous transparency modifier */ 43#define IRDA_TRANS 0x20 /* Asynchronous transparency modifier */
44 44
45/* States for receving a frame in async mode */ 45/* States for receiving a frame in async mode */
46enum { 46enum {
47 OUTSIDE_FRAME, 47 OUTSIDE_FRAME,
48 BEGIN_FRAME, 48 BEGIN_FRAME,
diff --git a/include/net/iucv/iucv.h b/include/net/iucv/iucv.h
index 205a3360156e..1121baa9f695 100644
--- a/include/net/iucv/iucv.h
+++ b/include/net/iucv/iucv.h
@@ -173,7 +173,7 @@ struct iucv_handler {
173 /* 173 /*
174 * The message_pending function is called after an icuv interrupt 174 * The message_pending function is called after an icuv interrupt
175 * type 0x06 or type 0x07 has been received. A new message is 175 * type 0x06 or type 0x07 has been received. A new message is
176 * availabe and can be received with iucv_message_receive. 176 * available and can be received with iucv_message_receive.
177 */ 177 */
178 void (*message_pending)(struct iucv_path *, struct iucv_message *); 178 void (*message_pending)(struct iucv_path *, struct iucv_message *);
179 /* 179 /*
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index 3afdb21cc31d..5d5a6a4732ef 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -91,7 +91,7 @@
91 * -------------------- 91 * --------------------
92 * The implementation goals were as follow : 92 * The implementation goals were as follow :
93 * o Obvious : you should not need a PhD to understand what's happening, 93 * o Obvious : you should not need a PhD to understand what's happening,
94 * the benefit is easier maintainance. 94 * the benefit is easier maintenance.
95 * o Flexible : it should accommodate a wide variety of driver 95 * o Flexible : it should accommodate a wide variety of driver
96 * implementations and be as flexible as the old API. 96 * implementations and be as flexible as the old API.
97 * o Lean : it should be efficient memory wise to minimise the impact 97 * o Lean : it should be efficient memory wise to minimise the impact
@@ -129,7 +129,7 @@
129 * 129 *
130 * Functions prototype uses union iwreq_data 130 * Functions prototype uses union iwreq_data
131 * ----------------------------------------- 131 * -----------------------------------------
132 * Some would have prefered functions defined this way : 132 * Some would have preferred functions defined this way :
133 * static int mydriver_ioctl_setrate(struct net_device *dev, 133 * static int mydriver_ioctl_setrate(struct net_device *dev,
134 * long rate, int auto) 134 * long rate, int auto)
135 * 1) The kernel code doesn't "validate" the content of iwreq_data, and 135 * 1) The kernel code doesn't "validate" the content of iwreq_data, and
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h
index 75b8e2968c9b..f57e7d46a453 100644
--- a/include/net/llc_pdu.h
+++ b/include/net/llc_pdu.h
@@ -199,7 +199,7 @@ struct llc_pdu_sn {
199 u8 ssap; 199 u8 ssap;
200 u8 ctrl_1; 200 u8 ctrl_1;
201 u8 ctrl_2; 201 u8 ctrl_2;
202}; 202} __packed;
203 203
204static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb) 204static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb)
205{ 205{
@@ -211,7 +211,7 @@ struct llc_pdu_un {
211 u8 dsap; 211 u8 dsap;
212 u8 ssap; 212 u8 ssap;
213 u8 ctrl_1; 213 u8 ctrl_1;
214}; 214} __packed;
215 215
216static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb) 216static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb)
217{ 217{
@@ -359,7 +359,7 @@ struct llc_xid_info {
359 u8 fmt_id; /* always 0x81 for LLC */ 359 u8 fmt_id; /* always 0x81 for LLC */
360 u8 type; /* different if NULL/non-NULL LSAP */ 360 u8 type; /* different if NULL/non-NULL LSAP */
361 u8 rw; /* sender receive window */ 361 u8 rw; /* sender receive window */
362}; 362} __packed;
363 363
364/** 364/**
365 * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID 365 * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID
@@ -415,7 +415,7 @@ struct llc_frmr_info {
415 u8 curr_ssv; /* current send state variable val */ 415 u8 curr_ssv; /* current send state variable val */
416 u8 curr_rsv; /* current receive state variable */ 416 u8 curr_rsv; /* current receive state variable */
417 u8 ind_bits; /* indicator bits set with macro */ 417 u8 ind_bits; /* indicator bits set with macro */
418}; 418} __packed;
419 419
420extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type); 420extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type);
421extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value); 421extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value);
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index b0787a1dea90..e6d6a66a8f71 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -97,6 +97,20 @@ enum ieee80211_max_queues {
97}; 97};
98 98
99/** 99/**
100 * enum ieee80211_ac_numbers - AC numbers as used in mac80211
101 * @IEEE80211_AC_VO: voice
102 * @IEEE80211_AC_VI: video
103 * @IEEE80211_AC_BE: best effort
104 * @IEEE80211_AC_BK: background
105 */
106enum ieee80211_ac_numbers {
107 IEEE80211_AC_VO = 0,
108 IEEE80211_AC_VI = 1,
109 IEEE80211_AC_BE = 2,
110 IEEE80211_AC_BK = 3,
111};
112
113/**
100 * struct ieee80211_tx_queue_params - transmit queue configuration 114 * struct ieee80211_tx_queue_params - transmit queue configuration
101 * 115 *
102 * The information provided in this structure is required for QoS 116 * The information provided in this structure is required for QoS
@@ -149,6 +163,7 @@ struct ieee80211_low_level_stats {
149 * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed. 163 * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed.
150 * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note 164 * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note
151 * that it is only ever disabled for station mode. 165 * that it is only ever disabled for station mode.
166 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
152 */ 167 */
153enum ieee80211_bss_change { 168enum ieee80211_bss_change {
154 BSS_CHANGED_ASSOC = 1<<0, 169 BSS_CHANGED_ASSOC = 1<<0,
@@ -165,6 +180,7 @@ enum ieee80211_bss_change {
165 BSS_CHANGED_IBSS = 1<<11, 180 BSS_CHANGED_IBSS = 1<<11,
166 BSS_CHANGED_ARP_FILTER = 1<<12, 181 BSS_CHANGED_ARP_FILTER = 1<<12,
167 BSS_CHANGED_QOS = 1<<13, 182 BSS_CHANGED_QOS = 1<<13,
183 BSS_CHANGED_IDLE = 1<<14,
168 184
169 /* when adding here, make sure to change ieee80211_reconfig */ 185 /* when adding here, make sure to change ieee80211_reconfig */
170}; 186};
@@ -203,6 +219,7 @@ enum ieee80211_bss_change {
203 * @basic_rates: bitmap of basic rates, each bit stands for an 219 * @basic_rates: bitmap of basic rates, each bit stands for an
204 * index into the rate table configured by the driver in 220 * index into the rate table configured by the driver in
205 * the current band. 221 * the current band.
222 * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
206 * @bssid: The BSSID for this BSS 223 * @bssid: The BSSID for this BSS
207 * @enable_beacon: whether beaconing should be enabled or not 224 * @enable_beacon: whether beaconing should be enabled or not
208 * @channel_type: Channel type for this BSS -- the hardware might be 225 * @channel_type: Channel type for this BSS -- the hardware might be
@@ -223,6 +240,9 @@ enum ieee80211_bss_change {
223 * hardware must not perform any ARP filtering. Note, that the filter will 240 * hardware must not perform any ARP filtering. Note, that the filter will
224 * be enabled also in promiscuous mode. 241 * be enabled also in promiscuous mode.
225 * @qos: This is a QoS-enabled BSS. 242 * @qos: This is a QoS-enabled BSS.
243 * @idle: This interface is idle. There's also a global idle flag in the
244 * hardware config which may be more appropriate depending on what
245 * your driver/device needs to do.
226 */ 246 */
227struct ieee80211_bss_conf { 247struct ieee80211_bss_conf {
228 const u8 *bssid; 248 const u8 *bssid;
@@ -239,6 +259,7 @@ struct ieee80211_bss_conf {
239 u16 assoc_capability; 259 u16 assoc_capability;
240 u64 timestamp; 260 u64 timestamp;
241 u32 basic_rates; 261 u32 basic_rates;
262 int mcast_rate[IEEE80211_NUM_BANDS];
242 u16 ht_operation_mode; 263 u16 ht_operation_mode;
243 s32 cqm_rssi_thold; 264 s32 cqm_rssi_thold;
244 u32 cqm_rssi_hyst; 265 u32 cqm_rssi_hyst;
@@ -247,6 +268,7 @@ struct ieee80211_bss_conf {
247 u8 arp_addr_cnt; 268 u8 arp_addr_cnt;
248 bool arp_filter_enabled; 269 bool arp_filter_enabled;
249 bool qos; 270 bool qos;
271 bool idle;
250}; 272};
251 273
252/** 274/**
@@ -315,6 +337,16 @@ struct ieee80211_bss_conf {
315 * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame 337 * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame
316 * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this 338 * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this
317 * frame and selects the maximum number of streams that it can use. 339 * frame and selects the maximum number of streams that it can use.
340 * @IEEE80211_TX_CTL_TX_OFFCHAN: Marks this packet to be transmitted on
341 * the off-channel channel when a remain-on-channel offload is done
342 * in hardware -- normal packets still flow and are expected to be
343 * handled properly by the device.
344 * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP
345 * testing. It will be sent out with incorrect Michael MIC key to allow
346 * TKIP countermeasures to be tested.
347 *
348 * Note: If you have to add new flags to the enumeration, then don't
349 * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
318 */ 350 */
319enum mac80211_tx_control_flags { 351enum mac80211_tx_control_flags {
320 IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0), 352 IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0),
@@ -340,10 +372,25 @@ enum mac80211_tx_control_flags {
340 IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21), 372 IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21),
341 IEEE80211_TX_CTL_LDPC = BIT(22), 373 IEEE80211_TX_CTL_LDPC = BIT(22),
342 IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24), 374 IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24),
375 IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25),
376 IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26),
343}; 377};
344 378
345#define IEEE80211_TX_CTL_STBC_SHIFT 23 379#define IEEE80211_TX_CTL_STBC_SHIFT 23
346 380
381/*
382 * This definition is used as a mask to clear all temporary flags, which are
383 * set by the tx handlers for each transmission attempt by the mac80211 stack.
384 */
385#define IEEE80211_TX_TEMPORARY_FLAGS (IEEE80211_TX_CTL_NO_ACK | \
386 IEEE80211_TX_CTL_CLEAR_PS_FILT | IEEE80211_TX_CTL_FIRST_FRAGMENT | \
387 IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \
388 IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \
389 IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \
390 IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_PSPOLL_RESPONSE | \
391 IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \
392 IEEE80211_TX_CTL_STBC)
393
347/** 394/**
348 * enum mac80211_rate_control_flags - per-rate flags set by the 395 * enum mac80211_rate_control_flags - per-rate flags set by the
349 * Rate Control algorithm. 396 * Rate Control algorithm.
@@ -490,6 +537,21 @@ struct ieee80211_tx_info {
490 }; 537 };
491}; 538};
492 539
540/**
541 * struct ieee80211_sched_scan_ies - scheduled scan IEs
542 *
543 * This structure is used to pass the appropriate IEs to be used in scheduled
544 * scans for all bands. It contains both the IEs passed from the userspace
545 * and the ones generated by mac80211.
546 *
547 * @ie: array with the IEs for each supported band
548 * @len: array with the total length of the IEs for each band
549 */
550struct ieee80211_sched_scan_ies {
551 u8 *ie[IEEE80211_NUM_BANDS];
552 size_t len[IEEE80211_NUM_BANDS];
553};
554
493static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb) 555static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb)
494{ 556{
495 return (struct ieee80211_tx_info *)skb->cb; 557 return (struct ieee80211_tx_info *)skb->cb;
@@ -552,16 +614,14 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
552 * the frame. 614 * the frame.
553 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on 615 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
554 * the frame. 616 * the frame.
555 * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field) 617 * @RX_FLAG_MACTIME_MPDU: The timestamp passed in the RX status (@mactime
556 * is valid. This is useful in monitor mode and necessary for beacon frames 618 * field) is valid and contains the time the first symbol of the MPDU
557 * to enable IBSS merging. 619 * was received. This is useful in monitor mode and for proper IBSS
620 * merging.
558 * @RX_FLAG_SHORTPRE: Short preamble was used for this frame 621 * @RX_FLAG_SHORTPRE: Short preamble was used for this frame
559 * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index 622 * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index
560 * @RX_FLAG_40MHZ: HT40 (40 MHz) was used 623 * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
561 * @RX_FLAG_SHORT_GI: Short guard interval was used 624 * @RX_FLAG_SHORT_GI: Short guard interval was used
562 * @RX_FLAG_INTERNAL_CMTR: set internally after frame was reported
563 * on cooked monitor to avoid double-reporting it for multiple
564 * virtual interfaces
565 */ 625 */
566enum mac80211_rx_flags { 626enum mac80211_rx_flags {
567 RX_FLAG_MMIC_ERROR = 1<<0, 627 RX_FLAG_MMIC_ERROR = 1<<0,
@@ -570,12 +630,11 @@ enum mac80211_rx_flags {
570 RX_FLAG_IV_STRIPPED = 1<<4, 630 RX_FLAG_IV_STRIPPED = 1<<4,
571 RX_FLAG_FAILED_FCS_CRC = 1<<5, 631 RX_FLAG_FAILED_FCS_CRC = 1<<5,
572 RX_FLAG_FAILED_PLCP_CRC = 1<<6, 632 RX_FLAG_FAILED_PLCP_CRC = 1<<6,
573 RX_FLAG_TSFT = 1<<7, 633 RX_FLAG_MACTIME_MPDU = 1<<7,
574 RX_FLAG_SHORTPRE = 1<<8, 634 RX_FLAG_SHORTPRE = 1<<8,
575 RX_FLAG_HT = 1<<9, 635 RX_FLAG_HT = 1<<9,
576 RX_FLAG_40MHZ = 1<<10, 636 RX_FLAG_40MHZ = 1<<10,
577 RX_FLAG_SHORT_GI = 1<<11, 637 RX_FLAG_SHORT_GI = 1<<11,
578 RX_FLAG_INTERNAL_CMTR = 1<<12,
579}; 638};
580 639
581/** 640/**
@@ -596,6 +655,7 @@ enum mac80211_rx_flags {
596 * @rate_idx: index of data rate into band's supported rates or MCS index if 655 * @rate_idx: index of data rate into band's supported rates or MCS index if
597 * HT rates are use (RX_FLAG_HT) 656 * HT rates are use (RX_FLAG_HT)
598 * @flag: %RX_FLAG_* 657 * @flag: %RX_FLAG_*
658 * @rx_flags: internal RX flags for mac80211
599 */ 659 */
600struct ieee80211_rx_status { 660struct ieee80211_rx_status {
601 u64 mactime; 661 u64 mactime;
@@ -605,6 +665,7 @@ struct ieee80211_rx_status {
605 int antenna; 665 int antenna;
606 int rate_idx; 666 int rate_idx;
607 int flag; 667 int flag;
668 unsigned int rx_flags;
608}; 669};
609 670
610/** 671/**
@@ -763,6 +824,8 @@ struct ieee80211_channel_switch {
763 * @bss_conf: BSS configuration for this interface, either our own 824 * @bss_conf: BSS configuration for this interface, either our own
764 * or the BSS we're associated to 825 * or the BSS we're associated to
765 * @addr: address of this interface 826 * @addr: address of this interface
827 * @p2p: indicates whether this AP or STA interface is a p2p
828 * interface, i.e. a GO or p2p-sta respectively
766 * @drv_priv: data area for driver use, will always be aligned to 829 * @drv_priv: data area for driver use, will always be aligned to
767 * sizeof(void *). 830 * sizeof(void *).
768 */ 831 */
@@ -770,6 +833,7 @@ struct ieee80211_vif {
770 enum nl80211_iftype type; 833 enum nl80211_iftype type;
771 struct ieee80211_bss_conf bss_conf; 834 struct ieee80211_bss_conf bss_conf;
772 u8 addr[ETH_ALEN]; 835 u8 addr[ETH_ALEN];
836 bool p2p;
773 /* must be last */ 837 /* must be last */
774 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); 838 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
775}; 839};
@@ -783,20 +847,6 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
783} 847}
784 848
785/** 849/**
786 * enum ieee80211_key_alg - key algorithm
787 * @ALG_WEP: WEP40 or WEP104
788 * @ALG_TKIP: TKIP
789 * @ALG_CCMP: CCMP (AES)
790 * @ALG_AES_CMAC: AES-128-CMAC
791 */
792enum ieee80211_key_alg {
793 ALG_WEP,
794 ALG_TKIP,
795 ALG_CCMP,
796 ALG_AES_CMAC,
797};
798
799/**
800 * enum ieee80211_key_flags - key flags 850 * enum ieee80211_key_flags - key flags
801 * 851 *
802 * These flags are used for communication about keys between the driver 852 * These flags are used for communication about keys between the driver
@@ -833,7 +883,7 @@ enum ieee80211_key_flags {
833 * @hw_key_idx: To be set by the driver, this is the key index the driver 883 * @hw_key_idx: To be set by the driver, this is the key index the driver
834 * wants to be given when a frame is transmitted and needs to be 884 * wants to be given when a frame is transmitted and needs to be
835 * encrypted in hardware. 885 * encrypted in hardware.
836 * @alg: The key algorithm. 886 * @cipher: The key's cipher suite selector.
837 * @flags: key flags, see &enum ieee80211_key_flags. 887 * @flags: key flags, see &enum ieee80211_key_flags.
838 * @keyidx: the key index (0-3) 888 * @keyidx: the key index (0-3)
839 * @keylen: key material length 889 * @keylen: key material length
@@ -846,7 +896,7 @@ enum ieee80211_key_flags {
846 * @iv_len: The IV length for this key type 896 * @iv_len: The IV length for this key type
847 */ 897 */
848struct ieee80211_key_conf { 898struct ieee80211_key_conf {
849 enum ieee80211_key_alg alg; 899 u32 cipher;
850 u8 icv_len; 900 u8 icv_len;
851 u8 iv_len; 901 u8 iv_len;
852 u8 hw_key_idx; 902 u8 hw_key_idx;
@@ -1032,6 +1082,20 @@ enum ieee80211_tkip_key_type {
1032 * @IEEE80211_HW_NEED_DTIM_PERIOD: 1082 * @IEEE80211_HW_NEED_DTIM_PERIOD:
1033 * This device needs to know the DTIM period for the BSS before 1083 * This device needs to know the DTIM period for the BSS before
1034 * associating. 1084 * associating.
1085 *
1086 * @IEEE80211_HW_SUPPORTS_PER_STA_GTK: The device's crypto engine supports
1087 * per-station GTKs as used by IBSS RSN or during fast transition. If
1088 * the device doesn't support per-station GTKs, but can be asked not
1089 * to decrypt group addressed frames, then IBSS RSN support is still
1090 * possible but software crypto will be used. Advertise the wiphy flag
1091 * only in that case.
1092 *
1093 * @IEEE80211_HW_AP_LINK_PS: When operating in AP mode the device
1094 * autonomously manages the PS status of connected stations. When
1095 * this flag is set mac80211 will not trigger PS mode for connected
1096 * stations based on the PM bit of incoming frames.
1097 * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure
1098 * the PS mode of connected stations.
1035 */ 1099 */
1036enum ieee80211_hw_flags { 1100enum ieee80211_hw_flags {
1037 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, 1101 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0,
@@ -1055,6 +1119,8 @@ enum ieee80211_hw_flags {
1055 IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, 1119 IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18,
1056 IEEE80211_HW_CONNECTION_MONITOR = 1<<19, 1120 IEEE80211_HW_CONNECTION_MONITOR = 1<<19,
1057 IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, 1121 IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20,
1122 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21,
1123 IEEE80211_HW_AP_LINK_PS = 1<<22,
1058}; 1124};
1059 1125
1060/** 1126/**
@@ -1100,8 +1166,26 @@ enum ieee80211_hw_flags {
1100 * @sta_data_size: size (in bytes) of the drv_priv data area 1166 * @sta_data_size: size (in bytes) of the drv_priv data area
1101 * within &struct ieee80211_sta. 1167 * within &struct ieee80211_sta.
1102 * 1168 *
1103 * @max_rates: maximum number of alternate rate retry stages 1169 * @max_rates: maximum number of alternate rate retry stages the hw
1170 * can handle.
1171 * @max_report_rates: maximum number of alternate rate retry stages
1172 * the hw can report back.
1104 * @max_rate_tries: maximum number of tries for each stage 1173 * @max_rate_tries: maximum number of tries for each stage
1174 *
1175 * @napi_weight: weight used for NAPI polling. You must specify an
1176 * appropriate value here if a napi_poll operation is provided
1177 * by your driver.
1178 *
1179 * @max_rx_aggregation_subframes: maximum buffer size (number of
1180 * sub-frames) to be used for A-MPDU block ack receiver
1181 * aggregation.
1182 * This is only relevant if the device has restrictions on the
1183 * number of subframes, if it relies on mac80211 to do reordering
1184 * it shouldn't be set.
1185 *
1186 * @max_tx_aggregation_subframes: maximum number of subframes in an
1187 * aggregate an HT driver will transmit, used by the peer as a
1188 * hint to size its reorder buffer.
1105 */ 1189 */
1106struct ieee80211_hw { 1190struct ieee80211_hw {
1107 struct ieee80211_conf conf; 1191 struct ieee80211_conf conf;
@@ -1113,11 +1197,15 @@ struct ieee80211_hw {
1113 int channel_change_time; 1197 int channel_change_time;
1114 int vif_data_size; 1198 int vif_data_size;
1115 int sta_data_size; 1199 int sta_data_size;
1200 int napi_weight;
1116 u16 queues; 1201 u16 queues;
1117 u16 max_listen_interval; 1202 u16 max_listen_interval;
1118 s8 max_signal; 1203 s8 max_signal;
1119 u8 max_rates; 1204 u8 max_rates;
1205 u8 max_report_rates;
1120 u8 max_rate_tries; 1206 u8 max_rate_tries;
1207 u8 max_rx_aggregation_subframes;
1208 u8 max_tx_aggregation_subframes;
1121}; 1209};
1122 1210
1123/** 1211/**
@@ -1221,7 +1309,7 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
1221 * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key 1309 * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
1222 * handler. 1310 * handler.
1223 * The update_tkip_key() call updates the driver with the new phase 1 key. 1311 * The update_tkip_key() call updates the driver with the new phase 1 key.
1224 * This happens everytime the iv16 wraps around (every 65536 packets). The 1312 * This happens every time the iv16 wraps around (every 65536 packets). The
1225 * set_key() call will happen only once for each key (unless the AP did 1313 * set_key() call will happen only once for each key (unless the AP did
1226 * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is 1314 * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
1227 * provided by update_tkip_key only. The trigger that makes mac80211 call this 1315 * provided by update_tkip_key only. The trigger that makes mac80211 call this
@@ -1245,8 +1333,8 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
1245 * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in 1333 * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in
1246 * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused 1334 * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused
1247 * with hardware wakeup and sleep states. Driver is responsible for waking 1335 * with hardware wakeup and sleep states. Driver is responsible for waking
1248 * up the hardware before issueing commands to the hardware and putting it 1336 * up the hardware before issuing commands to the hardware and putting it
1249 * back to sleep at approriate times. 1337 * back to sleep at appropriate times.
1250 * 1338 *
1251 * When PS is enabled, hardware needs to wakeup for beacons and receive the 1339 * When PS is enabled, hardware needs to wakeup for beacons and receive the
1252 * buffered multicast/broadcast frames after the beacon. Also it must be 1340 * buffered multicast/broadcast frames after the beacon. Also it must be
@@ -1267,7 +1355,7 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
1267 * there's data traffic and still saving significantly power in idle 1355 * there's data traffic and still saving significantly power in idle
1268 * periods. 1356 * periods.
1269 * 1357 *
1270 * Dynamic powersave is supported by simply mac80211 enabling and disabling 1358 * Dynamic powersave is simply supported by mac80211 enabling and disabling
1271 * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS 1359 * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS
1272 * flag and mac80211 will handle everything automatically. Additionally, 1360 * flag and mac80211 will handle everything automatically. Additionally,
1273 * hardware having support for the dynamic PS feature may set the 1361 * hardware having support for the dynamic PS feature may set the
@@ -1452,12 +1540,14 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
1452 * honour this flag if possible. 1540 * honour this flag if possible.
1453 * 1541 *
1454 * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS 1542 * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS
1455 * is not set then only those addressed to this station. 1543 * is not set then only those addressed to this station.
1456 * 1544 *
1457 * @FIF_OTHER_BSS: pass frames destined to other BSSes 1545 * @FIF_OTHER_BSS: pass frames destined to other BSSes
1458 * 1546 *
1459 * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS is not set then only 1547 * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS is not set then only
1460 * those addressed to this station. 1548 * those addressed to this station.
1549 *
1550 * @FIF_PROBE_REQ: pass probe request frames
1461 */ 1551 */
1462enum ieee80211_filter_flags { 1552enum ieee80211_filter_flags {
1463 FIF_PROMISC_IN_BSS = 1<<0, 1553 FIF_PROMISC_IN_BSS = 1<<0,
@@ -1468,6 +1558,7 @@ enum ieee80211_filter_flags {
1468 FIF_CONTROL = 1<<5, 1558 FIF_CONTROL = 1<<5,
1469 FIF_OTHER_BSS = 1<<6, 1559 FIF_OTHER_BSS = 1<<6,
1470 FIF_PSPOLL = 1<<7, 1560 FIF_PSPOLL = 1<<7,
1561 FIF_PROBE_REQ = 1<<8,
1471}; 1562};
1472 1563
1473/** 1564/**
@@ -1530,6 +1621,18 @@ enum ieee80211_ampdu_mlme_action {
1530 * you should ensure to cancel it on this callback. 1621 * you should ensure to cancel it on this callback.
1531 * Must be implemented and can sleep. 1622 * Must be implemented and can sleep.
1532 * 1623 *
1624 * @suspend: Suspend the device; mac80211 itself will quiesce before and
1625 * stop transmitting and doing any other configuration, and then
1626 * ask the device to suspend. This is only invoked when WoWLAN is
1627 * configured, otherwise the device is deconfigured completely and
1628 * reconfigured at resume time.
1629 *
1630 * @resume: If WoWLAN was configured, this indicates that mac80211 is
1631 * now resuming its operation, after this the device must be fully
1632 * functional again. If this returns an error, the only way out is
1633 * to also unregister the device. If it returns 1, then mac80211
1634 * will also go through the regular complete restart on resume.
1635 *
1533 * @add_interface: Called when a netdevice attached to the hardware is 1636 * @add_interface: Called when a netdevice attached to the hardware is
1534 * enabled. Because it is not called for monitor mode devices, @start 1637 * enabled. Because it is not called for monitor mode devices, @start
1535 * and @stop must be implemented. 1638 * and @stop must be implemented.
@@ -1540,6 +1643,12 @@ enum ieee80211_ampdu_mlme_action {
1540 * negative error code (which will be seen in userspace.) 1643 * negative error code (which will be seen in userspace.)
1541 * Must be implemented and can sleep. 1644 * Must be implemented and can sleep.
1542 * 1645 *
1646 * @change_interface: Called when a netdevice changes type. This callback
1647 * is optional, but only if it is supported can interface types be
1648 * switched while the interface is UP. The callback may sleep.
1649 * Note that while an interface is being switched, it will not be
1650 * found by the interface iteration callbacks.
1651 *
1543 * @remove_interface: Notifies a driver that an interface is going down. 1652 * @remove_interface: Notifies a driver that an interface is going down.
1544 * The @stop callback is called after this if it is the last interface 1653 * The @stop callback is called after this if it is the last interface
1545 * and no monitor interfaces are present. 1654 * and no monitor interfaces are present.
@@ -1599,6 +1708,13 @@ enum ieee80211_ampdu_mlme_action {
1599 * any error unless this callback returned a negative error code. 1708 * any error unless this callback returned a negative error code.
1600 * The callback can sleep. 1709 * The callback can sleep.
1601 * 1710 *
1711 * @sched_scan_start: Ask the hardware to start scanning repeatedly at
1712 * specific intervals. The driver must call the
1713 * ieee80211_sched_scan_results() function whenever it finds results.
1714 * This process will continue until sched_scan_stop is called.
1715 *
1716 * @sched_scan_stop: Tell the hardware to stop an ongoing scheduled scan.
1717 *
1602 * @sw_scan_start: Notifier function that is called just before a software scan 1718 * @sw_scan_start: Notifier function that is called just before a software scan
1603 * is started. Can be NULL, if the driver doesn't need this notification. 1719 * is started. Can be NULL, if the driver doesn't need this notification.
1604 * The callback can sleep. 1720 * The callback can sleep.
@@ -1617,6 +1733,11 @@ enum ieee80211_ampdu_mlme_action {
1617 * and IV16) for the given key from hardware. 1733 * and IV16) for the given key from hardware.
1618 * The callback must be atomic. 1734 * The callback must be atomic.
1619 * 1735 *
1736 * @set_frag_threshold: Configuration of fragmentation threshold. Assign this
1737 * if the device does fragmentation by itself; if this callback is
1738 * implemented then the stack will not do fragmentation.
1739 * The callback can sleep.
1740 *
1620 * @set_rts_threshold: Configuration of RTS threshold (if device needs it) 1741 * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
1621 * The callback can sleep. 1742 * The callback can sleep.
1622 * 1743 *
@@ -1627,7 +1748,9 @@ enum ieee80211_ampdu_mlme_action {
1627 * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep. 1748 * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep.
1628 * 1749 *
1629 * @sta_notify: Notifies low level driver about power state transition of an 1750 * @sta_notify: Notifies low level driver about power state transition of an
1630 * associated station, AP, IBSS/WDS/mesh peer etc. Must be atomic. 1751 * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating
1752 * in AP mode, this callback will not be called when the flag
1753 * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic.
1631 * 1754 *
1632 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), 1755 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
1633 * bursting) for a hardware TX queue. 1756 * bursting) for a hardware TX queue.
@@ -1662,6 +1785,21 @@ enum ieee80211_ampdu_mlme_action {
1662 * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) 1785 * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
1663 * is the first frame we expect to perform the action on. Notice 1786 * is the first frame we expect to perform the action on. Notice
1664 * that TX/RX_STOP can pass NULL for this parameter. 1787 * that TX/RX_STOP can pass NULL for this parameter.
1788 * The @buf_size parameter is only valid when the action is set to
1789 * %IEEE80211_AMPDU_TX_OPERATIONAL and indicates the peer's reorder
1790 * buffer size (number of subframes) for this session -- the driver
1791 * may neither send aggregates containing more subframes than this
1792 * nor send aggregates in a way that lost frames would exceed the
1793 * buffer size. If just limiting the aggregate size, this would be
1794 * possible with a buf_size of 8:
1795 * - TX: 1.....7
1796 * - RX: 2....7 (lost frame #1)
1797 * - TX: 8..1...
1798 * which is invalid since #1 was now re-transmitted well past the
1799 * buffer size of 8. Correct ways to retransmit #1 would be:
1800 * - TX: 1 or 18 or 81
1801 * Even "189" would be wrong since 1 could be lost again.
1802 *
1665 * Returns a negative error code on failure. 1803 * Returns a negative error code on failure.
1666 * The callback can sleep. 1804 * The callback can sleep.
1667 * 1805 *
@@ -1687,13 +1825,55 @@ enum ieee80211_ampdu_mlme_action {
1687 * switch operation for CSAs received from the AP may implement this 1825 * switch operation for CSAs received from the AP may implement this
1688 * callback. They must then call ieee80211_chswitch_done() to indicate 1826 * callback. They must then call ieee80211_chswitch_done() to indicate
1689 * completion of the channel switch. 1827 * completion of the channel switch.
1828 *
1829 * @napi_poll: Poll Rx queue for incoming data frames.
1830 *
1831 * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
1832 * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
1833 * reject TX/RX mask combinations they cannot support by returning -EINVAL
1834 * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
1835 *
1836 * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
1837 *
1838 * @remain_on_channel: Starts an off-channel period on the given channel, must
1839 * call back to ieee80211_ready_on_channel() when on that channel. Note
1840 * that normal channel traffic is not stopped as this is intended for hw
1841 * offload. Frames to transmit on the off-channel channel are transmitted
1842 * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the
1843 * duration (which will always be non-zero) expires, the driver must call
1844 * ieee80211_remain_on_channel_expired(). This callback may sleep.
1845 * @cancel_remain_on_channel: Requests that an ongoing off-channel period is
1846 * aborted before it expires. This callback may sleep.
1847 * @offchannel_tx: Transmit frame on another channel, wait for a response
1848 * and return. Reliable TX status must be reported for the frame. If the
1849 * return value is 1, then the @remain_on_channel will be used with a
1850 * regular transmission (if supported.)
1851 * @offchannel_tx_cancel_wait: cancel wait associated with offchannel TX
1852 *
1853 * @set_ringparam: Set tx and rx ring sizes.
1854 *
1855 * @get_ringparam: Get tx and rx ring current and maximum sizes.
1856 *
1857 * @tx_frames_pending: Check if there is any pending frame in the hardware
1858 * queues before entering power save.
1859 *
1860 * @set_bitrate_mask: Set a mask of rates to be used for rate control selection
1861 * when transmitting a frame. Currently only legacy rates are handled.
1862 * The callback can sleep.
1690 */ 1863 */
1691struct ieee80211_ops { 1864struct ieee80211_ops {
1692 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); 1865 void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
1693 int (*start)(struct ieee80211_hw *hw); 1866 int (*start)(struct ieee80211_hw *hw);
1694 void (*stop)(struct ieee80211_hw *hw); 1867 void (*stop)(struct ieee80211_hw *hw);
1868#ifdef CONFIG_PM
1869 int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
1870 int (*resume)(struct ieee80211_hw *hw);
1871#endif
1695 int (*add_interface)(struct ieee80211_hw *hw, 1872 int (*add_interface)(struct ieee80211_hw *hw,
1696 struct ieee80211_vif *vif); 1873 struct ieee80211_vif *vif);
1874 int (*change_interface)(struct ieee80211_hw *hw,
1875 struct ieee80211_vif *vif,
1876 enum nl80211_iftype new_type, bool p2p);
1697 void (*remove_interface)(struct ieee80211_hw *hw, 1877 void (*remove_interface)(struct ieee80211_hw *hw,
1698 struct ieee80211_vif *vif); 1878 struct ieee80211_vif *vif);
1699 int (*config)(struct ieee80211_hw *hw, u32 changed); 1879 int (*config)(struct ieee80211_hw *hw, u32 changed);
@@ -1719,12 +1899,19 @@ struct ieee80211_ops {
1719 u32 iv32, u16 *phase1key); 1899 u32 iv32, u16 *phase1key);
1720 int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1900 int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1721 struct cfg80211_scan_request *req); 1901 struct cfg80211_scan_request *req);
1902 int (*sched_scan_start)(struct ieee80211_hw *hw,
1903 struct ieee80211_vif *vif,
1904 struct cfg80211_sched_scan_request *req,
1905 struct ieee80211_sched_scan_ies *ies);
1906 void (*sched_scan_stop)(struct ieee80211_hw *hw,
1907 struct ieee80211_vif *vif);
1722 void (*sw_scan_start)(struct ieee80211_hw *hw); 1908 void (*sw_scan_start)(struct ieee80211_hw *hw);
1723 void (*sw_scan_complete)(struct ieee80211_hw *hw); 1909 void (*sw_scan_complete)(struct ieee80211_hw *hw);
1724 int (*get_stats)(struct ieee80211_hw *hw, 1910 int (*get_stats)(struct ieee80211_hw *hw,
1725 struct ieee80211_low_level_stats *stats); 1911 struct ieee80211_low_level_stats *stats);
1726 void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx, 1912 void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx,
1727 u32 *iv32, u16 *iv16); 1913 u32 *iv32, u16 *iv16);
1914 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
1728 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); 1915 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
1729 int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1916 int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1730 struct ieee80211_sta *sta); 1917 struct ieee80211_sta *sta);
@@ -1741,7 +1928,8 @@ struct ieee80211_ops {
1741 int (*ampdu_action)(struct ieee80211_hw *hw, 1928 int (*ampdu_action)(struct ieee80211_hw *hw,
1742 struct ieee80211_vif *vif, 1929 struct ieee80211_vif *vif,
1743 enum ieee80211_ampdu_mlme_action action, 1930 enum ieee80211_ampdu_mlme_action action,
1744 struct ieee80211_sta *sta, u16 tid, u16 *ssn); 1931 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
1932 u8 buf_size);
1745 int (*get_survey)(struct ieee80211_hw *hw, int idx, 1933 int (*get_survey)(struct ieee80211_hw *hw, int idx,
1746 struct survey_info *survey); 1934 struct survey_info *survey);
1747 void (*rfkill_poll)(struct ieee80211_hw *hw); 1935 void (*rfkill_poll)(struct ieee80211_hw *hw);
@@ -1752,6 +1940,26 @@ struct ieee80211_ops {
1752 void (*flush)(struct ieee80211_hw *hw, bool drop); 1940 void (*flush)(struct ieee80211_hw *hw, bool drop);
1753 void (*channel_switch)(struct ieee80211_hw *hw, 1941 void (*channel_switch)(struct ieee80211_hw *hw,
1754 struct ieee80211_channel_switch *ch_switch); 1942 struct ieee80211_channel_switch *ch_switch);
1943 int (*napi_poll)(struct ieee80211_hw *hw, int budget);
1944 int (*set_antenna)(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant);
1945 int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
1946
1947 int (*remain_on_channel)(struct ieee80211_hw *hw,
1948 struct ieee80211_channel *chan,
1949 enum nl80211_channel_type channel_type,
1950 int duration);
1951 int (*cancel_remain_on_channel)(struct ieee80211_hw *hw);
1952 int (*offchannel_tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
1953 struct ieee80211_channel *chan,
1954 enum nl80211_channel_type channel_type,
1955 unsigned int wait);
1956 int (*offchannel_tx_cancel_wait)(struct ieee80211_hw *hw);
1957 int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx);
1958 void (*get_ringparam)(struct ieee80211_hw *hw,
1959 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
1960 bool (*tx_frames_pending)(struct ieee80211_hw *hw);
1961 int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1962 const struct cfg80211_bitrate_mask *mask);
1755}; 1963};
1756 1964
1757/** 1965/**
@@ -1780,11 +1988,39 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1780 */ 1988 */
1781int ieee80211_register_hw(struct ieee80211_hw *hw); 1989int ieee80211_register_hw(struct ieee80211_hw *hw);
1782 1990
1991/**
1992 * struct ieee80211_tpt_blink - throughput blink description
1993 * @throughput: throughput in Kbit/sec
1994 * @blink_time: blink time in milliseconds
1995 * (full cycle, ie. one off + one on period)
1996 */
1997struct ieee80211_tpt_blink {
1998 int throughput;
1999 int blink_time;
2000};
2001
2002/**
2003 * enum ieee80211_tpt_led_trigger_flags - throughput trigger flags
2004 * @IEEE80211_TPT_LEDTRIG_FL_RADIO: enable blinking with radio
2005 * @IEEE80211_TPT_LEDTRIG_FL_WORK: enable blinking when working
2006 * @IEEE80211_TPT_LEDTRIG_FL_CONNECTED: enable blinking when at least one
2007 * interface is connected in some way, including being an AP
2008 */
2009enum ieee80211_tpt_led_trigger_flags {
2010 IEEE80211_TPT_LEDTRIG_FL_RADIO = BIT(0),
2011 IEEE80211_TPT_LEDTRIG_FL_WORK = BIT(1),
2012 IEEE80211_TPT_LEDTRIG_FL_CONNECTED = BIT(2),
2013};
2014
1783#ifdef CONFIG_MAC80211_LEDS 2015#ifdef CONFIG_MAC80211_LEDS
1784extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); 2016extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
1785extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); 2017extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
1786extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); 2018extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
1787extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw); 2019extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
2020extern char *__ieee80211_create_tpt_led_trigger(
2021 struct ieee80211_hw *hw, unsigned int flags,
2022 const struct ieee80211_tpt_blink *blink_table,
2023 unsigned int blink_table_len);
1788#endif 2024#endif
1789/** 2025/**
1790 * ieee80211_get_tx_led_name - get name of TX LED 2026 * ieee80211_get_tx_led_name - get name of TX LED
@@ -1863,6 +2099,30 @@ static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
1863} 2099}
1864 2100
1865/** 2101/**
2102 * ieee80211_create_tpt_led_trigger - create throughput LED trigger
2103 * @hw: the hardware to create the trigger for
2104 * @flags: trigger flags, see &enum ieee80211_tpt_led_trigger_flags
2105 * @blink_table: the blink table -- needs to be ordered by throughput
2106 * @blink_table_len: size of the blink table
2107 *
2108 * This function returns %NULL (in case of error, or if no LED
2109 * triggers are configured) or the name of the new trigger.
2110 * This function must be called before ieee80211_register_hw().
2111 */
2112static inline char *
2113ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags,
2114 const struct ieee80211_tpt_blink *blink_table,
2115 unsigned int blink_table_len)
2116{
2117#ifdef CONFIG_MAC80211_LEDS
2118 return __ieee80211_create_tpt_led_trigger(hw, flags, blink_table,
2119 blink_table_len);
2120#else
2121 return NULL;
2122#endif
2123}
2124
2125/**
1866 * ieee80211_unregister_hw - Unregister a hardware device 2126 * ieee80211_unregister_hw - Unregister a hardware device
1867 * 2127 *
1868 * This function instructs mac80211 to free allocated resources 2128 * This function instructs mac80211 to free allocated resources
@@ -1897,6 +2157,22 @@ void ieee80211_free_hw(struct ieee80211_hw *hw);
1897 */ 2157 */
1898void ieee80211_restart_hw(struct ieee80211_hw *hw); 2158void ieee80211_restart_hw(struct ieee80211_hw *hw);
1899 2159
2160/** ieee80211_napi_schedule - schedule NAPI poll
2161 *
2162 * Use this function to schedule NAPI polling on a device.
2163 *
2164 * @hw: the hardware to start polling
2165 */
2166void ieee80211_napi_schedule(struct ieee80211_hw *hw);
2167
2168/** ieee80211_napi_complete - complete NAPI polling
2169 *
2170 * Use this function to finish NAPI polling on a device.
2171 *
2172 * @hw: the hardware to stop polling
2173 */
2174void ieee80211_napi_complete(struct ieee80211_hw *hw);
2175
1900/** 2176/**
1901 * ieee80211_rx - receive frame 2177 * ieee80211_rx - receive frame
1902 * 2178 *
@@ -1952,6 +2228,48 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
1952 local_bh_enable(); 2228 local_bh_enable();
1953} 2229}
1954 2230
2231/**
2232 * ieee80211_sta_ps_transition - PS transition for connected sta
2233 *
2234 * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS
2235 * flag set, use this function to inform mac80211 about a connected station
2236 * entering/leaving PS mode.
2237 *
2238 * This function may not be called in IRQ context or with softirqs enabled.
2239 *
2240 * Calls to this function for a single hardware must be synchronized against
2241 * each other.
2242 *
2243 * The function returns -EINVAL when the requested PS mode is already set.
2244 *
2245 * @sta: currently connected sta
2246 * @start: start or stop PS
2247 */
2248int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start);
2249
2250/**
2251 * ieee80211_sta_ps_transition_ni - PS transition for connected sta
2252 * (in process context)
2253 *
2254 * Like ieee80211_sta_ps_transition() but can be called in process context
2255 * (internally disables bottom halves). Concurrent call restriction still
2256 * applies.
2257 *
2258 * @sta: currently connected sta
2259 * @start: start or stop PS
2260 */
2261static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta,
2262 bool start)
2263{
2264 int ret;
2265
2266 local_bh_disable();
2267 ret = ieee80211_sta_ps_transition(sta, start);
2268 local_bh_enable();
2269
2270 return ret;
2271}
2272
1955/* 2273/*
1956 * The TX headroom reserved by mac80211 for its own tx_status functions. 2274 * The TX headroom reserved by mac80211 for its own tx_status functions.
1957 * This is enough for the radiotap header. 2275 * This is enough for the radiotap header.
@@ -1959,6 +2277,19 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
1959#define IEEE80211_TX_STATUS_HEADROOM 13 2277#define IEEE80211_TX_STATUS_HEADROOM 13
1960 2278
1961/** 2279/**
2280 * ieee80211_sta_set_tim - set the TIM bit for a sleeping station
2281 * @sta: &struct ieee80211_sta pointer for the sleeping station
2282 *
2283 * If a driver buffers frames for a powersave station instead of passing
2284 * them back to mac80211 for retransmission, the station needs to be told
2285 * to wake up using the TIM bitmap in the beacon.
2286 *
2287 * This function sets the station's TIM bit - it will be cleared when the
2288 * station wakes up.
2289 */
2290void ieee80211_sta_set_tim(struct ieee80211_sta *sta);
2291
2292/**
1962 * ieee80211_tx_status - transmit status callback 2293 * ieee80211_tx_status - transmit status callback
1963 * 2294 *
1964 * Call this function for all transmitted frames after they have been 2295 * Call this function for all transmitted frames after they have been
@@ -1967,8 +2298,8 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
1967 * 2298 *
1968 * This function may not be called in IRQ context. Calls to this function 2299 * This function may not be called in IRQ context. Calls to this function
1969 * for a single hardware must be synchronized against each other. Calls 2300 * for a single hardware must be synchronized against each other. Calls
1970 * to this function and ieee80211_tx_status_irqsafe() may not be mixed 2301 * to this function, ieee80211_tx_status_ni() and ieee80211_tx_status_irqsafe()
1971 * for a single hardware. 2302 * may not be mixed for a single hardware.
1972 * 2303 *
1973 * @hw: the hardware the frame was transmitted by 2304 * @hw: the hardware the frame was transmitted by
1974 * @skb: the frame that was transmitted, owned by mac80211 after this call 2305 * @skb: the frame that was transmitted, owned by mac80211 after this call
@@ -1977,13 +2308,33 @@ void ieee80211_tx_status(struct ieee80211_hw *hw,
1977 struct sk_buff *skb); 2308 struct sk_buff *skb);
1978 2309
1979/** 2310/**
2311 * ieee80211_tx_status_ni - transmit status callback (in process context)
2312 *
2313 * Like ieee80211_tx_status() but can be called in process context.
2314 *
2315 * Calls to this function, ieee80211_tx_status() and
2316 * ieee80211_tx_status_irqsafe() may not be mixed
2317 * for a single hardware.
2318 *
2319 * @hw: the hardware the frame was transmitted by
2320 * @skb: the frame that was transmitted, owned by mac80211 after this call
2321 */
2322static inline void ieee80211_tx_status_ni(struct ieee80211_hw *hw,
2323 struct sk_buff *skb)
2324{
2325 local_bh_disable();
2326 ieee80211_tx_status(hw, skb);
2327 local_bh_enable();
2328}
2329
2330/**
1980 * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback 2331 * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback
1981 * 2332 *
1982 * Like ieee80211_tx_status() but can be called in IRQ context 2333 * Like ieee80211_tx_status() but can be called in IRQ context
1983 * (internally defers to a tasklet.) 2334 * (internally defers to a tasklet.)
1984 * 2335 *
1985 * Calls to this function and ieee80211_tx_status() may not be mixed for a 2336 * Calls to this function, ieee80211_tx_status() and
1986 * single hardware. 2337 * ieee80211_tx_status_ni() may not be mixed for a single hardware.
1987 * 2338 *
1988 * @hw: the hardware the frame was transmitted by 2339 * @hw: the hardware the frame was transmitted by
1989 * @skb: the frame that was transmitted, owned by mac80211 after this call 2340 * @skb: the frame that was transmitted, owned by mac80211 after this call
@@ -1992,6 +2343,17 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1992 struct sk_buff *skb); 2343 struct sk_buff *skb);
1993 2344
1994/** 2345/**
2346 * ieee80211_report_low_ack - report non-responding station
2347 *
2348 * When operating in AP-mode, call this function to report a non-responding
2349 * connected STA.
2350 *
2351 * @sta: the non-responding connected sta
2352 * @num_packets: number of packets sent to @sta without a response
2353 */
2354void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);
2355
2356/**
1995 * ieee80211_beacon_get_tim - beacon generation function 2357 * ieee80211_beacon_get_tim - beacon generation function
1996 * @hw: pointer obtained from ieee80211_alloc_hw(). 2358 * @hw: pointer obtained from ieee80211_alloc_hw().
1997 * @vif: &struct ieee80211_vif pointer from the add_interface callback. 2359 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
@@ -2252,7 +2614,8 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw);
2252 * 2614 *
2253 * When hardware scan offload is used (i.e. the hw_scan() callback is 2615 * When hardware scan offload is used (i.e. the hw_scan() callback is
2254 * assigned) this function needs to be called by the driver to notify 2616 * assigned) this function needs to be called by the driver to notify
2255 * mac80211 that the scan finished. 2617 * mac80211 that the scan finished. This function can be called from
2618 * any context, including hardirq context.
2256 * 2619 *
2257 * @hw: the hardware that finished the scan 2620 * @hw: the hardware that finished the scan
2258 * @aborted: set to true if scan was aborted 2621 * @aborted: set to true if scan was aborted
@@ -2260,6 +2623,28 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw);
2260void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted); 2623void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted);
2261 2624
2262/** 2625/**
2626 * ieee80211_sched_scan_results - got results from scheduled scan
2627 *
2628 * When a scheduled scan is running, this function needs to be called by the
2629 * driver whenever there are new scan results available.
2630 *
2631 * @hw: the hardware that is performing scheduled scans
2632 */
2633void ieee80211_sched_scan_results(struct ieee80211_hw *hw);
2634
2635/**
2636 * ieee80211_sched_scan_stopped - inform that the scheduled scan has stopped
2637 *
2638 * When a scheduled scan is running, this function can be called by
2639 * the driver if it needs to stop the scan to perform another task.
2640 * Usual scenarios are drivers that cannot continue the scheduled scan
2641 * while associating, for instance.
2642 *
2643 * @hw: the hardware that is performing scheduled scans
2644 */
2645void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw);
2646
2647/**
2263 * ieee80211_iterate_active_interfaces - iterate active interfaces 2648 * ieee80211_iterate_active_interfaces - iterate active interfaces
2264 * 2649 *
2265 * This function iterates over the interfaces associated with a given 2650 * This function iterates over the interfaces associated with a given
@@ -2267,6 +2652,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted);
2267 * This function allows the iterator function to sleep, when the iterator 2652 * This function allows the iterator function to sleep, when the iterator
2268 * function is atomic @ieee80211_iterate_active_interfaces_atomic can 2653 * function is atomic @ieee80211_iterate_active_interfaces_atomic can
2269 * be used. 2654 * be used.
2655 * Does not iterate over a new interface during add_interface()
2270 * 2656 *
2271 * @hw: the hardware struct of which the interfaces should be iterated over 2657 * @hw: the hardware struct of which the interfaces should be iterated over
2272 * @iterator: the iterator function to call 2658 * @iterator: the iterator function to call
@@ -2284,6 +2670,7 @@ void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
2284 * hardware that are currently active and calls the callback for them. 2670 * hardware that are currently active and calls the callback for them.
2285 * This function requires the iterator callback function to be atomic, 2671 * This function requires the iterator callback function to be atomic,
2286 * if that is not desired, use @ieee80211_iterate_active_interfaces instead. 2672 * if that is not desired, use @ieee80211_iterate_active_interfaces instead.
2673 * Does not iterate over a new interface during add_interface()
2287 * 2674 *
2288 * @hw: the hardware struct of which the interfaces should be iterated over 2675 * @hw: the hardware struct of which the interfaces should be iterated over
2289 * @iterator: the iterator function to call, cannot sleep 2676 * @iterator: the iterator function to call, cannot sleep
@@ -2324,6 +2711,7 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
2324 * ieee80211_start_tx_ba_session - Start a tx Block Ack session. 2711 * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
2325 * @sta: the station for which to start a BA session 2712 * @sta: the station for which to start a BA session
2326 * @tid: the TID to BA on. 2713 * @tid: the TID to BA on.
2714 * @timeout: session timeout value (in TUs)
2327 * 2715 *
2328 * Return: success if addBA request was sent, failure otherwise 2716 * Return: success if addBA request was sent, failure otherwise
2329 * 2717 *
@@ -2331,7 +2719,8 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
2331 * the need to start aggregation on a certain RA/TID, the session level 2719 * the need to start aggregation on a certain RA/TID, the session level
2332 * will be managed by the mac80211. 2720 * will be managed by the mac80211.
2333 */ 2721 */
2334int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid); 2722int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid,
2723 u16 timeout);
2335 2724
2336/** 2725/**
2337 * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate. 2726 * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
@@ -2385,25 +2774,28 @@ struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif,
2385 const u8 *addr); 2774 const u8 *addr);
2386 2775
2387/** 2776/**
2388 * ieee80211_find_sta_by_hw - find a station on hardware 2777 * ieee80211_find_sta_by_ifaddr - find a station on hardware
2389 * 2778 *
2390 * @hw: pointer as obtained from ieee80211_alloc_hw() 2779 * @hw: pointer as obtained from ieee80211_alloc_hw()
2391 * @addr: station's address 2780 * @addr: remote station's address
2781 * @localaddr: local address (vif->sdata->vif.addr). Use NULL for 'any'.
2392 * 2782 *
2393 * This function must be called under RCU lock and the 2783 * This function must be called under RCU lock and the
2394 * resulting pointer is only valid under RCU lock as well. 2784 * resulting pointer is only valid under RCU lock as well.
2395 * 2785 *
2396 * NOTE: This function should not be used! When mac80211 is converted 2786 * NOTE: You may pass NULL for localaddr, but then you will just get
2397 * internally to properly keep track of stations on multiple 2787 * the first STA that matches the remote address 'addr'.
2398 * virtual interfaces, it will not always know which station to 2788 * We can have multiple STA associated with multiple
2399 * return here since a single address might be used by multiple 2789 * logical stations (e.g. consider a station connecting to another
2400 * logical stations (e.g. consider a station connecting to another 2790 * BSSID on the same AP hardware without disconnecting first).
2401 * BSSID on the same AP hardware without disconnecting first). 2791 * In this case, the result of this method with localaddr NULL
2792 * is not reliable.
2402 * 2793 *
2403 * DO NOT USE THIS FUNCTION. 2794 * DO NOT USE THIS FUNCTION with localaddr NULL if at all possible.
2404 */ 2795 */
2405struct ieee80211_sta *ieee80211_find_sta_by_hw(struct ieee80211_hw *hw, 2796struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw,
2406 const u8 *addr); 2797 const u8 *addr,
2798 const u8 *localaddr);
2407 2799
2408/** 2800/**
2409 * ieee80211_sta_block_awake - block station from waking up 2801 * ieee80211_sta_block_awake - block station from waking up
@@ -2438,11 +2830,26 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
2438 struct ieee80211_sta *pubsta, bool block); 2830 struct ieee80211_sta *pubsta, bool block);
2439 2831
2440/** 2832/**
2833 * ieee80211_ap_probereq_get - retrieve a Probe Request template
2834 * @hw: pointer obtained from ieee80211_alloc_hw().
2835 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
2836 *
2837 * Creates a Probe Request template which can, for example, be uploaded to
2838 * hardware. The template is filled with bssid, ssid and supported rate
2839 * information. This function must only be called from within the
2840 * .bss_info_changed callback function and only in managed mode. The function
2841 * is only useful when the interface is associated, otherwise it will return
2842 * NULL.
2843 */
2844struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
2845 struct ieee80211_vif *vif);
2846
2847/**
2441 * ieee80211_beacon_loss - inform hardware does not receive beacons 2848 * ieee80211_beacon_loss - inform hardware does not receive beacons
2442 * 2849 *
2443 * @vif: &struct ieee80211_vif pointer from the add_interface callback. 2850 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
2444 * 2851 *
2445 * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTERING and 2852 * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER and
2446 * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the 2853 * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the
2447 * hardware is not receiving beacons with this function. 2854 * hardware is not receiving beacons with this function.
2448 */ 2855 */
@@ -2453,7 +2860,7 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif);
2453 * 2860 *
2454 * @vif: &struct ieee80211_vif pointer from the add_interface callback. 2861 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
2455 * 2862 *
2456 * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTERING, and 2863 * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER, and
2457 * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver 2864 * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver
2458 * needs to inform if the connection to the AP has been lost. 2865 * needs to inform if the connection to the AP has been lost.
2459 * 2866 *
@@ -2518,6 +2925,46 @@ void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
2518 */ 2925 */
2519void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success); 2926void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
2520 2927
2928/**
2929 * ieee80211_request_smps - request SM PS transition
2930 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
2931 * @smps_mode: new SM PS mode
2932 *
2933 * This allows the driver to request an SM PS transition in managed
2934 * mode. This is useful when the driver has more information than
2935 * the stack about possible interference, for example by bluetooth.
2936 */
2937void ieee80211_request_smps(struct ieee80211_vif *vif,
2938 enum ieee80211_smps_mode smps_mode);
2939
2940/**
2941 * ieee80211_key_removed - disable hw acceleration for key
2942 * @key_conf: The key hw acceleration should be disabled for
2943 *
2944 * This allows drivers to indicate that the given key has been
2945 * removed from hardware acceleration, due to a new key that
2946 * was added. Don't use this if the key can continue to be used
2947 * for TX, if the key restriction is on RX only it is permitted
2948 * to keep the key for TX only and not call this function.
2949 *
2950 * Due to locking constraints, it may only be called during
2951 * @set_key. This function must be allowed to sleep, and the
2952 * key it tries to disable may still be used until it returns.
2953 */
2954void ieee80211_key_removed(struct ieee80211_key_conf *key_conf);
2955
2956/**
2957 * ieee80211_ready_on_channel - notification of remain-on-channel start
2958 * @hw: pointer as obtained from ieee80211_alloc_hw()
2959 */
2960void ieee80211_ready_on_channel(struct ieee80211_hw *hw);
2961
2962/**
2963 * ieee80211_remain_on_channel_expired - remain_on_channel duration expired
2964 * @hw: pointer as obtained from ieee80211_alloc_hw()
2965 */
2966void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw);
2967
2521/* Rate control API */ 2968/* Rate control API */
2522 2969
2523/** 2970/**
@@ -2549,7 +2996,7 @@ enum rate_control_changed {
2549 * @rate_idx_mask: user-requested rate mask (not MCS for now) 2996 * @rate_idx_mask: user-requested rate mask (not MCS for now)
2550 * @skb: the skb that will be transmitted, the control information in it needs 2997 * @skb: the skb that will be transmitted, the control information in it needs
2551 * to be filled in 2998 * to be filled in
2552 * @ap: whether this frame is sent out in AP mode 2999 * @bss: whether this frame is sent out in AP or IBSS mode
2553 */ 3000 */
2554struct ieee80211_tx_rate_control { 3001struct ieee80211_tx_rate_control {
2555 struct ieee80211_hw *hw; 3002 struct ieee80211_hw *hw;
@@ -2560,7 +3007,7 @@ struct ieee80211_tx_rate_control {
2560 bool rts, short_preamble; 3007 bool rts, short_preamble;
2561 u8 max_rate_idx; 3008 u8 max_rate_idx;
2562 u32 rate_idx_mask; 3009 u32 rate_idx_mask;
2563 bool ap; 3010 bool bss;
2564}; 3011};
2565 3012
2566struct rate_control_ops { 3013struct rate_control_ops {
@@ -2681,4 +3128,26 @@ conf_is_ht(struct ieee80211_conf *conf)
2681 return conf->channel_type != NL80211_CHAN_NO_HT; 3128 return conf->channel_type != NL80211_CHAN_NO_HT;
2682} 3129}
2683 3130
3131static inline enum nl80211_iftype
3132ieee80211_iftype_p2p(enum nl80211_iftype type, bool p2p)
3133{
3134 if (p2p) {
3135 switch (type) {
3136 case NL80211_IFTYPE_STATION:
3137 return NL80211_IFTYPE_P2P_CLIENT;
3138 case NL80211_IFTYPE_AP:
3139 return NL80211_IFTYPE_P2P_GO;
3140 default:
3141 break;
3142 }
3143 }
3144 return type;
3145}
3146
3147static inline enum nl80211_iftype
3148ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
3149{
3150 return ieee80211_iftype_p2p(vif->type, vif->p2p);
3151}
3152
2684#endif /* MAC80211_H */ 3153#endif /* MAC80211_H */
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 895997bc2ead..62beeb97c4b1 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -42,11 +42,6 @@ enum {
42#define ND_REACHABLE_TIME (30*HZ) 42#define ND_REACHABLE_TIME (30*HZ)
43#define ND_RETRANS_TIMER HZ 43#define ND_RETRANS_TIMER HZ
44 44
45#define ND_MIN_RANDOM_FACTOR (1/2)
46#define ND_MAX_RANDOM_FACTOR (3/2)
47
48#ifdef __KERNEL__
49
50#include <linux/compiler.h> 45#include <linux/compiler.h>
51#include <linux/icmpv6.h> 46#include <linux/icmpv6.h>
52#include <linux/in6.h> 47#include <linux/in6.h>
@@ -105,7 +100,8 @@ extern void ndisc_send_redirect(struct sk_buff *skb,
105 struct neighbour *neigh, 100 struct neighbour *neigh,
106 const struct in6_addr *target); 101 const struct in6_addr *target);
107 102
108extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir); 103extern int ndisc_mc_map(const struct in6_addr *addr, char *buf,
104 struct net_device *dev, int dir);
109 105
110extern struct sk_buff *ndisc_build_skb(struct net_device *dev, 106extern struct sk_buff *ndisc_build_skb(struct net_device *dev,
111 const struct in6_addr *daddr, 107 const struct in6_addr *daddr,
@@ -158,8 +154,4 @@ static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, const s
158 return ERR_PTR(-ENODEV); 154 return ERR_PTR(-ENODEV);
159} 155}
160 156
161
162#endif /* __KERNEL__ */
163
164
165#endif 157#endif
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 242879b6c4df..4014b623880c 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -91,26 +91,28 @@ struct neigh_statistics {
91#define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field) 91#define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field)
92 92
93struct neighbour { 93struct neighbour {
94 struct neighbour *next; 94 struct neighbour __rcu *next;
95 struct neigh_table *tbl; 95 struct neigh_table *tbl;
96 struct neigh_parms *parms; 96 struct neigh_parms *parms;
97 struct net_device *dev;
98 unsigned long used;
99 unsigned long confirmed; 97 unsigned long confirmed;
100 unsigned long updated; 98 unsigned long updated;
99 rwlock_t lock;
100 atomic_t refcnt;
101 struct sk_buff_head arp_queue;
102 struct timer_list timer;
103 unsigned long used;
104 atomic_t probes;
101 __u8 flags; 105 __u8 flags;
102 __u8 nud_state; 106 __u8 nud_state;
103 __u8 type; 107 __u8 type;
104 __u8 dead; 108 __u8 dead;
105 atomic_t probes; 109 seqlock_t ha_lock;
106 rwlock_t lock;
107 unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))]; 110 unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))];
108 struct hh_cache *hh; 111 struct hh_cache *hh;
109 atomic_t refcnt;
110 int (*output)(struct sk_buff *skb); 112 int (*output)(struct sk_buff *skb);
111 struct sk_buff_head arp_queue;
112 struct timer_list timer;
113 const struct neigh_ops *ops; 113 const struct neigh_ops *ops;
114 struct rcu_head rcu;
115 struct net_device *dev;
114 u8 primary_key[0]; 116 u8 primary_key[0];
115}; 117};
116 118
@@ -138,13 +140,22 @@ struct pneigh_entry {
138 * neighbour table manipulation 140 * neighbour table manipulation
139 */ 141 */
140 142
143struct neigh_hash_table {
144 struct neighbour __rcu **hash_buckets;
145 unsigned int hash_mask;
146 __u32 hash_rnd;
147 struct rcu_head rcu;
148};
149
141 150
142struct neigh_table { 151struct neigh_table {
143 struct neigh_table *next; 152 struct neigh_table *next;
144 int family; 153 int family;
145 int entry_size; 154 int entry_size;
146 int key_len; 155 int key_len;
147 __u32 (*hash)(const void *pkey, const struct net_device *); 156 __u32 (*hash)(const void *pkey,
157 const struct net_device *dev,
158 __u32 hash_rnd);
148 int (*constructor)(struct neighbour *); 159 int (*constructor)(struct neighbour *);
149 int (*pconstructor)(struct pneigh_entry *); 160 int (*pconstructor)(struct pneigh_entry *);
150 void (*pdestructor)(struct pneigh_entry *); 161 void (*pdestructor)(struct pneigh_entry *);
@@ -163,11 +174,9 @@ struct neigh_table {
163 atomic_t entries; 174 atomic_t entries;
164 rwlock_t lock; 175 rwlock_t lock;
165 unsigned long last_rand; 176 unsigned long last_rand;
166 struct kmem_cache *kmem_cachep; 177 struct kmem_cache *kmem_cachep;
167 struct neigh_statistics __percpu *stats; 178 struct neigh_statistics __percpu *stats;
168 struct neighbour **hash_buckets; 179 struct neigh_hash_table __rcu *nht;
169 unsigned int hash_mask;
170 __u32 hash_rnd;
171 struct pneigh_entry **phash_buckets; 180 struct pneigh_entry **phash_buckets;
172}; 181};
173 182
@@ -237,6 +246,7 @@ extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_en
237struct neigh_seq_state { 246struct neigh_seq_state {
238 struct seq_net_private p; 247 struct seq_net_private p;
239 struct neigh_table *tbl; 248 struct neigh_table *tbl;
249 struct neigh_hash_table *nht;
240 void *(*neigh_sub_iter)(struct neigh_seq_state *state, 250 void *(*neigh_sub_iter)(struct neigh_seq_state *state,
241 struct neighbour *n, loff_t *pos); 251 struct neighbour *n, loff_t *pos);
242 unsigned int bucket; 252 unsigned int bucket;
@@ -293,7 +303,10 @@ static inline void neigh_confirm(struct neighbour *neigh)
293 303
294static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) 304static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
295{ 305{
296 neigh->used = jiffies; 306 unsigned long now = jiffies;
307
308 if (neigh->used != now)
309 neigh->used = now;
297 if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) 310 if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE)))
298 return __neigh_event_send(neigh, skb); 311 return __neigh_event_send(neigh, skb);
299 return 0; 312 return 0;
@@ -364,4 +377,14 @@ struct neighbour_cb {
364 377
365#define NEIGH_CB(skb) ((struct neighbour_cb *)(skb)->cb) 378#define NEIGH_CB(skb) ((struct neighbour_cb *)(skb)->cb)
366 379
380static inline void neigh_ha_snapshot(char *dst, const struct neighbour *n,
381 const struct net_device *dev)
382{
383 unsigned int seq;
384
385 do {
386 seq = read_seqbegin(&n->ha_lock);
387 memcpy(dst, n->ha, dev->addr_len);
388 } while (read_seqretry(&n->ha_lock, seq));
389}
367#endif 390#endif
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index bd10a7908993..aef430d779bd 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -7,6 +7,7 @@
7#include <asm/atomic.h> 7#include <asm/atomic.h>
8#include <linux/workqueue.h> 8#include <linux/workqueue.h>
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/sysctl.h>
10 11
11#include <net/netns/core.h> 12#include <net/netns/core.h>
12#include <net/netns/mib.h> 13#include <net/netns/mib.h>
@@ -27,20 +28,26 @@ struct sock;
27struct ctl_table_header; 28struct ctl_table_header;
28struct net_generic; 29struct net_generic;
29struct sock; 30struct sock;
31struct netns_ipvs;
30 32
31 33
32#define NETDEV_HASHBITS 8 34#define NETDEV_HASHBITS 8
33#define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS) 35#define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS)
34 36
35struct net { 37struct net {
38 atomic_t passive; /* To decided when the network
39 * namespace should be freed.
40 */
36 atomic_t count; /* To decided when the network 41 atomic_t count; /* To decided when the network
37 * namespace should be freed. 42 * namespace should be shut down.
38 */ 43 */
39#ifdef NETNS_REFCNT_DEBUG 44#ifdef NETNS_REFCNT_DEBUG
40 atomic_t use_count; /* To track references we 45 atomic_t use_count; /* To track references we
41 * destroy on demand 46 * destroy on demand
42 */ 47 */
43#endif 48#endif
49 spinlock_t rules_mod_lock;
50
44 struct list_head list; /* list of network namespaces */ 51 struct list_head list; /* list of network namespaces */
45 struct list_head cleanup_list; /* namespaces on death row */ 52 struct list_head cleanup_list; /* namespaces on death row */
46 struct list_head exit_list; /* Use only net_mutex */ 53 struct list_head exit_list; /* Use only net_mutex */
@@ -52,7 +59,8 @@ struct net {
52 struct ctl_table_set sysctls; 59 struct ctl_table_set sysctls;
53#endif 60#endif
54 61
55 struct net_device *loopback_dev; /* The loopback */ 62 struct sock *rtnl; /* rtnetlink socket */
63 struct sock *genl_sock;
56 64
57 struct list_head dev_base_head; 65 struct list_head dev_base_head;
58 struct hlist_head *dev_name_head; 66 struct hlist_head *dev_name_head;
@@ -60,11 +68,9 @@ struct net {
60 68
61 /* core fib_rules */ 69 /* core fib_rules */
62 struct list_head rules_ops; 70 struct list_head rules_ops;
63 spinlock_t rules_mod_lock;
64 71
65 struct sock *rtnl; /* rtnetlink socket */
66 struct sock *genl_sock;
67 72
73 struct net_device *loopback_dev; /* The loopback */
68 struct netns_core core; 74 struct netns_core core;
69 struct netns_mib mib; 75 struct netns_mib mib;
70 struct netns_packet packet; 76 struct netns_packet packet;
@@ -84,13 +90,16 @@ struct net {
84 struct sock *nfnl; 90 struct sock *nfnl;
85 struct sock *nfnl_stash; 91 struct sock *nfnl_stash;
86#endif 92#endif
87#ifdef CONFIG_XFRM
88 struct netns_xfrm xfrm;
89#endif
90#ifdef CONFIG_WEXT_CORE 93#ifdef CONFIG_WEXT_CORE
91 struct sk_buff_head wext_nlevents; 94 struct sk_buff_head wext_nlevents;
92#endif 95#endif
93 struct net_generic *gen; 96 struct net_generic __rcu *gen;
97
98 /* Note : following structs are cache line aligned */
99#ifdef CONFIG_XFRM
100 struct netns_xfrm xfrm;
101#endif
102 struct netns_ipvs *ipvs;
94}; 103};
95 104
96 105
@@ -114,6 +123,7 @@ static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)
114extern struct list_head net_namespace_list; 123extern struct list_head net_namespace_list;
115 124
116extern struct net *get_net_ns_by_pid(pid_t pid); 125extern struct net *get_net_ns_by_pid(pid_t pid);
126extern struct net *get_net_ns_by_fd(int pid);
117 127
118#ifdef CONFIG_NET_NS 128#ifdef CONFIG_NET_NS
119extern void __put_net(struct net *net); 129extern void __put_net(struct net *net);
@@ -147,6 +157,9 @@ int net_eq(const struct net *net1, const struct net *net2)
147{ 157{
148 return net1 == net2; 158 return net1 == net2;
149} 159}
160
161extern void net_drop_ns(void *);
162
150#else 163#else
151 164
152static inline struct net *get_net(struct net *net) 165static inline struct net *get_net(struct net *net)
@@ -168,6 +181,8 @@ int net_eq(const struct net *net1, const struct net *net2)
168{ 181{
169 return 1; 182 return 1;
170} 183}
184
185#define net_drop_ns NULL
171#endif 186#endif
172 187
173 188
diff --git a/include/net/net_ratelimit.h b/include/net/net_ratelimit.h
new file mode 100644
index 000000000000..7727b4247daf
--- /dev/null
+++ b/include/net/net_ratelimit.h
@@ -0,0 +1,8 @@
1#ifndef _LINUX_NET_RATELIMIT_H
2#define _LINUX_NET_RATELIMIT_H
3
4#include <linux/ratelimit.h>
5
6extern struct ratelimit_state net_ratelimit_state;
7
8#endif /* _LINUX_NET_RATELIMIT_H */
diff --git a/include/net/netevent.h b/include/net/netevent.h
index e82b7bab3ff3..086f8a5b59dc 100644
--- a/include/net/netevent.h
+++ b/include/net/netevent.h
@@ -10,7 +10,6 @@
10 * 10 *
11 * Changes: 11 * Changes:
12 */ 12 */
13#ifdef __KERNEL__
14 13
15struct dst_entry; 14struct dst_entry;
16 15
@@ -21,7 +20,6 @@ struct netevent_redirect {
21 20
22enum netevent_notif_type { 21enum netevent_notif_type {
23 NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */ 22 NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */
24 NETEVENT_PMTU_UPDATE, /* arg is struct dst_entry ptr */
25 NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */ 23 NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */
26}; 24};
27 25
@@ -30,4 +28,3 @@ extern int unregister_netevent_notifier(struct notifier_block *nb);
30extern int call_netevent_notifiers(unsigned long val, void *v); 28extern int call_netevent_notifiers(unsigned long val, void *v);
31 29
32#endif 30#endif
33#endif
diff --git a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
index 1ee717eb5b09..a4c993685795 100644
--- a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
+++ b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
@@ -7,16 +7,6 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6;
7extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6; 7extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6;
8extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6; 8extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
9 9
10extern int nf_ct_frag6_init(void);
11extern void nf_ct_frag6_cleanup(void);
12extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user);
13extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
14 struct net_device *in,
15 struct net_device *out,
16 int (*okfn)(struct sk_buff *));
17
18struct inet_frags_ctl;
19
20#include <linux/sysctl.h> 10#include <linux/sysctl.h>
21extern struct ctl_table nf_ct_ipv6_sysctl_table[]; 11extern struct ctl_table nf_ct_ipv6_sysctl_table[];
22 12
diff --git a/include/net/netfilter/ipv6/nf_defrag_ipv6.h b/include/net/netfilter/ipv6/nf_defrag_ipv6.h
new file mode 100644
index 000000000000..fd79c9a1779d
--- /dev/null
+++ b/include/net/netfilter/ipv6/nf_defrag_ipv6.h
@@ -0,0 +1,16 @@
1#ifndef _NF_DEFRAG_IPV6_H
2#define _NF_DEFRAG_IPV6_H
3
4extern void nf_defrag_ipv6_enable(void);
5
6extern int nf_ct_frag6_init(void);
7extern void nf_ct_frag6_cleanup(void);
8extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user);
9extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
10 struct net_device *in,
11 struct net_device *out,
12 int (*okfn)(struct sk_buff *));
13
14struct inet_frags_ctl;
15
16#endif /* _NF_DEFRAG_IPV6_H */
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index e624dae54fa4..5d4f8e586e32 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -14,7 +14,6 @@
14 14
15#include <linux/netfilter/nf_conntrack_common.h> 15#include <linux/netfilter/nf_conntrack_common.h>
16 16
17#ifdef __KERNEL__
18#include <linux/bitops.h> 17#include <linux/bitops.h>
19#include <linux/compiler.h> 18#include <linux/compiler.h>
20#include <asm/atomic.h> 19#include <asm/atomic.h>
@@ -50,11 +49,24 @@ union nf_conntrack_expect_proto {
50/* per conntrack: application helper private data */ 49/* per conntrack: application helper private data */
51union nf_conntrack_help { 50union nf_conntrack_help {
52 /* insert conntrack helper private data (master) here */ 51 /* insert conntrack helper private data (master) here */
52#if defined(CONFIG_NF_CONNTRACK_FTP) || defined(CONFIG_NF_CONNTRACK_FTP_MODULE)
53 struct nf_ct_ftp_master ct_ftp_info; 53 struct nf_ct_ftp_master ct_ftp_info;
54#endif
55#if defined(CONFIG_NF_CONNTRACK_PPTP) || \
56 defined(CONFIG_NF_CONNTRACK_PPTP_MODULE)
54 struct nf_ct_pptp_master ct_pptp_info; 57 struct nf_ct_pptp_master ct_pptp_info;
58#endif
59#if defined(CONFIG_NF_CONNTRACK_H323) || \
60 defined(CONFIG_NF_CONNTRACK_H323_MODULE)
55 struct nf_ct_h323_master ct_h323_info; 61 struct nf_ct_h323_master ct_h323_info;
62#endif
63#if defined(CONFIG_NF_CONNTRACK_SANE) || \
64 defined(CONFIG_NF_CONNTRACK_SANE_MODULE)
56 struct nf_ct_sane_master ct_sane_info; 65 struct nf_ct_sane_master ct_sane_info;
66#endif
67#if defined(CONFIG_NF_CONNTRACK_SIP) || defined(CONFIG_NF_CONNTRACK_SIP_MODULE)
57 struct nf_ct_sip_master ct_sip_info; 68 struct nf_ct_sip_master ct_sip_info;
69#endif
58}; 70};
59 71
60#include <linux/types.h> 72#include <linux/types.h>
@@ -75,7 +87,7 @@ struct nf_conntrack_helper;
75/* nf_conn feature for connections that have a helper */ 87/* nf_conn feature for connections that have a helper */
76struct nf_conn_help { 88struct nf_conn_help {
77 /* Helper. if any */ 89 /* Helper. if any */
78 struct nf_conntrack_helper *helper; 90 struct nf_conntrack_helper __rcu *helper;
79 91
80 union nf_conntrack_help help; 92 union nf_conntrack_help help;
81 93
@@ -116,14 +128,14 @@ struct nf_conn {
116 u_int32_t secmark; 128 u_int32_t secmark;
117#endif 129#endif
118 130
119 /* Storage reserved for other modules: */
120 union nf_conntrack_proto proto;
121
122 /* Extensions */ 131 /* Extensions */
123 struct nf_ct_ext *ext; 132 struct nf_ct_ext *ext;
124#ifdef CONFIG_NET_NS 133#ifdef CONFIG_NET_NS
125 struct net *ct_net; 134 struct net *ct_net;
126#endif 135#endif
136
137 /* Storage reserved for other modules, must be the last member */
138 union nf_conntrack_proto proto;
127}; 139};
128 140
129static inline struct nf_conn * 141static inline struct nf_conn *
@@ -189,9 +201,9 @@ extern void nf_ct_l3proto_module_put(unsigned short l3proto);
189 * Allocate a hashtable of hlist_head (if nulls == 0), 201 * Allocate a hashtable of hlist_head (if nulls == 0),
190 * or hlist_nulls_head (if nulls == 1) 202 * or hlist_nulls_head (if nulls == 1)
191 */ 203 */
192extern void *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced, int nulls); 204extern void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls);
193 205
194extern void nf_ct_free_hashtable(void *hash, int vmalloced, unsigned int size); 206extern void nf_ct_free_hashtable(void *hash, unsigned int size);
195 207
196extern struct nf_conntrack_tuple_hash * 208extern struct nf_conntrack_tuple_hash *
197__nf_conntrack_find(struct net *net, u16 zone, 209__nf_conntrack_find(struct net *net, u16 zone,
@@ -295,9 +307,17 @@ static inline int nf_ct_is_untracked(const struct nf_conn *ct)
295 return test_bit(IPS_UNTRACKED_BIT, &ct->status); 307 return test_bit(IPS_UNTRACKED_BIT, &ct->status);
296} 308}
297 309
310/* Packet is received from loopback */
311static inline bool nf_is_loopback_packet(const struct sk_buff *skb)
312{
313 return skb->dev && skb->skb_iif && skb->dev->flags & IFF_LOOPBACK;
314}
315
298extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp); 316extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp);
299extern unsigned int nf_conntrack_htable_size; 317extern unsigned int nf_conntrack_htable_size;
300extern unsigned int nf_conntrack_max; 318extern unsigned int nf_conntrack_max;
319extern unsigned int nf_conntrack_hash_rnd;
320void init_nf_conntrack_hash_rnd(void);
301 321
302#define NF_CT_STAT_INC(net, count) \ 322#define NF_CT_STAT_INC(net, count) \
303 __this_cpu_inc((net)->ct.stat->count) 323 __this_cpu_inc((net)->ct.stat->count)
@@ -311,5 +331,4 @@ do { \
311#define MODULE_ALIAS_NFCT_HELPER(helper) \ 331#define MODULE_ALIAS_NFCT_HELPER(helper) \
312 MODULE_ALIAS("nfct-helper-" helper) 332 MODULE_ALIAS("nfct-helper-" helper)
313 333
314#endif /* __KERNEL__ */
315#endif /* _NF_CONNTRACK_H */ 334#endif /* _NF_CONNTRACK_H */
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index 96ba5f7dcab6..4283508b3e18 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -23,12 +23,17 @@ struct nf_conntrack_ecache {
23static inline struct nf_conntrack_ecache * 23static inline struct nf_conntrack_ecache *
24nf_ct_ecache_find(const struct nf_conn *ct) 24nf_ct_ecache_find(const struct nf_conn *ct)
25{ 25{
26#ifdef CONFIG_NF_CONNTRACK_EVENTS
26 return nf_ct_ext_find(ct, NF_CT_EXT_ECACHE); 27 return nf_ct_ext_find(ct, NF_CT_EXT_ECACHE);
28#else
29 return NULL;
30#endif
27} 31}
28 32
29static inline struct nf_conntrack_ecache * 33static inline struct nf_conntrack_ecache *
30nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp) 34nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp)
31{ 35{
36#ifdef CONFIG_NF_CONNTRACK_EVENTS
32 struct net *net = nf_ct_net(ct); 37 struct net *net = nf_ct_net(ct);
33 struct nf_conntrack_ecache *e; 38 struct nf_conntrack_ecache *e;
34 39
@@ -45,6 +50,9 @@ nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp)
45 e->expmask = expmask; 50 e->expmask = expmask;
46 } 51 }
47 return e; 52 return e;
53#else
54 return NULL;
55#endif
48}; 56};
49 57
50#ifdef CONFIG_NF_CONNTRACK_EVENTS 58#ifdef CONFIG_NF_CONNTRACK_EVENTS
@@ -59,7 +67,7 @@ struct nf_ct_event_notifier {
59 int (*fcn)(unsigned int events, struct nf_ct_event *item); 67 int (*fcn)(unsigned int events, struct nf_ct_event *item);
60}; 68};
61 69
62extern struct nf_ct_event_notifier *nf_conntrack_event_cb; 70extern struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb;
63extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb); 71extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb);
64extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb); 72extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb);
65 73
@@ -77,9 +85,6 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
77 if (e == NULL) 85 if (e == NULL)
78 return; 86 return;
79 87
80 if (!(e->ctmask & (1 << event)))
81 return;
82
83 set_bit(event, &e->cache); 88 set_bit(event, &e->cache);
84} 89}
85 90
@@ -159,7 +164,7 @@ struct nf_exp_event_notifier {
159 int (*fcn)(unsigned int events, struct nf_exp_event *item); 164 int (*fcn)(unsigned int events, struct nf_exp_event *item);
160}; 165};
161 166
162extern struct nf_exp_event_notifier *nf_expect_event_cb; 167extern struct nf_exp_event_notifier __rcu *nf_expect_event_cb;
163extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb); 168extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb);
164extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb); 169extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb);
165 170
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index 11e815084fcf..0f8a8c587532 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -67,9 +67,6 @@ struct nf_conntrack_expect_policy {
67 67
68#define NF_CT_EXPECT_CLASS_DEFAULT 0 68#define NF_CT_EXPECT_CLASS_DEFAULT 0
69 69
70#define NF_CT_EXPECT_PERMANENT 0x1
71#define NF_CT_EXPECT_INACTIVE 0x2
72
73int nf_conntrack_expect_init(struct net *net); 70int nf_conntrack_expect_init(struct net *net);
74void nf_conntrack_expect_fini(struct net *net); 71void nf_conntrack_expect_fini(struct net *net);
75 72
@@ -85,9 +82,16 @@ struct nf_conntrack_expect *
85nf_ct_find_expectation(struct net *net, u16 zone, 82nf_ct_find_expectation(struct net *net, u16 zone,
86 const struct nf_conntrack_tuple *tuple); 83 const struct nf_conntrack_tuple *tuple);
87 84
88void nf_ct_unlink_expect(struct nf_conntrack_expect *exp); 85void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,
86 u32 pid, int report);
87static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp)
88{
89 nf_ct_unlink_expect_report(exp, 0, 0);
90}
91
89void nf_ct_remove_expectations(struct nf_conn *ct); 92void nf_ct_remove_expectations(struct nf_conn *ct);
90void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); 93void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
94void nf_ct_remove_userspace_expectations(void);
91 95
92/* Allocate space for an expectation: this is mandatory before calling 96/* Allocate space for an expectation: this is mandatory before calling
93 nf_ct_expect_related. You will have to call put afterwards. */ 97 nf_ct_expect_related. You will have to call put afterwards. */
diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h
index 0772d296dfdb..2dcf31703acb 100644
--- a/include/net/netfilter/nf_conntrack_extend.h
+++ b/include/net/netfilter/nf_conntrack_extend.h
@@ -7,10 +7,19 @@
7 7
8enum nf_ct_ext_id { 8enum nf_ct_ext_id {
9 NF_CT_EXT_HELPER, 9 NF_CT_EXT_HELPER,
10#if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
10 NF_CT_EXT_NAT, 11 NF_CT_EXT_NAT,
12#endif
11 NF_CT_EXT_ACCT, 13 NF_CT_EXT_ACCT,
14#ifdef CONFIG_NF_CONNTRACK_EVENTS
12 NF_CT_EXT_ECACHE, 15 NF_CT_EXT_ECACHE,
16#endif
17#ifdef CONFIG_NF_CONNTRACK_ZONES
13 NF_CT_EXT_ZONE, 18 NF_CT_EXT_ZONE,
19#endif
20#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
21 NF_CT_EXT_TSTAMP,
22#endif
14 NF_CT_EXT_NUM, 23 NF_CT_EXT_NUM,
15}; 24};
16 25
@@ -19,6 +28,7 @@ enum nf_ct_ext_id {
19#define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter 28#define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
20#define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache 29#define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache
21#define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone 30#define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone
31#define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp
22 32
23/* Extensions: optional stuff which isn't permanently in struct. */ 33/* Extensions: optional stuff which isn't permanently in struct. */
24struct nf_ct_ext { 34struct nf_ct_ext {
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index 32c305dbdab6..f1c1311adc2c 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -63,4 +63,10 @@ static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
63extern int nf_conntrack_helper_init(void); 63extern int nf_conntrack_helper_init(void);
64extern void nf_conntrack_helper_fini(void); 64extern void nf_conntrack_helper_fini(void);
65 65
66extern int nf_conntrack_broadcast_help(struct sk_buff *skb,
67 unsigned int protoff,
68 struct nf_conn *ct,
69 enum ip_conntrack_info ctinfo,
70 unsigned int timeout);
71
66#endif /*_NF_CONNTRACK_HELPER_H*/ 72#endif /*_NF_CONNTRACK_HELPER_H*/
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index a7547611e8f1..e8010f445ae1 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -73,7 +73,7 @@ struct nf_conntrack_l3proto {
73 struct module *me; 73 struct module *me;
74}; 74};
75 75
76extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX]; 76extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX];
77 77
78/* Protocol registration. */ 78/* Protocol registration. */
79extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); 79extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
diff --git a/include/net/netfilter/nf_conntrack_timestamp.h b/include/net/netfilter/nf_conntrack_timestamp.h
new file mode 100644
index 000000000000..fc9c82b1f06b
--- /dev/null
+++ b/include/net/netfilter/nf_conntrack_timestamp.h
@@ -0,0 +1,65 @@
1#ifndef _NF_CONNTRACK_TSTAMP_H
2#define _NF_CONNTRACK_TSTAMP_H
3
4#include <net/net_namespace.h>
5#include <linux/netfilter/nf_conntrack_common.h>
6#include <linux/netfilter/nf_conntrack_tuple_common.h>
7#include <net/netfilter/nf_conntrack.h>
8#include <net/netfilter/nf_conntrack_extend.h>
9
10struct nf_conn_tstamp {
11 u_int64_t start;
12 u_int64_t stop;
13};
14
15static inline
16struct nf_conn_tstamp *nf_conn_tstamp_find(const struct nf_conn *ct)
17{
18#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
19 return nf_ct_ext_find(ct, NF_CT_EXT_TSTAMP);
20#else
21 return NULL;
22#endif
23}
24
25static inline
26struct nf_conn_tstamp *nf_ct_tstamp_ext_add(struct nf_conn *ct, gfp_t gfp)
27{
28#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
29 struct net *net = nf_ct_net(ct);
30
31 if (!net->ct.sysctl_tstamp)
32 return NULL;
33
34 return nf_ct_ext_add(ct, NF_CT_EXT_TSTAMP, gfp);
35#else
36 return NULL;
37#endif
38};
39
40static inline bool nf_ct_tstamp_enabled(struct net *net)
41{
42 return net->ct.sysctl_tstamp != 0;
43}
44
45static inline void nf_ct_set_tstamp(struct net *net, bool enable)
46{
47 net->ct.sysctl_tstamp = enable;
48}
49
50#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
51extern int nf_conntrack_tstamp_init(struct net *net);
52extern void nf_conntrack_tstamp_fini(struct net *net);
53#else
54static inline int nf_conntrack_tstamp_init(struct net *net)
55{
56 return 0;
57}
58
59static inline void nf_conntrack_tstamp_fini(struct net *net)
60{
61 return;
62}
63#endif /* CONFIG_NF_CONNTRACK_TIMESTAMP */
64
65#endif /* _NF_CONNTRACK_TSTAMP_H */
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h
index 4ee44c84a304..7ca6bdd5bae6 100644
--- a/include/net/netfilter/nf_conntrack_tuple.h
+++ b/include/net/netfilter/nf_conntrack_tuple.h
@@ -104,8 +104,6 @@ struct nf_conntrack_tuple_mask {
104 } src; 104 } src;
105}; 105};
106 106
107#ifdef __KERNEL__
108
109static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t) 107static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t)
110{ 108{
111#ifdef DEBUG 109#ifdef DEBUG
@@ -148,8 +146,6 @@ struct nf_conntrack_tuple_hash {
148 struct nf_conntrack_tuple tuple; 146 struct nf_conntrack_tuple tuple;
149}; 147};
150 148
151#endif /* __KERNEL__ */
152
153static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, 149static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1,
154 const struct nf_conntrack_tuple *t2) 150 const struct nf_conntrack_tuple *t2)
155{ 151{
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h
index f5f09f032a90..0346b0070864 100644
--- a/include/net/netfilter/nf_nat.h
+++ b/include/net/netfilter/nf_nat.h
@@ -48,7 +48,6 @@ struct nf_nat_multi_range_compat {
48 struct nf_nat_range range[1]; 48 struct nf_nat_range range[1];
49}; 49};
50 50
51#ifdef __KERNEL__
52#include <linux/list.h> 51#include <linux/list.h>
53#include <linux/netfilter/nf_conntrack_pptp.h> 52#include <linux/netfilter/nf_conntrack_pptp.h>
54#include <net/netfilter/nf_conntrack_extend.h> 53#include <net/netfilter/nf_conntrack_extend.h>
@@ -56,7 +55,9 @@ struct nf_nat_multi_range_compat {
56/* per conntrack: nat application helper private data */ 55/* per conntrack: nat application helper private data */
57union nf_conntrack_nat_help { 56union nf_conntrack_nat_help {
58 /* insert nat helper private data here */ 57 /* insert nat helper private data here */
58#if defined(CONFIG_NF_NAT_PPTP) || defined(CONFIG_NF_NAT_PPTP_MODULE)
59 struct nf_nat_pptp nat_pptp_info; 59 struct nf_nat_pptp nat_pptp_info;
60#endif
60}; 61};
61 62
62struct nf_conn; 63struct nf_conn;
@@ -84,10 +85,11 @@ extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
84 85
85static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct) 86static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
86{ 87{
88#if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
87 return nf_ct_ext_find(ct, NF_CT_EXT_NAT); 89 return nf_ct_ext_find(ct, NF_CT_EXT_NAT);
90#else
91 return NULL;
92#endif
88} 93}
89 94
90#else /* !__KERNEL__: iptables wants this to compile. */
91#define nf_nat_multi_range nf_nat_multi_range_compat
92#endif /*__KERNEL__*/
93#endif 95#endif
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h
index 33602ab66190..3dc7b98effeb 100644
--- a/include/net/netfilter/nf_nat_core.h
+++ b/include/net/netfilter/nf_nat_core.h
@@ -21,9 +21,9 @@ static inline int nf_nat_initialized(struct nf_conn *ct,
21 enum nf_nat_manip_type manip) 21 enum nf_nat_manip_type manip)
22{ 22{
23 if (manip == IP_NAT_MANIP_SRC) 23 if (manip == IP_NAT_MANIP_SRC)
24 return test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status); 24 return ct->status & IPS_SRC_NAT_DONE;
25 else 25 else
26 return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status); 26 return ct->status & IPS_DST_NAT_DONE;
27} 27}
28 28
29struct nlattr; 29struct nlattr;
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h
index df17bac46bf5..93cc90d28e66 100644
--- a/include/net/netfilter/nf_nat_protocol.h
+++ b/include/net/netfilter/nf_nat_protocol.h
@@ -45,9 +45,6 @@ struct nf_nat_protocol {
45extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); 45extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
46extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); 46extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
47 47
48extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
49extern void nf_nat_proto_put(const struct nf_nat_protocol *proto);
50
51/* Built-in protocols. */ 48/* Built-in protocols. */
52extern const struct nf_nat_protocol nf_nat_protocol_tcp; 49extern const struct nf_nat_protocol nf_nat_protocol_tcp;
53extern const struct nf_nat_protocol nf_nat_protocol_udp; 50extern const struct nf_nat_protocol nf_nat_protocol_udp;
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h
index 208b46f4d6d2..e505358d8999 100644
--- a/include/net/netfilter/nf_tproxy_core.h
+++ b/include/net/netfilter/nf_tproxy_core.h
@@ -5,28 +5,204 @@
5#include <linux/in.h> 5#include <linux/in.h>
6#include <linux/skbuff.h> 6#include <linux/skbuff.h>
7#include <net/sock.h> 7#include <net/sock.h>
8#include <net/inet_sock.h> 8#include <net/inet_hashtables.h>
9#include <net/inet6_hashtables.h>
9#include <net/tcp.h> 10#include <net/tcp.h>
10 11
12#define NFT_LOOKUP_ANY 0
13#define NFT_LOOKUP_LISTENER 1
14#define NFT_LOOKUP_ESTABLISHED 2
15
11/* look up and get a reference to a matching socket */ 16/* look up and get a reference to a matching socket */
12extern struct sock * 17
18
19/* This function is used by the 'TPROXY' target and the 'socket'
20 * match. The following lookups are supported:
21 *
22 * Explicit TProxy target rule
23 * ===========================
24 *
25 * This is used when the user wants to intercept a connection matching
26 * an explicit iptables rule. In this case the sockets are assumed
27 * matching in preference order:
28 *
29 * - match: if there's a fully established connection matching the
30 * _packet_ tuple, it is returned, assuming the redirection
31 * already took place and we process a packet belonging to an
32 * established connection
33 *
34 * - match: if there's a listening socket matching the redirection
35 * (e.g. on-port & on-ip of the connection), it is returned,
36 * regardless if it was bound to 0.0.0.0 or an explicit
37 * address. The reasoning is that if there's an explicit rule, it
38 * does not really matter if the listener is bound to an interface
39 * or to 0. The user already stated that he wants redirection
40 * (since he added the rule).
41 *
42 * "socket" match based redirection (no specific rule)
43 * ===================================================
44 *
45 * There are connections with dynamic endpoints (e.g. FTP data
46 * connection) that the user is unable to add explicit rules
47 * for. These are taken care of by a generic "socket" rule. It is
48 * assumed that the proxy application is trusted to open such
49 * connections without explicit iptables rule (except of course the
50 * generic 'socket' rule). In this case the following sockets are
51 * matched in preference order:
52 *
53 * - match: if there's a fully established connection matching the
54 * _packet_ tuple
55 *
56 * - match: if there's a non-zero bound listener (possibly with a
57 * non-local address) We don't accept zero-bound listeners, since
58 * then local services could intercept traffic going through the
59 * box.
60 *
61 * Please note that there's an overlap between what a TPROXY target
62 * and a socket match will match. Normally if you have both rules the
63 * "socket" match will be the first one, effectively all packets
64 * belonging to established connections going through that one.
65 */
66static inline struct sock *
13nf_tproxy_get_sock_v4(struct net *net, const u8 protocol, 67nf_tproxy_get_sock_v4(struct net *net, const u8 protocol,
14 const __be32 saddr, const __be32 daddr, 68 const __be32 saddr, const __be32 daddr,
15 const __be16 sport, const __be16 dport, 69 const __be16 sport, const __be16 dport,
16 const struct net_device *in, bool listening); 70 const struct net_device *in, int lookup_type)
71{
72 struct sock *sk;
73
74 /* look up socket */
75 switch (protocol) {
76 case IPPROTO_TCP:
77 switch (lookup_type) {
78 case NFT_LOOKUP_ANY:
79 sk = __inet_lookup(net, &tcp_hashinfo,
80 saddr, sport, daddr, dport,
81 in->ifindex);
82 break;
83 case NFT_LOOKUP_LISTENER:
84 sk = inet_lookup_listener(net, &tcp_hashinfo,
85 daddr, dport,
86 in->ifindex);
17 87
18static inline void 88 /* NOTE: we return listeners even if bound to
19nf_tproxy_put_sock(struct sock *sk) 89 * 0.0.0.0, those are filtered out in
90 * xt_socket, since xt_TPROXY needs 0 bound
91 * listeners too */
92
93 break;
94 case NFT_LOOKUP_ESTABLISHED:
95 sk = inet_lookup_established(net, &tcp_hashinfo,
96 saddr, sport, daddr, dport,
97 in->ifindex);
98 break;
99 default:
100 WARN_ON(1);
101 sk = NULL;
102 break;
103 }
104 break;
105 case IPPROTO_UDP:
106 sk = udp4_lib_lookup(net, saddr, sport, daddr, dport,
107 in->ifindex);
108 if (sk && lookup_type != NFT_LOOKUP_ANY) {
109 int connected = (sk->sk_state == TCP_ESTABLISHED);
110 int wildcard = (inet_sk(sk)->inet_rcv_saddr == 0);
111
112 /* NOTE: we return listeners even if bound to
113 * 0.0.0.0, those are filtered out in
114 * xt_socket, since xt_TPROXY needs 0 bound
115 * listeners too */
116 if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
117 (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
118 sock_put(sk);
119 sk = NULL;
120 }
121 }
122 break;
123 default:
124 WARN_ON(1);
125 sk = NULL;
126 }
127
128 pr_debug("tproxy socket lookup: proto %u %08x:%u -> %08x:%u, lookup type: %d, sock %p\n",
129 protocol, ntohl(saddr), ntohs(sport), ntohl(daddr), ntohs(dport), lookup_type, sk);
130
131 return sk;
132}
133
134#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
135static inline struct sock *
136nf_tproxy_get_sock_v6(struct net *net, const u8 protocol,
137 const struct in6_addr *saddr, const struct in6_addr *daddr,
138 const __be16 sport, const __be16 dport,
139 const struct net_device *in, int lookup_type)
20{ 140{
21 /* TIME_WAIT inet sockets have to be handled differently */ 141 struct sock *sk;
22 if ((sk->sk_protocol == IPPROTO_TCP) && (sk->sk_state == TCP_TIME_WAIT)) 142
23 inet_twsk_put(inet_twsk(sk)); 143 /* look up socket */
24 else 144 switch (protocol) {
25 sock_put(sk); 145 case IPPROTO_TCP:
146 switch (lookup_type) {
147 case NFT_LOOKUP_ANY:
148 sk = inet6_lookup(net, &tcp_hashinfo,
149 saddr, sport, daddr, dport,
150 in->ifindex);
151 break;
152 case NFT_LOOKUP_LISTENER:
153 sk = inet6_lookup_listener(net, &tcp_hashinfo,
154 daddr, ntohs(dport),
155 in->ifindex);
156
157 /* NOTE: we return listeners even if bound to
158 * 0.0.0.0, those are filtered out in
159 * xt_socket, since xt_TPROXY needs 0 bound
160 * listeners too */
161
162 break;
163 case NFT_LOOKUP_ESTABLISHED:
164 sk = __inet6_lookup_established(net, &tcp_hashinfo,
165 saddr, sport, daddr, ntohs(dport),
166 in->ifindex);
167 break;
168 default:
169 WARN_ON(1);
170 sk = NULL;
171 break;
172 }
173 break;
174 case IPPROTO_UDP:
175 sk = udp6_lib_lookup(net, saddr, sport, daddr, dport,
176 in->ifindex);
177 if (sk && lookup_type != NFT_LOOKUP_ANY) {
178 int connected = (sk->sk_state == TCP_ESTABLISHED);
179 int wildcard = ipv6_addr_any(&inet6_sk(sk)->rcv_saddr);
180
181 /* NOTE: we return listeners even if bound to
182 * 0.0.0.0, those are filtered out in
183 * xt_socket, since xt_TPROXY needs 0 bound
184 * listeners too */
185 if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
186 (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
187 sock_put(sk);
188 sk = NULL;
189 }
190 }
191 break;
192 default:
193 WARN_ON(1);
194 sk = NULL;
195 }
196
197 pr_debug("tproxy socket lookup: proto %u %pI6:%u -> %pI6:%u, lookup type: %d, sock %p\n",
198 protocol, saddr, ntohs(sport), daddr, ntohs(dport), lookup_type, sk);
199
200 return sk;
26} 201}
202#endif
27 203
28/* assign a socket to the skb -- consumes sk */ 204/* assign a socket to the skb -- consumes sk */
29int 205void
30nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk); 206nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk);
31 207
32#endif 208#endif
diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h
new file mode 100644
index 000000000000..0dfb34a5b53c
--- /dev/null
+++ b/include/net/netfilter/xt_log.h
@@ -0,0 +1,54 @@
1#define S_SIZE (1024 - (sizeof(unsigned int) + 1))
2
3struct sbuff {
4 unsigned int count;
5 char buf[S_SIZE + 1];
6};
7static struct sbuff emergency, *emergency_ptr = &emergency;
8
9static int sb_add(struct sbuff *m, const char *f, ...)
10{
11 va_list args;
12 int len;
13
14 if (likely(m->count < S_SIZE)) {
15 va_start(args, f);
16 len = vsnprintf(m->buf + m->count, S_SIZE - m->count, f, args);
17 va_end(args);
18 if (likely(m->count + len < S_SIZE)) {
19 m->count += len;
20 return 0;
21 }
22 }
23 m->count = S_SIZE;
24 printk_once(KERN_ERR KBUILD_MODNAME " please increase S_SIZE\n");
25 return -1;
26}
27
28static struct sbuff *sb_open(void)
29{
30 struct sbuff *m = kmalloc(sizeof(*m), GFP_ATOMIC);
31
32 if (unlikely(!m)) {
33 local_bh_disable();
34 do {
35 m = xchg(&emergency_ptr, NULL);
36 } while (!m);
37 }
38 m->count = 0;
39 return m;
40}
41
42static void sb_close(struct sbuff *m)
43{
44 m->buf[m->count] = 0;
45 printk("%s\n", m->buf);
46
47 if (likely(m != &emergency))
48 kfree(m);
49 else {
50 xchg(&emergency_ptr, m);
51 local_bh_enable();
52 }
53}
54
diff --git a/include/net/netlink.h b/include/net/netlink.h
index f3b201d335b3..02740a94f108 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -225,13 +225,15 @@ extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb,
225 u32 pid, unsigned int group, int report, 225 u32 pid, unsigned int group, int report,
226 gfp_t flags); 226 gfp_t flags);
227 227
228extern int nla_validate(struct nlattr *head, int len, int maxtype, 228extern int nla_validate(const struct nlattr *head,
229 int len, int maxtype,
229 const struct nla_policy *policy); 230 const struct nla_policy *policy);
230extern int nla_parse(struct nlattr *tb[], int maxtype, 231extern int nla_parse(struct nlattr **tb, int maxtype,
231 struct nlattr *head, int len, 232 const struct nlattr *head, int len,
232 const struct nla_policy *policy); 233 const struct nla_policy *policy);
233extern int nla_policy_len(const struct nla_policy *, int); 234extern int nla_policy_len(const struct nla_policy *, int);
234extern struct nlattr * nla_find(struct nlattr *head, int len, int attrtype); 235extern struct nlattr * nla_find(const struct nlattr *head,
236 int len, int attrtype);
235extern size_t nla_strlcpy(char *dst, const struct nlattr *nla, 237extern size_t nla_strlcpy(char *dst, const struct nlattr *nla,
236 size_t dstsize); 238 size_t dstsize);
237extern int nla_memcpy(void *dest, const struct nlattr *src, int count); 239extern int nla_memcpy(void *dest, const struct nlattr *src, int count);
@@ -288,7 +290,7 @@ static inline int nlmsg_padlen(int payload)
288 290
289/** 291/**
290 * nlmsg_data - head of message payload 292 * nlmsg_data - head of message payload
291 * @nlh: netlink messsage header 293 * @nlh: netlink message header
292 */ 294 */
293static inline void *nlmsg_data(const struct nlmsghdr *nlh) 295static inline void *nlmsg_data(const struct nlmsghdr *nlh)
294{ 296{
@@ -346,7 +348,8 @@ static inline int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
346 * Returns the next netlink message in the message stream and 348 * Returns the next netlink message in the message stream and
347 * decrements remaining by the size of the current message. 349 * decrements remaining by the size of the current message.
348 */ 350 */
349static inline struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining) 351static inline struct nlmsghdr *
352nlmsg_next(const struct nlmsghdr *nlh, int *remaining)
350{ 353{
351 int totlen = NLMSG_ALIGN(nlh->nlmsg_len); 354 int totlen = NLMSG_ALIGN(nlh->nlmsg_len);
352 355
@@ -384,7 +387,7 @@ static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,
384 * 387 *
385 * Returns the first attribute which matches the specified type. 388 * Returns the first attribute which matches the specified type.
386 */ 389 */
387static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, 390static inline struct nlattr *nlmsg_find_attr(const struct nlmsghdr *nlh,
388 int hdrlen, int attrtype) 391 int hdrlen, int attrtype)
389{ 392{
390 return nla_find(nlmsg_attrdata(nlh, hdrlen), 393 return nla_find(nlmsg_attrdata(nlh, hdrlen),
@@ -398,7 +401,8 @@ static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh,
398 * @maxtype: maximum attribute type to be expected 401 * @maxtype: maximum attribute type to be expected
399 * @policy: validation policy 402 * @policy: validation policy
400 */ 403 */
401static inline int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, 404static inline int nlmsg_validate(const struct nlmsghdr *nlh,
405 int hdrlen, int maxtype,
402 const struct nla_policy *policy) 406 const struct nla_policy *policy)
403{ 407{
404 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) 408 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
@@ -727,7 +731,8 @@ static inline struct nlattr *nla_next(const struct nlattr *nla, int *remaining)
727 * 731 *
728 * Returns the first attribute which matches the specified type. 732 * Returns the first attribute which matches the specified type.
729 */ 733 */
730static inline struct nlattr *nla_find_nested(struct nlattr *nla, int attrtype) 734static inline struct nlattr *
735nla_find_nested(const struct nlattr *nla, int attrtype)
731{ 736{
732 return nla_find(nla_data(nla), nla_len(nla), attrtype); 737 return nla_find(nla_data(nla), nla_len(nla), attrtype);
733} 738}
@@ -851,18 +856,27 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
851#define NLA_PUT_BE16(skb, attrtype, value) \ 856#define NLA_PUT_BE16(skb, attrtype, value) \
852 NLA_PUT_TYPE(skb, __be16, attrtype, value) 857 NLA_PUT_TYPE(skb, __be16, attrtype, value)
853 858
859#define NLA_PUT_NET16(skb, attrtype, value) \
860 NLA_PUT_BE16(skb, attrtype | NLA_F_NET_BYTEORDER, value)
861
854#define NLA_PUT_U32(skb, attrtype, value) \ 862#define NLA_PUT_U32(skb, attrtype, value) \
855 NLA_PUT_TYPE(skb, u32, attrtype, value) 863 NLA_PUT_TYPE(skb, u32, attrtype, value)
856 864
857#define NLA_PUT_BE32(skb, attrtype, value) \ 865#define NLA_PUT_BE32(skb, attrtype, value) \
858 NLA_PUT_TYPE(skb, __be32, attrtype, value) 866 NLA_PUT_TYPE(skb, __be32, attrtype, value)
859 867
868#define NLA_PUT_NET32(skb, attrtype, value) \
869 NLA_PUT_BE32(skb, attrtype | NLA_F_NET_BYTEORDER, value)
870
860#define NLA_PUT_U64(skb, attrtype, value) \ 871#define NLA_PUT_U64(skb, attrtype, value) \
861 NLA_PUT_TYPE(skb, u64, attrtype, value) 872 NLA_PUT_TYPE(skb, u64, attrtype, value)
862 873
863#define NLA_PUT_BE64(skb, attrtype, value) \ 874#define NLA_PUT_BE64(skb, attrtype, value) \
864 NLA_PUT_TYPE(skb, __be64, attrtype, value) 875 NLA_PUT_TYPE(skb, __be64, attrtype, value)
865 876
877#define NLA_PUT_NET64(skb, attrtype, value) \
878 NLA_PUT_BE64(skb, attrtype | NLA_F_NET_BYTEORDER, value)
879
866#define NLA_PUT_STRING(skb, attrtype, value) \ 880#define NLA_PUT_STRING(skb, attrtype, value) \
867 NLA_PUT(skb, attrtype, strlen(value) + 1, value) 881 NLA_PUT(skb, attrtype, strlen(value) + 1, value)
868 882
@@ -1032,7 +1046,7 @@ static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start)
1032 * 1046 *
1033 * Returns 0 on success or a negative error code. 1047 * Returns 0 on success or a negative error code.
1034 */ 1048 */
1035static inline int nla_validate_nested(struct nlattr *start, int maxtype, 1049static inline int nla_validate_nested(const struct nlattr *start, int maxtype,
1036 const struct nla_policy *policy) 1050 const struct nla_policy *policy)
1037{ 1051{
1038 return nla_validate(nla_data(start), nla_len(start), maxtype, policy); 1052 return nla_validate(nla_data(start), nla_len(start), maxtype, policy);
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
index d4958d4c6574..341eb089349e 100644
--- a/include/net/netns/conntrack.h
+++ b/include/net/netns/conntrack.h
@@ -21,15 +21,15 @@ struct netns_ct {
21 int sysctl_events; 21 int sysctl_events;
22 unsigned int sysctl_events_retry_timeout; 22 unsigned int sysctl_events_retry_timeout;
23 int sysctl_acct; 23 int sysctl_acct;
24 int sysctl_tstamp;
24 int sysctl_checksum; 25 int sysctl_checksum;
25 unsigned int sysctl_log_invalid; /* Log invalid packets */ 26 unsigned int sysctl_log_invalid; /* Log invalid packets */
26#ifdef CONFIG_SYSCTL 27#ifdef CONFIG_SYSCTL
27 struct ctl_table_header *sysctl_header; 28 struct ctl_table_header *sysctl_header;
28 struct ctl_table_header *acct_sysctl_header; 29 struct ctl_table_header *acct_sysctl_header;
30 struct ctl_table_header *tstamp_sysctl_header;
29 struct ctl_table_header *event_sysctl_header; 31 struct ctl_table_header *event_sysctl_header;
30#endif 32#endif
31 int hash_vmalloc;
32 int expect_vmalloc;
33 char *slabname; 33 char *slabname;
34}; 34};
35#endif 35#endif
diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h
index 81a31c0db3e7..3419bf5cd154 100644
--- a/include/net/netns/generic.h
+++ b/include/net/netns/generic.h
@@ -30,7 +30,7 @@ struct net_generic {
30 void *ptr[0]; 30 void *ptr[0];
31}; 31};
32 32
33static inline void *net_generic(struct net *net, int id) 33static inline void *net_generic(const struct net *net, int id)
34{ 34{
35 struct net_generic *ng; 35 struct net_generic *ng;
36 void *ptr; 36 void *ptr;
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index d68c3f121774..d786b4fc02a4 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -43,7 +43,6 @@ struct netns_ipv4 {
43 struct xt_table *nat_table; 43 struct xt_table *nat_table;
44 struct hlist_head *nat_bysource; 44 struct hlist_head *nat_bysource;
45 unsigned int nat_htable_size; 45 unsigned int nat_htable_size;
46 int nat_vmalloced;
47#endif 46#endif
48 47
49 int sysctl_icmp_echo_ignore_all; 48 int sysctl_icmp_echo_ignore_all;
@@ -55,7 +54,10 @@ struct netns_ipv4 {
55 int sysctl_rt_cache_rebuild_count; 54 int sysctl_rt_cache_rebuild_count;
56 int current_rt_cache_rebuild_count; 55 int current_rt_cache_rebuild_count;
57 56
57 unsigned int sysctl_ping_group_range[2];
58
58 atomic_t rt_genid; 59 atomic_t rt_genid;
60 atomic_t dev_addr_genid;
59 61
60#ifdef CONFIG_IP_MROUTE 62#ifdef CONFIG_IP_MROUTE
61#ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES 63#ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
index 74f119a2829a..748f91f87cd5 100644
--- a/include/net/netns/xfrm.h
+++ b/include/net/netns/xfrm.h
@@ -43,10 +43,6 @@ struct netns_xfrm {
43 unsigned int policy_count[XFRM_POLICY_MAX * 2]; 43 unsigned int policy_count[XFRM_POLICY_MAX * 2];
44 struct work_struct policy_hash_work; 44 struct work_struct policy_hash_work;
45 45
46 struct dst_ops xfrm4_dst_ops;
47#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
48 struct dst_ops xfrm6_dst_ops;
49#endif
50 46
51 struct sock *nlsk; 47 struct sock *nlsk;
52 struct sock *nlsk_stash; 48 struct sock *nlsk_stash;
@@ -58,6 +54,11 @@ struct netns_xfrm {
58#ifdef CONFIG_SYSCTL 54#ifdef CONFIG_SYSCTL
59 struct ctl_table_header *sysctl_hdr; 55 struct ctl_table_header *sysctl_hdr;
60#endif 56#endif
57
58 struct dst_ops xfrm4_dst_ops;
59#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
60 struct dst_ops xfrm6_dst_ops;
61#endif
61}; 62};
62 63
63#endif 64#endif
diff --git a/include/net/phonet/pep.h b/include/net/phonet/pep.h
index 35672b1cf44a..b669fe6dbc3b 100644
--- a/include/net/phonet/pep.h
+++ b/include/net/phonet/pep.h
@@ -28,7 +28,6 @@ struct pep_sock {
28 28
29 /* XXX: union-ify listening vs connected stuff ? */ 29 /* XXX: union-ify listening vs connected stuff ? */
30 /* Listening socket stuff: */ 30 /* Listening socket stuff: */
31 struct hlist_head ackq;
32 struct hlist_head hlist; 31 struct hlist_head hlist;
33 32
34 /* Connected socket stuff: */ 33 /* Connected socket stuff: */
@@ -77,6 +76,11 @@ static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb)
77#define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4) 76#define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)
78 77
79enum { 78enum {
79 PNS_PIPE_CREATE_REQ = 0x00,
80 PNS_PIPE_CREATE_RESP,
81 PNS_PIPE_REMOVE_REQ,
82 PNS_PIPE_REMOVE_RESP,
83
80 PNS_PIPE_DATA = 0x20, 84 PNS_PIPE_DATA = 0x20,
81 PNS_PIPE_ALIGNED_DATA, 85 PNS_PIPE_ALIGNED_DATA,
82 86
@@ -149,6 +153,7 @@ enum {
149 PN_LEGACY_FLOW_CONTROL, 153 PN_LEGACY_FLOW_CONTROL,
150 PN_ONE_CREDIT_FLOW_CONTROL, 154 PN_ONE_CREDIT_FLOW_CONTROL,
151 PN_MULTI_CREDIT_FLOW_CONTROL, 155 PN_MULTI_CREDIT_FLOW_CONTROL,
156 PN_MAX_FLOW_CONTROL,
152}; 157};
153 158
154#define pn_flow_safe(fc) ((fc) >> 1) 159#define pn_flow_safe(fc) ((fc) >> 1)
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
index 7b114079a51b..68e509750caa 100644
--- a/include/net/phonet/phonet.h
+++ b/include/net/phonet/phonet.h
@@ -36,6 +36,7 @@
36struct pn_sock { 36struct pn_sock {
37 struct sock sk; 37 struct sock sk;
38 u16 sobject; 38 u16 sobject;
39 u16 dobject;
39 u8 resource; 40 u8 resource;
40}; 41};
41 42
@@ -54,6 +55,11 @@ void pn_sock_hash(struct sock *sk);
54void pn_sock_unhash(struct sock *sk); 55void pn_sock_unhash(struct sock *sk);
55int pn_sock_get_port(struct sock *sk, unsigned short sport); 56int pn_sock_get_port(struct sock *sk, unsigned short sport);
56 57
58struct sock *pn_find_sock_by_res(struct net *net, u8 res);
59int pn_sock_bind_res(struct sock *sock, u8 res);
60int pn_sock_unbind_res(struct sock *sk, u8 res);
61void pn_sock_unbind_all_res(struct sock *sk);
62
57int pn_skb_send(struct sock *sk, struct sk_buff *skb, 63int pn_skb_send(struct sock *sk, struct sk_buff *skb,
58 const struct sockaddr_pn *target); 64 const struct sockaddr_pn *target);
59 65
@@ -102,8 +108,8 @@ struct phonet_protocol {
102 int sock_type; 108 int sock_type;
103}; 109};
104 110
105int phonet_proto_register(int protocol, struct phonet_protocol *pp); 111int phonet_proto_register(unsigned int protocol, struct phonet_protocol *pp);
106void phonet_proto_unregister(int protocol, struct phonet_protocol *pp); 112void phonet_proto_unregister(unsigned int protocol, struct phonet_protocol *pp);
107 113
108int phonet_sysctl_init(void); 114int phonet_sysctl_init(void);
109void phonet_sysctl_exit(void); 115void phonet_sysctl_exit(void);
diff --git a/include/net/phonet/pn_dev.h b/include/net/phonet/pn_dev.h
index 2d16783d5e20..8639de5750f6 100644
--- a/include/net/phonet/pn_dev.h
+++ b/include/net/phonet/pn_dev.h
@@ -51,11 +51,12 @@ void phonet_address_notify(int event, struct net_device *dev, u8 addr);
51int phonet_route_add(struct net_device *dev, u8 daddr); 51int phonet_route_add(struct net_device *dev, u8 daddr);
52int phonet_route_del(struct net_device *dev, u8 daddr); 52int phonet_route_del(struct net_device *dev, u8 daddr);
53void rtm_phonet_notify(int event, struct net_device *dev, u8 dst); 53void rtm_phonet_notify(int event, struct net_device *dev, u8 dst);
54struct net_device *phonet_route_get(struct net *net, u8 daddr); 54struct net_device *phonet_route_get_rcu(struct net *net, u8 daddr);
55struct net_device *phonet_route_output(struct net *net, u8 daddr); 55struct net_device *phonet_route_output(struct net *net, u8 daddr);
56 56
57#define PN_NO_ADDR 0xff 57#define PN_NO_ADDR 0xff
58 58
59extern const struct file_operations pn_sock_seq_fops; 59extern const struct file_operations pn_sock_seq_fops;
60extern const struct file_operations pn_res_seq_fops;
60 61
61#endif 62#endif
diff --git a/include/net/ping.h b/include/net/ping.h
new file mode 100644
index 000000000000..682b5ae9af51
--- /dev/null
+++ b/include/net/ping.h
@@ -0,0 +1,55 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Definitions for the "ping" module.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#ifndef _PING_H
14#define _PING_H
15
16#include <net/netns/hash.h>
17
18/* PING_HTABLE_SIZE must be power of 2 */
19#define PING_HTABLE_SIZE 64
20#define PING_HTABLE_MASK (PING_HTABLE_SIZE-1)
21
22#define ping_portaddr_for_each_entry(__sk, node, list) \
23 hlist_nulls_for_each_entry(__sk, node, list, sk_nulls_node)
24
25/*
26 * gid_t is either uint or ushort. We want to pass it to
27 * proc_dointvec_minmax(), so it must not be larger than MAX_INT
28 */
29#define GID_T_MAX (((gid_t)~0U) >> 1)
30
31struct ping_table {
32 struct hlist_nulls_head hash[PING_HTABLE_SIZE];
33 rwlock_t lock;
34};
35
36struct ping_iter_state {
37 struct seq_net_private p;
38 int bucket;
39};
40
41extern struct proto ping_prot;
42
43
44extern void ping_rcv(struct sk_buff *);
45extern void ping_err(struct sk_buff *, u32 info);
46
47#ifdef CONFIG_PROC_FS
48extern int __init ping_proc_init(void);
49extern void ping_proc_exit(void);
50#endif
51
52void __init ping_init(void);
53
54
55#endif /* _PING_H */
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index dd3031aed9d5..9fcc680ab6b9 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -323,7 +323,9 @@ static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer)
323static inline int tcf_valid_offset(const struct sk_buff *skb, 323static inline int tcf_valid_offset(const struct sk_buff *skb,
324 const unsigned char *ptr, const int len) 324 const unsigned char *ptr, const int len)
325{ 325{
326 return unlikely((ptr + len) < skb_tail_pointer(skb) && ptr > skb->head); 326 return likely((ptr + len) <= skb_tail_pointer(skb) &&
327 ptr >= skb->head &&
328 (ptr <= (ptr + len)));
327} 329}
328 330
329#ifdef CONFIG_NET_CLS_IND 331#ifdef CONFIG_NET_CLS_IND
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index d9549af6929a..65afc4966204 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -32,7 +32,7 @@ static inline void *qdisc_priv(struct Qdisc *q)
32 32
33 The result: [34]86 is not good choice for QoS router :-( 33 The result: [34]86 is not good choice for QoS router :-(
34 34
35 The things are not so bad, because we may use artifical 35 The things are not so bad, because we may use artificial
36 clock evaluated by integration of network data flow 36 clock evaluated by integration of network data flow
37 in the most critical places. 37 in the most critical places.
38 */ 38 */
diff --git a/include/net/protocol.h b/include/net/protocol.h
index f1effdd3c265..6f7eb800974a 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -38,7 +38,7 @@ struct net_protocol {
38 void (*err_handler)(struct sk_buff *skb, u32 info); 38 void (*err_handler)(struct sk_buff *skb, u32 info);
39 int (*gso_send_check)(struct sk_buff *skb); 39 int (*gso_send_check)(struct sk_buff *skb);
40 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 40 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
41 int features); 41 u32 features);
42 struct sk_buff **(*gro_receive)(struct sk_buff **head, 42 struct sk_buff **(*gro_receive)(struct sk_buff **head,
43 struct sk_buff *skb); 43 struct sk_buff *skb);
44 int (*gro_complete)(struct sk_buff *skb); 44 int (*gro_complete)(struct sk_buff *skb);
@@ -57,7 +57,7 @@ struct inet6_protocol {
57 57
58 int (*gso_send_check)(struct sk_buff *skb); 58 int (*gso_send_check)(struct sk_buff *skb);
59 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 59 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
60 int features); 60 u32 features);
61 struct sk_buff **(*gro_receive)(struct sk_buff **head, 61 struct sk_buff **(*gro_receive)(struct sk_buff **head,
62 struct sk_buff *skb); 62 struct sk_buff *skb);
63 int (*gro_complete)(struct sk_buff *skb); 63 int (*gro_complete)(struct sk_buff *skb);
@@ -89,10 +89,10 @@ struct inet_protosw {
89#define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ 89#define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */
90#define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ 90#define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */
91 91
92extern const struct net_protocol *inet_protos[MAX_INET_PROTOS]; 92extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS];
93 93
94#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 94#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
95extern const struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; 95extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS];
96#endif 96#endif
97 97
98extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num); 98extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num);
diff --git a/include/net/raw.h b/include/net/raw.h
index 43c57502659b..42ce6fe7a2d5 100644
--- a/include/net/raw.h
+++ b/include/net/raw.h
@@ -45,7 +45,10 @@ struct raw_iter_state {
45 struct raw_hashinfo *h; 45 struct raw_hashinfo *h;
46}; 46};
47 47
48#define raw_seq_private(seq) ((struct raw_iter_state *)(seq)->private) 48static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq)
49{
50 return seq->private;
51}
49void *raw_seq_start(struct seq_file *seq, loff_t *pos); 52void *raw_seq_start(struct seq_file *seq, loff_t *pos);
50void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos); 53void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
51void raw_seq_stop(struct seq_file *seq, void *v); 54void raw_seq_stop(struct seq_file *seq, void *v);
diff --git a/include/net/rawv6.h b/include/net/rawv6.h
index f6b9b830df8c..cf7577234457 100644
--- a/include/net/rawv6.h
+++ b/include/net/rawv6.h
@@ -1,8 +1,6 @@
1#ifndef _NET_RAWV6_H 1#ifndef _NET_RAWV6_H
2#define _NET_RAWV6_H 2#define _NET_RAWV6_H
3 3
4#ifdef __KERNEL__
5
6#include <net/protocol.h> 4#include <net/protocol.h>
7 5
8void raw6_icmp_error(struct sk_buff *, int nexthdr, 6void raw6_icmp_error(struct sk_buff *, int nexthdr,
@@ -20,5 +18,3 @@ int rawv6_mh_filter_unregister(int (*filter)(struct sock *sock,
20#endif 18#endif
21 19
22#endif 20#endif
23
24#endif
diff --git a/include/net/red.h b/include/net/red.h
index 995108e54d9f..3319f16b3beb 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -97,7 +97,6 @@ struct red_stats {
97 u32 forced_mark; /* Forced marks, qavg > max_thresh */ 97 u32 forced_mark; /* Forced marks, qavg > max_thresh */
98 u32 pdrop; /* Drops due to queue limits */ 98 u32 pdrop; /* Drops due to queue limits */
99 u32 other; /* Drops due to drop() calls */ 99 u32 other; /* Drops due to drop() calls */
100 u32 backlog;
101}; 100};
102 101
103struct red_parms { 102struct red_parms {
diff --git a/include/net/regulatory.h b/include/net/regulatory.h
index 9e103a4e91ee..356d6e3dc20a 100644
--- a/include/net/regulatory.h
+++ b/include/net/regulatory.h
@@ -43,6 +43,12 @@ enum environment_cap {
43 * @intersect: indicates whether the wireless core should intersect 43 * @intersect: indicates whether the wireless core should intersect
44 * the requested regulatory domain with the presently set regulatory 44 * the requested regulatory domain with the presently set regulatory
45 * domain. 45 * domain.
46 * @processed: indicates whether or not this requests has already been
47 * processed. When the last request is processed it means that the
48 * currently regulatory domain set on cfg80211 is updated from
49 * CRDA and can be used by other regulatory requests. When a
50 * the last request is not yet processed we must yield until it
51 * is processed before processing any new requests.
46 * @country_ie_checksum: checksum of the last processed and accepted 52 * @country_ie_checksum: checksum of the last processed and accepted
47 * country IE 53 * country IE
48 * @country_ie_env: lets us know if the AP is telling us we are outdoor, 54 * @country_ie_env: lets us know if the AP is telling us we are outdoor,
@@ -54,6 +60,7 @@ struct regulatory_request {
54 enum nl80211_reg_initiator initiator; 60 enum nl80211_reg_initiator initiator;
55 char alpha2[2]; 61 char alpha2[2];
56 bool intersect; 62 bool intersect;
63 bool processed;
57 enum environment_cap country_ie_env; 64 enum environment_cap country_ie_env;
58 struct list_head list; 65 struct list_head list;
59}; 66};
diff --git a/include/net/rose.h b/include/net/rose.h
index 5ba9f02731eb..555dd198aab7 100644
--- a/include/net/rose.h
+++ b/include/net/rose.h
@@ -14,6 +14,12 @@
14 14
15#define ROSE_MIN_LEN 3 15#define ROSE_MIN_LEN 3
16 16
17#define ROSE_CALL_REQ_ADDR_LEN_OFF 3
18#define ROSE_CALL_REQ_ADDR_LEN_VAL 0xAA /* each address is 10 digits */
19#define ROSE_CALL_REQ_DEST_ADDR_OFF 4
20#define ROSE_CALL_REQ_SRC_ADDR_OFF 9
21#define ROSE_CALL_REQ_FACILITIES_OFF 14
22
17#define ROSE_GFI 0x10 23#define ROSE_GFI 0x10
18#define ROSE_Q_BIT 0x80 24#define ROSE_Q_BIT 0x80
19#define ROSE_D_BIT 0x40 25#define ROSE_D_BIT 0x40
@@ -214,7 +220,7 @@ extern void rose_requeue_frames(struct sock *);
214extern int rose_validate_nr(struct sock *, unsigned short); 220extern int rose_validate_nr(struct sock *, unsigned short);
215extern void rose_write_internal(struct sock *, int); 221extern void rose_write_internal(struct sock *, int);
216extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *); 222extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
217extern int rose_parse_facilities(unsigned char *, struct rose_facilities_struct *); 223extern int rose_parse_facilities(unsigned char *, unsigned int, struct rose_facilities_struct *);
218extern void rose_disconnect(struct sock *, int, int, int); 224extern void rose_disconnect(struct sock *, int, int, int);
219 225
220/* rose_timer.c */ 226/* rose_timer.c */
diff --git a/include/net/route.h b/include/net/route.h
index 7e5e73bfa4de..db7b3432f07c 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -35,44 +35,52 @@
35#include <linux/cache.h> 35#include <linux/cache.h>
36#include <linux/security.h> 36#include <linux/security.h>
37 37
38#ifndef __KERNEL__
39#warning This file is not supposed to be used outside of kernel.
40#endif
41
42#define RTO_ONLINK 0x01 38#define RTO_ONLINK 0x01
43 39
44#define RTO_CONN 0
45/* RTO_CONN is not used (being alias for 0), but preserved not to break
46 * some modules referring to it. */
47
48#define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE)) 40#define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE))
49 41
50struct fib_nh; 42struct fib_nh;
51struct inet_peer; 43struct inet_peer;
44struct fib_info;
52struct rtable { 45struct rtable {
53 struct dst_entry dst; 46 struct dst_entry dst;
54 47
55 /* Cache lookup keys */ 48 /* Lookup key. */
56 struct flowi fl; 49 __be32 rt_key_dst;
50 __be32 rt_key_src;
57 51
58 struct in_device *idev;
59
60 int rt_genid; 52 int rt_genid;
61 unsigned rt_flags; 53 unsigned rt_flags;
62 __u16 rt_type; 54 __u16 rt_type;
55 __u8 rt_key_tos;
63 56
64 __be32 rt_dst; /* Path destination */ 57 __be32 rt_dst; /* Path destination */
65 __be32 rt_src; /* Path source */ 58 __be32 rt_src; /* Path source */
59 int rt_route_iif;
66 int rt_iif; 60 int rt_iif;
61 int rt_oif;
62 __u32 rt_mark;
67 63
68 /* Info on neighbour */ 64 /* Info on neighbour */
69 __be32 rt_gateway; 65 __be32 rt_gateway;
70 66
71 /* Miscellaneous cached information */ 67 /* Miscellaneous cached information */
72 __be32 rt_spec_dst; /* RFC1122 specific destination */ 68 __be32 rt_spec_dst; /* RFC1122 specific destination */
69 u32 rt_peer_genid;
73 struct inet_peer *peer; /* long-living peer info */ 70 struct inet_peer *peer; /* long-living peer info */
71 struct fib_info *fi; /* for client ref to shared metrics */
74}; 72};
75 73
74static inline bool rt_is_input_route(struct rtable *rt)
75{
76 return rt->rt_route_iif != 0;
77}
78
79static inline bool rt_is_output_route(struct rtable *rt)
80{
81 return rt->rt_route_iif == 0;
82}
83
76struct ip_rt_acct { 84struct ip_rt_acct {
77 __u32 o_bytes; 85 __u32 o_bytes;
78 __u32 o_packets; 86 __u32 o_packets;
@@ -106,10 +114,57 @@ extern int ip_rt_init(void);
106extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, 114extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw,
107 __be32 src, struct net_device *dev); 115 __be32 src, struct net_device *dev);
108extern void rt_cache_flush(struct net *net, int how); 116extern void rt_cache_flush(struct net *net, int how);
109extern void rt_cache_flush_batch(void); 117extern void rt_cache_flush_batch(struct net *net);
110extern int __ip_route_output_key(struct net *, struct rtable **, const struct flowi *flp); 118extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp);
111extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp); 119extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
112extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); 120 struct sock *sk);
121extern struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig);
122
123static inline struct rtable *ip_route_output_key(struct net *net, struct flowi4 *flp)
124{
125 return ip_route_output_flow(net, flp, NULL);
126}
127
128static inline struct rtable *ip_route_output(struct net *net, __be32 daddr,
129 __be32 saddr, u8 tos, int oif)
130{
131 struct flowi4 fl4 = {
132 .flowi4_oif = oif,
133 .daddr = daddr,
134 .saddr = saddr,
135 .flowi4_tos = tos,
136 };
137 return ip_route_output_key(net, &fl4);
138}
139
140static inline struct rtable *ip_route_output_ports(struct net *net, struct flowi4 *fl4,
141 struct sock *sk,
142 __be32 daddr, __be32 saddr,
143 __be16 dport, __be16 sport,
144 __u8 proto, __u8 tos, int oif)
145{
146 flowi4_init_output(fl4, oif, sk ? sk->sk_mark : 0, tos,
147 RT_SCOPE_UNIVERSE, proto,
148 sk ? inet_sk_flowi_flags(sk) : 0,
149 daddr, saddr, dport, sport);
150 if (sk)
151 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
152 return ip_route_output_flow(net, fl4, sk);
153}
154
155static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4 *fl4,
156 __be32 daddr, __be32 saddr,
157 __be32 gre_key, __u8 tos, int oif)
158{
159 memset(fl4, 0, sizeof(*fl4));
160 fl4->flowi4_oif = oif;
161 fl4->daddr = daddr;
162 fl4->saddr = saddr;
163 fl4->flowi4_tos = tos;
164 fl4->flowi4_proto = IPPROTO_GRE;
165 fl4->fl4_gre_key = gre_key;
166 return ip_route_output_key(net, fl4);
167}
113 168
114extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, 169extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src,
115 u8 tos, struct net_device *devin, bool noref); 170 u8 tos, struct net_device *devin, bool noref);
@@ -126,18 +181,20 @@ static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 s
126 return ip_route_input_common(skb, dst, src, tos, devin, true); 181 return ip_route_input_common(skb, dst, src, tos, devin, true);
127} 182}
128 183
129extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev); 184extern unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph,
185 unsigned short new_mtu, struct net_device *dev);
130extern void ip_rt_send_redirect(struct sk_buff *skb); 186extern void ip_rt_send_redirect(struct sk_buff *skb);
131 187
132extern unsigned inet_addr_type(struct net *net, __be32 addr); 188extern unsigned inet_addr_type(struct net *net, __be32 addr);
133extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr); 189extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr);
134extern void ip_rt_multicast_event(struct in_device *); 190extern void ip_rt_multicast_event(struct in_device *);
135extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg); 191extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg);
136extern void ip_rt_get_source(u8 *src, struct rtable *rt); 192extern void ip_rt_get_source(u8 *src, struct sk_buff *skb, struct rtable *rt);
137extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); 193extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb);
138 194
139struct in_ifaddr; 195struct in_ifaddr;
140extern void fib_add_ifaddr(struct in_ifaddr *); 196extern void fib_add_ifaddr(struct in_ifaddr *);
197extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *);
141 198
142static inline void ip_rt_put(struct rtable * rt) 199static inline void ip_rt_put(struct rtable * rt)
143{ 200{
@@ -154,69 +211,93 @@ static inline char rt_tos2priority(u8 tos)
154 return ip_tos2prio[IPTOS_TOS(tos)>>1]; 211 return ip_tos2prio[IPTOS_TOS(tos)>>1];
155} 212}
156 213
157static inline int ip_route_connect(struct rtable **rp, __be32 dst, 214/* ip_route_connect() and ip_route_newports() work in tandem whilst
158 __be32 src, u32 tos, int oif, u8 protocol, 215 * binding a socket for a new outgoing connection.
159 __be16 sport, __be16 dport, struct sock *sk, 216 *
160 int flags) 217 * In order to use IPSEC properly, we must, in the end, have a
218 * route that was looked up using all available keys including source
219 * and destination ports.
220 *
221 * However, if a source port needs to be allocated (the user specified
222 * a wildcard source port) we need to obtain addressing information
223 * in order to perform that allocation.
224 *
225 * So ip_route_connect() looks up a route using wildcarded source and
226 * destination ports in the key, simply so that we can get a pair of
227 * addresses to use for port allocation.
228 *
229 * Later, once the ports are allocated, ip_route_newports() will make
230 * another route lookup if needed to make sure we catch any IPSEC
231 * rules keyed on the port information.
232 *
233 * The callers allocate the flow key on their stack, and must pass in
234 * the same flowi4 object to both the ip_route_connect() and the
235 * ip_route_newports() calls.
236 */
237
238static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32 src,
239 u32 tos, int oif, u8 protocol,
240 __be16 sport, __be16 dport,
241 struct sock *sk, bool can_sleep)
161{ 242{
162 struct flowi fl = { .oif = oif, 243 __u8 flow_flags = 0;
163 .mark = sk->sk_mark, 244
164 .nl_u = { .ip4_u = { .daddr = dst, 245 if (inet_sk(sk)->transparent)
165 .saddr = src, 246 flow_flags |= FLOWI_FLAG_ANYSRC;
166 .tos = tos } }, 247 if (protocol == IPPROTO_TCP)
167 .proto = protocol, 248 flow_flags |= FLOWI_FLAG_PRECOW_METRICS;
168 .uli_u = { .ports = 249 if (can_sleep)
169 { .sport = sport, 250 flow_flags |= FLOWI_FLAG_CAN_SLEEP;
170 .dport = dport } } }; 251
252 flowi4_init_output(fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE,
253 protocol, flow_flags, dst, src, dport, sport);
254}
171 255
172 int err; 256static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
257 __be32 dst, __be32 src, u32 tos,
258 int oif, u8 protocol,
259 __be16 sport, __be16 dport,
260 struct sock *sk, bool can_sleep)
261{
173 struct net *net = sock_net(sk); 262 struct net *net = sock_net(sk);
263 struct rtable *rt;
174 264
175 if (inet_sk(sk)->transparent) 265 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
176 fl.flags |= FLOWI_FLAG_ANYSRC; 266 sport, dport, sk, can_sleep);
177 267
178 if (!dst || !src) { 268 if (!dst || !src) {
179 err = __ip_route_output_key(net, rp, &fl); 269 rt = __ip_route_output_key(net, fl4);
180 if (err) 270 if (IS_ERR(rt))
181 return err; 271 return rt;
182 fl.fl4_dst = (*rp)->rt_dst; 272 ip_rt_put(rt);
183 fl.fl4_src = (*rp)->rt_src;
184 ip_rt_put(*rp);
185 *rp = NULL;
186 } 273 }
187 security_sk_classify_flow(sk, &fl); 274 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
188 return ip_route_output_flow(net, rp, &fl, sk, flags); 275 return ip_route_output_flow(net, fl4, sk);
189} 276}
190 277
191static inline int ip_route_newports(struct rtable **rp, u8 protocol, 278static inline struct rtable *ip_route_newports(struct flowi4 *fl4, struct rtable *rt,
192 __be16 sport, __be16 dport, struct sock *sk) 279 __be16 orig_sport, __be16 orig_dport,
193{ 280 __be16 sport, __be16 dport,
194 if (sport != (*rp)->fl.fl_ip_sport || 281 struct sock *sk)
195 dport != (*rp)->fl.fl_ip_dport) { 282{
196 struct flowi fl; 283 if (sport != orig_sport || dport != orig_dport) {
197 284 fl4->fl4_dport = dport;
198 memcpy(&fl, &(*rp)->fl, sizeof(fl)); 285 fl4->fl4_sport = sport;
199 fl.fl_ip_sport = sport; 286 ip_rt_put(rt);
200 fl.fl_ip_dport = dport; 287 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
201 fl.proto = protocol; 288 return ip_route_output_flow(sock_net(sk), fl4, sk);
202 if (inet_sk(sk)->transparent)
203 fl.flags |= FLOWI_FLAG_ANYSRC;
204 ip_rt_put(*rp);
205 *rp = NULL;
206 security_sk_classify_flow(sk, &fl);
207 return ip_route_output_flow(sock_net(sk), rp, &fl, sk, 0);
208 } 289 }
209 return 0; 290 return rt;
210} 291}
211 292
212extern void rt_bind_peer(struct rtable *rt, int create); 293extern void rt_bind_peer(struct rtable *rt, __be32 daddr, int create);
213 294
214static inline struct inet_peer *rt_get_peer(struct rtable *rt) 295static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr)
215{ 296{
216 if (rt->peer) 297 if (rt->peer)
217 return rt->peer; 298 return rt->peer;
218 299
219 rt_bind_peer(rt, 0); 300 rt_bind_peer(rt, daddr, 0);
220 return rt->peer; 301 return rt->peer;
221} 302}
222 303
@@ -225,4 +306,15 @@ static inline int inet_iif(const struct sk_buff *skb)
225 return skb_rtable(skb)->rt_iif; 306 return skb_rtable(skb)->rt_iif;
226} 307}
227 308
309extern int sysctl_ip_default_ttl;
310
311static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
312{
313 int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT);
314
315 if (hoplimit == 0)
316 hoplimit = sysctl_ip_default_ttl;
317 return hoplimit;
318}
319
228#endif /* _ROUTE_H */ 320#endif /* _ROUTE_H */
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index af60fd050844..4093ca78cf60 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -79,11 +79,45 @@ struct rtnl_link_ops {
79 79
80extern int __rtnl_link_register(struct rtnl_link_ops *ops); 80extern int __rtnl_link_register(struct rtnl_link_ops *ops);
81extern void __rtnl_link_unregister(struct rtnl_link_ops *ops); 81extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
82extern void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops);
83 82
84extern int rtnl_link_register(struct rtnl_link_ops *ops); 83extern int rtnl_link_register(struct rtnl_link_ops *ops);
85extern void rtnl_link_unregister(struct rtnl_link_ops *ops); 84extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
86 85
86/**
87 * struct rtnl_af_ops - rtnetlink address family operations
88 *
89 * @list: Used internally
90 * @family: Address family
91 * @fill_link_af: Function to fill IFLA_AF_SPEC with address family
92 * specific netlink attributes.
93 * @get_link_af_size: Function to calculate size of address family specific
94 * netlink attributes exlusive the container attribute.
95 * @validate_link_af: Validate a IFLA_AF_SPEC attribute, must check attr
96 * for invalid configuration settings.
97 * @set_link_af: Function to parse a IFLA_AF_SPEC attribute and modify
98 * net_device accordingly.
99 */
100struct rtnl_af_ops {
101 struct list_head list;
102 int family;
103
104 int (*fill_link_af)(struct sk_buff *skb,
105 const struct net_device *dev);
106 size_t (*get_link_af_size)(const struct net_device *dev);
107
108 int (*validate_link_af)(const struct net_device *dev,
109 const struct nlattr *attr);
110 int (*set_link_af)(struct net_device *dev,
111 const struct nlattr *attr);
112};
113
114extern int __rtnl_af_register(struct rtnl_af_ops *ops);
115extern void __rtnl_af_unregister(struct rtnl_af_ops *ops);
116
117extern int rtnl_af_register(struct rtnl_af_ops *ops);
118extern void rtnl_af_unregister(struct rtnl_af_ops *ops);
119
120
87extern struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]); 121extern struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);
88extern struct net_device *rtnl_create_link(struct net *src_net, struct net *net, 122extern struct net_device *rtnl_create_link(struct net *src_net, struct net *net,
89 char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]); 123 char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]);
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 3c8728aaab4e..b931f021d7ab 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -25,16 +25,18 @@ struct qdisc_rate_table {
25enum qdisc_state_t { 25enum qdisc_state_t {
26 __QDISC_STATE_SCHED, 26 __QDISC_STATE_SCHED,
27 __QDISC_STATE_DEACTIVATED, 27 __QDISC_STATE_DEACTIVATED,
28 __QDISC_STATE_THROTTLED,
28}; 29};
29 30
30/* 31/*
31 * following bits are only changed while qdisc lock is held 32 * following bits are only changed while qdisc lock is held
32 */ 33 */
33enum qdisc___state_t { 34enum qdisc___state_t {
34 __QDISC___STATE_RUNNING, 35 __QDISC___STATE_RUNNING = 1,
35}; 36};
36 37
37struct qdisc_size_table { 38struct qdisc_size_table {
39 struct rcu_head rcu;
38 struct list_head list; 40 struct list_head list;
39 struct tc_sizespec szopts; 41 struct tc_sizespec szopts;
40 int refcnt; 42 int refcnt;
@@ -46,14 +48,13 @@ struct Qdisc {
46 struct sk_buff * (*dequeue)(struct Qdisc *dev); 48 struct sk_buff * (*dequeue)(struct Qdisc *dev);
47 unsigned flags; 49 unsigned flags;
48#define TCQ_F_BUILTIN 1 50#define TCQ_F_BUILTIN 1
49#define TCQ_F_THROTTLED 2 51#define TCQ_F_INGRESS 2
50#define TCQ_F_INGRESS 4 52#define TCQ_F_CAN_BYPASS 4
51#define TCQ_F_CAN_BYPASS 8 53#define TCQ_F_MQROOT 8
52#define TCQ_F_MQROOT 16
53#define TCQ_F_WARN_NONWC (1 << 16) 54#define TCQ_F_WARN_NONWC (1 << 16)
54 int padded; 55 int padded;
55 struct Qdisc_ops *ops; 56 struct Qdisc_ops *ops;
56 struct qdisc_size_table *stab; 57 struct qdisc_size_table __rcu *stab;
57 struct list_head list; 58 struct list_head list;
58 u32 handle; 59 u32 handle;
59 u32 parent; 60 u32 parent;
@@ -78,25 +79,44 @@ struct Qdisc {
78 unsigned long state; 79 unsigned long state;
79 struct sk_buff_head q; 80 struct sk_buff_head q;
80 struct gnet_stats_basic_packed bstats; 81 struct gnet_stats_basic_packed bstats;
81 unsigned long __state; 82 unsigned int __state;
82 struct gnet_stats_queue qstats; 83 struct gnet_stats_queue qstats;
83 struct rcu_head rcu_head; 84 struct rcu_head rcu_head;
84 spinlock_t busylock; 85 spinlock_t busylock;
86 u32 limit;
85}; 87};
86 88
87static inline bool qdisc_is_running(struct Qdisc *qdisc) 89static inline bool qdisc_is_running(const struct Qdisc *qdisc)
88{ 90{
89 return test_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 91 return (qdisc->__state & __QDISC___STATE_RUNNING) ? true : false;
90} 92}
91 93
92static inline bool qdisc_run_begin(struct Qdisc *qdisc) 94static inline bool qdisc_run_begin(struct Qdisc *qdisc)
93{ 95{
94 return !__test_and_set_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 96 if (qdisc_is_running(qdisc))
97 return false;
98 qdisc->__state |= __QDISC___STATE_RUNNING;
99 return true;
95} 100}
96 101
97static inline void qdisc_run_end(struct Qdisc *qdisc) 102static inline void qdisc_run_end(struct Qdisc *qdisc)
98{ 103{
99 __clear_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 104 qdisc->__state &= ~__QDISC___STATE_RUNNING;
105}
106
107static inline bool qdisc_is_throttled(const struct Qdisc *qdisc)
108{
109 return test_bit(__QDISC_STATE_THROTTLED, &qdisc->state) ? true : false;
110}
111
112static inline void qdisc_throttled(struct Qdisc *qdisc)
113{
114 set_bit(__QDISC_STATE_THROTTLED, &qdisc->state);
115}
116
117static inline void qdisc_unthrottled(struct Qdisc *qdisc)
118{
119 clear_bit(__QDISC_STATE_THROTTLED, &qdisc->state);
100} 120}
101 121
102struct Qdisc_class_ops { 122struct Qdisc_class_ops {
@@ -199,7 +219,7 @@ struct tcf_proto {
199 219
200struct qdisc_skb_cb { 220struct qdisc_skb_cb {
201 unsigned int pkt_len; 221 unsigned int pkt_len;
202 char data[]; 222 long data[];
203}; 223};
204 224
205static inline int qdisc_qlen(struct Qdisc *q) 225static inline int qdisc_qlen(struct Qdisc *q)
@@ -207,7 +227,7 @@ static inline int qdisc_qlen(struct Qdisc *q)
207 return q->q.qlen; 227 return q->q.qlen;
208} 228}
209 229
210static inline struct qdisc_skb_cb *qdisc_skb_cb(struct sk_buff *skb) 230static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
211{ 231{
212 return (struct qdisc_skb_cb *)skb->cb; 232 return (struct qdisc_skb_cb *)skb->cb;
213} 233}
@@ -321,6 +341,7 @@ extern void dev_init_scheduler(struct net_device *dev);
321extern void dev_shutdown(struct net_device *dev); 341extern void dev_shutdown(struct net_device *dev);
322extern void dev_activate(struct net_device *dev); 342extern void dev_activate(struct net_device *dev);
323extern void dev_deactivate(struct net_device *dev); 343extern void dev_deactivate(struct net_device *dev);
344extern void dev_deactivate_many(struct list_head *head);
324extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, 345extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
325 struct Qdisc *qdisc); 346 struct Qdisc *qdisc);
326extern void qdisc_reset(struct Qdisc *qdisc); 347extern void qdisc_reset(struct Qdisc *qdisc);
@@ -328,11 +349,10 @@ extern void qdisc_destroy(struct Qdisc *qdisc);
328extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); 349extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
329extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, 350extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
330 struct Qdisc_ops *ops); 351 struct Qdisc_ops *ops);
331extern struct Qdisc *qdisc_create_dflt(struct net_device *dev, 352extern struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
332 struct netdev_queue *dev_queue,
333 struct Qdisc_ops *ops, u32 parentid); 353 struct Qdisc_ops *ops, u32 parentid);
334extern void qdisc_calculate_pkt_len(struct sk_buff *skb, 354extern void __qdisc_calculate_pkt_len(struct sk_buff *skb,
335 struct qdisc_size_table *stab); 355 const struct qdisc_size_table *stab);
336extern void tcf_destroy(struct tcf_proto *tp); 356extern void tcf_destroy(struct tcf_proto *tp);
337extern void tcf_destroy_chain(struct tcf_proto **fl); 357extern void tcf_destroy_chain(struct tcf_proto **fl);
338 358
@@ -394,7 +414,7 @@ static inline bool qdisc_tx_is_noop(const struct net_device *dev)
394 return true; 414 return true;
395} 415}
396 416
397static inline unsigned int qdisc_pkt_len(struct sk_buff *skb) 417static inline unsigned int qdisc_pkt_len(const struct sk_buff *skb)
398{ 418{
399 return qdisc_skb_cb(skb)->pkt_len; 419 return qdisc_skb_cb(skb)->pkt_len;
400} 420}
@@ -411,12 +431,20 @@ enum net_xmit_qdisc_t {
411#define net_xmit_drop_count(e) (1) 431#define net_xmit_drop_count(e) (1)
412#endif 432#endif
413 433
414static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) 434static inline void qdisc_calculate_pkt_len(struct sk_buff *skb,
435 const struct Qdisc *sch)
415{ 436{
416#ifdef CONFIG_NET_SCHED 437#ifdef CONFIG_NET_SCHED
417 if (sch->stab) 438 struct qdisc_size_table *stab = rcu_dereference_bh(sch->stab);
418 qdisc_calculate_pkt_len(skb, sch->stab); 439
440 if (stab)
441 __qdisc_calculate_pkt_len(skb, stab);
419#endif 442#endif
443}
444
445static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
446{
447 qdisc_calculate_pkt_len(skb, sch);
420 return sch->enqueue(skb, sch); 448 return sch->enqueue(skb, sch);
421} 449}
422 450
@@ -426,10 +454,18 @@ static inline int qdisc_enqueue_root(struct sk_buff *skb, struct Qdisc *sch)
426 return qdisc_enqueue(skb, sch) & NET_XMIT_MASK; 454 return qdisc_enqueue(skb, sch) & NET_XMIT_MASK;
427} 455}
428 456
429static inline void __qdisc_update_bstats(struct Qdisc *sch, unsigned int len) 457
458static inline void bstats_update(struct gnet_stats_basic_packed *bstats,
459 const struct sk_buff *skb)
460{
461 bstats->bytes += qdisc_pkt_len(skb);
462 bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1;
463}
464
465static inline void qdisc_bstats_update(struct Qdisc *sch,
466 const struct sk_buff *skb)
430{ 467{
431 sch->bstats.bytes += len; 468 bstats_update(&sch->bstats, skb);
432 sch->bstats.packets++;
433} 469}
434 470
435static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, 471static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
@@ -437,7 +473,6 @@ static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
437{ 473{
438 __skb_queue_tail(list, skb); 474 __skb_queue_tail(list, skb);
439 sch->qstats.backlog += qdisc_pkt_len(skb); 475 sch->qstats.backlog += qdisc_pkt_len(skb);
440 __qdisc_update_bstats(sch, qdisc_pkt_len(skb));
441 476
442 return NET_XMIT_SUCCESS; 477 return NET_XMIT_SUCCESS;
443} 478}
@@ -452,8 +487,10 @@ static inline struct sk_buff *__qdisc_dequeue_head(struct Qdisc *sch,
452{ 487{
453 struct sk_buff *skb = __skb_dequeue(list); 488 struct sk_buff *skb = __skb_dequeue(list);
454 489
455 if (likely(skb != NULL)) 490 if (likely(skb != NULL)) {
456 sch->qstats.backlog -= qdisc_pkt_len(skb); 491 sch->qstats.backlog -= qdisc_pkt_len(skb);
492 qdisc_bstats_update(sch, skb);
493 }
457 494
458 return skb; 495 return skb;
459} 496}
@@ -466,10 +503,11 @@ static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch)
466static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch, 503static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch,
467 struct sk_buff_head *list) 504 struct sk_buff_head *list)
468{ 505{
469 struct sk_buff *skb = __qdisc_dequeue_head(sch, list); 506 struct sk_buff *skb = __skb_dequeue(list);
470 507
471 if (likely(skb != NULL)) { 508 if (likely(skb != NULL)) {
472 unsigned int len = qdisc_pkt_len(skb); 509 unsigned int len = qdisc_pkt_len(skb);
510 sch->qstats.backlog -= len;
473 kfree_skb(skb); 511 kfree_skb(skb);
474 return len; 512 return len;
475 } 513 }
@@ -601,7 +639,7 @@ static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen)
601 slot = 0; 639 slot = 0;
602 slot >>= rtab->rate.cell_log; 640 slot >>= rtab->rate.cell_log;
603 if (slot > 255) 641 if (slot > 255)
604 return (rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF]); 642 return rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF];
605 return rtab->data[slot]; 643 return rtab->data[slot];
606} 644}
607 645
@@ -611,11 +649,7 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask,
611{ 649{
612 struct sk_buff *n; 650 struct sk_buff *n;
613 651
614 if ((action == TC_ACT_STOLEN || action == TC_ACT_QUEUED) && 652 n = skb_clone(skb, gfp_mask);
615 !skb_shared(skb))
616 n = skb_get(skb);
617 else
618 n = skb_clone(skb, gfp_mask);
619 653
620 if (n) { 654 if (n) {
621 n->tc_verd = SET_TC_VERD(n->tc_verd, 0); 655 n->tc_verd = SET_TC_VERD(n->tc_verd, 0);
diff --git a/include/net/scm.h b/include/net/scm.h
index 31656506d967..745460fa2f02 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -10,11 +10,12 @@
10/* Well, we should have at least one descriptor open 10/* Well, we should have at least one descriptor open
11 * to accept passed FDs 8) 11 * to accept passed FDs 8)
12 */ 12 */
13#define SCM_MAX_FD 255 13#define SCM_MAX_FD 253
14 14
15struct scm_fp_list { 15struct scm_fp_list {
16 struct list_head list; 16 struct list_head list;
17 int count; 17 short count;
18 short max;
18 struct file *fp[SCM_MAX_FD]; 19 struct file *fp[SCM_MAX_FD];
19}; 20};
20 21
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 2c55a7ea20af..6506458ccd33 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -63,6 +63,7 @@ typedef enum {
63 SCTP_CMD_ECN_ECNE, /* Do delayed ECNE processing. */ 63 SCTP_CMD_ECN_ECNE, /* Do delayed ECNE processing. */
64 SCTP_CMD_ECN_CWR, /* Do delayed CWR processing. */ 64 SCTP_CMD_ECN_CWR, /* Do delayed CWR processing. */
65 SCTP_CMD_TIMER_START, /* Start a timer. */ 65 SCTP_CMD_TIMER_START, /* Start a timer. */
66 SCTP_CMD_TIMER_START_ONCE, /* Start a timer once */
66 SCTP_CMD_TIMER_RESTART, /* Restart a timer. */ 67 SCTP_CMD_TIMER_RESTART, /* Restart a timer. */
67 SCTP_CMD_TIMER_STOP, /* Stop a timer. */ 68 SCTP_CMD_TIMER_STOP, /* Stop a timer. */
68 SCTP_CMD_INIT_CHOOSE_TRANSPORT, /* Choose transport for an INIT. */ 69 SCTP_CMD_INIT_CHOOSE_TRANSPORT, /* Choose transport for an INIT. */
@@ -73,7 +74,6 @@ typedef enum {
73 SCTP_CMD_INIT_FAILED, /* High level, do init failure work. */ 74 SCTP_CMD_INIT_FAILED, /* High level, do init failure work. */
74 SCTP_CMD_REPORT_DUP, /* Report a duplicate TSN. */ 75 SCTP_CMD_REPORT_DUP, /* Report a duplicate TSN. */
75 SCTP_CMD_STRIKE, /* Mark a strike against a transport. */ 76 SCTP_CMD_STRIKE, /* Mark a strike against a transport. */
76 SCTP_CMD_TRANSMIT, /* Transmit the outqueue. */
77 SCTP_CMD_HB_TIMERS_START, /* Start the heartbeat timers. */ 77 SCTP_CMD_HB_TIMERS_START, /* Start the heartbeat timers. */
78 SCTP_CMD_HB_TIMER_UPDATE, /* Update a heartbeat timers. */ 78 SCTP_CMD_HB_TIMER_UPDATE, /* Update a heartbeat timers. */
79 SCTP_CMD_HB_TIMERS_STOP, /* Stop the heartbeat timers. */ 79 SCTP_CMD_HB_TIMERS_STOP, /* Stop the heartbeat timers. */
@@ -108,12 +108,10 @@ typedef enum {
108 SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */ 108 SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */
109 SCTP_CMD_SEND_MSG, /* Send the whole use message */ 109 SCTP_CMD_SEND_MSG, /* Send the whole use message */
110 SCTP_CMD_SEND_NEXT_ASCONF, /* Send the next ASCONF after ACK */ 110 SCTP_CMD_SEND_NEXT_ASCONF, /* Send the next ASCONF after ACK */
111 SCTP_CMD_PURGE_ASCONF_QUEUE, /* Purge all asconf queues.*/
111 SCTP_CMD_LAST 112 SCTP_CMD_LAST
112} sctp_verb_t; 113} sctp_verb_t;
113 114
114#define SCTP_CMD_MAX (SCTP_CMD_LAST - 1)
115#define SCTP_CMD_NUM_VERBS (SCTP_CMD_MAX + 1)
116
117/* How many commands can you put in an sctp_cmd_seq_t? 115/* How many commands can you put in an sctp_cmd_seq_t?
118 * This is a rather arbitrary number, ideally derived from a careful 116 * This is a rather arbitrary number, ideally derived from a careful
119 * analysis of the state functions, but in reality just taken from 117 * analysis of the state functions, but in reality just taken from
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index 63908840eef0..942b864f6135 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -61,7 +61,6 @@ enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM };
61 * symbols. CIDs are dense through SCTP_CID_BASE_MAX. 61 * symbols. CIDs are dense through SCTP_CID_BASE_MAX.
62 */ 62 */
63#define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE 63#define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE
64#define SCTP_CID_MAX SCTP_CID_ASCONF_ACK
65 64
66#define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1) 65#define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1)
67 66
@@ -86,9 +85,6 @@ typedef enum {
86 85
87} sctp_event_t; 86} sctp_event_t;
88 87
89#define SCTP_EVENT_T_MAX SCTP_EVENT_T_PRIMITIVE
90#define SCTP_EVENT_T_NUM (SCTP_EVENT_T_MAX + 1)
91
92/* As a convenience for the state machine, we append SCTP_EVENT_* and 88/* As a convenience for the state machine, we append SCTP_EVENT_* and
93 * SCTP_ULP_* to the list of possible chunks. 89 * SCTP_ULP_* to the list of possible chunks.
94 */ 90 */
@@ -154,7 +150,6 @@ SCTP_SUBTYPE_CONSTRUCTOR(OTHER, sctp_event_other_t, other)
154SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive) 150SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive)
155 151
156 152
157#define sctp_chunk_is_control(a) (a->chunk_hdr->type != SCTP_CID_DATA)
158#define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA) 153#define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA)
159 154
160/* Calculate the actual data size in a data chunk */ 155/* Calculate the actual data size in a data chunk */
@@ -162,9 +157,6 @@ SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive)
162 - (unsigned long)(c->chunk_hdr)\ 157 - (unsigned long)(c->chunk_hdr)\
163 - sizeof(sctp_data_chunk_t))) 158 - sizeof(sctp_data_chunk_t)))
164 159
165#define SCTP_MAX_ERROR_CAUSE SCTP_ERROR_NONEXIST_IP
166#define SCTP_NUM_ERROR_CAUSE 10
167
168/* Internal error codes */ 160/* Internal error codes */
169typedef enum { 161typedef enum {
170 162
@@ -195,15 +187,14 @@ typedef enum {
195/* SCTP state defines for internal state machine */ 187/* SCTP state defines for internal state machine */
196typedef enum { 188typedef enum {
197 189
198 SCTP_STATE_EMPTY = 0, 190 SCTP_STATE_CLOSED = 0,
199 SCTP_STATE_CLOSED = 1, 191 SCTP_STATE_COOKIE_WAIT = 1,
200 SCTP_STATE_COOKIE_WAIT = 2, 192 SCTP_STATE_COOKIE_ECHOED = 2,
201 SCTP_STATE_COOKIE_ECHOED = 3, 193 SCTP_STATE_ESTABLISHED = 3,
202 SCTP_STATE_ESTABLISHED = 4, 194 SCTP_STATE_SHUTDOWN_PENDING = 4,
203 SCTP_STATE_SHUTDOWN_PENDING = 5, 195 SCTP_STATE_SHUTDOWN_SENT = 5,
204 SCTP_STATE_SHUTDOWN_SENT = 6, 196 SCTP_STATE_SHUTDOWN_RECEIVED = 6,
205 SCTP_STATE_SHUTDOWN_RECEIVED = 7, 197 SCTP_STATE_SHUTDOWN_ACK_SENT = 7,
206 SCTP_STATE_SHUTDOWN_ACK_SENT = 8,
207 198
208} sctp_state_t; 199} sctp_state_t;
209 200
@@ -266,7 +257,6 @@ enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 };
266#define SCTP_TSN_MAP_INITIAL BITS_PER_LONG 257#define SCTP_TSN_MAP_INITIAL BITS_PER_LONG
267#define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL 258#define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL
268#define SCTP_TSN_MAP_SIZE 4096 259#define SCTP_TSN_MAP_SIZE 4096
269#define SCTP_TSN_MAX_GAP 65535
270 260
271/* We will not record more than this many duplicate TSNs between two 261/* We will not record more than this many duplicate TSNs between two
272 * SACKs. The minimum PMTU is 576. Remove all the headers and there 262 * SACKs. The minimum PMTU is 576. Remove all the headers and there
@@ -301,9 +291,6 @@ enum { SCTP_MAX_GABS = 16 };
301 291
302#define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ 292#define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */
303 293
304#define SCTP_DEF_MAX_INIT 6
305#define SCTP_DEF_MAX_SEND 10
306
307#define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000) /* 60 seconds */ 294#define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000) /* 60 seconds */
308 295
309#define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */ 296#define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */
@@ -317,9 +304,6 @@ enum { SCTP_MAX_GABS = 16 };
317 */ 304 */
318#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */ 305#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */
319#define SCTP_HOW_MANY_SECRETS 2 /* How many secrets I keep */ 306#define SCTP_HOW_MANY_SECRETS 2 /* How many secrets I keep */
320#define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* How many seconds the current
321 * secret will live?
322 */
323#define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */ 307#define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */
324 308
325#define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */ 309#define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 65946bc43d00..b2c2366676a7 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -115,7 +115,6 @@
115 * sctp/protocol.c 115 * sctp/protocol.c
116 */ 116 */
117extern struct sock *sctp_get_ctl_sock(void); 117extern struct sock *sctp_get_ctl_sock(void);
118extern void sctp_local_addr_free(struct rcu_head *head);
119extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, 118extern int sctp_copy_local_addr_list(struct sctp_bind_addr *,
120 sctp_scope_t, gfp_t gfp, 119 sctp_scope_t, gfp_t gfp,
121 int flags); 120 int flags);
@@ -275,24 +274,35 @@ struct sctp_mib {
275/* Print debugging messages. */ 274/* Print debugging messages. */
276#if SCTP_DEBUG 275#if SCTP_DEBUG
277extern int sctp_debug_flag; 276extern int sctp_debug_flag;
278#define SCTP_DEBUG_PRINTK(whatever...) \ 277#define SCTP_DEBUG_PRINTK(fmt, args...) \
279 ((void) (sctp_debug_flag && printk(KERN_DEBUG whatever))) 278do { \
280#define SCTP_DEBUG_PRINTK_IPADDR(lead, trail, leadparm, saddr, otherparms...) \ 279 if (sctp_debug_flag) \
281 if (sctp_debug_flag) { \ 280 printk(KERN_DEBUG pr_fmt(fmt), ##args); \
282 if (saddr->sa.sa_family == AF_INET6) { \ 281} while (0)
283 printk(KERN_DEBUG \ 282#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) \
284 lead "%pI6" trail, \ 283do { \
285 leadparm, \ 284 if (sctp_debug_flag) \
286 &saddr->v6.sin6_addr, \ 285 pr_cont(fmt, ##args); \
287 otherparms); \ 286} while (0)
288 } else { \ 287#define SCTP_DEBUG_PRINTK_IPADDR(fmt_lead, fmt_trail, \
289 printk(KERN_DEBUG \ 288 args_lead, saddr, args_trail...) \
290 lead "%pI4" trail, \ 289do { \
291 leadparm, \ 290 if (sctp_debug_flag) { \
292 &saddr->v4.sin_addr.s_addr, \ 291 if (saddr->sa.sa_family == AF_INET6) { \
293 otherparms); \ 292 printk(KERN_DEBUG \
294 } \ 293 pr_fmt(fmt_lead "%pI6" fmt_trail), \
295 } 294 args_lead, \
295 &saddr->v6.sin6_addr, \
296 args_trail); \
297 } else { \
298 printk(KERN_DEBUG \
299 pr_fmt(fmt_lead "%pI4" fmt_trail), \
300 args_lead, \
301 &saddr->v4.sin_addr.s_addr, \
302 args_trail); \
303 } \
304 } \
305} while (0)
296#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; } 306#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; }
297#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; } 307#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; }
298 308
@@ -306,6 +316,7 @@ extern int sctp_debug_flag;
306#else /* SCTP_DEBUG */ 316#else /* SCTP_DEBUG */
307 317
308#define SCTP_DEBUG_PRINTK(whatever...) 318#define SCTP_DEBUG_PRINTK(whatever...)
319#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
309#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) 320#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
310#define SCTP_ENABLE_DEBUG 321#define SCTP_ENABLE_DEBUG
311#define SCTP_DISABLE_DEBUG 322#define SCTP_DISABLE_DEBUG
@@ -393,7 +404,7 @@ static inline void sctp_v6_del_protocol(void) { return; }
393/* Map an association to an assoc_id. */ 404/* Map an association to an assoc_id. */
394static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc) 405static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc)
395{ 406{
396 return (asoc?asoc->assoc_id:0); 407 return asoc ? asoc->assoc_id : 0;
397} 408}
398 409
399/* Look up the association by its id. */ 410/* Look up the association by its id. */
@@ -461,7 +472,7 @@ static inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
461/* Tests if the list has one and only one entry. */ 472/* Tests if the list has one and only one entry. */
462static inline int sctp_list_single_entry(struct list_head *head) 473static inline int sctp_list_single_entry(struct list_head *head)
463{ 474{
464 return ((head->next != head) && (head->next == head->prev)); 475 return (head->next != head) && (head->next == head->prev);
465} 476}
466 477
467/* Generate a random jitter in the range of -50% ~ +50% of input RTO. */ 478/* Generate a random jitter in the range of -50% ~ +50% of input RTO. */
@@ -519,7 +530,6 @@ _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member)
519 530
520#define _sctp_walk_params(pos, chunk, end, member)\ 531#define _sctp_walk_params(pos, chunk, end, member)\
521for (pos.v = chunk->member;\ 532for (pos.v = chunk->member;\
522 pos.v <= (void *)chunk + end - sizeof(sctp_paramhdr_t) &&\
523 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ 533 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
524 ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\ 534 ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\
525 pos.v += WORD_ROUND(ntohs(pos.p->length))) 535 pos.v += WORD_ROUND(ntohs(pos.p->length)))
@@ -530,7 +540,6 @@ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length))
530#define _sctp_walk_errors(err, chunk_hdr, end)\ 540#define _sctp_walk_errors(err, chunk_hdr, end)\
531for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ 541for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \
532 sizeof(sctp_chunkhdr_t));\ 542 sizeof(sctp_chunkhdr_t));\
533 (void *)err <= (void *)chunk_hdr + end - sizeof(sctp_errhdr_t) &&\
534 (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ 543 (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\
535 ntohs(err->length) >= sizeof(sctp_errhdr_t); \ 544 ntohs(err->length) >= sizeof(sctp_errhdr_t); \
536 err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length)))) 545 err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length))))
@@ -619,13 +628,13 @@ static inline int sctp_sanity_check(void)
619/* This is the hash function for the SCTP port hash table. */ 628/* This is the hash function for the SCTP port hash table. */
620static inline int sctp_phashfn(__u16 lport) 629static inline int sctp_phashfn(__u16 lport)
621{ 630{
622 return (lport & (sctp_port_hashsize - 1)); 631 return lport & (sctp_port_hashsize - 1);
623} 632}
624 633
625/* This is the hash function for the endpoint hash table. */ 634/* This is the hash function for the endpoint hash table. */
626static inline int sctp_ep_hashfn(__u16 lport) 635static inline int sctp_ep_hashfn(__u16 lport)
627{ 636{
628 return (lport & (sctp_ep_hashsize - 1)); 637 return lport & (sctp_ep_hashsize - 1);
629} 638}
630 639
631/* This is the hash function for the association hash table. */ 640/* This is the hash function for the association hash table. */
@@ -633,7 +642,7 @@ static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport)
633{ 642{
634 int h = (lport << 16) + rport; 643 int h = (lport << 16) + rport;
635 h ^= h>>8; 644 h ^= h>>8;
636 return (h & (sctp_assoc_hashsize - 1)); 645 return h & (sctp_assoc_hashsize - 1);
637} 646}
638 647
639/* This is the hash function for the association hash table. This is 648/* This is the hash function for the association hash table. This is
@@ -644,7 +653,7 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
644{ 653{
645 int h = (lport << 16) + rport; 654 int h = (lport << 16) + rport;
646 h ^= vtag; 655 h ^= vtag;
647 return (h & (sctp_assoc_hashsize-1)); 656 return h & (sctp_assoc_hashsize - 1);
648} 657}
649 658
650#define sctp_for_each_hentry(epb, node, head) \ 659#define sctp_for_each_hentry(epb, node, head) \
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 4088c89a9055..9148632b8204 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -165,6 +165,7 @@ sctp_state_fn_t sctp_sf_do_prm_requestheartbeat;
165sctp_state_fn_t sctp_sf_do_prm_asconf; 165sctp_state_fn_t sctp_sf_do_prm_asconf;
166 166
167/* Prototypes for other event state functions. */ 167/* Prototypes for other event state functions. */
168sctp_state_fn_t sctp_sf_do_no_pending_tsn;
168sctp_state_fn_t sctp_sf_do_9_2_start_shutdown; 169sctp_state_fn_t sctp_sf_do_9_2_start_shutdown;
169sctp_state_fn_t sctp_sf_do_9_2_shutdown_ack; 170sctp_state_fn_t sctp_sf_do_9_2_shutdown_ack;
170sctp_state_fn_t sctp_sf_ignore_other; 171sctp_state_fn_t sctp_sf_ignore_other;
@@ -232,9 +233,7 @@ struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association *,
232 const struct sctp_chunk *, 233 const struct sctp_chunk *,
233 struct sctp_paramhdr *); 234 struct sctp_paramhdr *);
234struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, 235struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *,
235 const struct sctp_transport *, 236 const struct sctp_transport *);
236 const void *payload,
237 const size_t paylen);
238struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *, 237struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *,
239 const struct sctp_chunk *, 238 const struct sctp_chunk *,
240 const void *payload, 239 const void *payload,
@@ -345,12 +344,12 @@ enum {
345 344
346static inline int TSN_lt(__u32 s, __u32 t) 345static inline int TSN_lt(__u32 s, __u32 t)
347{ 346{
348 return (((s) - (t)) & TSN_SIGN_BIT); 347 return ((s) - (t)) & TSN_SIGN_BIT;
349} 348}
350 349
351static inline int TSN_lte(__u32 s, __u32 t) 350static inline int TSN_lte(__u32 s, __u32 t)
352{ 351{
353 return (((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT)); 352 return ((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT);
354} 353}
355 354
356/* Compare two SSNs */ 355/* Compare two SSNs */
@@ -369,12 +368,12 @@ enum {
369 368
370static inline int SSN_lt(__u16 s, __u16 t) 369static inline int SSN_lt(__u16 s, __u16 t)
371{ 370{
372 return (((s) - (t)) & SSN_SIGN_BIT); 371 return ((s) - (t)) & SSN_SIGN_BIT;
373} 372}
374 373
375static inline int SSN_lte(__u16 s, __u16 t) 374static inline int SSN_lte(__u16 s, __u16 t)
376{ 375{
377 return (((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT)); 376 return ((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT);
378} 377}
379 378
380/* 379/*
@@ -388,7 +387,7 @@ enum {
388 387
389static inline int ADDIP_SERIAL_gte(__u16 s, __u16 t) 388static inline int ADDIP_SERIAL_gte(__u16 s, __u16 t)
390{ 389{
391 return (((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT)); 390 return ((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT);
392} 391}
393 392
394/* Check VTAG of the packet matches the sender's own tag. */ 393/* Check VTAG of the packet matches the sender's own tag. */
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index f9e7473613bd..7df327a6d564 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -261,8 +261,6 @@ extern struct sctp_globals {
261#define sctp_assoc_hashsize (sctp_globals.assoc_hashsize) 261#define sctp_assoc_hashsize (sctp_globals.assoc_hashsize)
262#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) 262#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
263#define sctp_port_hashsize (sctp_globals.port_hashsize) 263#define sctp_port_hashsize (sctp_globals.port_hashsize)
264#define sctp_port_rover (sctp_globals.port_rover)
265#define sctp_port_alloc_lock (sctp_globals.port_alloc_lock)
266#define sctp_port_hashtable (sctp_globals.port_hashtable) 264#define sctp_port_hashtable (sctp_globals.port_hashtable)
267#define sctp_local_addr_list (sctp_globals.local_addr_list) 265#define sctp_local_addr_list (sctp_globals.local_addr_list)
268#define sctp_local_addr_lock (sctp_globals.addr_list_lock) 266#define sctp_local_addr_lock (sctp_globals.addr_list_lock)
@@ -424,7 +422,7 @@ struct sctp_cookie {
424 __u32 adaptation_ind; 422 __u32 adaptation_ind;
425 423
426 __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH]; 424 __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH];
427 __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS + 2]; 425 __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS * sizeof(__u16) + 2];
428 __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS]; 426 __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS];
429 427
430 /* This is a shim for my peer's INIT packet, followed by 428 /* This is a shim for my peer's INIT packet, followed by
@@ -566,19 +564,15 @@ struct sctp_af {
566 int optname, 564 int optname,
567 char __user *optval, 565 char __user *optval,
568 int __user *optlen); 566 int __user *optlen);
569 struct dst_entry *(*get_dst) (struct sctp_association *asoc, 567 void (*get_dst) (struct sctp_transport *t,
570 union sctp_addr *daddr, 568 union sctp_addr *saddr,
571 union sctp_addr *saddr); 569 struct flowi *fl,
570 struct sock *sk);
572 void (*get_saddr) (struct sctp_sock *sk, 571 void (*get_saddr) (struct sctp_sock *sk,
573 struct sctp_association *asoc, 572 struct sctp_transport *t,
574 struct dst_entry *dst, 573 struct flowi *fl);
575 union sctp_addr *daddr,
576 union sctp_addr *saddr);
577 void (*copy_addrlist) (struct list_head *, 574 void (*copy_addrlist) (struct list_head *,
578 struct net_device *); 575 struct net_device *);
579 void (*dst_saddr) (union sctp_addr *saddr,
580 struct dst_entry *dst,
581 __be16 port);
582 int (*cmp_addr) (const union sctp_addr *addr1, 576 int (*cmp_addr) (const union sctp_addr *addr1,
583 const union sctp_addr *addr2); 577 const union sctp_addr *addr2);
584 void (*addr_copy) (union sctp_addr *dst, 578 void (*addr_copy) (union sctp_addr *dst,
@@ -847,7 +841,7 @@ void sctp_packet_free(struct sctp_packet *);
847 841
848static inline int sctp_packet_empty(struct sctp_packet *packet) 842static inline int sctp_packet_empty(struct sctp_packet *packet)
849{ 843{
850 return (packet->size == packet->overhead); 844 return packet->size == packet->overhead;
851} 845}
852 846
853/* This represents a remote transport address. 847/* This represents a remote transport address.
@@ -900,6 +894,7 @@ struct sctp_transport {
900 /* Is this structure kfree()able? */ 894 /* Is this structure kfree()able? */
901 malloced:1; 895 malloced:1;
902 896
897 struct flowi fl;
903 898
904 /* This is the peer's IP address and port. */ 899 /* This is the peer's IP address and port. */
905 union sctp_addr ipaddr; 900 union sctp_addr ipaddr;
@@ -1063,7 +1058,7 @@ void sctp_transport_set_owner(struct sctp_transport *,
1063 struct sctp_association *); 1058 struct sctp_association *);
1064void sctp_transport_route(struct sctp_transport *, union sctp_addr *, 1059void sctp_transport_route(struct sctp_transport *, union sctp_addr *,
1065 struct sctp_sock *); 1060 struct sctp_sock *);
1066void sctp_transport_pmtu(struct sctp_transport *); 1061void sctp_transport_pmtu(struct sctp_transport *, struct sock *sk);
1067void sctp_transport_free(struct sctp_transport *); 1062void sctp_transport_free(struct sctp_transport *);
1068void sctp_transport_reset_timers(struct sctp_transport *); 1063void sctp_transport_reset_timers(struct sctp_transport *);
1069void sctp_transport_hold(struct sctp_transport *); 1064void sctp_transport_hold(struct sctp_transport *);
@@ -1402,7 +1397,7 @@ int sctp_has_association(const union sctp_addr *laddr,
1402int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t, 1397int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t,
1403 sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk, 1398 sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk,
1404 struct sctp_chunk **err_chunk); 1399 struct sctp_chunk **err_chunk);
1405int sctp_process_init(struct sctp_association *, sctp_cid_t cid, 1400int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk,
1406 const union sctp_addr *peer, 1401 const union sctp_addr *peer,
1407 sctp_init_chunk_t *init, gfp_t gfp); 1402 sctp_init_chunk_t *init, gfp_t gfp);
1408__u32 sctp_generate_tag(const struct sctp_endpoint *); 1403__u32 sctp_generate_tag(const struct sctp_endpoint *);
@@ -1998,7 +1993,7 @@ void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc);
1998struct sctp_chunk *sctp_assoc_lookup_asconf_ack( 1993struct sctp_chunk *sctp_assoc_lookup_asconf_ack(
1999 const struct sctp_association *asoc, 1994 const struct sctp_association *asoc,
2000 __be32 serial); 1995 __be32 serial);
2001 1996void sctp_asconf_queue_teardown(struct sctp_association *asoc);
2002 1997
2003int sctp_cmp_addr_exact(const union sctp_addr *ss1, 1998int sctp_cmp_addr_exact(const union sctp_addr *ss1,
2004 const union sctp_addr *ss2); 1999 const union sctp_addr *ss2);
diff --git a/include/net/sctp/tsnmap.h b/include/net/sctp/tsnmap.h
index 4aabc5a96cf6..e7728bc14ccf 100644
--- a/include/net/sctp/tsnmap.h
+++ b/include/net/sctp/tsnmap.h
@@ -157,7 +157,7 @@ __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map);
157/* Is there a gap in the TSN map? */ 157/* Is there a gap in the TSN map? */
158static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map) 158static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map)
159{ 159{
160 return (map->cumulative_tsn_ack_point != map->max_tsn_seen); 160 return map->cumulative_tsn_ack_point != map->max_tsn_seen;
161} 161}
162 162
163/* Mark a duplicate TSN. Note: limit the storage of duplicate TSN 163/* Mark a duplicate TSN. Note: limit the storage of duplicate TSN
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
index 7ea12e8e6676..ca4693b4e09e 100644
--- a/include/net/sctp/ulpevent.h
+++ b/include/net/sctp/ulpevent.h
@@ -80,7 +80,7 @@ static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb)
80 80
81void sctp_ulpevent_free(struct sctp_ulpevent *); 81void sctp_ulpevent_free(struct sctp_ulpevent *);
82int sctp_ulpevent_is_notification(const struct sctp_ulpevent *); 82int sctp_ulpevent_is_notification(const struct sctp_ulpevent *);
83void sctp_queue_purge_ulpevents(struct sk_buff_head *list); 83unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list);
84 84
85struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( 85struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
86 const struct sctp_association *asoc, 86 const struct sctp_association *asoc,
@@ -132,6 +132,9 @@ struct sctp_ulpevent *sctp_ulpevent_make_authkey(
132 const struct sctp_association *asoc, __u16 key_id, 132 const struct sctp_association *asoc, __u16 key_id,
133 __u32 indication, gfp_t gfp); 133 __u32 indication, gfp_t gfp);
134 134
135struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
136 const struct sctp_association *asoc, gfp_t gfp);
137
135void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, 138void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
136 struct msghdr *); 139 struct msghdr *);
137__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event); 140__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 2b2769c5ca9f..32fd51274037 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -78,6 +78,7 @@ typedef __s32 sctp_assoc_t;
78#define SCTP_GET_PEER_ADDR_INFO 15 78#define SCTP_GET_PEER_ADDR_INFO 15
79#define SCTP_DELAYED_ACK_TIME 16 79#define SCTP_DELAYED_ACK_TIME 16
80#define SCTP_DELAYED_ACK SCTP_DELAYED_ACK_TIME 80#define SCTP_DELAYED_ACK SCTP_DELAYED_ACK_TIME
81#define SCTP_DELAYED_SACK SCTP_DELAYED_ACK_TIME
81#define SCTP_CONTEXT 17 82#define SCTP_CONTEXT 17
82#define SCTP_FRAGMENT_INTERLEAVE 18 83#define SCTP_FRAGMENT_INTERLEAVE 18
83#define SCTP_PARTIAL_DELIVERY_POINT 19 /* Set/Get partial delivery point */ 84#define SCTP_PARTIAL_DELIVERY_POINT 19 /* Set/Get partial delivery point */
@@ -90,6 +91,7 @@ typedef __s32 sctp_assoc_t;
90#define SCTP_PEER_AUTH_CHUNKS 26 /* Read only */ 91#define SCTP_PEER_AUTH_CHUNKS 26 /* Read only */
91#define SCTP_LOCAL_AUTH_CHUNKS 27 /* Read only */ 92#define SCTP_LOCAL_AUTH_CHUNKS 27 /* Read only */
92#define SCTP_GET_ASSOC_NUMBER 28 /* Read only */ 93#define SCTP_GET_ASSOC_NUMBER 28 /* Read only */
94#define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */
93 95
94/* Internal Socket Options. Some of the sctp library functions are 96/* Internal Socket Options. Some of the sctp library functions are
95 * implemented using these socket options. 97 * implemented using these socket options.
@@ -99,8 +101,8 @@ typedef __s32 sctp_assoc_t;
99#define SCTP_SOCKOPT_PEELOFF 102 /* peel off association. */ 101#define SCTP_SOCKOPT_PEELOFF 102 /* peel off association. */
100/* Options 104-106 are deprecated and removed. Do not use this space */ 102/* Options 104-106 are deprecated and removed. Do not use this space */
101#define SCTP_SOCKOPT_CONNECTX_OLD 107 /* CONNECTX old requests. */ 103#define SCTP_SOCKOPT_CONNECTX_OLD 107 /* CONNECTX old requests. */
102#define SCTP_GET_PEER_ADDRS 108 /* Get all peer addresss. */ 104#define SCTP_GET_PEER_ADDRS 108 /* Get all peer address. */
103#define SCTP_GET_LOCAL_ADDRS 109 /* Get all local addresss. */ 105#define SCTP_GET_LOCAL_ADDRS 109 /* Get all local address. */
104#define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */ 106#define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */
105#define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ 107#define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */
106 108
@@ -352,6 +354,20 @@ struct sctp_authkey_event {
352 354
353enum { SCTP_AUTH_NEWKEY = 0, }; 355enum { SCTP_AUTH_NEWKEY = 0, };
354 356
357/*
358 * 6.1.9. SCTP_SENDER_DRY_EVENT
359 *
360 * When the SCTP stack has no more user data to send or retransmit, this
361 * notification is given to the user. Also, at the time when a user app
362 * subscribes to this event, if there is no data to be sent or
363 * retransmit, the stack will immediately send up this notification.
364 */
365struct sctp_sender_dry_event {
366 __u16 sender_dry_type;
367 __u16 sender_dry_flags;
368 __u32 sender_dry_length;
369 sctp_assoc_t sender_dry_assoc_id;
370};
355 371
356/* 372/*
357 * Described in Section 7.3 373 * Described in Section 7.3
@@ -367,6 +383,7 @@ struct sctp_event_subscribe {
367 __u8 sctp_partial_delivery_event; 383 __u8 sctp_partial_delivery_event;
368 __u8 sctp_adaptation_layer_event; 384 __u8 sctp_adaptation_layer_event;
369 __u8 sctp_authentication_event; 385 __u8 sctp_authentication_event;
386 __u8 sctp_sender_dry_event;
370}; 387};
371 388
372/* 389/*
@@ -390,6 +407,7 @@ union sctp_notification {
390 struct sctp_adaptation_event sn_adaptation_event; 407 struct sctp_adaptation_event sn_adaptation_event;
391 struct sctp_pdapi_event sn_pdapi_event; 408 struct sctp_pdapi_event sn_pdapi_event;
392 struct sctp_authkey_event sn_authkey_event; 409 struct sctp_authkey_event sn_authkey_event;
410 struct sctp_sender_dry_event sn_sender_dry_event;
393}; 411};
394 412
395/* Section 5.3.1 413/* Section 5.3.1
@@ -406,7 +424,9 @@ enum sctp_sn_type {
406 SCTP_SHUTDOWN_EVENT, 424 SCTP_SHUTDOWN_EVENT,
407 SCTP_PARTIAL_DELIVERY_EVENT, 425 SCTP_PARTIAL_DELIVERY_EVENT,
408 SCTP_ADAPTATION_INDICATION, 426 SCTP_ADAPTATION_INDICATION,
409 SCTP_AUTHENTICATION_INDICATION, 427 SCTP_AUTHENTICATION_EVENT,
428#define SCTP_AUTHENTICATION_INDICATION SCTP_AUTHENTICATION_EVENT
429 SCTP_SENDER_DRY_EVENT,
410}; 430};
411 431
412/* Notification error codes used to fill up the error fields in some 432/* Notification error codes used to fill up the error fields in some
@@ -668,6 +688,18 @@ struct sctp_authchunks {
668}; 688};
669 689
670/* 690/*
691 * 8.2.6. Get the Current Identifiers of Associations
692 * (SCTP_GET_ASSOC_ID_LIST)
693 *
694 * This option gets the current list of SCTP association identifiers of
695 * the SCTP associations handled by a one-to-many style socket.
696 */
697struct sctp_assoc_ids {
698 __u32 gaids_number_of_ids;
699 sctp_assoc_t gaids_assoc_id[];
700};
701
702/*
671 * 8.3, 8.5 get all peer/local addresses in an association. 703 * 8.3, 8.5 get all peer/local addresses in an association.
672 * This parameter struct is used by SCTP_GET_PEER_ADDRS and 704 * This parameter struct is used by SCTP_GET_PEER_ADDRS and
673 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement 705 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement
diff --git a/include/net/snmp.h b/include/net/snmp.h
index a0e61806d480..479083a78b0c 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -60,9 +60,7 @@ struct ipstats_mib {
60}; 60};
61 61
62/* ICMP */ 62/* ICMP */
63#define ICMP_MIB_DUMMY __ICMP_MIB_MAX 63#define ICMP_MIB_MAX __ICMP_MIB_MAX
64#define ICMP_MIB_MAX (__ICMP_MIB_MAX + 1)
65
66struct icmp_mib { 64struct icmp_mib {
67 unsigned long mibs[ICMP_MIB_MAX]; 65 unsigned long mibs[ICMP_MIB_MAX];
68}; 66};
@@ -74,14 +72,24 @@ struct icmpmsg_mib {
74 72
75/* ICMP6 (IPv6-ICMP) */ 73/* ICMP6 (IPv6-ICMP) */
76#define ICMP6_MIB_MAX __ICMP6_MIB_MAX 74#define ICMP6_MIB_MAX __ICMP6_MIB_MAX
75/* per network ns counters */
77struct icmpv6_mib { 76struct icmpv6_mib {
78 unsigned long mibs[ICMP6_MIB_MAX]; 77 unsigned long mibs[ICMP6_MIB_MAX];
79}; 78};
79/* per device counters, (shared on all cpus) */
80struct icmpv6_mib_device {
81 atomic_long_t mibs[ICMP6_MIB_MAX];
82};
80 83
81#define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX 84#define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX
85/* per network ns counters */
82struct icmpv6msg_mib { 86struct icmpv6msg_mib {
83 unsigned long mibs[ICMP6MSG_MIB_MAX]; 87 unsigned long mibs[ICMP6MSG_MIB_MAX];
84}; 88};
89/* per device counters, (shared on all cpus) */
90struct icmpv6msg_mib_device {
91 atomic_long_t mibs[ICMP6MSG_MIB_MAX];
92};
85 93
86 94
87/* TCP */ 95/* TCP */
@@ -116,6 +124,8 @@ struct linux_xfrm_mib {
116 */ 124 */
117#define DEFINE_SNMP_STAT(type, name) \ 125#define DEFINE_SNMP_STAT(type, name) \
118 __typeof__(type) __percpu *name[2] 126 __typeof__(type) __percpu *name[2]
127#define DEFINE_SNMP_STAT_ATOMIC(type, name) \
128 __typeof__(type) *name
119#define DECLARE_SNMP_STAT(type, name) \ 129#define DECLARE_SNMP_STAT(type, name) \
120 extern __typeof__(type) __percpu *name[2] 130 extern __typeof__(type) __percpu *name[2]
121 131
@@ -126,6 +136,8 @@ struct linux_xfrm_mib {
126 __this_cpu_inc(mib[0]->mibs[field]) 136 __this_cpu_inc(mib[0]->mibs[field])
127#define SNMP_INC_STATS_USER(mib, field) \ 137#define SNMP_INC_STATS_USER(mib, field) \
128 this_cpu_inc(mib[1]->mibs[field]) 138 this_cpu_inc(mib[1]->mibs[field])
139#define SNMP_INC_STATS_ATOMIC_LONG(mib, field) \
140 atomic_long_inc(&mib->mibs[field])
129#define SNMP_INC_STATS(mib, field) \ 141#define SNMP_INC_STATS(mib, field) \
130 this_cpu_inc(mib[!in_softirq()]->mibs[field]) 142 this_cpu_inc(mib[!in_softirq()]->mibs[field])
131#define SNMP_DEC_STATS(mib, field) \ 143#define SNMP_DEC_STATS(mib, field) \
@@ -152,7 +164,7 @@ struct linux_xfrm_mib {
152#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ 164#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
153 do { \ 165 do { \
154 __typeof__(*mib[0]) *ptr = \ 166 __typeof__(*mib[0]) *ptr = \
155 __this_cpu_ptr((mib)[!in_softirq()]); \ 167 __this_cpu_ptr((mib)[0]); \
156 ptr->mibs[basefield##PKTS]++; \ 168 ptr->mibs[basefield##PKTS]++; \
157 ptr->mibs[basefield##OCTETS] += addend;\ 169 ptr->mibs[basefield##OCTETS] += addend;\
158 } while (0) 170 } while (0)
@@ -204,7 +216,7 @@ struct linux_xfrm_mib {
204#define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \ 216#define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \
205 do { \ 217 do { \
206 __typeof__(*mib[0]) *ptr; \ 218 __typeof__(*mib[0]) *ptr; \
207 ptr = __this_cpu_ptr((mib)[!in_softirq()]); \ 219 ptr = __this_cpu_ptr((mib)[0]); \
208 u64_stats_update_begin(&ptr->syncp); \ 220 u64_stats_update_begin(&ptr->syncp); \
209 ptr->mibs[basefield##PKTS]++; \ 221 ptr->mibs[basefield##PKTS]++; \
210 ptr->mibs[basefield##OCTETS] += addend; \ 222 ptr->mibs[basefield##OCTETS] += addend; \
diff --git a/include/net/sock.h b/include/net/sock.h
index adab9dc58183..c0b938cb4b1a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -52,12 +52,13 @@
52#include <linux/mm.h> 52#include <linux/mm.h>
53#include <linux/security.h> 53#include <linux/security.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/uaccess.h>
55 56
56#include <linux/filter.h> 57#include <linux/filter.h>
57#include <linux/rculist_nulls.h> 58#include <linux/rculist_nulls.h>
58#include <linux/poll.h> 59#include <linux/poll.h>
59 60
60#include <asm/atomic.h> 61#include <linux/atomic.h>
61#include <net/dst.h> 62#include <net/dst.h>
62#include <net/checksum.h> 63#include <net/checksum.h>
63 64
@@ -105,10 +106,8 @@ struct net;
105 106
106/** 107/**
107 * struct sock_common - minimal network layer representation of sockets 108 * struct sock_common - minimal network layer representation of sockets
108 * @skc_node: main hash linkage for various protocol lookup tables 109 * @skc_daddr: Foreign IPv4 addr
109 * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol 110 * @skc_rcv_saddr: Bound local IPv4 addr
110 * @skc_refcnt: reference count
111 * @skc_tx_queue_mapping: tx queue number for this connection
112 * @skc_hash: hash value used with various protocol lookup tables 111 * @skc_hash: hash value used with various protocol lookup tables
113 * @skc_u16hashes: two u16 hash values used by UDP lookup tables 112 * @skc_u16hashes: two u16 hash values used by UDP lookup tables
114 * @skc_family: network address family 113 * @skc_family: network address family
@@ -119,20 +118,20 @@ struct net;
119 * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol 118 * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol
120 * @skc_prot: protocol handlers inside a network family 119 * @skc_prot: protocol handlers inside a network family
121 * @skc_net: reference to the network namespace of this socket 120 * @skc_net: reference to the network namespace of this socket
121 * @skc_node: main hash linkage for various protocol lookup tables
122 * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol
123 * @skc_tx_queue_mapping: tx queue number for this connection
124 * @skc_refcnt: reference count
122 * 125 *
123 * This is the minimal network layer representation of sockets, the header 126 * This is the minimal network layer representation of sockets, the header
124 * for struct sock and struct inet_timewait_sock. 127 * for struct sock and struct inet_timewait_sock.
125 */ 128 */
126struct sock_common { 129struct sock_common {
127 /* 130 /* skc_daddr and skc_rcv_saddr must be grouped :
128 * first fields are not copied in sock_copy() 131 * cf INET_MATCH() and INET_TW_MATCH()
129 */ 132 */
130 union { 133 __be32 skc_daddr;
131 struct hlist_node skc_node; 134 __be32 skc_rcv_saddr;
132 struct hlist_nulls_node skc_nulls_node;
133 };
134 atomic_t skc_refcnt;
135 int skc_tx_queue_mapping;
136 135
137 union { 136 union {
138 unsigned int skc_hash; 137 unsigned int skc_hash;
@@ -150,6 +149,22 @@ struct sock_common {
150#ifdef CONFIG_NET_NS 149#ifdef CONFIG_NET_NS
151 struct net *skc_net; 150 struct net *skc_net;
152#endif 151#endif
152 /*
153 * fields between dontcopy_begin/dontcopy_end
154 * are not copied in sock_copy()
155 */
156 /* private: */
157 int skc_dontcopy_begin[0];
158 /* public: */
159 union {
160 struct hlist_node skc_node;
161 struct hlist_nulls_node skc_nulls_node;
162 };
163 int skc_tx_queue_mapping;
164 atomic_t skc_refcnt;
165 /* private: */
166 int skc_dontcopy_end[0];
167 /* public: */
153}; 168};
154 169
155/** 170/**
@@ -163,7 +178,6 @@ struct sock_common {
163 * @sk_dst_cache: destination cache 178 * @sk_dst_cache: destination cache
164 * @sk_dst_lock: destination cache lock 179 * @sk_dst_lock: destination cache lock
165 * @sk_policy: flow policy 180 * @sk_policy: flow policy
166 * @sk_rmem_alloc: receive queue bytes committed
167 * @sk_receive_queue: incoming packets 181 * @sk_receive_queue: incoming packets
168 * @sk_wmem_alloc: transmit queue bytes committed 182 * @sk_wmem_alloc: transmit queue bytes committed
169 * @sk_write_queue: Packet sending queue 183 * @sk_write_queue: Packet sending queue
@@ -232,7 +246,8 @@ struct sock {
232#define sk_refcnt __sk_common.skc_refcnt 246#define sk_refcnt __sk_common.skc_refcnt
233#define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping 247#define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping
234 248
235#define sk_copy_start __sk_common.skc_hash 249#define sk_dontcopy_begin __sk_common.skc_dontcopy_begin
250#define sk_dontcopy_end __sk_common.skc_dontcopy_end
236#define sk_hash __sk_common.skc_hash 251#define sk_hash __sk_common.skc_hash
237#define sk_family __sk_common.skc_family 252#define sk_family __sk_common.skc_family
238#define sk_state __sk_common.skc_state 253#define sk_state __sk_common.skc_state
@@ -241,59 +256,67 @@ struct sock {
241#define sk_bind_node __sk_common.skc_bind_node 256#define sk_bind_node __sk_common.skc_bind_node
242#define sk_prot __sk_common.skc_prot 257#define sk_prot __sk_common.skc_prot
243#define sk_net __sk_common.skc_net 258#define sk_net __sk_common.skc_net
244 kmemcheck_bitfield_begin(flags);
245 unsigned int sk_shutdown : 2,
246 sk_no_check : 2,
247 sk_userlocks : 4,
248 sk_protocol : 8,
249 sk_type : 16;
250 kmemcheck_bitfield_end(flags);
251 int sk_rcvbuf;
252 socket_lock_t sk_lock; 259 socket_lock_t sk_lock;
260 struct sk_buff_head sk_receive_queue;
253 /* 261 /*
254 * The backlog queue is special, it is always used with 262 * The backlog queue is special, it is always used with
255 * the per-socket spinlock held and requires low latency 263 * the per-socket spinlock held and requires low latency
256 * access. Therefore we special case it's implementation. 264 * access. Therefore we special case it's implementation.
265 * Note : rmem_alloc is in this structure to fill a hole
266 * on 64bit arches, not because its logically part of
267 * backlog.
257 */ 268 */
258 struct { 269 struct {
259 struct sk_buff *head; 270 atomic_t rmem_alloc;
260 struct sk_buff *tail; 271 int len;
261 int len; 272 struct sk_buff *head;
273 struct sk_buff *tail;
262 } sk_backlog; 274 } sk_backlog;
263 struct socket_wq *sk_wq; 275#define sk_rmem_alloc sk_backlog.rmem_alloc
264 struct dst_entry *sk_dst_cache; 276 int sk_forward_alloc;
277#ifdef CONFIG_RPS
278 __u32 sk_rxhash;
279#endif
280 atomic_t sk_drops;
281 int sk_rcvbuf;
282
283 struct sk_filter __rcu *sk_filter;
284 struct socket_wq __rcu *sk_wq;
285
286#ifdef CONFIG_NET_DMA
287 struct sk_buff_head sk_async_wait_queue;
288#endif
289
265#ifdef CONFIG_XFRM 290#ifdef CONFIG_XFRM
266 struct xfrm_policy *sk_policy[2]; 291 struct xfrm_policy *sk_policy[2];
267#endif 292#endif
293 unsigned long sk_flags;
294 struct dst_entry *sk_dst_cache;
268 spinlock_t sk_dst_lock; 295 spinlock_t sk_dst_lock;
269 atomic_t sk_rmem_alloc;
270 atomic_t sk_wmem_alloc; 296 atomic_t sk_wmem_alloc;
271 atomic_t sk_omem_alloc; 297 atomic_t sk_omem_alloc;
272 int sk_sndbuf; 298 int sk_sndbuf;
273 struct sk_buff_head sk_receive_queue;
274 struct sk_buff_head sk_write_queue; 299 struct sk_buff_head sk_write_queue;
275#ifdef CONFIG_NET_DMA 300 kmemcheck_bitfield_begin(flags);
276 struct sk_buff_head sk_async_wait_queue; 301 unsigned int sk_shutdown : 2,
277#endif 302 sk_no_check : 2,
303 sk_userlocks : 4,
304 sk_protocol : 8,
305 sk_type : 16;
306 kmemcheck_bitfield_end(flags);
278 int sk_wmem_queued; 307 int sk_wmem_queued;
279 int sk_forward_alloc;
280 gfp_t sk_allocation; 308 gfp_t sk_allocation;
281 int sk_route_caps; 309 int sk_route_caps;
282 int sk_route_nocaps; 310 int sk_route_nocaps;
283 int sk_gso_type; 311 int sk_gso_type;
284 unsigned int sk_gso_max_size; 312 unsigned int sk_gso_max_size;
285 int sk_rcvlowat; 313 int sk_rcvlowat;
286#ifdef CONFIG_RPS
287 __u32 sk_rxhash;
288#endif
289 unsigned long sk_flags;
290 unsigned long sk_lingertime; 314 unsigned long sk_lingertime;
291 struct sk_buff_head sk_error_queue; 315 struct sk_buff_head sk_error_queue;
292 struct proto *sk_prot_creator; 316 struct proto *sk_prot_creator;
293 rwlock_t sk_callback_lock; 317 rwlock_t sk_callback_lock;
294 int sk_err, 318 int sk_err,
295 sk_err_soft; 319 sk_err_soft;
296 atomic_t sk_drops;
297 unsigned short sk_ack_backlog; 320 unsigned short sk_ack_backlog;
298 unsigned short sk_max_ack_backlog; 321 unsigned short sk_max_ack_backlog;
299 __u32 sk_priority; 322 __u32 sk_priority;
@@ -301,7 +324,6 @@ struct sock {
301 const struct cred *sk_peer_cred; 324 const struct cred *sk_peer_cred;
302 long sk_rcvtimeo; 325 long sk_rcvtimeo;
303 long sk_sndtimeo; 326 long sk_sndtimeo;
304 struct sk_filter *sk_filter;
305 void *sk_protinfo; 327 void *sk_protinfo;
306 struct timer_list sk_timer; 328 struct timer_list sk_timer;
307 ktime_t sk_stamp; 329 ktime_t sk_stamp;
@@ -509,9 +531,6 @@ static __inline__ void sk_add_bind_node(struct sock *sk,
509#define sk_nulls_for_each_from(__sk, node) \ 531#define sk_nulls_for_each_from(__sk, node) \
510 if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \ 532 if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \
511 hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node) 533 hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node)
512#define sk_for_each_continue(__sk, node) \
513 if (__sk && ({ node = &(__sk)->sk_node; 1; })) \
514 hlist_for_each_entry_continue(__sk, node, sk_node)
515#define sk_for_each_safe(__sk, node, tmp, list) \ 534#define sk_for_each_safe(__sk, node, tmp, list) \
516 hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node) 535 hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node)
517#define sk_for_each_bound(__sk, node, list) \ 536#define sk_for_each_bound(__sk, node, list) \
@@ -734,6 +753,8 @@ struct proto {
734 int level, 753 int level,
735 int optname, char __user *optval, 754 int optname, char __user *optval,
736 int __user *option); 755 int __user *option);
756 int (*compat_ioctl)(struct sock *sk,
757 unsigned int cmd, unsigned long arg);
737#endif 758#endif
738 int (*sendmsg)(struct kiocb *iocb, struct sock *sk, 759 int (*sendmsg)(struct kiocb *iocb, struct sock *sk,
739 struct msghdr *msg, size_t len); 760 struct msghdr *msg, size_t len);
@@ -754,6 +775,7 @@ struct proto {
754 void (*unhash)(struct sock *sk); 775 void (*unhash)(struct sock *sk);
755 void (*rehash)(struct sock *sk); 776 void (*rehash)(struct sock *sk);
756 int (*get_port)(struct sock *sk, unsigned short snum); 777 int (*get_port)(struct sock *sk, unsigned short snum);
778 void (*clear_sk)(struct sock *sk, int size);
757 779
758 /* Keeping track of sockets in use */ 780 /* Keeping track of sockets in use */
759#ifdef CONFIG_PROC_FS 781#ifdef CONFIG_PROC_FS
@@ -762,7 +784,7 @@ struct proto {
762 784
763 /* Memory pressure */ 785 /* Memory pressure */
764 void (*enter_memory_pressure)(struct sock *sk); 786 void (*enter_memory_pressure)(struct sock *sk);
765 atomic_t *memory_allocated; /* Current allocated memory. */ 787 atomic_long_t *memory_allocated; /* Current allocated memory. */
766 struct percpu_counter *sockets_allocated; /* Current number of sockets. */ 788 struct percpu_counter *sockets_allocated; /* Current number of sockets. */
767 /* 789 /*
768 * Pressure flag: try to collapse. 790 * Pressure flag: try to collapse.
@@ -771,7 +793,7 @@ struct proto {
771 * is strict, actions are advisory and have some latency. 793 * is strict, actions are advisory and have some latency.
772 */ 794 */
773 int *memory_pressure; 795 int *memory_pressure;
774 int *sysctl_mem; 796 long *sysctl_mem;
775 int *sysctl_wmem; 797 int *sysctl_wmem;
776 int *sysctl_rmem; 798 int *sysctl_rmem;
777 int max_header; 799 int max_header;
@@ -852,6 +874,8 @@ static inline void __sk_prot_rehash(struct sock *sk)
852 sk->sk_prot->hash(sk); 874 sk->sk_prot->hash(sk);
853} 875}
854 876
877void sk_prot_clear_portaddr_nulls(struct sock *sk, int size);
878
855/* About 10 seconds */ 879/* About 10 seconds */
856#define SOCK_DESTROY_TIME (10*HZ) 880#define SOCK_DESTROY_TIME (10*HZ)
857 881
@@ -1155,6 +1179,8 @@ extern void sk_common_release(struct sock *sk);
1155/* Initialise core socket variables */ 1179/* Initialise core socket variables */
1156extern void sock_init_data(struct socket *sock, struct sock *sk); 1180extern void sock_init_data(struct socket *sock, struct sock *sk);
1157 1181
1182extern void sk_filter_release_rcu(struct rcu_head *rcu);
1183
1158/** 1184/**
1159 * sk_filter_release - release a socket filter 1185 * sk_filter_release - release a socket filter
1160 * @fp: filter to remove 1186 * @fp: filter to remove
@@ -1165,7 +1191,7 @@ extern void sock_init_data(struct socket *sock, struct sock *sk);
1165static inline void sk_filter_release(struct sk_filter *fp) 1191static inline void sk_filter_release(struct sk_filter *fp)
1166{ 1192{
1167 if (atomic_dec_and_test(&fp->refcnt)) 1193 if (atomic_dec_and_test(&fp->refcnt))
1168 kfree(fp); 1194 call_rcu(&fp->rcu, sk_filter_release_rcu);
1169} 1195}
1170 1196
1171static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp) 1197static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
@@ -1240,7 +1266,8 @@ static inline void sk_set_socket(struct sock *sk, struct socket *sock)
1240 1266
1241static inline wait_queue_head_t *sk_sleep(struct sock *sk) 1267static inline wait_queue_head_t *sk_sleep(struct sock *sk)
1242{ 1268{
1243 return &sk->sk_wq->wait; 1269 BUILD_BUG_ON(offsetof(struct socket_wq, wait) != 0);
1270 return &rcu_dereference_raw(sk->sk_wq)->wait;
1244} 1271}
1245/* Detach socket from process context. 1272/* Detach socket from process context.
1246 * Announce socket dead, detach it from wait queue and inode. 1273 * Announce socket dead, detach it from wait queue and inode.
@@ -1261,7 +1288,7 @@ static inline void sock_orphan(struct sock *sk)
1261static inline void sock_graft(struct sock *sk, struct socket *parent) 1288static inline void sock_graft(struct sock *sk, struct socket *parent)
1262{ 1289{
1263 write_lock_bh(&sk->sk_callback_lock); 1290 write_lock_bh(&sk->sk_callback_lock);
1264 rcu_assign_pointer(sk->sk_wq, parent->wq); 1291 sk->sk_wq = parent->wq;
1265 parent->sk = sk; 1292 parent->sk = sk;
1266 sk_set_socket(sk, parent); 1293 sk_set_socket(sk, parent);
1267 security_sock_graft(sk, parent); 1294 security_sock_graft(sk, parent);
@@ -1362,6 +1389,59 @@ static inline void sk_nocaps_add(struct sock *sk, int flags)
1362 sk->sk_route_caps &= ~flags; 1389 sk->sk_route_caps &= ~flags;
1363} 1390}
1364 1391
1392static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
1393 char __user *from, char *to,
1394 int copy, int offset)
1395{
1396 if (skb->ip_summed == CHECKSUM_NONE) {
1397 int err = 0;
1398 __wsum csum = csum_and_copy_from_user(from, to, copy, 0, &err);
1399 if (err)
1400 return err;
1401 skb->csum = csum_block_add(skb->csum, csum, offset);
1402 } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) {
1403 if (!access_ok(VERIFY_READ, from, copy) ||
1404 __copy_from_user_nocache(to, from, copy))
1405 return -EFAULT;
1406 } else if (copy_from_user(to, from, copy))
1407 return -EFAULT;
1408
1409 return 0;
1410}
1411
1412static inline int skb_add_data_nocache(struct sock *sk, struct sk_buff *skb,
1413 char __user *from, int copy)
1414{
1415 int err, offset = skb->len;
1416
1417 err = skb_do_copy_data_nocache(sk, skb, from, skb_put(skb, copy),
1418 copy, offset);
1419 if (err)
1420 __skb_trim(skb, offset);
1421
1422 return err;
1423}
1424
1425static inline int skb_copy_to_page_nocache(struct sock *sk, char __user *from,
1426 struct sk_buff *skb,
1427 struct page *page,
1428 int off, int copy)
1429{
1430 int err;
1431
1432 err = skb_do_copy_data_nocache(sk, skb, from, page_address(page) + off,
1433 copy, skb->len);
1434 if (err)
1435 return err;
1436
1437 skb->len += copy;
1438 skb->data_len += copy;
1439 skb->truesize += copy;
1440 sk->sk_wmem_queued += copy;
1441 sk_mem_charge(sk, copy);
1442 return 0;
1443}
1444
1365static inline int skb_copy_to_page(struct sock *sk, char __user *from, 1445static inline int skb_copy_to_page(struct sock *sk, char __user *from,
1366 struct sk_buff *skb, struct page *page, 1446 struct sk_buff *skb, struct page *page,
1367 int off, int copy) 1447 int off, int copy)
@@ -1558,7 +1638,11 @@ static inline void sk_wake_async(struct sock *sk, int how, int band)
1558} 1638}
1559 1639
1560#define SOCK_MIN_SNDBUF 2048 1640#define SOCK_MIN_SNDBUF 2048
1561#define SOCK_MIN_RCVBUF 256 1641/*
1642 * Since sk_rmem_alloc sums skb->truesize, even a small frame might need
1643 * sizeof(sk_buff) + MTU + padding, unless net driver perform copybreak
1644 */
1645#define SOCK_MIN_RCVBUF (2048 + sizeof(struct sk_buff))
1562 1646
1563static inline void sk_stream_moderate_sndbuf(struct sock *sk) 1647static inline void sk_stream_moderate_sndbuf(struct sock *sk)
1564{ 1648{
@@ -1670,17 +1754,13 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
1670 1754
1671/** 1755/**
1672 * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped 1756 * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
1673 * @msg: outgoing packet
1674 * @sk: socket sending this packet 1757 * @sk: socket sending this packet
1675 * @shtx: filled with instructions for time stamping 1758 * @tx_flags: filled with instructions for time stamping
1676 * 1759 *
1677 * Currently only depends on SOCK_TIMESTAMPING* flags. Returns error code if 1760 * Currently only depends on SOCK_TIMESTAMPING* flags. Returns error code if
1678 * parameters are invalid. 1761 * parameters are invalid.
1679 */ 1762 */
1680extern int sock_tx_timestamp(struct msghdr *msg, 1763extern int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags);
1681 struct sock *sk,
1682 union skb_shared_tx *shtx);
1683
1684 1764
1685/** 1765/**
1686 * sk_eat_skb - Release a skb if it is no longer needed 1766 * sk_eat_skb - Release a skb if it is no longer needed
@@ -1722,7 +1802,7 @@ void sock_net_set(struct sock *sk, struct net *net)
1722 1802
1723/* 1803/*
1724 * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace. 1804 * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace.
1725 * They should not hold a referrence to a namespace in order to allow 1805 * They should not hold a reference to a namespace in order to allow
1726 * to stop it. 1806 * to stop it.
1727 * Sockets after sk_change_net should be released using sk_release_kernel 1807 * Sockets after sk_change_net should be released using sk_release_kernel
1728 */ 1808 */
diff --git a/include/net/tc_act/tc_csum.h b/include/net/tc_act/tc_csum.h
new file mode 100644
index 000000000000..9e8710be7a04
--- /dev/null
+++ b/include/net/tc_act/tc_csum.h
@@ -0,0 +1,15 @@
1#ifndef __NET_TC_CSUM_H
2#define __NET_TC_CSUM_H
3
4#include <linux/types.h>
5#include <net/act_api.h>
6
7struct tcf_csum {
8 struct tcf_common common;
9
10 u32 update_flags;
11};
12#define to_tcf_csum(pc) \
13 container_of(pc,struct tcf_csum,common)
14
15#endif /* __NET_TC_CSUM_H */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3e4b33e36602..cda30ea354a2 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -60,6 +60,9 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
60 */ 60 */
61#define MAX_TCP_WINDOW 32767U 61#define MAX_TCP_WINDOW 32767U
62 62
63/* Offer an initial receive window of 10 mss. */
64#define TCP_DEFAULT_INIT_RCVWND 10
65
63/* Minimal accepted MSS. It is (60+60+8) - (20+20). */ 66/* Minimal accepted MSS. It is (60+60+8) - (20+20). */
64#define TCP_MIN_MSS 88U 67#define TCP_MIN_MSS 88U
65 68
@@ -100,12 +103,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
100#define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a 103#define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a
101 * connection: ~180sec is RFC minimum */ 104 * connection: ~180sec is RFC minimum */
102 105
103
104#define TCP_ORPHAN_RETRIES 7 /* number of times to retry on an orphaned
105 * socket. 7 is ~50sec-16min.
106 */
107
108
109#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT 106#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT
110 * state, about 60 seconds */ 107 * state, about 60 seconds */
111#define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN 108#define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN
@@ -199,6 +196,9 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
199/* TCP thin-stream limits */ 196/* TCP thin-stream limits */
200#define TCP_THIN_LINEAR_RETRIES 6 /* After 6 linear retries, do exp. backoff */ 197#define TCP_THIN_LINEAR_RETRIES 6 /* After 6 linear retries, do exp. backoff */
201 198
199/* TCP initial congestion window as per draft-hkchu-tcpm-initcwnd-01 */
200#define TCP_INIT_CWND 10
201
202extern struct inet_timewait_death_row tcp_death_row; 202extern struct inet_timewait_death_row tcp_death_row;
203 203
204/* sysctl variables for tcp */ 204/* sysctl variables for tcp */
@@ -224,7 +224,7 @@ extern int sysctl_tcp_fack;
224extern int sysctl_tcp_reordering; 224extern int sysctl_tcp_reordering;
225extern int sysctl_tcp_ecn; 225extern int sysctl_tcp_ecn;
226extern int sysctl_tcp_dsack; 226extern int sysctl_tcp_dsack;
227extern int sysctl_tcp_mem[3]; 227extern long sysctl_tcp_mem[3];
228extern int sysctl_tcp_wmem[3]; 228extern int sysctl_tcp_wmem[3];
229extern int sysctl_tcp_rmem[3]; 229extern int sysctl_tcp_rmem[3];
230extern int sysctl_tcp_app_win; 230extern int sysctl_tcp_app_win;
@@ -247,7 +247,7 @@ extern int sysctl_tcp_cookie_size;
247extern int sysctl_tcp_thin_linear_timeouts; 247extern int sysctl_tcp_thin_linear_timeouts;
248extern int sysctl_tcp_thin_dupack; 248extern int sysctl_tcp_thin_dupack;
249 249
250extern atomic_t tcp_memory_allocated; 250extern atomic_long_t tcp_memory_allocated;
251extern struct percpu_counter tcp_sockets_allocated; 251extern struct percpu_counter tcp_sockets_allocated;
252extern int tcp_memory_pressure; 252extern int tcp_memory_pressure;
253 253
@@ -280,7 +280,7 @@ static inline bool tcp_too_many_orphans(struct sock *sk, int shift)
280 } 280 }
281 281
282 if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && 282 if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
283 atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]) 283 atomic_long_read(&tcp_memory_allocated) > sysctl_tcp_mem[2])
284 return true; 284 return true;
285 return false; 285 return false;
286} 286}
@@ -312,7 +312,8 @@ extern void tcp_shutdown (struct sock *sk, int how);
312 312
313extern int tcp_v4_rcv(struct sk_buff *skb); 313extern int tcp_v4_rcv(struct sk_buff *skb);
314 314
315extern int tcp_v4_remember_stamp(struct sock *sk); 315extern struct inet_peer *tcp_v4_get_peer(struct sock *sk, bool *release_it);
316extern void *tcp_v4_tw_get_peer(struct sock *sk);
316extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); 317extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw);
317extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 318extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
318 size_t size); 319 size_t size);
@@ -346,8 +347,6 @@ static inline void tcp_dec_quickack_mode(struct sock *sk,
346 } 347 }
347} 348}
348 349
349extern void tcp_enter_quickack_mode(struct sock *sk);
350
351#define TCP_ECN_OK 1 350#define TCP_ECN_OK 1
352#define TCP_ECN_QUEUE_CWR 2 351#define TCP_ECN_QUEUE_CWR 2
353#define TCP_ECN_DEMAND_CWR 4 352#define TCP_ECN_DEMAND_CWR 4
@@ -1036,7 +1035,13 @@ static inline int tcp_paws_check(const struct tcp_options_received *rx_opt,
1036 return 1; 1035 return 1;
1037 if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) 1036 if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS))
1038 return 1; 1037 return 1;
1039 1038 /*
1039 * Some OSes send SYN and SYNACK messages with tsval=0 tsecr=0,
1040 * then following tcp messages have valid values. Ignore 0 value,
1041 * or else 'negative' tsval might forbid us to accept their packets.
1042 */
1043 if (!rx_opt->ts_recent)
1044 return 1;
1040 return 0; 1045 return 0;
1041} 1046}
1042 1047
@@ -1063,8 +1068,6 @@ static inline int tcp_paws_reject(const struct tcp_options_received *rx_opt,
1063 return 1; 1068 return 1;
1064} 1069}
1065 1070
1066#define TCP_CHECK_TIMER(sk) do { } while (0)
1067
1068static inline void tcp_mib_init(struct net *net) 1071static inline void tcp_mib_init(struct net *net)
1069{ 1072{
1070 /* See RFC 2012 */ 1073 /* See RFC 2012 */
@@ -1150,8 +1153,6 @@ struct tcp_md5sig_pool {
1150 union tcp_md5sum_block md5_blk; 1153 union tcp_md5sum_block md5_blk;
1151}; 1154};
1152 1155
1153#define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */
1154
1155/* - functions */ 1156/* - functions */
1156extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, 1157extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
1157 struct sock *sk, struct request_sock *req, 1158 struct sock *sk, struct request_sock *req,
@@ -1395,7 +1396,7 @@ extern struct request_sock_ops tcp6_request_sock_ops;
1395extern void tcp_v4_destroy_sock(struct sock *sk); 1396extern void tcp_v4_destroy_sock(struct sock *sk);
1396 1397
1397extern int tcp_v4_gso_send_check(struct sk_buff *skb); 1398extern int tcp_v4_gso_send_check(struct sk_buff *skb);
1398extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features); 1399extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, u32 features);
1399extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, 1400extern struct sk_buff **tcp_gro_receive(struct sk_buff **head,
1400 struct sk_buff *skb); 1401 struct sk_buff *skb);
1401extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, 1402extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head,
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h
index 97c3b14da55d..053b3cf2c66a 100644
--- a/include/net/timewait_sock.h
+++ b/include/net/timewait_sock.h
@@ -21,6 +21,7 @@ struct timewait_sock_ops {
21 int (*twsk_unique)(struct sock *sk, 21 int (*twsk_unique)(struct sock *sk,
22 struct sock *sktw, void *twp); 22 struct sock *sktw, void *twp);
23 void (*twsk_destructor)(struct sock *sk); 23 void (*twsk_destructor)(struct sock *sk);
24 void *(*twsk_getpeer)(struct sock *sk);
24}; 25};
25 26
26static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) 27static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
@@ -39,4 +40,11 @@ static inline void twsk_destructor(struct sock *sk)
39 sk->sk_prot->twsk_prot->twsk_destructor(sk); 40 sk->sk_prot->twsk_prot->twsk_destructor(sk);
40} 41}
41 42
43static inline void *twsk_getpeer(struct sock *sk)
44{
45 if (sk->sk_prot->twsk_prot->twsk_getpeer)
46 return sk->sk_prot->twsk_prot->twsk_getpeer(sk);
47 return NULL;
48}
49
42#endif /* _TIMEWAIT_SOCK_H */ 50#endif /* _TIMEWAIT_SOCK_H */
diff --git a/include/net/tipc/tipc.h b/include/net/tipc/tipc.h
deleted file mode 100644
index 15af6dca0b49..000000000000
--- a/include/net/tipc/tipc.h
+++ /dev/null
@@ -1,257 +0,0 @@
1/*
2 * include/net/tipc/tipc.h: Main include file for TIPC users
3 *
4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005,2010 Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _NET_TIPC_H_
38#define _NET_TIPC_H_
39
40#ifdef __KERNEL__
41
42#include <linux/tipc.h>
43#include <linux/skbuff.h>
44
45/*
46 * Native API
47 */
48
49/*
50 * TIPC operating mode routines
51 */
52
53u32 tipc_get_addr(void);
54
55#define TIPC_NOT_RUNNING 0
56#define TIPC_NODE_MODE 1
57#define TIPC_NET_MODE 2
58
59typedef void (*tipc_mode_event)(void *usr_handle, int mode, u32 addr);
60
61int tipc_attach(unsigned int *userref, tipc_mode_event, void *usr_handle);
62
63void tipc_detach(unsigned int userref);
64
65int tipc_get_mode(void);
66
67/*
68 * TIPC port manipulation routines
69 */
70
71typedef void (*tipc_msg_err_event) (void *usr_handle,
72 u32 portref,
73 struct sk_buff **buf,
74 unsigned char const *data,
75 unsigned int size,
76 int reason,
77 struct tipc_portid const *attmpt_destid);
78
79typedef void (*tipc_named_msg_err_event) (void *usr_handle,
80 u32 portref,
81 struct sk_buff **buf,
82 unsigned char const *data,
83 unsigned int size,
84 int reason,
85 struct tipc_name_seq const *attmpt_dest);
86
87typedef void (*tipc_conn_shutdown_event) (void *usr_handle,
88 u32 portref,
89 struct sk_buff **buf,
90 unsigned char const *data,
91 unsigned int size,
92 int reason);
93
94typedef void (*tipc_msg_event) (void *usr_handle,
95 u32 portref,
96 struct sk_buff **buf,
97 unsigned char const *data,
98 unsigned int size,
99 unsigned int importance,
100 struct tipc_portid const *origin);
101
102typedef void (*tipc_named_msg_event) (void *usr_handle,
103 u32 portref,
104 struct sk_buff **buf,
105 unsigned char const *data,
106 unsigned int size,
107 unsigned int importance,
108 struct tipc_portid const *orig,
109 struct tipc_name_seq const *dest);
110
111typedef void (*tipc_conn_msg_event) (void *usr_handle,
112 u32 portref,
113 struct sk_buff **buf,
114 unsigned char const *data,
115 unsigned int size);
116
117typedef void (*tipc_continue_event) (void *usr_handle,
118 u32 portref);
119
120int tipc_createport(unsigned int tipc_user,
121 void *usr_handle,
122 unsigned int importance,
123 tipc_msg_err_event error_cb,
124 tipc_named_msg_err_event named_error_cb,
125 tipc_conn_shutdown_event conn_error_cb,
126 tipc_msg_event message_cb,
127 tipc_named_msg_event named_message_cb,
128 tipc_conn_msg_event conn_message_cb,
129 tipc_continue_event continue_event_cb,
130 u32 *portref);
131
132int tipc_deleteport(u32 portref);
133
134int tipc_ownidentity(u32 portref, struct tipc_portid *port);
135
136int tipc_portimportance(u32 portref, unsigned int *importance);
137int tipc_set_portimportance(u32 portref, unsigned int importance);
138
139int tipc_portunreliable(u32 portref, unsigned int *isunreliable);
140int tipc_set_portunreliable(u32 portref, unsigned int isunreliable);
141
142int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable);
143int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable);
144
145int tipc_publish(u32 portref, unsigned int scope,
146 struct tipc_name_seq const *name_seq);
147int tipc_withdraw(u32 portref, unsigned int scope,
148 struct tipc_name_seq const *name_seq);
149
150int tipc_connect2port(u32 portref, struct tipc_portid const *port);
151
152int tipc_disconnect(u32 portref);
153
154int tipc_shutdown(u32 ref);
155
156int tipc_isconnected(u32 portref, int *isconnected);
157
158int tipc_peer(u32 portref, struct tipc_portid *peer);
159
160int tipc_ref_valid(u32 portref);
161
162/*
163 * TIPC messaging routines
164 */
165
166#define TIPC_PORT_IMPORTANCE 100 /* send using current port setting */
167
168
169int tipc_send(u32 portref,
170 unsigned int num_sect,
171 struct iovec const *msg_sect);
172
173int tipc_send_buf(u32 portref,
174 struct sk_buff *buf,
175 unsigned int dsz);
176
177int tipc_send2name(u32 portref,
178 struct tipc_name const *name,
179 u32 domain,
180 unsigned int num_sect,
181 struct iovec const *msg_sect);
182
183int tipc_send_buf2name(u32 portref,
184 struct tipc_name const *name,
185 u32 domain,
186 struct sk_buff *buf,
187 unsigned int dsz);
188
189int tipc_forward2name(u32 portref,
190 struct tipc_name const *name,
191 u32 domain,
192 unsigned int section_count,
193 struct iovec const *msg_sect,
194 struct tipc_portid const *origin,
195 unsigned int importance);
196
197int tipc_forward_buf2name(u32 portref,
198 struct tipc_name const *name,
199 u32 domain,
200 struct sk_buff *buf,
201 unsigned int dsz,
202 struct tipc_portid const *orig,
203 unsigned int importance);
204
205int tipc_send2port(u32 portref,
206 struct tipc_portid const *dest,
207 unsigned int num_sect,
208 struct iovec const *msg_sect);
209
210int tipc_send_buf2port(u32 portref,
211 struct tipc_portid const *dest,
212 struct sk_buff *buf,
213 unsigned int dsz);
214
215int tipc_forward2port(u32 portref,
216 struct tipc_portid const *dest,
217 unsigned int num_sect,
218 struct iovec const *msg_sect,
219 struct tipc_portid const *origin,
220 unsigned int importance);
221
222int tipc_forward_buf2port(u32 portref,
223 struct tipc_portid const *dest,
224 struct sk_buff *buf,
225 unsigned int dsz,
226 struct tipc_portid const *orig,
227 unsigned int importance);
228
229int tipc_multicast(u32 portref,
230 struct tipc_name_seq const *seq,
231 u32 domain, /* currently unused */
232 unsigned int section_count,
233 struct iovec const *msg);
234
235#if 0
236int tipc_multicast_buf(u32 portref,
237 struct tipc_name_seq const *seq,
238 u32 domain,
239 void *buf,
240 unsigned int size);
241#endif
242
243/*
244 * TIPC subscription routines
245 */
246
247int tipc_ispublished(struct tipc_name const *name);
248
249/*
250 * Get number of available nodes within specified domain (excluding own node)
251 */
252
253unsigned int tipc_available_nodes(const u32 domain);
254
255#endif
256
257#endif
diff --git a/include/net/tipc/tipc_bearer.h b/include/net/tipc/tipc_bearer.h
deleted file mode 100644
index ee2f304e4919..000000000000
--- a/include/net/tipc/tipc_bearer.h
+++ /dev/null
@@ -1,138 +0,0 @@
1/*
2 * include/net/tipc/tipc_bearer.h: Include file for privileged access to TIPC bearers
3 *
4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _NET_TIPC_BEARER_H_
38#define _NET_TIPC_BEARER_H_
39
40#ifdef __KERNEL__
41
42#include <linux/tipc_config.h>
43#include <linux/skbuff.h>
44#include <linux/spinlock.h>
45
46/*
47 * Identifiers of supported TIPC media types
48 */
49
50#define TIPC_MEDIA_TYPE_ETH 1
51
52/*
53 * Destination address structure used by TIPC bearers when sending messages
54 *
55 * IMPORTANT: The fields of this structure MUST be stored using the specified
56 * byte order indicated below, as the structure is exchanged between nodes
57 * as part of a link setup process.
58 */
59
60struct tipc_media_addr {
61 __be32 type; /* bearer type (network byte order) */
62 union {
63 __u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */
64#if 0
65 /* Prototypes for other possible bearer types */
66
67 struct {
68 __u16 sin_family;
69 __u16 sin_port;
70 struct {
71 __u32 s_addr;
72 } sin_addr;
73 char pad[4];
74 } addr_in; /* IP-based bearer */
75 __u16 sock_descr; /* generic socket bearer */
76#endif
77 } dev_addr;
78};
79
80/**
81 * struct tipc_bearer - TIPC bearer info available to privileged users
82 * @usr_handle: pointer to additional user-defined information about bearer
83 * @mtu: max packet size bearer can support
84 * @blocked: non-zero if bearer is blocked
85 * @lock: spinlock for controlling access to bearer
86 * @addr: media-specific address associated with bearer
87 * @name: bearer name (format = media:interface)
88 *
89 * Note: TIPC initializes "name" and "lock" fields; user is responsible for
90 * initialization all other fields when a bearer is enabled.
91 */
92
93struct tipc_bearer {
94 void *usr_handle;
95 u32 mtu;
96 int blocked;
97 spinlock_t lock;
98 struct tipc_media_addr addr;
99 char name[TIPC_MAX_BEARER_NAME];
100};
101
102/*
103 * TIPC routines available to supported media types
104 */
105
106int tipc_register_media(u32 media_type,
107 char *media_name,
108 int (*enable)(struct tipc_bearer *),
109 void (*disable)(struct tipc_bearer *),
110 int (*send_msg)(struct sk_buff *,
111 struct tipc_bearer *,
112 struct tipc_media_addr *),
113 char *(*addr2str)(struct tipc_media_addr *a,
114 char *str_buf,
115 int str_size),
116 struct tipc_media_addr *bcast_addr,
117 const u32 bearer_priority,
118 const u32 link_tolerance, /* [ms] */
119 const u32 send_window_limit);
120
121void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
122
123int tipc_block_bearer(const char *name);
124void tipc_continue(struct tipc_bearer *tb_ptr);
125
126int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority);
127int tipc_disable_bearer(const char *name);
128
129/*
130 * Routines made available to TIPC by supported media types
131 */
132
133int tipc_eth_media_start(void);
134void tipc_eth_media_stop(void);
135
136#endif
137
138#endif
diff --git a/include/net/tipc/tipc_msg.h b/include/net/tipc/tipc_msg.h
deleted file mode 100644
index 2e159a812f83..000000000000
--- a/include/net/tipc/tipc_msg.h
+++ /dev/null
@@ -1,207 +0,0 @@
1/*
2 * include/net/tipc/tipc_msg.h: Include file for privileged access to TIPC message headers
3 *
4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _NET_TIPC_MSG_H_
38#define _NET_TIPC_MSG_H_
39
40#ifdef __KERNEL__
41
42struct tipc_msg {
43 __be32 hdr[15];
44};
45
46
47/*
48 TIPC user data message header format, version 2:
49
50
51 1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0
52 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 w0:|vers | user |hdr sz |n|d|s|-| message size |
54 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 w1:|mstyp| error |rer cnt|lsc|opt p| broadcast ack no |
56 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 w2:| link level ack no | broadcast/link level seq no |
58 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 w3:| previous node |
60 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 w4:| originating port |
62 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 w5:| destination port |
64 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 w6:| originating node |
66 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67 w7:| destination node |
68 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69 w8:| name type / transport sequence number |
70 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
71 w9:| name instance/multicast lower bound |
72 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 wA:| multicast upper bound |
74 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 / /
76 \ options \
77 / /
78 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79
80*/
81
82#define TIPC_CONN_MSG 0
83#define TIPC_MCAST_MSG 1
84#define TIPC_NAMED_MSG 2
85#define TIPC_DIRECT_MSG 3
86
87
88static inline u32 msg_word(struct tipc_msg *m, u32 pos)
89{
90 return ntohl(m->hdr[pos]);
91}
92
93static inline u32 msg_bits(struct tipc_msg *m, u32 w, u32 pos, u32 mask)
94{
95 return (msg_word(m, w) >> pos) & mask;
96}
97
98static inline u32 msg_importance(struct tipc_msg *m)
99{
100 return msg_bits(m, 0, 25, 0xf);
101}
102
103static inline u32 msg_hdr_sz(struct tipc_msg *m)
104{
105 return msg_bits(m, 0, 21, 0xf) << 2;
106}
107
108static inline int msg_short(struct tipc_msg *m)
109{
110 return (msg_hdr_sz(m) == 24);
111}
112
113static inline u32 msg_size(struct tipc_msg *m)
114{
115 return msg_bits(m, 0, 0, 0x1ffff);
116}
117
118static inline u32 msg_data_sz(struct tipc_msg *m)
119{
120 return (msg_size(m) - msg_hdr_sz(m));
121}
122
123static inline unchar *msg_data(struct tipc_msg *m)
124{
125 return ((unchar *)m) + msg_hdr_sz(m);
126}
127
128static inline u32 msg_type(struct tipc_msg *m)
129{
130 return msg_bits(m, 1, 29, 0x7);
131}
132
133static inline u32 msg_named(struct tipc_msg *m)
134{
135 return (msg_type(m) == TIPC_NAMED_MSG);
136}
137
138static inline u32 msg_mcast(struct tipc_msg *m)
139{
140 return (msg_type(m) == TIPC_MCAST_MSG);
141}
142
143static inline u32 msg_connected(struct tipc_msg *m)
144{
145 return (msg_type(m) == TIPC_CONN_MSG);
146}
147
148static inline u32 msg_errcode(struct tipc_msg *m)
149{
150 return msg_bits(m, 1, 25, 0xf);
151}
152
153static inline u32 msg_prevnode(struct tipc_msg *m)
154{
155 return msg_word(m, 3);
156}
157
158static inline u32 msg_origport(struct tipc_msg *m)
159{
160 return msg_word(m, 4);
161}
162
163static inline u32 msg_destport(struct tipc_msg *m)
164{
165 return msg_word(m, 5);
166}
167
168static inline u32 msg_mc_netid(struct tipc_msg *m)
169{
170 return msg_word(m, 5);
171}
172
173static inline u32 msg_orignode(struct tipc_msg *m)
174{
175 if (likely(msg_short(m)))
176 return msg_prevnode(m);
177 return msg_word(m, 6);
178}
179
180static inline u32 msg_destnode(struct tipc_msg *m)
181{
182 return msg_word(m, 7);
183}
184
185static inline u32 msg_nametype(struct tipc_msg *m)
186{
187 return msg_word(m, 8);
188}
189
190static inline u32 msg_nameinst(struct tipc_msg *m)
191{
192 return msg_word(m, 9);
193}
194
195static inline u32 msg_namelower(struct tipc_msg *m)
196{
197 return msg_nameinst(m);
198}
199
200static inline u32 msg_nameupper(struct tipc_msg *m)
201{
202 return msg_word(m, 10);
203}
204
205#endif
206
207#endif
diff --git a/include/net/tipc/tipc_port.h b/include/net/tipc/tipc_port.h
deleted file mode 100644
index c54917cbfa48..000000000000
--- a/include/net/tipc/tipc_port.h
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 * include/net/tipc/tipc_port.h: Include file for privileged access to TIPC ports
3 *
4 * Copyright (c) 1994-2007, Ericsson AB
5 * Copyright (c) 2005-2008, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _NET_TIPC_PORT_H_
38#define _NET_TIPC_PORT_H_
39
40#ifdef __KERNEL__
41
42#include <linux/tipc.h>
43#include <linux/skbuff.h>
44#include <net/tipc/tipc_msg.h>
45
46#define TIPC_FLOW_CONTROL_WIN 512
47
48/**
49 * struct tipc_port - native TIPC port info available to privileged users
50 * @usr_handle: pointer to additional user-defined information about port
51 * @lock: pointer to spinlock for controlling access to port
52 * @connected: non-zero if port is currently connected to a peer port
53 * @conn_type: TIPC type used when connection was established
54 * @conn_instance: TIPC instance used when connection was established
55 * @conn_unacked: number of unacknowledged messages received from peer port
56 * @published: non-zero if port has one or more associated names
57 * @congested: non-zero if cannot send because of link or port congestion
58 * @max_pkt: maximum packet size "hint" used when building messages sent by port
59 * @ref: unique reference to port in TIPC object registry
60 * @phdr: preformatted message header used when sending messages
61 */
62
63struct tipc_port {
64 void *usr_handle;
65 spinlock_t *lock;
66 int connected;
67 u32 conn_type;
68 u32 conn_instance;
69 u32 conn_unacked;
70 int published;
71 u32 congested;
72 u32 max_pkt;
73 u32 ref;
74 struct tipc_msg phdr;
75};
76
77
78struct tipc_port *tipc_createport_raw(void *usr_handle,
79 u32 (*dispatcher)(struct tipc_port *, struct sk_buff *),
80 void (*wakeup)(struct tipc_port *),
81 const u32 importance);
82
83int tipc_reject_msg(struct sk_buff *buf, u32 err);
84
85int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode);
86
87void tipc_acknowledge(u32 port_ref,u32 ack);
88
89struct tipc_port *tipc_get_port(const u32 ref);
90
91void *tipc_get_handle(const u32 ref);
92
93/*
94 * The following routines require that the port be locked on entry
95 */
96
97int tipc_disconnect_port(struct tipc_port *tp_ptr);
98
99
100#endif
101
102#endif
103
diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h
index 42a0eb68b7b6..5271a741c3a3 100644
--- a/include/net/transp_v6.h
+++ b/include/net/transp_v6.h
@@ -7,16 +7,14 @@
7 * IPv6 transport protocols 7 * IPv6 transport protocols
8 */ 8 */
9 9
10#ifdef __KERNEL__
11
12extern struct proto rawv6_prot; 10extern struct proto rawv6_prot;
13extern struct proto udpv6_prot; 11extern struct proto udpv6_prot;
14extern struct proto udplitev6_prot; 12extern struct proto udplitev6_prot;
15extern struct proto tcpv6_prot; 13extern struct proto tcpv6_prot;
16 14
17struct flowi; 15struct flowi6;
18 16
19/* extention headers */ 17/* extension headers */
20extern int ipv6_exthdrs_init(void); 18extern int ipv6_exthdrs_init(void);
21extern void ipv6_exthdrs_exit(void); 19extern void ipv6_exthdrs_exit(void);
22extern int ipv6_frag_init(void); 20extern int ipv6_frag_init(void);
@@ -42,7 +40,7 @@ extern int datagram_recv_ctl(struct sock *sk,
42 40
43extern int datagram_send_ctl(struct net *net, 41extern int datagram_send_ctl(struct net *net,
44 struct msghdr *msg, 42 struct msghdr *msg,
45 struct flowi *fl, 43 struct flowi6 *fl6,
46 struct ipv6_txoptions *opt, 44 struct ipv6_txoptions *opt,
47 int *hlimit, int *tclass, 45 int *hlimit, int *tclass,
48 int *dontfrag); 46 int *dontfrag);
@@ -57,5 +55,3 @@ extern const struct inet_connection_sock_af_ops ipv4_specific;
57extern void inet6_destroy_sock(struct sock *sk); 55extern void inet6_destroy_sock(struct sock *sk);
58 56
59#endif 57#endif
60
61#endif
diff --git a/include/net/udp.h b/include/net/udp.h
index a184d3496b13..67ea6fcb3ec0 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -105,10 +105,10 @@ static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
105 105
106extern struct proto udp_prot; 106extern struct proto udp_prot;
107 107
108extern atomic_t udp_memory_allocated; 108extern atomic_long_t udp_memory_allocated;
109 109
110/* sysctl variables for udp */ 110/* sysctl variables for udp */
111extern int sysctl_udp_mem[3]; 111extern long sysctl_udp_mem[3];
112extern int sysctl_udp_rmem_min; 112extern int sysctl_udp_rmem_min;
113extern int sysctl_udp_wmem_min; 113extern int sysctl_udp_wmem_min;
114 114
@@ -144,6 +144,17 @@ static inline __wsum udp_csum_outgoing(struct sock *sk, struct sk_buff *skb)
144 return csum; 144 return csum;
145} 145}
146 146
147static inline __wsum udp_csum(struct sk_buff *skb)
148{
149 __wsum csum = csum_partial(skb_transport_header(skb),
150 sizeof(struct udphdr), skb->csum);
151
152 for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) {
153 csum = csum_add(csum, skb->csum);
154 }
155 return csum;
156}
157
147/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ 158/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
148static inline void udp_lib_hash(struct sock *sk) 159static inline void udp_lib_hash(struct sock *sk)
149{ 160{
@@ -183,6 +194,9 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
183extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, 194extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
184 __be32 daddr, __be16 dport, 195 __be32 daddr, __be16 dport,
185 int dif); 196 int dif);
197extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport,
198 const struct in6_addr *daddr, __be16 dport,
199 int dif);
186 200
187/* 201/*
188 * SNMP statistics for UDP and UDP-Lite 202 * SNMP statistics for UDP and UDP-Lite
@@ -242,5 +256,5 @@ extern void udp4_proc_exit(void);
242extern void udp_init(void); 256extern void udp_init(void);
243 257
244extern int udp4_ufo_send_check(struct sk_buff *skb); 258extern int udp4_ufo_send_check(struct sk_buff *skb);
245extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, int features); 259extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, u32 features);
246#endif /* _UDP_H */ 260#endif /* _UDP_H */
diff --git a/include/net/udplite.h b/include/net/udplite.h
index afdffe607b24..673a024c6b2a 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -115,6 +115,18 @@ static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
115 return csum; 115 return csum;
116} 116}
117 117
118static inline __wsum udplite_csum(struct sk_buff *skb)
119{
120 struct sock *sk = skb->sk;
121 int cscov = udplite_sender_cscov(udp_sk(sk), udp_hdr(skb));
122 const int off = skb_transport_offset(skb);
123 const int len = skb->len - off;
124
125 skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */
126
127 return skb_checksum(skb, off, min(cscov, len), 0);
128}
129
118extern void udplite4_register(void); 130extern void udplite4_register(void);
119extern int udplite_get_port(struct sock *sk, unsigned short snum, 131extern int udplite_get_port(struct sock *sk, unsigned short snum,
120 int (*scmp)(const struct sock *, const struct sock *)); 132 int (*scmp)(const struct sock *, const struct sock *));
diff --git a/include/net/wimax.h b/include/net/wimax.h
index 3461aa1df1e0..7328d5019d88 100644
--- a/include/net/wimax.h
+++ b/include/net/wimax.h
@@ -250,7 +250,6 @@
250 250
251#ifndef __NET__WIMAX_H__ 251#ifndef __NET__WIMAX_H__
252#define __NET__WIMAX_H__ 252#define __NET__WIMAX_H__
253#ifdef __KERNEL__
254 253
255#include <linux/wimax.h> 254#include <linux/wimax.h>
256#include <net/genetlink.h> 255#include <net/genetlink.h>
@@ -286,7 +285,7 @@ struct wimax_dev;
286 * does not disconnect the device from the bus and return 0. 285 * does not disconnect the device from the bus and return 0.
287 * If that fails, it should resort to some sort of cold or bus 286 * If that fails, it should resort to some sort of cold or bus
288 * reset (even if it implies a bus disconnection and device 287 * reset (even if it implies a bus disconnection and device
289 * dissapearance). In that case, -ENODEV should be returned to 288 * disappearance). In that case, -ENODEV should be returned to
290 * indicate the device is gone. 289 * indicate the device is gone.
291 * This operation has to be synchronous, and return only when the 290 * This operation has to be synchronous, and return only when the
292 * reset is complete. In case of having had to resort to bus/cold 291 * reset is complete. In case of having had to resort to bus/cold
@@ -518,8 +517,4 @@ extern ssize_t wimax_msg_len(struct sk_buff *);
518extern int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state); 517extern int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state);
519extern int wimax_reset(struct wimax_dev *); 518extern int wimax_reset(struct wimax_dev *);
520 519
521#else
522/* You might be looking for linux/wimax.h */
523#error This file should not be included from user space.
524#endif /* #ifdef __KERNEL__ */
525#endif /* #ifndef __NET__WIMAX_H__ */ 520#endif /* #ifndef __NET__WIMAX_H__ */
diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h
index 85926231c07a..d86fffd3c03c 100644
--- a/include/net/wpan-phy.h
+++ b/include/net/wpan-phy.h
@@ -28,7 +28,7 @@ struct wpan_phy {
28 struct mutex pib_lock; 28 struct mutex pib_lock;
29 29
30 /* 30 /*
31 * This is a PIB acording to 802.15.4-2006. 31 * This is a PIB according to 802.15.4-2006.
32 * We do not provide timing-related variables, as they 32 * We do not provide timing-related variables, as they
33 * aren't used outside of driver 33 * aren't used outside of driver
34 */ 34 */
diff --git a/include/net/x25.h b/include/net/x25.h
index 1479cb4a41fc..a06119a05129 100644
--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -315,6 +315,8 @@ extern struct list_head x25_route_list;
315extern rwlock_t x25_route_list_lock; 315extern rwlock_t x25_route_list_lock;
316extern struct list_head x25_forward_list; 316extern struct list_head x25_forward_list;
317extern rwlock_t x25_forward_list_lock; 317extern rwlock_t x25_forward_list_lock;
318extern struct list_head x25_neigh_list;
319extern rwlock_t x25_neigh_list_lock;
318 320
319extern int x25_proc_init(void); 321extern int x25_proc_init(void);
320extern void x25_proc_exit(void); 322extern void x25_proc_exit(void);
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 4f53532d4c2f..b203e14d26b7 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -36,6 +36,7 @@
36#define XFRM_PROTO_ROUTING IPPROTO_ROUTING 36#define XFRM_PROTO_ROUTING IPPROTO_ROUTING
37#define XFRM_PROTO_DSTOPTS IPPROTO_DSTOPTS 37#define XFRM_PROTO_DSTOPTS IPPROTO_DSTOPTS
38 38
39#define XFRM_ALIGN4(len) (((len) + 3) & ~3)
39#define XFRM_ALIGN8(len) (((len) + 7) & ~7) 40#define XFRM_ALIGN8(len) (((len) + 7) & ~7)
40#define MODULE_ALIAS_XFRM_MODE(family, encap) \ 41#define MODULE_ALIAS_XFRM_MODE(family, encap) \
41 MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap)) 42 MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap))
@@ -143,6 +144,7 @@ struct xfrm_state {
143 struct xfrm_id id; 144 struct xfrm_id id;
144 struct xfrm_selector sel; 145 struct xfrm_selector sel;
145 struct xfrm_mark mark; 146 struct xfrm_mark mark;
147 u32 tfcpad;
146 148
147 u32 genid; 149 u32 genid;
148 150
@@ -184,9 +186,14 @@ struct xfrm_state {
184 186
185 /* State for replay detection */ 187 /* State for replay detection */
186 struct xfrm_replay_state replay; 188 struct xfrm_replay_state replay;
189 struct xfrm_replay_state_esn *replay_esn;
187 190
188 /* Replay detection state at the time we sent the last notification */ 191 /* Replay detection state at the time we sent the last notification */
189 struct xfrm_replay_state preplay; 192 struct xfrm_replay_state preplay;
193 struct xfrm_replay_state_esn *preplay_esn;
194
195 /* The functions for replay detection. */
196 struct xfrm_replay *repl;
190 197
191 /* internal flag that only holds state for delayed aevent at the 198 /* internal flag that only holds state for delayed aevent at the
192 * moment 199 * moment
@@ -257,6 +264,15 @@ struct km_event {
257 struct net *net; 264 struct net *net;
258}; 265};
259 266
267struct xfrm_replay {
268 void (*advance)(struct xfrm_state *x, __be32 net_seq);
269 int (*check)(struct xfrm_state *x,
270 struct sk_buff *skb,
271 __be32 net_seq);
272 void (*notify)(struct xfrm_state *x, int event);
273 int (*overflow)(struct xfrm_state *x, struct sk_buff *skb);
274};
275
260struct net_device; 276struct net_device;
261struct xfrm_type; 277struct xfrm_type;
262struct xfrm_dst; 278struct xfrm_dst;
@@ -265,25 +281,26 @@ struct xfrm_policy_afinfo {
265 struct dst_ops *dst_ops; 281 struct dst_ops *dst_ops;
266 void (*garbage_collect)(struct net *net); 282 void (*garbage_collect)(struct net *net);
267 struct dst_entry *(*dst_lookup)(struct net *net, int tos, 283 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
268 xfrm_address_t *saddr, 284 const xfrm_address_t *saddr,
269 xfrm_address_t *daddr); 285 const xfrm_address_t *daddr);
270 int (*get_saddr)(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr); 286 int (*get_saddr)(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr);
271 void (*decode_session)(struct sk_buff *skb, 287 void (*decode_session)(struct sk_buff *skb,
272 struct flowi *fl, 288 struct flowi *fl,
273 int reverse); 289 int reverse);
274 int (*get_tos)(struct flowi *fl); 290 int (*get_tos)(const struct flowi *fl);
275 int (*init_path)(struct xfrm_dst *path, 291 int (*init_path)(struct xfrm_dst *path,
276 struct dst_entry *dst, 292 struct dst_entry *dst,
277 int nfheader_len); 293 int nfheader_len);
278 int (*fill_dst)(struct xfrm_dst *xdst, 294 int (*fill_dst)(struct xfrm_dst *xdst,
279 struct net_device *dev, 295 struct net_device *dev,
280 struct flowi *fl); 296 const struct flowi *fl);
297 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
281}; 298};
282 299
283extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); 300extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
284extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo); 301extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
285extern void km_policy_notify(struct xfrm_policy *xp, int dir, struct km_event *c); 302extern void km_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c);
286extern void km_state_notify(struct xfrm_state *x, struct km_event *c); 303extern void km_state_notify(struct xfrm_state *x, const struct km_event *c);
287 304
288struct xfrm_tmpl; 305struct xfrm_tmpl;
289extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); 306extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol);
@@ -298,12 +315,16 @@ struct xfrm_state_afinfo {
298 const struct xfrm_type *type_map[IPPROTO_MAX]; 315 const struct xfrm_type *type_map[IPPROTO_MAX];
299 struct xfrm_mode *mode_map[XFRM_MODE_MAX]; 316 struct xfrm_mode *mode_map[XFRM_MODE_MAX];
300 int (*init_flags)(struct xfrm_state *x); 317 int (*init_flags)(struct xfrm_state *x);
301 void (*init_tempsel)(struct xfrm_selector *sel, struct flowi *fl); 318 void (*init_tempsel)(struct xfrm_selector *sel,
302 void (*init_temprop)(struct xfrm_state *x, struct xfrm_tmpl *tmpl, 319 const struct flowi *fl);
303 xfrm_address_t *daddr, xfrm_address_t *saddr); 320 void (*init_temprop)(struct xfrm_state *x,
321 const struct xfrm_tmpl *tmpl,
322 const xfrm_address_t *daddr,
323 const xfrm_address_t *saddr);
304 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); 324 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
305 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); 325 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
306 int (*output)(struct sk_buff *skb); 326 int (*output)(struct sk_buff *skb);
327 int (*output_finish)(struct sk_buff *skb);
307 int (*extract_input)(struct xfrm_state *x, 328 int (*extract_input)(struct xfrm_state *x,
308 struct sk_buff *skb); 329 struct sk_buff *skb);
309 int (*extract_output)(struct xfrm_state *x, 330 int (*extract_output)(struct xfrm_state *x,
@@ -331,7 +352,8 @@ struct xfrm_type {
331 void (*destructor)(struct xfrm_state *); 352 void (*destructor)(struct xfrm_state *);
332 int (*input)(struct xfrm_state *, struct sk_buff *skb); 353 int (*input)(struct xfrm_state *, struct sk_buff *skb);
333 int (*output)(struct xfrm_state *, struct sk_buff *pskb); 354 int (*output)(struct xfrm_state *, struct sk_buff *pskb);
334 int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); 355 int (*reject)(struct xfrm_state *, struct sk_buff *,
356 const struct flowi *);
335 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); 357 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **);
336 /* Estimate maximal size of result of transformation of a dgram */ 358 /* Estimate maximal size of result of transformation of a dgram */
337 u32 (*get_mtu)(struct xfrm_state *, int size); 359 u32 (*get_mtu)(struct xfrm_state *, int size);
@@ -500,7 +522,7 @@ struct xfrm_policy {
500 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; 522 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
501}; 523};
502 524
503static inline struct net *xp_net(struct xfrm_policy *xp) 525static inline struct net *xp_net(const struct xfrm_policy *xp)
504{ 526{
505 return read_pnet(&xp->xp_net); 527 return read_pnet(&xp->xp_net);
506} 528}
@@ -544,13 +566,17 @@ struct xfrm_migrate {
544struct xfrm_mgr { 566struct xfrm_mgr {
545 struct list_head list; 567 struct list_head list;
546 char *id; 568 char *id;
547 int (*notify)(struct xfrm_state *x, struct km_event *c); 569 int (*notify)(struct xfrm_state *x, const struct km_event *c);
548 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); 570 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir);
549 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir); 571 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir);
550 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); 572 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
551 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c); 573 int (*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c);
552 int (*report)(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); 574 int (*report)(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
553 int (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles, struct xfrm_kmaddress *k); 575 int (*migrate)(const struct xfrm_selector *sel,
576 u8 dir, u8 type,
577 const struct xfrm_migrate *m,
578 int num_bundles,
579 const struct xfrm_kmaddress *k);
554}; 580};
555 581
556extern int xfrm_register_km(struct xfrm_mgr *km); 582extern int xfrm_register_km(struct xfrm_mgr *km);
@@ -569,8 +595,14 @@ struct xfrm_skb_cb {
569 595
570 /* Sequence number for replay protection. */ 596 /* Sequence number for replay protection. */
571 union { 597 union {
572 u64 output; 598 struct {
573 __be32 input; 599 __u32 low;
600 __u32 hi;
601 } output;
602 struct {
603 __be32 low;
604 __be32 hi;
605 } input;
574 } seq; 606 } seq;
575}; 607};
576 608
@@ -674,6 +706,8 @@ extern void xfrm_audit_state_delete(struct xfrm_state *x, int result,
674 u32 auid, u32 ses, u32 secid); 706 u32 auid, u32 ses, u32 secid);
675extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, 707extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
676 struct sk_buff *skb); 708 struct sk_buff *skb);
709extern void xfrm_audit_state_replay(struct xfrm_state *x,
710 struct sk_buff *skb, __be32 net_seq);
677extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); 711extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family);
678extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family, 712extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family,
679 __be32 net_spi, __be32 net_seq); 713 __be32 net_spi, __be32 net_seq);
@@ -706,6 +740,11 @@ static inline void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
706{ 740{
707} 741}
708 742
743static inline void xfrm_audit_state_replay(struct xfrm_state *x,
744 struct sk_buff *skb, __be32 net_seq)
745{
746}
747
709static inline void xfrm_audit_state_notfound_simple(struct sk_buff *skb, 748static inline void xfrm_audit_state_notfound_simple(struct sk_buff *skb,
710 u16 family) 749 u16 family)
711{ 750{
@@ -761,10 +800,11 @@ static inline void xfrm_state_hold(struct xfrm_state *x)
761 atomic_inc(&x->refcnt); 800 atomic_inc(&x->refcnt);
762} 801}
763 802
764static __inline__ int addr_match(void *token1, void *token2, int prefixlen) 803static inline bool addr_match(const void *token1, const void *token2,
804 int prefixlen)
765{ 805{
766 __be32 *a1 = token1; 806 const __be32 *a1 = token1;
767 __be32 *a2 = token2; 807 const __be32 *a2 = token2;
768 int pdw; 808 int pdw;
769 int pbi; 809 int pbi;
770 810
@@ -773,7 +813,7 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen)
773 813
774 if (pdw) 814 if (pdw)
775 if (memcmp(a1, a2, pdw << 2)) 815 if (memcmp(a1, a2, pdw << 2))
776 return 0; 816 return false;
777 817
778 if (pbi) { 818 if (pbi) {
779 __be32 mask; 819 __be32 mask;
@@ -781,29 +821,32 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen)
781 mask = htonl((0xffffffff) << (32 - pbi)); 821 mask = htonl((0xffffffff) << (32 - pbi));
782 822
783 if ((a1[pdw] ^ a2[pdw]) & mask) 823 if ((a1[pdw] ^ a2[pdw]) & mask)
784 return 0; 824 return false;
785 } 825 }
786 826
787 return 1; 827 return true;
788} 828}
789 829
790static __inline__ 830static __inline__
791__be16 xfrm_flowi_sport(struct flowi *fl) 831__be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli)
792{ 832{
793 __be16 port; 833 __be16 port;
794 switch(fl->proto) { 834 switch(fl->flowi_proto) {
795 case IPPROTO_TCP: 835 case IPPROTO_TCP:
796 case IPPROTO_UDP: 836 case IPPROTO_UDP:
797 case IPPROTO_UDPLITE: 837 case IPPROTO_UDPLITE:
798 case IPPROTO_SCTP: 838 case IPPROTO_SCTP:
799 port = fl->fl_ip_sport; 839 port = uli->ports.sport;
800 break; 840 break;
801 case IPPROTO_ICMP: 841 case IPPROTO_ICMP:
802 case IPPROTO_ICMPV6: 842 case IPPROTO_ICMPV6:
803 port = htons(fl->fl_icmp_type); 843 port = htons(uli->icmpt.type);
804 break; 844 break;
805 case IPPROTO_MH: 845 case IPPROTO_MH:
806 port = htons(fl->fl_mh_type); 846 port = htons(uli->mht.type);
847 break;
848 case IPPROTO_GRE:
849 port = htons(ntohl(uli->gre_key) >> 16);
807 break; 850 break;
808 default: 851 default:
809 port = 0; /*XXX*/ 852 port = 0; /*XXX*/
@@ -812,19 +855,22 @@ __be16 xfrm_flowi_sport(struct flowi *fl)
812} 855}
813 856
814static __inline__ 857static __inline__
815__be16 xfrm_flowi_dport(struct flowi *fl) 858__be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli)
816{ 859{
817 __be16 port; 860 __be16 port;
818 switch(fl->proto) { 861 switch(fl->flowi_proto) {
819 case IPPROTO_TCP: 862 case IPPROTO_TCP:
820 case IPPROTO_UDP: 863 case IPPROTO_UDP:
821 case IPPROTO_UDPLITE: 864 case IPPROTO_UDPLITE:
822 case IPPROTO_SCTP: 865 case IPPROTO_SCTP:
823 port = fl->fl_ip_dport; 866 port = uli->ports.dport;
824 break; 867 break;
825 case IPPROTO_ICMP: 868 case IPPROTO_ICMP:
826 case IPPROTO_ICMPV6: 869 case IPPROTO_ICMPV6:
827 port = htons(fl->fl_icmp_code); 870 port = htons(uli->icmpt.code);
871 break;
872 case IPPROTO_GRE:
873 port = htons(ntohl(uli->gre_key) & 0xffff);
828 break; 874 break;
829 default: 875 default:
830 port = 0; /*XXX*/ 876 port = 0; /*XXX*/
@@ -832,7 +878,8 @@ __be16 xfrm_flowi_dport(struct flowi *fl)
832 return port; 878 return port;
833} 879}
834 880
835extern int xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl, 881extern int xfrm_selector_match(const struct xfrm_selector *sel,
882 const struct flowi *fl,
836 unsigned short family); 883 unsigned short family);
837 884
838#ifdef CONFIG_SECURITY_NETWORK_XFRM 885#ifdef CONFIG_SECURITY_NETWORK_XFRM
@@ -911,6 +958,15 @@ struct sec_path {
911 struct xfrm_state *xvec[XFRM_MAX_DEPTH]; 958 struct xfrm_state *xvec[XFRM_MAX_DEPTH];
912}; 959};
913 960
961static inline int secpath_exists(struct sk_buff *skb)
962{
963#ifdef CONFIG_XFRM
964 return skb->sp != NULL;
965#else
966 return 0;
967#endif
968}
969
914static inline struct sec_path * 970static inline struct sec_path *
915secpath_get(struct sec_path *sp) 971secpath_get(struct sec_path *sp)
916{ 972{
@@ -940,7 +996,7 @@ secpath_reset(struct sk_buff *skb)
940} 996}
941 997
942static inline int 998static inline int
943xfrm_addr_any(xfrm_address_t *addr, unsigned short family) 999xfrm_addr_any(const xfrm_address_t *addr, unsigned short family)
944{ 1000{
945 switch (family) { 1001 switch (family) {
946 case AF_INET: 1002 case AF_INET:
@@ -952,21 +1008,21 @@ xfrm_addr_any(xfrm_address_t *addr, unsigned short family)
952} 1008}
953 1009
954static inline int 1010static inline int
955__xfrm4_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x) 1011__xfrm4_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x)
956{ 1012{
957 return (tmpl->saddr.a4 && 1013 return (tmpl->saddr.a4 &&
958 tmpl->saddr.a4 != x->props.saddr.a4); 1014 tmpl->saddr.a4 != x->props.saddr.a4);
959} 1015}
960 1016
961static inline int 1017static inline int
962__xfrm6_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x) 1018__xfrm6_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x)
963{ 1019{
964 return (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) && 1020 return (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) &&
965 ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr)); 1021 ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr));
966} 1022}
967 1023
968static inline int 1024static inline int
969xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short family) 1025xfrm_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x, unsigned short family)
970{ 1026{
971 switch (family) { 1027 switch (family) {
972 case AF_INET: 1028 case AF_INET:
@@ -1119,49 +1175,49 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
1119#endif 1175#endif
1120 1176
1121static __inline__ 1177static __inline__
1122xfrm_address_t *xfrm_flowi_daddr(struct flowi *fl, unsigned short family) 1178xfrm_address_t *xfrm_flowi_daddr(const struct flowi *fl, unsigned short family)
1123{ 1179{
1124 switch (family){ 1180 switch (family){
1125 case AF_INET: 1181 case AF_INET:
1126 return (xfrm_address_t *)&fl->fl4_dst; 1182 return (xfrm_address_t *)&fl->u.ip4.daddr;
1127 case AF_INET6: 1183 case AF_INET6:
1128 return (xfrm_address_t *)&fl->fl6_dst; 1184 return (xfrm_address_t *)&fl->u.ip6.daddr;
1129 } 1185 }
1130 return NULL; 1186 return NULL;
1131} 1187}
1132 1188
1133static __inline__ 1189static __inline__
1134xfrm_address_t *xfrm_flowi_saddr(struct flowi *fl, unsigned short family) 1190xfrm_address_t *xfrm_flowi_saddr(const struct flowi *fl, unsigned short family)
1135{ 1191{
1136 switch (family){ 1192 switch (family){
1137 case AF_INET: 1193 case AF_INET:
1138 return (xfrm_address_t *)&fl->fl4_src; 1194 return (xfrm_address_t *)&fl->u.ip4.saddr;
1139 case AF_INET6: 1195 case AF_INET6:
1140 return (xfrm_address_t *)&fl->fl6_src; 1196 return (xfrm_address_t *)&fl->u.ip6.saddr;
1141 } 1197 }
1142 return NULL; 1198 return NULL;
1143} 1199}
1144 1200
1145static __inline__ 1201static __inline__
1146void xfrm_flowi_addr_get(struct flowi *fl, 1202void xfrm_flowi_addr_get(const struct flowi *fl,
1147 xfrm_address_t *saddr, xfrm_address_t *daddr, 1203 xfrm_address_t *saddr, xfrm_address_t *daddr,
1148 unsigned short family) 1204 unsigned short family)
1149{ 1205{
1150 switch(family) { 1206 switch(family) {
1151 case AF_INET: 1207 case AF_INET:
1152 memcpy(&saddr->a4, &fl->fl4_src, sizeof(saddr->a4)); 1208 memcpy(&saddr->a4, &fl->u.ip4.saddr, sizeof(saddr->a4));
1153 memcpy(&daddr->a4, &fl->fl4_dst, sizeof(daddr->a4)); 1209 memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4));
1154 break; 1210 break;
1155 case AF_INET6: 1211 case AF_INET6:
1156 ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->fl6_src); 1212 ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->u.ip6.saddr);
1157 ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->fl6_dst); 1213 ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->u.ip6.daddr);
1158 break; 1214 break;
1159 } 1215 }
1160} 1216}
1161 1217
1162static __inline__ int 1218static __inline__ int
1163__xfrm4_state_addr_check(struct xfrm_state *x, 1219__xfrm4_state_addr_check(const struct xfrm_state *x,
1164 xfrm_address_t *daddr, xfrm_address_t *saddr) 1220 const xfrm_address_t *daddr, const xfrm_address_t *saddr)
1165{ 1221{
1166 if (daddr->a4 == x->id.daddr.a4 && 1222 if (daddr->a4 == x->id.daddr.a4 &&
1167 (saddr->a4 == x->props.saddr.a4 || !saddr->a4 || !x->props.saddr.a4)) 1223 (saddr->a4 == x->props.saddr.a4 || !saddr->a4 || !x->props.saddr.a4))
@@ -1170,8 +1226,8 @@ __xfrm4_state_addr_check(struct xfrm_state *x,
1170} 1226}
1171 1227
1172static __inline__ int 1228static __inline__ int
1173__xfrm6_state_addr_check(struct xfrm_state *x, 1229__xfrm6_state_addr_check(const struct xfrm_state *x,
1174 xfrm_address_t *daddr, xfrm_address_t *saddr) 1230 const xfrm_address_t *daddr, const xfrm_address_t *saddr)
1175{ 1231{
1176 if (!ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) && 1232 if (!ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) &&
1177 (!ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr)|| 1233 (!ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr)||
@@ -1182,8 +1238,8 @@ __xfrm6_state_addr_check(struct xfrm_state *x,
1182} 1238}
1183 1239
1184static __inline__ int 1240static __inline__ int
1185xfrm_state_addr_check(struct xfrm_state *x, 1241xfrm_state_addr_check(const struct xfrm_state *x,
1186 xfrm_address_t *daddr, xfrm_address_t *saddr, 1242 const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1187 unsigned short family) 1243 unsigned short family)
1188{ 1244{
1189 switch (family) { 1245 switch (family) {
@@ -1196,23 +1252,23 @@ xfrm_state_addr_check(struct xfrm_state *x,
1196} 1252}
1197 1253
1198static __inline__ int 1254static __inline__ int
1199xfrm_state_addr_flow_check(struct xfrm_state *x, struct flowi *fl, 1255xfrm_state_addr_flow_check(const struct xfrm_state *x, const struct flowi *fl,
1200 unsigned short family) 1256 unsigned short family)
1201{ 1257{
1202 switch (family) { 1258 switch (family) {
1203 case AF_INET: 1259 case AF_INET:
1204 return __xfrm4_state_addr_check(x, 1260 return __xfrm4_state_addr_check(x,
1205 (xfrm_address_t *)&fl->fl4_dst, 1261 (const xfrm_address_t *)&fl->u.ip4.daddr,
1206 (xfrm_address_t *)&fl->fl4_src); 1262 (const xfrm_address_t *)&fl->u.ip4.saddr);
1207 case AF_INET6: 1263 case AF_INET6:
1208 return __xfrm6_state_addr_check(x, 1264 return __xfrm6_state_addr_check(x,
1209 (xfrm_address_t *)&fl->fl6_dst, 1265 (const xfrm_address_t *)&fl->u.ip6.daddr,
1210 (xfrm_address_t *)&fl->fl6_src); 1266 (const xfrm_address_t *)&fl->u.ip6.saddr);
1211 } 1267 }
1212 return 0; 1268 return 0;
1213} 1269}
1214 1270
1215static inline int xfrm_state_kern(struct xfrm_state *x) 1271static inline int xfrm_state_kern(const struct xfrm_state *x)
1216{ 1272{
1217 return atomic_read(&x->tunnel_users); 1273 return atomic_read(&x->tunnel_users);
1218} 1274}
@@ -1264,7 +1320,7 @@ struct xfrm_tunnel {
1264 int (*handler)(struct sk_buff *skb); 1320 int (*handler)(struct sk_buff *skb);
1265 int (*err_handler)(struct sk_buff *skb, u32 info); 1321 int (*err_handler)(struct sk_buff *skb, u32 info);
1266 1322
1267 struct xfrm_tunnel *next; 1323 struct xfrm_tunnel __rcu *next;
1268 int priority; 1324 int priority;
1269}; 1325};
1270 1326
@@ -1272,7 +1328,7 @@ struct xfrm6_tunnel {
1272 int (*handler)(struct sk_buff *skb); 1328 int (*handler)(struct sk_buff *skb);
1273 int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, 1329 int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt,
1274 u8 type, u8 code, int offset, __be32 info); 1330 u8 type, u8 code, int offset, __be32 info);
1275 struct xfrm6_tunnel *next; 1331 struct xfrm6_tunnel __rcu *next;
1276 int priority; 1332 int priority;
1277}; 1333};
1278 1334
@@ -1316,8 +1372,10 @@ extern int xfrm_state_walk(struct net *net, struct xfrm_state_walk *walk,
1316 int (*func)(struct xfrm_state *, int, void*), void *); 1372 int (*func)(struct xfrm_state *, int, void*), void *);
1317extern void xfrm_state_walk_done(struct xfrm_state_walk *walk); 1373extern void xfrm_state_walk_done(struct xfrm_state_walk *walk);
1318extern struct xfrm_state *xfrm_state_alloc(struct net *net); 1374extern struct xfrm_state *xfrm_state_alloc(struct net *net);
1319extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 1375extern struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr,
1320 struct flowi *fl, struct xfrm_tmpl *tmpl, 1376 const xfrm_address_t *saddr,
1377 const struct flowi *fl,
1378 struct xfrm_tmpl *tmpl,
1321 struct xfrm_policy *pol, int *err, 1379 struct xfrm_policy *pol, int *err,
1322 unsigned short family); 1380 unsigned short family);
1323extern struct xfrm_state *xfrm_stateonly_find(struct net *net, u32 mark, 1381extern struct xfrm_state *xfrm_stateonly_find(struct net *net, u32 mark,
@@ -1330,11 +1388,11 @@ extern void xfrm_state_insert(struct xfrm_state *x);
1330extern int xfrm_state_add(struct xfrm_state *x); 1388extern int xfrm_state_add(struct xfrm_state *x);
1331extern int xfrm_state_update(struct xfrm_state *x); 1389extern int xfrm_state_update(struct xfrm_state *x);
1332extern struct xfrm_state *xfrm_state_lookup(struct net *net, u32 mark, 1390extern struct xfrm_state *xfrm_state_lookup(struct net *net, u32 mark,
1333 xfrm_address_t *daddr, __be32 spi, 1391 const xfrm_address_t *daddr, __be32 spi,
1334 u8 proto, unsigned short family); 1392 u8 proto, unsigned short family);
1335extern struct xfrm_state *xfrm_state_lookup_byaddr(struct net *net, u32 mark, 1393extern struct xfrm_state *xfrm_state_lookup_byaddr(struct net *net, u32 mark,
1336 xfrm_address_t *daddr, 1394 const xfrm_address_t *daddr,
1337 xfrm_address_t *saddr, 1395 const xfrm_address_t *saddr,
1338 u8 proto, 1396 u8 proto,
1339 unsigned short family); 1397 unsigned short family);
1340#ifdef CONFIG_XFRM_SUB_POLICY 1398#ifdef CONFIG_XFRM_SUB_POLICY
@@ -1379,11 +1437,10 @@ extern int xfrm_state_delete(struct xfrm_state *x);
1379extern int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info); 1437extern int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info);
1380extern void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si); 1438extern void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si);
1381extern void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si); 1439extern void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si);
1382extern int xfrm_replay_check(struct xfrm_state *x, 1440extern u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq);
1383 struct sk_buff *skb, __be32 seq); 1441extern int xfrm_init_replay(struct xfrm_state *x);
1384extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
1385extern void xfrm_replay_notify(struct xfrm_state *x, int event);
1386extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); 1442extern int xfrm_state_mtu(struct xfrm_state *x, int mtu);
1443extern int __xfrm_init_state(struct xfrm_state *x, bool init_replay);
1387extern int xfrm_init_state(struct xfrm_state *x); 1444extern int xfrm_init_state(struct xfrm_state *x);
1388extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb); 1445extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb);
1389extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, 1446extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi,
@@ -1407,6 +1464,7 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi)
1407extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); 1464extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1408extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); 1465extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1409extern int xfrm4_output(struct sk_buff *skb); 1466extern int xfrm4_output(struct sk_buff *skb);
1467extern int xfrm4_output_finish(struct sk_buff *skb);
1410extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); 1468extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family);
1411extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); 1469extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family);
1412extern int xfrm6_extract_header(struct sk_buff *skb); 1470extern int xfrm6_extract_header(struct sk_buff *skb);
@@ -1419,11 +1477,11 @@ extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
1419extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family); 1477extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family);
1420extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family); 1478extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family);
1421extern __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr); 1479extern __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr);
1422extern void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr); 1480extern __be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr);
1423extern __be32 xfrm6_tunnel_spi_lookup(struct net *net, xfrm_address_t *saddr);
1424extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); 1481extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1425extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); 1482extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1426extern int xfrm6_output(struct sk_buff *skb); 1483extern int xfrm6_output(struct sk_buff *skb);
1484extern int xfrm6_output_finish(struct sk_buff *skb);
1427extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, 1485extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
1428 u8 **prevhdr); 1486 u8 **prevhdr);
1429 1487
@@ -1462,21 +1520,19 @@ u32 xfrm_get_acqseq(void);
1462extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); 1520extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi);
1463struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark, 1521struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark,
1464 u8 mode, u32 reqid, u8 proto, 1522 u8 mode, u32 reqid, u8 proto,
1465 xfrm_address_t *daddr, 1523 const xfrm_address_t *daddr,
1466 xfrm_address_t *saddr, int create, 1524 const xfrm_address_t *saddr, int create,
1467 unsigned short family); 1525 unsigned short family);
1468extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); 1526extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
1469extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
1470 struct flowi *fl, int family, int strict);
1471 1527
1472#ifdef CONFIG_XFRM_MIGRATE 1528#ifdef CONFIG_XFRM_MIGRATE
1473extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1529extern int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
1474 struct xfrm_migrate *m, int num_bundles, 1530 const struct xfrm_migrate *m, int num_bundles,
1475 struct xfrm_kmaddress *k); 1531 const struct xfrm_kmaddress *k);
1476extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m); 1532extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m);
1477extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x, 1533extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
1478 struct xfrm_migrate *m); 1534 struct xfrm_migrate *m);
1479extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1535extern int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
1480 struct xfrm_migrate *m, int num_bundles, 1536 struct xfrm_migrate *m, int num_bundles,
1481 struct xfrm_kmaddress *k); 1537 struct xfrm_kmaddress *k);
1482#endif 1538#endif
@@ -1496,10 +1552,10 @@ extern struct xfrm_algo_desc *xfrm_ealg_get_byidx(unsigned int idx);
1496extern struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id); 1552extern struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id);
1497extern struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id); 1553extern struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id);
1498extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id); 1554extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id);
1499extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe); 1555extern struct xfrm_algo_desc *xfrm_aalg_get_byname(const char *name, int probe);
1500extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe); 1556extern struct xfrm_algo_desc *xfrm_ealg_get_byname(const char *name, int probe);
1501extern struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe); 1557extern struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe);
1502extern struct xfrm_algo_desc *xfrm_aead_get_byname(char *name, int icv_len, 1558extern struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len,
1503 int probe); 1559 int probe);
1504 1560
1505struct hash_desc; 1561struct hash_desc;
@@ -1507,7 +1563,8 @@ struct scatterlist;
1507typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *, 1563typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *,
1508 unsigned int); 1564 unsigned int);
1509 1565
1510static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b, 1566static inline int xfrm_addr_cmp(const xfrm_address_t *a,
1567 const xfrm_address_t *b,
1511 int family) 1568 int family)
1512{ 1569{
1513 switch (family) { 1570 switch (family) {
@@ -1515,8 +1572,8 @@ static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b,
1515 case AF_INET: 1572 case AF_INET:
1516 return (__force u32)a->a4 - (__force u32)b->a4; 1573 return (__force u32)a->a4 - (__force u32)b->a4;
1517 case AF_INET6: 1574 case AF_INET6:
1518 return ipv6_addr_cmp((struct in6_addr *)a, 1575 return ipv6_addr_cmp((const struct in6_addr *)a,
1519 (struct in6_addr *)b); 1576 (const struct in6_addr *)b);
1520 } 1577 }
1521} 1578}
1522 1579
@@ -1540,17 +1597,44 @@ static inline int xfrm_aevent_is_on(struct net *net)
1540} 1597}
1541#endif 1598#endif
1542 1599
1543static inline int xfrm_alg_len(struct xfrm_algo *alg) 1600static inline int xfrm_alg_len(const struct xfrm_algo *alg)
1544{ 1601{
1545 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); 1602 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
1546} 1603}
1547 1604
1548static inline int xfrm_alg_auth_len(struct xfrm_algo_auth *alg) 1605static inline int xfrm_alg_auth_len(const struct xfrm_algo_auth *alg)
1549{ 1606{
1550 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); 1607 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
1551} 1608}
1552 1609
1610static inline int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay_esn)
1611{
1612 return sizeof(*replay_esn) + replay_esn->bmp_len * sizeof(__u32);
1613}
1614
1553#ifdef CONFIG_XFRM_MIGRATE 1615#ifdef CONFIG_XFRM_MIGRATE
1616static inline int xfrm_replay_clone(struct xfrm_state *x,
1617 struct xfrm_state *orig)
1618{
1619 x->replay_esn = kzalloc(xfrm_replay_state_esn_len(orig->replay_esn),
1620 GFP_KERNEL);
1621 if (!x->replay_esn)
1622 return -ENOMEM;
1623
1624 x->replay_esn->bmp_len = orig->replay_esn->bmp_len;
1625 x->replay_esn->replay_window = orig->replay_esn->replay_window;
1626
1627 x->preplay_esn = kmemdup(x->replay_esn,
1628 xfrm_replay_state_esn_len(x->replay_esn),
1629 GFP_KERNEL);
1630 if (!x->preplay_esn) {
1631 kfree(x->replay_esn);
1632 return -ENOMEM;
1633 }
1634
1635 return 0;
1636}
1637
1554static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) 1638static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
1555{ 1639{
1556 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL); 1640 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);
@@ -1593,7 +1677,7 @@ static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m)
1593 return m->v & m->m; 1677 return m->v & m->m;
1594} 1678}
1595 1679
1596static inline int xfrm_mark_put(struct sk_buff *skb, struct xfrm_mark *m) 1680static inline int xfrm_mark_put(struct sk_buff *skb, const struct xfrm_mark *m)
1597{ 1681{
1598 if (m->m | m->v) 1682 if (m->m | m->v)
1599 NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); 1683 NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m);
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
deleted file mode 100644
index 68d8bde7e8d6..000000000000
--- a/include/pcmcia/cs.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * cs.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * The initial developer of the original code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
11 *
12 * (C) 1999 David A. Hinds
13 */
14
15#ifndef _LINUX_CS_H
16#define _LINUX_CS_H
17
18#ifdef __KERNEL__
19#include <linux/interrupt.h>
20#endif
21
22/* ModifyConfiguration */
23typedef struct modconf_t {
24 u_int Attributes;
25 u_int Vcc, Vpp1, Vpp2;
26} modconf_t;
27
28/* Attributes for ModifyConfiguration */
29#define CONF_IRQ_CHANGE_VALID 0x0100
30#define CONF_VCC_CHANGE_VALID 0x0200
31#define CONF_VPP1_CHANGE_VALID 0x0400
32#define CONF_VPP2_CHANGE_VALID 0x0800
33#define CONF_IO_CHANGE_WIDTH 0x1000
34
35/* For RequestConfiguration */
36typedef struct config_req_t {
37 u_int Attributes;
38 u_int Vpp; /* both Vpp1 and Vpp2 */
39 u_int IntType;
40 u_int ConfigBase;
41 u_char Status, Pin, Copy, ExtStatus;
42 u_char ConfigIndex;
43 u_int Present;
44} config_req_t;
45
46/* Attributes for RequestConfiguration */
47#define CONF_ENABLE_IRQ 0x01
48#define CONF_ENABLE_DMA 0x02
49#define CONF_ENABLE_SPKR 0x04
50#define CONF_ENABLE_PULSE_IRQ 0x08
51#define CONF_VALID_CLIENT 0x100
52
53/* IntType field */
54#define INT_MEMORY 0x01
55#define INT_MEMORY_AND_IO 0x02
56#define INT_CARDBUS 0x04
57#define INT_ZOOMED_VIDEO 0x08
58
59/* Configuration registers present */
60#define PRESENT_OPTION 0x001
61#define PRESENT_STATUS 0x002
62#define PRESENT_PIN_REPLACE 0x004
63#define PRESENT_COPY 0x008
64#define PRESENT_EXT_STATUS 0x010
65#define PRESENT_IOBASE_0 0x020
66#define PRESENT_IOBASE_1 0x040
67#define PRESENT_IOBASE_2 0x080
68#define PRESENT_IOBASE_3 0x100
69#define PRESENT_IOSIZE 0x200
70
71/* For RequestWindow */
72typedef struct win_req_t {
73 u_int Attributes;
74 u_long Base;
75 u_int Size;
76 u_int AccessSpeed;
77} win_req_t;
78
79/* Attributes for RequestWindow */
80#define WIN_MEMORY_TYPE_CM 0x00 /* default */
81#define WIN_MEMORY_TYPE_AM 0x20 /* MAP_ATTRIB */
82#define WIN_DATA_WIDTH_8 0x00 /* default */
83#define WIN_DATA_WIDTH_16 0x02 /* MAP_16BIT */
84#define WIN_ENABLE 0x01 /* MAP_ACTIVE */
85#define WIN_USE_WAIT 0x40 /* MAP_USE_WAIT */
86
87#define WIN_FLAGS_MAP 0x63 /* MAP_ATTRIB | MAP_16BIT | MAP_ACTIVE |
88 MAP_USE_WAIT */
89#define WIN_FLAGS_REQ 0x1c /* mapping to socket->win[i]:
90 0x04 -> 0
91 0x08 -> 1
92 0x0c -> 2
93 0x10 -> 3 */
94
95#endif /* _LINUX_CS_H */
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 70c58ed2278c..7b82080eb02c 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -24,9 +24,11 @@
24 24
25#ifdef __KERNEL__ 25#ifdef __KERNEL__
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/interrupt.h>
27#include <pcmcia/ss.h> 28#include <pcmcia/ss.h>
28#include <asm/atomic.h> 29#include <asm/atomic.h>
29 30
31
30/* 32/*
31 * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus 33 * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus
32 * a.k.a. PCI drivers 34 * a.k.a. PCI drivers
@@ -36,8 +38,6 @@ struct pcmcia_device;
36struct config_t; 38struct config_t;
37struct net_device; 39struct net_device;
38 40
39typedef struct resource *window_handle_t;
40
41/* dynamic device IDs for PCMCIA device drivers. See 41/* dynamic device IDs for PCMCIA device drivers. See
42 * Documentation/pcmcia/driver.txt for details. 42 * Documentation/pcmcia/driver.txt for details.
43*/ 43*/
@@ -47,6 +47,8 @@ struct pcmcia_dynids {
47}; 47};
48 48
49struct pcmcia_driver { 49struct pcmcia_driver {
50 const char *name;
51
50 int (*probe) (struct pcmcia_device *dev); 52 int (*probe) (struct pcmcia_device *dev);
51 void (*remove) (struct pcmcia_device *dev); 53 void (*remove) (struct pcmcia_device *dev);
52 54
@@ -54,7 +56,7 @@ struct pcmcia_driver {
54 int (*resume) (struct pcmcia_device *dev); 56 int (*resume) (struct pcmcia_device *dev);
55 57
56 struct module *owner; 58 struct module *owner;
57 struct pcmcia_device_id *id_table; 59 const struct pcmcia_device_id *id_table;
58 struct device_driver drv; 60 struct device_driver drv;
59 struct pcmcia_dynids dynids; 61 struct pcmcia_dynids dynids;
60}; 62};
@@ -90,15 +92,17 @@ struct pcmcia_device {
90 92
91 struct list_head socket_device_list; 93 struct list_head socket_device_list;
92 94
93 /* deprecated, will be cleaned up soon */
94 config_req_t conf;
95 window_handle_t win;
96
97 /* device setup */ 95 /* device setup */
98 unsigned int irq; 96 unsigned int irq;
99 struct resource *resource[PCMCIA_NUM_RESOURCES]; 97 struct resource *resource[PCMCIA_NUM_RESOURCES];
98 resource_size_t card_addr; /* for the 1st IOMEM resource */
99 unsigned int vpp;
100 100
101 unsigned int io_lines; /* number of I/O lines */ 101 unsigned int config_flags; /* CONF_ENABLE_ flags below */
102 unsigned int config_base;
103 unsigned int config_index;
104 unsigned int config_regs; /* PRESENT_ flags below */
105 unsigned int io_lines; /* number of I/O lines */
102 106
103 /* Is the device suspended? */ 107 /* Is the device suspended? */
104 u16 suspended:1; 108 u16 suspended:1;
@@ -174,9 +178,6 @@ int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
174/* loop CIS entries for valid configuration */ 178/* loop CIS entries for valid configuration */
175int pcmcia_loop_config(struct pcmcia_device *p_dev, 179int pcmcia_loop_config(struct pcmcia_device *p_dev,
176 int (*conf_check) (struct pcmcia_device *p_dev, 180 int (*conf_check) (struct pcmcia_device *p_dev,
177 cistpl_cftable_entry_t *cf,
178 cistpl_cftable_entry_t *dflt,
179 unsigned int vcc,
180 void *priv_data), 181 void *priv_data),
181 void *priv_data); 182 void *priv_data);
182 183
@@ -206,16 +207,17 @@ pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
206int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev, 207int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
207 irq_handler_t handler); 208 irq_handler_t handler);
208 209
209int pcmcia_request_configuration(struct pcmcia_device *p_dev, 210int pcmcia_enable_device(struct pcmcia_device *p_dev);
210 config_req_t *req);
211 211
212int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, 212int pcmcia_request_window(struct pcmcia_device *p_dev, struct resource *res,
213 window_handle_t *wh); 213 unsigned int speed);
214int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t win); 214int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res);
215int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t win, 215int pcmcia_map_mem_page(struct pcmcia_device *p_dev, struct resource *res,
216 unsigned int offset); 216 unsigned int offset);
217 217
218int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 218int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp);
219int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev);
220
219void pcmcia_disable_device(struct pcmcia_device *p_dev); 221void pcmcia_disable_device(struct pcmcia_device *p_dev);
220 222
221/* IO ports */ 223/* IO ports */
@@ -224,15 +226,49 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev);
224#define IO_DATA_PATH_WIDTH_16 0x08 226#define IO_DATA_PATH_WIDTH_16 0x08
225#define IO_DATA_PATH_WIDTH_AUTO 0x10 227#define IO_DATA_PATH_WIDTH_AUTO 0x10
226 228
227/* convert flag found in cfgtable to data path width parameter */ 229/* IO memory */
228static inline int pcmcia_io_cfg_data_width(unsigned int flags) 230#define WIN_MEMORY_TYPE_CM 0x00 /* default */
229{ 231#define WIN_MEMORY_TYPE_AM 0x20 /* MAP_ATTRIB */
230 if (!(flags & CISTPL_IO_8BIT)) 232#define WIN_DATA_WIDTH_8 0x00 /* default */
231 return IO_DATA_PATH_WIDTH_16; 233#define WIN_DATA_WIDTH_16 0x02 /* MAP_16BIT */
232 if (!(flags & CISTPL_IO_16BIT)) 234#define WIN_ENABLE 0x01 /* MAP_ACTIVE */
233 return IO_DATA_PATH_WIDTH_8; 235#define WIN_USE_WAIT 0x40 /* MAP_USE_WAIT */
234 return IO_DATA_PATH_WIDTH_AUTO; 236
235} 237#define WIN_FLAGS_MAP 0x63 /* MAP_ATTRIB | MAP_16BIT | MAP_ACTIVE |
238 MAP_USE_WAIT */
239#define WIN_FLAGS_REQ 0x1c /* mapping to socket->win[i]:
240 0x04 -> 0
241 0x08 -> 1
242 0x0c -> 2
243 0x10 -> 3 */
244
245/* config_reg{ister}s present for this PCMCIA device */
246#define PRESENT_OPTION 0x001
247#define PRESENT_STATUS 0x002
248#define PRESENT_PIN_REPLACE 0x004
249#define PRESENT_COPY 0x008
250#define PRESENT_EXT_STATUS 0x010
251#define PRESENT_IOBASE_0 0x020
252#define PRESENT_IOBASE_1 0x040
253#define PRESENT_IOBASE_2 0x080
254#define PRESENT_IOBASE_3 0x100
255#define PRESENT_IOSIZE 0x200
256
257/* flags to be passed to pcmcia_enable_device() */
258#define CONF_ENABLE_IRQ 0x0001
259#define CONF_ENABLE_SPKR 0x0002
260#define CONF_ENABLE_PULSE_IRQ 0x0004
261#define CONF_ENABLE_ESR 0x0008
262#define CONF_ENABLE_IOCARD 0x0010 /* auto-enabled if IO resources or IRQ
263 * (CONF_ENABLE_IRQ) in use */
264#define CONF_ENABLE_ZVCARD 0x0020
265
266/* flags used by pcmcia_loop_config() autoconfiguration */
267#define CONF_AUTO_CHECK_VCC 0x0100 /* check for matching Vcc? */
268#define CONF_AUTO_SET_VPP 0x0200 /* set Vpp? */
269#define CONF_AUTO_AUDIO 0x0400 /* enable audio line? */
270#define CONF_AUTO_SET_IO 0x0800 /* set ->resource[0,1] */
271#define CONF_AUTO_SET_IOMEM 0x1000 /* set ->resource[2] */
236 272
237#endif /* __KERNEL__ */ 273#endif /* __KERNEL__ */
238 274
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 626b63c33d9e..731cde010f42 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -19,7 +19,6 @@
19#include <linux/sched.h> /* task_struct, completion */ 19#include <linux/sched.h> /* task_struct, completion */
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21 21
22#include <pcmcia/cs.h>
23#ifdef CONFIG_CARDBUS 22#ifdef CONFIG_CARDBUS
24#include <linux/pci.h> 23#include <linux/pci.h>
25#endif 24#endif
diff --git a/include/rdma/Kbuild b/include/rdma/Kbuild
index e7c043216558..ea56f76c0c22 100644
--- a/include/rdma/Kbuild
+++ b/include/rdma/Kbuild
@@ -1 +1,6 @@
1header-y += ib_user_cm.h
1header-y += ib_user_mad.h 2header-y += ib_user_mad.h
3header-y += ib_user_sa.h
4header-y += ib_user_verbs.h
5header-y += rdma_netlink.h
6header-y += rdma_user_cm.h
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index fa0d52b8e622..ae8c68f30f1b 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -39,7 +39,9 @@
39#include <linux/if_arp.h> 39#include <linux/if_arp.h>
40#include <linux/netdevice.h> 40#include <linux/netdevice.h>
41#include <linux/socket.h> 41#include <linux/socket.h>
42#include <linux/if_vlan.h>
42#include <rdma/ib_verbs.h> 43#include <rdma/ib_verbs.h>
44#include <rdma/ib_pack.h>
43 45
44struct rdma_addr_client { 46struct rdma_addr_client {
45 atomic_t refcount; 47 atomic_t refcount;
@@ -63,6 +65,7 @@ struct rdma_dev_addr {
63 unsigned char broadcast[MAX_ADDR_LEN]; 65 unsigned char broadcast[MAX_ADDR_LEN];
64 unsigned short dev_type; 66 unsigned short dev_type;
65 int bound_dev_if; 67 int bound_dev_if;
68 enum rdma_transport_type transport;
66}; 69};
67 70
68/** 71/**
@@ -127,9 +130,51 @@ static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr)
127 return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0; 130 return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0;
128} 131}
129 132
133static inline void iboe_mac_vlan_to_ll(union ib_gid *gid, u8 *mac, u16 vid)
134{
135 memset(gid->raw, 0, 16);
136 *((__be32 *) gid->raw) = cpu_to_be32(0xfe800000);
137 if (vid < 0x1000) {
138 gid->raw[12] = vid & 0xff;
139 gid->raw[11] = vid >> 8;
140 } else {
141 gid->raw[12] = 0xfe;
142 gid->raw[11] = 0xff;
143 }
144 memcpy(gid->raw + 13, mac + 3, 3);
145 memcpy(gid->raw + 8, mac, 3);
146 gid->raw[8] ^= 2;
147}
148
149static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev)
150{
151 return dev->priv_flags & IFF_802_1Q_VLAN ?
152 vlan_dev_vlan_id(dev) : 0xffff;
153}
154
155static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
156 union ib_gid *gid)
157{
158 struct net_device *dev;
159 u16 vid = 0xffff;
160
161 dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
162 if (dev) {
163 vid = rdma_vlan_dev_vlan_id(dev);
164 dev_put(dev);
165 }
166
167 iboe_mac_vlan_to_ll(gid, dev_addr->src_dev_addr, vid);
168}
169
130static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) 170static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
131{ 171{
132 memcpy(gid, dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr), sizeof *gid); 172 if (dev_addr->transport == RDMA_TRANSPORT_IB &&
173 dev_addr->dev_type != ARPHRD_INFINIBAND)
174 iboe_addr_get_sgid(dev_addr, gid);
175 else
176 memcpy(gid, dev_addr->src_dev_addr +
177 rdma_addr_gid_offset(dev_addr), sizeof *gid);
133} 178}
134 179
135static inline void rdma_addr_set_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) 180static inline void rdma_addr_set_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
@@ -147,4 +192,92 @@ static inline void rdma_addr_set_dgid(struct rdma_dev_addr *dev_addr, union ib_g
147 memcpy(dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid); 192 memcpy(dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid);
148} 193}
149 194
195static inline enum ib_mtu iboe_get_mtu(int mtu)
196{
197 /*
198 * reduce IB headers from effective IBoE MTU. 28 stands for
199 * atomic header which is the biggest possible header after BTH
200 */
201 mtu = mtu - IB_GRH_BYTES - IB_BTH_BYTES - 28;
202
203 if (mtu >= ib_mtu_enum_to_int(IB_MTU_4096))
204 return IB_MTU_4096;
205 else if (mtu >= ib_mtu_enum_to_int(IB_MTU_2048))
206 return IB_MTU_2048;
207 else if (mtu >= ib_mtu_enum_to_int(IB_MTU_1024))
208 return IB_MTU_1024;
209 else if (mtu >= ib_mtu_enum_to_int(IB_MTU_512))
210 return IB_MTU_512;
211 else if (mtu >= ib_mtu_enum_to_int(IB_MTU_256))
212 return IB_MTU_256;
213 else
214 return 0;
215}
216
217static inline int iboe_get_rate(struct net_device *dev)
218{
219 struct ethtool_cmd cmd;
220 u32 speed;
221
222 if (dev_ethtool_get_settings(dev, &cmd))
223 return IB_RATE_PORT_CURRENT;
224
225 speed = ethtool_cmd_speed(&cmd);
226 if (speed >= 40000)
227 return IB_RATE_40_GBPS;
228 else if (speed >= 30000)
229 return IB_RATE_30_GBPS;
230 else if (speed >= 20000)
231 return IB_RATE_20_GBPS;
232 else if (speed >= 10000)
233 return IB_RATE_10_GBPS;
234 else
235 return IB_RATE_PORT_CURRENT;
236}
237
238static inline int rdma_link_local_addr(struct in6_addr *addr)
239{
240 if (addr->s6_addr32[0] == htonl(0xfe800000) &&
241 addr->s6_addr32[1] == 0)
242 return 1;
243
244 return 0;
245}
246
247static inline void rdma_get_ll_mac(struct in6_addr *addr, u8 *mac)
248{
249 memcpy(mac, &addr->s6_addr[8], 3);
250 memcpy(mac + 3, &addr->s6_addr[13], 3);
251 mac[0] ^= 2;
252}
253
254static inline int rdma_is_multicast_addr(struct in6_addr *addr)
255{
256 return addr->s6_addr[0] == 0xff;
257}
258
259static inline void rdma_get_mcast_mac(struct in6_addr *addr, u8 *mac)
260{
261 int i;
262
263 mac[0] = 0x33;
264 mac[1] = 0x33;
265 for (i = 2; i < 6; ++i)
266 mac[i] = addr->s6_addr[i + 10];
267}
268
269static inline u16 rdma_get_vlan_id(union ib_gid *dgid)
270{
271 u16 vid;
272
273 vid = dgid->raw[11] << 8 | dgid->raw[12];
274 return vid < 0x1000 ? vid : 0xffff;
275}
276
277static inline struct net_device *rdma_vlan_dev_real_dev(const struct net_device *dev)
278{
279 return dev->priv_flags & IFF_802_1Q_VLAN ?
280 vlan_dev_real_dev(dev) : 0;
281}
282
150#endif /* IB_ADDR_H */ 283#endif /* IB_ADDR_H */
diff --git a/include/rdma/ib_pack.h b/include/rdma/ib_pack.h
index cbb50f4da3dd..b37fe3b10a9d 100644
--- a/include/rdma/ib_pack.h
+++ b/include/rdma/ib_pack.h
@@ -37,6 +37,8 @@
37 37
38enum { 38enum {
39 IB_LRH_BYTES = 8, 39 IB_LRH_BYTES = 8,
40 IB_ETH_BYTES = 14,
41 IB_VLAN_BYTES = 4,
40 IB_GRH_BYTES = 40, 42 IB_GRH_BYTES = 40,
41 IB_BTH_BYTES = 12, 43 IB_BTH_BYTES = 12,
42 IB_DETH_BYTES = 8 44 IB_DETH_BYTES = 8
@@ -210,14 +212,32 @@ struct ib_unpacked_deth {
210 __be32 source_qpn; 212 __be32 source_qpn;
211}; 213};
212 214
215struct ib_unpacked_eth {
216 u8 dmac_h[4];
217 u8 dmac_l[2];
218 u8 smac_h[2];
219 u8 smac_l[4];
220 __be16 type;
221};
222
223struct ib_unpacked_vlan {
224 __be16 tag;
225 __be16 type;
226};
227
213struct ib_ud_header { 228struct ib_ud_header {
229 int lrh_present;
214 struct ib_unpacked_lrh lrh; 230 struct ib_unpacked_lrh lrh;
215 int grh_present; 231 int eth_present;
216 struct ib_unpacked_grh grh; 232 struct ib_unpacked_eth eth;
217 struct ib_unpacked_bth bth; 233 int vlan_present;
234 struct ib_unpacked_vlan vlan;
235 int grh_present;
236 struct ib_unpacked_grh grh;
237 struct ib_unpacked_bth bth;
218 struct ib_unpacked_deth deth; 238 struct ib_unpacked_deth deth;
219 int immediate_present; 239 int immediate_present;
220 __be32 immediate_data; 240 __be32 immediate_data;
221}; 241};
222 242
223void ib_pack(const struct ib_field *desc, 243void ib_pack(const struct ib_field *desc,
@@ -230,9 +250,12 @@ void ib_unpack(const struct ib_field *desc,
230 void *buf, 250 void *buf,
231 void *structure); 251 void *structure);
232 252
233void ib_ud_header_init(int payload_bytes, 253void ib_ud_header_init(int payload_bytes,
234 int grh_present, 254 int lrh_present,
235 int immediate_present, 255 int eth_present,
256 int vlan_present,
257 int grh_present,
258 int immediate_present,
236 struct ib_ud_header *header); 259 struct ib_ud_header *header);
237 260
238int ib_ud_header_pack(struct ib_ud_header *header, 261int ib_ud_header_pack(struct ib_ud_header *header,
diff --git a/include/rdma/ib_user_cm.h b/include/rdma/ib_user_cm.h
index bd3d380781e0..f79014aa28f9 100644
--- a/include/rdma/ib_user_cm.h
+++ b/include/rdma/ib_user_cm.h
@@ -34,6 +34,7 @@
34#ifndef IB_USER_CM_H 34#ifndef IB_USER_CM_H
35#define IB_USER_CM_H 35#define IB_USER_CM_H
36 36
37#include <linux/types.h>
37#include <rdma/ib_user_sa.h> 38#include <rdma/ib_user_sa.h>
38 39
39#define IB_USER_CM_ABI_VERSION 5 40#define IB_USER_CM_ABI_VERSION 5
diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h
index a17f77106149..fe5b05177a2c 100644
--- a/include/rdma/ib_user_verbs.h
+++ b/include/rdma/ib_user_verbs.h
@@ -205,7 +205,8 @@ struct ib_uverbs_query_port_resp {
205 __u8 active_width; 205 __u8 active_width;
206 __u8 active_speed; 206 __u8 active_speed;
207 __u8 phys_state; 207 __u8 phys_state;
208 __u8 reserved[3]; 208 __u8 link_layer;
209 __u8 reserved[2];
209}; 210};
210 211
211struct ib_uverbs_alloc_pd { 212struct ib_uverbs_alloc_pd {
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 857b3b9cf120..55cd0a0bc977 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -47,10 +47,13 @@
47#include <linux/list.h> 47#include <linux/list.h>
48#include <linux/rwsem.h> 48#include <linux/rwsem.h>
49#include <linux/scatterlist.h> 49#include <linux/scatterlist.h>
50#include <linux/workqueue.h>
50 51
51#include <asm/atomic.h> 52#include <asm/atomic.h>
52#include <asm/uaccess.h> 53#include <asm/uaccess.h>
53 54
55extern struct workqueue_struct *ib_wq;
56
54union ib_gid { 57union ib_gid {
55 u8 raw[16]; 58 u8 raw[16];
56 struct { 59 struct {
@@ -75,6 +78,12 @@ enum rdma_transport_type {
75enum rdma_transport_type 78enum rdma_transport_type
76rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__; 79rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__;
77 80
81enum rdma_link_layer {
82 IB_LINK_LAYER_UNSPECIFIED,
83 IB_LINK_LAYER_INFINIBAND,
84 IB_LINK_LAYER_ETHERNET,
85};
86
78enum ib_device_cap_flags { 87enum ib_device_cap_flags {
79 IB_DEVICE_RESIZE_MAX_WR = 1, 88 IB_DEVICE_RESIZE_MAX_WR = 1,
80 IB_DEVICE_BAD_PKEY_CNTR = (1<<1), 89 IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
@@ -1010,6 +1019,8 @@ struct ib_device {
1010 int (*query_port)(struct ib_device *device, 1019 int (*query_port)(struct ib_device *device,
1011 u8 port_num, 1020 u8 port_num,
1012 struct ib_port_attr *port_attr); 1021 struct ib_port_attr *port_attr);
1022 enum rdma_link_layer (*get_link_layer)(struct ib_device *device,
1023 u8 port_num);
1013 int (*query_gid)(struct ib_device *device, 1024 int (*query_gid)(struct ib_device *device,
1014 u8 port_num, int index, 1025 u8 port_num, int index,
1015 union ib_gid *gid); 1026 union ib_gid *gid);
@@ -1222,6 +1233,9 @@ int ib_query_device(struct ib_device *device,
1222int ib_query_port(struct ib_device *device, 1233int ib_query_port(struct ib_device *device,
1223 u8 port_num, struct ib_port_attr *port_attr); 1234 u8 port_num, struct ib_port_attr *port_attr);
1224 1235
1236enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
1237 u8 port_num);
1238
1225int ib_query_gid(struct ib_device *device, 1239int ib_query_gid(struct ib_device *device,
1226 u8 port_num, int index, union ib_gid *gid); 1240 u8 port_num, int index, union ib_gid *gid);
1227 1241
diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
index cbb822e8d791..2d0191c90f9e 100644
--- a/include/rdma/iw_cm.h
+++ b/include/rdma/iw_cm.h
@@ -46,18 +46,9 @@ enum iw_cm_event_type {
46 IW_CM_EVENT_CLOSE /* close complete */ 46 IW_CM_EVENT_CLOSE /* close complete */
47}; 47};
48 48
49enum iw_cm_event_status {
50 IW_CM_EVENT_STATUS_OK = 0, /* request successful */
51 IW_CM_EVENT_STATUS_ACCEPTED = 0, /* connect request accepted */
52 IW_CM_EVENT_STATUS_REJECTED, /* connect request rejected */
53 IW_CM_EVENT_STATUS_TIMEOUT, /* the operation timed out */
54 IW_CM_EVENT_STATUS_RESET, /* reset from remote peer */
55 IW_CM_EVENT_STATUS_EINVAL, /* asynchronous failure for bad parm */
56};
57
58struct iw_cm_event { 49struct iw_cm_event {
59 enum iw_cm_event_type event; 50 enum iw_cm_event_type event;
60 enum iw_cm_event_status status; 51 int status;
61 struct sockaddr_in local_addr; 52 struct sockaddr_in local_addr;
62 struct sockaddr_in remote_addr; 53 struct sockaddr_in remote_addr;
63 void *private_data; 54 void *private_data;
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
index 4fae90304648..26977c149c41 100644
--- a/include/rdma/rdma_cm.h
+++ b/include/rdma/rdma_cm.h
@@ -111,6 +111,20 @@ struct rdma_cm_event {
111 } param; 111 } param;
112}; 112};
113 113
114enum rdma_cm_state {
115 RDMA_CM_IDLE,
116 RDMA_CM_ADDR_QUERY,
117 RDMA_CM_ADDR_RESOLVED,
118 RDMA_CM_ROUTE_QUERY,
119 RDMA_CM_ROUTE_RESOLVED,
120 RDMA_CM_CONNECT,
121 RDMA_CM_DISCONNECT,
122 RDMA_CM_ADDR_BOUND,
123 RDMA_CM_LISTEN,
124 RDMA_CM_DEVICE_REMOVAL,
125 RDMA_CM_DESTROYING
126};
127
114struct rdma_cm_id; 128struct rdma_cm_id;
115 129
116/** 130/**
@@ -130,6 +144,7 @@ struct rdma_cm_id {
130 rdma_cm_event_handler event_handler; 144 rdma_cm_event_handler event_handler;
131 struct rdma_route route; 145 struct rdma_route route;
132 enum rdma_port_space ps; 146 enum rdma_port_space ps;
147 enum ib_qp_type qp_type;
133 u8 port_num; 148 u8 port_num;
134}; 149};
135 150
@@ -140,9 +155,11 @@ struct rdma_cm_id {
140 * returned rdma_id. 155 * returned rdma_id.
141 * @context: User specified context associated with the id. 156 * @context: User specified context associated with the id.
142 * @ps: RDMA port space. 157 * @ps: RDMA port space.
158 * @qp_type: type of queue pair associated with the id.
143 */ 159 */
144struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler, 160struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
145 void *context, enum rdma_port_space ps); 161 void *context, enum rdma_port_space ps,
162 enum ib_qp_type qp_type);
146 163
147/** 164/**
148 * rdma_destroy_id - Destroys an RDMA identifier. 165 * rdma_destroy_id - Destroys an RDMA identifier.
@@ -329,4 +346,14 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr);
329 */ 346 */
330void rdma_set_service_type(struct rdma_cm_id *id, int tos); 347void rdma_set_service_type(struct rdma_cm_id *id, int tos);
331 348
349/**
350 * rdma_set_reuseaddr - Allow the reuse of local addresses when binding
351 * the rdma_cm_id.
352 * @id: Communication identifier to configure.
353 * @reuse: Value indicating if the bound address is reusable.
354 *
355 * Reuse must be set before an address is bound to the id.
356 */
357int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse);
358
332#endif /* RDMA_CM_H */ 359#endif /* RDMA_CM_H */
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
new file mode 100644
index 000000000000..3c5363ab867b
--- /dev/null
+++ b/include/rdma/rdma_netlink.h
@@ -0,0 +1,92 @@
1#ifndef _RDMA_NETLINK_H
2#define _RDMA_NETLINK_H
3
4#include <linux/types.h>
5
6enum {
7 RDMA_NL_RDMA_CM = 1
8};
9
10#define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10)
11#define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1))
12#define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op)
13
14enum {
15 RDMA_NL_RDMA_CM_ID_STATS = 0,
16 RDMA_NL_RDMA_CM_NUM_OPS
17};
18
19enum {
20 RDMA_NL_RDMA_CM_ATTR_SRC_ADDR = 1,
21 RDMA_NL_RDMA_CM_ATTR_DST_ADDR,
22 RDMA_NL_RDMA_CM_NUM_ATTR,
23};
24
25struct rdma_cm_id_stats {
26 __u32 qp_num;
27 __u32 bound_dev_if;
28 __u32 port_space;
29 __s32 pid;
30 __u8 cm_state;
31 __u8 node_type;
32 __u8 port_num;
33 __u8 qp_type;
34};
35
36#ifdef __KERNEL__
37
38#include <linux/netlink.h>
39
40struct ibnl_client_cbs {
41 int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
42};
43
44int ibnl_init(void);
45void ibnl_cleanup(void);
46
47/**
48 * Add a a client to the list of IB netlink exporters.
49 * @index: Index of the added client
50 * @nops: Number of supported ops by the added client.
51 * @cb_table: A table for op->callback
52 *
53 * Returns 0 on success or a negative error code.
54 */
55int ibnl_add_client(int index, int nops,
56 const struct ibnl_client_cbs cb_table[]);
57
58/**
59 * Remove a client from IB netlink.
60 * @index: Index of the removed IB client.
61 *
62 * Returns 0 on success or a negative error code.
63 */
64int ibnl_remove_client(int index);
65
66/**
67 * Put a new message in a supplied skb.
68 * @skb: The netlink skb.
69 * @nlh: Pointer to put the header of the new netlink message.
70 * @seq: The message sequence number.
71 * @len: The requested message length to allocate.
72 * @client: Calling IB netlink client.
73 * @op: message content op.
74 * Returns the allocated buffer on success and NULL on failure.
75 */
76void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
77 int len, int client, int op);
78/**
79 * Put a new attribute in a supplied skb.
80 * @skb: The netlink skb.
81 * @nlh: Header of the netlink message to append the attribute to.
82 * @len: The length of the attribute data.
83 * @data: The attribute data to put.
84 * @type: The attribute type.
85 * Returns the 0 and a negative error code on failure.
86 */
87int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
88 int len, void *data, int type);
89
90#endif /* __KERNEL__ */
91
92#endif /* _RDMA_NETLINK_H */
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index 1d165022c02d..fc82c1896f75 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -221,8 +221,9 @@ enum {
221 221
222/* Option details */ 222/* Option details */
223enum { 223enum {
224 RDMA_OPTION_ID_TOS = 0, 224 RDMA_OPTION_ID_TOS = 0,
225 RDMA_OPTION_IB_PATH = 1 225 RDMA_OPTION_ID_REUSEADDR = 1,
226 RDMA_OPTION_IB_PATH = 1
226}; 227};
227 228
228struct rdma_ucm_set_option { 229struct rdma_ucm_set_option {
diff --git a/include/rxrpc/packet.h b/include/rxrpc/packet.h
index 9b2c30897e50..f2902ef7ab75 100644
--- a/include/rxrpc/packet.h
+++ b/include/rxrpc/packet.h
@@ -148,7 +148,7 @@ struct rxkad_challenge {
148 * Kerberos security type-2 response packet 148 * Kerberos security type-2 response packet
149 */ 149 */
150struct rxkad_response { 150struct rxkad_response {
151 __be32 version; /* version of this reponse type */ 151 __be32 version; /* version of this response type */
152 __be32 __pad; 152 __be32 __pad;
153 153
154 /* encrypted bit of the response */ 154 /* encrypted bit of the response */
diff --git a/include/scsi/fc/fc_fcp.h b/include/scsi/fc/fc_fcp.h
index 8e9b222251c2..652dec230514 100644
--- a/include/scsi/fc/fc_fcp.h
+++ b/include/scsi/fc/fc_fcp.h
@@ -46,7 +46,7 @@
46 */ 46 */
47struct fcp_cmnd { 47struct fcp_cmnd {
48 __u8 fc_lun[8]; /* logical unit number */ 48 __u8 fc_lun[8]; /* logical unit number */
49 __u8 fc_cmdref; /* commmand reference number */ 49 __u8 fc_cmdref; /* command reference number */
50 __u8 fc_pri_ta; /* priority and task attribute */ 50 __u8 fc_pri_ta; /* priority and task attribute */
51 __u8 fc_tm_flags; /* task management flags */ 51 __u8 fc_tm_flags; /* task management flags */
52 __u8 fc_flags; /* additional len & flags */ 52 __u8 fc_flags; /* additional len & flags */
@@ -58,7 +58,7 @@ struct fcp_cmnd {
58 58
59struct fcp_cmnd32 { 59struct fcp_cmnd32 {
60 __u8 fc_lun[8]; /* logical unit number */ 60 __u8 fc_lun[8]; /* logical unit number */
61 __u8 fc_cmdref; /* commmand reference number */ 61 __u8 fc_cmdref; /* command reference number */
62 __u8 fc_pri_ta; /* priority and task attribute */ 62 __u8 fc_pri_ta; /* priority and task attribute */
63 __u8 fc_tm_flags; /* task management flags */ 63 __u8 fc_tm_flags; /* task management flags */
64 __u8 fc_flags; /* additional len & flags */ 64 __u8 fc_flags; /* additional len & flags */
@@ -75,7 +75,7 @@ struct fcp_cmnd32 {
75#define FCP_PTA_SIMPLE 0 /* simple task attribute */ 75#define FCP_PTA_SIMPLE 0 /* simple task attribute */
76#define FCP_PTA_HEADQ 1 /* head of queue task attribute */ 76#define FCP_PTA_HEADQ 1 /* head of queue task attribute */
77#define FCP_PTA_ORDERED 2 /* ordered task attribute */ 77#define FCP_PTA_ORDERED 2 /* ordered task attribute */
78#define FCP_PTA_ACA 4 /* auto. contigent allegiance */ 78#define FCP_PTA_ACA 4 /* auto. contingent allegiance */
79#define FCP_PTA_MASK 7 /* mask for task attribute field */ 79#define FCP_PTA_MASK 7 /* mask for task attribute field */
80#define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */ 80#define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */
81#define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */ 81#define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */
diff --git a/include/scsi/fc/fc_ns.h b/include/scsi/fc/fc_ns.h
index 185015dd1166..f7751d53f1d3 100644
--- a/include/scsi/fc/fc_ns.h
+++ b/include/scsi/fc/fc_ns.h
@@ -41,6 +41,7 @@ enum fc_ns_req {
41 FC_NS_GI_A = 0x0101, /* get identifiers - scope */ 41 FC_NS_GI_A = 0x0101, /* get identifiers - scope */
42 FC_NS_GPN_ID = 0x0112, /* get port name by ID */ 42 FC_NS_GPN_ID = 0x0112, /* get port name by ID */
43 FC_NS_GNN_ID = 0x0113, /* get node name by ID */ 43 FC_NS_GNN_ID = 0x0113, /* get node name by ID */
44 FC_NS_GSPN_ID = 0x0118, /* get symbolic port name */
44 FC_NS_GID_PN = 0x0121, /* get ID for port name */ 45 FC_NS_GID_PN = 0x0121, /* get ID for port name */
45 FC_NS_GID_NN = 0x0131, /* get IDs for node name */ 46 FC_NS_GID_NN = 0x0131, /* get IDs for node name */
46 FC_NS_GID_FT = 0x0171, /* get IDs by FC4 type */ 47 FC_NS_GID_FT = 0x0171, /* get IDs by FC4 type */
@@ -144,7 +145,7 @@ struct fc_ns_gid_pn {
144}; 145};
145 146
146/* 147/*
147 * GID_PN response 148 * GID_PN response or GSPN_ID request
148 */ 149 */
149struct fc_gid_pn_resp { 150struct fc_gid_pn_resp {
150 __u8 fp_resvd; 151 __u8 fp_resvd;
@@ -152,6 +153,14 @@ struct fc_gid_pn_resp {
152}; 153};
153 154
154/* 155/*
156 * GSPN_ID response
157 */
158struct fc_gspn_resp {
159 __u8 fp_name_len;
160 char fp_name[];
161};
162
163/*
155 * RFT_ID request - register FC-4 types for ID. 164 * RFT_ID request - register FC-4 types for ID.
156 */ 165 */
157struct fc_ns_rft_id { 166struct fc_ns_rft_id {
diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h
index 6d293c846a46..be418d8448a5 100644
--- a/include/scsi/fc_encode.h
+++ b/include/scsi/fc_encode.h
@@ -46,16 +46,11 @@ struct fc_ct_req {
46 } payload; 46 } payload;
47}; 47};
48 48
49/** 49static inline void __fc_fill_fc_hdr(struct fc_frame_header *fh,
50 * fill FC header fields in specified fc_frame 50 enum fc_rctl r_ctl,
51 */ 51 u32 did, u32 sid, enum fc_fh_type type,
52static inline void fc_fill_fc_hdr(struct fc_frame *fp, enum fc_rctl r_ctl, 52 u32 f_ctl, u32 parm_offset)
53 u32 did, u32 sid, enum fc_fh_type type,
54 u32 f_ctl, u32 parm_offset)
55{ 53{
56 struct fc_frame_header *fh;
57
58 fh = fc_frame_header_get(fp);
59 WARN_ON(r_ctl == 0); 54 WARN_ON(r_ctl == 0);
60 fh->fh_r_ctl = r_ctl; 55 fh->fh_r_ctl = r_ctl;
61 hton24(fh->fh_d_id, did); 56 hton24(fh->fh_d_id, did);
@@ -68,6 +63,19 @@ static inline void fc_fill_fc_hdr(struct fc_frame *fp, enum fc_rctl r_ctl,
68} 63}
69 64
70/** 65/**
66 * fill FC header fields in specified fc_frame
67 */
68static inline void fc_fill_fc_hdr(struct fc_frame *fp, enum fc_rctl r_ctl,
69 u32 did, u32 sid, enum fc_fh_type type,
70 u32 f_ctl, u32 parm_offset)
71{
72 struct fc_frame_header *fh;
73
74 fh = fc_frame_header_get(fp);
75 __fc_fill_fc_hdr(fh, r_ctl, did, sid, type, f_ctl, parm_offset);
76}
77
78/**
71 * fc_adisc_fill() - Fill in adisc request frame 79 * fc_adisc_fill() - Fill in adisc request frame
72 * @lport: local port. 80 * @lport: local port.
73 * @fp: fc frame where payload will be placed. 81 * @fp: fc frame where payload will be placed.
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index a8631acd37c3..ddb04568a509 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -263,6 +263,7 @@ enum iscsi_err {
263 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18, 263 ISCSI_ERR_INVALID_HOST = ISCSI_ERR_BASE + 18,
264 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, 264 ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19,
265 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20, 265 ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20,
266 ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21,
266}; 267};
267 268
268/* 269/*
@@ -291,7 +292,7 @@ enum iscsi_param {
291 ISCSI_PARAM_PERSISTENT_PORT, 292 ISCSI_PARAM_PERSISTENT_PORT,
292 ISCSI_PARAM_SESS_RECOVERY_TMO, 293 ISCSI_PARAM_SESS_RECOVERY_TMO,
293 294
294 /* pased in through bind conn using transport_fd */ 295 /* passed in through bind conn using transport_fd */
295 ISCSI_PARAM_CONN_PORT, 296 ISCSI_PARAM_CONN_PORT,
296 ISCSI_PARAM_CONN_ADDRESS, 297 ISCSI_PARAM_CONN_ADDRESS,
297 298
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 14be49b44e84..a3cbda4ddb5c 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -35,6 +35,8 @@
35 35
36#include <scsi/fc_frame.h> 36#include <scsi/fc_frame.h>
37 37
38#define FC_FC4_PROV_SIZE (FC_TYPE_FCP + 1) /* size of tables */
39
38/* 40/*
39 * libfc error codes 41 * libfc error codes
40 */ 42 */
@@ -156,6 +158,7 @@ struct fc_rport_libfc_priv {
156 #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0) 158 #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0)
157 #define FC_RP_FLAGS_RETRY (1 << 1) 159 #define FC_RP_FLAGS_RETRY (1 << 1)
158 #define FC_RP_STARTED (1 << 2) 160 #define FC_RP_STARTED (1 << 2)
161 #define FC_RP_FLAGS_CONF_REQ (1 << 3)
159 unsigned int e_d_tov; 162 unsigned int e_d_tov;
160 unsigned int r_a_tov; 163 unsigned int r_a_tov;
161}; 164};
@@ -179,6 +182,7 @@ struct fc_rport_libfc_priv {
179 * @rp_mutex: The mutex that protects the remote port 182 * @rp_mutex: The mutex that protects the remote port
180 * @retry_work: Handle for retries 183 * @retry_work: Handle for retries
181 * @event_callback: Callback when READY, FAILED or LOGO states complete 184 * @event_callback: Callback when READY, FAILED or LOGO states complete
185 * @prli_count: Count of open PRLI sessions in providers
182 * @rcu: Structure used for freeing in an RCU-safe manner 186 * @rcu: Structure used for freeing in an RCU-safe manner
183 */ 187 */
184struct fc_rport_priv { 188struct fc_rport_priv {
@@ -202,7 +206,13 @@ struct fc_rport_priv {
202 struct list_head peers; 206 struct list_head peers;
203 struct work_struct event_work; 207 struct work_struct event_work;
204 u32 supported_classes; 208 u32 supported_classes;
209 u16 prli_count;
205 struct rcu_head rcu; 210 struct rcu_head rcu;
211 u16 sp_features;
212 u8 spp_type;
213 void (*lld_event_callback)(struct fc_lport *,
214 struct fc_rport_priv *,
215 enum fc_rport_event);
206}; 216};
207 217
208/** 218/**
@@ -221,8 +231,8 @@ struct fc_rport_priv {
221 * @InputRequests: Number of input requests 231 * @InputRequests: Number of input requests
222 * @OutputRequests: Number of output requests 232 * @OutputRequests: Number of output requests
223 * @ControlRequests: Number of control requests 233 * @ControlRequests: Number of control requests
224 * @InputMegabytes: Number of received megabytes 234 * @InputBytes: Number of received bytes
225 * @OutputMegabytes: Number of transmitted megabytes 235 * @OutputBytes: Number of transmitted bytes
226 * @VLinkFailureCount: Number of virtual link failures 236 * @VLinkFailureCount: Number of virtual link failures
227 * @MissDiscAdvCount: Number of missing FIP discovery advertisement 237 * @MissDiscAdvCount: Number of missing FIP discovery advertisement
228 */ 238 */
@@ -241,8 +251,8 @@ struct fcoe_dev_stats {
241 u64 InputRequests; 251 u64 InputRequests;
242 u64 OutputRequests; 252 u64 OutputRequests;
243 u64 ControlRequests; 253 u64 ControlRequests;
244 u64 InputMegabytes; 254 u64 InputBytes;
245 u64 OutputMegabytes; 255 u64 OutputBytes;
246 u64 VLinkFailureCount; 256 u64 VLinkFailureCount;
247 u64 MissDiscAdvCount; 257 u64 MissDiscAdvCount;
248}; 258};
@@ -250,7 +260,7 @@ struct fcoe_dev_stats {
250/** 260/**
251 * struct fc_seq_els_data - ELS data used for passing ELS specific responses 261 * struct fc_seq_els_data - ELS data used for passing ELS specific responses
252 * @reason: The reason for rejection 262 * @reason: The reason for rejection
253 * @explan: The explaination of the rejection 263 * @explan: The explanation of the rejection
254 * 264 *
255 * Mainly used by the exchange manager layer. 265 * Mainly used by the exchange manager layer.
256 */ 266 */
@@ -263,7 +273,6 @@ struct fc_seq_els_data {
263 * struct fc_fcp_pkt - FCP request structure (one for each scsi_cmnd request) 273 * struct fc_fcp_pkt - FCP request structure (one for each scsi_cmnd request)
264 * @lp: The associated local port 274 * @lp: The associated local port
265 * @state: The state of the I/O 275 * @state: The state of the I/O
266 * @tgt_flags: Target's flags
267 * @ref_cnt: Reference count 276 * @ref_cnt: Reference count
268 * @scsi_pkt_lock: Lock to protect the SCSI packet (must be taken before the 277 * @scsi_pkt_lock: Lock to protect the SCSI packet (must be taken before the
269 * host_lock if both are to be held at the same time) 278 * host_lock if both are to be held at the same time)
@@ -298,7 +307,6 @@ struct fc_fcp_pkt {
298 /* Housekeeping information */ 307 /* Housekeeping information */
299 struct fc_lport *lp; 308 struct fc_lport *lp;
300 u16 state; 309 u16 state;
301 u16 tgt_flags;
302 atomic_t ref_cnt; 310 atomic_t ref_cnt;
303 spinlock_t scsi_pkt_lock; 311 spinlock_t scsi_pkt_lock;
304 312
@@ -517,7 +525,7 @@ struct libfc_function_template {
517 struct fc_frame *); 525 struct fc_frame *);
518 526
519 /* 527 /*
520 * Send an ELS response using infomation from the received frame. 528 * Send an ELS response using information from the received frame.
521 * 529 *
522 * STATUS: OPTIONAL 530 * STATUS: OPTIONAL
523 */ 531 */
@@ -553,6 +561,16 @@ struct libfc_function_template {
553 struct fc_seq *(*seq_start_next)(struct fc_seq *); 561 struct fc_seq *(*seq_start_next)(struct fc_seq *);
554 562
555 /* 563 /*
564 * Set a response handler for the exchange of the sequence.
565 *
566 * STATUS: OPTIONAL
567 */
568 void (*seq_set_resp)(struct fc_seq *sp,
569 void (*resp)(struct fc_seq *, struct fc_frame *,
570 void *),
571 void *arg);
572
573 /*
556 * Assign a sequence for an incoming request frame. 574 * Assign a sequence for an incoming request frame.
557 * 575 *
558 * STATUS: OPTIONAL 576 * STATUS: OPTIONAL
@@ -560,6 +578,13 @@ struct libfc_function_template {
560 struct fc_seq *(*seq_assign)(struct fc_lport *, struct fc_frame *); 578 struct fc_seq *(*seq_assign)(struct fc_lport *, struct fc_frame *);
561 579
562 /* 580 /*
581 * Release the reference on the sequence returned by seq_assign().
582 *
583 * STATUS: OPTIONAL
584 */
585 void (*seq_release)(struct fc_seq *);
586
587 /*
563 * Reset an exchange manager, completing all sequences and exchanges. 588 * Reset an exchange manager, completing all sequences and exchanges.
564 * If s_id is non-zero, reset only exchanges originating from that FID. 589 * If s_id is non-zero, reset only exchanges originating from that FID.
565 * If d_id is non-zero, reset only exchanges sending to that FID. 590 * If d_id is non-zero, reset only exchanges sending to that FID.
@@ -638,7 +663,7 @@ struct libfc_function_template {
638 int (*rport_logoff)(struct fc_rport_priv *); 663 int (*rport_logoff)(struct fc_rport_priv *);
639 664
640 /* 665 /*
641 * Recieve a request from a remote port. 666 * Receive a request from a remote port.
642 * 667 *
643 * STATUS: OPTIONAL 668 * STATUS: OPTIONAL
644 */ 669 */
@@ -658,6 +683,15 @@ struct libfc_function_template {
658 void (*rport_destroy)(struct kref *); 683 void (*rport_destroy)(struct kref *);
659 684
660 /* 685 /*
686 * Callback routine after the remote port is logged in
687 *
688 * STATUS: OPTIONAL
689 */
690 void (*rport_event_callback)(struct fc_lport *,
691 struct fc_rport_priv *,
692 enum fc_rport_event);
693
694 /*
661 * Send a fcp cmd from fsp pkt. 695 * Send a fcp cmd from fsp pkt.
662 * Called with the SCSI host lock unlocked and irqs disabled. 696 * Called with the SCSI host lock unlocked and irqs disabled.
663 * 697 *
@@ -670,7 +704,7 @@ struct libfc_function_template {
670 void *)); 704 void *));
671 705
672 /* 706 /*
673 * Cleanup the FCP layer, used durring link down and reset 707 * Cleanup the FCP layer, used during link down and reset
674 * 708 *
675 * STATUS: OPTIONAL 709 * STATUS: OPTIONAL
676 */ 710 */
@@ -721,7 +755,7 @@ struct libfc_function_template {
721 * struct fc_disc - Discovery context 755 * struct fc_disc - Discovery context
722 * @retry_count: Number of retries 756 * @retry_count: Number of retries
723 * @pending: 1 if discovery is pending, 0 if not 757 * @pending: 1 if discovery is pending, 0 if not
724 * @requesting: 1 if discovery has been requested, 0 if not 758 * @requested: 1 if discovery has been requested, 0 if not
725 * @seq_count: Number of sequences used for discovery 759 * @seq_count: Number of sequences used for discovery
726 * @buf_len: Length of the discovery buffer 760 * @buf_len: Length of the discovery buffer
727 * @disc_id: Discovery ID 761 * @disc_id: Discovery ID
@@ -751,6 +785,15 @@ struct fc_disc {
751 enum fc_disc_event); 785 enum fc_disc_event);
752}; 786};
753 787
788/*
789 * Local port notifier and events.
790 */
791extern struct blocking_notifier_head fc_lport_notifier_head;
792enum fc_lport_event {
793 FC_LPORT_EV_ADD,
794 FC_LPORT_EV_DEL,
795};
796
754/** 797/**
755 * struct fc_lport - Local port 798 * struct fc_lport - Local port
756 * @host: The SCSI host associated with a local port 799 * @host: The SCSI host associated with a local port
@@ -791,8 +834,10 @@ struct fc_disc {
791 * @lso_max: The maximum large offload send size 834 * @lso_max: The maximum large offload send size
792 * @fcts: FC-4 type mask 835 * @fcts: FC-4 type mask
793 * @lp_mutex: Mutex to protect the local port 836 * @lp_mutex: Mutex to protect the local port
794 * @list: Handle for list of local ports 837 * @list: Linkage on list of vport peers
795 * @retry_work: Handle to local port for delayed retry context 838 * @retry_work: Handle to local port for delayed retry context
839 * @prov: Pointers available for use by passive FC-4 providers
840 * @lport_list: Linkage on module-wide list of local ports
796 */ 841 */
797struct fc_lport { 842struct fc_lport {
798 /* Associations */ 843 /* Associations */
@@ -848,8 +893,32 @@ struct fc_lport {
848 struct mutex lp_mutex; 893 struct mutex lp_mutex;
849 struct list_head list; 894 struct list_head list;
850 struct delayed_work retry_work; 895 struct delayed_work retry_work;
896 void *prov[FC_FC4_PROV_SIZE];
897 struct list_head lport_list;
851}; 898};
852 899
900/**
901 * struct fc4_prov - FC-4 provider registration
902 * @prli: Handler for incoming PRLI
903 * @prlo: Handler for session reset
904 * @recv: Handler for incoming request
905 * @module: Pointer to module. May be NULL.
906 */
907struct fc4_prov {
908 int (*prli)(struct fc_rport_priv *, u32 spp_len,
909 const struct fc_els_spp *spp_in,
910 struct fc_els_spp *spp_out);
911 void (*prlo)(struct fc_rport_priv *);
912 void (*recv)(struct fc_lport *, struct fc_frame *);
913 struct module *module;
914};
915
916/*
917 * Register FC-4 provider with libfc.
918 */
919int fc_fc4_register_provider(enum fc_fh_type type, struct fc4_prov *);
920void fc_fc4_deregister_provider(enum fc_fh_type type, struct fc4_prov *);
921
853/* 922/*
854 * FC_LPORT HELPER FUNCTIONS 923 * FC_LPORT HELPER FUNCTIONS
855 *****************************/ 924 *****************************/
@@ -980,6 +1049,7 @@ struct fc_lport *libfc_vport_create(struct fc_vport *, int privsize);
980struct fc_lport *fc_vport_id_lookup(struct fc_lport *, u32 port_id); 1049struct fc_lport *fc_vport_id_lookup(struct fc_lport *, u32 port_id);
981int fc_lport_bsg_request(struct fc_bsg_job *); 1050int fc_lport_bsg_request(struct fc_bsg_job *);
982void fc_lport_set_local_id(struct fc_lport *, u32 port_id); 1051void fc_lport_set_local_id(struct fc_lport *, u32 port_id);
1052void fc_lport_iterate(void (*func)(struct fc_lport *, void *), void *);
983 1053
984/* 1054/*
985 * REMOTE PORT LAYER 1055 * REMOTE PORT LAYER
@@ -1006,8 +1076,7 @@ void fc_fcp_destroy(struct fc_lport *);
1006/* 1076/*
1007 * SCSI INTERACTION LAYER 1077 * SCSI INTERACTION LAYER
1008 *****************************/ 1078 *****************************/
1009int fc_queuecommand(struct scsi_cmnd *, 1079int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
1010 void (*done)(struct scsi_cmnd *));
1011int fc_eh_abort(struct scsi_cmnd *); 1080int fc_eh_abort(struct scsi_cmnd *);
1012int fc_eh_device_reset(struct scsi_cmnd *); 1081int fc_eh_device_reset(struct scsi_cmnd *);
1013int fc_eh_host_reset(struct scsi_cmnd *); 1082int fc_eh_host_reset(struct scsi_cmnd *);
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index 06f1b5a8ed19..8c1638b8c28e 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -33,6 +33,12 @@
33#define FCOE_MAX_CMD_LEN 16 /* Supported CDB length */ 33#define FCOE_MAX_CMD_LEN 16 /* Supported CDB length */
34 34
35/* 35/*
36 * Max MTU for FCoE: 14 (FCoE header) + 24 (FC header) + 2112 (max FC payload)
37 * + 4 (FC CRC) + 4 (FCoE trailer) = 2158 bytes
38 */
39#define FCOE_MTU 2158
40
41/*
36 * FIP tunable parameters. 42 * FIP tunable parameters.
37 */ 43 */
38#define FCOE_CTLR_START_DELAY 2000 /* mS after first adv. to choose FCF */ 44#define FCOE_CTLR_START_DELAY 2000 /* mS after first adv. to choose FCF */
@@ -92,10 +98,12 @@ enum fip_state {
92 * @timer_work: &work_struct for doing keep-alives and resets. 98 * @timer_work: &work_struct for doing keep-alives and resets.
93 * @recv_work: &work_struct for receiving FIP frames. 99 * @recv_work: &work_struct for receiving FIP frames.
94 * @fip_recv_list: list of received FIP frames. 100 * @fip_recv_list: list of received FIP frames.
101 * @flogi_req: clone of FLOGI request sent
95 * @rnd_state: state for pseudo-random number generator. 102 * @rnd_state: state for pseudo-random number generator.
96 * @port_id: proposed or selected local-port ID. 103 * @port_id: proposed or selected local-port ID.
97 * @user_mfs: configured maximum FC frame size, including FC header. 104 * @user_mfs: configured maximum FC frame size, including FC header.
98 * @flogi_oxid: exchange ID of most recent fabric login. 105 * @flogi_oxid: exchange ID of most recent fabric login.
106 * @flogi_req_send: send of FLOGI requested
99 * @flogi_count: number of FLOGI attempts in AUTO mode. 107 * @flogi_count: number of FLOGI attempts in AUTO mode.
100 * @map_dest: use the FC_MAP mode for destination MAC addresses. 108 * @map_dest: use the FC_MAP mode for destination MAC addresses.
101 * @spma: supports SPMA server-provided MACs mode 109 * @spma: supports SPMA server-provided MACs mode
@@ -106,6 +114,7 @@ enum fip_state {
106 * @update_mac: LLD-supplied function to handle changes to MAC addresses. 114 * @update_mac: LLD-supplied function to handle changes to MAC addresses.
107 * @get_src_addr: LLD-supplied function to supply a source MAC address. 115 * @get_src_addr: LLD-supplied function to supply a source MAC address.
108 * @ctlr_mutex: lock protecting this structure. 116 * @ctlr_mutex: lock protecting this structure.
117 * @ctlr_lock: spinlock covering flogi_req
109 * 118 *
110 * This structure is used by all FCoE drivers. It contains information 119 * This structure is used by all FCoE drivers. It contains information
111 * needed by all FCoE low-level drivers (LLDs) as well as internal state 120 * needed by all FCoE low-level drivers (LLDs) as well as internal state
@@ -126,12 +135,14 @@ struct fcoe_ctlr {
126 struct work_struct timer_work; 135 struct work_struct timer_work;
127 struct work_struct recv_work; 136 struct work_struct recv_work;
128 struct sk_buff_head fip_recv_list; 137 struct sk_buff_head fip_recv_list;
138 struct sk_buff *flogi_req;
129 139
130 struct rnd_state rnd_state; 140 struct rnd_state rnd_state;
131 u32 port_id; 141 u32 port_id;
132 142
133 u16 user_mfs; 143 u16 user_mfs;
134 u16 flogi_oxid; 144 u16 flogi_oxid;
145 u8 flogi_req_send;
135 u8 flogi_count; 146 u8 flogi_count;
136 u8 map_dest; 147 u8 map_dest;
137 u8 spma; 148 u8 spma;
@@ -143,6 +154,7 @@ struct fcoe_ctlr {
143 void (*update_mac)(struct fc_lport *, u8 *addr); 154 void (*update_mac)(struct fc_lport *, u8 *addr);
144 u8 * (*get_src_addr)(struct fc_lport *); 155 u8 * (*get_src_addr)(struct fc_lport *);
145 struct mutex ctlr_mutex; 156 struct mutex ctlr_mutex;
157 spinlock_t ctlr_lock;
146}; 158};
147 159
148/** 160/**
@@ -155,6 +167,7 @@ struct fcoe_ctlr {
155 * @fcf_mac: Ethernet address of the FCF 167 * @fcf_mac: Ethernet address of the FCF
156 * @vfid: virtual fabric ID 168 * @vfid: virtual fabric ID
157 * @pri: selection priority, smaller values are better 169 * @pri: selection priority, smaller values are better
170 * @flogi_sent: current FLOGI sent to this FCF
158 * @flags: flags received from advertisement 171 * @flags: flags received from advertisement
159 * @fka_period: keep-alive period, in jiffies 172 * @fka_period: keep-alive period, in jiffies
160 * 173 *
@@ -176,6 +189,7 @@ struct fcoe_fcf {
176 u8 fcf_mac[ETH_ALEN]; 189 u8 fcf_mac[ETH_ALEN];
177 190
178 u8 pri; 191 u8 pri;
192 u8 flogi_sent;
179 u16 flags; 193 u16 flags;
180 u32 fka_period; 194 u32 fka_period;
181 u8 fd_flags:1; 195 u8 fd_flags:1;
@@ -213,6 +227,8 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *,
213u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int); 227u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int);
214int fcoe_libfc_config(struct fc_lport *, struct fcoe_ctlr *, 228int fcoe_libfc_config(struct fc_lport *, struct fcoe_ctlr *,
215 const struct libfc_function_template *, int init_fcp); 229 const struct libfc_function_template *, int init_fcp);
230u32 fcoe_fc_crc(struct fc_frame *fp);
231int fcoe_start_io(struct sk_buff *skb);
216 232
217/** 233/**
218 * is_fip_mode() - returns true if FIP mode selected. 234 * is_fip_mode() - returns true if FIP mode selected.
@@ -223,5 +239,102 @@ static inline bool is_fip_mode(struct fcoe_ctlr *fip)
223 return fip->state == FIP_ST_ENABLED; 239 return fip->state == FIP_ST_ENABLED;
224} 240}
225 241
242/* helper for FCoE SW HBA drivers, can include subven and subdev if needed. The
243 * modpost would use pci_device_id table to auto-generate formatted module alias
244 * into the corresponding .mod.c file, but there may or may not be a pci device
245 * id table for FCoE drivers so we use the following helper for build the fcoe
246 * driver module alias.
247 */
248#define MODULE_ALIAS_FCOE_PCI(ven, dev) \
249 MODULE_ALIAS("fcoe-pci:" \
250 "v" __stringify(ven) \
251 "d" __stringify(dev) "sv*sd*bc*sc*i*")
252
253/* the name of the default FCoE transport driver fcoe.ko */
254#define FCOE_TRANSPORT_DEFAULT "fcoe"
255
256/* struct fcoe_transport - The FCoE transport interface
257 * @name: a vendor specific name for their FCoE transport driver
258 * @attached: whether this transport is already attached
259 * @list: list linkage to all attached transports
260 * @match: handler to allow the transport driver to match up a given netdev
261 * @create: handler to sysfs entry of create for FCoE instances
262 * @destroy: handler to sysfs entry of destroy for FCoE instances
263 * @enable: handler to sysfs entry of enable for FCoE instances
264 * @disable: handler to sysfs entry of disable for FCoE instances
265 */
266struct fcoe_transport {
267 char name[IFNAMSIZ];
268 bool attached;
269 struct list_head list;
270 bool (*match) (struct net_device *device);
271 int (*create) (struct net_device *device, enum fip_state fip_mode);
272 int (*destroy) (struct net_device *device);
273 int (*enable) (struct net_device *device);
274 int (*disable) (struct net_device *device);
275};
276
277/**
278 * struct fcoe_percpu_s - The context for FCoE receive thread(s)
279 * @thread: The thread context
280 * @fcoe_rx_list: The queue of pending packets to process
281 * @page: The memory page for calculating frame trailer CRCs
282 * @crc_eof_offset: The offset into the CRC page pointing to available
283 * memory for a new trailer
284 */
285struct fcoe_percpu_s {
286 struct task_struct *thread;
287 struct sk_buff_head fcoe_rx_list;
288 struct page *crc_eof_page;
289 int crc_eof_offset;
290};
291
292/**
293 * struct fcoe_port - The FCoE private structure
294 * @priv: The associated fcoe interface. The structure is
295 * defined by the low level driver
296 * @lport: The associated local port
297 * @fcoe_pending_queue: The pending Rx queue of skbs
298 * @fcoe_pending_queue_active: Indicates if the pending queue is active
299 * @max_queue_depth: Max queue depth of pending queue
300 * @min_queue_depth: Min queue depth of pending queue
301 * @timer: The queue timer
302 * @destroy_work: Handle for work context
303 * (to prevent RTNL deadlocks)
304 * @data_srt_addr: Source address for data
305 *
306 * An instance of this structure is to be allocated along with the
307 * Scsi_Host and libfc fc_lport structures.
308 */
309struct fcoe_port {
310 void *priv;
311 struct fc_lport *lport;
312 struct sk_buff_head fcoe_pending_queue;
313 u8 fcoe_pending_queue_active;
314 u32 max_queue_depth;
315 u32 min_queue_depth;
316 struct timer_list timer;
317 struct work_struct destroy_work;
318 u8 data_src_addr[ETH_ALEN];
319};
320void fcoe_clean_pending_queue(struct fc_lport *);
321void fcoe_check_wait_queue(struct fc_lport *lport, struct sk_buff *skb);
322void fcoe_queue_timer(ulong lport);
323int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen,
324 struct fcoe_percpu_s *fps);
325
326/**
327 * struct netdev_list
328 * A mapping from netdevice to fcoe_transport
329 */
330struct fcoe_netdev_mapping {
331 struct list_head list;
332 struct net_device *netdev;
333 struct fcoe_transport *ft;
334};
335
336/* fcoe transports registration and deregistration */
337int fcoe_transport_attach(struct fcoe_transport *ft);
338int fcoe_transport_detach(struct fcoe_transport *ft);
226 339
227#endif /* _LIBFCOE_H */ 340#endif /* _LIBFCOE_H */
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ae5196aae1a5..0f4367751b71 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -89,6 +89,7 @@ enum {
89 ISCSI_TASK_RUNNING, 89 ISCSI_TASK_RUNNING,
90 ISCSI_TASK_ABRT_TMF, /* aborted due to TMF */ 90 ISCSI_TASK_ABRT_TMF, /* aborted due to TMF */
91 ISCSI_TASK_ABRT_SESS_RECOV, /* aborted due to session recovery */ 91 ISCSI_TASK_ABRT_SESS_RECOV, /* aborted due to session recovery */
92 ISCSI_TASK_REQUEUE_SCSIQ, /* qcmd requeueing to scsi-ml */
92}; 93};
93 94
94struct iscsi_r2t_info { 95struct iscsi_r2t_info {
@@ -211,9 +212,6 @@ struct iscsi_conn {
211 /* values userspace uses to id a conn */ 212 /* values userspace uses to id a conn */
212 int persistent_port; 213 int persistent_port;
213 char *persistent_address; 214 char *persistent_address;
214 /* remote portal currently connected to */
215 int portal_port;
216 char portal_address[ISCSI_ADDRESS_BUF_LEN];
217 215
218 /* MIB-statistics */ 216 /* MIB-statistics */
219 uint64_t txdata_octets; 217 uint64_t txdata_octets;
@@ -318,9 +316,6 @@ struct iscsi_host {
318 /* hw address or netdev iscsi connection is bound to */ 316 /* hw address or netdev iscsi connection is bound to */
319 char *hwaddress; 317 char *hwaddress;
320 char *netdev; 318 char *netdev;
321 /* local address */
322 int local_port;
323 char local_address[ISCSI_ADDRESS_BUF_LEN];
324 319
325 wait_queue_head_t session_removal_wq; 320 wait_queue_head_t session_removal_wq;
326 /* protects sessions and state */ 321 /* protects sessions and state */
@@ -341,8 +336,7 @@ extern int iscsi_eh_abort(struct scsi_cmnd *sc);
341extern int iscsi_eh_recover_target(struct scsi_cmnd *sc); 336extern int iscsi_eh_recover_target(struct scsi_cmnd *sc);
342extern int iscsi_eh_session_reset(struct scsi_cmnd *sc); 337extern int iscsi_eh_session_reset(struct scsi_cmnd *sc);
343extern int iscsi_eh_device_reset(struct scsi_cmnd *sc); 338extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
344extern int iscsi_queuecommand(struct scsi_cmnd *sc, 339extern int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc);
345 void (*done)(struct scsi_cmnd *));
346 340
347/* 341/*
348 * iSCSI host helpers. 342 * iSCSI host helpers.
@@ -394,6 +388,8 @@ extern void iscsi_session_failure(struct iscsi_session *session,
394 enum iscsi_err err); 388 enum iscsi_err err);
395extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, 389extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
396 enum iscsi_param param, char *buf); 390 enum iscsi_param param, char *buf);
391extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr,
392 enum iscsi_param param, char *buf);
397extern void iscsi_suspend_tx(struct iscsi_conn *conn); 393extern void iscsi_suspend_tx(struct iscsi_conn *conn);
398extern void iscsi_suspend_queue(struct iscsi_conn *conn); 394extern void iscsi_suspend_queue(struct iscsi_conn *conn);
399extern void iscsi_conn_queue_work(struct iscsi_conn *conn); 395extern void iscsi_conn_queue_work(struct iscsi_conn *conn);
@@ -420,6 +416,7 @@ extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
420extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t); 416extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
421extern void iscsi_requeue_task(struct iscsi_task *task); 417extern void iscsi_requeue_task(struct iscsi_task *task);
422extern void iscsi_put_task(struct iscsi_task *task); 418extern void iscsi_put_task(struct iscsi_task *task);
419extern void __iscsi_put_task(struct iscsi_task *task);
423extern void __iscsi_get_task(struct iscsi_task *task); 420extern void __iscsi_get_task(struct iscsi_task *task);
424extern void iscsi_complete_scsi_task(struct iscsi_task *task, 421extern void iscsi_complete_scsi_task(struct iscsi_task *task,
425 uint32_t exp_cmdsn, uint32_t max_cmdsn); 422 uint32_t exp_cmdsn, uint32_t max_cmdsn);
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
index 741ae7ed4394..ac0cc1d925ef 100644
--- a/include/scsi/libiscsi_tcp.h
+++ b/include/scsi/libiscsi_tcp.h
@@ -47,11 +47,12 @@ struct iscsi_segment {
47 struct scatterlist *sg; 47 struct scatterlist *sg;
48 void *sg_mapped; 48 void *sg_mapped;
49 unsigned int sg_offset; 49 unsigned int sg_offset;
50 bool atomic_mapped;
50 51
51 iscsi_segment_done_fn_t *done; 52 iscsi_segment_done_fn_t *done;
52}; 53};
53 54
54/* Socket connection recieve helper */ 55/* Socket connection receive helper */
55struct iscsi_tcp_recv { 56struct iscsi_tcp_recv {
56 struct iscsi_hdr *hdr; 57 struct iscsi_hdr *hdr;
57 struct iscsi_segment segment; 58 struct iscsi_segment segment;
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index d06e13be717b..ee866060f8a4 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -205,6 +205,7 @@ struct domain_device {
205 }; 205 };
206 206
207 void *lldd_dev; 207 void *lldd_dev;
208 int gone;
208}; 209};
209 210
210struct sas_discovery_event { 211struct sas_discovery_event {
@@ -360,6 +361,8 @@ struct sas_ha_struct {
360 /* The class calls this to send a task for execution. */ 361 /* The class calls this to send a task for execution. */
361 int lldd_max_execute_num; 362 int lldd_max_execute_num;
362 int lldd_queue_size; 363 int lldd_queue_size;
364 int strict_wide_ports; /* both sas_addr and attached_sas_addr must match
365 * their siblings when forming wide ports */
363 366
364 /* LLDD calls these to notify the class of an event. */ 367 /* LLDD calls these to notify the class of an event. */
365 void (*notify_ha_event)(struct sas_ha_struct *, enum ha_event); 368 void (*notify_ha_event)(struct sas_ha_struct *, enum ha_event);
@@ -601,6 +604,7 @@ struct sas_domain_function_template {
601 int (*lldd_clear_aca)(struct domain_device *, u8 *lun); 604 int (*lldd_clear_aca)(struct domain_device *, u8 *lun);
602 int (*lldd_clear_task_set)(struct domain_device *, u8 *lun); 605 int (*lldd_clear_task_set)(struct domain_device *, u8 *lun);
603 int (*lldd_I_T_nexus_reset)(struct domain_device *); 606 int (*lldd_I_T_nexus_reset)(struct domain_device *);
607 int (*lldd_ata_soft_reset)(struct domain_device *);
604 int (*lldd_lu_reset)(struct domain_device *, u8 *lun); 608 int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
605 int (*lldd_query_task)(struct sas_task *); 609 int (*lldd_query_task)(struct sas_task *);
606 610
@@ -620,8 +624,7 @@ int sas_set_phy_speed(struct sas_phy *phy,
620int sas_phy_enable(struct sas_phy *phy, int enabled); 624int sas_phy_enable(struct sas_phy *phy, int enabled);
621int sas_phy_reset(struct sas_phy *phy, int hard_reset); 625int sas_phy_reset(struct sas_phy *phy, int hard_reset);
622int sas_queue_up(struct sas_task *task); 626int sas_queue_up(struct sas_task *task);
623extern int sas_queuecommand(struct scsi_cmnd *, 627extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *);
624 void (*scsi_done)(struct scsi_cmnd *));
625extern int sas_target_alloc(struct scsi_target *); 628extern int sas_target_alloc(struct scsi_target *);
626extern int sas_slave_alloc(struct scsi_device *); 629extern int sas_slave_alloc(struct scsi_device *);
627extern int sas_slave_configure(struct scsi_device *); 630extern int sas_slave_configure(struct scsi_device *);
diff --git a/include/scsi/osd_initiator.h b/include/scsi/osd_initiator.h
index a8f370126632..0a5079974fe9 100644
--- a/include/scsi/osd_initiator.h
+++ b/include/scsi/osd_initiator.h
@@ -137,7 +137,7 @@ struct osd_request {
137 void *buff; 137 void *buff;
138 unsigned alloc_size; /* 0 here means: don't call kfree */ 138 unsigned alloc_size; /* 0 here means: don't call kfree */
139 unsigned total_bytes; 139 unsigned total_bytes;
140 } set_attr, enc_get_attr, get_attr; 140 } cdb_cont, set_attr, enc_get_attr, get_attr;
141 141
142 struct _osd_io_info { 142 struct _osd_io_info {
143 struct bio *bio; 143 struct bio *bio;
@@ -265,7 +265,7 @@ int osd_execute_request_async(struct osd_request *or,
265 * @osi - Recievs a more detailed error report information (optional). 265 * @osi - Recievs a more detailed error report information (optional).
266 * @silent - Do not print to dmsg (Even if enabled) 266 * @silent - Do not print to dmsg (Even if enabled)
267 * @bad_obj_list - Some commands act on multiple objects. Failed objects will 267 * @bad_obj_list - Some commands act on multiple objects. Failed objects will
268 * be recieved here (optional) 268 * be received here (optional)
269 * @max_obj - Size of @bad_obj_list. 269 * @max_obj - Size of @bad_obj_list.
270 * @bad_attr_list - List of failing attributes (optional) 270 * @bad_attr_list - List of failing attributes (optional)
271 * @max_attr - Size of @bad_attr_list. 271 * @max_attr - Size of @bad_attr_list.
@@ -448,6 +448,20 @@ void osd_req_read(struct osd_request *or,
448int osd_req_read_kern(struct osd_request *or, 448int osd_req_read_kern(struct osd_request *or,
449 const struct osd_obj_id *obj, u64 offset, void *buff, u64 len); 449 const struct osd_obj_id *obj, u64 offset, void *buff, u64 len);
450 450
451/* Scatter/Gather write/read commands */
452int osd_req_write_sg(struct osd_request *or,
453 const struct osd_obj_id *obj, struct bio *bio,
454 const struct osd_sg_entry *sglist, unsigned numentries);
455int osd_req_read_sg(struct osd_request *or,
456 const struct osd_obj_id *obj, struct bio *bio,
457 const struct osd_sg_entry *sglist, unsigned numentries);
458int osd_req_write_sg_kern(struct osd_request *or,
459 const struct osd_obj_id *obj, void **buff,
460 const struct osd_sg_entry *sglist, unsigned numentries);
461int osd_req_read_sg_kern(struct osd_request *or,
462 const struct osd_obj_id *obj, void **buff,
463 const struct osd_sg_entry *sglist, unsigned numentries);
464
451/* 465/*
452 * Root/Partition/Collection/Object Attributes commands 466 * Root/Partition/Collection/Object Attributes commands
453 */ 467 */
diff --git a/include/scsi/osd_protocol.h b/include/scsi/osd_protocol.h
index 685661283540..a6026da25f3e 100644
--- a/include/scsi/osd_protocol.h
+++ b/include/scsi/osd_protocol.h
@@ -631,4 +631,46 @@ static inline void osd_sec_set_caps(struct osd_capability_head *cap,
631 put_unaligned_le16(bit_mask, &cap->permissions_bit_mask); 631 put_unaligned_le16(bit_mask, &cap->permissions_bit_mask);
632} 632}
633 633
634/* osd2r05a sec 5.3: CDB continuation segment formats */
635enum osd_continuation_segment_format {
636 CDB_CONTINUATION_FORMAT_V2 = 0x01,
637};
638
639struct osd_continuation_segment_header {
640 u8 format;
641 u8 reserved1;
642 __be16 service_action;
643 __be32 reserved2;
644 u8 integrity_check[OSDv2_CRYPTO_KEYID_SIZE];
645} __packed;
646
647/* osd2r05a sec 5.4.1: CDB continuation descriptors */
648enum osd_continuation_descriptor_type {
649 NO_MORE_DESCRIPTORS = 0x0000,
650 SCATTER_GATHER_LIST = 0x0001,
651 QUERY_LIST = 0x0002,
652 USER_OBJECT = 0x0003,
653 COPY_USER_OBJECT_SOURCE = 0x0101,
654 EXTENSION_CAPABILITIES = 0xFFEE
655};
656
657struct osd_continuation_descriptor_header {
658 __be16 type;
659 u8 reserved;
660 u8 pad_length;
661 __be32 length;
662} __packed;
663
664
665/* osd2r05a sec 5.4.2: Scatter/gather list */
666struct osd_sg_list_entry {
667 __be64 offset;
668 __be64 len;
669};
670
671struct osd_sg_continuation_descriptor {
672 struct osd_continuation_descriptor_header hdr;
673 struct osd_sg_list_entry entries[];
674};
675
634#endif /* ndef __OSD_PROTOCOL_H__ */ 676#endif /* ndef __OSD_PROTOCOL_H__ */
diff --git a/include/scsi/osd_types.h b/include/scsi/osd_types.h
index 3f5e88cc75c0..bd0be7ed4bcf 100644
--- a/include/scsi/osd_types.h
+++ b/include/scsi/osd_types.h
@@ -37,4 +37,9 @@ struct osd_attr {
37 void *val_ptr; /* in network order */ 37 void *val_ptr; /* in network order */
38}; 38};
39 39
40struct osd_sg_entry {
41 u64 offset;
42 u64 len;
43};
44
40#endif /* ndef __OSD_TYPES_H__ */ 45#endif /* ndef __OSD_TYPES_H__ */
diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h
index c583193ae929..9c159f74c6d0 100644
--- a/include/scsi/sas_ata.h
+++ b/include/scsi/sas_ata.h
@@ -39,6 +39,11 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev,
39 struct scsi_target *starget); 39 struct scsi_target *starget);
40 40
41void sas_ata_task_abort(struct sas_task *task); 41void sas_ata_task_abort(struct sas_task *task);
42void sas_ata_strategy_handler(struct Scsi_Host *shost);
43int sas_ata_timed_out(struct scsi_cmnd *cmd, struct sas_task *task,
44 enum blk_eh_timer_return *rtn);
45int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
46 struct list_head *done_q);
42 47
43#else 48#else
44 49
@@ -55,6 +60,23 @@ static inline int sas_ata_init_host_and_port(struct domain_device *found_dev,
55static inline void sas_ata_task_abort(struct sas_task *task) 60static inline void sas_ata_task_abort(struct sas_task *task)
56{ 61{
57} 62}
63
64static inline void sas_ata_strategy_handler(struct Scsi_Host *shost)
65{
66}
67
68static inline int sas_ata_timed_out(struct scsi_cmnd *cmd,
69 struct sas_task *task,
70 enum blk_eh_timer_return *rtn)
71{
72 return 0;
73}
74static inline int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
75 struct list_head *done_q)
76{
77 return 0;
78}
79
58#endif 80#endif
59 81
60#endif /* _SAS_ATA_H_ */ 82#endif /* _SAS_ATA_H_ */
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 8fcb6e0e9e72..3668903e397b 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -9,6 +9,7 @@
9#define _SCSI_SCSI_H 9#define _SCSI_SCSI_H
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/scatterlist.h>
12 13
13struct scsi_cmnd; 14struct scsi_cmnd;
14 15
@@ -32,6 +33,12 @@ struct scsi_cmnd;
32#endif 33#endif
33 34
34/* 35/*
36 * DIX-capable adapters effectively support infinite chaining for the
37 * protection information scatterlist
38 */
39#define SCSI_MAX_PROT_SG_SEGMENTS 0xFFFF
40
41/*
35 * Special value for scanning to specify scanning or rescanning of all 42 * Special value for scanning to specify scanning or rescanning of all
36 * possible channels, (target) ids, or luns on a given shost. 43 * possible channels, (target) ids, or luns on a given shost.
37 */ 44 */
@@ -67,6 +74,7 @@ struct scsi_cmnd;
67#define SEND_DIAGNOSTIC 0x1d 74#define SEND_DIAGNOSTIC 0x1d
68#define ALLOW_MEDIUM_REMOVAL 0x1e 75#define ALLOW_MEDIUM_REMOVAL 0x1e
69 76
77#define READ_FORMAT_CAPACITIES 0x23
70#define SET_WINDOW 0x24 78#define SET_WINDOW 0x24
71#define READ_CAPACITY 0x25 79#define READ_CAPACITY 0x25
72#define READ_10 0x28 80#define READ_10 0x28
@@ -96,6 +104,8 @@ struct scsi_cmnd;
96#define WRITE_SAME 0x41 104#define WRITE_SAME 0x41
97#define UNMAP 0x42 105#define UNMAP 0x42
98#define READ_TOC 0x43 106#define READ_TOC 0x43
107#define READ_HEADER 0x44
108#define GET_EVENT_STATUS_NOTIFICATION 0x4a
99#define LOG_SELECT 0x4c 109#define LOG_SELECT 0x4c
100#define LOG_SENSE 0x4d 110#define LOG_SENSE 0x4d
101#define XDWRITEREAD_10 0x53 111#define XDWRITEREAD_10 0x53
@@ -107,33 +117,61 @@ struct scsi_cmnd;
107#define PERSISTENT_RESERVE_OUT 0x5f 117#define PERSISTENT_RESERVE_OUT 0x5f
108#define VARIABLE_LENGTH_CMD 0x7f 118#define VARIABLE_LENGTH_CMD 0x7f
109#define REPORT_LUNS 0xa0 119#define REPORT_LUNS 0xa0
120#define SECURITY_PROTOCOL_IN 0xa2
110#define MAINTENANCE_IN 0xa3 121#define MAINTENANCE_IN 0xa3
111#define MAINTENANCE_OUT 0xa4 122#define MAINTENANCE_OUT 0xa4
112#define MOVE_MEDIUM 0xa5 123#define MOVE_MEDIUM 0xa5
113#define EXCHANGE_MEDIUM 0xa6 124#define EXCHANGE_MEDIUM 0xa6
114#define READ_12 0xa8 125#define READ_12 0xa8
115#define WRITE_12 0xaa 126#define WRITE_12 0xaa
127#define READ_MEDIA_SERIAL_NUMBER 0xab
116#define WRITE_VERIFY_12 0xae 128#define WRITE_VERIFY_12 0xae
117#define VERIFY_12 0xaf 129#define VERIFY_12 0xaf
118#define SEARCH_HIGH_12 0xb0 130#define SEARCH_HIGH_12 0xb0
119#define SEARCH_EQUAL_12 0xb1 131#define SEARCH_EQUAL_12 0xb1
120#define SEARCH_LOW_12 0xb2 132#define SEARCH_LOW_12 0xb2
133#define SECURITY_PROTOCOL_OUT 0xb5
121#define READ_ELEMENT_STATUS 0xb8 134#define READ_ELEMENT_STATUS 0xb8
122#define SEND_VOLUME_TAG 0xb6 135#define SEND_VOLUME_TAG 0xb6
123#define WRITE_LONG_2 0xea 136#define WRITE_LONG_2 0xea
137#define EXTENDED_COPY 0x83
138#define RECEIVE_COPY_RESULTS 0x84
139#define ACCESS_CONTROL_IN 0x86
140#define ACCESS_CONTROL_OUT 0x87
124#define READ_16 0x88 141#define READ_16 0x88
125#define WRITE_16 0x8a 142#define WRITE_16 0x8a
143#define READ_ATTRIBUTE 0x8c
144#define WRITE_ATTRIBUTE 0x8d
126#define VERIFY_16 0x8f 145#define VERIFY_16 0x8f
127#define WRITE_SAME_16 0x93 146#define WRITE_SAME_16 0x93
128#define SERVICE_ACTION_IN 0x9e 147#define SERVICE_ACTION_IN 0x9e
129/* values for service action in */ 148/* values for service action in */
130#define SAI_READ_CAPACITY_16 0x10 149#define SAI_READ_CAPACITY_16 0x10
131#define SAI_GET_LBA_STATUS 0x12 150#define SAI_GET_LBA_STATUS 0x12
151/* values for VARIABLE_LENGTH_CMD service action codes
152 * see spc4r17 Section D.3.5, table D.7 and D.8 */
153#define VLC_SA_RECEIVE_CREDENTIAL 0x1800
132/* values for maintenance in */ 154/* values for maintenance in */
155#define MI_REPORT_IDENTIFYING_INFORMATION 0x05
133#define MI_REPORT_TARGET_PGS 0x0a 156#define MI_REPORT_TARGET_PGS 0x0a
157#define MI_REPORT_ALIASES 0x0b
158#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
159#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
160#define MI_REPORT_PRIORITY 0x0e
161#define MI_REPORT_TIMESTAMP 0x0f
162#define MI_MANAGEMENT_PROTOCOL_IN 0x10
134/* values for maintenance out */ 163/* values for maintenance out */
164#define MO_SET_IDENTIFYING_INFORMATION 0x06
135#define MO_SET_TARGET_PGS 0x0a 165#define MO_SET_TARGET_PGS 0x0a
166#define MO_CHANGE_ALIASES 0x0b
167#define MO_SET_PRIORITY 0x0e
168#define MO_SET_TIMESTAMP 0x0f
169#define MO_MANAGEMENT_PROTOCOL_OUT 0x10
136/* values for variable length command */ 170/* values for variable length command */
171#define XDREAD_32 0x03
172#define XDWRITE_32 0x04
173#define XPWRITE_32 0x06
174#define XDWRITEREAD_32 0x07
137#define READ_32 0x09 175#define READ_32 0x09
138#define VERIFY_32 0x0a 176#define VERIFY_32 0x0a
139#define WRITE_32 0x0b 177#define WRITE_32 0x0b
@@ -397,6 +435,10 @@ static inline int scsi_is_wlun(unsigned int lun)
397 * recover the link. Transport class will 435 * recover the link. Transport class will
398 * retry or fail IO */ 436 * retry or fail IO */
399#define DID_TRANSPORT_FAILFAST 0x0f /* Transport class fastfailed the io */ 437#define DID_TRANSPORT_FAILFAST 0x0f /* Transport class fastfailed the io */
438#define DID_TARGET_FAILURE 0x10 /* Permanent target failure, do not retry on
439 * other paths */
440#define DID_NEXUS_FAILURE 0x11 /* Permanent nexus failure, retry on other
441 * paths might yield different results */
400#define DRIVER_OK 0x00 /* Driver status */ 442#define DRIVER_OK 0x00 /* Driver status */
401 443
402/* 444/*
@@ -426,6 +468,7 @@ static inline int scsi_is_wlun(unsigned int lun)
426#define TIMEOUT_ERROR 0x2007 468#define TIMEOUT_ERROR 0x2007
427#define SCSI_RETURN_NOT_HANDLED 0x2008 469#define SCSI_RETURN_NOT_HANDLED 0x2008
428#define FAST_IO_FAIL 0x2009 470#define FAST_IO_FAIL 0x2009
471#define TARGET_ERROR 0x200A
429 472
430/* 473/*
431 * Midlevel queue return values. 474 * Midlevel queue return values.
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 50cb34ffef11..dd82e02ddde3 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -148,6 +148,8 @@ struct scsi_device {
148 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ 148 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */
149 unsigned last_sector_bug:1; /* do not use multisector accesses on 149 unsigned last_sector_bug:1; /* do not use multisector accesses on
150 SD_LAST_BUGGY_SECTORS */ 150 SD_LAST_BUGGY_SECTORS */
151 unsigned no_read_disc_info:1; /* Avoid READ_DISC_INFO cmds */
152 unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */
151 unsigned is_visible:1; /* is the device visible in sysfs */ 153 unsigned is_visible:1; /* is the device visible in sysfs */
152 154
153 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ 155 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
@@ -167,6 +169,7 @@ struct scsi_device {
167 sdev_dev; 169 sdev_dev;
168 170
169 struct execute_work ew; /* used to get process context on put */ 171 struct execute_work ew; /* used to get process context on put */
172 struct work_struct requeue_work;
170 173
171 struct scsi_dh_data *scsi_dh_data; 174 struct scsi_dh_data *scsi_dh_data;
172 enum scsi_device_state sdev_state; 175 enum scsi_device_state sdev_state;
@@ -182,6 +185,7 @@ typedef void (*activate_complete)(void *, int);
182struct scsi_device_handler { 185struct scsi_device_handler {
183 /* Used by the infrastructure */ 186 /* Used by the infrastructure */
184 struct list_head list; /* list of scsi_device_handlers */ 187 struct list_head list; /* list of scsi_device_handlers */
188 int idx;
185 189
186 /* Filled by the hardware handler */ 190 /* Filled by the hardware handler */
187 struct module *module; 191 struct module *module;
@@ -459,7 +463,7 @@ static inline int scsi_device_qas(struct scsi_device *sdev)
459} 463}
460static inline int scsi_device_enclosure(struct scsi_device *sdev) 464static inline int scsi_device_enclosure(struct scsi_device *sdev)
461{ 465{
462 return sdev->inquiry[6] & (1<<6); 466 return sdev->inquiry ? (sdev->inquiry[6] & (1<<6)) : 1;
463} 467}
464 468
465static inline int scsi_device_protection(struct scsi_device *sdev) 469static inline int scsi_device_protection(struct scsi_device *sdev)
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index b7bdecb7b76e..f1f2644137b8 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -46,7 +46,7 @@ struct blk_queue_tags;
46enum { 46enum {
47 SCSI_QDEPTH_DEFAULT, /* default requested change, e.g. from sysfs */ 47 SCSI_QDEPTH_DEFAULT, /* default requested change, e.g. from sysfs */
48 SCSI_QDEPTH_QFULL, /* scsi-ml requested due to queue full */ 48 SCSI_QDEPTH_QFULL, /* scsi-ml requested due to queue full */
49 SCSI_QDEPTH_RAMP_UP, /* scsi-ml requested due to threshhold event */ 49 SCSI_QDEPTH_RAMP_UP, /* scsi-ml requested due to threshold event */
50}; 50};
51 51
52struct scsi_host_template { 52struct scsi_host_template {
@@ -127,8 +127,7 @@ struct scsi_host_template {
127 * 127 *
128 * STATUS: REQUIRED 128 * STATUS: REQUIRED
129 */ 129 */
130 int (* queuecommand)(struct scsi_cmnd *, 130 int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
131 void (*done)(struct scsi_cmnd *));
132 131
133 /* 132 /*
134 * The transfer functions are used to queue a scsi command to 133 * The transfer functions are used to queue a scsi command to
@@ -388,6 +387,7 @@ struct scsi_host_template {
388 * of scatter-gather. 387 * of scatter-gather.
389 */ 388 */
390 unsigned short sg_tablesize; 389 unsigned short sg_tablesize;
390 unsigned short sg_prot_tablesize;
391 391
392 /* 392 /*
393 * Set this if the host adapter has limitations beside segment count. 393 * Set this if the host adapter has limitations beside segment count.
@@ -504,6 +504,25 @@ struct scsi_host_template {
504}; 504};
505 505
506/* 506/*
507 * Temporary #define for host lock push down. Can be removed when all
508 * drivers have been updated to take advantage of unlocked
509 * queuecommand.
510 *
511 */
512#define DEF_SCSI_QCMD(func_name) \
513 int func_name(struct Scsi_Host *shost, struct scsi_cmnd *cmd) \
514 { \
515 unsigned long irq_flags; \
516 int rc; \
517 spin_lock_irqsave(shost->host_lock, irq_flags); \
518 scsi_cmd_get_serial(shost, cmd); \
519 rc = func_name##_lck (cmd, cmd->scsi_done); \
520 spin_unlock_irqrestore(shost->host_lock, irq_flags); \
521 return rc; \
522 }
523
524
525/*
507 * shost state: If you alter this, you also need to alter scsi_sysfs.c 526 * shost state: If you alter this, you also need to alter scsi_sysfs.c
508 * (for the ascii descriptions) and the state model enforcer: 527 * (for the ascii descriptions) and the state model enforcer:
509 * scsi_host_set_state() 528 * scsi_host_set_state()
@@ -599,6 +618,7 @@ struct Scsi_Host {
599 int can_queue; 618 int can_queue;
600 short cmd_per_lun; 619 short cmd_per_lun;
601 short unsigned int sg_tablesize; 620 short unsigned int sg_tablesize;
621 short unsigned int sg_prot_tablesize;
602 short unsigned int max_sectors; 622 short unsigned int max_sectors;
603 unsigned long dma_boundary; 623 unsigned long dma_boundary;
604 /* 624 /*
@@ -750,6 +770,7 @@ extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
750extern void scsi_host_put(struct Scsi_Host *t); 770extern void scsi_host_put(struct Scsi_Host *t);
751extern struct Scsi_Host *scsi_host_lookup(unsigned short); 771extern struct Scsi_Host *scsi_host_lookup(unsigned short);
752extern const char *scsi_host_state_name(enum scsi_host_state); 772extern const char *scsi_host_state_name(enum scsi_host_state);
773extern void scsi_cmd_get_serial(struct Scsi_Host *, struct scsi_cmnd *);
753 774
754extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); 775extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *);
755 776
@@ -823,6 +844,11 @@ static inline unsigned int scsi_host_get_prot(struct Scsi_Host *shost)
823 return shost->prot_capabilities; 844 return shost->prot_capabilities;
824} 845}
825 846
847static inline int scsi_host_prot_dma(struct Scsi_Host *shost)
848{
849 return shost->prot_capabilities >= SHOST_DIX_TYPE0_PROTECTION;
850}
851
826static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsigned int target_type) 852static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsigned int target_type)
827{ 853{
828 static unsigned char cap[] = { 0, 854 static unsigned char cap[] = { 0,
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index 17231385cb37..81dd12edc38c 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -9,6 +9,7 @@
9#define MSG_SIMPLE_TAG 0x20 9#define MSG_SIMPLE_TAG 0x20
10#define MSG_HEAD_TAG 0x21 10#define MSG_HEAD_TAG 0x21
11#define MSG_ORDERED_TAG 0x22 11#define MSG_ORDERED_TAG 0x22
12#define MSG_ACA_TAG 0x24 /* unsupported */
12 13
13#define SCSI_NO_TAG (-1) /* identify no tag in use */ 14#define SCSI_NO_TAG (-1) /* identify no tag in use */
14 15
@@ -97,13 +98,9 @@ static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)
97static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg) 98static inline int scsi_populate_tag_msg(struct scsi_cmnd *cmd, char *msg)
98{ 99{
99 struct request *req = cmd->request; 100 struct request *req = cmd->request;
100 struct scsi_device *sdev = cmd->device;
101 101
102 if (blk_rq_tagged(req)) { 102 if (blk_rq_tagged(req)) {
103 if (sdev->ordered_tags && req->cmd_flags & REQ_HARDBARRIER) 103 *msg++ = MSG_SIMPLE_TAG;
104 *msg++ = MSG_ORDERED_TAG;
105 else
106 *msg++ = MSG_SIMPLE_TAG;
107 *msg++ = req->tag; 104 *msg++ = req->tag;
108 return 2; 105 return 2;
109 } 106 }
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 87d81b3ce564..2a65167a8f10 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -192,9 +192,9 @@ struct fc_vport_identifiers {
192 * 192 *
193 * This structure exists for each FC port is a virtual FC port. Virtual 193 * This structure exists for each FC port is a virtual FC port. Virtual
194 * ports share the physical link with the Physical port. Each virtual 194 * ports share the physical link with the Physical port. Each virtual
195 * ports has a unique presense on the SAN, and may be instantiated via 195 * ports has a unique presence on the SAN, and may be instantiated via
196 * NPIV, Virtual Fabrics, or via additional ALPAs. As the vport is a 196 * NPIV, Virtual Fabrics, or via additional ALPAs. As the vport is a
197 * unique presense, each vport has it's own view of the fabric, 197 * unique presence, each vport has it's own view of the fabric,
198 * authentication privilege, and priorities. 198 * authentication privilege, and priorities.
199 * 199 *
200 * A virtual port may support 1 or more FC4 roles. Typically it is a 200 * A virtual port may support 1 or more FC4 roles. Typically it is a
@@ -370,7 +370,7 @@ struct fc_rport { /* aka fc_starget_attrs */
370/* 370/*
371 * FC SCSI Target Attributes 371 * FC SCSI Target Attributes
372 * 372 *
373 * The SCSI Target is considered an extention of a remote port (as 373 * The SCSI Target is considered an extension of a remote port (as
374 * a remote port can be more than a SCSI Target). Within the scsi 374 * a remote port can be more than a SCSI Target). Within the scsi
375 * subsystem, we leave the Target as a separate entity. Doing so 375 * subsystem, we leave the Target as a separate entity. Doing so
376 * provides backward compatibility with prior FC transport api's, 376 * provides backward compatibility with prior FC transport api's,
@@ -496,6 +496,7 @@ struct fc_host_attrs {
496 u64 fabric_name; 496 u64 fabric_name;
497 char symbolic_name[FC_SYMBOLIC_NAME_SIZE]; 497 char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
498 char system_hostname[FC_SYMBOLIC_NAME_SIZE]; 498 char system_hostname[FC_SYMBOLIC_NAME_SIZE];
499 u32 dev_loss_tmo;
499 500
500 /* Private (Transport-managed) Attributes */ 501 /* Private (Transport-managed) Attributes */
501 enum fc_tgtid_binding_type tgtid_bind_type; 502 enum fc_tgtid_binding_type tgtid_bind_type;
@@ -580,6 +581,8 @@ struct fc_host_attrs {
580 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name) 581 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name)
581#define fc_host_devloss_work_q(x) \ 582#define fc_host_devloss_work_q(x) \
582 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q) 583 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q)
584#define fc_host_dev_loss_tmo(x) \
585 (((struct fc_host_attrs *)(x)->shost_data)->dev_loss_tmo)
583 586
584 587
585struct fc_bsg_buffer { 588struct fc_bsg_buffer {
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 7fff94b3b2a8..bf8f52965675 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -101,6 +101,8 @@ struct iscsi_transport {
101 void (*destroy_conn) (struct iscsi_cls_conn *conn); 101 void (*destroy_conn) (struct iscsi_cls_conn *conn);
102 int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param, 102 int (*set_param) (struct iscsi_cls_conn *conn, enum iscsi_param param,
103 char *buf, int buflen); 103 char *buf, int buflen);
104 int (*get_ep_param) (struct iscsi_endpoint *ep, enum iscsi_param param,
105 char *buf);
104 int (*get_conn_param) (struct iscsi_cls_conn *conn, 106 int (*get_conn_param) (struct iscsi_cls_conn *conn,
105 enum iscsi_param param, char *buf); 107 enum iscsi_param param, char *buf);
106 int (*get_session_param) (struct iscsi_cls_session *session, 108 int (*get_session_param) (struct iscsi_cls_session *session,
@@ -160,8 +162,9 @@ struct iscsi_cls_conn {
160 void *dd_data; /* LLD private data */ 162 void *dd_data; /* LLD private data */
161 struct iscsi_transport *transport; 163 struct iscsi_transport *transport;
162 uint32_t cid; /* connection id */ 164 uint32_t cid; /* connection id */
165 struct mutex ep_mutex;
166 struct iscsi_endpoint *ep;
163 167
164 int active; /* must be accessed with the connlock */
165 struct device dev; /* sysfs transport/container device */ 168 struct device dev; /* sysfs transport/container device */
166}; 169};
167 170
@@ -222,6 +225,7 @@ struct iscsi_endpoint {
222 void *dd_data; /* LLD private data */ 225 void *dd_data; /* LLD private data */
223 struct device dev; 226 struct device dev;
224 uint64_t id; 227 uint64_t id;
228 struct iscsi_cls_conn *conn;
225}; 229};
226 230
227/* 231/*
diff --git a/include/scsi/srp.h b/include/scsi/srp.h
index ad178fa78f66..1ae84db4c9fb 100644
--- a/include/scsi/srp.h
+++ b/include/scsi/srp.h
@@ -239,4 +239,42 @@ struct srp_rsp {
239 u8 data[0]; 239 u8 data[0];
240} __attribute__((packed)); 240} __attribute__((packed));
241 241
242struct srp_cred_req {
243 u8 opcode;
244 u8 sol_not;
245 u8 reserved[2];
246 __be32 req_lim_delta;
247 u64 tag;
248};
249
250struct srp_cred_rsp {
251 u8 opcode;
252 u8 reserved[7];
253 u64 tag;
254};
255
256/*
257 * The SRP spec defines the fixed portion of the AER_REQ structure to be
258 * 36 bytes, so it needs to be packed to avoid having it padded to 40 bytes
259 * on 64-bit architectures.
260 */
261struct srp_aer_req {
262 u8 opcode;
263 u8 sol_not;
264 u8 reserved[2];
265 __be32 req_lim_delta;
266 u64 tag;
267 u32 reserved2;
268 __be64 lun;
269 __be32 sense_data_len;
270 u32 reserved3;
271 u8 sense_data[0];
272} __attribute__((packed));
273
274struct srp_aer_rsp {
275 u8 opcode;
276 u8 reserved[7];
277 u64 tag;
278};
279
242#endif /* SCSI_SRP_H */ 280#endif /* SCSI_SRP_H */
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 49400459b477..02cbb50225bb 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -96,6 +96,10 @@
96#define AC97_FUNC_INFO 0x68 /* Function Information */ 96#define AC97_FUNC_INFO 0x68 /* Function Information */
97#define AC97_SENSE_INFO 0x6a /* Sense Details */ 97#define AC97_SENSE_INFO 0x6a /* Sense Details */
98 98
99/* volume controls */
100#define AC97_MUTE_MASK_MONO 0x8000
101#define AC97_MUTE_MASK_STEREO 0x8080
102
99/* slot allocation */ 103/* slot allocation */
100#define AC97_SLOT_TAG 0 104#define AC97_SLOT_TAG 0
101#define AC97_SLOT_CMD_ADDR 1 105#define AC97_SLOT_CMD_ADDR 1
@@ -138,6 +142,7 @@
138#define AC97_BC_18BIT_ADC 0x0100 /* 18-bit ADC resolution */ 142#define AC97_BC_18BIT_ADC 0x0100 /* 18-bit ADC resolution */
139#define AC97_BC_20BIT_ADC 0x0200 /* 20-bit ADC resolution */ 143#define AC97_BC_20BIT_ADC 0x0200 /* 20-bit ADC resolution */
140#define AC97_BC_ADC_MASK 0x0300 144#define AC97_BC_ADC_MASK 0x0300
145#define AC97_BC_3D_TECH_ID_MASK 0x7c00 /* Per-vendor ID of 3D enhancement */
141 146
142/* general purpose */ 147/* general purpose */
143#define AC97_GP_DRSS_MASK 0x0c00 /* double rate slot select */ 148#define AC97_GP_DRSS_MASK 0x0c00 /* double rate slot select */
@@ -380,7 +385,7 @@
380#define AC97_SCAP_DETECT_BY_VENDOR (1<<8) /* use vendor registers for read tests */ 385#define AC97_SCAP_DETECT_BY_VENDOR (1<<8) /* use vendor registers for read tests */
381#define AC97_SCAP_NO_SPDIF (1<<9) /* don't build SPDIF controls */ 386#define AC97_SCAP_NO_SPDIF (1<<9) /* don't build SPDIF controls */
382#define AC97_SCAP_EAPD_LED (1<<10) /* EAPD as mute LED */ 387#define AC97_SCAP_EAPD_LED (1<<10) /* EAPD as mute LED */
383#define AC97_SCAP_POWER_SAVE (1<<11) /* capable for aggresive power-saving */ 388#define AC97_SCAP_POWER_SAVE (1<<11) /* capable for aggressive power-saving */
384 389
385/* ac97->flags */ 390/* ac97->flags */
386#define AC97_HAS_PC_BEEP (1<<0) /* force PC Speaker usage */ 391#define AC97_HAS_PC_BEEP (1<<0) /* force PC Speaker usage */
@@ -477,7 +482,7 @@ struct snd_ac97_template {
477 482
478struct snd_ac97 { 483struct snd_ac97 {
479 /* -- lowlevel (hardware) driver specific -- */ 484 /* -- lowlevel (hardware) driver specific -- */
480 struct snd_ac97_build_ops * build_ops; 485 const struct snd_ac97_build_ops *build_ops;
481 void *private_data; 486 void *private_data;
482 void (*private_free) (struct snd_ac97 *ac97); 487 void (*private_free) (struct snd_ac97 *ac97);
483 /* --- */ 488 /* --- */
diff --git a/include/sound/ak4641.h b/include/sound/ak4641.h
new file mode 100644
index 000000000000..96d1991c811d
--- /dev/null
+++ b/include/sound/ak4641.h
@@ -0,0 +1,26 @@
1/*
2 * AK4641 ALSA SoC Codec driver
3 *
4 * Copyright 2009 Philipp Zabel
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __AK4641_H
12#define __AK4641_H
13
14/**
15 * struct ak4641_platform_data - platform specific AK4641 configuration
16 * @gpio_power: GPIO to control external power to AK4641
17 * @gpio_npdn: GPIO connected to AK4641 nPDN pin
18 *
19 * Both GPIO parameters are optional.
20 */
21struct ak4641_platform_data {
22 int gpio_power;
23 int gpio_npdn;
24};
25
26#endif /* __AK4641_H */
diff --git a/include/sound/alc5623.h b/include/sound/alc5623.h
new file mode 100644
index 000000000000..422c97d43df3
--- /dev/null
+++ b/include/sound/alc5623.h
@@ -0,0 +1,15 @@
1#ifndef _INCLUDE_SOUND_ALC5623_H
2#define _INCLUDE_SOUND_ALC5623_H
3struct alc5623_platform_data {
4 /* configure : */
5 /* Lineout/Speaker Amps Vmid ratio control */
6 /* enable/disable adc/dac high pass filters */
7 unsigned int add_ctrl;
8 /* configure : */
9 /* output to enable when jack is low */
10 /* output to enable when jack is high */
11 /* jack detect (gpio/nc/jack detect [12] */
12 unsigned int jack_det_ctrl;
13};
14#endif
15
diff --git a/include/sound/asound.h b/include/sound/asound.h
index a1803ecea34d..5d6074faa279 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -259,6 +259,7 @@ typedef int __bitwise snd_pcm_subformat_t;
259#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000 /* only half duplex */ 259#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000 /* only half duplex */
260#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 /* playback and capture stream are somewhat correlated */ 260#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 /* playback and capture stream are somewhat correlated */
261#define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */ 261#define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */
262#define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000 /* period wakeup can be disabled */
262#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */ 263#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
263 264
264typedef int __bitwise snd_pcm_state_t; 265typedef int __bitwise snd_pcm_state_t;
@@ -334,6 +335,8 @@ typedef int snd_pcm_hw_param_t;
334#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME 335#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME
335 336
336#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */ 337#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */
338#define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER (1<<1) /* export buffer */
339#define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP (1<<2) /* disable period wakeups */
337 340
338struct snd_interval { 341struct snd_interval {
339 unsigned int min, max; 342 unsigned int min, max;
diff --git a/include/sound/control.h b/include/sound/control.h
index 112374dc0c58..1a94a216ed99 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -113,8 +113,11 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, v
113void snd_ctl_free_one(struct snd_kcontrol * kcontrol); 113void snd_ctl_free_one(struct snd_kcontrol * kcontrol);
114int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol); 114int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
115int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol); 115int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
116int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace);
116int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id); 117int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
117int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id); 118int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
119int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
120 int active);
118struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid); 121struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
119struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id); 122struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
120 123
@@ -160,12 +163,14 @@ static inline struct snd_ctl_elem_id *snd_ctl_build_ioff(struct snd_ctl_elem_id
160} 163}
161 164
162/* 165/*
163 * Frequently used control callbacks 166 * Frequently used control callbacks/helpers
164 */ 167 */
165int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol, 168int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
166 struct snd_ctl_elem_info *uinfo); 169 struct snd_ctl_elem_info *uinfo);
167int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol, 170int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
168 struct snd_ctl_elem_info *uinfo); 171 struct snd_ctl_elem_info *uinfo);
172int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
173 unsigned int items, const char *const names[]);
169 174
170/* 175/*
171 * virtual master control 176 * virtual master control
@@ -187,7 +192,7 @@ int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
187 * Returns zero if successful or a negative error code. 192 * Returns zero if successful or a negative error code.
188 * 193 *
189 * All slaves must be the same type (returning the same information 194 * All slaves must be the same type (returning the same information
190 * via info callback). The fucntion doesn't check it, so it's your 195 * via info callback). The function doesn't check it, so it's your
191 * responsibility. 196 * responsibility.
192 * 197 *
193 * Also, some additional limitations: 198 * Also, some additional limitations:
diff --git a/include/sound/core.h b/include/sound/core.h
index 89e0ac17f44a..1fa2407c966f 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -133,9 +133,7 @@ struct snd_card {
133 int free_on_last_close; /* free in context of file_release */ 133 int free_on_last_close; /* free in context of file_release */
134 wait_queue_head_t shutdown_sleep; 134 wait_queue_head_t shutdown_sleep;
135 struct device *dev; /* device assigned to this card */ 135 struct device *dev; /* device assigned to this card */
136#ifndef CONFIG_SYSFS_DEPRECATED
137 struct device *card_dev; /* cardX object for sysfs */ 136 struct device *card_dev; /* cardX object for sysfs */
138#endif
139 137
140#ifdef CONFIG_PM 138#ifdef CONFIG_PM
141 unsigned int power_state; /* power state */ 139 unsigned int power_state; /* power state */
@@ -179,7 +177,7 @@ int snd_power_wait(struct snd_card *card, unsigned int power_state);
179#define snd_power_lock(card) do { (void)(card); } while (0) 177#define snd_power_lock(card) do { (void)(card); } while (0)
180#define snd_power_unlock(card) do { (void)(card); } while (0) 178#define snd_power_unlock(card) do { (void)(card); } while (0)
181static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; } 179static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; }
182#define snd_power_get_state(card) SNDRV_CTL_POWER_D0 180#define snd_power_get_state(card) ({ (void)(card); SNDRV_CTL_POWER_D0; })
183#define snd_power_change_state(card, state) do { (void)(card); } while (0) 181#define snd_power_change_state(card, state) do { (void)(card); } while (0)
184 182
185#endif /* CONFIG_PM */ 183#endif /* CONFIG_PM */
@@ -196,11 +194,7 @@ struct snd_minor {
196/* return a device pointer linked to each sound device as a parent */ 194/* return a device pointer linked to each sound device as a parent */
197static inline struct device *snd_card_get_device_link(struct snd_card *card) 195static inline struct device *snd_card_get_device_link(struct snd_card *card)
198{ 196{
199#ifdef CONFIG_SYSFS_DEPRECATED
200 return card ? card->dev : NULL;
201#else
202 return card ? card->card_dev : NULL; 197 return card ? card->card_dev : NULL;
203#endif
204} 198}
205 199
206/* sound.c */ 200/* sound.c */
diff --git a/include/sound/cs4271.h b/include/sound/cs4271.h
new file mode 100644
index 000000000000..50a059e7d116
--- /dev/null
+++ b/include/sound/cs4271.h
@@ -0,0 +1,24 @@
1/*
2 * Definitions for CS4271 ASoC codec driver
3 *
4 * Copyright (c) 2010 Alexander Sverdlin <subaparts@yandex.ru>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef __CS4271_H
18#define __CS4271_H
19
20struct cs4271_platform_data {
21 int gpio_nreset; /* GPIO driving Reset pin, if any */
22};
23
24#endif /* __CS4271_H */
diff --git a/include/sound/cs46xx_dsp_spos.h b/include/sound/cs46xx_dsp_spos.h
index 49b03c9e5e55..8008c59288a6 100644
--- a/include/sound/cs46xx_dsp_spos.h
+++ b/include/sound/cs46xx_dsp_spos.h
@@ -147,7 +147,7 @@ struct dsp_pcm_channel_descriptor {
147}; 147};
148 148
149struct dsp_spos_instance { 149struct dsp_spos_instance {
150 struct dsp_symbol_desc symbol_table; /* currently availble loaded symbols in SP */ 150 struct dsp_symbol_desc symbol_table; /* currently available loaded symbols in SP */
151 151
152 int nmodules; 152 int nmodules;
153 struct dsp_module_desc * modules; /* modules loaded into SP */ 153 struct dsp_module_desc * modules; /* modules loaded into SP */
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 7dc97d12253c..4f865df42f0f 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -438,6 +438,8 @@
438#define CCCA_CURRADDR_MASK 0x00ffffff /* Current address of the selected channel */ 438#define CCCA_CURRADDR_MASK 0x00ffffff /* Current address of the selected channel */
439#define CCCA_CURRADDR 0x18000008 439#define CCCA_CURRADDR 0x18000008
440 440
441/* undefine CCR to avoid conflict with the definition for SH */
442#undef CCR
441#define CCR 0x09 /* Cache control register */ 443#define CCR 0x09 /* Cache control register */
442#define CCR_CACHEINVALIDSIZE 0x07190009 444#define CCR_CACHEINVALIDSIZE 0x07190009
443#define CCR_CACHEINVALIDSIZE_MASK 0xfe000000 /* Number of invalid samples cache for this channel */ 445#define CCR_CACHEINVALIDSIZE_MASK 0xfe000000 /* Number of invalid samples cache for this channel */
diff --git a/include/sound/hdsp.h b/include/sound/hdsp.h
index d98a78dff2db..0909a3843479 100644
--- a/include/sound/hdsp.h
+++ b/include/sound/hdsp.h
@@ -28,6 +28,7 @@ enum HDSP_IO_Type {
28 Multiface, 28 Multiface,
29 H9652, 29 H9652,
30 H9632, 30 H9632,
31 RPM,
31 Undefined, 32 Undefined,
32}; 33};
33 34
diff --git a/include/sound/hdspm.h b/include/sound/hdspm.h
index 81990b2bcc98..1f59ea2a4a76 100644
--- a/include/sound/hdspm.h
+++ b/include/sound/hdspm.h
@@ -3,8 +3,8 @@
3/* 3/*
4 * Copyright (C) 2003 Winfried Ritsch (IEM) 4 * Copyright (C) 2003 Winfried Ritsch (IEM)
5 * based on hdsp.h from Thomas Charbonnel (thomas@undata.org) 5 * based on hdsp.h from Thomas Charbonnel (thomas@undata.org)
6 * 6 *
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
@@ -23,50 +23,41 @@
23/* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */ 23/* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */
24#define HDSPM_MAX_CHANNELS 64 24#define HDSPM_MAX_CHANNELS 64
25 25
26/* -------------------- IOCTL Peak/RMS Meters -------------------- */ 26enum hdspm_io_type {
27 27 MADI,
28/* peam rms level structure like we get from hardware 28 MADIface,
29 29 AIO,
30 maybe in future we can memory map it so I just copy it 30 AES32,
31 to user on ioctl call now an dont change anything 31 RayDAT
32 rms are made out of low and high values 32};
33 where (long) ????_rms = (????_rms_l >> 8) + ((????_rms_h & 0xFFFFFF00)<<24)
34 (i asume so from the code)
35*/
36
37struct hdspm_peak_rms {
38
39 unsigned int level_offset[1024];
40 33
41 unsigned int input_peak[64]; 34enum hdspm_speed {
42 unsigned int playback_peak[64]; 35 ss,
43 unsigned int output_peak[64]; 36 ds,
44 unsigned int xxx_peak[64]; /* not used */ 37 qs
38};
45 39
46 unsigned int reserved[256]; /* not used */ 40/* -------------------- IOCTL Peak/RMS Meters -------------------- */
47 41
48 unsigned int input_rms_l[64]; 42struct hdspm_peak_rms {
49 unsigned int playback_rms_l[64]; 43 uint32_t input_peaks[64];
50 unsigned int output_rms_l[64]; 44 uint32_t playback_peaks[64];
51 unsigned int xxx_rms_l[64]; /* not used */ 45 uint32_t output_peaks[64];
52 46
53 unsigned int input_rms_h[64]; 47 uint64_t input_rms[64];
54 unsigned int playback_rms_h[64]; 48 uint64_t playback_rms[64];
55 unsigned int output_rms_h[64]; 49 uint64_t output_rms[64];
56 unsigned int xxx_rms_h[64]; /* not used */
57};
58 50
59struct hdspm_peak_rms_ioctl { 51 uint8_t speed; /* enum {ss, ds, qs} */
60 struct hdspm_peak_rms *peak; 52 int status2;
61}; 53};
62 54
63/* use indirect access due to the limit of ioctl bit size */
64#define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS \ 55#define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS \
65 _IOR('H', 0x40, struct hdspm_peak_rms_ioctl) 56 _IOR('H', 0x42, struct hdspm_peak_rms)
66 57
67/* ------------ CONFIG block IOCTL ---------------------- */ 58/* ------------ CONFIG block IOCTL ---------------------- */
68 59
69struct hdspm_config_info { 60struct hdspm_config {
70 unsigned char pref_sync_ref; 61 unsigned char pref_sync_ref;
71 unsigned char wordclock_sync_check; 62 unsigned char wordclock_sync_check;
72 unsigned char madi_sync_check; 63 unsigned char madi_sync_check;
@@ -80,18 +71,121 @@ struct hdspm_config_info {
80 unsigned int analog_out; 71 unsigned int analog_out;
81}; 72};
82 73
83#define SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO \ 74#define SNDRV_HDSPM_IOCTL_GET_CONFIG \
84 _IOR('H', 0x41, struct hdspm_config_info) 75 _IOR('H', 0x41, struct hdspm_config)
76
77/**
78 * If there's a TCO (TimeCode Option) board installed,
79 * there are further options and status data available.
80 * The hdspm_ltc structure contains the current SMPTE
81 * timecode and some status information and can be
82 * obtained via SNDRV_HDSPM_IOCTL_GET_LTC or in the
83 * hdspm_status struct.
84 **/
85
86enum hdspm_ltc_format {
87 format_invalid,
88 fps_24,
89 fps_25,
90 fps_2997,
91 fps_30
92};
93
94enum hdspm_ltc_frame {
95 frame_invalid,
96 drop_frame,
97 full_frame
98};
99
100enum hdspm_ltc_input_format {
101 ntsc,
102 pal,
103 no_video
104};
105
106struct hdspm_ltc {
107 unsigned int ltc;
85 108
109 enum hdspm_ltc_format format;
110 enum hdspm_ltc_frame frame;
111 enum hdspm_ltc_input_format input_format;
112};
113
114#define SNDRV_HDSPM_IOCTL_GET_LTC _IOR('H', 0x46, struct hdspm_mixer_ioctl)
115
116/**
117 * The status data reflects the device's current state
118 * as determined by the card's configuration and
119 * connection status.
120 **/
121
122enum hdspm_sync {
123 hdspm_sync_no_lock = 0,
124 hdspm_sync_lock = 1,
125 hdspm_sync_sync = 2
126};
86 127
87/* get Soundcard Version */ 128enum hdspm_madi_input {
129 hdspm_input_optical = 0,
130 hdspm_input_coax = 1
131};
132
133enum hdspm_madi_channel_format {
134 hdspm_format_ch_64 = 0,
135 hdspm_format_ch_56 = 1
136};
137
138enum hdspm_madi_frame_format {
139 hdspm_frame_48 = 0,
140 hdspm_frame_96 = 1
141};
142
143enum hdspm_syncsource {
144 syncsource_wc = 0,
145 syncsource_madi = 1,
146 syncsource_tco = 2,
147 syncsource_sync = 3,
148 syncsource_none = 4
149};
150
151struct hdspm_status {
152 uint8_t card_type; /* enum hdspm_io_type */
153 enum hdspm_syncsource autosync_source;
154
155 uint64_t card_clock;
156 uint32_t master_period;
157
158 union {
159 struct {
160 uint8_t sync_wc; /* enum hdspm_sync */
161 uint8_t sync_madi; /* enum hdspm_sync */
162 uint8_t sync_tco; /* enum hdspm_sync */
163 uint8_t sync_in; /* enum hdspm_sync */
164 uint8_t madi_input; /* enum hdspm_madi_input */
165 uint8_t channel_format; /* enum hdspm_madi_channel_format */
166 uint8_t frame_format; /* enum hdspm_madi_frame_format */
167 } madi;
168 } card_specific;
169};
170
171#define SNDRV_HDSPM_IOCTL_GET_STATUS \
172 _IOR('H', 0x47, struct hdspm_status)
173
174/**
175 * Get information about the card and its add-ons.
176 **/
177
178#define HDSPM_ADDON_TCO 1
88 179
89struct hdspm_version { 180struct hdspm_version {
181 uint8_t card_type; /* enum hdspm_io_type */
182 char cardname[20];
183 unsigned int serial;
90 unsigned short firmware_rev; 184 unsigned short firmware_rev;
185 int addons;
91}; 186};
92 187
93#define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x43, struct hdspm_version) 188#define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x48, struct hdspm_version)
94
95 189
96/* ------------- get Matrix Mixer IOCTL --------------- */ 190/* ------------- get Matrix Mixer IOCTL --------------- */
97 191
@@ -99,11 +193,11 @@ struct hdspm_version {
99 * 32768 Bytes 193 * 32768 Bytes
100 */ 194 */
101 195
102/* organisation is 64 channelfader in a continous memory block */ 196/* organisation is 64 channelfader in a continuous memory block */
103/* equivalent to hardware definition, maybe for future feature of mmap of 197/* equivalent to hardware definition, maybe for future feature of mmap of
104 * them 198 * them
105 */ 199 */
106/* each of 64 outputs has 64 infader and 64 outfader: 200/* each of 64 outputs has 64 infader and 64 outfader:
107 Ins to Outs mixer[out].in[in], Outstreams to Outs mixer[out].pb[pb] */ 201 Ins to Outs mixer[out].in[in], Outstreams to Outs mixer[out].pb[pb] */
108 202
109#define HDSPM_MIXER_CHANNELS HDSPM_MAX_CHANNELS 203#define HDSPM_MIXER_CHANNELS HDSPM_MAX_CHANNELS
@@ -131,4 +225,5 @@ typedef struct hdspm_version hdspm_version_t;
131typedef struct hdspm_channelfader snd_hdspm_channelfader_t; 225typedef struct hdspm_channelfader snd_hdspm_channelfader_t;
132typedef struct hdspm_mixer hdspm_mixer_t; 226typedef struct hdspm_mixer hdspm_mixer_t;
133 227
134#endif /* __SOUND_HDSPM_H */ 228
229#endif
diff --git a/include/sound/jack.h b/include/sound/jack.h
index d90b9fa32707..c140fc7cbd3f 100644
--- a/include/sound/jack.h
+++ b/include/sound/jack.h
@@ -47,6 +47,9 @@ enum snd_jack_types {
47 SND_JACK_BTN_0 = 0x4000, 47 SND_JACK_BTN_0 = 0x4000,
48 SND_JACK_BTN_1 = 0x2000, 48 SND_JACK_BTN_1 = 0x2000,
49 SND_JACK_BTN_2 = 0x1000, 49 SND_JACK_BTN_2 = 0x1000,
50 SND_JACK_BTN_3 = 0x0800,
51 SND_JACK_BTN_4 = 0x0400,
52 SND_JACK_BTN_5 = 0x0200,
50}; 53};
51 54
52struct snd_jack { 55struct snd_jack {
@@ -55,7 +58,7 @@ struct snd_jack {
55 int type; 58 int type;
56 const char *id; 59 const char *id;
57 char name[100]; 60 char name[100];
58 unsigned int key[3]; /* Keep in sync with definitions above */ 61 unsigned int key[6]; /* Keep in sync with definitions above */
59 void *private_data; 62 void *private_data;
60 void (*private_free)(struct snd_jack *); 63 void (*private_free)(struct snd_jack *);
61}; 64};
diff --git a/include/sound/max98088.h b/include/sound/max98088.h
new file mode 100644
index 000000000000..c3ba8239182d
--- /dev/null
+++ b/include/sound/max98088.h
@@ -0,0 +1,50 @@
1/*
2 * Platform data for MAX98088
3 *
4 * Copyright 2010 Maxim Integrated Products
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __SOUND_MAX98088_PDATA_H__
14#define __SOUND_MAX98088_PDATA_H__
15
16/* Equalizer filter response configuration */
17struct max98088_eq_cfg {
18 const char *name;
19 unsigned int rate;
20 u16 band1[5];
21 u16 band2[5];
22 u16 band3[5];
23 u16 band4[5];
24 u16 band5[5];
25};
26
27/* codec platform data */
28struct max98088_pdata {
29
30 /* Equalizers for DAI1 and DAI2 */
31 struct max98088_eq_cfg *eq_cfg;
32 unsigned int eq_cfgcnt;
33
34 /* Receiver output can be configured as power amplifier or LINE out */
35 /* Set receiver_mode to:
36 * 0 = amplifier output, or
37 * 1 = LINE level output
38 */
39 unsigned int receiver_mode:1;
40
41 /* Analog/digital microphone configuration:
42 * 0 = analog microphone input (normal setting)
43 * 1 = digital microphone input
44 */
45 unsigned int digmic_left_mode:1;
46 unsigned int digmic_right_mode:1;
47
48};
49
50#endif
diff --git a/include/sound/max98095.h b/include/sound/max98095.h
new file mode 100644
index 000000000000..7513a42dd4aa
--- /dev/null
+++ b/include/sound/max98095.h
@@ -0,0 +1,54 @@
1/*
2 * Platform data for MAX98095
3 *
4 * Copyright 2011 Maxim Integrated Products
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __SOUND_MAX98095_PDATA_H__
14#define __SOUND_MAX98095_PDATA_H__
15
16/* Equalizer filter response configuration */
17struct max98095_eq_cfg {
18 const char *name;
19 unsigned int rate;
20 u16 band1[5];
21 u16 band2[5];
22 u16 band3[5];
23 u16 band4[5];
24 u16 band5[5];
25};
26
27/* Biquad filter response configuration */
28struct max98095_biquad_cfg {
29 const char *name;
30 unsigned int rate;
31 u16 band1[5];
32 u16 band2[5];
33};
34
35/* codec platform data */
36struct max98095_pdata {
37
38 /* Equalizers for DAI1 and DAI2 */
39 struct max98095_eq_cfg *eq_cfg;
40 unsigned int eq_cfgcnt;
41
42 /* Biquad filter for DAI1 and DAI2 */
43 struct max98095_biquad_cfg *bq_cfg;
44 unsigned int bq_cfgcnt;
45
46 /* Analog/digital microphone configuration:
47 * 0 = analog microphone input (normal setting)
48 * 1 = digital microphone input
49 */
50 unsigned int digmic_left_mode:1;
51 unsigned int digmic_right_mode:1;
52};
53
54#endif
diff --git a/include/sound/minors.h b/include/sound/minors.h
index a81798ab73ed..8f764204a856 100644
--- a/include/sound/minors.h
+++ b/include/sound/minors.h
@@ -31,8 +31,8 @@
31/* these minors can still be used for autoloading devices (/dev/aload*) */ 31/* these minors can still be used for autoloading devices (/dev/aload*) */
32#define SNDRV_MINOR_CONTROL 0 /* 0 */ 32#define SNDRV_MINOR_CONTROL 0 /* 0 */
33#define SNDRV_MINOR_GLOBAL 1 /* 1 */ 33#define SNDRV_MINOR_GLOBAL 1 /* 1 */
34#define SNDRV_MINOR_SEQUENCER (SNDRV_MINOR_GLOBAL + 0 * 32) 34#define SNDRV_MINOR_SEQUENCER 1 /* SNDRV_MINOR_GLOBAL + 0 * 32 */
35#define SNDRV_MINOR_TIMER (SNDRV_MINOR_GLOBAL + 1 * 32) 35#define SNDRV_MINOR_TIMER 33 /* SNDRV_MINOR_GLOBAL + 1 * 32 */
36 36
37#ifndef CONFIG_SND_DYNAMIC_MINORS 37#ifndef CONFIG_SND_DYNAMIC_MINORS
38 /* 2 - 3 (reserved) */ 38 /* 2 - 3 (reserved) */
diff --git a/include/sound/mixer_oss.h b/include/sound/mixer_oss.h
index 51fbcb4a277a..13cb0b430a1b 100644
--- a/include/sound/mixer_oss.h
+++ b/include/sound/mixer_oss.h
@@ -73,6 +73,9 @@ struct snd_mixer_oss_file {
73 struct snd_mixer_oss *mixer; 73 struct snd_mixer_oss *mixer;
74}; 74};
75 75
76int snd_mixer_oss_ioctl_card(struct snd_card *card,
77 unsigned int cmd, unsigned long arg);
78
76#endif /* CONFIG_SND_MIXER_OSS */ 79#endif /* CONFIG_SND_MIXER_OSS */
77 80
78#endif /* __SOUND_MIXER_OSS_H */ 81#endif /* __SOUND_MIXER_OSS_H */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 85f1c6bf8566..e1bad1130616 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -136,48 +136,49 @@ struct snd_pcm_ops {
136 SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000) 136 SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)
137#define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\ 137#define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
138 SNDRV_PCM_RATE_192000) 138 SNDRV_PCM_RATE_192000)
139#define SNDRV_PCM_FMTBIT_S8 (1ULL << SNDRV_PCM_FORMAT_S8) 139#define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
140#define SNDRV_PCM_FMTBIT_U8 (1ULL << SNDRV_PCM_FORMAT_U8) 140#define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8)
141#define SNDRV_PCM_FMTBIT_S16_LE (1ULL << SNDRV_PCM_FORMAT_S16_LE) 141#define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8)
142#define SNDRV_PCM_FMTBIT_S16_BE (1ULL << SNDRV_PCM_FORMAT_S16_BE) 142#define SNDRV_PCM_FMTBIT_S16_LE _SNDRV_PCM_FMTBIT(S16_LE)
143#define SNDRV_PCM_FMTBIT_U16_LE (1ULL << SNDRV_PCM_FORMAT_U16_LE) 143#define SNDRV_PCM_FMTBIT_S16_BE _SNDRV_PCM_FMTBIT(S16_BE)
144#define SNDRV_PCM_FMTBIT_U16_BE (1ULL << SNDRV_PCM_FORMAT_U16_BE) 144#define SNDRV_PCM_FMTBIT_U16_LE _SNDRV_PCM_FMTBIT(U16_LE)
145#define SNDRV_PCM_FMTBIT_S24_LE (1ULL << SNDRV_PCM_FORMAT_S24_LE) 145#define SNDRV_PCM_FMTBIT_U16_BE _SNDRV_PCM_FMTBIT(U16_BE)
146#define SNDRV_PCM_FMTBIT_S24_BE (1ULL << SNDRV_PCM_FORMAT_S24_BE) 146#define SNDRV_PCM_FMTBIT_S24_LE _SNDRV_PCM_FMTBIT(S24_LE)
147#define SNDRV_PCM_FMTBIT_U24_LE (1ULL << SNDRV_PCM_FORMAT_U24_LE) 147#define SNDRV_PCM_FMTBIT_S24_BE _SNDRV_PCM_FMTBIT(S24_BE)
148#define SNDRV_PCM_FMTBIT_U24_BE (1ULL << SNDRV_PCM_FORMAT_U24_BE) 148#define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE)
149#define SNDRV_PCM_FMTBIT_S32_LE (1ULL << SNDRV_PCM_FORMAT_S32_LE) 149#define SNDRV_PCM_FMTBIT_U24_BE _SNDRV_PCM_FMTBIT(U24_BE)
150#define SNDRV_PCM_FMTBIT_S32_BE (1ULL << SNDRV_PCM_FORMAT_S32_BE) 150#define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE)
151#define SNDRV_PCM_FMTBIT_U32_LE (1ULL << SNDRV_PCM_FORMAT_U32_LE) 151#define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE)
152#define SNDRV_PCM_FMTBIT_U32_BE (1ULL << SNDRV_PCM_FORMAT_U32_BE) 152#define SNDRV_PCM_FMTBIT_U32_LE _SNDRV_PCM_FMTBIT(U32_LE)
153#define SNDRV_PCM_FMTBIT_FLOAT_LE (1ULL << SNDRV_PCM_FORMAT_FLOAT_LE) 153#define SNDRV_PCM_FMTBIT_U32_BE _SNDRV_PCM_FMTBIT(U32_BE)
154#define SNDRV_PCM_FMTBIT_FLOAT_BE (1ULL << SNDRV_PCM_FORMAT_FLOAT_BE) 154#define SNDRV_PCM_FMTBIT_FLOAT_LE _SNDRV_PCM_FMTBIT(FLOAT_LE)
155#define SNDRV_PCM_FMTBIT_FLOAT64_LE (1ULL << SNDRV_PCM_FORMAT_FLOAT64_LE) 155#define SNDRV_PCM_FMTBIT_FLOAT_BE _SNDRV_PCM_FMTBIT(FLOAT_BE)
156#define SNDRV_PCM_FMTBIT_FLOAT64_BE (1ULL << SNDRV_PCM_FORMAT_FLOAT64_BE) 156#define SNDRV_PCM_FMTBIT_FLOAT64_LE _SNDRV_PCM_FMTBIT(FLOAT64_LE)
157#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE) 157#define SNDRV_PCM_FMTBIT_FLOAT64_BE _SNDRV_PCM_FMTBIT(FLOAT64_BE)
158#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE) 158#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE)
159#define SNDRV_PCM_FMTBIT_MU_LAW (1ULL << SNDRV_PCM_FORMAT_MU_LAW) 159#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE)
160#define SNDRV_PCM_FMTBIT_A_LAW (1ULL << SNDRV_PCM_FORMAT_A_LAW) 160#define SNDRV_PCM_FMTBIT_MU_LAW _SNDRV_PCM_FMTBIT(MU_LAW)
161#define SNDRV_PCM_FMTBIT_IMA_ADPCM (1ULL << SNDRV_PCM_FORMAT_IMA_ADPCM) 161#define SNDRV_PCM_FMTBIT_A_LAW _SNDRV_PCM_FMTBIT(A_LAW)
162#define SNDRV_PCM_FMTBIT_MPEG (1ULL << SNDRV_PCM_FORMAT_MPEG) 162#define SNDRV_PCM_FMTBIT_IMA_ADPCM _SNDRV_PCM_FMTBIT(IMA_ADPCM)
163#define SNDRV_PCM_FMTBIT_GSM (1ULL << SNDRV_PCM_FORMAT_GSM) 163#define SNDRV_PCM_FMTBIT_MPEG _SNDRV_PCM_FMTBIT(MPEG)
164#define SNDRV_PCM_FMTBIT_SPECIAL (1ULL << SNDRV_PCM_FORMAT_SPECIAL) 164#define SNDRV_PCM_FMTBIT_GSM _SNDRV_PCM_FMTBIT(GSM)
165#define SNDRV_PCM_FMTBIT_S24_3LE (1ULL << SNDRV_PCM_FORMAT_S24_3LE) 165#define SNDRV_PCM_FMTBIT_SPECIAL _SNDRV_PCM_FMTBIT(SPECIAL)
166#define SNDRV_PCM_FMTBIT_U24_3LE (1ULL << SNDRV_PCM_FORMAT_U24_3LE) 166#define SNDRV_PCM_FMTBIT_S24_3LE _SNDRV_PCM_FMTBIT(S24_3LE)
167#define SNDRV_PCM_FMTBIT_S24_3BE (1ULL << SNDRV_PCM_FORMAT_S24_3BE) 167#define SNDRV_PCM_FMTBIT_U24_3LE _SNDRV_PCM_FMTBIT(U24_3LE)
168#define SNDRV_PCM_FMTBIT_U24_3BE (1ULL << SNDRV_PCM_FORMAT_U24_3BE) 168#define SNDRV_PCM_FMTBIT_S24_3BE _SNDRV_PCM_FMTBIT(S24_3BE)
169#define SNDRV_PCM_FMTBIT_S20_3LE (1ULL << SNDRV_PCM_FORMAT_S20_3LE) 169#define SNDRV_PCM_FMTBIT_U24_3BE _SNDRV_PCM_FMTBIT(U24_3BE)
170#define SNDRV_PCM_FMTBIT_U20_3LE (1ULL << SNDRV_PCM_FORMAT_U20_3LE) 170#define SNDRV_PCM_FMTBIT_S20_3LE _SNDRV_PCM_FMTBIT(S20_3LE)
171#define SNDRV_PCM_FMTBIT_S20_3BE (1ULL << SNDRV_PCM_FORMAT_S20_3BE) 171#define SNDRV_PCM_FMTBIT_U20_3LE _SNDRV_PCM_FMTBIT(U20_3LE)
172#define SNDRV_PCM_FMTBIT_U20_3BE (1ULL << SNDRV_PCM_FORMAT_U20_3BE) 172#define SNDRV_PCM_FMTBIT_S20_3BE _SNDRV_PCM_FMTBIT(S20_3BE)
173#define SNDRV_PCM_FMTBIT_S18_3LE (1ULL << SNDRV_PCM_FORMAT_S18_3LE) 173#define SNDRV_PCM_FMTBIT_U20_3BE _SNDRV_PCM_FMTBIT(U20_3BE)
174#define SNDRV_PCM_FMTBIT_U18_3LE (1ULL << SNDRV_PCM_FORMAT_U18_3LE) 174#define SNDRV_PCM_FMTBIT_S18_3LE _SNDRV_PCM_FMTBIT(S18_3LE)
175#define SNDRV_PCM_FMTBIT_S18_3BE (1ULL << SNDRV_PCM_FORMAT_S18_3BE) 175#define SNDRV_PCM_FMTBIT_U18_3LE _SNDRV_PCM_FMTBIT(U18_3LE)
176#define SNDRV_PCM_FMTBIT_U18_3BE (1ULL << SNDRV_PCM_FORMAT_U18_3BE) 176#define SNDRV_PCM_FMTBIT_S18_3BE _SNDRV_PCM_FMTBIT(S18_3BE)
177#define SNDRV_PCM_FMTBIT_G723_24 (1ULL << SNDRV_PCM_FORMAT_G723_24) 177#define SNDRV_PCM_FMTBIT_U18_3BE _SNDRV_PCM_FMTBIT(U18_3BE)
178#define SNDRV_PCM_FMTBIT_G723_24_1B (1ULL << SNDRV_PCM_FORMAT_G723_24_1B) 178#define SNDRV_PCM_FMTBIT_G723_24 _SNDRV_PCM_FMTBIT(G723_24)
179#define SNDRV_PCM_FMTBIT_G723_40 (1ULL << SNDRV_PCM_FORMAT_G723_40) 179#define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B)
180#define SNDRV_PCM_FMTBIT_G723_40_1B (1ULL << SNDRV_PCM_FORMAT_G723_40_1B) 180#define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40)
181#define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B)
181 182
182#ifdef SNDRV_LITTLE_ENDIAN 183#ifdef SNDRV_LITTLE_ENDIAN
183#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE 184#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE
@@ -278,6 +279,7 @@ struct snd_pcm_runtime {
278 snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */ 279 snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */
279 snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time */ 280 snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time */
280 unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */ 281 unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */
282 unsigned long hw_ptr_buffer_jiffies; /* buffer time in jiffies */
281 snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */ 283 snd_pcm_sframes_t delay; /* extra delay; typically FIFO size */
282 284
283 /* -- HW params -- */ 285 /* -- HW params -- */
@@ -296,6 +298,7 @@ struct snd_pcm_runtime {
296 unsigned int info; 298 unsigned int info;
297 unsigned int rate_num; 299 unsigned int rate_num;
298 unsigned int rate_den; 300 unsigned int rate_den;
301 unsigned int no_period_wakeup: 1;
299 302
300 /* -- SW params -- */ 303 /* -- SW params -- */
301 int tstamp_mode; /* mmap timestamp is updated */ 304 int tstamp_mode; /* mmap timestamp is updated */
@@ -488,7 +491,7 @@ int snd_pcm_info_user(struct snd_pcm_substream *substream,
488int snd_pcm_status(struct snd_pcm_substream *substream, 491int snd_pcm_status(struct snd_pcm_substream *substream,
489 struct snd_pcm_status *status); 492 struct snd_pcm_status *status);
490int snd_pcm_start(struct snd_pcm_substream *substream); 493int snd_pcm_start(struct snd_pcm_substream *substream);
491int snd_pcm_stop(struct snd_pcm_substream *substream, int status); 494int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
492int snd_pcm_drain_done(struct snd_pcm_substream *substream); 495int snd_pcm_drain_done(struct snd_pcm_substream *substream);
493#ifdef CONFIG_PM 496#ifdef CONFIG_PM
494int snd_pcm_suspend(struct snd_pcm_substream *substream); 497int snd_pcm_suspend(struct snd_pcm_substream *substream);
@@ -746,8 +749,8 @@ static inline const struct snd_interval *hw_param_interval_c(const struct snd_pc
746 return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; 749 return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
747} 750}
748 751
749#define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS)) 752#define params_access(p) ((__force snd_pcm_access_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS)))
750#define params_format(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT)) 753#define params_format(p) ((__force snd_pcm_format_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT)))
751#define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT)) 754#define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
752#define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min 755#define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min
753#define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min 756#define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min
@@ -1028,9 +1031,7 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_s
1028#define snd_pcm_lib_mmap_iomem NULL 1031#define snd_pcm_lib_mmap_iomem NULL
1029#endif 1032#endif
1030 1033
1031int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream, 1034#define snd_pcm_lib_mmap_vmalloc NULL
1032 struct vm_area_struct *area);
1033#define snd_pcm_lib_mmap_vmalloc snd_pcm_lib_mmap_noncached
1034 1035
1035static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max) 1036static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
1036{ 1037{
diff --git a/include/sound/sb16_csp.h b/include/sound/sb16_csp.h
index 736eac71d053..af1b49e982df 100644
--- a/include/sound/sb16_csp.h
+++ b/include/sound/sb16_csp.h
@@ -99,7 +99,14 @@ struct snd_sb_csp_info {
99/* get CSP information */ 99/* get CSP information */
100#define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info) 100#define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info)
101/* load microcode to CSP */ 101/* load microcode to CSP */
102#define SNDRV_SB_CSP_IOCTL_LOAD_CODE _IOW('H', 0x11, struct snd_sb_csp_microcode) 102/* NOTE: struct snd_sb_csp_microcode overflows the max size (13 bits)
103 * defined for some architectures like MIPS, and it leads to build errors.
104 * (x86 and co have 14-bit size, thus it's valid, though.)
105 * As a workaround for skipping the size-limit check, here we don't use the
106 * normal _IOW() macro but _IOC() with the manual argument.
107 */
108#define SNDRV_SB_CSP_IOCTL_LOAD_CODE \
109 _IOC(_IOC_WRITE, 'H', 0x11, sizeof(struct snd_sb_csp_microcode))
103/* unload microcode from CSP */ 110/* unload microcode from CSP */
104#define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12) 111#define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12)
105/* start CSP */ 112/* start CSP */
diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h
index 9d51d6f35893..9a155f9d0a12 100644
--- a/include/sound/sh_fsi.h
+++ b/include/sound/sh_fsi.h
@@ -15,67 +15,29 @@
15#define FSI_PORT_A 0 15#define FSI_PORT_A 0
16#define FSI_PORT_B 1 16#define FSI_PORT_B 1
17 17
18/* flags format
19
20 * 0xABCDEEFF
21 *
22 * A: channel size for TDM (input)
23 * B: channel size for TDM (ooutput)
24 * C: inversion
25 * D: mode
26 * E: input format
27 * F: output format
28 */
29
30#include <linux/clk.h> 18#include <linux/clk.h>
31#include <sound/soc.h> 19#include <sound/soc.h>
32 20
33/* TDM channel */ 21/*
34#define SH_FSI_SET_CH_I(x) ((x & 0xF) << 28) 22 * flags format
35#define SH_FSI_SET_CH_O(x) ((x & 0xF) << 24) 23 *
36 24 * 0x000000BA
37#define SH_FSI_CH_IMASK 0xF0000000 25 *
38#define SH_FSI_CH_OMASK 0x0F000000 26 * A: inversion
39#define SH_FSI_GET_CH_I(x) ((x & SH_FSI_CH_IMASK) >> 28) 27 * B: format mode
40#define SH_FSI_GET_CH_O(x) ((x & SH_FSI_CH_OMASK) >> 24) 28 */
41
42/* clock inversion */
43#define SH_FSI_INVERSION_MASK 0x00F00000
44#define SH_FSI_LRM_INV (1 << 20)
45#define SH_FSI_BRM_INV (1 << 21)
46#define SH_FSI_LRS_INV (1 << 22)
47#define SH_FSI_BRS_INV (1 << 23)
48
49/* mode */
50#define SH_FSI_MODE_MASK 0x000F0000
51#define SH_FSI_IN_SLAVE_MODE (1 << 16) /* default master mode */
52#define SH_FSI_OUT_SLAVE_MODE (1 << 17) /* default master mode */
53
54/* DI format */
55#define SH_FSI_FMT_MASK 0x000000FF
56#define SH_FSI_IFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 8)
57#define SH_FSI_OFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 0)
58#define SH_FSI_GET_IFMT(x) ((x >> 8) & SH_FSI_FMT_MASK)
59#define SH_FSI_GET_OFMT(x) ((x >> 0) & SH_FSI_FMT_MASK)
60
61#define SH_FSI_FMT_MONO 0
62#define SH_FSI_FMT_MONO_DELAY 1
63#define SH_FSI_FMT_PCM 2
64#define SH_FSI_FMT_I2S 3
65#define SH_FSI_FMT_TDM 4
66#define SH_FSI_FMT_TDM_DELAY 5
67#define SH_FSI_FMT_SPDIF 6
68
69 29
70#define SH_FSI_IFMT_TDM_CH(x) \ 30/* A: clock inversion */
71 (SH_FSI_IFMT(TDM) | SH_FSI_SET_CH_I(x)) 31#define SH_FSI_INVERSION_MASK 0x0000000F
72#define SH_FSI_IFMT_TDM_DELAY_CH(x) \ 32#define SH_FSI_LRM_INV (1 << 0)
73 (SH_FSI_IFMT(TDM_DELAY) | SH_FSI_SET_CH_I(x)) 33#define SH_FSI_BRM_INV (1 << 1)
34#define SH_FSI_LRS_INV (1 << 2)
35#define SH_FSI_BRS_INV (1 << 3)
74 36
75#define SH_FSI_OFMT_TDM_CH(x) \ 37/* B: format mode */
76 (SH_FSI_OFMT(TDM) | SH_FSI_SET_CH_O(x)) 38#define SH_FSI_FMT_MASK 0x000000F0
77#define SH_FSI_OFMT_TDM_DELAY_CH(x) \ 39#define SH_FSI_FMT_DAI (0 << 4)
78 (SH_FSI_OFMT(TDM_DELAY) | SH_FSI_SET_CH_O(x)) 40#define SH_FSI_FMT_SPDIF (1 << 4)
79 41
80 42
81/* 43/*
@@ -85,7 +47,9 @@
85 * ACK_MD (FSI2) 47 * ACK_MD (FSI2)
86 * CKG1 (FSI) 48 * CKG1 (FSI)
87 * 49 *
88 * err: return value < 0 50 * err : return value < 0
51 * no change : return value == 0
52 * change xMD : return value > 0
89 * 53 *
90 * 0x-00000AB 54 * 0x-00000AB
91 * 55 *
@@ -111,10 +75,7 @@
111struct sh_fsi_platform_info { 75struct sh_fsi_platform_info {
112 unsigned long porta_flags; 76 unsigned long porta_flags;
113 unsigned long portb_flags; 77 unsigned long portb_flags;
114 int (*set_rate)(int is_porta, int rate); /* for master mode */ 78 int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
115}; 79};
116 80
117extern struct snd_soc_dai fsi_soc_dai[2];
118extern struct snd_soc_platform fsi_soc_platform;
119
120#endif /* __SOUND_FSI_H */ 81#endif /* __SOUND_FSI_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 377693a14385..1bafe95dcf41 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -16,8 +16,6 @@
16 16
17#include <linux/list.h> 17#include <linux/list.h>
18 18
19#include <sound/soc.h>
20
21struct snd_pcm_substream; 19struct snd_pcm_substream;
22 20
23/* 21/*
@@ -91,15 +89,17 @@ struct snd_pcm_substream;
91 SNDRV_PCM_FMTBIT_S32_LE |\ 89 SNDRV_PCM_FMTBIT_S32_LE |\
92 SNDRV_PCM_FMTBIT_S32_BE) 90 SNDRV_PCM_FMTBIT_S32_BE)
93 91
94struct snd_soc_dai_ops; 92struct snd_soc_dai_driver;
95struct snd_soc_dai; 93struct snd_soc_dai;
96struct snd_ac97_bus_ops; 94struct snd_ac97_bus_ops;
97 95
98/* Digital Audio Interface registration */ 96/* Digital Audio Interface registration */
99int snd_soc_register_dai(struct snd_soc_dai *dai); 97int snd_soc_register_dai(struct device *dev,
100void snd_soc_unregister_dai(struct snd_soc_dai *dai); 98 struct snd_soc_dai_driver *dai_drv);
101int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count); 99void snd_soc_unregister_dai(struct device *dev);
102void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count); 100int snd_soc_register_dais(struct device *dev,
101 struct snd_soc_dai_driver *dai_drv, size_t count);
102void snd_soc_unregister_dais(struct device *dev, size_t count);
103 103
104/* Digital Audio Interface clocking API.*/ 104/* Digital Audio Interface clocking API.*/
105int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, 105int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
@@ -126,16 +126,6 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
126/* Digital Audio Interface mute */ 126/* Digital Audio Interface mute */
127int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute); 127int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute);
128 128
129/*
130 * Digital Audio Interface.
131 *
132 * Describes the Digital Audio Interface in terms of its ALSA, DAI and AC97
133 * operations and capabilities. Codec and platform drivers will register this
134 * structure for every DAI they have.
135 *
136 * This structure covers the clocking, formating and ALSA operations for each
137 * interface.
138 */
139struct snd_soc_dai_ops { 129struct snd_soc_dai_ops {
140 /* 130 /*
141 * DAI clocking configuration, all optional. 131 * DAI clocking configuration, all optional.
@@ -191,54 +181,79 @@ struct snd_soc_dai_ops {
191}; 181};
192 182
193/* 183/*
194 * Digital Audio Interface runtime data. 184 * Digital Audio Interface Driver.
195 * 185 *
196 * Holds runtime data for a DAI. 186 * Describes the Digital Audio Interface in terms of its ALSA, DAI and AC97
187 * operations and capabilities. Codec and platform drivers will register this
188 * structure for every DAI they have.
189 *
190 * This structure covers the clocking, formating and ALSA operations for each
191 * interface.
197 */ 192 */
198struct snd_soc_dai { 193struct snd_soc_dai_driver {
199 /* DAI description */ 194 /* DAI description */
200 char *name; 195 const char *name;
201 unsigned int id; 196 unsigned int id;
202 int ac97_control; 197 int ac97_control;
203 198
204 struct device *dev; 199 /* DAI driver callbacks */
205 void *ac97_pdata; /* platform_data for the ac97 codec */ 200 int (*probe)(struct snd_soc_dai *dai);
206 201 int (*remove)(struct snd_soc_dai *dai);
207 /* DAI callbacks */
208 int (*probe)(struct platform_device *pdev,
209 struct snd_soc_dai *dai);
210 void (*remove)(struct platform_device *pdev,
211 struct snd_soc_dai *dai);
212 int (*suspend)(struct snd_soc_dai *dai); 202 int (*suspend)(struct snd_soc_dai *dai);
213 int (*resume)(struct snd_soc_dai *dai); 203 int (*resume)(struct snd_soc_dai *dai);
214 204
215 /* ops */ 205 /* ops */
216 struct snd_soc_dai_ops *ops; 206 const struct snd_soc_dai_ops *ops;
217 207
218 /* DAI capabilities */ 208 /* DAI capabilities */
219 struct snd_soc_pcm_stream capture; 209 struct snd_soc_pcm_stream capture;
220 struct snd_soc_pcm_stream playback; 210 struct snd_soc_pcm_stream playback;
221 unsigned int symmetric_rates:1; 211 unsigned int symmetric_rates:1;
212};
213
214/*
215 * Digital Audio Interface runtime data.
216 *
217 * Holds runtime data for a DAI.
218 */
219struct snd_soc_dai {
220 const char *name;
221 int id;
222 struct device *dev;
223 void *ac97_pdata; /* platform_data for the ac97 codec */
224
225 /* driver ops */
226 struct snd_soc_dai_driver *driver;
222 227
223 /* DAI runtime info */ 228 /* DAI runtime info */
224 struct snd_soc_codec *codec; 229 unsigned int capture_active:1; /* stream is in use */
230 unsigned int playback_active:1; /* stream is in use */
231 unsigned int symmetric_rates:1;
232 struct snd_pcm_runtime *runtime;
225 unsigned int active; 233 unsigned int active;
226 unsigned char pop_wait:1; 234 unsigned char pop_wait:1;
235 unsigned char probed:1;
227 236
228 /* DAI private data */ 237 /* DAI DMA data */
229 void *private_data; 238 void *playback_dma_data;
239 void *capture_dma_data;
230 240
231 /* parent platform */ 241 /* parent platform/codec */
232 struct snd_soc_platform *platform; 242 union {
243 struct snd_soc_platform *platform;
244 struct snd_soc_codec *codec;
245 };
246 struct snd_soc_card *card;
233 247
234 struct list_head list; 248 struct list_head list;
249 struct list_head card_list;
235}; 250};
236 251
237static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai, 252static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai,
238 const struct snd_pcm_substream *ss) 253 const struct snd_pcm_substream *ss)
239{ 254{
240 return (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 255 return (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
241 dai->playback.dma_data : dai->capture.dma_data; 256 dai->playback_dma_data : dai->capture_dma_data;
242} 257}
243 258
244static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai, 259static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai,
@@ -246,9 +261,20 @@ static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai,
246 void *data) 261 void *data)
247{ 262{
248 if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) 263 if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
249 dai->playback.dma_data = data; 264 dai->playback_dma_data = data;
250 else 265 else
251 dai->capture.dma_data = data; 266 dai->capture_dma_data = data;
267}
268
269static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai,
270 void *data)
271{
272 dev_set_drvdata(dai->dev, data);
273}
274
275static inline void *snd_soc_dai_get_drvdata(struct snd_soc_dai *dai)
276{
277 return dev_get_drvdata(dai->dev);
252} 278}
253 279
254#endif 280#endif
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index c5d9987bc897..c46e7d89561d 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -16,7 +16,6 @@
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <sound/control.h> 18#include <sound/control.h>
19#include <sound/soc.h>
20 19
21/* widget has no PM register bit */ 20/* widget has no PM register bit */
22#define SND_SOC_NOPM -1 21#define SND_SOC_NOPM -1
@@ -24,8 +23,8 @@
24/* 23/*
25 * SoC dynamic audio power management 24 * SoC dynamic audio power management
26 * 25 *
27 * We can have upto 4 power domains 26 * We can have up to 4 power domains
28 * 1. Codec domain - VREF, VMID 27 * 1. Codec domain - VREF, VMID
29 * Usually controlled at codec probe/remove, although can be set 28 * Usually controlled at codec probe/remove, although can be set
30 * at stream time if power is not needed for sidetone, etc. 29 * at stream time if power is not needed for sidetone, etc.
31 * 2. Platform/Machine domain - physically connected inputs and outputs 30 * 2. Platform/Machine domain - physically connected inputs and outputs
@@ -40,141 +39,180 @@
40 39
41/* codec domain */ 40/* codec domain */
42#define SND_SOC_DAPM_VMID(wname) \ 41#define SND_SOC_DAPM_VMID(wname) \
43{ .id = snd_soc_dapm_vmid, .name = wname, .kcontrols = NULL, \ 42{ .id = snd_soc_dapm_vmid, .name = wname, .kcontrol_news = NULL, \
44 .num_kcontrols = 0} 43 .num_kcontrols = 0}
45 44
46/* platform domain */ 45/* platform domain */
47#define SND_SOC_DAPM_INPUT(wname) \ 46#define SND_SOC_DAPM_INPUT(wname) \
48{ .id = snd_soc_dapm_input, .name = wname, .kcontrols = NULL, \ 47{ .id = snd_soc_dapm_input, .name = wname, .kcontrol_news = NULL, \
49 .num_kcontrols = 0} 48 .num_kcontrols = 0, .reg = SND_SOC_NOPM }
50#define SND_SOC_DAPM_OUTPUT(wname) \ 49#define SND_SOC_DAPM_OUTPUT(wname) \
51{ .id = snd_soc_dapm_output, .name = wname, .kcontrols = NULL, \ 50{ .id = snd_soc_dapm_output, .name = wname, .kcontrol_news = NULL, \
52 .num_kcontrols = 0} 51 .num_kcontrols = 0, .reg = SND_SOC_NOPM }
53#define SND_SOC_DAPM_MIC(wname, wevent) \ 52#define SND_SOC_DAPM_MIC(wname, wevent) \
54{ .id = snd_soc_dapm_mic, .name = wname, .kcontrols = NULL, \ 53{ .id = snd_soc_dapm_mic, .name = wname, .kcontrol_news = NULL, \
55 .num_kcontrols = 0, .event = wevent, \ 54 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
56 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} 55 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
57#define SND_SOC_DAPM_HP(wname, wevent) \ 56#define SND_SOC_DAPM_HP(wname, wevent) \
58{ .id = snd_soc_dapm_hp, .name = wname, .kcontrols = NULL, \ 57{ .id = snd_soc_dapm_hp, .name = wname, .kcontrol_news = NULL, \
59 .num_kcontrols = 0, .event = wevent, \ 58 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
60 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} 59 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
61#define SND_SOC_DAPM_SPK(wname, wevent) \ 60#define SND_SOC_DAPM_SPK(wname, wevent) \
62{ .id = snd_soc_dapm_spk, .name = wname, .kcontrols = NULL, \ 61{ .id = snd_soc_dapm_spk, .name = wname, .kcontrol_news = NULL, \
63 .num_kcontrols = 0, .event = wevent, \ 62 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
64 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} 63 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
65#define SND_SOC_DAPM_LINE(wname, wevent) \ 64#define SND_SOC_DAPM_LINE(wname, wevent) \
66{ .id = snd_soc_dapm_line, .name = wname, .kcontrols = NULL, \ 65{ .id = snd_soc_dapm_line, .name = wname, .kcontrol_news = NULL, \
67 .num_kcontrols = 0, .event = wevent, \ 66 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
68 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD} 67 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
69 68
70/* path domain */ 69/* path domain */
71#define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\ 70#define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\
72 wcontrols, wncontrols) \ 71 wcontrols, wncontrols) \
73{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ 72{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
74 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} 73 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
74#define SND_SOC_DAPM_OUT_DRV(wname, wreg, wshift, winvert,\
75 wcontrols, wncontrols) \
76{ .id = snd_soc_dapm_out_drv, .name = wname, .reg = wreg, .shift = wshift, \
77 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
75#define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \ 78#define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \
76 wcontrols, wncontrols)\ 79 wcontrols, wncontrols)\
77{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 80{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
78 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} 81 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
79#define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \ 82#define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \
80 wcontrols, wncontrols)\ 83 wcontrols, wncontrols)\
81{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \ 84{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \
82 .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ 85 .shift = wshift, .invert = winvert, .kcontrol_news = wcontrols, \
83 .num_kcontrols = wncontrols} 86 .num_kcontrols = wncontrols}
84#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \ 87#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \
85{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ 88{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
86 .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0} 89 .invert = winvert, .kcontrol_news = NULL, .num_kcontrols = 0}
87#define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \ 90#define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \
88{ .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ 91{ .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \
89 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} 92 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = 1}
90#define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \ 93#define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \
91{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ 94{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
92 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} 95 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = 1}
96#define SND_SOC_DAPM_VIRT_MUX(wname, wreg, wshift, winvert, wcontrols) \
97{ .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \
98 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = 1}
93#define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \ 99#define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \
94{ .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \ 100{ .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \
95 .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ 101 .shift = wshift, .invert = winvert, .kcontrol_news = wcontrols, \
96 .num_kcontrols = 1} 102 .num_kcontrols = 1}
97 103
98/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ 104/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
99#define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\ 105#define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\
100 wcontrols) \ 106 wcontrols) \
101{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ 107{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
102 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} 108 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
103#define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \ 109#define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \
104 wcontrols)\ 110 wcontrols)\
105{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 111{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
106 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)} 112 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
107#define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \ 113#define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \
108 wcontrols)\ 114 wcontrols)\
109{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \ 115{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \
110 .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ 116 .shift = wshift, .invert = winvert, .kcontrol_news = wcontrols, \
111 .num_kcontrols = ARRAY_SIZE(wcontrols)} 117 .num_kcontrols = ARRAY_SIZE(wcontrols)}
112 118
113/* path domain with event - event handler must return 0 for success */ 119/* path domain with event - event handler must return 0 for success */
114#define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \ 120#define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \
115 wncontrols, wevent, wflags) \ 121 wncontrols, wevent, wflags) \
116{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ 122{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
117 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ 123 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
124 .event = wevent, .event_flags = wflags}
125#define SND_SOC_DAPM_OUT_DRV_E(wname, wreg, wshift, winvert, wcontrols, \
126 wncontrols, wevent, wflags) \
127{ .id = snd_soc_dapm_out_drv, .name = wname, .reg = wreg, .shift = wshift, \
128 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
118 .event = wevent, .event_flags = wflags} 129 .event = wevent, .event_flags = wflags}
119#define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \ 130#define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \
120 wncontrols, wevent, wflags) \ 131 wncontrols, wevent, wflags) \
121{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 132{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
122 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ 133 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
123 .event = wevent, .event_flags = wflags} 134 .event = wevent, .event_flags = wflags}
124#define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \ 135#define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \
125 wcontrols, wncontrols, wevent, wflags) \ 136 wcontrols, wncontrols, wevent, wflags) \
126{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 137{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
127 .invert = winvert, .kcontrols = wcontrols, \ 138 .invert = winvert, .kcontrol_news = wcontrols, \
128 .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags} 139 .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags}
129#define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \ 140#define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \
130{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ 141{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
131 .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \ 142 .invert = winvert, .kcontrol_news = NULL, .num_kcontrols = 0, \
132 .event = wevent, .event_flags = wflags} 143 .event = wevent, .event_flags = wflags}
133#define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \ 144#define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \
134 wevent, wflags) \ 145 wevent, wflags) \
135{ .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \ 146{ .id = snd_soc_dapm_switch, .name = wname, .reg = wreg, .shift = wshift, \
136 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ 147 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = 1, \
137 .event = wevent, .event_flags = wflags} 148 .event = wevent, .event_flags = wflags}
138#define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ 149#define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
139 wevent, wflags) \ 150 wevent, wflags) \
140{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ 151{ .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \
141 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ 152 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = 1, \
153 .event = wevent, .event_flags = wflags}
154#define SND_SOC_DAPM_VIRT_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
155 wevent, wflags) \
156{ .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \
157 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = 1, \
142 .event = wevent, .event_flags = wflags} 158 .event = wevent, .event_flags = wflags}
143 159
160/* additional sequencing control within an event type */
161#define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \
162 wevent, wflags) \
163{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
164 .invert = winvert, .event = wevent, .event_flags = wflags, \
165 .subseq = wsubseq}
166#define SND_SOC_DAPM_SUPPLY_S(wname, wsubseq, wreg, wshift, winvert, wevent, \
167 wflags) \
168{ .id = snd_soc_dapm_supply, .name = wname, .reg = wreg, \
169 .shift = wshift, .invert = winvert, .event = wevent, \
170 .event_flags = wflags, .subseq = wsubseq}
171
144/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ 172/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
145#define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ 173#define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
146 wevent, wflags) \ 174 wevent, wflags) \
147{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \ 175{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
148 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ 176 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
149 .event = wevent, .event_flags = wflags} 177 .event = wevent, .event_flags = wflags}
150#define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ 178#define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
151 wevent, wflags) \ 179 wevent, wflags) \
152{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 180{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
153 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \ 181 .invert = winvert, .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
154 .event = wevent, .event_flags = wflags} 182 .event = wevent, .event_flags = wflags}
155#define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \ 183#define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \
156 wcontrols, wevent, wflags) \ 184 wcontrols, wevent, wflags) \
157{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 185{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
158 .invert = winvert, .kcontrols = wcontrols, \ 186 .invert = winvert, .kcontrol_news = wcontrols, \
159 .num_kcontrols = ARRAY_SIZE(wcontrols), .event = wevent, .event_flags = wflags} 187 .num_kcontrols = ARRAY_SIZE(wcontrols), .event = wevent, .event_flags = wflags}
160 188
161/* events that are pre and post DAPM */ 189/* events that are pre and post DAPM */
162#define SND_SOC_DAPM_PRE(wname, wevent) \ 190#define SND_SOC_DAPM_PRE(wname, wevent) \
163{ .id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \ 191{ .id = snd_soc_dapm_pre, .name = wname, .kcontrol_news = NULL, \
164 .num_kcontrols = 0, .event = wevent, \ 192 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
165 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD} 193 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD}
166#define SND_SOC_DAPM_POST(wname, wevent) \ 194#define SND_SOC_DAPM_POST(wname, wevent) \
167{ .id = snd_soc_dapm_post, .name = wname, .kcontrols = NULL, \ 195{ .id = snd_soc_dapm_post, .name = wname, .kcontrol_news = NULL, \
168 .num_kcontrols = 0, .event = wevent, \ 196 .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
169 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD} 197 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD}
170 198
171/* stream domain */ 199/* stream domain */
172#define SND_SOC_DAPM_AIF_IN(wname, stname, wslot, wreg, wshift, winvert) \ 200#define SND_SOC_DAPM_AIF_IN(wname, stname, wslot, wreg, wshift, winvert) \
173{ .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \ 201{ .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
174 .reg = wreg, .shift = wshift, .invert = winvert } 202 .reg = wreg, .shift = wshift, .invert = winvert }
203#define SND_SOC_DAPM_AIF_IN_E(wname, stname, wslot, wreg, wshift, winvert, \
204 wevent, wflags) \
205{ .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
206 .reg = wreg, .shift = wshift, .invert = winvert, \
207 .event = wevent, .event_flags = wflags }
175#define SND_SOC_DAPM_AIF_OUT(wname, stname, wslot, wreg, wshift, winvert) \ 208#define SND_SOC_DAPM_AIF_OUT(wname, stname, wslot, wreg, wshift, winvert) \
176{ .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \ 209{ .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
177 .reg = wreg, .shift = wshift, .invert = winvert } 210 .reg = wreg, .shift = wshift, .invert = winvert }
211#define SND_SOC_DAPM_AIF_OUT_E(wname, stname, wslot, wreg, wshift, winvert, \
212 wevent, wflags) \
213{ .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
214 .reg = wreg, .shift = wshift, .invert = winvert, \
215 .event = wevent, .event_flags = wflags }
178#define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \ 216#define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \
179{ .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \ 217{ .id = snd_soc_dapm_dac, .name = wname, .sname = stname, .reg = wreg, \
180 .shift = wshift, .invert = winvert} 218 .shift = wshift, .invert = winvert}
@@ -194,7 +232,7 @@
194 232
195/* generic widgets */ 233/* generic widgets */
196#define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \ 234#define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \
197{ .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \ 235{ .id = wid, .name = wname, .kcontrol_news = NULL, .num_kcontrols = 0, \
198 .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \ 236 .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \
199 .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \ 237 .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \
200 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD} 238 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
@@ -209,13 +247,6 @@
209 .info = snd_soc_info_volsw, \ 247 .info = snd_soc_info_volsw, \
210 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ 248 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
211 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } 249 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
212#define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, max, invert, \
213 power) \
214{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
215 .info = snd_soc_info_volsw, \
216 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
217 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
218 ((max) << 16) | ((invert) << 24) }
219#define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ 250#define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
220{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 251{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
221 .info = snd_soc_info_volsw, \ 252 .info = snd_soc_info_volsw, \
@@ -223,15 +254,6 @@
223 .tlv.p = (tlv_array), \ 254 .tlv.p = (tlv_array), \
224 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ 255 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
225 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } 256 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
226#define SOC_DAPM_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, \
227 power, tlv_array) \
228{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
229 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
230 .tlv.p = (tlv_array), \
231 .info = snd_soc_info_volsw, \
232 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
233 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
234 ((max) << 16) | ((invert) << 24) }
235#define SOC_DAPM_ENUM(xname, xenum) \ 257#define SOC_DAPM_ENUM(xname, xenum) \
236{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 258{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
237 .info = snd_soc_info_enum_double, \ 259 .info = snd_soc_info_enum_double, \
@@ -287,6 +309,7 @@ enum snd_soc_dapm_type;
287struct snd_soc_dapm_path; 309struct snd_soc_dapm_path;
288struct snd_soc_dapm_pin; 310struct snd_soc_dapm_pin;
289struct snd_soc_dapm_route; 311struct snd_soc_dapm_route;
312struct snd_soc_dapm_context;
290 313
291int dapm_reg_event(struct snd_soc_dapm_widget *w, 314int dapm_reg_event(struct snd_soc_dapm_widget *w,
292 struct snd_kcontrol *kcontrol, int event); 315 struct snd_kcontrol *kcontrol, int event);
@@ -314,46 +337,53 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
314 struct snd_ctl_elem_value *uncontrol); 337 struct snd_ctl_elem_value *uncontrol);
315int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, 338int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
316 struct snd_ctl_elem_value *uncontrol); 339 struct snd_ctl_elem_value *uncontrol);
317int snd_soc_dapm_new_control(struct snd_soc_codec *codec, 340int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
318 const struct snd_soc_dapm_widget *widget); 341 const struct snd_soc_dapm_widget *widget);
319int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, 342int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
320 const struct snd_soc_dapm_widget *widget, 343 const struct snd_soc_dapm_widget *widget,
321 int num); 344 int num);
322 345
323/* dapm path setup */ 346/* dapm path setup */
324int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec); 347int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm);
325void snd_soc_dapm_free(struct snd_soc_device *socdev); 348void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm);
326int snd_soc_dapm_add_routes(struct snd_soc_codec *codec, 349int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
327 const struct snd_soc_dapm_route *route, int num); 350 const struct snd_soc_dapm_route *route, int num);
328 351
329/* dapm events */ 352/* dapm events */
330int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream, 353int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd,
331 int event); 354 const char *stream, int event);
332void snd_soc_dapm_shutdown(struct snd_soc_device *socdev); 355void snd_soc_dapm_shutdown(struct snd_soc_card *card);
333 356
334/* dapm sys fs - used by the core */ 357/* dapm sys fs - used by the core */
335int snd_soc_dapm_sys_add(struct device *dev); 358int snd_soc_dapm_sys_add(struct device *dev);
336void snd_soc_dapm_debugfs_init(struct snd_soc_codec *codec); 359void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
360 struct dentry *parent);
337 361
338/* dapm audio pin control and status */ 362/* dapm audio pin control and status */
339int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, const char *pin); 363int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm,
340int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin); 364 const char *pin);
341int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, const char *pin); 365int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
342int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin); 366 const char *pin);
343int snd_soc_dapm_sync(struct snd_soc_codec *codec); 367int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin);
344int snd_soc_dapm_force_enable_pin(struct snd_soc_codec *codec, 368int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
369 const char *pin);
370int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
371int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
345 const char *pin); 372 const char *pin);
346int snd_soc_dapm_ignore_suspend(struct snd_soc_codec *codec, const char *pin); 373int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
374 const char *pin);
347 375
348/* dapm widget types */ 376/* dapm widget types */
349enum snd_soc_dapm_type { 377enum snd_soc_dapm_type {
350 snd_soc_dapm_input = 0, /* input pin */ 378 snd_soc_dapm_input = 0, /* input pin */
351 snd_soc_dapm_output, /* output pin */ 379 snd_soc_dapm_output, /* output pin */
352 snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ 380 snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */
381 snd_soc_dapm_virt_mux, /* virtual version of snd_soc_dapm_mux */
353 snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ 382 snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */
354 snd_soc_dapm_mixer, /* mixes several analog signals together */ 383 snd_soc_dapm_mixer, /* mixes several analog signals together */
355 snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ 384 snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */
356 snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ 385 snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */
386 snd_soc_dapm_out_drv, /* output driver */
357 snd_soc_dapm_adc, /* analog to digital converter */ 387 snd_soc_dapm_adc, /* analog to digital converter */
358 snd_soc_dapm_dac, /* digital to analog converter */ 388 snd_soc_dapm_dac, /* digital to analog converter */
359 snd_soc_dapm_micbias, /* microphone bias (power) */ 389 snd_soc_dapm_micbias, /* microphone bias (power) */
@@ -415,6 +445,7 @@ struct snd_soc_dapm_widget {
415 char *sname; /* stream name */ 445 char *sname; /* stream name */
416 struct snd_soc_codec *codec; 446 struct snd_soc_codec *codec;
417 struct list_head list; 447 struct list_head list;
448 struct snd_soc_dapm_context *dapm;
418 449
419 /* dapm control */ 450 /* dapm control */
420 short reg; /* negative reg = no direct dapm */ 451 short reg; /* negative reg = no direct dapm */
@@ -432,6 +463,7 @@ struct snd_soc_dapm_widget {
432 unsigned char ext:1; /* has external widgets */ 463 unsigned char ext:1; /* has external widgets */
433 unsigned char force:1; /* force state */ 464 unsigned char force:1; /* force state */
434 unsigned char ignore_suspend:1; /* kept enabled over suspend */ 465 unsigned char ignore_suspend:1; /* kept enabled over suspend */
466 int subseq; /* sort within widget type */
435 467
436 int (*power_check)(struct snd_soc_dapm_widget *w); 468 int (*power_check)(struct snd_soc_dapm_widget *w);
437 469
@@ -441,7 +473,8 @@ struct snd_soc_dapm_widget {
441 473
442 /* kcontrols that relate to this widget */ 474 /* kcontrols that relate to this widget */
443 int num_kcontrols; 475 int num_kcontrols;
444 const struct snd_kcontrol_new *kcontrols; 476 const struct snd_kcontrol_new *kcontrol_news;
477 struct snd_kcontrol **kcontrols;
445 478
446 /* widget input and outputs */ 479 /* widget input and outputs */
447 struct list_head sources; 480 struct list_head sources;
@@ -451,4 +484,44 @@ struct snd_soc_dapm_widget {
451 struct list_head power_list; 484 struct list_head power_list;
452}; 485};
453 486
487struct snd_soc_dapm_update {
488 struct snd_soc_dapm_widget *widget;
489 struct snd_kcontrol *kcontrol;
490 int reg;
491 int mask;
492 int val;
493};
494
495/* DAPM context */
496struct snd_soc_dapm_context {
497 int n_widgets; /* number of widgets in this context */
498 enum snd_soc_bias_level bias_level;
499 enum snd_soc_bias_level suspend_bias_level;
500 struct delayed_work delayed_work;
501 unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
502
503 struct snd_soc_dapm_update *update;
504
505 void (*seq_notifier)(struct snd_soc_dapm_context *,
506 enum snd_soc_dapm_type, int);
507
508 struct device *dev; /* from parent - for debug */
509 struct snd_soc_codec *codec; /* parent codec */
510 struct snd_soc_card *card; /* parent card */
511
512 /* used during DAPM updates */
513 int dev_power;
514 struct list_head list;
515
516#ifdef CONFIG_DEBUG_FS
517 struct dentry *debugfs_dapm;
518#endif
519};
520
521/* A list of widgets associated with an object, typically a snd_kcontrol */
522struct snd_soc_dapm_widget_list {
523 int num_widgets;
524 struct snd_soc_dapm_widget *widgets[0];
525};
526
454#endif 527#endif
diff --git a/include/sound/soc-of-simple.h b/include/sound/soc-of-simple.h
deleted file mode 100644
index a064e1934a56..000000000000
--- a/include/sound/soc-of-simple.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * OF helpers for ALSA SoC
3 *
4 * Copyright (C) 2008, Secret Lab Technologies Ltd.
5 */
6
7#ifndef _INCLUDE_SOC_OF_H_
8#define _INCLUDE_SOC_OF_H_
9
10#if defined(CONFIG_SND_SOC_OF_SIMPLE) || defined(CONFIG_SND_SOC_OF_SIMPLE_MODULE)
11
12#include <linux/of.h>
13#include <sound/soc.h>
14
15int of_snd_soc_register_codec(struct snd_soc_codec_device *codec_dev,
16 void *codec_data, struct snd_soc_dai *dai,
17 struct device_node *node);
18
19int of_snd_soc_register_platform(struct snd_soc_platform *platform,
20 struct device_node *node,
21 struct snd_soc_dai *cpu_dai);
22
23#endif
24
25#endif /* _INCLUDE_SOC_OF_H_ */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 65e9d03ed4f5..3a4bd3a3c68d 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -214,27 +214,31 @@
214 * @OFF: Power Off. No restrictions on transition times. 214 * @OFF: Power Off. No restrictions on transition times.
215 */ 215 */
216enum snd_soc_bias_level { 216enum snd_soc_bias_level {
217 SND_SOC_BIAS_ON,
218 SND_SOC_BIAS_PREPARE,
219 SND_SOC_BIAS_STANDBY,
220 SND_SOC_BIAS_OFF, 217 SND_SOC_BIAS_OFF,
218 SND_SOC_BIAS_STANDBY,
219 SND_SOC_BIAS_PREPARE,
220 SND_SOC_BIAS_ON,
221}; 221};
222 222
223struct snd_jack; 223struct snd_jack;
224struct snd_soc_card; 224struct snd_soc_card;
225struct snd_soc_device;
226struct snd_soc_pcm_stream; 225struct snd_soc_pcm_stream;
227struct snd_soc_ops; 226struct snd_soc_ops;
228struct snd_soc_dai_mode;
229struct snd_soc_pcm_runtime; 227struct snd_soc_pcm_runtime;
230struct snd_soc_dai; 228struct snd_soc_dai;
229struct snd_soc_dai_driver;
231struct snd_soc_platform; 230struct snd_soc_platform;
232struct snd_soc_dai_link; 231struct snd_soc_dai_link;
232struct snd_soc_platform_driver;
233struct snd_soc_codec; 233struct snd_soc_codec;
234struct snd_soc_codec_driver;
234struct soc_enum; 235struct soc_enum;
235struct snd_soc_ac97_ops;
236struct snd_soc_jack; 236struct snd_soc_jack;
237struct snd_soc_jack_zone;
237struct snd_soc_jack_pin; 238struct snd_soc_jack_pin;
239struct snd_soc_cache_ops;
240#include <sound/soc-dapm.h>
241
238#ifdef CONFIG_GPIOLIB 242#ifdef CONFIG_GPIOLIB
239struct snd_soc_jack_gpio; 243struct snd_soc_jack_gpio;
240#endif 244#endif
@@ -244,23 +248,55 @@ typedef int (*hw_write_t)(void *,const char* ,int);
244extern struct snd_ac97_bus_ops soc_ac97_ops; 248extern struct snd_ac97_bus_ops soc_ac97_ops;
245 249
246enum snd_soc_control_type { 250enum snd_soc_control_type {
247 SND_SOC_CUSTOM, 251 SND_SOC_I2C = 1,
248 SND_SOC_I2C,
249 SND_SOC_SPI, 252 SND_SOC_SPI,
250}; 253};
251 254
252int snd_soc_register_platform(struct snd_soc_platform *platform); 255enum snd_soc_compress_type {
253void snd_soc_unregister_platform(struct snd_soc_platform *platform); 256 SND_SOC_FLAT_COMPRESSION = 1,
254int snd_soc_register_codec(struct snd_soc_codec *codec); 257 SND_SOC_LZO_COMPRESSION,
255void snd_soc_unregister_codec(struct snd_soc_codec *codec); 258 SND_SOC_RBTREE_COMPRESSION
256int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); 259};
260
261int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
262 unsigned int freq, int dir);
263int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
264 unsigned int freq_in, unsigned int freq_out);
265
266int snd_soc_register_card(struct snd_soc_card *card);
267int snd_soc_unregister_card(struct snd_soc_card *card);
268int snd_soc_suspend(struct device *dev);
269int snd_soc_resume(struct device *dev);
270int snd_soc_poweroff(struct device *dev);
271int snd_soc_register_platform(struct device *dev,
272 struct snd_soc_platform_driver *platform_drv);
273void snd_soc_unregister_platform(struct device *dev);
274int snd_soc_register_codec(struct device *dev,
275 const struct snd_soc_codec_driver *codec_drv,
276 struct snd_soc_dai_driver *dai_drv, int num_dai);
277void snd_soc_unregister_codec(struct device *dev);
278int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
279 unsigned int reg);
280int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
281 unsigned int reg);
282int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
283 unsigned int reg);
257int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, 284int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
258 int addr_bits, int data_bits, 285 int addr_bits, int data_bits,
259 enum snd_soc_control_type control); 286 enum snd_soc_control_type control);
260 287int snd_soc_cache_sync(struct snd_soc_codec *codec);
261/* pcm <-> DAI connect */ 288int snd_soc_cache_init(struct snd_soc_codec *codec);
262void snd_soc_free_pcms(struct snd_soc_device *socdev); 289int snd_soc_cache_exit(struct snd_soc_codec *codec);
263int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); 290int snd_soc_cache_write(struct snd_soc_codec *codec,
291 unsigned int reg, unsigned int value);
292int snd_soc_cache_read(struct snd_soc_codec *codec,
293 unsigned int reg, unsigned int *value);
294int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
295 unsigned int reg);
296int snd_soc_default_readable_register(struct snd_soc_codec *codec,
297 unsigned int reg);
298int snd_soc_default_writable_register(struct snd_soc_codec *codec,
299 unsigned int reg);
264 300
265/* Utility functions to get clock rates from various things */ 301/* Utility functions to get clock rates from various things */
266int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); 302int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
@@ -273,7 +309,7 @@ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
273 const struct snd_pcm_hardware *hw); 309 const struct snd_pcm_hardware *hw);
274 310
275/* Jack reporting */ 311/* Jack reporting */
276int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type, 312int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
277 struct snd_soc_jack *jack); 313 struct snd_soc_jack *jack);
278void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); 314void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
279int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, 315int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
@@ -282,6 +318,9 @@ void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
282 struct notifier_block *nb); 318 struct notifier_block *nb);
283void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, 319void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
284 struct notifier_block *nb); 320 struct notifier_block *nb);
321int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
322 struct snd_soc_jack_zone *zones);
323int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
285#ifdef CONFIG_GPIOLIB 324#ifdef CONFIG_GPIOLIB
286int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, 325int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
287 struct snd_soc_jack_gpio *gpios); 326 struct snd_soc_jack_gpio *gpios);
@@ -306,7 +345,8 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
306 *Controls 345 *Controls
307 */ 346 */
308struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, 347struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
309 void *data, char *long_name); 348 void *data, char *long_name,
349 const char *prefix);
310int snd_soc_add_controls(struct snd_soc_codec *codec, 350int snd_soc_add_controls(struct snd_soc_codec *codec,
311 const struct snd_kcontrol_new *controls, int num_controls); 351 const struct snd_kcontrol_new *controls, int num_controls);
312int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, 352int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
@@ -352,6 +392,22 @@ int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
352 struct snd_ctl_elem_value *ucontrol); 392 struct snd_ctl_elem_value *ucontrol);
353 393
354/** 394/**
395 * struct snd_soc_reg_access - Describes whether a given register is
396 * readable, writable or volatile.
397 *
398 * @reg: the register number
399 * @read: whether this register is readable
400 * @write: whether this register is writable
401 * @vol: whether this register is volatile
402 */
403struct snd_soc_reg_access {
404 u16 reg;
405 u16 read;
406 u16 write;
407 u16 vol;
408};
409
410/**
355 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection 411 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
356 * 412 *
357 * @pin: name of the pin to update 413 * @pin: name of the pin to update
@@ -366,6 +422,24 @@ struct snd_soc_jack_pin {
366}; 422};
367 423
368/** 424/**
425 * struct snd_soc_jack_zone - Describes voltage zones of jack detection
426 *
427 * @min_mv: start voltage in mv
428 * @max_mv: end voltage in mv
429 * @jack_type: type of jack that is expected for this voltage
430 * @debounce_time: debounce_time for jack, codec driver should wait for this
431 * duration before reading the adc for voltages
432 * @:list: list container
433 */
434struct snd_soc_jack_zone {
435 unsigned int min_mv;
436 unsigned int max_mv;
437 unsigned int jack_type;
438 unsigned int debounce_time;
439 struct list_head list;
440};
441
442/**
369 * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection 443 * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
370 * 444 *
371 * @gpio: gpio number 445 * @gpio: gpio number
@@ -373,6 +447,10 @@ struct snd_soc_jack_pin {
373 * @report: value to report when jack detected 447 * @report: value to report when jack detected
374 * @invert: report presence in low state 448 * @invert: report presence in low state
375 * @debouce_time: debouce time in ms 449 * @debouce_time: debouce time in ms
450 * @wake: enable as wake source
451 * @jack_status_check: callback function which overrides the detection
452 * to provide more complex checks (eg, reading an
453 * ADC).
376 */ 454 */
377#ifdef CONFIG_GPIOLIB 455#ifdef CONFIG_GPIOLIB
378struct snd_soc_jack_gpio { 456struct snd_soc_jack_gpio {
@@ -381,8 +459,10 @@ struct snd_soc_jack_gpio {
381 int report; 459 int report;
382 int invert; 460 int invert;
383 int debounce_time; 461 int debounce_time;
462 bool wake;
463
384 struct snd_soc_jack *jack; 464 struct snd_soc_jack *jack;
385 struct work_struct work; 465 struct delayed_work work;
386 466
387 int (*jack_status_check)(void); 467 int (*jack_status_check)(void);
388}; 468};
@@ -390,23 +470,22 @@ struct snd_soc_jack_gpio {
390 470
391struct snd_soc_jack { 471struct snd_soc_jack {
392 struct snd_jack *jack; 472 struct snd_jack *jack;
393 struct snd_soc_card *card; 473 struct snd_soc_codec *codec;
394 struct list_head pins; 474 struct list_head pins;
395 int status; 475 int status;
396 struct blocking_notifier_head notifier; 476 struct blocking_notifier_head notifier;
477 struct list_head jack_zones;
397}; 478};
398 479
399/* SoC PCM stream information */ 480/* SoC PCM stream information */
400struct snd_soc_pcm_stream { 481struct snd_soc_pcm_stream {
401 char *stream_name; 482 const char *stream_name;
402 u64 formats; /* SNDRV_PCM_FMTBIT_* */ 483 u64 formats; /* SNDRV_PCM_FMTBIT_* */
403 unsigned int rates; /* SNDRV_PCM_RATE_* */ 484 unsigned int rates; /* SNDRV_PCM_RATE_* */
404 unsigned int rate_min; /* min rate */ 485 unsigned int rate_min; /* min rate */
405 unsigned int rate_max; /* max rate */ 486 unsigned int rate_max; /* max rate */
406 unsigned int channels_min; /* min channels */ 487 unsigned int channels_min; /* min channels */
407 unsigned int channels_max; /* max channels */ 488 unsigned int channels_max; /* max channels */
408 unsigned int active; /* stream is in use */
409 void *dma_data; /* used by platform code */
410}; 489};
411 490
412/* SoC audio ops */ 491/* SoC audio ops */
@@ -419,82 +498,129 @@ struct snd_soc_ops {
419 int (*trigger)(struct snd_pcm_substream *, int); 498 int (*trigger)(struct snd_pcm_substream *, int);
420}; 499};
421 500
422/* SoC Audio Codec */ 501/* SoC cache ops */
502struct snd_soc_cache_ops {
503 const char *name;
504 enum snd_soc_compress_type id;
505 int (*init)(struct snd_soc_codec *codec);
506 int (*exit)(struct snd_soc_codec *codec);
507 int (*read)(struct snd_soc_codec *codec, unsigned int reg,
508 unsigned int *value);
509 int (*write)(struct snd_soc_codec *codec, unsigned int reg,
510 unsigned int value);
511 int (*sync)(struct snd_soc_codec *codec);
512};
513
514/* SoC Audio Codec device */
423struct snd_soc_codec { 515struct snd_soc_codec {
424 char *name; 516 const char *name;
425 struct module *owner; 517 const char *name_prefix;
426 struct mutex mutex; 518 int id;
427 struct device *dev; 519 struct device *dev;
428 struct snd_soc_device *socdev; 520 const struct snd_soc_codec_driver *driver;
429 521
522 struct mutex mutex;
523 struct snd_soc_card *card;
430 struct list_head list; 524 struct list_head list;
431 525 struct list_head card_list;
432 /* callbacks */ 526 int num_dai;
433 int (*set_bias_level)(struct snd_soc_codec *, 527 enum snd_soc_compress_type compress_type;
434 enum snd_soc_bias_level level); 528 size_t reg_size; /* reg_cache_size * reg_word_size */
529 int (*volatile_register)(struct snd_soc_codec *, unsigned int);
530 int (*readable_register)(struct snd_soc_codec *, unsigned int);
531 int (*writable_register)(struct snd_soc_codec *, unsigned int);
435 532
436 /* runtime */ 533 /* runtime */
437 struct snd_card *card;
438 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ 534 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
439 unsigned int active; 535 unsigned int active;
440 unsigned int pcm_devs; 536 unsigned int cache_bypass:1; /* Suppress access to the cache */
441 void *drvdata; 537 unsigned int suspended:1; /* Codec is in suspend PM state */
538 unsigned int probed:1; /* Codec has been probed */
539 unsigned int ac97_registered:1; /* Codec has been AC97 registered */
540 unsigned int ac97_created:1; /* Codec has been created by SoC */
541 unsigned int sysfs_registered:1; /* codec has been sysfs registered */
542 unsigned int cache_init:1; /* codec cache has been initialized */
543 u32 cache_only; /* Suppress writes to hardware */
544 u32 cache_sync; /* Cache needs to be synced to hardware */
442 545
443 /* codec IO */ 546 /* codec IO */
444 void *control_data; /* codec control (i2c/3wire) data */ 547 void *control_data; /* codec control (i2c/3wire) data */
445 unsigned int (*read)(struct snd_soc_codec *, unsigned int); 548 enum snd_soc_control_type control_type;
446 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
447 int (*display_register)(struct snd_soc_codec *, char *,
448 size_t, unsigned int);
449 int (*volatile_register)(unsigned int);
450 int (*readable_register)(unsigned int);
451 hw_write_t hw_write; 549 hw_write_t hw_write;
452 unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); 550 unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
551 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
552 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
553 int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t);
453 void *reg_cache; 554 void *reg_cache;
454 short reg_cache_size; 555 const void *reg_def_copy;
455 short reg_cache_step; 556 const struct snd_soc_cache_ops *cache_ops;
456 557 struct mutex cache_rw_mutex;
457 unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
458 unsigned int cache_only:1; /* Suppress writes to hardware */
459 unsigned int cache_sync:1; /* Cache needs to be synced to hardware */
460 558
461 /* dapm */ 559 /* dapm */
462 u32 pop_time; 560 struct snd_soc_dapm_context dapm;
463 struct list_head dapm_widgets;
464 struct list_head dapm_paths;
465 enum snd_soc_bias_level bias_level;
466 enum snd_soc_bias_level suspend_bias_level;
467 struct delayed_work delayed_work;
468
469 /* codec DAI's */
470 struct snd_soc_dai *dai;
471 unsigned int num_dai;
472 561
473#ifdef CONFIG_DEBUG_FS 562#ifdef CONFIG_DEBUG_FS
474 struct dentry *debugfs_codec_root; 563 struct dentry *debugfs_codec_root;
475 struct dentry *debugfs_reg; 564 struct dentry *debugfs_reg;
476 struct dentry *debugfs_pop_time;
477 struct dentry *debugfs_dapm; 565 struct dentry *debugfs_dapm;
478#endif 566#endif
479}; 567};
480 568
481/* codec device */ 569/* codec driver */
482struct snd_soc_codec_device { 570struct snd_soc_codec_driver {
483 int (*probe)(struct platform_device *pdev); 571
484 int (*remove)(struct platform_device *pdev); 572 /* driver ops */
485 int (*suspend)(struct platform_device *pdev, pm_message_t state); 573 int (*probe)(struct snd_soc_codec *);
486 int (*resume)(struct platform_device *pdev); 574 int (*remove)(struct snd_soc_codec *);
575 int (*suspend)(struct snd_soc_codec *,
576 pm_message_t state);
577 int (*resume)(struct snd_soc_codec *);
578
579 /* Default control and setup, added after probe() is run */
580 const struct snd_kcontrol_new *controls;
581 int num_controls;
582 const struct snd_soc_dapm_widget *dapm_widgets;
583 int num_dapm_widgets;
584 const struct snd_soc_dapm_route *dapm_routes;
585 int num_dapm_routes;
586
587 /* codec wide operations */
588 int (*set_sysclk)(struct snd_soc_codec *codec,
589 int clk_id, unsigned int freq, int dir);
590 int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
591 unsigned int freq_in, unsigned int freq_out);
592
593 /* codec IO */
594 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
595 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
596 int (*display_register)(struct snd_soc_codec *, char *,
597 size_t, unsigned int);
598 int (*volatile_register)(struct snd_soc_codec *, unsigned int);
599 int (*readable_register)(struct snd_soc_codec *, unsigned int);
600 int (*writable_register)(struct snd_soc_codec *, unsigned int);
601 short reg_cache_size;
602 short reg_cache_step;
603 short reg_word_size;
604 const void *reg_cache_default;
605 short reg_access_size;
606 const struct snd_soc_reg_access *reg_access_default;
607 enum snd_soc_compress_type compress_type;
608
609 /* codec bias level */
610 int (*set_bias_level)(struct snd_soc_codec *,
611 enum snd_soc_bias_level level);
612
613 void (*seq_notifier)(struct snd_soc_dapm_context *,
614 enum snd_soc_dapm_type, int);
487}; 615};
488 616
489/* SoC platform interface */ 617/* SoC platform interface */
490struct snd_soc_platform { 618struct snd_soc_platform_driver {
491 char *name;
492 struct list_head list;
493 619
494 int (*probe)(struct platform_device *pdev); 620 int (*probe)(struct snd_soc_platform *);
495 int (*remove)(struct platform_device *pdev); 621 int (*remove)(struct snd_soc_platform *);
496 int (*suspend)(struct snd_soc_dai_link *dai_link); 622 int (*suspend)(struct snd_soc_dai *dai);
497 int (*resume)(struct snd_soc_dai_link *dai_link); 623 int (*resume)(struct snd_soc_dai *dai);
498 624
499 /* pcm creation and destruction */ 625 /* pcm creation and destruction */
500 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *, 626 int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
@@ -509,23 +635,31 @@ struct snd_soc_platform {
509 struct snd_soc_dai *); 635 struct snd_soc_dai *);
510 636
511 /* platform stream ops */ 637 /* platform stream ops */
512 struct snd_pcm_ops *pcm_ops; 638 struct snd_pcm_ops *ops;
513}; 639};
514 640
515/* SoC machine DAI configuration, glues a codec and cpu DAI together */ 641struct snd_soc_platform {
516struct snd_soc_dai_link { 642 const char *name;
517 char *name; /* Codec name */ 643 int id;
518 char *stream_name; /* Stream name */ 644 struct device *dev;
645 struct snd_soc_platform_driver *driver;
519 646
520 /* DAI */ 647 unsigned int suspended:1; /* platform is suspended */
521 struct snd_soc_dai *codec_dai; 648 unsigned int probed:1;
522 struct snd_soc_dai *cpu_dai;
523 649
524 /* machine stream operations */ 650 struct snd_soc_card *card;
525 struct snd_soc_ops *ops; 651 struct list_head list;
652 struct list_head card_list;
653};
526 654
527 /* codec/machine specific init - e.g. add machine controls */ 655struct snd_soc_dai_link {
528 int (*init)(struct snd_soc_codec *codec); 656 /* config - must be set by machine driver */
657 const char *name; /* Codec name */
658 const char *stream_name; /* Stream name */
659 const char *codec_name; /* for multi-codec */
660 const char *platform_name; /* for multi-platform */
661 const char *cpu_dai_name;
662 const char *codec_dai_name;
529 663
530 /* Keep DAI active over suspend */ 664 /* Keep DAI active over suspend */
531 unsigned int ignore_suspend:1; 665 unsigned int ignore_suspend:1;
@@ -533,63 +667,144 @@ struct snd_soc_dai_link {
533 /* Symmetry requirements */ 667 /* Symmetry requirements */
534 unsigned int symmetric_rates:1; 668 unsigned int symmetric_rates:1;
535 669
536 /* Symmetry data - only valid if symmetry is being enforced */ 670 /* codec/machine specific init - e.g. add machine controls */
537 unsigned int rate; 671 int (*init)(struct snd_soc_pcm_runtime *rtd);
538 672
539 /* DAI pcm */ 673 /* machine stream operations */
540 struct snd_pcm *pcm; 674 struct snd_soc_ops *ops;
675};
676
677struct snd_soc_codec_conf {
678 const char *dev_name;
679
680 /*
681 * optional map of kcontrol, widget and path name prefixes that are
682 * associated per device
683 */
684 const char *name_prefix;
685
686 /*
687 * set this to the desired compression type if you want to
688 * override the one supplied in codec->driver->compress_type
689 */
690 enum snd_soc_compress_type compress_type;
691};
692
693struct snd_soc_aux_dev {
694 const char *name; /* Codec name */
695 const char *codec_name; /* for multi-codec */
696
697 /* codec/machine specific init - e.g. add machine controls */
698 int (*init)(struct snd_soc_dapm_context *dapm);
541}; 699};
542 700
543/* SoC card */ 701/* SoC card */
544struct snd_soc_card { 702struct snd_soc_card {
545 char *name; 703 const char *name;
704 const char *long_name;
705 const char *driver_name;
546 struct device *dev; 706 struct device *dev;
707 struct snd_card *snd_card;
708 struct module *owner;
547 709
548 struct list_head list; 710 struct list_head list;
711 struct mutex mutex;
549 712
550 int instantiated; 713 bool instantiated;
551 714
552 int (*probe)(struct platform_device *pdev); 715 int (*probe)(struct snd_soc_card *card);
553 int (*remove)(struct platform_device *pdev); 716 int (*late_probe)(struct snd_soc_card *card);
717 int (*remove)(struct snd_soc_card *card);
554 718
555 /* the pre and post PM functions are used to do any PM work before and 719 /* the pre and post PM functions are used to do any PM work before and
556 * after the codec and DAI's do any PM work. */ 720 * after the codec and DAI's do any PM work. */
557 int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); 721 int (*suspend_pre)(struct snd_soc_card *card);
558 int (*suspend_post)(struct platform_device *pdev, pm_message_t state); 722 int (*suspend_post)(struct snd_soc_card *card);
559 int (*resume_pre)(struct platform_device *pdev); 723 int (*resume_pre)(struct snd_soc_card *card);
560 int (*resume_post)(struct platform_device *pdev); 724 int (*resume_post)(struct snd_soc_card *card);
561 725
562 /* callbacks */ 726 /* callbacks */
563 int (*set_bias_level)(struct snd_soc_card *, 727 int (*set_bias_level)(struct snd_soc_card *,
564 enum snd_soc_bias_level level); 728 enum snd_soc_bias_level level);
729 int (*set_bias_level_post)(struct snd_soc_card *,
730 enum snd_soc_bias_level level);
565 731
566 long pmdown_time; 732 long pmdown_time;
567 733
568 /* CPU <--> Codec DAI links */ 734 /* CPU <--> Codec DAI links */
569 struct snd_soc_dai_link *dai_link; 735 struct snd_soc_dai_link *dai_link;
570 int num_links; 736 int num_links;
737 struct snd_soc_pcm_runtime *rtd;
738 int num_rtd;
571 739
572 struct snd_soc_device *socdev; 740 /* optional codec specific configuration */
741 struct snd_soc_codec_conf *codec_conf;
742 int num_configs;
573 743
574 struct snd_soc_codec *codec; 744 /*
745 * optional auxiliary devices such as amplifiers or codecs with DAI
746 * link unused
747 */
748 struct snd_soc_aux_dev *aux_dev;
749 int num_aux_devs;
750 struct snd_soc_pcm_runtime *rtd_aux;
751 int num_aux_rtd;
752
753 const struct snd_kcontrol_new *controls;
754 int num_controls;
755
756 /*
757 * Card-specific routes and widgets.
758 */
759 const struct snd_soc_dapm_widget *dapm_widgets;
760 int num_dapm_widgets;
761 const struct snd_soc_dapm_route *dapm_routes;
762 int num_dapm_routes;
575 763
576 struct snd_soc_platform *platform;
577 struct delayed_work delayed_work;
578 struct work_struct deferred_resume_work; 764 struct work_struct deferred_resume_work;
765
766 /* lists of probed devices belonging to this card */
767 struct list_head codec_dev_list;
768 struct list_head platform_dev_list;
769 struct list_head dai_dev_list;
770
771 struct list_head widgets;
772 struct list_head paths;
773 struct list_head dapm_list;
774
775 /* Generic DAPM context for the card */
776 struct snd_soc_dapm_context dapm;
777
778#ifdef CONFIG_DEBUG_FS
779 struct dentry *debugfs_card_root;
780 struct dentry *debugfs_pop_time;
781#endif
782 u32 pop_time;
783
784 void *drvdata;
579}; 785};
580 786
581/* SoC Device - the audio subsystem */ 787/* SoC machine DAI configuration, glues a codec and cpu DAI together */
582struct snd_soc_device { 788struct snd_soc_pcm_runtime {
583 struct device *dev; 789 struct device dev;
584 struct snd_soc_card *card; 790 struct snd_soc_card *card;
585 struct snd_soc_codec_device *codec_dev; 791 struct snd_soc_dai_link *dai_link;
586 void *codec_data; 792
587}; 793 unsigned int complete:1;
794 unsigned int dev_registered:1;
795
796 /* Symmetry data - only valid if symmetry is being enforced */
797 unsigned int rate;
798 long pmdown_time;
588 799
589/* runtime channel data */ 800 /* runtime devices */
590struct snd_soc_pcm_runtime { 801 struct snd_pcm *pcm;
591 struct snd_soc_dai_link *dai; 802 struct snd_soc_codec *codec;
592 struct snd_soc_device *socdev; 803 struct snd_soc_platform *platform;
804 struct snd_soc_dai *codec_dai;
805 struct snd_soc_dai *cpu_dai;
806
807 struct delayed_work delayed_work;
593}; 808};
594 809
595/* mixer control */ 810/* mixer control */
@@ -606,35 +821,83 @@ struct soc_enum {
606 unsigned char shift_r; 821 unsigned char shift_r;
607 unsigned int max; 822 unsigned int max;
608 unsigned int mask; 823 unsigned int mask;
609 const char **texts; 824 const char * const *texts;
610 const unsigned int *values; 825 const unsigned int *values;
611 void *dapm; 826 void *dapm;
612}; 827};
613 828
614/* codec IO */ 829/* codec IO */
615static inline unsigned int snd_soc_read(struct snd_soc_codec *codec, 830unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
616 unsigned int reg) 831unsigned int snd_soc_write(struct snd_soc_codec *codec,
832 unsigned int reg, unsigned int val);
833unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec,
834 unsigned int reg, const void *data, size_t len);
835
836/* device driver data */
837
838static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
839 void *data)
617{ 840{
618 return codec->read(codec, reg); 841 card->drvdata = data;
619} 842}
620 843
621static inline unsigned int snd_soc_write(struct snd_soc_codec *codec, 844static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
622 unsigned int reg, unsigned int val)
623{ 845{
624 return codec->write(codec, reg, val); 846 return card->drvdata;
625} 847}
626 848
627static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, 849static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
628 void *data) 850 void *data)
629{ 851{
630 codec->drvdata = data; 852 dev_set_drvdata(codec->dev, data);
631} 853}
632 854
633static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) 855static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
634{ 856{
635 return codec->drvdata; 857 return dev_get_drvdata(codec->dev);
636} 858}
637 859
860static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
861 void *data)
862{
863 dev_set_drvdata(platform->dev, data);
864}
865
866static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
867{
868 return dev_get_drvdata(platform->dev);
869}
870
871static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
872 void *data)
873{
874 dev_set_drvdata(&rtd->dev, data);
875}
876
877static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
878{
879 return dev_get_drvdata(&rtd->dev);
880}
881
882static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
883{
884 INIT_LIST_HEAD(&card->dai_dev_list);
885 INIT_LIST_HEAD(&card->codec_dev_list);
886 INIT_LIST_HEAD(&card->platform_dev_list);
887 INIT_LIST_HEAD(&card->widgets);
888 INIT_LIST_HEAD(&card->paths);
889 INIT_LIST_HEAD(&card->dapm_list);
890}
891
892int snd_soc_util_init(void);
893void snd_soc_util_exit(void);
894
638#include <sound/soc-dai.h> 895#include <sound/soc-dai.h>
639 896
897#ifdef CONFIG_DEBUG_FS
898extern struct dentry *snd_soc_debugfs_root;
899#endif
900
901extern const struct dev_pm_ops snd_soc_pm_ops;
902
640#endif 903#endif
diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h
index 5718a02d3afb..d2ea112fc20f 100644
--- a/include/sound/tea575x-tuner.h
+++ b/include/sound/tea575x-tuner.h
@@ -26,29 +26,37 @@
26#include <media/v4l2-dev.h> 26#include <media/v4l2-dev.h>
27#include <media/v4l2-ioctl.h> 27#include <media/v4l2-ioctl.h>
28 28
29#define TEA575X_FMIF 10700
30
31#define TEA575X_DATA (1 << 0)
32#define TEA575X_CLK (1 << 1)
33#define TEA575X_WREN (1 << 2)
34#define TEA575X_MOST (1 << 3)
35
29struct snd_tea575x; 36struct snd_tea575x;
30 37
31struct snd_tea575x_ops { 38struct snd_tea575x_ops {
32 void (*write)(struct snd_tea575x *tea, unsigned int val); 39 void (*set_pins)(struct snd_tea575x *tea, u8 pins);
33 unsigned int (*read)(struct snd_tea575x *tea); 40 u8 (*get_pins)(struct snd_tea575x *tea);
34 void (*mute)(struct snd_tea575x *tea, unsigned int mute); 41 void (*set_direction)(struct snd_tea575x *tea, bool output);
35}; 42};
36 43
37struct snd_tea575x { 44struct snd_tea575x {
38 struct snd_card *card;
39 struct video_device *vd; /* video device */ 45 struct video_device *vd; /* video device */
40 int dev_nr; /* requested device number + 1 */ 46 bool tea5759; /* 5759 chip is present */
41 int tea5759; /* 5759 chip is present */ 47 bool mute; /* Device is muted? */
42 int mute; /* Device is muted? */ 48 bool stereo; /* receiving stereo */
43 unsigned int freq_fixup; /* crystal onboard */ 49 bool tuned; /* tuned to a station */
44 unsigned int val; /* hw value */ 50 unsigned int val; /* hw value */
45 unsigned long freq; /* frequency */ 51 unsigned long freq; /* frequency */
46 unsigned long in_use; /* set if the device is in use */ 52 unsigned long in_use; /* set if the device is in use */
47 struct snd_tea575x_ops *ops; 53 struct snd_tea575x_ops *ops;
48 void *private_data; 54 void *private_data;
55 u8 card[32];
56 u8 bus_info[32];
49}; 57};
50 58
51void snd_tea575x_init(struct snd_tea575x *tea); 59int snd_tea575x_init(struct snd_tea575x *tea);
52void snd_tea575x_exit(struct snd_tea575x *tea); 60void snd_tea575x_exit(struct snd_tea575x *tea);
53 61
54#endif /* __SOUND_TEA575X_TUNER_H */ 62#endif /* __SOUND_TEA575X_TUNER_H */
diff --git a/include/sound/tlv.h b/include/sound/tlv.h
index 9fd5b19ccf5c..7067e2dfb0b9 100644
--- a/include/sound/tlv.h
+++ b/include/sound/tlv.h
@@ -38,9 +38,11 @@
38#define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */ 38#define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */
39#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */ 39#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */
40 40
41#define TLV_DB_SCALE_MASK 0xffff
42#define TLV_DB_SCALE_MUTE 0x10000
41#define TLV_DB_SCALE_ITEM(min, step, mute) \ 43#define TLV_DB_SCALE_ITEM(min, step, mute) \
42 SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int), \ 44 SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int), \
43 (min), ((step) & 0xffff) | ((mute) ? 0x10000 : 0) 45 (min), ((step) & TLV_DB_SCALE_MASK) | ((mute) ? TLV_DB_SCALE_MUTE : 0)
44#define DECLARE_TLV_DB_SCALE(name, min, step, mute) \ 46#define DECLARE_TLV_DB_SCALE(name, min, step, mute) \
45 unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) } 47 unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) }
46 48
diff --git a/include/sound/tlv320aic32x4.h b/include/sound/tlv320aic32x4.h
new file mode 100644
index 000000000000..c009f70b4029
--- /dev/null
+++ b/include/sound/tlv320aic32x4.h
@@ -0,0 +1,31 @@
1/*
2 * tlv320aic32x4.h -- TLV320AIC32X4 Soc Audio driver platform data
3 *
4 * Copyright 2011 Vista Silicon S.L.
5 *
6 * Author: Javier Martin <javier.martin@vista-silicon.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _AIC32X4_PDATA_H
14#define _AIC32X4_PDATA_H
15
16#define AIC32X4_PWR_MICBIAS_2075_LDOIN 0x00000001
17#define AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE 0x00000002
18#define AIC32X4_PWR_AIC32X4_LDO_ENABLE 0x00000004
19#define AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36 0x00000008
20#define AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED 0x00000010
21
22#define AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K 0x00000001
23#define AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K 0x00000002
24
25struct aic32x4_pdata {
26 u32 power_cfg;
27 u32 micpga_routing;
28 bool swapdacs;
29};
30
31#endif
diff --git a/include/sound/tlv320aic3x.h b/include/sound/tlv320aic3x.h
index b1a5f34e5cfa..99e0308bf2c2 100644
--- a/include/sound/tlv320aic3x.h
+++ b/include/sound/tlv320aic3x.h
@@ -10,8 +10,49 @@
10#ifndef __TLV320AIC3x_H__ 10#ifndef __TLV320AIC3x_H__
11#define __TLV320AIC3x_H__ 11#define __TLV320AIC3x_H__
12 12
13/* GPIO API */
14enum {
15 AIC3X_GPIO1_FUNC_DISABLED = 0,
16 AIC3X_GPIO1_FUNC_AUDIO_WORDCLK_ADC = 1,
17 AIC3X_GPIO1_FUNC_CLOCK_MUX = 2,
18 AIC3X_GPIO1_FUNC_CLOCK_MUX_DIV2 = 3,
19 AIC3X_GPIO1_FUNC_CLOCK_MUX_DIV4 = 4,
20 AIC3X_GPIO1_FUNC_CLOCK_MUX_DIV8 = 5,
21 AIC3X_GPIO1_FUNC_SHORT_CIRCUIT_IRQ = 6,
22 AIC3X_GPIO1_FUNC_AGC_NOISE_IRQ = 7,
23 AIC3X_GPIO1_FUNC_INPUT = 8,
24 AIC3X_GPIO1_FUNC_OUTPUT = 9,
25 AIC3X_GPIO1_FUNC_DIGITAL_MIC_MODCLK = 10,
26 AIC3X_GPIO1_FUNC_AUDIO_WORDCLK = 11,
27 AIC3X_GPIO1_FUNC_BUTTON_IRQ = 12,
28 AIC3X_GPIO1_FUNC_HEADSET_DETECT_IRQ = 13,
29 AIC3X_GPIO1_FUNC_HEADSET_DETECT_OR_BUTTON_IRQ = 14,
30 AIC3X_GPIO1_FUNC_ALL_IRQ = 16
31};
32
33enum {
34 AIC3X_GPIO2_FUNC_DISABLED = 0,
35 AIC3X_GPIO2_FUNC_HEADSET_DETECT_IRQ = 2,
36 AIC3X_GPIO2_FUNC_INPUT = 3,
37 AIC3X_GPIO2_FUNC_OUTPUT = 4,
38 AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT = 5,
39 AIC3X_GPIO2_FUNC_AUDIO_BITCLK = 8,
40 AIC3X_GPIO2_FUNC_HEADSET_DETECT_OR_BUTTON_IRQ = 9,
41 AIC3X_GPIO2_FUNC_ALL_IRQ = 10,
42 AIC3X_GPIO2_FUNC_SHORT_CIRCUIT_OR_AGC_IRQ = 11,
43 AIC3X_GPIO2_FUNC_HEADSET_OR_BUTTON_PRESS_OR_SHORT_CIRCUIT_IRQ = 12,
44 AIC3X_GPIO2_FUNC_SHORT_CIRCUIT_IRQ = 13,
45 AIC3X_GPIO2_FUNC_AGC_NOISE_IRQ = 14,
46 AIC3X_GPIO2_FUNC_BUTTON_PRESS_IRQ = 15
47};
48
49struct aic3x_setup_data {
50 unsigned int gpio_func[2];
51};
52
13struct aic3x_pdata { 53struct aic3x_pdata {
14 int gpio_reset; /* < 0 if not used */ 54 int gpio_reset; /* < 0 if not used */
55 struct aic3x_setup_data *setup;
15}; 56};
16 57
17#endif \ No newline at end of file 58#endif
diff --git a/include/sound/tlv320dac33-plat.h b/include/sound/tlv320dac33-plat.h
index 6c6649656798..0b94192a8cdf 100644
--- a/include/sound/tlv320dac33-plat.h
+++ b/include/sound/tlv320dac33-plat.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Platform header for Texas Instruments TLV320DAC33 codec driver 2 * Platform header for Texas Instruments TLV320DAC33 codec driver
3 * 3 *
4 * Author: Peter Ujfalusi <peter.ujfalusi@nokia.com> 4 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
5 * 5 *
6 * Copyright: (C) 2009 Nokia Corporation 6 * Copyright: (C) 2009 Nokia Corporation
7 * 7 *
diff --git a/include/sound/tpa6130a2-plat.h b/include/sound/tpa6130a2-plat.h
index e29fde6b5cbe..89beccb57edd 100644
--- a/include/sound/tpa6130a2-plat.h
+++ b/include/sound/tpa6130a2-plat.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) Nokia Corporation 4 * Copyright (C) Nokia Corporation
5 * 5 *
6 * Written by Peter Ujfalusi <peter.ujfalusi@nokia.com> 6 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License 9 * modify it under the terms of the GNU General Public License
diff --git a/include/sound/version.h b/include/sound/version.h
index bf69a5b7e65f..8fc5321e1ecc 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h */ 1/* include/version.h */
2#define CONFIG_SND_VERSION "1.0.23" 2#define CONFIG_SND_VERSION "1.0.24"
3#define CONFIG_SND_DATE "" 3#define CONFIG_SND_DATE ""
diff --git a/include/sound/wm8903.h b/include/sound/wm8903.h
index b4a0db2307ef..cf7ccb76a8de 100644
--- a/include/sound/wm8903.h
+++ b/include/sound/wm8903.h
@@ -17,13 +17,9 @@
17/* 17/*
18 * R6 (0x06) - Mic Bias Control 0 18 * R6 (0x06) - Mic Bias Control 0
19 */ 19 */
20#define WM8903_MICDET_HYST_ENA 0x0080 /* MICDET_HYST_ENA */ 20#define WM8903_MICDET_THR_MASK 0x0030 /* MICDET_THR - [5:4] */
21#define WM8903_MICDET_HYST_ENA_MASK 0x0080 /* MICDET_HYST_ENA */ 21#define WM8903_MICDET_THR_SHIFT 4 /* MICDET_THR - [5:4] */
22#define WM8903_MICDET_HYST_ENA_SHIFT 7 /* MICDET_HYST_ENA */ 22#define WM8903_MICDET_THR_WIDTH 2 /* MICDET_THR - [5:4] */
23#define WM8903_MICDET_HYST_ENA_WIDTH 1 /* MICDET_HYST_ENA */
24#define WM8903_MICDET_THR_MASK 0x0070 /* MICDET_THR - [6:4] */
25#define WM8903_MICDET_THR_SHIFT 4 /* MICDET_THR - [6:4] */
26#define WM8903_MICDET_THR_WIDTH 3 /* MICDET_THR - [6:4] */
27#define WM8903_MICSHORT_THR_MASK 0x000C /* MICSHORT_THR - [3:2] */ 23#define WM8903_MICSHORT_THR_MASK 0x000C /* MICSHORT_THR - [3:2] */
28#define WM8903_MICSHORT_THR_SHIFT 2 /* MICSHORT_THR - [3:2] */ 24#define WM8903_MICSHORT_THR_SHIFT 2 /* MICSHORT_THR - [3:2] */
29#define WM8903_MICSHORT_THR_WIDTH 2 /* MICSHORT_THR - [3:2] */ 25#define WM8903_MICSHORT_THR_WIDTH 2 /* MICSHORT_THR - [3:2] */
@@ -37,6 +33,21 @@
37#define WM8903_MICBIAS_ENA_WIDTH 1 /* MICBIAS_ENA */ 33#define WM8903_MICBIAS_ENA_WIDTH 1 /* MICBIAS_ENA */
38 34
39/* 35/*
36 * WM8903_GPn_FN values
37 *
38 * See datasheets for list of valid values per pin
39 */
40#define WM8903_GPn_FN_GPIO_OUTPUT 0
41#define WM8903_GPn_FN_BCLK 1
42#define WM8903_GPn_FN_IRQ_OUTPT 2
43#define WM8903_GPn_FN_GPIO_INPUT 3
44#define WM8903_GPn_FN_MICBIAS_CURRENT_DETECT 4
45#define WM8903_GPn_FN_MICBIAS_SHORT_DETECT 5
46#define WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT 6
47#define WM8903_GPn_FN_FLL_LOCK_OUTPUT 8
48#define WM8903_GPn_FN_FLL_CLOCK_OUTPUT 9
49
50/*
40 * R116 (0x74) - GPIO Control 1 51 * R116 (0x74) - GPIO Control 1
41 */ 52 */
42#define WM8903_GP1_FN_MASK 0x1F00 /* GP1_FN - [12:8] */ 53#define WM8903_GP1_FN_MASK 0x1F00 /* GP1_FN - [12:8] */
@@ -231,6 +242,8 @@
231#define WM8903_GP5_DB_SHIFT 0 /* GP5_DB */ 242#define WM8903_GP5_DB_SHIFT 0 /* GP5_DB */
232#define WM8903_GP5_DB_WIDTH 1 /* GP5_DB */ 243#define WM8903_GP5_DB_WIDTH 1 /* GP5_DB */
233 244
245#define WM8903_NUM_GPIO 5
246
234struct wm8903_platform_data { 247struct wm8903_platform_data {
235 bool irq_active_low; /* Set if IRQ active low, default high */ 248 bool irq_active_low; /* Set if IRQ active low, default high */
236 249
@@ -243,7 +256,8 @@ struct wm8903_platform_data {
243 256
244 int micdet_delay; /* Delay after microphone detection (ms) */ 257 int micdet_delay; /* Delay after microphone detection (ms) */
245 258
246 u32 gpio_cfg[5]; /* Default register values for GPIO pin mux */ 259 int gpio_base;
260 u32 gpio_cfg[WM8903_NUM_GPIO]; /* Default register values for GPIO pin mux */
247}; 261};
248 262
249#endif 263#endif
diff --git a/include/sound/wm8915.h b/include/sound/wm8915.h
new file mode 100644
index 000000000000..5817d762f6f3
--- /dev/null
+++ b/include/sound/wm8915.h
@@ -0,0 +1,55 @@
1/*
2 * linux/sound/wm8915.h -- Platform data for WM8915
3 *
4 * Copyright 2011 Wolfson Microelectronics. PLC.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __LINUX_SND_WM8903_H
12#define __LINUX_SND_WM8903_H
13
14enum wm8915_inmode {
15 WM8915_DIFFERRENTIAL_1 = 0, /* IN1xP - IN1xN */
16 WM8915_INVERTING = 1, /* IN1xN */
17 WM8915_NON_INVERTING = 2, /* IN1xP */
18 WM8915_DIFFERENTIAL_2 = 3, /* IN2xP - IN2xP */
19};
20
21/**
22 * ReTune Mobile configurations are specified with a label, sample
23 * rate and set of values to write (the enable bits will be ignored).
24 *
25 * Configurations are expected to be generated using the ReTune Mobile
26 * control panel in WISCE - see http://www.wolfsonmicro.com/wisce/
27 */
28struct wm8915_retune_mobile_config {
29 const char *name;
30 int rate;
31 u16 regs[20];
32};
33
34#define WM8915_SET_DEFAULT 0x10000
35
36struct wm8915_pdata {
37 int irq_flags; /** Set IRQ trigger flags; default active low */
38
39 int ldo_ena; /** GPIO for LDO1; -1 for none */
40
41 int micdet_def; /** Default MICDET_SRC/HP1FB_SRC/MICD_BIAS */
42
43 enum wm8915_inmode inl_mode;
44 enum wm8915_inmode inr_mode;
45
46 u32 spkmute_seq; /** Value for register 0x802 */
47
48 int gpio_base;
49 u32 gpio_default[5];
50
51 int num_retune_mobile_cfgs;
52 struct wm8915_retune_mobile_config *retune_mobile_cfgs;
53};
54
55#endif
diff --git a/include/sound/wm8962.h b/include/sound/wm8962.h
new file mode 100644
index 000000000000..1750bed7c2f6
--- /dev/null
+++ b/include/sound/wm8962.h
@@ -0,0 +1,54 @@
1/*
2 * wm8962.h -- WM8962 Soc Audio driver platform data
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef _WM8962_PDATA_H
10#define _WM8962_PDATA_H
11
12#define WM8962_MAX_GPIO 6
13
14/* Use to set GPIO default values to zero */
15#define WM8962_GPIO_SET 0x10000
16
17#define WM8962_GPIO_FN_CLKOUT 0
18#define WM8962_GPIO_FN_LOGIC 1
19#define WM8962_GPIO_FN_SDOUT 2
20#define WM8962_GPIO_FN_IRQ 3
21#define WM8962_GPIO_FN_THERMAL 4
22#define WM8962_GPIO_FN_PLL2_LOCK 6
23#define WM8962_GPIO_FN_PLL3_LOCK 7
24#define WM8962_GPIO_FN_FLL_LOCK 9
25#define WM8962_GPIO_FN_DRC_ACT 10
26#define WM8962_GPIO_FN_WSEQ_DONE 11
27#define WM8962_GPIO_FN_ALC_NG_ACT 12
28#define WM8962_GPIO_FN_ALC_PEAK_LIMIT 13
29#define WM8962_GPIO_FN_ALC_SATURATION 14
30#define WM8962_GPIO_FN_ALC_LEVEL_THR 15
31#define WM8962_GPIO_FN_ALC_LEVEL_LOCK 16
32#define WM8962_GPIO_FN_FIFO_ERR 17
33#define WM8962_GPIO_FN_OPCLK 18
34#define WM8962_GPIO_FN_DMICCLK 19
35#define WM8962_GPIO_FN_DMICDAT 20
36#define WM8962_GPIO_FN_MICD 21
37#define WM8962_GPIO_FN_MICSCD 22
38
39struct wm8962_pdata {
40 int gpio_base;
41 u32 gpio_init[WM8962_MAX_GPIO];
42
43 /* Setup for microphone detection, raw value to be written to
44 * R48(0x30) - only microphone related bits will be updated.
45 * Detection may be enabled here for use with signals brought
46 * out on the GPIOs. */
47 u32 mic_cfg;
48
49 bool irq_active_low;
50
51 bool spk_mono; /* Speaker outputs tied together as mono */
52};
53
54#endif
diff --git a/include/sound/wm9081.h b/include/sound/wm9081.h
index e173ddbf6bd4..f34b0b1716d8 100644
--- a/include/sound/wm9081.h
+++ b/include/sound/wm9081.h
@@ -17,9 +17,12 @@ struct wm9081_retune_mobile_setting {
17 u16 config[20]; 17 u16 config[20];
18}; 18};
19 19
20struct wm9081_retune_mobile_config { 20struct wm9081_pdata {
21 struct wm9081_retune_mobile_setting *configs; 21 bool irq_high; /* IRQ is active high */
22 int num_configs; 22 bool irq_cmos; /* IRQ is in CMOS mode */
23
24 struct wm9081_retune_mobile_setting *retune_configs;
25 int num_retune_configs;
23}; 26};
24 27
25#endif 28#endif
diff --git a/include/target/configfs_macros.h b/include/target/configfs_macros.h
new file mode 100644
index 000000000000..7fe74608b437
--- /dev/null
+++ b/include/target/configfs_macros.h
@@ -0,0 +1,147 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * configfs_macros.h - extends macros for configfs
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 021110-1307, USA.
20 *
21 * Based on sysfs:
22 * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel
23 *
24 * Based on kobject.h:
25 * Copyright (c) 2002-2003 Patrick Mochel
26 * Copyright (c) 2002-2003 Open Source Development Labs
27 *
28 * configfs Copyright (C) 2005 Oracle. All rights reserved.
29 *
30 * Added CONFIGFS_EATTR() macros from original configfs.h macros
31 * Copright (C) 2008-2009 Nicholas A. Bellinger <nab@linux-iscsi.org>
32 *
33 * Please read Documentation/filesystems/configfs.txt before using the
34 * configfs interface, ESPECIALLY the parts about reference counts and
35 * item destructors.
36 */
37
38#ifndef _CONFIGFS_MACROS_H_
39#define _CONFIGFS_MACROS_H_
40
41#include <linux/configfs.h>
42
43/*
44 * Users often need to create attribute structures for their configurable
45 * attributes, containing a configfs_attribute member and function pointers
46 * for the show() and store() operations on that attribute. If they don't
47 * need anything else on the extended attribute structure, they can use
48 * this macro to define it. The argument _name isends up as
49 * 'struct _name_attribute, as well as names of to CONFIGFS_ATTR_OPS() below.
50 * The argument _item is the name of the structure containing the
51 * struct config_item or struct config_group structure members
52 */
53#define CONFIGFS_EATTR_STRUCT(_name, _item) \
54struct _name##_attribute { \
55 struct configfs_attribute attr; \
56 ssize_t (*show)(struct _item *, char *); \
57 ssize_t (*store)(struct _item *, const char *, size_t); \
58}
59
60/*
61 * With the extended attribute structure, users can use this macro
62 * (similar to sysfs' __ATTR) to make defining attributes easier.
63 * An example:
64 * #define MYITEM_EATTR(_name, _mode, _show, _store) \
65 * struct myitem_attribute childless_attr_##_name = \
66 * __CONFIGFS_EATTR(_name, _mode, _show, _store)
67 */
68#define __CONFIGFS_EATTR(_name, _mode, _show, _store) \
69{ \
70 .attr = { \
71 .ca_name = __stringify(_name), \
72 .ca_mode = _mode, \
73 .ca_owner = THIS_MODULE, \
74 }, \
75 .show = _show, \
76 .store = _store, \
77}
78/* Here is a readonly version, only requiring a show() operation */
79#define __CONFIGFS_EATTR_RO(_name, _show) \
80{ \
81 .attr = { \
82 .ca_name = __stringify(_name), \
83 .ca_mode = 0444, \
84 .ca_owner = THIS_MODULE, \
85 }, \
86 .show = _show, \
87}
88
89/*
90 * With these extended attributes, the simple show_attribute() and
91 * store_attribute() operations need to call the show() and store() of the
92 * attributes. This is a common pattern, so we provide a macro to define
93 * them. The argument _name is the name of the attribute defined by
94 * CONFIGFS_ATTR_STRUCT(). The argument _item is the name of the structure
95 * containing the struct config_item or struct config_group structure member.
96 * The argument _item_member is the actual name of the struct config_* struct
97 * in your _item structure. Meaning my_structure->some_config_group.
98 * ^^_item^^^^^ ^^_item_member^^^
99 * This macro expects the attributes to be named "struct <name>_attribute".
100 */
101#define CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member) \
102static struct _item *to_##_name(struct config_item *ci) \
103{ \
104 return (ci) ? container_of(to_config_group(ci), struct _item, \
105 _item_member) : NULL; \
106}
107
108#define CONFIGFS_EATTR_OPS_SHOW(_name, _item) \
109static ssize_t _name##_attr_show(struct config_item *item, \
110 struct configfs_attribute *attr, \
111 char *page) \
112{ \
113 struct _item *_item = to_##_name(item); \
114 struct _name##_attribute * _name##_attr = \
115 container_of(attr, struct _name##_attribute, attr); \
116 ssize_t ret = 0; \
117 \
118 if (_name##_attr->show) \
119 ret = _name##_attr->show(_item, page); \
120 return ret; \
121}
122
123#define CONFIGFS_EATTR_OPS_STORE(_name, _item) \
124static ssize_t _name##_attr_store(struct config_item *item, \
125 struct configfs_attribute *attr, \
126 const char *page, size_t count) \
127{ \
128 struct _item *_item = to_##_name(item); \
129 struct _name##_attribute * _name##_attr = \
130 container_of(attr, struct _name##_attribute, attr); \
131 ssize_t ret = -EINVAL; \
132 \
133 if (_name##_attr->store) \
134 ret = _name##_attr->store(_item, page, count); \
135 return ret; \
136}
137
138#define CONFIGFS_EATTR_OPS(_name, _item, _item_member) \
139 CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \
140 CONFIGFS_EATTR_OPS_SHOW(_name, _item); \
141 CONFIGFS_EATTR_OPS_STORE(_name, _item);
142
143#define CONFIGFS_EATTR_OPS_RO(_name, _item, _item_member) \
144 CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \
145 CONFIGFS_EATTR_OPS_SHOW(_name, _item);
146
147#endif /* _CONFIGFS_MACROS_H_ */
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
new file mode 100644
index 000000000000..561ac99def5a
--- /dev/null
+++ b/include/target/target_core_base.h
@@ -0,0 +1,985 @@
1#ifndef TARGET_CORE_BASE_H
2#define TARGET_CORE_BASE_H
3
4#include <linux/in.h>
5#include <linux/configfs.h>
6#include <linux/dma-mapping.h>
7#include <linux/blkdev.h>
8#include <scsi/scsi_cmnd.h>
9#include <net/sock.h>
10#include <net/tcp.h>
11
12#define TARGET_CORE_MOD_VERSION "v4.0.0-rc7-ml"
13#define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGABRT))
14
15/* Used by transport_generic_allocate_iovecs() */
16#define TRANSPORT_IOV_DATA_BUFFER 5
17/* Maximum Number of LUNs per Target Portal Group */
18#define TRANSPORT_MAX_LUNS_PER_TPG 256
19/*
20 * By default we use 32-byte CDBs in TCM Core and subsystem plugin code.
21 *
22 * Note that both include/scsi/scsi_cmnd.h:MAX_COMMAND_SIZE and
23 * include/linux/blkdev.h:BLOCK_MAX_CDB as of v2.6.36-rc4 still use
24 * 16-byte CDBs by default and require an extra allocation for
25 * 32-byte CDBs to because of legacy issues.
26 *
27 * Within TCM Core there are no such legacy limitiations, so we go ahead
28 * use 32-byte CDBs by default and use include/scsi/scsi.h:scsi_command_size()
29 * within all TCM Core and subsystem plugin code.
30 */
31#define TCM_MAX_COMMAND_SIZE 32
32/*
33 * From include/scsi/scsi_cmnd.h:SCSI_SENSE_BUFFERSIZE, currently
34 * defined 96, but the real limit is 252 (or 260 including the header)
35 */
36#define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE
37/* Used by transport_send_check_condition_and_sense() */
38#define SPC_SENSE_KEY_OFFSET 2
39#define SPC_ASC_KEY_OFFSET 12
40#define SPC_ASCQ_KEY_OFFSET 13
41#define TRANSPORT_IQN_LEN 224
42/* Used by target_core_store_alua_lu_gp() and target_core_alua_lu_gp_show_attr_members() */
43#define LU_GROUP_NAME_BUF 256
44/* Used by core_alua_store_tg_pt_gp_info() and target_core_alua_tg_pt_gp_show_attr_members() */
45#define TG_PT_GROUP_NAME_BUF 256
46/* Used to parse VPD into struct t10_vpd */
47#define VPD_TMP_BUF_SIZE 128
48/* Used by transport_generic_cmd_sequencer() */
49#define READ_BLOCK_LEN 6
50#define READ_CAP_LEN 8
51#define READ_POSITION_LEN 20
52#define INQUIRY_LEN 36
53/* Used by transport_get_inquiry_vpd_serial() */
54#define INQUIRY_VPD_SERIAL_LEN 254
55/* Used by transport_get_inquiry_vpd_device_ident() */
56#define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254
57
58/* struct se_hba->hba_flags */
59enum hba_flags_table {
60 HBA_FLAGS_INTERNAL_USE = 0x01,
61 HBA_FLAGS_PSCSI_MODE = 0x02,
62};
63
64/* struct se_lun->lun_status */
65enum transport_lun_status_table {
66 TRANSPORT_LUN_STATUS_FREE = 0,
67 TRANSPORT_LUN_STATUS_ACTIVE = 1,
68};
69
70/* struct se_portal_group->se_tpg_type */
71enum transport_tpg_type_table {
72 TRANSPORT_TPG_TYPE_NORMAL = 0,
73 TRANSPORT_TPG_TYPE_DISCOVERY = 1,
74};
75
76/* Used for generate timer flags */
77enum timer_flags_table {
78 TF_RUNNING = 0x01,
79 TF_STOP = 0x02,
80};
81
82/* Special transport agnostic struct se_cmd->t_states */
83enum transport_state_table {
84 TRANSPORT_NO_STATE = 0,
85 TRANSPORT_NEW_CMD = 1,
86 TRANSPORT_DEFERRED_CMD = 2,
87 TRANSPORT_WRITE_PENDING = 3,
88 TRANSPORT_PROCESS_WRITE = 4,
89 TRANSPORT_PROCESSING = 5,
90 TRANSPORT_COMPLETE_OK = 6,
91 TRANSPORT_COMPLETE_FAILURE = 7,
92 TRANSPORT_COMPLETE_TIMEOUT = 8,
93 TRANSPORT_PROCESS_TMR = 9,
94 TRANSPORT_TMR_COMPLETE = 10,
95 TRANSPORT_ISTATE_PROCESSING = 11,
96 TRANSPORT_ISTATE_PROCESSED = 12,
97 TRANSPORT_KILL = 13,
98 TRANSPORT_REMOVE = 14,
99 TRANSPORT_FREE = 15,
100 TRANSPORT_NEW_CMD_MAP = 16,
101 TRANSPORT_FREE_CMD_INTR = 17,
102};
103
104/* Used for struct se_cmd->se_cmd_flags */
105enum se_cmd_flags_table {
106 SCF_SUPPORTED_SAM_OPCODE = 0x00000001,
107 SCF_TRANSPORT_TASK_SENSE = 0x00000002,
108 SCF_EMULATED_TASK_SENSE = 0x00000004,
109 SCF_SCSI_DATA_SG_IO_CDB = 0x00000008,
110 SCF_SCSI_CONTROL_SG_IO_CDB = 0x00000010,
111 SCF_SCSI_CONTROL_NONSG_IO_CDB = 0x00000020,
112 SCF_SCSI_NON_DATA_CDB = 0x00000040,
113 SCF_SCSI_CDB_EXCEPTION = 0x00000080,
114 SCF_SCSI_RESERVATION_CONFLICT = 0x00000100,
115 SCF_CMD_PASSTHROUGH_NOALLOC = 0x00000200,
116 SCF_SE_CMD_FAILED = 0x00000400,
117 SCF_SE_LUN_CMD = 0x00000800,
118 SCF_SE_ALLOW_EOO = 0x00001000,
119 SCF_SE_DISABLE_ONLINE_CHECK = 0x00002000,
120 SCF_SENT_CHECK_CONDITION = 0x00004000,
121 SCF_OVERFLOW_BIT = 0x00008000,
122 SCF_UNDERFLOW_BIT = 0x00010000,
123 SCF_SENT_DELAYED_TAS = 0x00020000,
124 SCF_ALUA_NON_OPTIMIZED = 0x00040000,
125 SCF_DELAYED_CMD_FROM_SAM_ATTR = 0x00080000,
126 SCF_PASSTHROUGH_SG_TO_MEM = 0x00100000,
127 SCF_PASSTHROUGH_CONTIG_TO_SG = 0x00200000,
128 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00400000,
129 SCF_EMULATE_SYNC_CACHE = 0x00800000,
130 SCF_EMULATE_CDB_ASYNC = 0x01000000,
131 SCF_EMULATE_SYNC_UNMAP = 0x02000000
132};
133
134/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
135enum transport_lunflags_table {
136 TRANSPORT_LUNFLAGS_NO_ACCESS = 0x00,
137 TRANSPORT_LUNFLAGS_INITIATOR_ACCESS = 0x01,
138 TRANSPORT_LUNFLAGS_READ_ONLY = 0x02,
139 TRANSPORT_LUNFLAGS_READ_WRITE = 0x04,
140};
141
142/* struct se_device->dev_status */
143enum transport_device_status_table {
144 TRANSPORT_DEVICE_ACTIVATED = 0x01,
145 TRANSPORT_DEVICE_DEACTIVATED = 0x02,
146 TRANSPORT_DEVICE_QUEUE_FULL = 0x04,
147 TRANSPORT_DEVICE_SHUTDOWN = 0x08,
148 TRANSPORT_DEVICE_OFFLINE_ACTIVATED = 0x10,
149 TRANSPORT_DEVICE_OFFLINE_DEACTIVATED = 0x20,
150};
151
152/*
153 * Used by transport_send_check_condition_and_sense() and se_cmd->scsi_sense_reason
154 * to signal which ASC/ASCQ sense payload should be built.
155 */
156enum tcm_sense_reason_table {
157 TCM_NON_EXISTENT_LUN = 0x01,
158 TCM_UNSUPPORTED_SCSI_OPCODE = 0x02,
159 TCM_INCORRECT_AMOUNT_OF_DATA = 0x03,
160 TCM_UNEXPECTED_UNSOLICITED_DATA = 0x04,
161 TCM_SERVICE_CRC_ERROR = 0x05,
162 TCM_SNACK_REJECTED = 0x06,
163 TCM_SECTOR_COUNT_TOO_MANY = 0x07,
164 TCM_INVALID_CDB_FIELD = 0x08,
165 TCM_INVALID_PARAMETER_LIST = 0x09,
166 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = 0x0a,
167 TCM_UNKNOWN_MODE_PAGE = 0x0b,
168 TCM_WRITE_PROTECTED = 0x0c,
169 TCM_CHECK_CONDITION_ABORT_CMD = 0x0d,
170 TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e,
171 TCM_CHECK_CONDITION_NOT_READY = 0x0f,
172};
173
174struct se_obj {
175 atomic_t obj_access_count;
176} ____cacheline_aligned;
177
178/*
179 * Used by TCM Core internally to signal if ALUA emulation is enabled or
180 * disabled, or running in with TCM/pSCSI passthrough mode
181 */
182typedef enum {
183 SPC_ALUA_PASSTHROUGH,
184 SPC2_ALUA_DISABLED,
185 SPC3_ALUA_EMULATED
186} t10_alua_index_t;
187
188/*
189 * Used by TCM Core internally to signal if SAM Task Attribute emulation
190 * is enabled or disabled, or running in with TCM/pSCSI passthrough mode
191 */
192typedef enum {
193 SAM_TASK_ATTR_PASSTHROUGH,
194 SAM_TASK_ATTR_UNTAGGED,
195 SAM_TASK_ATTR_EMULATED
196} t10_task_attr_index_t;
197
198/*
199 * Used for target SCSI statistics
200 */
201typedef enum {
202 SCSI_INST_INDEX,
203 SCSI_DEVICE_INDEX,
204 SCSI_AUTH_INTR_INDEX,
205 SCSI_INDEX_TYPE_MAX
206} scsi_index_t;
207
208struct scsi_index_table {
209 spinlock_t lock;
210 u32 scsi_mib_index[SCSI_INDEX_TYPE_MAX];
211} ____cacheline_aligned;
212
213struct se_cmd;
214
215struct t10_alua {
216 t10_alua_index_t alua_type;
217 /* ALUA Target Port Group ID */
218 u16 alua_tg_pt_gps_counter;
219 u32 alua_tg_pt_gps_count;
220 spinlock_t tg_pt_gps_lock;
221 struct se_subsystem_dev *t10_sub_dev;
222 /* Used for default ALUA Target Port Group */
223 struct t10_alua_tg_pt_gp *default_tg_pt_gp;
224 /* Used for default ALUA Target Port Group ConfigFS group */
225 struct config_group alua_tg_pt_gps_group;
226 int (*alua_state_check)(struct se_cmd *, unsigned char *, u8 *);
227 struct list_head tg_pt_gps_list;
228} ____cacheline_aligned;
229
230struct t10_alua_lu_gp {
231 u16 lu_gp_id;
232 int lu_gp_valid_id;
233 u32 lu_gp_members;
234 atomic_t lu_gp_shutdown;
235 atomic_t lu_gp_ref_cnt;
236 spinlock_t lu_gp_lock;
237 struct config_group lu_gp_group;
238 struct list_head lu_gp_list;
239 struct list_head lu_gp_mem_list;
240} ____cacheline_aligned;
241
242struct t10_alua_lu_gp_member {
243 bool lu_gp_assoc;
244 atomic_t lu_gp_mem_ref_cnt;
245 spinlock_t lu_gp_mem_lock;
246 struct t10_alua_lu_gp *lu_gp;
247 struct se_device *lu_gp_mem_dev;
248 struct list_head lu_gp_mem_list;
249} ____cacheline_aligned;
250
251struct t10_alua_tg_pt_gp {
252 u16 tg_pt_gp_id;
253 int tg_pt_gp_valid_id;
254 int tg_pt_gp_alua_access_status;
255 int tg_pt_gp_alua_access_type;
256 int tg_pt_gp_nonop_delay_msecs;
257 int tg_pt_gp_trans_delay_msecs;
258 int tg_pt_gp_pref;
259 int tg_pt_gp_write_metadata;
260 /* Used by struct t10_alua_tg_pt_gp->tg_pt_gp_md_buf_len */
261#define ALUA_MD_BUF_LEN 1024
262 u32 tg_pt_gp_md_buf_len;
263 u32 tg_pt_gp_members;
264 atomic_t tg_pt_gp_alua_access_state;
265 atomic_t tg_pt_gp_ref_cnt;
266 spinlock_t tg_pt_gp_lock;
267 struct mutex tg_pt_gp_md_mutex;
268 struct se_subsystem_dev *tg_pt_gp_su_dev;
269 struct config_group tg_pt_gp_group;
270 struct list_head tg_pt_gp_list;
271 struct list_head tg_pt_gp_mem_list;
272} ____cacheline_aligned;
273
274struct t10_alua_tg_pt_gp_member {
275 bool tg_pt_gp_assoc;
276 atomic_t tg_pt_gp_mem_ref_cnt;
277 spinlock_t tg_pt_gp_mem_lock;
278 struct t10_alua_tg_pt_gp *tg_pt_gp;
279 struct se_port *tg_pt;
280 struct list_head tg_pt_gp_mem_list;
281} ____cacheline_aligned;
282
283struct t10_vpd {
284 unsigned char device_identifier[INQUIRY_VPD_DEVICE_IDENTIFIER_LEN];
285 int protocol_identifier_set;
286 u32 protocol_identifier;
287 u32 device_identifier_code_set;
288 u32 association;
289 u32 device_identifier_type;
290 struct list_head vpd_list;
291} ____cacheline_aligned;
292
293struct t10_wwn {
294 unsigned char vendor[8];
295 unsigned char model[16];
296 unsigned char revision[4];
297 unsigned char unit_serial[INQUIRY_VPD_SERIAL_LEN];
298 spinlock_t t10_vpd_lock;
299 struct se_subsystem_dev *t10_sub_dev;
300 struct config_group t10_wwn_group;
301 struct list_head t10_vpd_list;
302} ____cacheline_aligned;
303
304
305/*
306 * Used by TCM Core internally to signal if >= SPC-3 persistent reservations
307 * emulation is enabled or disabled, or running in with TCM/pSCSI passthrough
308 * mode
309 */
310typedef enum {
311 SPC_PASSTHROUGH,
312 SPC2_RESERVATIONS,
313 SPC3_PERSISTENT_RESERVATIONS
314} t10_reservations_index_t;
315
316struct t10_pr_registration {
317 /* Used for fabrics that contain WWN+ISID */
318#define PR_REG_ISID_LEN 16
319 /* PR_REG_ISID_LEN + ',i,0x' */
320#define PR_REG_ISID_ID_LEN (PR_REG_ISID_LEN + 5)
321 char pr_reg_isid[PR_REG_ISID_LEN];
322 /* Used during APTPL metadata reading */
323#define PR_APTPL_MAX_IPORT_LEN 256
324 unsigned char pr_iport[PR_APTPL_MAX_IPORT_LEN];
325 /* Used during APTPL metadata reading */
326#define PR_APTPL_MAX_TPORT_LEN 256
327 unsigned char pr_tport[PR_APTPL_MAX_TPORT_LEN];
328 /* For writing out live meta data */
329 unsigned char *pr_aptpl_buf;
330 u16 pr_aptpl_rpti;
331 u16 pr_reg_tpgt;
332 /* Reservation effects all target ports */
333 int pr_reg_all_tg_pt;
334 /* Activate Persistence across Target Power Loss */
335 int pr_reg_aptpl;
336 int pr_res_holder;
337 int pr_res_type;
338 int pr_res_scope;
339 /* Used for fabric initiator WWPNs using a ISID */
340 bool isid_present_at_reg;
341 u32 pr_res_mapped_lun;
342 u32 pr_aptpl_target_lun;
343 u32 pr_res_generation;
344 u64 pr_reg_bin_isid;
345 u64 pr_res_key;
346 atomic_t pr_res_holders;
347 struct se_node_acl *pr_reg_nacl;
348 struct se_dev_entry *pr_reg_deve;
349 struct se_lun *pr_reg_tg_pt_lun;
350 struct list_head pr_reg_list;
351 struct list_head pr_reg_abort_list;
352 struct list_head pr_reg_aptpl_list;
353 struct list_head pr_reg_atp_list;
354 struct list_head pr_reg_atp_mem_list;
355} ____cacheline_aligned;
356
357/*
358 * This set of function pointer ops is set based upon SPC3_PERSISTENT_RESERVATIONS,
359 * SPC2_RESERVATIONS or SPC_PASSTHROUGH in drivers/target/target_core_pr.c:
360 * core_setup_reservations()
361 */
362struct t10_reservation_ops {
363 int (*t10_reservation_check)(struct se_cmd *, u32 *);
364 int (*t10_seq_non_holder)(struct se_cmd *, unsigned char *, u32);
365 int (*t10_pr_register)(struct se_cmd *);
366 int (*t10_pr_clear)(struct se_cmd *);
367};
368
369struct t10_reservation_template {
370 /* Reservation effects all target ports */
371 int pr_all_tg_pt;
372 /* Activate Persistence across Target Power Loss enabled
373 * for SCSI device */
374 int pr_aptpl_active;
375 /* Used by struct t10_reservation_template->pr_aptpl_buf_len */
376#define PR_APTPL_BUF_LEN 8192
377 u32 pr_aptpl_buf_len;
378 u32 pr_generation;
379 t10_reservations_index_t res_type;
380 spinlock_t registration_lock;
381 spinlock_t aptpl_reg_lock;
382 /*
383 * This will always be set by one individual I_T Nexus.
384 * However with all_tg_pt=1, other I_T Nexus from the
385 * same initiator can access PR reg/res info on a different
386 * target port.
387 *
388 * There is also the 'All Registrants' case, where there is
389 * a single *pr_res_holder of the reservation, but all
390 * registrations are considered reservation holders.
391 */
392 struct se_node_acl *pr_res_holder;
393 struct list_head registration_list;
394 struct list_head aptpl_reg_list;
395 struct t10_reservation_ops pr_ops;
396} ____cacheline_aligned;
397
398struct se_queue_req {
399 int state;
400 void *cmd;
401 struct list_head qr_list;
402} ____cacheline_aligned;
403
404struct se_queue_obj {
405 atomic_t queue_cnt;
406 spinlock_t cmd_queue_lock;
407 struct list_head qobj_list;
408 wait_queue_head_t thread_wq;
409} ____cacheline_aligned;
410
411/*
412 * Used one per struct se_cmd to hold all extra struct se_task
413 * metadata. This structure is setup and allocated in
414 * drivers/target/target_core_transport.c:__transport_alloc_se_cmd()
415 */
416struct se_transport_task {
417 unsigned char *t_task_cdb;
418 unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];
419 unsigned long long t_task_lba;
420 int t_tasks_failed;
421 int t_tasks_fua;
422 bool t_tasks_bidi;
423 u32 t_task_cdbs;
424 u32 t_tasks_check;
425 u32 t_tasks_no;
426 u32 t_tasks_sectors;
427 u32 t_tasks_se_num;
428 u32 t_tasks_se_bidi_num;
429 u32 t_tasks_sg_chained_no;
430 atomic_t t_fe_count;
431 atomic_t t_se_count;
432 atomic_t t_task_cdbs_left;
433 atomic_t t_task_cdbs_ex_left;
434 atomic_t t_task_cdbs_timeout_left;
435 atomic_t t_task_cdbs_sent;
436 atomic_t t_transport_aborted;
437 atomic_t t_transport_active;
438 atomic_t t_transport_complete;
439 atomic_t t_transport_queue_active;
440 atomic_t t_transport_sent;
441 atomic_t t_transport_stop;
442 atomic_t t_transport_timeout;
443 atomic_t transport_dev_active;
444 atomic_t transport_lun_active;
445 atomic_t transport_lun_fe_stop;
446 atomic_t transport_lun_stop;
447 spinlock_t t_state_lock;
448 struct completion t_transport_stop_comp;
449 struct completion transport_lun_fe_stop_comp;
450 struct completion transport_lun_stop_comp;
451 struct scatterlist *t_tasks_sg_chained;
452 struct scatterlist t_tasks_sg_bounce;
453 void *t_task_buf;
454 /*
455 * Used for pre-registered fabric SGL passthrough WRITE and READ
456 * with the special SCF_PASSTHROUGH_CONTIG_TO_SG case for TCM_Loop
457 * and other HW target mode fabric modules.
458 */
459 struct scatterlist *t_task_pt_sgl;
460 struct list_head *t_mem_list;
461 /* Used for BIDI READ */
462 struct list_head *t_mem_bidi_list;
463 struct list_head t_task_list;
464} ____cacheline_aligned;
465
466struct se_task {
467 unsigned char task_sense;
468 struct scatterlist *task_sg;
469 struct scatterlist *task_sg_bidi;
470 u8 task_scsi_status;
471 u8 task_flags;
472 int task_error_status;
473 int task_state_flags;
474 bool task_padded_sg;
475 unsigned long long task_lba;
476 u32 task_no;
477 u32 task_sectors;
478 u32 task_size;
479 u32 task_sg_num;
480 u32 task_sg_offset;
481 enum dma_data_direction task_data_direction;
482 struct se_cmd *task_se_cmd;
483 struct se_device *se_dev;
484 struct completion task_stop_comp;
485 atomic_t task_active;
486 atomic_t task_execute_queue;
487 atomic_t task_timeout;
488 atomic_t task_sent;
489 atomic_t task_stop;
490 atomic_t task_state_active;
491 struct timer_list task_timer;
492 struct se_device *se_obj_ptr;
493 struct list_head t_list;
494 struct list_head t_execute_list;
495 struct list_head t_state_list;
496} ____cacheline_aligned;
497
498#define TASK_CMD(task) ((task)->task_se_cmd)
499#define TASK_DEV(task) ((task)->se_dev)
500
501struct se_cmd {
502 /* SAM response code being sent to initiator */
503 u8 scsi_status;
504 u8 scsi_asc;
505 u8 scsi_ascq;
506 u8 scsi_sense_reason;
507 u16 scsi_sense_length;
508 /* Delay for ALUA Active/NonOptimized state access in milliseconds */
509 int alua_nonop_delay;
510 /* See include/linux/dma-mapping.h */
511 enum dma_data_direction data_direction;
512 /* For SAM Task Attribute */
513 int sam_task_attr;
514 /* Transport protocol dependent state, see transport_state_table */
515 enum transport_state_table t_state;
516 /* Transport protocol dependent state for out of order CmdSNs */
517 int deferred_t_state;
518 /* Transport specific error status */
519 int transport_error_status;
520 /* See se_cmd_flags_table */
521 u32 se_cmd_flags;
522 u32 se_ordered_id;
523 /* Total size in bytes associated with command */
524 u32 data_length;
525 /* SCSI Presented Data Transfer Length */
526 u32 cmd_spdtl;
527 u32 residual_count;
528 u32 orig_fe_lun;
529 /* Persistent Reservation key */
530 u64 pr_res_key;
531 atomic_t transport_sent;
532 /* Used for sense data */
533 void *sense_buffer;
534 struct list_head se_delayed_list;
535 struct list_head se_ordered_list;
536 struct list_head se_lun_list;
537 struct se_device *se_dev;
538 struct se_dev_entry *se_deve;
539 struct se_device *se_obj_ptr;
540 struct se_device *se_orig_obj_ptr;
541 struct se_lun *se_lun;
542 /* Only used for internal passthrough and legacy TCM fabric modules */
543 struct se_session *se_sess;
544 struct se_tmr_req *se_tmr_req;
545 /* t_task is setup to t_task_backstore in transport_init_se_cmd() */
546 struct se_transport_task *t_task;
547 struct se_transport_task t_task_backstore;
548 struct target_core_fabric_ops *se_tfo;
549 int (*transport_emulate_cdb)(struct se_cmd *);
550 void (*transport_split_cdb)(unsigned long long, u32 *, unsigned char *);
551 void (*transport_wait_for_tasks)(struct se_cmd *, int, int);
552 void (*transport_complete_callback)(struct se_cmd *);
553} ____cacheline_aligned;
554
555#define T_TASK(cmd) ((cmd)->t_task)
556#define CMD_TFO(cmd) ((cmd)->se_tfo)
557
558struct se_tmr_req {
559 /* Task Management function to be preformed */
560 u8 function;
561 /* Task Management response to send */
562 u8 response;
563 int call_transport;
564 /* Reference to ITT that Task Mgmt should be preformed */
565 u32 ref_task_tag;
566 /* 64-bit encoded SAM LUN from $FABRIC_MOD TMR header */
567 u64 ref_task_lun;
568 void *fabric_tmr_ptr;
569 struct se_cmd *task_cmd;
570 struct se_cmd *ref_cmd;
571 struct se_device *tmr_dev;
572 struct se_lun *tmr_lun;
573 struct list_head tmr_list;
574} ____cacheline_aligned;
575
576struct se_ua {
577 u8 ua_asc;
578 u8 ua_ascq;
579 struct se_node_acl *ua_nacl;
580 struct list_head ua_dev_list;
581 struct list_head ua_nacl_list;
582} ____cacheline_aligned;
583
584struct se_node_acl {
585 char initiatorname[TRANSPORT_IQN_LEN];
586 /* Used to signal demo mode created ACL, disabled by default */
587 bool dynamic_node_acl;
588 u32 queue_depth;
589 u32 acl_index;
590 u64 num_cmds;
591 u64 read_bytes;
592 u64 write_bytes;
593 spinlock_t stats_lock;
594 /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */
595 atomic_t acl_pr_ref_count;
596 struct se_dev_entry *device_list;
597 struct se_session *nacl_sess;
598 struct se_portal_group *se_tpg;
599 spinlock_t device_list_lock;
600 spinlock_t nacl_sess_lock;
601 struct config_group acl_group;
602 struct config_group acl_attrib_group;
603 struct config_group acl_auth_group;
604 struct config_group acl_param_group;
605 struct config_group acl_fabric_stat_group;
606 struct config_group *acl_default_groups[5];
607 struct list_head acl_list;
608 struct list_head acl_sess_list;
609} ____cacheline_aligned;
610
611struct se_session {
612 u64 sess_bin_isid;
613 struct se_node_acl *se_node_acl;
614 struct se_portal_group *se_tpg;
615 void *fabric_sess_ptr;
616 struct list_head sess_list;
617 struct list_head sess_acl_list;
618} ____cacheline_aligned;
619
620#define SE_SESS(cmd) ((cmd)->se_sess)
621#define SE_NODE_ACL(sess) ((sess)->se_node_acl)
622
623struct se_device;
624struct se_transform_info;
625struct scatterlist;
626
627struct se_ml_stat_grps {
628 struct config_group stat_group;
629 struct config_group scsi_auth_intr_group;
630 struct config_group scsi_att_intr_port_group;
631};
632
633struct se_lun_acl {
634 char initiatorname[TRANSPORT_IQN_LEN];
635 u32 mapped_lun;
636 struct se_node_acl *se_lun_nacl;
637 struct se_lun *se_lun;
638 struct list_head lacl_list;
639 struct config_group se_lun_group;
640 struct se_ml_stat_grps ml_stat_grps;
641} ____cacheline_aligned;
642
643#define ML_STAT_GRPS(lacl) (&(lacl)->ml_stat_grps)
644
645struct se_dev_entry {
646 bool def_pr_registered;
647 /* See transport_lunflags_table */
648 u32 lun_flags;
649 u32 deve_cmds;
650 u32 mapped_lun;
651 u32 average_bytes;
652 u32 last_byte_count;
653 u32 total_cmds;
654 u32 total_bytes;
655 u64 pr_res_key;
656 u64 creation_time;
657 u32 attach_count;
658 u64 read_bytes;
659 u64 write_bytes;
660 atomic_t ua_count;
661 /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */
662 atomic_t pr_ref_count;
663 struct se_lun_acl *se_lun_acl;
664 spinlock_t ua_lock;
665 struct se_lun *se_lun;
666 struct list_head alua_port_list;
667 struct list_head ua_list;
668} ____cacheline_aligned;
669
670struct se_dev_limits {
671 /* Max supported HW queue depth */
672 u32 hw_queue_depth;
673 /* Max supported virtual queue depth */
674 u32 queue_depth;
675 /* From include/linux/blkdev.h for the other HW/SW limits. */
676 struct queue_limits limits;
677} ____cacheline_aligned;
678
679struct se_dev_attrib {
680 int emulate_dpo;
681 int emulate_fua_write;
682 int emulate_fua_read;
683 int emulate_write_cache;
684 int emulate_ua_intlck_ctrl;
685 int emulate_tas;
686 int emulate_tpu;
687 int emulate_tpws;
688 int emulate_reservations;
689 int emulate_alua;
690 int enforce_pr_isids;
691 u32 hw_block_size;
692 u32 block_size;
693 u32 hw_max_sectors;
694 u32 max_sectors;
695 u32 optimal_sectors;
696 u32 hw_queue_depth;
697 u32 queue_depth;
698 u32 task_timeout;
699 u32 max_unmap_lba_count;
700 u32 max_unmap_block_desc_count;
701 u32 unmap_granularity;
702 u32 unmap_granularity_alignment;
703 struct se_subsystem_dev *da_sub_dev;
704 struct config_group da_group;
705} ____cacheline_aligned;
706
707struct se_dev_stat_grps {
708 struct config_group stat_group;
709 struct config_group scsi_dev_group;
710 struct config_group scsi_tgt_dev_group;
711 struct config_group scsi_lu_group;
712};
713
714struct se_subsystem_dev {
715/* Used for struct se_subsystem_dev-->se_dev_alias, must be less than PAGE_SIZE */
716#define SE_DEV_ALIAS_LEN 512
717 unsigned char se_dev_alias[SE_DEV_ALIAS_LEN];
718/* Used for struct se_subsystem_dev->se_dev_udev_path[], must be less than PAGE_SIZE */
719#define SE_UDEV_PATH_LEN 512
720 unsigned char se_dev_udev_path[SE_UDEV_PATH_LEN];
721 u32 su_dev_flags;
722 struct se_hba *se_dev_hba;
723 struct se_device *se_dev_ptr;
724 struct se_dev_attrib se_dev_attrib;
725 /* T10 Asymmetric Logical Unit Assignment for Target Ports */
726 struct t10_alua t10_alua;
727 /* T10 Inquiry and VPD WWN Information */
728 struct t10_wwn t10_wwn;
729 /* T10 SPC-2 + SPC-3 Reservations */
730 struct t10_reservation_template t10_reservation;
731 spinlock_t se_dev_lock;
732 void *se_dev_su_ptr;
733 struct list_head g_se_dev_list;
734 struct config_group se_dev_group;
735 /* For T10 Reservations */
736 struct config_group se_dev_pr_group;
737 /* For target_core_stat.c groups */
738 struct se_dev_stat_grps dev_stat_grps;
739} ____cacheline_aligned;
740
741#define T10_ALUA(su_dev) (&(su_dev)->t10_alua)
742#define T10_RES(su_dev) (&(su_dev)->t10_reservation)
743#define T10_PR_OPS(su_dev) (&(su_dev)->t10_reservation.pr_ops)
744#define DEV_STAT_GRP(dev) (&(dev)->dev_stat_grps)
745
746struct se_device {
747 /* Set to 1 if thread is NOT sleeping on thread_sem */
748 u8 thread_active;
749 u8 dev_status_timer_flags;
750 /* RELATIVE TARGET PORT IDENTIFER Counter */
751 u16 dev_rpti_counter;
752 /* Used for SAM Task Attribute ordering */
753 u32 dev_cur_ordered_id;
754 u32 dev_flags;
755 u32 dev_port_count;
756 /* See transport_device_status_table */
757 u32 dev_status;
758 u32 dev_tcq_window_closed;
759 /* Physical device queue depth */
760 u32 queue_depth;
761 /* Used for SPC-2 reservations enforce of ISIDs */
762 u64 dev_res_bin_isid;
763 t10_task_attr_index_t dev_task_attr_type;
764 /* Pointer to transport specific device structure */
765 void *dev_ptr;
766 u32 dev_index;
767 u64 creation_time;
768 u32 num_resets;
769 u64 num_cmds;
770 u64 read_bytes;
771 u64 write_bytes;
772 spinlock_t stats_lock;
773 /* Active commands on this virtual SE device */
774 atomic_t active_cmds;
775 atomic_t simple_cmds;
776 atomic_t depth_left;
777 atomic_t dev_ordered_id;
778 atomic_t dev_tur_active;
779 atomic_t execute_tasks;
780 atomic_t dev_status_thr_count;
781 atomic_t dev_hoq_count;
782 atomic_t dev_ordered_sync;
783 struct se_obj dev_obj;
784 struct se_obj dev_access_obj;
785 struct se_obj dev_export_obj;
786 struct se_queue_obj *dev_queue_obj;
787 struct se_queue_obj *dev_status_queue_obj;
788 spinlock_t delayed_cmd_lock;
789 spinlock_t ordered_cmd_lock;
790 spinlock_t execute_task_lock;
791 spinlock_t state_task_lock;
792 spinlock_t dev_alua_lock;
793 spinlock_t dev_reservation_lock;
794 spinlock_t dev_state_lock;
795 spinlock_t dev_status_lock;
796 spinlock_t dev_status_thr_lock;
797 spinlock_t se_port_lock;
798 spinlock_t se_tmr_lock;
799 /* Used for legacy SPC-2 reservationsa */
800 struct se_node_acl *dev_reserved_node_acl;
801 /* Used for ALUA Logical Unit Group membership */
802 struct t10_alua_lu_gp_member *dev_alua_lu_gp_mem;
803 /* Used for SPC-3 Persistent Reservations */
804 struct t10_pr_registration *dev_pr_res_holder;
805 struct list_head dev_sep_list;
806 struct list_head dev_tmr_list;
807 struct timer_list dev_status_timer;
808 /* Pointer to descriptor for processing thread */
809 struct task_struct *process_thread;
810 pid_t process_thread_pid;
811 struct task_struct *dev_mgmt_thread;
812 struct list_head delayed_cmd_list;
813 struct list_head ordered_cmd_list;
814 struct list_head execute_task_list;
815 struct list_head state_task_list;
816 /* Pointer to associated SE HBA */
817 struct se_hba *se_hba;
818 struct se_subsystem_dev *se_sub_dev;
819 /* Pointer to template of function pointers for transport */
820 struct se_subsystem_api *transport;
821 /* Linked list for struct se_hba struct se_device list */
822 struct list_head dev_list;
823 /* Linked list for struct se_global->g_se_dev_list */
824 struct list_head g_se_dev_list;
825} ____cacheline_aligned;
826
827#define SE_DEV(cmd) ((cmd)->se_lun->lun_se_dev)
828#define SU_DEV(dev) ((dev)->se_sub_dev)
829#define DEV_ATTRIB(dev) (&(dev)->se_sub_dev->se_dev_attrib)
830#define DEV_T10_WWN(dev) (&(dev)->se_sub_dev->t10_wwn)
831
832struct se_hba {
833 u16 hba_tpgt;
834 u32 hba_id;
835 /* See hba_flags_table */
836 u32 hba_flags;
837 /* Virtual iSCSI devices attached. */
838 u32 dev_count;
839 u32 hba_index;
840 atomic_t load_balance_queue;
841 atomic_t left_queue_depth;
842 /* Maximum queue depth the HBA can handle. */
843 atomic_t max_queue_depth;
844 /* Pointer to transport specific host structure. */
845 void *hba_ptr;
846 /* Linked list for struct se_device */
847 struct list_head hba_dev_list;
848 struct list_head hba_list;
849 spinlock_t device_lock;
850 spinlock_t hba_queue_lock;
851 struct config_group hba_group;
852 struct mutex hba_access_mutex;
853 struct se_subsystem_api *transport;
854} ____cacheline_aligned;
855
856#define SE_HBA(dev) ((dev)->se_hba)
857
858struct se_port_stat_grps {
859 struct config_group stat_group;
860 struct config_group scsi_port_group;
861 struct config_group scsi_tgt_port_group;
862 struct config_group scsi_transport_group;
863};
864
865struct se_lun {
866 /* See transport_lun_status_table */
867 enum transport_lun_status_table lun_status;
868 u32 lun_access;
869 u32 lun_flags;
870 u32 unpacked_lun;
871 atomic_t lun_acl_count;
872 spinlock_t lun_acl_lock;
873 spinlock_t lun_cmd_lock;
874 spinlock_t lun_sep_lock;
875 struct completion lun_shutdown_comp;
876 struct list_head lun_cmd_list;
877 struct list_head lun_acl_list;
878 struct se_device *lun_se_dev;
879 struct se_port *lun_sep;
880 struct config_group lun_group;
881 struct se_port_stat_grps port_stat_grps;
882} ____cacheline_aligned;
883
884#define SE_LUN(cmd) ((cmd)->se_lun)
885#define PORT_STAT_GRP(lun) (&(lun)->port_stat_grps)
886
887struct scsi_port_stats {
888 u64 cmd_pdus;
889 u64 tx_data_octets;
890 u64 rx_data_octets;
891} ____cacheline_aligned;
892
893struct se_port {
894 /* RELATIVE TARGET PORT IDENTIFER */
895 u16 sep_rtpi;
896 int sep_tg_pt_secondary_stat;
897 int sep_tg_pt_secondary_write_md;
898 u32 sep_index;
899 struct scsi_port_stats sep_stats;
900 /* Used for ALUA Target Port Groups membership */
901 atomic_t sep_tg_pt_gp_active;
902 atomic_t sep_tg_pt_secondary_offline;
903 /* Used for PR ALL_TG_PT=1 */
904 atomic_t sep_tg_pt_ref_cnt;
905 spinlock_t sep_alua_lock;
906 struct mutex sep_tg_pt_md_mutex;
907 struct t10_alua_tg_pt_gp_member *sep_alua_tg_pt_gp_mem;
908 struct se_lun *sep_lun;
909 struct se_portal_group *sep_tpg;
910 struct list_head sep_alua_list;
911 struct list_head sep_list;
912} ____cacheline_aligned;
913
914struct se_tpg_np {
915 struct se_portal_group *tpg_np_parent;
916 struct config_group tpg_np_group;
917} ____cacheline_aligned;
918
919struct se_portal_group {
920 /* Type of target portal group, see transport_tpg_type_table */
921 enum transport_tpg_type_table se_tpg_type;
922 /* Number of ACLed Initiator Nodes for this TPG */
923 u32 num_node_acls;
924 /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */
925 atomic_t tpg_pr_ref_count;
926 /* Spinlock for adding/removing ACLed Nodes */
927 spinlock_t acl_node_lock;
928 /* Spinlock for adding/removing sessions */
929 spinlock_t session_lock;
930 spinlock_t tpg_lun_lock;
931 /* Pointer to $FABRIC_MOD portal group */
932 void *se_tpg_fabric_ptr;
933 struct list_head se_tpg_list;
934 /* linked list for initiator ACL list */
935 struct list_head acl_node_list;
936 struct se_lun *tpg_lun_list;
937 struct se_lun tpg_virt_lun0;
938 /* List of TCM sessions associated wth this TPG */
939 struct list_head tpg_sess_list;
940 /* Pointer to $FABRIC_MOD dependent code */
941 struct target_core_fabric_ops *se_tpg_tfo;
942 struct se_wwn *se_tpg_wwn;
943 struct config_group tpg_group;
944 struct config_group *tpg_default_groups[6];
945 struct config_group tpg_lun_group;
946 struct config_group tpg_np_group;
947 struct config_group tpg_acl_group;
948 struct config_group tpg_attrib_group;
949 struct config_group tpg_param_group;
950} ____cacheline_aligned;
951
952#define TPG_TFO(se_tpg) ((se_tpg)->se_tpg_tfo)
953
954struct se_wwn {
955 struct target_fabric_configfs *wwn_tf;
956 struct config_group wwn_group;
957 struct config_group *wwn_default_groups[2];
958 struct config_group fabric_stat_group;
959} ____cacheline_aligned;
960
961struct se_global {
962 u16 alua_lu_gps_counter;
963 int g_sub_api_initialized;
964 u32 in_shutdown;
965 u32 alua_lu_gps_count;
966 u32 g_hba_id_counter;
967 struct config_group target_core_hbagroup;
968 struct config_group alua_group;
969 struct config_group alua_lu_gps_group;
970 struct list_head g_lu_gps_list;
971 struct list_head g_se_tpg_list;
972 struct list_head g_hba_list;
973 struct list_head g_se_dev_list;
974 struct se_hba *g_lun0_hba;
975 struct se_subsystem_dev *g_lun0_su_dev;
976 struct se_device *g_lun0_dev;
977 struct t10_alua_lu_gp *default_lu_gp;
978 spinlock_t g_device_lock;
979 spinlock_t hba_lock;
980 spinlock_t se_tpg_lock;
981 spinlock_t lu_gps_lock;
982 spinlock_t plugin_class_lock;
983} ____cacheline_aligned;
984
985#endif /* TARGET_CORE_BASE_H */
diff --git a/include/target/target_core_configfs.h b/include/target/target_core_configfs.h
new file mode 100644
index 000000000000..612509592ffd
--- /dev/null
+++ b/include/target/target_core_configfs.h
@@ -0,0 +1,56 @@
1#define TARGET_CORE_CONFIGFS_VERSION TARGET_CORE_MOD_VERSION
2
3#define TARGET_CORE_CONFIG_ROOT "/sys/kernel/config"
4
5#define TARGET_CORE_NAME_MAX_LEN 64
6#define TARGET_FABRIC_NAME_SIZE 32
7
8extern struct target_fabric_configfs *target_fabric_configfs_init(
9 struct module *, const char *);
10extern void target_fabric_configfs_free(struct target_fabric_configfs *);
11extern int target_fabric_configfs_register(struct target_fabric_configfs *);
12extern void target_fabric_configfs_deregister(struct target_fabric_configfs *);
13
14struct target_fabric_configfs_template {
15 struct config_item_type tfc_discovery_cit;
16 struct config_item_type tfc_wwn_cit;
17 struct config_item_type tfc_wwn_fabric_stats_cit;
18 struct config_item_type tfc_tpg_cit;
19 struct config_item_type tfc_tpg_base_cit;
20 struct config_item_type tfc_tpg_lun_cit;
21 struct config_item_type tfc_tpg_port_cit;
22 struct config_item_type tfc_tpg_port_stat_cit;
23 struct config_item_type tfc_tpg_np_cit;
24 struct config_item_type tfc_tpg_np_base_cit;
25 struct config_item_type tfc_tpg_attrib_cit;
26 struct config_item_type tfc_tpg_param_cit;
27 struct config_item_type tfc_tpg_nacl_cit;
28 struct config_item_type tfc_tpg_nacl_base_cit;
29 struct config_item_type tfc_tpg_nacl_attrib_cit;
30 struct config_item_type tfc_tpg_nacl_auth_cit;
31 struct config_item_type tfc_tpg_nacl_param_cit;
32 struct config_item_type tfc_tpg_nacl_stat_cit;
33 struct config_item_type tfc_tpg_mappedlun_cit;
34 struct config_item_type tfc_tpg_mappedlun_stat_cit;
35};
36
37struct target_fabric_configfs {
38 char tf_name[TARGET_FABRIC_NAME_SIZE];
39 atomic_t tf_access_cnt;
40 struct list_head tf_list;
41 struct config_group tf_group;
42 struct config_group tf_disc_group;
43 struct config_group *tf_default_groups[2];
44 /* Pointer to fabric's config_item */
45 struct config_item *tf_fabric;
46 /* Passed from fabric modules */
47 struct config_item_type *tf_fabric_cit;
48 /* Pointer to target core subsystem */
49 struct configfs_subsystem *tf_subsys;
50 /* Pointer to fabric's struct module */
51 struct module *tf_module;
52 struct target_core_fabric_ops tf_ops;
53 struct target_fabric_configfs_template tf_cit_tmpl;
54};
55
56#define TF_CIT_TMPL(tf) (&(tf)->tf_cit_tmpl)
diff --git a/include/target/target_core_device.h b/include/target/target_core_device.h
new file mode 100644
index 000000000000..52b18a5752c9
--- /dev/null
+++ b/include/target/target_core_device.h
@@ -0,0 +1,61 @@
1#ifndef TARGET_CORE_DEVICE_H
2#define TARGET_CORE_DEVICE_H
3
4extern int transport_get_lun_for_cmd(struct se_cmd *, unsigned char *, u32);
5extern int transport_get_lun_for_tmr(struct se_cmd *, u32);
6extern struct se_dev_entry *core_get_se_deve_from_rtpi(
7 struct se_node_acl *, u16);
8extern int core_free_device_list_for_node(struct se_node_acl *,
9 struct se_portal_group *);
10extern void core_dec_lacl_count(struct se_node_acl *, struct se_cmd *);
11extern void core_update_device_list_access(u32, u32, struct se_node_acl *);
12extern int core_update_device_list_for_node(struct se_lun *, struct se_lun_acl *, u32,
13 u32, struct se_node_acl *,
14 struct se_portal_group *, int);
15extern void core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *);
16extern int core_dev_export(struct se_device *, struct se_portal_group *,
17 struct se_lun *);
18extern void core_dev_unexport(struct se_device *, struct se_portal_group *,
19 struct se_lun *);
20extern int transport_core_report_lun_response(struct se_cmd *);
21extern void se_release_device_for_hba(struct se_device *);
22extern void se_release_vpd_for_dev(struct se_device *);
23extern void se_clear_dev_ports(struct se_device *);
24extern int se_free_virtual_device(struct se_device *, struct se_hba *);
25extern int se_dev_check_online(struct se_device *);
26extern int se_dev_check_shutdown(struct se_device *);
27extern void se_dev_set_default_attribs(struct se_device *, struct se_dev_limits *);
28extern int se_dev_set_task_timeout(struct se_device *, u32);
29extern int se_dev_set_max_unmap_lba_count(struct se_device *, u32);
30extern int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32);
31extern int se_dev_set_unmap_granularity(struct se_device *, u32);
32extern int se_dev_set_unmap_granularity_alignment(struct se_device *, u32);
33extern int se_dev_set_emulate_dpo(struct se_device *, int);
34extern int se_dev_set_emulate_fua_write(struct se_device *, int);
35extern int se_dev_set_emulate_fua_read(struct se_device *, int);
36extern int se_dev_set_emulate_write_cache(struct se_device *, int);
37extern int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int);
38extern int se_dev_set_emulate_tas(struct se_device *, int);
39extern int se_dev_set_emulate_tpu(struct se_device *, int);
40extern int se_dev_set_emulate_tpws(struct se_device *, int);
41extern int se_dev_set_enforce_pr_isids(struct se_device *, int);
42extern int se_dev_set_queue_depth(struct se_device *, u32);
43extern int se_dev_set_max_sectors(struct se_device *, u32);
44extern int se_dev_set_optimal_sectors(struct se_device *, u32);
45extern int se_dev_set_block_size(struct se_device *, u32);
46extern struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_hba *,
47 struct se_device *, u32);
48extern int core_dev_del_lun(struct se_portal_group *, u32);
49extern struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32);
50extern struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *,
51 u32, char *, int *);
52extern int core_dev_add_initiator_node_lun_acl(struct se_portal_group *,
53 struct se_lun_acl *, u32, u32);
54extern int core_dev_del_initiator_node_lun_acl(struct se_portal_group *,
55 struct se_lun *, struct se_lun_acl *);
56extern void core_dev_free_initiator_node_lun_acl(struct se_portal_group *,
57 struct se_lun_acl *lacl);
58extern int core_dev_setup_virtual_lun0(void);
59extern void core_dev_release_virtual_lun0(void);
60
61#endif /* TARGET_CORE_DEVICE_H */
diff --git a/include/target/target_core_fabric_configfs.h b/include/target/target_core_fabric_configfs.h
new file mode 100644
index 000000000000..a26fb7586a09
--- /dev/null
+++ b/include/target/target_core_fabric_configfs.h
@@ -0,0 +1,106 @@
1/*
2 * Used for tfc_wwn_cit attributes
3 */
4
5#include <target/configfs_macros.h>
6
7CONFIGFS_EATTR_STRUCT(target_fabric_nacl_attrib, se_node_acl);
8#define TF_NACL_ATTRIB_ATTR(_fabric, _name, _mode) \
9static struct target_fabric_nacl_attrib_attribute _fabric##_nacl_attrib_##_name = \
10 __CONFIGFS_EATTR(_name, _mode, \
11 _fabric##_nacl_attrib_show_##_name, \
12 _fabric##_nacl_attrib_store_##_name);
13
14CONFIGFS_EATTR_STRUCT(target_fabric_nacl_auth, se_node_acl);
15#define TF_NACL_AUTH_ATTR(_fabric, _name, _mode) \
16static struct target_fabric_nacl_auth_attribute _fabric##_nacl_auth_##_name = \
17 __CONFIGFS_EATTR(_name, _mode, \
18 _fabric##_nacl_auth_show_##_name, \
19 _fabric##_nacl_auth_store_##_name);
20
21#define TF_NACL_AUTH_ATTR_RO(_fabric, _name) \
22static struct target_fabric_nacl_auth_attribute _fabric##_nacl_auth_##_name = \
23 __CONFIGFS_EATTR_RO(_name, \
24 _fabric##_nacl_auth_show_##_name);
25
26CONFIGFS_EATTR_STRUCT(target_fabric_nacl_param, se_node_acl);
27#define TF_NACL_PARAM_ATTR(_fabric, _name, _mode) \
28static struct target_fabric_nacl_param_attribute _fabric##_nacl_param_##_name = \
29 __CONFIGFS_EATTR(_name, _mode, \
30 _fabric##_nacl_param_show_##_name, \
31 _fabric##_nacl_param_store_##_name);
32
33#define TF_NACL_PARAM_ATTR_RO(_fabric, _name) \
34static struct target_fabric_nacl_param_attribute _fabric##_nacl_param_##_name = \
35 __CONFIGFS_EATTR_RO(_name, \
36 _fabric##_nacl_param_show_##_name);
37
38
39CONFIGFS_EATTR_STRUCT(target_fabric_nacl_base, se_node_acl);
40#define TF_NACL_BASE_ATTR(_fabric, _name, _mode) \
41static struct target_fabric_nacl_base_attribute _fabric##_nacl_##_name = \
42 __CONFIGFS_EATTR(_name, _mode, \
43 _fabric##_nacl_show_##_name, \
44 _fabric##_nacl_store_##_name);
45
46#define TF_NACL_BASE_ATTR_RO(_fabric, _name) \
47static struct target_fabric_nacl_base_attribute _fabric##_nacl_##_name = \
48 __CONFIGFS_EATTR_RO(_name, \
49 _fabric##_nacl_show_##_name);
50
51CONFIGFS_EATTR_STRUCT(target_fabric_np_base, se_tpg_np);
52#define TF_NP_BASE_ATTR(_fabric, _name, _mode) \
53static struct target_fabric_np_base_attribute _fabric##_np_##_name = \
54 __CONFIGFS_EATTR(_name, _mode, \
55 _fabric##_np_show_##_name, \
56 _fabric##_np_store_##_name);
57
58CONFIGFS_EATTR_STRUCT(target_fabric_tpg_attrib, se_portal_group);
59#define TF_TPG_ATTRIB_ATTR(_fabric, _name, _mode) \
60static struct target_fabric_tpg_attrib_attribute _fabric##_tpg_attrib_##_name = \
61 __CONFIGFS_EATTR(_name, _mode, \
62 _fabric##_tpg_attrib_show_##_name, \
63 _fabric##_tpg_attrib_store_##_name);
64
65
66CONFIGFS_EATTR_STRUCT(target_fabric_tpg_param, se_portal_group);
67#define TF_TPG_PARAM_ATTR(_fabric, _name, _mode) \
68static struct target_fabric_tpg_param_attribute _fabric##_tpg_param_##_name = \
69 __CONFIGFS_EATTR(_name, _mode, \
70 _fabric##_tpg_param_show_##_name, \
71 _fabric##_tpg_param_store_##_name);
72
73
74CONFIGFS_EATTR_STRUCT(target_fabric_tpg, se_portal_group);
75#define TF_TPG_BASE_ATTR(_fabric, _name, _mode) \
76static struct target_fabric_tpg_attribute _fabric##_tpg_##_name = \
77 __CONFIGFS_EATTR(_name, _mode, \
78 _fabric##_tpg_show_##_name, \
79 _fabric##_tpg_store_##_name);
80
81
82CONFIGFS_EATTR_STRUCT(target_fabric_wwn, target_fabric_configfs);
83#define TF_WWN_ATTR(_fabric, _name, _mode) \
84static struct target_fabric_wwn_attribute _fabric##_wwn_##_name = \
85 __CONFIGFS_EATTR(_name, _mode, \
86 _fabric##_wwn_show_attr_##_name, \
87 _fabric##_wwn_store_attr_##_name);
88
89#define TF_WWN_ATTR_RO(_fabric, _name) \
90static struct target_fabric_wwn_attribute _fabric##_wwn_##_name = \
91 __CONFIGFS_EATTR_RO(_name, \
92 _fabric##_wwn_show_attr_##_name);
93
94CONFIGFS_EATTR_STRUCT(target_fabric_discovery, target_fabric_configfs);
95#define TF_DISC_ATTR(_fabric, _name, _mode) \
96static struct target_fabric_discovery_attribute _fabric##_disc_##_name = \
97 __CONFIGFS_EATTR(_name, _mode, \
98 _fabric##_disc_show_##_name, \
99 _fabric##_disc_store_##_name);
100
101#define TF_DISC_ATTR_RO(_fabric, _name) \
102static struct target_fabric_discovery_attribute _fabric##_disc_##_name = \
103 __CONFIGFS_EATTR_RO(_name, \
104 _fabric##_disc_show_##_name);
105
106extern int target_fabric_setup_cits(struct target_fabric_configfs *);
diff --git a/include/target/target_core_fabric_lib.h b/include/target/target_core_fabric_lib.h
new file mode 100644
index 000000000000..c2f8d0e3a03b
--- /dev/null
+++ b/include/target/target_core_fabric_lib.h
@@ -0,0 +1,28 @@
1#ifndef TARGET_CORE_FABRIC_LIB_H
2#define TARGET_CORE_FABRIC_LIB_H
3
4extern u8 sas_get_fabric_proto_ident(struct se_portal_group *);
5extern u32 sas_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
6 struct t10_pr_registration *, int *, unsigned char *);
7extern u32 sas_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
8 struct t10_pr_registration *, int *);
9extern char *sas_parse_pr_out_transport_id(struct se_portal_group *,
10 const char *, u32 *, char **);
11
12extern u8 fc_get_fabric_proto_ident(struct se_portal_group *);
13extern u32 fc_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
14 struct t10_pr_registration *, int *, unsigned char *);
15extern u32 fc_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
16 struct t10_pr_registration *, int *);
17extern char *fc_parse_pr_out_transport_id(struct se_portal_group *,
18 const char *, u32 *, char **);
19
20extern u8 iscsi_get_fabric_proto_ident(struct se_portal_group *);
21extern u32 iscsi_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
22 struct t10_pr_registration *, int *, unsigned char *);
23extern u32 iscsi_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
24 struct t10_pr_registration *, int *);
25extern char *iscsi_parse_pr_out_transport_id(struct se_portal_group *,
26 const char *, u32 *, char **);
27
28#endif /* TARGET_CORE_FABRIC_LIB_H */
diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
new file mode 100644
index 000000000000..747e1404dca0
--- /dev/null
+++ b/include/target/target_core_fabric_ops.h
@@ -0,0 +1,99 @@
1/* Defined in target_core_configfs.h */
2struct target_fabric_configfs;
3
4struct target_core_fabric_ops {
5 struct configfs_subsystem *tf_subsys;
6 /*
7 * Optional to signal struct se_task->task_sg[] padding entries
8 * for scatterlist chaining using transport_do_task_sg_link(),
9 * disabled by default
10 */
11 bool task_sg_chaining;
12 char *(*get_fabric_name)(void);
13 u8 (*get_fabric_proto_ident)(struct se_portal_group *);
14 char *(*tpg_get_wwn)(struct se_portal_group *);
15 u16 (*tpg_get_tag)(struct se_portal_group *);
16 u32 (*tpg_get_default_depth)(struct se_portal_group *);
17 u32 (*tpg_get_pr_transport_id)(struct se_portal_group *,
18 struct se_node_acl *,
19 struct t10_pr_registration *, int *,
20 unsigned char *);
21 u32 (*tpg_get_pr_transport_id_len)(struct se_portal_group *,
22 struct se_node_acl *,
23 struct t10_pr_registration *, int *);
24 char *(*tpg_parse_pr_out_transport_id)(struct se_portal_group *,
25 const char *, u32 *, char **);
26 int (*tpg_check_demo_mode)(struct se_portal_group *);
27 int (*tpg_check_demo_mode_cache)(struct se_portal_group *);
28 int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *);
29 int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *);
30 struct se_node_acl *(*tpg_alloc_fabric_acl)(
31 struct se_portal_group *);
32 void (*tpg_release_fabric_acl)(struct se_portal_group *,
33 struct se_node_acl *);
34 u32 (*tpg_get_inst_index)(struct se_portal_group *);
35 /*
36 * Optional function pointer for TCM to perform command map
37 * from TCM processing thread context, for those struct se_cmd
38 * initially allocated in interrupt context.
39 */
40 int (*new_cmd_map)(struct se_cmd *);
41 /*
42 * Optional function pointer for TCM fabric modules that use
43 * Linux/NET sockets to allocate struct iovec array to struct se_cmd
44 */
45 int (*alloc_cmd_iovecs)(struct se_cmd *);
46 /*
47 * Optional to release struct se_cmd and fabric dependent allocated
48 * I/O descriptor in transport_cmd_check_stop()
49 */
50 void (*check_stop_free)(struct se_cmd *);
51 void (*release_cmd_to_pool)(struct se_cmd *);
52 void (*release_cmd_direct)(struct se_cmd *);
53 /*
54 * Called with spin_lock_bh(struct se_portal_group->session_lock held.
55 */
56 int (*shutdown_session)(struct se_session *);
57 void (*close_session)(struct se_session *);
58 void (*stop_session)(struct se_session *, int, int);
59 void (*fall_back_to_erl0)(struct se_session *);
60 int (*sess_logged_in)(struct se_session *);
61 u32 (*sess_get_index)(struct se_session *);
62 /*
63 * Used only for SCSI fabrics that contain multi-value TransportIDs
64 * (like iSCSI). All other SCSI fabrics should set this to NULL.
65 */
66 u32 (*sess_get_initiator_sid)(struct se_session *,
67 unsigned char *, u32);
68 int (*write_pending)(struct se_cmd *);
69 int (*write_pending_status)(struct se_cmd *);
70 void (*set_default_node_attributes)(struct se_node_acl *);
71 u32 (*get_task_tag)(struct se_cmd *);
72 int (*get_cmd_state)(struct se_cmd *);
73 void (*new_cmd_failure)(struct se_cmd *);
74 int (*queue_data_in)(struct se_cmd *);
75 int (*queue_status)(struct se_cmd *);
76 int (*queue_tm_rsp)(struct se_cmd *);
77 u16 (*set_fabric_sense_len)(struct se_cmd *, u32);
78 u16 (*get_fabric_sense_len)(void);
79 int (*is_state_remove)(struct se_cmd *);
80 /*
81 * fabric module calls for target_core_fabric_configfs.c
82 */
83 struct se_wwn *(*fabric_make_wwn)(struct target_fabric_configfs *,
84 struct config_group *, const char *);
85 void (*fabric_drop_wwn)(struct se_wwn *);
86 struct se_portal_group *(*fabric_make_tpg)(struct se_wwn *,
87 struct config_group *, const char *);
88 void (*fabric_drop_tpg)(struct se_portal_group *);
89 int (*fabric_post_link)(struct se_portal_group *,
90 struct se_lun *);
91 void (*fabric_pre_unlink)(struct se_portal_group *,
92 struct se_lun *);
93 struct se_tpg_np *(*fabric_make_np)(struct se_portal_group *,
94 struct config_group *, const char *);
95 void (*fabric_drop_np)(struct se_tpg_np *);
96 struct se_node_acl *(*fabric_make_nodeacl)(struct se_portal_group *,
97 struct config_group *, const char *);
98 void (*fabric_drop_nodeacl)(struct se_node_acl *);
99};
diff --git a/include/target/target_core_tmr.h b/include/target/target_core_tmr.h
new file mode 100644
index 000000000000..bd5596807478
--- /dev/null
+++ b/include/target/target_core_tmr.h
@@ -0,0 +1,35 @@
1#ifndef TARGET_CORE_TMR_H
2#define TARGET_CORE_TMR_H
3
4/* fabric independent task management function values */
5enum tcm_tmreq_table {
6 TMR_ABORT_TASK = 1,
7 TMR_ABORT_TASK_SET = 2,
8 TMR_CLEAR_ACA = 3,
9 TMR_CLEAR_TASK_SET = 4,
10 TMR_LUN_RESET = 5,
11 TMR_TARGET_WARM_RESET = 6,
12 TMR_TARGET_COLD_RESET = 7,
13 TMR_FABRIC_TMR = 255,
14};
15
16/* fabric independent task management response values */
17enum tcm_tmrsp_table {
18 TMR_FUNCTION_COMPLETE = 0,
19 TMR_TASK_DOES_NOT_EXIST = 1,
20 TMR_LUN_DOES_NOT_EXIST = 2,
21 TMR_TASK_STILL_ALLEGIANT = 3,
22 TMR_TASK_FAILOVER_NOT_SUPPORTED = 4,
23 TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED = 5,
24 TMR_FUNCTION_AUTHORIZATION_FAILED = 6,
25 TMR_FUNCTION_REJECTED = 255,
26};
27
28extern struct kmem_cache *se_tmr_req_cache;
29
30extern struct se_tmr_req *core_tmr_alloc_req(struct se_cmd *, void *, u8);
31extern void core_tmr_release_req(struct se_tmr_req *);
32extern int core_tmr_lun_reset(struct se_device *, struct se_tmr_req *,
33 struct list_head *, struct se_cmd *);
34
35#endif /* TARGET_CORE_TMR_H */
diff --git a/include/target/target_core_tpg.h b/include/target/target_core_tpg.h
new file mode 100644
index 000000000000..77e18729c4c1
--- /dev/null
+++ b/include/target/target_core_tpg.h
@@ -0,0 +1,35 @@
1#ifndef TARGET_CORE_TPG_H
2#define TARGET_CORE_TPG_H
3
4extern struct se_node_acl *__core_tpg_get_initiator_node_acl(struct se_portal_group *tpg,
5 const char *);
6extern struct se_node_acl *core_tpg_get_initiator_node_acl(struct se_portal_group *tpg,
7 unsigned char *);
8extern void core_tpg_add_node_to_devs(struct se_node_acl *,
9 struct se_portal_group *);
10extern struct se_node_acl *core_tpg_check_initiator_node_acl(
11 struct se_portal_group *,
12 unsigned char *);
13extern void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
14extern void core_tpg_wait_for_mib_ref(struct se_node_acl *);
15extern void core_tpg_clear_object_luns(struct se_portal_group *);
16extern struct se_node_acl *core_tpg_add_initiator_node_acl(
17 struct se_portal_group *,
18 struct se_node_acl *,
19 const char *, u32);
20extern int core_tpg_del_initiator_node_acl(struct se_portal_group *,
21 struct se_node_acl *, int);
22extern int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *,
23 unsigned char *, u32, int);
24extern int core_tpg_register(struct target_core_fabric_ops *,
25 struct se_wwn *,
26 struct se_portal_group *, void *,
27 int);
28extern int core_tpg_deregister(struct se_portal_group *);
29extern struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32);
30extern int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *, u32,
31 void *);
32extern struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32, int *);
33extern int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *);
34
35#endif /* TARGET_CORE_TPG_H */
diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h
new file mode 100644
index 000000000000..24a1c6cb83c3
--- /dev/null
+++ b/include/target/target_core_transport.h
@@ -0,0 +1,360 @@
1#ifndef TARGET_CORE_TRANSPORT_H
2#define TARGET_CORE_TRANSPORT_H
3
4#define TARGET_CORE_VERSION TARGET_CORE_MOD_VERSION
5
6/* Attempts before moving from SHORT to LONG */
7#define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3
8#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT 3 /* In milliseconds */
9#define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_LONG 10 /* In milliseconds */
10
11#define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */
12
13#define PYX_TRANSPORT_SENT_TO_TRANSPORT 0
14#define PYX_TRANSPORT_WRITE_PENDING 1
15
16#define PYX_TRANSPORT_UNKNOWN_SAM_OPCODE -1
17#define PYX_TRANSPORT_HBA_QUEUE_FULL -2
18#define PYX_TRANSPORT_REQ_TOO_MANY_SECTORS -3
19#define PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES -4
20#define PYX_TRANSPORT_INVALID_CDB_FIELD -5
21#define PYX_TRANSPORT_INVALID_PARAMETER_LIST -6
22#define PYX_TRANSPORT_LU_COMM_FAILURE -7
23#define PYX_TRANSPORT_UNKNOWN_MODE_PAGE -8
24#define PYX_TRANSPORT_WRITE_PROTECTED -9
25#define PYX_TRANSPORT_TASK_TIMEOUT -10
26#define PYX_TRANSPORT_RESERVATION_CONFLICT -11
27#define PYX_TRANSPORT_ILLEGAL_REQUEST -12
28#define PYX_TRANSPORT_USE_SENSE_REASON -13
29
30#ifndef SAM_STAT_RESERVATION_CONFLICT
31#define SAM_STAT_RESERVATION_CONFLICT 0x18
32#endif
33
34#define TRANSPORT_PLUGIN_FREE 0
35#define TRANSPORT_PLUGIN_REGISTERED 1
36
37#define TRANSPORT_PLUGIN_PHBA_PDEV 1
38#define TRANSPORT_PLUGIN_VHBA_PDEV 2
39#define TRANSPORT_PLUGIN_VHBA_VDEV 3
40
41/* For SE OBJ Plugins, in seconds */
42#define TRANSPORT_TIMEOUT_TUR 10
43#define TRANSPORT_TIMEOUT_TYPE_DISK 60
44#define TRANSPORT_TIMEOUT_TYPE_ROM 120
45#define TRANSPORT_TIMEOUT_TYPE_TAPE 600
46#define TRANSPORT_TIMEOUT_TYPE_OTHER 300
47
48/* For se_task->task_state_flags */
49#define TSF_EXCEPTION_CLEARED 0x01
50
51/*
52 * struct se_subsystem_dev->su_dev_flags
53*/
54#define SDF_FIRMWARE_VPD_UNIT_SERIAL 0x00000001
55#define SDF_EMULATED_VPD_UNIT_SERIAL 0x00000002
56#define SDF_USING_UDEV_PATH 0x00000004
57#define SDF_USING_ALIAS 0x00000008
58
59/*
60 * struct se_device->dev_flags
61 */
62#define DF_READ_ONLY 0x00000001
63#define DF_SPC2_RESERVATIONS 0x00000002
64#define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000004
65
66/* struct se_dev_attrib sanity values */
67/* 10 Minutes */
68#define DA_TASK_TIMEOUT_MAX 600
69/* Default max_unmap_lba_count */
70#define DA_MAX_UNMAP_LBA_COUNT 0
71/* Default max_unmap_block_desc_count */
72#define DA_MAX_UNMAP_BLOCK_DESC_COUNT 0
73/* Default unmap_granularity */
74#define DA_UNMAP_GRANULARITY_DEFAULT 0
75/* Default unmap_granularity_alignment */
76#define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0
77/* Emulation for Direct Page Out */
78#define DA_EMULATE_DPO 0
79/* Emulation for Forced Unit Access WRITEs */
80#define DA_EMULATE_FUA_WRITE 1
81/* Emulation for Forced Unit Access READs */
82#define DA_EMULATE_FUA_READ 0
83/* Emulation for WriteCache and SYNCHRONIZE_CACHE */
84#define DA_EMULATE_WRITE_CACHE 0
85/* Emulation for UNIT ATTENTION Interlock Control */
86#define DA_EMULATE_UA_INTLLCK_CTRL 0
87/* Emulation for TASK_ABORTED status (TAS) by default */
88#define DA_EMULATE_TAS 1
89/* Emulation for Thin Provisioning UNMAP using block/blk-lib.c:blkdev_issue_discard() */
90#define DA_EMULATE_TPU 0
91/*
92 * Emulation for Thin Provisioning WRITE_SAME w/ UNMAP=1 bit using
93 * block/blk-lib.c:blkdev_issue_discard()
94 */
95#define DA_EMULATE_TPWS 0
96/* No Emulation for PSCSI by default */
97#define DA_EMULATE_RESERVATIONS 0
98/* No Emulation for PSCSI by default */
99#define DA_EMULATE_ALUA 0
100/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
101#define DA_ENFORCE_PR_ISIDS 1
102#define DA_STATUS_MAX_SECTORS_MIN 16
103#define DA_STATUS_MAX_SECTORS_MAX 8192
104
105#define SE_MODE_PAGE_BUF 512
106
107#define MOD_MAX_SECTORS(ms, bs) (ms % (PAGE_SIZE / bs))
108
109struct se_mem;
110struct se_subsystem_api;
111
112extern struct kmem_cache *se_mem_cache;
113
114extern int init_se_global(void);
115extern void release_se_global(void);
116extern void init_scsi_index_table(void);
117extern u32 scsi_get_new_index(scsi_index_t);
118extern void transport_init_queue_obj(struct se_queue_obj *);
119extern int transport_subsystem_check_init(void);
120extern int transport_subsystem_register(struct se_subsystem_api *);
121extern void transport_subsystem_release(struct se_subsystem_api *);
122extern void transport_load_plugins(void);
123extern struct se_session *transport_init_session(void);
124extern void __transport_register_session(struct se_portal_group *,
125 struct se_node_acl *,
126 struct se_session *, void *);
127extern void transport_register_session(struct se_portal_group *,
128 struct se_node_acl *,
129 struct se_session *, void *);
130extern void transport_free_session(struct se_session *);
131extern void transport_deregister_session_configfs(struct se_session *);
132extern void transport_deregister_session(struct se_session *);
133extern void transport_cmd_finish_abort(struct se_cmd *, int);
134extern void transport_cmd_finish_abort_tmr(struct se_cmd *);
135extern void transport_complete_sync_cache(struct se_cmd *, int);
136extern void transport_complete_task(struct se_task *, int);
137extern void transport_add_task_to_execute_queue(struct se_task *,
138 struct se_task *,
139 struct se_device *);
140extern void transport_remove_task_from_execute_queue(struct se_task *,
141 struct se_device *);
142unsigned char *transport_dump_cmd_direction(struct se_cmd *);
143extern void transport_dump_dev_state(struct se_device *, char *, int *);
144extern void transport_dump_dev_info(struct se_device *, struct se_lun *,
145 unsigned long long, char *, int *);
146extern void transport_dump_vpd_proto_id(struct t10_vpd *,
147 unsigned char *, int);
148extern void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
149extern int transport_dump_vpd_assoc(struct t10_vpd *,
150 unsigned char *, int);
151extern int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
152extern int transport_dump_vpd_ident_type(struct t10_vpd *,
153 unsigned char *, int);
154extern int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
155extern int transport_dump_vpd_ident(struct t10_vpd *,
156 unsigned char *, int);
157extern int transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
158extern struct se_device *transport_add_device_to_core_hba(struct se_hba *,
159 struct se_subsystem_api *,
160 struct se_subsystem_dev *, u32,
161 void *, struct se_dev_limits *,
162 const char *, const char *);
163extern void transport_device_setup_cmd(struct se_cmd *);
164extern void transport_init_se_cmd(struct se_cmd *,
165 struct target_core_fabric_ops *,
166 struct se_session *, u32, int, int,
167 unsigned char *);
168extern void transport_free_se_cmd(struct se_cmd *);
169extern int transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
170extern int transport_generic_handle_cdb(struct se_cmd *);
171extern int transport_generic_handle_cdb_map(struct se_cmd *);
172extern int transport_generic_handle_data(struct se_cmd *);
173extern void transport_new_cmd_failure(struct se_cmd *);
174extern int transport_generic_handle_tmr(struct se_cmd *);
175extern void transport_generic_free_cmd_intr(struct se_cmd *);
176extern void __transport_stop_task_timer(struct se_task *, unsigned long *);
177extern unsigned char transport_asciihex_to_binaryhex(unsigned char val[2]);
178extern int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *, u32,
179 struct scatterlist *, u32);
180extern int transport_clear_lun_from_sessions(struct se_lun *);
181extern int transport_check_aborted_status(struct se_cmd *, int);
182extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int);
183extern void transport_send_task_abort(struct se_cmd *);
184extern void transport_release_cmd_to_pool(struct se_cmd *);
185extern void transport_generic_free_cmd(struct se_cmd *, int, int, int);
186extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
187extern u32 transport_calc_sg_num(struct se_task *, struct se_mem *, u32);
188extern int transport_map_mem_to_sg(struct se_task *, struct list_head *,
189 void *, struct se_mem *,
190 struct se_mem **, u32 *, u32 *);
191extern void transport_do_task_sg_chain(struct se_cmd *);
192extern void transport_generic_process_write(struct se_cmd *);
193extern int transport_generic_do_tmr(struct se_cmd *);
194/* From target_core_alua.c */
195extern int core_alua_check_nonop_delay(struct se_cmd *);
196/* From target_core_cdb.c */
197extern int transport_emulate_control_cdb(struct se_task *);
198
199/*
200 * Each se_transport_task_t can have N number of possible struct se_task's
201 * for the storage transport(s) to possibly execute.
202 * Used primarily for splitting up CDBs that exceed the physical storage
203 * HBA's maximum sector count per task.
204 */
205struct se_mem {
206 struct page *se_page;
207 u32 se_len;
208 u32 se_off;
209 struct list_head se_list;
210} ____cacheline_aligned;
211
212/*
213 * Each type of disk transport supported MUST have a template defined
214 * within its .h file.
215 */
216struct se_subsystem_api {
217 /*
218 * The Name. :-)
219 */
220 char name[16];
221 /*
222 * Transport Type.
223 */
224 u8 transport_type;
225 /*
226 * struct module for struct se_hba references
227 */
228 struct module *owner;
229 /*
230 * Used for global se_subsystem_api list_head
231 */
232 struct list_head sub_api_list;
233 /*
234 * For SCF_SCSI_NON_DATA_CDB
235 */
236 int (*cdb_none)(struct se_task *);
237 /*
238 * For SCF_SCSI_CONTROL_NONSG_IO_CDB
239 */
240 int (*map_task_non_SG)(struct se_task *);
241 /*
242 * For SCF_SCSI_DATA_SG_IO_CDB and SCF_SCSI_CONTROL_SG_IO_CDB
243 */
244 int (*map_task_SG)(struct se_task *);
245 /*
246 * attach_hba():
247 */
248 int (*attach_hba)(struct se_hba *, u32);
249 /*
250 * detach_hba():
251 */
252 void (*detach_hba)(struct se_hba *);
253 /*
254 * pmode_hba(): Used for TCM/pSCSI subsystem plugin HBA ->
255 * Linux/SCSI struct Scsi_Host passthrough
256 */
257 int (*pmode_enable_hba)(struct se_hba *, unsigned long);
258 /*
259 * allocate_virtdevice():
260 */
261 void *(*allocate_virtdevice)(struct se_hba *, const char *);
262 /*
263 * create_virtdevice(): Only for Virtual HBAs
264 */
265 struct se_device *(*create_virtdevice)(struct se_hba *,
266 struct se_subsystem_dev *, void *);
267 /*
268 * free_device():
269 */
270 void (*free_device)(void *);
271
272 /*
273 * dpo_emulated():
274 */
275 int (*dpo_emulated)(struct se_device *);
276 /*
277 * fua_write_emulated():
278 */
279 int (*fua_write_emulated)(struct se_device *);
280 /*
281 * fua_read_emulated():
282 */
283 int (*fua_read_emulated)(struct se_device *);
284 /*
285 * write_cache_emulated():
286 */
287 int (*write_cache_emulated)(struct se_device *);
288 /*
289 * transport_complete():
290 *
291 * Use transport_generic_complete() for majority of DAS transport
292 * drivers. Provided out of convenience.
293 */
294 int (*transport_complete)(struct se_task *task);
295 struct se_task *(*alloc_task)(struct se_cmd *);
296 /*
297 * do_task():
298 */
299 int (*do_task)(struct se_task *);
300 /*
301 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
302 * UNMAP and WRITE_SAME_* w/ UNMAP=1 <-> Linux/Block Discard
303 */
304 int (*do_discard)(struct se_device *, sector_t, u32);
305 /*
306 * Used by virtual subsystem plugins IBLOCK and FILEIO to emulate
307 * SYNCHRONIZE_CACHE_* <-> Linux/Block blkdev_issue_flush()
308 */
309 void (*do_sync_cache)(struct se_task *);
310 /*
311 * free_task():
312 */
313 void (*free_task)(struct se_task *);
314 /*
315 * check_configfs_dev_params():
316 */
317 ssize_t (*check_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *);
318 /*
319 * set_configfs_dev_params():
320 */
321 ssize_t (*set_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *,
322 const char *, ssize_t);
323 /*
324 * show_configfs_dev_params():
325 */
326 ssize_t (*show_configfs_dev_params)(struct se_hba *, struct se_subsystem_dev *,
327 char *);
328 /*
329 * get_cdb():
330 */
331 unsigned char *(*get_cdb)(struct se_task *);
332 /*
333 * get_device_rev():
334 */
335 u32 (*get_device_rev)(struct se_device *);
336 /*
337 * get_device_type():
338 */
339 u32 (*get_device_type)(struct se_device *);
340 /*
341 * Get the sector_t from a subsystem backstore..
342 */
343 sector_t (*get_blocks)(struct se_device *);
344 /*
345 * do_se_mem_map():
346 */
347 int (*do_se_mem_map)(struct se_task *, struct list_head *, void *,
348 struct se_mem *, struct se_mem **, u32 *, u32 *);
349 /*
350 * get_sense_buffer():
351 */
352 unsigned char *(*get_sense_buffer)(struct se_task *);
353} ____cacheline_aligned;
354
355#define TRANSPORT(dev) ((dev)->transport)
356#define HBA_TRANSPORT(hba) ((hba)->transport)
357
358extern struct se_global *se_global;
359
360#endif /* TARGET_CORE_TRANSPORT_H */
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index 1dfab5401511..da39b22636f7 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -21,11 +21,30 @@
21#undef CREATE_TRACE_POINTS 21#undef CREATE_TRACE_POINTS
22 22
23#include <linux/stringify.h> 23#include <linux/stringify.h>
24/*
25 * module.h includes tracepoints, and because ftrace.h
26 * pulls in module.h:
27 * trace/ftrace.h -> linux/ftrace_event.h -> linux/perf_event.h ->
28 * linux/ftrace.h -> linux/module.h
29 * we must include module.h here before we play with any of
30 * the TRACE_EVENT() macros, otherwise the tracepoints included
31 * by module.h may break the build.
32 */
33#include <linux/module.h>
24 34
25#undef TRACE_EVENT 35#undef TRACE_EVENT
26#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \ 36#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
27 DEFINE_TRACE(name) 37 DEFINE_TRACE(name)
28 38
39#undef TRACE_EVENT_CONDITION
40#define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \
41 TRACE_EVENT(name, \
42 PARAMS(proto), \
43 PARAMS(args), \
44 PARAMS(tstruct), \
45 PARAMS(assign), \
46 PARAMS(print))
47
29#undef TRACE_EVENT_FN 48#undef TRACE_EVENT_FN
30#define TRACE_EVENT_FN(name, proto, args, tstruct, \ 49#define TRACE_EVENT_FN(name, proto, args, tstruct, \
31 assign, print, reg, unreg) \ 50 assign, print, reg, unreg) \
@@ -39,6 +58,10 @@
39#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ 58#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
40 DEFINE_TRACE(name) 59 DEFINE_TRACE(name)
41 60
61#undef DEFINE_EVENT_CONDITION
62#define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \
63 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
64
42#undef DECLARE_TRACE 65#undef DECLARE_TRACE
43#define DECLARE_TRACE(name, proto, args) \ 66#define DECLARE_TRACE(name, proto, args) \
44 DEFINE_TRACE(name) 67 DEFINE_TRACE(name)
@@ -75,9 +98,11 @@
75 98
76#undef TRACE_EVENT 99#undef TRACE_EVENT
77#undef TRACE_EVENT_FN 100#undef TRACE_EVENT_FN
101#undef TRACE_EVENT_CONDITION
78#undef DECLARE_EVENT_CLASS 102#undef DECLARE_EVENT_CLASS
79#undef DEFINE_EVENT 103#undef DEFINE_EVENT
80#undef DEFINE_EVENT_PRINT 104#undef DEFINE_EVENT_PRINT
105#undef DEFINE_EVENT_CONDITION
81#undef TRACE_HEADER_MULTI_READ 106#undef TRACE_HEADER_MULTI_READ
82#undef DECLARE_TRACE 107#undef DECLARE_TRACE
83 108
diff --git a/include/trace/events/asoc.h b/include/trace/events/asoc.h
new file mode 100644
index 000000000000..ae973d2e27a1
--- /dev/null
+++ b/include/trace/events/asoc.h
@@ -0,0 +1,260 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM asoc
3
4#if !defined(_TRACE_ASOC_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_ASOC_H
6
7#include <linux/ktime.h>
8#include <linux/tracepoint.h>
9
10struct snd_soc_jack;
11struct snd_soc_codec;
12struct snd_soc_card;
13struct snd_soc_dapm_widget;
14
15/*
16 * Log register events
17 */
18DECLARE_EVENT_CLASS(snd_soc_reg,
19
20 TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
21 unsigned int val),
22
23 TP_ARGS(codec, reg, val),
24
25 TP_STRUCT__entry(
26 __string( name, codec->name )
27 __field( int, id )
28 __field( unsigned int, reg )
29 __field( unsigned int, val )
30 ),
31
32 TP_fast_assign(
33 __assign_str(name, codec->name);
34 __entry->id = codec->id;
35 __entry->reg = reg;
36 __entry->val = val;
37 ),
38
39 TP_printk("codec=%s.%d reg=%x val=%x", __get_str(name),
40 (int)__entry->id, (unsigned int)__entry->reg,
41 (unsigned int)__entry->val)
42);
43
44DEFINE_EVENT(snd_soc_reg, snd_soc_reg_write,
45
46 TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
47 unsigned int val),
48
49 TP_ARGS(codec, reg, val)
50
51);
52
53DEFINE_EVENT(snd_soc_reg, snd_soc_reg_read,
54
55 TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
56 unsigned int val),
57
58 TP_ARGS(codec, reg, val)
59
60);
61
62DECLARE_EVENT_CLASS(snd_soc_card,
63
64 TP_PROTO(struct snd_soc_card *card, int val),
65
66 TP_ARGS(card, val),
67
68 TP_STRUCT__entry(
69 __string( name, card->name )
70 __field( int, val )
71 ),
72
73 TP_fast_assign(
74 __assign_str(name, card->name);
75 __entry->val = val;
76 ),
77
78 TP_printk("card=%s val=%d", __get_str(name), (int)__entry->val)
79);
80
81DEFINE_EVENT(snd_soc_card, snd_soc_bias_level_start,
82
83 TP_PROTO(struct snd_soc_card *card, int val),
84
85 TP_ARGS(card, val)
86
87);
88
89DEFINE_EVENT(snd_soc_card, snd_soc_bias_level_done,
90
91 TP_PROTO(struct snd_soc_card *card, int val),
92
93 TP_ARGS(card, val)
94
95);
96
97DECLARE_EVENT_CLASS(snd_soc_dapm_basic,
98
99 TP_PROTO(struct snd_soc_card *card),
100
101 TP_ARGS(card),
102
103 TP_STRUCT__entry(
104 __string( name, card->name )
105 ),
106
107 TP_fast_assign(
108 __assign_str(name, card->name);
109 ),
110
111 TP_printk("card=%s", __get_str(name))
112);
113
114DEFINE_EVENT(snd_soc_dapm_basic, snd_soc_dapm_start,
115
116 TP_PROTO(struct snd_soc_card *card),
117
118 TP_ARGS(card)
119
120);
121
122DEFINE_EVENT(snd_soc_dapm_basic, snd_soc_dapm_done,
123
124 TP_PROTO(struct snd_soc_card *card),
125
126 TP_ARGS(card)
127
128);
129
130DECLARE_EVENT_CLASS(snd_soc_dapm_widget,
131
132 TP_PROTO(struct snd_soc_dapm_widget *w, int val),
133
134 TP_ARGS(w, val),
135
136 TP_STRUCT__entry(
137 __string( name, w->name )
138 __field( int, val )
139 ),
140
141 TP_fast_assign(
142 __assign_str(name, w->name);
143 __entry->val = val;
144 ),
145
146 TP_printk("widget=%s val=%d", __get_str(name),
147 (int)__entry->val)
148);
149
150DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_power,
151
152 TP_PROTO(struct snd_soc_dapm_widget *w, int val),
153
154 TP_ARGS(w, val)
155
156);
157
158DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_event_start,
159
160 TP_PROTO(struct snd_soc_dapm_widget *w, int val),
161
162 TP_ARGS(w, val)
163
164);
165
166DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_event_done,
167
168 TP_PROTO(struct snd_soc_dapm_widget *w, int val),
169
170 TP_ARGS(w, val)
171
172);
173
174TRACE_EVENT(snd_soc_jack_irq,
175
176 TP_PROTO(const char *name),
177
178 TP_ARGS(name),
179
180 TP_STRUCT__entry(
181 __string( name, name )
182 ),
183
184 TP_fast_assign(
185 __assign_str(name, name);
186 ),
187
188 TP_printk("%s", __get_str(name))
189);
190
191TRACE_EVENT(snd_soc_jack_report,
192
193 TP_PROTO(struct snd_soc_jack *jack, int mask, int val),
194
195 TP_ARGS(jack, mask, val),
196
197 TP_STRUCT__entry(
198 __string( name, jack->jack->name )
199 __field( int, mask )
200 __field( int, val )
201 ),
202
203 TP_fast_assign(
204 __assign_str(name, jack->jack->name);
205 __entry->mask = mask;
206 __entry->val = val;
207 ),
208
209 TP_printk("jack=%s %x/%x", __get_str(name), (int)__entry->val,
210 (int)__entry->mask)
211);
212
213TRACE_EVENT(snd_soc_jack_notify,
214
215 TP_PROTO(struct snd_soc_jack *jack, int val),
216
217 TP_ARGS(jack, val),
218
219 TP_STRUCT__entry(
220 __string( name, jack->jack->name )
221 __field( int, val )
222 ),
223
224 TP_fast_assign(
225 __assign_str(name, jack->jack->name);
226 __entry->val = val;
227 ),
228
229 TP_printk("jack=%s %x", __get_str(name), (int)__entry->val)
230);
231
232TRACE_EVENT(snd_soc_cache_sync,
233
234 TP_PROTO(struct snd_soc_codec *codec, const char *type,
235 const char *status),
236
237 TP_ARGS(codec, type, status),
238
239 TP_STRUCT__entry(
240 __string( name, codec->name )
241 __string( status, status )
242 __string( type, type )
243 __field( int, id )
244 ),
245
246 TP_fast_assign(
247 __assign_str(name, codec->name);
248 __assign_str(status, status);
249 __assign_str(type, type);
250 __entry->id = codec->id;
251 ),
252
253 TP_printk("codec=%s.%d type=%s status=%s", __get_str(name),
254 (int)__entry->id, __get_str(type), __get_str(status))
255);
256
257#endif /* _TRACE_ASOC_H */
258
259/* This part must be outside protection */
260#include <trace/define_trace.h>
diff --git a/include/trace/events/bkl.h b/include/trace/events/bkl.h
deleted file mode 100644
index 1af72dc24278..000000000000
--- a/include/trace/events/bkl.h
+++ /dev/null
@@ -1,61 +0,0 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM bkl
3
4#if !defined(_TRACE_BKL_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_BKL_H
6
7#include <linux/tracepoint.h>
8
9TRACE_EVENT(lock_kernel,
10
11 TP_PROTO(const char *func, const char *file, int line),
12
13 TP_ARGS(func, file, line),
14
15 TP_STRUCT__entry(
16 __field( int, depth )
17 __field_ext( const char *, func, FILTER_PTR_STRING )
18 __field_ext( const char *, file, FILTER_PTR_STRING )
19 __field( int, line )
20 ),
21
22 TP_fast_assign(
23 /* We want to record the lock_depth after lock is acquired */
24 __entry->depth = current->lock_depth + 1;
25 __entry->func = func;
26 __entry->file = file;
27 __entry->line = line;
28 ),
29
30 TP_printk("depth=%d file:line=%s:%d func=%s()", __entry->depth,
31 __entry->file, __entry->line, __entry->func)
32);
33
34TRACE_EVENT(unlock_kernel,
35
36 TP_PROTO(const char *func, const char *file, int line),
37
38 TP_ARGS(func, file, line),
39
40 TP_STRUCT__entry(
41 __field(int, depth )
42 __field(const char *, func )
43 __field(const char *, file )
44 __field(int, line )
45 ),
46
47 TP_fast_assign(
48 __entry->depth = current->lock_depth;
49 __entry->func = func;
50 __entry->file = file;
51 __entry->line = line;
52 ),
53
54 TP_printk("depth=%d file:line=%s:%d func=%s()", __entry->depth,
55 __entry->file, __entry->line, __entry->func)
56);
57
58#endif /* _TRACE_BKL_H */
59
60/* This part must be outside protection */
61#include <trace/define_trace.h>
diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index d8ce278515c3..bf366547da25 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -31,7 +31,7 @@ DECLARE_EVENT_CLASS(block_rq_with_error,
31 0 : blk_rq_sectors(rq); 31 0 : blk_rq_sectors(rq);
32 __entry->errors = rq->errors; 32 __entry->errors = rq->errors;
33 33
34 blk_fill_rwbs_rq(__entry->rwbs, rq); 34 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
35 blk_dump_cmd(__get_str(cmd), rq); 35 blk_dump_cmd(__get_str(cmd), rq);
36 ), 36 ),
37 37
@@ -118,7 +118,7 @@ DECLARE_EVENT_CLASS(block_rq,
118 __entry->bytes = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 118 __entry->bytes = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
119 blk_rq_bytes(rq) : 0; 119 blk_rq_bytes(rq) : 0;
120 120
121 blk_fill_rwbs_rq(__entry->rwbs, rq); 121 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
122 blk_dump_cmd(__get_str(cmd), rq); 122 blk_dump_cmd(__get_str(cmd), rq);
123 memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 123 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
124 ), 124 ),
@@ -206,15 +206,16 @@ TRACE_EVENT(block_bio_bounce,
206 * block_bio_complete - completed all work on the block operation 206 * block_bio_complete - completed all work on the block operation
207 * @q: queue holding the block operation 207 * @q: queue holding the block operation
208 * @bio: block operation completed 208 * @bio: block operation completed
209 * @error: io error value
209 * 210 *
210 * This tracepoint indicates there is no further work to do on this 211 * This tracepoint indicates there is no further work to do on this
211 * block IO operation @bio. 212 * block IO operation @bio.
212 */ 213 */
213TRACE_EVENT(block_bio_complete, 214TRACE_EVENT(block_bio_complete,
214 215
215 TP_PROTO(struct request_queue *q, struct bio *bio), 216 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
216 217
217 TP_ARGS(q, bio), 218 TP_ARGS(q, bio, error),
218 219
219 TP_STRUCT__entry( 220 TP_STRUCT__entry(
220 __field( dev_t, dev ) 221 __field( dev_t, dev )
@@ -228,6 +229,7 @@ TRACE_EVENT(block_bio_complete,
228 __entry->dev = bio->bi_bdev->bd_dev; 229 __entry->dev = bio->bi_bdev->bd_dev;
229 __entry->sector = bio->bi_sector; 230 __entry->sector = bio->bi_sector;
230 __entry->nr_sector = bio->bi_size >> 9; 231 __entry->nr_sector = bio->bi_size >> 9;
232 __entry->error = error;
231 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 233 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
232 ), 234 ),
233 235
@@ -399,9 +401,9 @@ TRACE_EVENT(block_plug,
399 401
400DECLARE_EVENT_CLASS(block_unplug, 402DECLARE_EVENT_CLASS(block_unplug,
401 403
402 TP_PROTO(struct request_queue *q), 404 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
403 405
404 TP_ARGS(q), 406 TP_ARGS(q, depth, explicit),
405 407
406 TP_STRUCT__entry( 408 TP_STRUCT__entry(
407 __field( int, nr_rq ) 409 __field( int, nr_rq )
@@ -409,7 +411,7 @@ DECLARE_EVENT_CLASS(block_unplug,
409 ), 411 ),
410 412
411 TP_fast_assign( 413 TP_fast_assign(
412 __entry->nr_rq = q->rq.count[READ] + q->rq.count[WRITE]; 414 __entry->nr_rq = depth;
413 memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 415 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
414 ), 416 ),
415 417
@@ -417,31 +419,19 @@ DECLARE_EVENT_CLASS(block_unplug,
417); 419);
418 420
419/** 421/**
420 * block_unplug_timer - timed release of operations requests in queue to device driver 422 * block_unplug - release of operations requests in request queue
421 * @q: request queue to unplug
422 *
423 * Unplug the request queue @q because a timer expired and allow block
424 * operation requests to be sent to the device driver.
425 */
426DEFINE_EVENT(block_unplug, block_unplug_timer,
427
428 TP_PROTO(struct request_queue *q),
429
430 TP_ARGS(q)
431);
432
433/**
434 * block_unplug_io - release of operations requests in request queue
435 * @q: request queue to unplug 423 * @q: request queue to unplug
424 * @depth: number of requests just added to the queue
425 * @explicit: whether this was an explicit unplug, or one from schedule()
436 * 426 *
437 * Unplug request queue @q because device driver is scheduled to work 427 * Unplug request queue @q because device driver is scheduled to work
438 * on elements in the request queue. 428 * on elements in the request queue.
439 */ 429 */
440DEFINE_EVENT(block_unplug, block_unplug_io, 430DEFINE_EVENT(block_unplug, block_unplug,
441 431
442 TP_PROTO(struct request_queue *q), 432 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
443 433
444 TP_ARGS(q) 434 TP_ARGS(q, depth, explicit)
445); 435);
446 436
447/** 437/**
@@ -486,16 +476,16 @@ TRACE_EVENT(block_split,
486); 476);
487 477
488/** 478/**
489 * block_remap - map request for a partition to the raw device 479 * block_bio_remap - map request for a logical device to the raw device
490 * @q: queue holding the operation 480 * @q: queue holding the operation
491 * @bio: revised operation 481 * @bio: revised operation
492 * @dev: device for the operation 482 * @dev: device for the operation
493 * @from: original sector for the operation 483 * @from: original sector for the operation
494 * 484 *
495 * An operation for a partition on a block device has been mapped to the 485 * An operation for a logical device has been mapped to the
496 * raw block device. 486 * raw block device.
497 */ 487 */
498TRACE_EVENT(block_remap, 488TRACE_EVENT(block_bio_remap,
499 489
500 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev, 490 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
501 sector_t from), 491 sector_t from),
@@ -561,7 +551,7 @@ TRACE_EVENT(block_rq_remap,
561 __entry->nr_sector = blk_rq_sectors(rq); 551 __entry->nr_sector = blk_rq_sectors(rq);
562 __entry->old_dev = dev; 552 __entry->old_dev = dev;
563 __entry->old_sector = from; 553 __entry->old_sector = from;
564 blk_fill_rwbs_rq(__entry->rwbs, rq); 554 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
565 ), 555 ),
566 556
567 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu", 557 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
new file mode 100644
index 000000000000..4114129f0794
--- /dev/null
+++ b/include/trace/events/btrfs.h
@@ -0,0 +1,667 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM btrfs
3
4#if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_BTRFS_H
6
7#include <linux/writeback.h>
8#include <linux/tracepoint.h>
9
10struct btrfs_root;
11struct btrfs_fs_info;
12struct btrfs_inode;
13struct extent_map;
14struct btrfs_ordered_extent;
15struct btrfs_delayed_ref_node;
16struct btrfs_delayed_tree_ref;
17struct btrfs_delayed_data_ref;
18struct btrfs_delayed_ref_head;
19struct map_lookup;
20struct extent_buffer;
21
22#define show_ref_type(type) \
23 __print_symbolic(type, \
24 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
25 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
26 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
27 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
28 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
29
30#define __show_root_type(obj) \
31 __print_symbolic_u64(obj, \
32 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
33 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
34 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
35 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
36 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
37 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
38 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
39 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
40 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
41 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
42
43#define show_root_type(obj) \
44 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
45 (obj <= BTRFS_CSUM_TREE_OBJECTID )) ? __show_root_type(obj) : "-"
46
47TRACE_EVENT(btrfs_transaction_commit,
48
49 TP_PROTO(struct btrfs_root *root),
50
51 TP_ARGS(root),
52
53 TP_STRUCT__entry(
54 __field( u64, generation )
55 __field( u64, root_objectid )
56 ),
57
58 TP_fast_assign(
59 __entry->generation = root->fs_info->generation;
60 __entry->root_objectid = root->root_key.objectid;
61 ),
62
63 TP_printk("root = %llu(%s), gen = %llu",
64 show_root_type(__entry->root_objectid),
65 (unsigned long long)__entry->generation)
66);
67
68DECLARE_EVENT_CLASS(btrfs__inode,
69
70 TP_PROTO(struct inode *inode),
71
72 TP_ARGS(inode),
73
74 TP_STRUCT__entry(
75 __field( ino_t, ino )
76 __field( blkcnt_t, blocks )
77 __field( u64, disk_i_size )
78 __field( u64, generation )
79 __field( u64, last_trans )
80 __field( u64, logged_trans )
81 __field( u64, root_objectid )
82 ),
83
84 TP_fast_assign(
85 __entry->ino = inode->i_ino;
86 __entry->blocks = inode->i_blocks;
87 __entry->disk_i_size = BTRFS_I(inode)->disk_i_size;
88 __entry->generation = BTRFS_I(inode)->generation;
89 __entry->last_trans = BTRFS_I(inode)->last_trans;
90 __entry->logged_trans = BTRFS_I(inode)->logged_trans;
91 __entry->root_objectid =
92 BTRFS_I(inode)->root->root_key.objectid;
93 ),
94
95 TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
96 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
97 show_root_type(__entry->root_objectid),
98 (unsigned long long)__entry->generation,
99 (unsigned long)__entry->ino,
100 (unsigned long long)__entry->blocks,
101 (unsigned long long)__entry->disk_i_size,
102 (unsigned long long)__entry->last_trans,
103 (unsigned long long)__entry->logged_trans)
104);
105
106DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
107
108 TP_PROTO(struct inode *inode),
109
110 TP_ARGS(inode)
111);
112
113DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
114
115 TP_PROTO(struct inode *inode),
116
117 TP_ARGS(inode)
118);
119
120DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
121
122 TP_PROTO(struct inode *inode),
123
124 TP_ARGS(inode)
125);
126
127#define __show_map_type(type) \
128 __print_symbolic_u64(type, \
129 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
130 { EXTENT_MAP_HOLE, "HOLE" }, \
131 { EXTENT_MAP_INLINE, "INLINE" }, \
132 { EXTENT_MAP_DELALLOC, "DELALLOC" })
133
134#define show_map_type(type) \
135 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
136
137#define show_map_flags(flag) \
138 __print_flags(flag, "|", \
139 { EXTENT_FLAG_PINNED, "PINNED" }, \
140 { EXTENT_FLAG_COMPRESSED, "COMPRESSED" }, \
141 { EXTENT_FLAG_VACANCY, "VACANCY" }, \
142 { EXTENT_FLAG_PREALLOC, "PREALLOC" })
143
144TRACE_EVENT(btrfs_get_extent,
145
146 TP_PROTO(struct btrfs_root *root, struct extent_map *map),
147
148 TP_ARGS(root, map),
149
150 TP_STRUCT__entry(
151 __field( u64, root_objectid )
152 __field( u64, start )
153 __field( u64, len )
154 __field( u64, orig_start )
155 __field( u64, block_start )
156 __field( u64, block_len )
157 __field( unsigned long, flags )
158 __field( int, refs )
159 __field( unsigned int, compress_type )
160 ),
161
162 TP_fast_assign(
163 __entry->root_objectid = root->root_key.objectid;
164 __entry->start = map->start;
165 __entry->len = map->len;
166 __entry->orig_start = map->orig_start;
167 __entry->block_start = map->block_start;
168 __entry->block_len = map->block_len;
169 __entry->flags = map->flags;
170 __entry->refs = atomic_read(&map->refs);
171 __entry->compress_type = map->compress_type;
172 ),
173
174 TP_printk("root = %llu(%s), start = %llu, len = %llu, "
175 "orig_start = %llu, block_start = %llu(%s), "
176 "block_len = %llu, flags = %s, refs = %u, "
177 "compress_type = %u",
178 show_root_type(__entry->root_objectid),
179 (unsigned long long)__entry->start,
180 (unsigned long long)__entry->len,
181 (unsigned long long)__entry->orig_start,
182 show_map_type(__entry->block_start),
183 (unsigned long long)__entry->block_len,
184 show_map_flags(__entry->flags),
185 __entry->refs, __entry->compress_type)
186);
187
188#define show_ordered_flags(flags) \
189 __print_symbolic(flags, \
190 { BTRFS_ORDERED_IO_DONE, "IO_DONE" }, \
191 { BTRFS_ORDERED_COMPLETE, "COMPLETE" }, \
192 { BTRFS_ORDERED_NOCOW, "NOCOW" }, \
193 { BTRFS_ORDERED_COMPRESSED, "COMPRESSED" }, \
194 { BTRFS_ORDERED_PREALLOC, "PREALLOC" }, \
195 { BTRFS_ORDERED_DIRECT, "DIRECT" })
196
197DECLARE_EVENT_CLASS(btrfs__ordered_extent,
198
199 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
200
201 TP_ARGS(inode, ordered),
202
203 TP_STRUCT__entry(
204 __field( ino_t, ino )
205 __field( u64, file_offset )
206 __field( u64, start )
207 __field( u64, len )
208 __field( u64, disk_len )
209 __field( u64, bytes_left )
210 __field( unsigned long, flags )
211 __field( int, compress_type )
212 __field( int, refs )
213 __field( u64, root_objectid )
214 ),
215
216 TP_fast_assign(
217 __entry->ino = inode->i_ino;
218 __entry->file_offset = ordered->file_offset;
219 __entry->start = ordered->start;
220 __entry->len = ordered->len;
221 __entry->disk_len = ordered->disk_len;
222 __entry->bytes_left = ordered->bytes_left;
223 __entry->flags = ordered->flags;
224 __entry->compress_type = ordered->compress_type;
225 __entry->refs = atomic_read(&ordered->refs);
226 __entry->root_objectid =
227 BTRFS_I(inode)->root->root_key.objectid;
228 ),
229
230 TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
231 "start = %llu, len = %llu, disk_len = %llu, "
232 "bytes_left = %llu, flags = %s, compress_type = %d, "
233 "refs = %d",
234 show_root_type(__entry->root_objectid),
235 (unsigned long long)__entry->ino,
236 (unsigned long long)__entry->file_offset,
237 (unsigned long long)__entry->start,
238 (unsigned long long)__entry->len,
239 (unsigned long long)__entry->disk_len,
240 (unsigned long long)__entry->bytes_left,
241 show_ordered_flags(__entry->flags),
242 __entry->compress_type, __entry->refs)
243);
244
245DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
246
247 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
248
249 TP_ARGS(inode, ordered)
250);
251
252DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
253
254 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
255
256 TP_ARGS(inode, ordered)
257);
258
259DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
260
261 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
262
263 TP_ARGS(inode, ordered)
264);
265
266DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
267
268 TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
269
270 TP_ARGS(inode, ordered)
271);
272
273DECLARE_EVENT_CLASS(btrfs__writepage,
274
275 TP_PROTO(struct page *page, struct inode *inode,
276 struct writeback_control *wbc),
277
278 TP_ARGS(page, inode, wbc),
279
280 TP_STRUCT__entry(
281 __field( ino_t, ino )
282 __field( pgoff_t, index )
283 __field( long, nr_to_write )
284 __field( long, pages_skipped )
285 __field( loff_t, range_start )
286 __field( loff_t, range_end )
287 __field( char, nonblocking )
288 __field( char, for_kupdate )
289 __field( char, for_reclaim )
290 __field( char, range_cyclic )
291 __field( pgoff_t, writeback_index )
292 __field( u64, root_objectid )
293 ),
294
295 TP_fast_assign(
296 __entry->ino = inode->i_ino;
297 __entry->index = page->index;
298 __entry->nr_to_write = wbc->nr_to_write;
299 __entry->pages_skipped = wbc->pages_skipped;
300 __entry->range_start = wbc->range_start;
301 __entry->range_end = wbc->range_end;
302 __entry->nonblocking = wbc->nonblocking;
303 __entry->for_kupdate = wbc->for_kupdate;
304 __entry->for_reclaim = wbc->for_reclaim;
305 __entry->range_cyclic = wbc->range_cyclic;
306 __entry->writeback_index = inode->i_mapping->writeback_index;
307 __entry->root_objectid =
308 BTRFS_I(inode)->root->root_key.objectid;
309 ),
310
311 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
312 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
313 "range_end = %llu, nonblocking = %d, for_kupdate = %d, "
314 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
315 show_root_type(__entry->root_objectid),
316 (unsigned long)__entry->ino, __entry->index,
317 __entry->nr_to_write, __entry->pages_skipped,
318 __entry->range_start, __entry->range_end,
319 __entry->nonblocking, __entry->for_kupdate,
320 __entry->for_reclaim, __entry->range_cyclic,
321 (unsigned long)__entry->writeback_index)
322);
323
324DEFINE_EVENT(btrfs__writepage, __extent_writepage,
325
326 TP_PROTO(struct page *page, struct inode *inode,
327 struct writeback_control *wbc),
328
329 TP_ARGS(page, inode, wbc)
330);
331
332TRACE_EVENT(btrfs_writepage_end_io_hook,
333
334 TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
335
336 TP_ARGS(page, start, end, uptodate),
337
338 TP_STRUCT__entry(
339 __field( ino_t, ino )
340 __field( pgoff_t, index )
341 __field( u64, start )
342 __field( u64, end )
343 __field( int, uptodate )
344 __field( u64, root_objectid )
345 ),
346
347 TP_fast_assign(
348 __entry->ino = page->mapping->host->i_ino;
349 __entry->index = page->index;
350 __entry->start = start;
351 __entry->end = end;
352 __entry->uptodate = uptodate;
353 __entry->root_objectid =
354 BTRFS_I(page->mapping->host)->root->root_key.objectid;
355 ),
356
357 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
358 "end = %llu, uptodate = %d",
359 show_root_type(__entry->root_objectid),
360 (unsigned long)__entry->ino, (unsigned long)__entry->index,
361 (unsigned long long)__entry->start,
362 (unsigned long long)__entry->end, __entry->uptodate)
363);
364
365TRACE_EVENT(btrfs_sync_file,
366
367 TP_PROTO(struct file *file, int datasync),
368
369 TP_ARGS(file, datasync),
370
371 TP_STRUCT__entry(
372 __field( ino_t, ino )
373 __field( ino_t, parent )
374 __field( int, datasync )
375 __field( u64, root_objectid )
376 ),
377
378 TP_fast_assign(
379 struct dentry *dentry = file->f_path.dentry;
380 struct inode *inode = dentry->d_inode;
381
382 __entry->ino = inode->i_ino;
383 __entry->parent = dentry->d_parent->d_inode->i_ino;
384 __entry->datasync = datasync;
385 __entry->root_objectid =
386 BTRFS_I(inode)->root->root_key.objectid;
387 ),
388
389 TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
390 show_root_type(__entry->root_objectid),
391 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
392 __entry->datasync)
393);
394
395TRACE_EVENT(btrfs_sync_fs,
396
397 TP_PROTO(int wait),
398
399 TP_ARGS(wait),
400
401 TP_STRUCT__entry(
402 __field( int, wait )
403 ),
404
405 TP_fast_assign(
406 __entry->wait = wait;
407 ),
408
409 TP_printk("wait = %d", __entry->wait)
410);
411
412#define show_ref_action(action) \
413 __print_symbolic(action, \
414 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
415 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
416 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
417 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
418
419
420TRACE_EVENT(btrfs_delayed_tree_ref,
421
422 TP_PROTO(struct btrfs_delayed_ref_node *ref,
423 struct btrfs_delayed_tree_ref *full_ref,
424 int action),
425
426 TP_ARGS(ref, full_ref, action),
427
428 TP_STRUCT__entry(
429 __field( u64, bytenr )
430 __field( u64, num_bytes )
431 __field( int, action )
432 __field( u64, parent )
433 __field( u64, ref_root )
434 __field( int, level )
435 __field( int, type )
436 ),
437
438 TP_fast_assign(
439 __entry->bytenr = ref->bytenr;
440 __entry->num_bytes = ref->num_bytes;
441 __entry->action = action;
442 __entry->parent = full_ref->parent;
443 __entry->ref_root = full_ref->root;
444 __entry->level = full_ref->level;
445 __entry->type = ref->type;
446 ),
447
448 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
449 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
450 "type = %s",
451 (unsigned long long)__entry->bytenr,
452 (unsigned long long)__entry->num_bytes,
453 show_ref_action(__entry->action),
454 show_root_type(__entry->parent),
455 show_root_type(__entry->ref_root),
456 __entry->level, show_ref_type(__entry->type))
457);
458
459TRACE_EVENT(btrfs_delayed_data_ref,
460
461 TP_PROTO(struct btrfs_delayed_ref_node *ref,
462 struct btrfs_delayed_data_ref *full_ref,
463 int action),
464
465 TP_ARGS(ref, full_ref, action),
466
467 TP_STRUCT__entry(
468 __field( u64, bytenr )
469 __field( u64, num_bytes )
470 __field( int, action )
471 __field( u64, parent )
472 __field( u64, ref_root )
473 __field( u64, owner )
474 __field( u64, offset )
475 __field( int, type )
476 ),
477
478 TP_fast_assign(
479 __entry->bytenr = ref->bytenr;
480 __entry->num_bytes = ref->num_bytes;
481 __entry->action = action;
482 __entry->parent = full_ref->parent;
483 __entry->ref_root = full_ref->root;
484 __entry->owner = full_ref->objectid;
485 __entry->offset = full_ref->offset;
486 __entry->type = ref->type;
487 ),
488
489 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
490 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
491 "offset = %llu, type = %s",
492 (unsigned long long)__entry->bytenr,
493 (unsigned long long)__entry->num_bytes,
494 show_ref_action(__entry->action),
495 show_root_type(__entry->parent),
496 show_root_type(__entry->ref_root),
497 (unsigned long long)__entry->owner,
498 (unsigned long long)__entry->offset,
499 show_ref_type(__entry->type))
500);
501
502TRACE_EVENT(btrfs_delayed_ref_head,
503
504 TP_PROTO(struct btrfs_delayed_ref_node *ref,
505 struct btrfs_delayed_ref_head *head_ref,
506 int action),
507
508 TP_ARGS(ref, head_ref, action),
509
510 TP_STRUCT__entry(
511 __field( u64, bytenr )
512 __field( u64, num_bytes )
513 __field( int, action )
514 __field( int, is_data )
515 ),
516
517 TP_fast_assign(
518 __entry->bytenr = ref->bytenr;
519 __entry->num_bytes = ref->num_bytes;
520 __entry->action = action;
521 __entry->is_data = head_ref->is_data;
522 ),
523
524 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
525 (unsigned long long)__entry->bytenr,
526 (unsigned long long)__entry->num_bytes,
527 show_ref_action(__entry->action),
528 __entry->is_data)
529);
530
531#define show_chunk_type(type) \
532 __print_flags(type, "|", \
533 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
534 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
535 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
536 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
537 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
538 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
539 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"})
540
541DECLARE_EVENT_CLASS(btrfs__chunk,
542
543 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
544 u64 offset, u64 size),
545
546 TP_ARGS(root, map, offset, size),
547
548 TP_STRUCT__entry(
549 __field( int, num_stripes )
550 __field( u64, type )
551 __field( int, sub_stripes )
552 __field( u64, offset )
553 __field( u64, size )
554 __field( u64, root_objectid )
555 ),
556
557 TP_fast_assign(
558 __entry->num_stripes = map->num_stripes;
559 __entry->type = map->type;
560 __entry->sub_stripes = map->sub_stripes;
561 __entry->offset = offset;
562 __entry->size = size;
563 __entry->root_objectid = root->root_key.objectid;
564 ),
565
566 TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
567 "num_stripes = %d, sub_stripes = %d, type = %s",
568 show_root_type(__entry->root_objectid),
569 (unsigned long long)__entry->offset,
570 (unsigned long long)__entry->size,
571 __entry->num_stripes, __entry->sub_stripes,
572 show_chunk_type(__entry->type))
573);
574
575DEFINE_EVENT(btrfs__chunk, btrfs_chunk_alloc,
576
577 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
578 u64 offset, u64 size),
579
580 TP_ARGS(root, map, offset, size)
581);
582
583DEFINE_EVENT(btrfs__chunk, btrfs_chunk_free,
584
585 TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
586 u64 offset, u64 size),
587
588 TP_ARGS(root, map, offset, size)
589);
590
591TRACE_EVENT(btrfs_cow_block,
592
593 TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
594 struct extent_buffer *cow),
595
596 TP_ARGS(root, buf, cow),
597
598 TP_STRUCT__entry(
599 __field( u64, root_objectid )
600 __field( u64, buf_start )
601 __field( int, refs )
602 __field( u64, cow_start )
603 __field( int, buf_level )
604 __field( int, cow_level )
605 ),
606
607 TP_fast_assign(
608 __entry->root_objectid = root->root_key.objectid;
609 __entry->buf_start = buf->start;
610 __entry->refs = atomic_read(&buf->refs);
611 __entry->cow_start = cow->start;
612 __entry->buf_level = btrfs_header_level(buf);
613 __entry->cow_level = btrfs_header_level(cow);
614 ),
615
616 TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
617 "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
618 show_root_type(__entry->root_objectid),
619 __entry->refs,
620 (unsigned long long)__entry->buf_start,
621 __entry->buf_level,
622 (unsigned long long)__entry->cow_start,
623 __entry->cow_level)
624);
625
626DECLARE_EVENT_CLASS(btrfs__reserved_extent,
627
628 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
629
630 TP_ARGS(root, start, len),
631
632 TP_STRUCT__entry(
633 __field( u64, root_objectid )
634 __field( u64, start )
635 __field( u64, len )
636 ),
637
638 TP_fast_assign(
639 __entry->root_objectid = root->root_key.objectid;
640 __entry->start = start;
641 __entry->len = len;
642 ),
643
644 TP_printk("root = %llu(%s), start = %llu, len = %llu",
645 show_root_type(__entry->root_objectid),
646 (unsigned long long)__entry->start,
647 (unsigned long long)__entry->len)
648);
649
650DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_alloc,
651
652 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
653
654 TP_ARGS(root, start, len)
655);
656
657DEFINE_EVENT(btrfs__reserved_extent, btrfs_reserved_extent_free,
658
659 TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
660
661 TP_ARGS(root, start, len)
662);
663
664#endif /* _TRACE_BTRFS_H */
665
666/* This part must be outside protection */
667#include <trace/define_trace.h>
diff --git a/include/trace/events/compaction.h b/include/trace/events/compaction.h
new file mode 100644
index 000000000000..388bcdd26d46
--- /dev/null
+++ b/include/trace/events/compaction.h
@@ -0,0 +1,74 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM compaction
3
4#if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_COMPACTION_H
6
7#include <linux/types.h>
8#include <linux/tracepoint.h>
9#include "gfpflags.h"
10
11DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
12
13 TP_PROTO(unsigned long nr_scanned,
14 unsigned long nr_taken),
15
16 TP_ARGS(nr_scanned, nr_taken),
17
18 TP_STRUCT__entry(
19 __field(unsigned long, nr_scanned)
20 __field(unsigned long, nr_taken)
21 ),
22
23 TP_fast_assign(
24 __entry->nr_scanned = nr_scanned;
25 __entry->nr_taken = nr_taken;
26 ),
27
28 TP_printk("nr_scanned=%lu nr_taken=%lu",
29 __entry->nr_scanned,
30 __entry->nr_taken)
31);
32
33DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
34
35 TP_PROTO(unsigned long nr_scanned,
36 unsigned long nr_taken),
37
38 TP_ARGS(nr_scanned, nr_taken)
39);
40
41DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
42 TP_PROTO(unsigned long nr_scanned,
43 unsigned long nr_taken),
44
45 TP_ARGS(nr_scanned, nr_taken)
46);
47
48TRACE_EVENT(mm_compaction_migratepages,
49
50 TP_PROTO(unsigned long nr_migrated,
51 unsigned long nr_failed),
52
53 TP_ARGS(nr_migrated, nr_failed),
54
55 TP_STRUCT__entry(
56 __field(unsigned long, nr_migrated)
57 __field(unsigned long, nr_failed)
58 ),
59
60 TP_fast_assign(
61 __entry->nr_migrated = nr_migrated;
62 __entry->nr_failed = nr_failed;
63 ),
64
65 TP_printk("nr_migrated=%lu nr_failed=%lu",
66 __entry->nr_migrated,
67 __entry->nr_failed)
68);
69
70
71#endif /* _TRACE_COMPACTION_H */
72
73/* This part must be outside protection */
74#include <trace/define_trace.h>
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 01e9e0076a92..5ce2b2f5f524 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -26,7 +26,7 @@ TRACE_EVENT(ext4_free_inode,
26 __field( umode_t, mode ) 26 __field( umode_t, mode )
27 __field( uid_t, uid ) 27 __field( uid_t, uid )
28 __field( gid_t, gid ) 28 __field( gid_t, gid )
29 __field( blkcnt_t, blocks ) 29 __field( __u64, blocks )
30 ), 30 ),
31 31
32 TP_fast_assign( 32 TP_fast_assign(
@@ -38,10 +38,10 @@ TRACE_EVENT(ext4_free_inode,
38 __entry->blocks = inode->i_blocks; 38 __entry->blocks = inode->i_blocks;
39 ), 39 ),
40 40
41 TP_printk("dev %s ino %lu mode 0%o uid %u gid %u blocks %llu", 41 TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %llu",
42 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 42 MAJOR(__entry->dev), MINOR(__entry->dev),
43 __entry->mode, __entry->uid, __entry->gid, 43 (unsigned long) __entry->ino, __entry->mode,
44 (unsigned long long) __entry->blocks) 44 __entry->uid, __entry->gid, __entry->blocks)
45); 45);
46 46
47TRACE_EVENT(ext4_request_inode, 47TRACE_EVENT(ext4_request_inode,
@@ -61,9 +61,9 @@ TRACE_EVENT(ext4_request_inode,
61 __entry->mode = mode; 61 __entry->mode = mode;
62 ), 62 ),
63 63
64 TP_printk("dev %s dir %lu mode 0%o", 64 TP_printk("dev %d,%d dir %lu mode 0%o",
65 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->dir, 65 MAJOR(__entry->dev), MINOR(__entry->dev),
66 __entry->mode) 66 (unsigned long) __entry->dir, __entry->mode)
67); 67);
68 68
69TRACE_EVENT(ext4_allocate_inode, 69TRACE_EVENT(ext4_allocate_inode,
@@ -85,11 +85,101 @@ TRACE_EVENT(ext4_allocate_inode,
85 __entry->mode = mode; 85 __entry->mode = mode;
86 ), 86 ),
87 87
88 TP_printk("dev %s ino %lu dir %lu mode 0%o", 88 TP_printk("dev %d,%d ino %lu dir %lu mode 0%o",
89 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 89 MAJOR(__entry->dev), MINOR(__entry->dev),
90 (unsigned long) __entry->ino,
90 (unsigned long) __entry->dir, __entry->mode) 91 (unsigned long) __entry->dir, __entry->mode)
91); 92);
92 93
94TRACE_EVENT(ext4_evict_inode,
95 TP_PROTO(struct inode *inode),
96
97 TP_ARGS(inode),
98
99 TP_STRUCT__entry(
100 __field( dev_t, dev )
101 __field( ino_t, ino )
102 __field( int, nlink )
103 ),
104
105 TP_fast_assign(
106 __entry->dev = inode->i_sb->s_dev;
107 __entry->ino = inode->i_ino;
108 __entry->nlink = inode->i_nlink;
109 ),
110
111 TP_printk("dev %d,%d ino %lu nlink %d",
112 MAJOR(__entry->dev), MINOR(__entry->dev),
113 (unsigned long) __entry->ino, __entry->nlink)
114);
115
116TRACE_EVENT(ext4_drop_inode,
117 TP_PROTO(struct inode *inode, int drop),
118
119 TP_ARGS(inode, drop),
120
121 TP_STRUCT__entry(
122 __field( dev_t, dev )
123 __field( ino_t, ino )
124 __field( int, drop )
125 ),
126
127 TP_fast_assign(
128 __entry->dev = inode->i_sb->s_dev;
129 __entry->ino = inode->i_ino;
130 __entry->drop = drop;
131 ),
132
133 TP_printk("dev %d,%d ino %lu drop %d",
134 MAJOR(__entry->dev), MINOR(__entry->dev),
135 (unsigned long) __entry->ino, __entry->drop)
136);
137
138TRACE_EVENT(ext4_mark_inode_dirty,
139 TP_PROTO(struct inode *inode, unsigned long IP),
140
141 TP_ARGS(inode, IP),
142
143 TP_STRUCT__entry(
144 __field( dev_t, dev )
145 __field( ino_t, ino )
146 __field(unsigned long, ip )
147 ),
148
149 TP_fast_assign(
150 __entry->dev = inode->i_sb->s_dev;
151 __entry->ino = inode->i_ino;
152 __entry->ip = IP;
153 ),
154
155 TP_printk("dev %d,%d ino %lu caller %pF",
156 MAJOR(__entry->dev), MINOR(__entry->dev),
157 (unsigned long) __entry->ino, (void *)__entry->ip)
158);
159
160TRACE_EVENT(ext4_begin_ordered_truncate,
161 TP_PROTO(struct inode *inode, loff_t new_size),
162
163 TP_ARGS(inode, new_size),
164
165 TP_STRUCT__entry(
166 __field( dev_t, dev )
167 __field( ino_t, ino )
168 __field( loff_t, new_size )
169 ),
170
171 TP_fast_assign(
172 __entry->dev = inode->i_sb->s_dev;
173 __entry->ino = inode->i_ino;
174 __entry->new_size = new_size;
175 ),
176
177 TP_printk("dev %d,%d ino %lu new_size %lld",
178 MAJOR(__entry->dev), MINOR(__entry->dev),
179 (unsigned long) __entry->ino,
180 __entry->new_size)
181);
182
93DECLARE_EVENT_CLASS(ext4__write_begin, 183DECLARE_EVENT_CLASS(ext4__write_begin,
94 184
95 TP_PROTO(struct inode *inode, loff_t pos, unsigned int len, 185 TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
@@ -113,8 +203,9 @@ DECLARE_EVENT_CLASS(ext4__write_begin,
113 __entry->flags = flags; 203 __entry->flags = flags;
114 ), 204 ),
115 205
116 TP_printk("dev %s ino %lu pos %llu len %u flags %u", 206 TP_printk("dev %d,%d ino %lu pos %lld len %u flags %u",
117 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 207 MAJOR(__entry->dev), MINOR(__entry->dev),
208 (unsigned long) __entry->ino,
118 __entry->pos, __entry->len, __entry->flags) 209 __entry->pos, __entry->len, __entry->flags)
119); 210);
120 211
@@ -156,8 +247,9 @@ DECLARE_EVENT_CLASS(ext4__write_end,
156 __entry->copied = copied; 247 __entry->copied = copied;
157 ), 248 ),
158 249
159 TP_printk("dev %s ino %lu pos %llu len %u copied %u", 250 TP_printk("dev %d,%d ino %lu pos %lld len %u copied %u",
160 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 251 MAJOR(__entry->dev), MINOR(__entry->dev),
252 (unsigned long) __entry->ino,
161 __entry->pos, __entry->len, __entry->copied) 253 __entry->pos, __entry->len, __entry->copied)
162); 254);
163 255
@@ -193,29 +285,6 @@ DEFINE_EVENT(ext4__write_end, ext4_da_write_end,
193 TP_ARGS(inode, pos, len, copied) 285 TP_ARGS(inode, pos, len, copied)
194); 286);
195 287
196TRACE_EVENT(ext4_writepage,
197 TP_PROTO(struct inode *inode, struct page *page),
198
199 TP_ARGS(inode, page),
200
201 TP_STRUCT__entry(
202 __field( dev_t, dev )
203 __field( ino_t, ino )
204 __field( pgoff_t, index )
205
206 ),
207
208 TP_fast_assign(
209 __entry->dev = inode->i_sb->s_dev;
210 __entry->ino = inode->i_ino;
211 __entry->index = page->index;
212 ),
213
214 TP_printk("dev %s ino %lu page_index %lu",
215 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino,
216 __entry->index)
217);
218
219TRACE_EVENT(ext4_da_writepages, 288TRACE_EVENT(ext4_da_writepages,
220 TP_PROTO(struct inode *inode, struct writeback_control *wbc), 289 TP_PROTO(struct inode *inode, struct writeback_control *wbc),
221 290
@@ -228,9 +297,8 @@ TRACE_EVENT(ext4_da_writepages,
228 __field( long, pages_skipped ) 297 __field( long, pages_skipped )
229 __field( loff_t, range_start ) 298 __field( loff_t, range_start )
230 __field( loff_t, range_end ) 299 __field( loff_t, range_end )
231 __field( char, nonblocking ) 300 __field( int, sync_mode )
232 __field( char, for_kupdate ) 301 __field( char, for_kupdate )
233 __field( char, for_reclaim )
234 __field( char, range_cyclic ) 302 __field( char, range_cyclic )
235 __field( pgoff_t, writeback_index ) 303 __field( pgoff_t, writeback_index )
236 ), 304 ),
@@ -242,20 +310,20 @@ TRACE_EVENT(ext4_da_writepages,
242 __entry->pages_skipped = wbc->pages_skipped; 310 __entry->pages_skipped = wbc->pages_skipped;
243 __entry->range_start = wbc->range_start; 311 __entry->range_start = wbc->range_start;
244 __entry->range_end = wbc->range_end; 312 __entry->range_end = wbc->range_end;
245 __entry->nonblocking = wbc->nonblocking; 313 __entry->sync_mode = wbc->sync_mode;
246 __entry->for_kupdate = wbc->for_kupdate; 314 __entry->for_kupdate = wbc->for_kupdate;
247 __entry->for_reclaim = wbc->for_reclaim;
248 __entry->range_cyclic = wbc->range_cyclic; 315 __entry->range_cyclic = wbc->range_cyclic;
249 __entry->writeback_index = inode->i_mapping->writeback_index; 316 __entry->writeback_index = inode->i_mapping->writeback_index;
250 ), 317 ),
251 318
252 TP_printk("dev %s ino %lu nr_to_write %ld pages_skipped %ld range_start %llu range_end %llu nonblocking %d for_kupdate %d for_reclaim %d range_cyclic %d writeback_index %lu", 319 TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld "
253 jbd2_dev_to_name(__entry->dev), 320 "range_start %lld range_end %lld sync_mode %d"
321 "for_kupdate %d range_cyclic %d writeback_index %lu",
322 MAJOR(__entry->dev), MINOR(__entry->dev),
254 (unsigned long) __entry->ino, __entry->nr_to_write, 323 (unsigned long) __entry->ino, __entry->nr_to_write,
255 __entry->pages_skipped, __entry->range_start, 324 __entry->pages_skipped, __entry->range_start,
256 __entry->range_end, __entry->nonblocking, 325 __entry->range_end, __entry->sync_mode,
257 __entry->for_kupdate, __entry->for_reclaim, 326 __entry->for_kupdate, __entry->range_cyclic,
258 __entry->range_cyclic,
259 (unsigned long) __entry->writeback_index) 327 (unsigned long) __entry->writeback_index)
260); 328);
261 329
@@ -273,6 +341,7 @@ TRACE_EVENT(ext4_da_write_pages,
273 __field( unsigned long, first_page ) 341 __field( unsigned long, first_page )
274 __field( int, io_done ) 342 __field( int, io_done )
275 __field( int, pages_written ) 343 __field( int, pages_written )
344 __field( int, sync_mode )
276 ), 345 ),
277 346
278 TP_fast_assign( 347 TP_fast_assign(
@@ -284,13 +353,18 @@ TRACE_EVENT(ext4_da_write_pages,
284 __entry->first_page = mpd->first_page; 353 __entry->first_page = mpd->first_page;
285 __entry->io_done = mpd->io_done; 354 __entry->io_done = mpd->io_done;
286 __entry->pages_written = mpd->pages_written; 355 __entry->pages_written = mpd->pages_written;
356 __entry->sync_mode = mpd->wbc->sync_mode;
287 ), 357 ),
288 358
289 TP_printk("dev %s ino %lu b_blocknr %llu b_size %u b_state 0x%04x first_page %lu io_done %d pages_written %d", 359 TP_printk("dev %d,%d ino %lu b_blocknr %llu b_size %u b_state 0x%04x "
290 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 360 "first_page %lu io_done %d pages_written %d sync_mode %d",
361 MAJOR(__entry->dev), MINOR(__entry->dev),
362 (unsigned long) __entry->ino,
291 __entry->b_blocknr, __entry->b_size, 363 __entry->b_blocknr, __entry->b_size,
292 __entry->b_state, __entry->first_page, 364 __entry->b_state, __entry->first_page,
293 __entry->io_done, __entry->pages_written) 365 __entry->io_done, __entry->pages_written,
366 __entry->sync_mode
367 )
294); 368);
295 369
296TRACE_EVENT(ext4_da_writepages_result, 370TRACE_EVENT(ext4_da_writepages_result,
@@ -305,6 +379,7 @@ TRACE_EVENT(ext4_da_writepages_result,
305 __field( int, ret ) 379 __field( int, ret )
306 __field( int, pages_written ) 380 __field( int, pages_written )
307 __field( long, pages_skipped ) 381 __field( long, pages_skipped )
382 __field( int, sync_mode )
308 __field( char, more_io ) 383 __field( char, more_io )
309 __field( pgoff_t, writeback_index ) 384 __field( pgoff_t, writeback_index )
310 ), 385 ),
@@ -315,18 +390,91 @@ TRACE_EVENT(ext4_da_writepages_result,
315 __entry->ret = ret; 390 __entry->ret = ret;
316 __entry->pages_written = pages_written; 391 __entry->pages_written = pages_written;
317 __entry->pages_skipped = wbc->pages_skipped; 392 __entry->pages_skipped = wbc->pages_skipped;
393 __entry->sync_mode = wbc->sync_mode;
318 __entry->more_io = wbc->more_io; 394 __entry->more_io = wbc->more_io;
319 __entry->writeback_index = inode->i_mapping->writeback_index; 395 __entry->writeback_index = inode->i_mapping->writeback_index;
320 ), 396 ),
321 397
322 TP_printk("dev %s ino %lu ret %d pages_written %d pages_skipped %ld more_io %d writeback_index %lu", 398 TP_printk("dev %d,%d ino %lu ret %d pages_written %d pages_skipped %ld "
323 jbd2_dev_to_name(__entry->dev), 399 " more_io %d sync_mode %d writeback_index %lu",
400 MAJOR(__entry->dev), MINOR(__entry->dev),
324 (unsigned long) __entry->ino, __entry->ret, 401 (unsigned long) __entry->ino, __entry->ret,
325 __entry->pages_written, __entry->pages_skipped, 402 __entry->pages_written, __entry->pages_skipped,
326 __entry->more_io, 403 __entry->more_io, __entry->sync_mode,
327 (unsigned long) __entry->writeback_index) 404 (unsigned long) __entry->writeback_index)
328); 405);
329 406
407DECLARE_EVENT_CLASS(ext4__page_op,
408 TP_PROTO(struct page *page),
409
410 TP_ARGS(page),
411
412 TP_STRUCT__entry(
413 __field( pgoff_t, index )
414 __field( ino_t, ino )
415 __field( dev_t, dev )
416
417 ),
418
419 TP_fast_assign(
420 __entry->index = page->index;
421 __entry->ino = page->mapping->host->i_ino;
422 __entry->dev = page->mapping->host->i_sb->s_dev;
423 ),
424
425 TP_printk("dev %d,%d ino %lu page_index %lu",
426 MAJOR(__entry->dev), MINOR(__entry->dev),
427 (unsigned long) __entry->ino,
428 (unsigned long) __entry->index)
429);
430
431DEFINE_EVENT(ext4__page_op, ext4_writepage,
432
433 TP_PROTO(struct page *page),
434
435 TP_ARGS(page)
436);
437
438DEFINE_EVENT(ext4__page_op, ext4_readpage,
439
440 TP_PROTO(struct page *page),
441
442 TP_ARGS(page)
443);
444
445DEFINE_EVENT(ext4__page_op, ext4_releasepage,
446
447 TP_PROTO(struct page *page),
448
449 TP_ARGS(page)
450);
451
452TRACE_EVENT(ext4_invalidatepage,
453 TP_PROTO(struct page *page, unsigned long offset),
454
455 TP_ARGS(page, offset),
456
457 TP_STRUCT__entry(
458 __field( pgoff_t, index )
459 __field( unsigned long, offset )
460 __field( ino_t, ino )
461 __field( dev_t, dev )
462
463 ),
464
465 TP_fast_assign(
466 __entry->index = page->index;
467 __entry->offset = offset;
468 __entry->ino = page->mapping->host->i_ino;
469 __entry->dev = page->mapping->host->i_sb->s_dev;
470 ),
471
472 TP_printk("dev %d,%d ino %lu page_index %lu offset %lu",
473 MAJOR(__entry->dev), MINOR(__entry->dev),
474 (unsigned long) __entry->ino,
475 (unsigned long) __entry->index, __entry->offset)
476);
477
330TRACE_EVENT(ext4_discard_blocks, 478TRACE_EVENT(ext4_discard_blocks,
331 TP_PROTO(struct super_block *sb, unsigned long long blk, 479 TP_PROTO(struct super_block *sb, unsigned long long blk,
332 unsigned long long count), 480 unsigned long long count),
@@ -346,8 +494,9 @@ TRACE_EVENT(ext4_discard_blocks,
346 __entry->count = count; 494 __entry->count = count;
347 ), 495 ),
348 496
349 TP_printk("dev %s blk %llu count %llu", 497 TP_printk("dev %d,%d blk %llu count %llu",
350 jbd2_dev_to_name(__entry->dev), __entry->blk, __entry->count) 498 MAJOR(__entry->dev), MINOR(__entry->dev),
499 __entry->blk, __entry->count)
351); 500);
352 501
353DECLARE_EVENT_CLASS(ext4__mb_new_pa, 502DECLARE_EVENT_CLASS(ext4__mb_new_pa,
@@ -373,8 +522,9 @@ DECLARE_EVENT_CLASS(ext4__mb_new_pa,
373 __entry->pa_lstart = pa->pa_lstart; 522 __entry->pa_lstart = pa->pa_lstart;
374 ), 523 ),
375 524
376 TP_printk("dev %s ino %lu pstart %llu len %u lstart %llu", 525 TP_printk("dev %d,%d ino %lu pstart %llu len %u lstart %llu",
377 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 526 MAJOR(__entry->dev), MINOR(__entry->dev),
527 (unsigned long) __entry->ino,
378 __entry->pa_pstart, __entry->pa_len, __entry->pa_lstart) 528 __entry->pa_pstart, __entry->pa_len, __entry->pa_lstart)
379); 529);
380 530
@@ -395,12 +545,10 @@ DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_group_pa,
395); 545);
396 546
397TRACE_EVENT(ext4_mb_release_inode_pa, 547TRACE_EVENT(ext4_mb_release_inode_pa,
398 TP_PROTO(struct super_block *sb, 548 TP_PROTO(struct ext4_prealloc_space *pa,
399 struct ext4_allocation_context *ac,
400 struct ext4_prealloc_space *pa,
401 unsigned long long block, unsigned int count), 549 unsigned long long block, unsigned int count),
402 550
403 TP_ARGS(sb, ac, pa, block, count), 551 TP_ARGS(pa, block, count),
404 552
405 TP_STRUCT__entry( 553 TP_STRUCT__entry(
406 __field( dev_t, dev ) 554 __field( dev_t, dev )
@@ -411,43 +559,39 @@ TRACE_EVENT(ext4_mb_release_inode_pa,
411 ), 559 ),
412 560
413 TP_fast_assign( 561 TP_fast_assign(
414 __entry->dev = sb->s_dev; 562 __entry->dev = pa->pa_inode->i_sb->s_dev;
415 __entry->ino = (ac && ac->ac_inode) ? 563 __entry->ino = pa->pa_inode->i_ino;
416 ac->ac_inode->i_ino : 0;
417 __entry->block = block; 564 __entry->block = block;
418 __entry->count = count; 565 __entry->count = count;
419 ), 566 ),
420 567
421 TP_printk("dev %s ino %lu block %llu count %u", 568 TP_printk("dev %d,%d ino %lu block %llu count %u",
422 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 569 MAJOR(__entry->dev), MINOR(__entry->dev),
570 (unsigned long) __entry->ino,
423 __entry->block, __entry->count) 571 __entry->block, __entry->count)
424); 572);
425 573
426TRACE_EVENT(ext4_mb_release_group_pa, 574TRACE_EVENT(ext4_mb_release_group_pa,
427 TP_PROTO(struct super_block *sb, 575 TP_PROTO(struct ext4_prealloc_space *pa),
428 struct ext4_allocation_context *ac,
429 struct ext4_prealloc_space *pa),
430 576
431 TP_ARGS(sb, ac, pa), 577 TP_ARGS(pa),
432 578
433 TP_STRUCT__entry( 579 TP_STRUCT__entry(
434 __field( dev_t, dev ) 580 __field( dev_t, dev )
435 __field( ino_t, ino )
436 __field( __u64, pa_pstart ) 581 __field( __u64, pa_pstart )
437 __field( __u32, pa_len ) 582 __field( __u32, pa_len )
438 583
439 ), 584 ),
440 585
441 TP_fast_assign( 586 TP_fast_assign(
442 __entry->dev = sb->s_dev; 587 __entry->dev = pa->pa_inode->i_sb->s_dev;
443 __entry->ino = (ac && ac->ac_inode) ?
444 ac->ac_inode->i_ino : 0;
445 __entry->pa_pstart = pa->pa_pstart; 588 __entry->pa_pstart = pa->pa_pstart;
446 __entry->pa_len = pa->pa_len; 589 __entry->pa_len = pa->pa_len;
447 ), 590 ),
448 591
449 TP_printk("dev %s pstart %llu len %u", 592 TP_printk("dev %d,%d pstart %llu len %u",
450 jbd2_dev_to_name(__entry->dev), __entry->pa_pstart, __entry->pa_len) 593 MAJOR(__entry->dev), MINOR(__entry->dev),
594 __entry->pa_pstart, __entry->pa_len)
451); 595);
452 596
453TRACE_EVENT(ext4_discard_preallocations, 597TRACE_EVENT(ext4_discard_preallocations,
@@ -466,8 +610,9 @@ TRACE_EVENT(ext4_discard_preallocations,
466 __entry->ino = inode->i_ino; 610 __entry->ino = inode->i_ino;
467 ), 611 ),
468 612
469 TP_printk("dev %s ino %lu", 613 TP_printk("dev %d,%d ino %lu",
470 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino) 614 MAJOR(__entry->dev), MINOR(__entry->dev),
615 (unsigned long) __entry->ino)
471); 616);
472 617
473TRACE_EVENT(ext4_mb_discard_preallocations, 618TRACE_EVENT(ext4_mb_discard_preallocations,
@@ -486,8 +631,9 @@ TRACE_EVENT(ext4_mb_discard_preallocations,
486 __entry->needed = needed; 631 __entry->needed = needed;
487 ), 632 ),
488 633
489 TP_printk("dev %s needed %d", 634 TP_printk("dev %d,%d needed %d",
490 jbd2_dev_to_name(__entry->dev), __entry->needed) 635 MAJOR(__entry->dev), MINOR(__entry->dev),
636 __entry->needed)
491); 637);
492 638
493TRACE_EVENT(ext4_request_blocks, 639TRACE_EVENT(ext4_request_blocks,
@@ -500,10 +646,10 @@ TRACE_EVENT(ext4_request_blocks,
500 __field( ino_t, ino ) 646 __field( ino_t, ino )
501 __field( unsigned int, flags ) 647 __field( unsigned int, flags )
502 __field( unsigned int, len ) 648 __field( unsigned int, len )
503 __field( __u64, logical ) 649 __field( __u32, logical )
650 __field( __u32, lleft )
651 __field( __u32, lright )
504 __field( __u64, goal ) 652 __field( __u64, goal )
505 __field( __u64, lleft )
506 __field( __u64, lright )
507 __field( __u64, pleft ) 653 __field( __u64, pleft )
508 __field( __u64, pright ) 654 __field( __u64, pright )
509 ), 655 ),
@@ -521,15 +667,13 @@ TRACE_EVENT(ext4_request_blocks,
521 __entry->pright = ar->pright; 667 __entry->pright = ar->pright;
522 ), 668 ),
523 669
524 TP_printk("dev %s ino %lu flags %u len %u lblk %llu goal %llu lleft %llu lright %llu pleft %llu pright %llu ", 670 TP_printk("dev %d,%d ino %lu flags %u len %u lblk %u goal %llu "
525 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 671 "lleft %u lright %u pleft %llu pright %llu ",
526 __entry->flags, __entry->len, 672 MAJOR(__entry->dev), MINOR(__entry->dev),
527 (unsigned long long) __entry->logical, 673 (unsigned long) __entry->ino, __entry->flags,
528 (unsigned long long) __entry->goal, 674 __entry->len, __entry->logical, __entry->goal,
529 (unsigned long long) __entry->lleft, 675 __entry->lleft, __entry->lright, __entry->pleft,
530 (unsigned long long) __entry->lright, 676 __entry->pright)
531 (unsigned long long) __entry->pleft,
532 (unsigned long long) __entry->pright)
533); 677);
534 678
535TRACE_EVENT(ext4_allocate_blocks, 679TRACE_EVENT(ext4_allocate_blocks,
@@ -543,10 +687,10 @@ TRACE_EVENT(ext4_allocate_blocks,
543 __field( __u64, block ) 687 __field( __u64, block )
544 __field( unsigned int, flags ) 688 __field( unsigned int, flags )
545 __field( unsigned int, len ) 689 __field( unsigned int, len )
546 __field( __u64, logical ) 690 __field( __u32, logical )
691 __field( __u32, lleft )
692 __field( __u32, lright )
547 __field( __u64, goal ) 693 __field( __u64, goal )
548 __field( __u64, lleft )
549 __field( __u64, lright )
550 __field( __u64, pleft ) 694 __field( __u64, pleft )
551 __field( __u64, pright ) 695 __field( __u64, pright )
552 ), 696 ),
@@ -565,15 +709,13 @@ TRACE_EVENT(ext4_allocate_blocks,
565 __entry->pright = ar->pright; 709 __entry->pright = ar->pright;
566 ), 710 ),
567 711
568 TP_printk("dev %s ino %lu flags %u len %u block %llu lblk %llu goal %llu lleft %llu lright %llu pleft %llu pright %llu ", 712 TP_printk("dev %d,%d ino %lu flags %u len %u block %llu lblk %u "
569 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 713 "goal %llu lleft %u lright %u pleft %llu pright %llu",
570 __entry->flags, __entry->len, __entry->block, 714 MAJOR(__entry->dev), MINOR(__entry->dev),
571 (unsigned long long) __entry->logical, 715 (unsigned long) __entry->ino, __entry->flags,
572 (unsigned long long) __entry->goal, 716 __entry->len, __entry->block, __entry->logical,
573 (unsigned long long) __entry->lleft, 717 __entry->goal, __entry->lleft, __entry->lright,
574 (unsigned long long) __entry->lright, 718 __entry->pleft, __entry->pright)
575 (unsigned long long) __entry->pleft,
576 (unsigned long long) __entry->pright)
577); 719);
578 720
579TRACE_EVENT(ext4_free_blocks, 721TRACE_EVENT(ext4_free_blocks,
@@ -585,10 +727,10 @@ TRACE_EVENT(ext4_free_blocks,
585 TP_STRUCT__entry( 727 TP_STRUCT__entry(
586 __field( dev_t, dev ) 728 __field( dev_t, dev )
587 __field( ino_t, ino ) 729 __field( ino_t, ino )
588 __field( umode_t, mode ) 730 __field( umode_t, mode )
589 __field( __u64, block ) 731 __field( __u64, block )
590 __field( unsigned long, count ) 732 __field( unsigned long, count )
591 __field( int, flags ) 733 __field( int, flags )
592 ), 734 ),
593 735
594 TP_fast_assign( 736 TP_fast_assign(
@@ -600,13 +742,14 @@ TRACE_EVENT(ext4_free_blocks,
600 __entry->flags = flags; 742 __entry->flags = flags;
601 ), 743 ),
602 744
603 TP_printk("dev %s ino %lu mode 0%o block %llu count %lu flags %d", 745 TP_printk("dev %d,%d ino %lu mode 0%o block %llu count %lu flags %d",
604 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 746 MAJOR(__entry->dev), MINOR(__entry->dev),
747 (unsigned long) __entry->ino,
605 __entry->mode, __entry->block, __entry->count, 748 __entry->mode, __entry->block, __entry->count,
606 __entry->flags) 749 __entry->flags)
607); 750);
608 751
609TRACE_EVENT(ext4_sync_file, 752TRACE_EVENT(ext4_sync_file_enter,
610 TP_PROTO(struct file *file, int datasync), 753 TP_PROTO(struct file *file, int datasync),
611 754
612 TP_ARGS(file, datasync), 755 TP_ARGS(file, datasync),
@@ -627,11 +770,35 @@ TRACE_EVENT(ext4_sync_file,
627 __entry->parent = dentry->d_parent->d_inode->i_ino; 770 __entry->parent = dentry->d_parent->d_inode->i_ino;
628 ), 771 ),
629 772
630 TP_printk("dev %s ino %ld parent %ld datasync %d ", 773 TP_printk("dev %d,%d ino %lu parent %lu datasync %d ",
631 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 774 MAJOR(__entry->dev), MINOR(__entry->dev),
775 (unsigned long) __entry->ino,
632 (unsigned long) __entry->parent, __entry->datasync) 776 (unsigned long) __entry->parent, __entry->datasync)
633); 777);
634 778
779TRACE_EVENT(ext4_sync_file_exit,
780 TP_PROTO(struct inode *inode, int ret),
781
782 TP_ARGS(inode, ret),
783
784 TP_STRUCT__entry(
785 __field( int, ret )
786 __field( ino_t, ino )
787 __field( dev_t, dev )
788 ),
789
790 TP_fast_assign(
791 __entry->ret = ret;
792 __entry->ino = inode->i_ino;
793 __entry->dev = inode->i_sb->s_dev;
794 ),
795
796 TP_printk("dev %d,%d ino %lu ret %d",
797 MAJOR(__entry->dev), MINOR(__entry->dev),
798 (unsigned long) __entry->ino,
799 __entry->ret)
800);
801
635TRACE_EVENT(ext4_sync_fs, 802TRACE_EVENT(ext4_sync_fs,
636 TP_PROTO(struct super_block *sb, int wait), 803 TP_PROTO(struct super_block *sb, int wait),
637 804
@@ -648,7 +815,8 @@ TRACE_EVENT(ext4_sync_fs,
648 __entry->wait = wait; 815 __entry->wait = wait;
649 ), 816 ),
650 817
651 TP_printk("dev %s wait %d", jbd2_dev_to_name(__entry->dev), 818 TP_printk("dev %d,%d wait %d",
819 MAJOR(__entry->dev), MINOR(__entry->dev),
652 __entry->wait) 820 __entry->wait)
653); 821);
654 822
@@ -671,8 +839,9 @@ TRACE_EVENT(ext4_alloc_da_blocks,
671 __entry->meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks; 839 __entry->meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks;
672 ), 840 ),
673 841
674 TP_printk("dev %s ino %lu data_blocks %u meta_blocks %u", 842 TP_printk("dev %d,%d ino %lu data_blocks %u meta_blocks %u",
675 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 843 MAJOR(__entry->dev), MINOR(__entry->dev),
844 (unsigned long) __entry->ino,
676 __entry->data_blocks, __entry->meta_blocks) 845 __entry->data_blocks, __entry->meta_blocks)
677); 846);
678 847
@@ -727,10 +896,11 @@ TRACE_EVENT(ext4_mballoc_alloc,
727 __entry->result_len = ac->ac_f_ex.fe_len; 896 __entry->result_len = ac->ac_f_ex.fe_len;
728 ), 897 ),
729 898
730 TP_printk("dev %s inode %lu orig %u/%d/%u@%u goal %u/%d/%u@%u " 899 TP_printk("dev %d,%d inode %lu orig %u/%d/%u@%u goal %u/%d/%u@%u "
731 "result %u/%d/%u@%u blks %u grps %u cr %u flags 0x%04x " 900 "result %u/%d/%u@%u blks %u grps %u cr %u flags 0x%04x "
732 "tail %u broken %u", 901 "tail %u broken %u",
733 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 902 MAJOR(__entry->dev), MINOR(__entry->dev),
903 (unsigned long) __entry->ino,
734 __entry->orig_group, __entry->orig_start, 904 __entry->orig_group, __entry->orig_start,
735 __entry->orig_len, __entry->orig_logical, 905 __entry->orig_len, __entry->orig_logical,
736 __entry->goal_group, __entry->goal_start, 906 __entry->goal_group, __entry->goal_start,
@@ -773,8 +943,9 @@ TRACE_EVENT(ext4_mballoc_prealloc,
773 __entry->result_len = ac->ac_b_ex.fe_len; 943 __entry->result_len = ac->ac_b_ex.fe_len;
774 ), 944 ),
775 945
776 TP_printk("dev %s inode %lu orig %u/%d/%u@%u result %u/%d/%u@%u", 946 TP_printk("dev %d,%d inode %lu orig %u/%d/%u@%u result %u/%d/%u@%u",
777 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 947 MAJOR(__entry->dev), MINOR(__entry->dev),
948 (unsigned long) __entry->ino,
778 __entry->orig_group, __entry->orig_start, 949 __entry->orig_group, __entry->orig_start,
779 __entry->orig_len, __entry->orig_logical, 950 __entry->orig_len, __entry->orig_logical,
780 __entry->result_group, __entry->result_start, 951 __entry->result_group, __entry->result_start,
@@ -782,46 +953,57 @@ TRACE_EVENT(ext4_mballoc_prealloc,
782); 953);
783 954
784DECLARE_EVENT_CLASS(ext4__mballoc, 955DECLARE_EVENT_CLASS(ext4__mballoc,
785 TP_PROTO(struct ext4_allocation_context *ac), 956 TP_PROTO(struct super_block *sb,
957 struct inode *inode,
958 ext4_group_t group,
959 ext4_grpblk_t start,
960 ext4_grpblk_t len),
786 961
787 TP_ARGS(ac), 962 TP_ARGS(sb, inode, group, start, len),
788 963
789 TP_STRUCT__entry( 964 TP_STRUCT__entry(
790 __field( dev_t, dev ) 965 __field( dev_t, dev )
791 __field( ino_t, ino ) 966 __field( ino_t, ino )
792 __field( __u32, result_logical )
793 __field( int, result_start ) 967 __field( int, result_start )
794 __field( __u32, result_group ) 968 __field( __u32, result_group )
795 __field( int, result_len ) 969 __field( int, result_len )
796 ), 970 ),
797 971
798 TP_fast_assign( 972 TP_fast_assign(
799 __entry->dev = ac->ac_inode->i_sb->s_dev; 973 __entry->dev = sb->s_dev;
800 __entry->ino = ac->ac_inode->i_ino; 974 __entry->ino = inode ? inode->i_ino : 0;
801 __entry->result_logical = ac->ac_b_ex.fe_logical; 975 __entry->result_start = start;
802 __entry->result_start = ac->ac_b_ex.fe_start; 976 __entry->result_group = group;
803 __entry->result_group = ac->ac_b_ex.fe_group; 977 __entry->result_len = len;
804 __entry->result_len = ac->ac_b_ex.fe_len;
805 ), 978 ),
806 979
807 TP_printk("dev %s inode %lu extent %u/%d/%u@%u ", 980 TP_printk("dev %d,%d inode %lu extent %u/%d/%d ",
808 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 981 MAJOR(__entry->dev), MINOR(__entry->dev),
982 (unsigned long) __entry->ino,
809 __entry->result_group, __entry->result_start, 983 __entry->result_group, __entry->result_start,
810 __entry->result_len, __entry->result_logical) 984 __entry->result_len)
811); 985);
812 986
813DEFINE_EVENT(ext4__mballoc, ext4_mballoc_discard, 987DEFINE_EVENT(ext4__mballoc, ext4_mballoc_discard,
814 988
815 TP_PROTO(struct ext4_allocation_context *ac), 989 TP_PROTO(struct super_block *sb,
990 struct inode *inode,
991 ext4_group_t group,
992 ext4_grpblk_t start,
993 ext4_grpblk_t len),
816 994
817 TP_ARGS(ac) 995 TP_ARGS(sb, inode, group, start, len)
818); 996);
819 997
820DEFINE_EVENT(ext4__mballoc, ext4_mballoc_free, 998DEFINE_EVENT(ext4__mballoc, ext4_mballoc_free,
821 999
822 TP_PROTO(struct ext4_allocation_context *ac), 1000 TP_PROTO(struct super_block *sb,
1001 struct inode *inode,
1002 ext4_group_t group,
1003 ext4_grpblk_t start,
1004 ext4_grpblk_t len),
823 1005
824 TP_ARGS(ac) 1006 TP_ARGS(sb, inode, group, start, len)
825); 1007);
826 1008
827TRACE_EVENT(ext4_forget, 1009TRACE_EVENT(ext4_forget,
@@ -845,8 +1027,9 @@ TRACE_EVENT(ext4_forget,
845 __entry->block = block; 1027 __entry->block = block;
846 ), 1028 ),
847 1029
848 TP_printk("dev %s ino %lu mode 0%o is_metadata %d block %llu", 1030 TP_printk("dev %d,%d ino %lu mode 0%o is_metadata %d block %llu",
849 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 1031 MAJOR(__entry->dev), MINOR(__entry->dev),
1032 (unsigned long) __entry->ino,
850 __entry->mode, __entry->is_metadata, __entry->block) 1033 __entry->mode, __entry->is_metadata, __entry->block)
851); 1034);
852 1035
@@ -877,9 +1060,12 @@ TRACE_EVENT(ext4_da_update_reserve_space,
877 __entry->allocated_meta_blocks = EXT4_I(inode)->i_allocated_meta_blocks; 1060 __entry->allocated_meta_blocks = EXT4_I(inode)->i_allocated_meta_blocks;
878 ), 1061 ),
879 1062
880 TP_printk("dev %s ino %lu mode 0%o i_blocks %llu used_blocks %d reserved_data_blocks %d reserved_meta_blocks %d allocated_meta_blocks %d", 1063 TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu used_blocks %d "
881 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 1064 "reserved_data_blocks %d reserved_meta_blocks %d "
882 __entry->mode, (unsigned long long) __entry->i_blocks, 1065 "allocated_meta_blocks %d",
1066 MAJOR(__entry->dev), MINOR(__entry->dev),
1067 (unsigned long) __entry->ino,
1068 __entry->mode, __entry->i_blocks,
883 __entry->used_blocks, __entry->reserved_data_blocks, 1069 __entry->used_blocks, __entry->reserved_data_blocks,
884 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks) 1070 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks)
885); 1071);
@@ -909,9 +1095,11 @@ TRACE_EVENT(ext4_da_reserve_space,
909 __entry->reserved_meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks; 1095 __entry->reserved_meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks;
910 ), 1096 ),
911 1097
912 TP_printk("dev %s ino %lu mode 0%o i_blocks %llu md_needed %d reserved_data_blocks %d reserved_meta_blocks %d", 1098 TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu md_needed %d "
913 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 1099 "reserved_data_blocks %d reserved_meta_blocks %d",
914 __entry->mode, (unsigned long long) __entry->i_blocks, 1100 MAJOR(__entry->dev), MINOR(__entry->dev),
1101 (unsigned long) __entry->ino,
1102 __entry->mode, __entry->i_blocks,
915 __entry->md_needed, __entry->reserved_data_blocks, 1103 __entry->md_needed, __entry->reserved_data_blocks,
916 __entry->reserved_meta_blocks) 1104 __entry->reserved_meta_blocks)
917); 1105);
@@ -943,9 +1131,12 @@ TRACE_EVENT(ext4_da_release_space,
943 __entry->allocated_meta_blocks = EXT4_I(inode)->i_allocated_meta_blocks; 1131 __entry->allocated_meta_blocks = EXT4_I(inode)->i_allocated_meta_blocks;
944 ), 1132 ),
945 1133
946 TP_printk("dev %s ino %lu mode 0%o i_blocks %llu freed_blocks %d reserved_data_blocks %d reserved_meta_blocks %d allocated_meta_blocks %d", 1134 TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu freed_blocks %d "
947 jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, 1135 "reserved_data_blocks %d reserved_meta_blocks %d "
948 __entry->mode, (unsigned long long) __entry->i_blocks, 1136 "allocated_meta_blocks %d",
1137 MAJOR(__entry->dev), MINOR(__entry->dev),
1138 (unsigned long) __entry->ino,
1139 __entry->mode, __entry->i_blocks,
949 __entry->freed_blocks, __entry->reserved_data_blocks, 1140 __entry->freed_blocks, __entry->reserved_data_blocks,
950 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks) 1141 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks)
951); 1142);
@@ -966,8 +1157,9 @@ DECLARE_EVENT_CLASS(ext4__bitmap_load,
966 __entry->group = group; 1157 __entry->group = group;
967 ), 1158 ),
968 1159
969 TP_printk("dev %s group %u", 1160 TP_printk("dev %d,%d group %u",
970 jbd2_dev_to_name(__entry->dev), __entry->group) 1161 MAJOR(__entry->dev), MINOR(__entry->dev),
1162 __entry->group)
971); 1163);
972 1164
973DEFINE_EVENT(ext4__bitmap_load, ext4_mb_bitmap_load, 1165DEFINE_EVENT(ext4__bitmap_load, ext4_mb_bitmap_load,
@@ -984,6 +1176,350 @@ DEFINE_EVENT(ext4__bitmap_load, ext4_mb_buddy_bitmap_load,
984 TP_ARGS(sb, group) 1176 TP_ARGS(sb, group)
985); 1177);
986 1178
1179DEFINE_EVENT(ext4__bitmap_load, ext4_read_block_bitmap_load,
1180
1181 TP_PROTO(struct super_block *sb, unsigned long group),
1182
1183 TP_ARGS(sb, group)
1184);
1185
1186DEFINE_EVENT(ext4__bitmap_load, ext4_load_inode_bitmap,
1187
1188 TP_PROTO(struct super_block *sb, unsigned long group),
1189
1190 TP_ARGS(sb, group)
1191);
1192
1193TRACE_EVENT(ext4_direct_IO_enter,
1194 TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, int rw),
1195
1196 TP_ARGS(inode, offset, len, rw),
1197
1198 TP_STRUCT__entry(
1199 __field( ino_t, ino )
1200 __field( dev_t, dev )
1201 __field( loff_t, pos )
1202 __field( unsigned long, len )
1203 __field( int, rw )
1204 ),
1205
1206 TP_fast_assign(
1207 __entry->ino = inode->i_ino;
1208 __entry->dev = inode->i_sb->s_dev;
1209 __entry->pos = offset;
1210 __entry->len = len;
1211 __entry->rw = rw;
1212 ),
1213
1214 TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d",
1215 MAJOR(__entry->dev), MINOR(__entry->dev),
1216 (unsigned long) __entry->ino,
1217 __entry->pos, __entry->len, __entry->rw)
1218);
1219
1220TRACE_EVENT(ext4_direct_IO_exit,
1221 TP_PROTO(struct inode *inode, loff_t offset, unsigned long len,
1222 int rw, int ret),
1223
1224 TP_ARGS(inode, offset, len, rw, ret),
1225
1226 TP_STRUCT__entry(
1227 __field( ino_t, ino )
1228 __field( dev_t, dev )
1229 __field( loff_t, pos )
1230 __field( unsigned long, len )
1231 __field( int, rw )
1232 __field( int, ret )
1233 ),
1234
1235 TP_fast_assign(
1236 __entry->ino = inode->i_ino;
1237 __entry->dev = inode->i_sb->s_dev;
1238 __entry->pos = offset;
1239 __entry->len = len;
1240 __entry->rw = rw;
1241 __entry->ret = ret;
1242 ),
1243
1244 TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d ret %d",
1245 MAJOR(__entry->dev), MINOR(__entry->dev),
1246 (unsigned long) __entry->ino,
1247 __entry->pos, __entry->len,
1248 __entry->rw, __entry->ret)
1249);
1250
1251TRACE_EVENT(ext4_fallocate_enter,
1252 TP_PROTO(struct inode *inode, loff_t offset, loff_t len, int mode),
1253
1254 TP_ARGS(inode, offset, len, mode),
1255
1256 TP_STRUCT__entry(
1257 __field( ino_t, ino )
1258 __field( dev_t, dev )
1259 __field( loff_t, pos )
1260 __field( loff_t, len )
1261 __field( int, mode )
1262 ),
1263
1264 TP_fast_assign(
1265 __entry->ino = inode->i_ino;
1266 __entry->dev = inode->i_sb->s_dev;
1267 __entry->pos = offset;
1268 __entry->len = len;
1269 __entry->mode = mode;
1270 ),
1271
1272 TP_printk("dev %d,%d ino %lu pos %lld len %lld mode %d",
1273 MAJOR(__entry->dev), MINOR(__entry->dev),
1274 (unsigned long) __entry->ino, __entry->pos,
1275 __entry->len, __entry->mode)
1276);
1277
1278TRACE_EVENT(ext4_fallocate_exit,
1279 TP_PROTO(struct inode *inode, loff_t offset,
1280 unsigned int max_blocks, int ret),
1281
1282 TP_ARGS(inode, offset, max_blocks, ret),
1283
1284 TP_STRUCT__entry(
1285 __field( ino_t, ino )
1286 __field( dev_t, dev )
1287 __field( loff_t, pos )
1288 __field( unsigned int, blocks )
1289 __field( int, ret )
1290 ),
1291
1292 TP_fast_assign(
1293 __entry->ino = inode->i_ino;
1294 __entry->dev = inode->i_sb->s_dev;
1295 __entry->pos = offset;
1296 __entry->blocks = max_blocks;
1297 __entry->ret = ret;
1298 ),
1299
1300 TP_printk("dev %d,%d ino %lu pos %lld blocks %u ret %d",
1301 MAJOR(__entry->dev), MINOR(__entry->dev),
1302 (unsigned long) __entry->ino,
1303 __entry->pos, __entry->blocks,
1304 __entry->ret)
1305);
1306
1307TRACE_EVENT(ext4_unlink_enter,
1308 TP_PROTO(struct inode *parent, struct dentry *dentry),
1309
1310 TP_ARGS(parent, dentry),
1311
1312 TP_STRUCT__entry(
1313 __field( ino_t, parent )
1314 __field( ino_t, ino )
1315 __field( loff_t, size )
1316 __field( dev_t, dev )
1317 ),
1318
1319 TP_fast_assign(
1320 __entry->parent = parent->i_ino;
1321 __entry->ino = dentry->d_inode->i_ino;
1322 __entry->size = dentry->d_inode->i_size;
1323 __entry->dev = dentry->d_inode->i_sb->s_dev;
1324 ),
1325
1326 TP_printk("dev %d,%d ino %lu size %lld parent %lu",
1327 MAJOR(__entry->dev), MINOR(__entry->dev),
1328 (unsigned long) __entry->ino, __entry->size,
1329 (unsigned long) __entry->parent)
1330);
1331
1332TRACE_EVENT(ext4_unlink_exit,
1333 TP_PROTO(struct dentry *dentry, int ret),
1334
1335 TP_ARGS(dentry, ret),
1336
1337 TP_STRUCT__entry(
1338 __field( ino_t, ino )
1339 __field( dev_t, dev )
1340 __field( int, ret )
1341 ),
1342
1343 TP_fast_assign(
1344 __entry->ino = dentry->d_inode->i_ino;
1345 __entry->dev = dentry->d_inode->i_sb->s_dev;
1346 __entry->ret = ret;
1347 ),
1348
1349 TP_printk("dev %d,%d ino %lu ret %d",
1350 MAJOR(__entry->dev), MINOR(__entry->dev),
1351 (unsigned long) __entry->ino,
1352 __entry->ret)
1353);
1354
1355DECLARE_EVENT_CLASS(ext4__truncate,
1356 TP_PROTO(struct inode *inode),
1357
1358 TP_ARGS(inode),
1359
1360 TP_STRUCT__entry(
1361 __field( ino_t, ino )
1362 __field( dev_t, dev )
1363 __field( __u64, blocks )
1364 ),
1365
1366 TP_fast_assign(
1367 __entry->ino = inode->i_ino;
1368 __entry->dev = inode->i_sb->s_dev;
1369 __entry->blocks = inode->i_blocks;
1370 ),
1371
1372 TP_printk("dev %d,%d ino %lu blocks %llu",
1373 MAJOR(__entry->dev), MINOR(__entry->dev),
1374 (unsigned long) __entry->ino, __entry->blocks)
1375);
1376
1377DEFINE_EVENT(ext4__truncate, ext4_truncate_enter,
1378
1379 TP_PROTO(struct inode *inode),
1380
1381 TP_ARGS(inode)
1382);
1383
1384DEFINE_EVENT(ext4__truncate, ext4_truncate_exit,
1385
1386 TP_PROTO(struct inode *inode),
1387
1388 TP_ARGS(inode)
1389);
1390
1391DECLARE_EVENT_CLASS(ext4__map_blocks_enter,
1392 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1393 unsigned int len, unsigned int flags),
1394
1395 TP_ARGS(inode, lblk, len, flags),
1396
1397 TP_STRUCT__entry(
1398 __field( ino_t, ino )
1399 __field( dev_t, dev )
1400 __field( ext4_lblk_t, lblk )
1401 __field( unsigned int, len )
1402 __field( unsigned int, flags )
1403 ),
1404
1405 TP_fast_assign(
1406 __entry->ino = inode->i_ino;
1407 __entry->dev = inode->i_sb->s_dev;
1408 __entry->lblk = lblk;
1409 __entry->len = len;
1410 __entry->flags = flags;
1411 ),
1412
1413 TP_printk("dev %d,%d ino %lu lblk %u len %u flags %u",
1414 MAJOR(__entry->dev), MINOR(__entry->dev),
1415 (unsigned long) __entry->ino,
1416 __entry->lblk, __entry->len, __entry->flags)
1417);
1418
1419DEFINE_EVENT(ext4__map_blocks_enter, ext4_ext_map_blocks_enter,
1420 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1421 unsigned len, unsigned flags),
1422
1423 TP_ARGS(inode, lblk, len, flags)
1424);
1425
1426DEFINE_EVENT(ext4__map_blocks_enter, ext4_ind_map_blocks_enter,
1427 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1428 unsigned len, unsigned flags),
1429
1430 TP_ARGS(inode, lblk, len, flags)
1431);
1432
1433DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
1434 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1435 ext4_fsblk_t pblk, unsigned int len, int ret),
1436
1437 TP_ARGS(inode, lblk, pblk, len, ret),
1438
1439 TP_STRUCT__entry(
1440 __field( ino_t, ino )
1441 __field( dev_t, dev )
1442 __field( ext4_lblk_t, lblk )
1443 __field( ext4_fsblk_t, pblk )
1444 __field( unsigned int, len )
1445 __field( int, ret )
1446 ),
1447
1448 TP_fast_assign(
1449 __entry->ino = inode->i_ino;
1450 __entry->dev = inode->i_sb->s_dev;
1451 __entry->lblk = lblk;
1452 __entry->pblk = pblk;
1453 __entry->len = len;
1454 __entry->ret = ret;
1455 ),
1456
1457 TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u ret %d",
1458 MAJOR(__entry->dev), MINOR(__entry->dev),
1459 (unsigned long) __entry->ino,
1460 __entry->lblk, __entry->pblk,
1461 __entry->len, __entry->ret)
1462);
1463
1464DEFINE_EVENT(ext4__map_blocks_exit, ext4_ext_map_blocks_exit,
1465 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1466 ext4_fsblk_t pblk, unsigned len, int ret),
1467
1468 TP_ARGS(inode, lblk, pblk, len, ret)
1469);
1470
1471DEFINE_EVENT(ext4__map_blocks_exit, ext4_ind_map_blocks_exit,
1472 TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
1473 ext4_fsblk_t pblk, unsigned len, int ret),
1474
1475 TP_ARGS(inode, lblk, pblk, len, ret)
1476);
1477
1478TRACE_EVENT(ext4_ext_load_extent,
1479 TP_PROTO(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk),
1480
1481 TP_ARGS(inode, lblk, pblk),
1482
1483 TP_STRUCT__entry(
1484 __field( ino_t, ino )
1485 __field( dev_t, dev )
1486 __field( ext4_lblk_t, lblk )
1487 __field( ext4_fsblk_t, pblk )
1488 ),
1489
1490 TP_fast_assign(
1491 __entry->ino = inode->i_ino;
1492 __entry->dev = inode->i_sb->s_dev;
1493 __entry->lblk = lblk;
1494 __entry->pblk = pblk;
1495 ),
1496
1497 TP_printk("dev %d,%d ino %lu lblk %u pblk %llu",
1498 MAJOR(__entry->dev), MINOR(__entry->dev),
1499 (unsigned long) __entry->ino,
1500 __entry->lblk, __entry->pblk)
1501);
1502
1503TRACE_EVENT(ext4_load_inode,
1504 TP_PROTO(struct inode *inode),
1505
1506 TP_ARGS(inode),
1507
1508 TP_STRUCT__entry(
1509 __field( ino_t, ino )
1510 __field( dev_t, dev )
1511 ),
1512
1513 TP_fast_assign(
1514 __entry->ino = inode->i_ino;
1515 __entry->dev = inode->i_sb->s_dev;
1516 ),
1517
1518 TP_printk("dev %d,%d ino %ld",
1519 MAJOR(__entry->dev), MINOR(__entry->dev),
1520 (unsigned long) __entry->ino)
1521);
1522
987#endif /* _TRACE_EXT4_H */ 1523#endif /* _TRACE_EXT4_H */
988 1524
989/* This part must be outside protection */ 1525/* This part must be outside protection */
diff --git a/include/trace/events/gfpflags.h b/include/trace/events/gfpflags.h
index e3615c093741..9fe3a36646e9 100644
--- a/include/trace/events/gfpflags.h
+++ b/include/trace/events/gfpflags.h
@@ -10,6 +10,7 @@
10 */ 10 */
11#define show_gfp_flags(flags) \ 11#define show_gfp_flags(flags) \
12 (flags) ? __print_flags(flags, "|", \ 12 (flags) ? __print_flags(flags, "|", \
13 {(unsigned long)GFP_TRANSHUGE, "GFP_TRANSHUGE"}, \
13 {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"}, \ 14 {(unsigned long)GFP_HIGHUSER_MOVABLE, "GFP_HIGHUSER_MOVABLE"}, \
14 {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \ 15 {(unsigned long)GFP_HIGHUSER, "GFP_HIGHUSER"}, \
15 {(unsigned long)GFP_USER, "GFP_USER"}, \ 16 {(unsigned long)GFP_USER, "GFP_USER"}, \
@@ -32,6 +33,9 @@
32 {(unsigned long)__GFP_HARDWALL, "GFP_HARDWALL"}, \ 33 {(unsigned long)__GFP_HARDWALL, "GFP_HARDWALL"}, \
33 {(unsigned long)__GFP_THISNODE, "GFP_THISNODE"}, \ 34 {(unsigned long)__GFP_THISNODE, "GFP_THISNODE"}, \
34 {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \ 35 {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \
35 {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"} \ 36 {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"}, \
37 {(unsigned long)__GFP_NOTRACK, "GFP_NOTRACK"}, \
38 {(unsigned long)__GFP_NO_KSWAPD, "GFP_NO_KSWAPD"}, \
39 {(unsigned long)__GFP_OTHER_NODE, "GFP_OTHER_NODE"} \
36 ) : "GFP_NOWAIT" 40 ) : "GFP_NOWAIT"
37 41
diff --git a/include/trace/events/gpio.h b/include/trace/events/gpio.h
new file mode 100644
index 000000000000..927a8ad9e51b
--- /dev/null
+++ b/include/trace/events/gpio.h
@@ -0,0 +1,56 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM gpio
3
4#if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_GPIO_H
6
7#include <linux/tracepoint.h>
8
9TRACE_EVENT(gpio_direction,
10
11 TP_PROTO(unsigned gpio, int in, int err),
12
13 TP_ARGS(gpio, in, err),
14
15 TP_STRUCT__entry(
16 __field(unsigned, gpio)
17 __field(int, in)
18 __field(int, err)
19 ),
20
21 TP_fast_assign(
22 __entry->gpio = gpio;
23 __entry->in = in;
24 __entry->err = err;
25 ),
26
27 TP_printk("%u %3s (%d)", __entry->gpio,
28 __entry->in ? "in" : "out", __entry->err)
29);
30
31TRACE_EVENT(gpio_value,
32
33 TP_PROTO(unsigned gpio, int get, int value),
34
35 TP_ARGS(gpio, get, value),
36
37 TP_STRUCT__entry(
38 __field(unsigned, gpio)
39 __field(int, get)
40 __field(int, value)
41 ),
42
43 TP_fast_assign(
44 __entry->gpio = gpio;
45 __entry->get = get;
46 __entry->value = value;
47 ),
48
49 TP_printk("%u %3s %d", __entry->gpio,
50 __entry->get ? "get" : "set", __entry->value)
51);
52
53#endif /* if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ) */
54
55/* This part must be outside protection */
56#include <trace/define_trace.h>
diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
index 0e4cfb694fe7..1c09820df585 100644
--- a/include/trace/events/irq.h
+++ b/include/trace/events/irq.h
@@ -5,7 +5,9 @@
5#define _TRACE_IRQ_H 5#define _TRACE_IRQ_H
6 6
7#include <linux/tracepoint.h> 7#include <linux/tracepoint.h>
8#include <linux/interrupt.h> 8
9struct irqaction;
10struct softirq_action;
9 11
10#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq } 12#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
11#define show_softirq_name(val) \ 13#define show_softirq_name(val) \
@@ -84,56 +86,62 @@ TRACE_EVENT(irq_handler_exit,
84 86
85DECLARE_EVENT_CLASS(softirq, 87DECLARE_EVENT_CLASS(softirq,
86 88
87 TP_PROTO(struct softirq_action *h, struct softirq_action *vec), 89 TP_PROTO(unsigned int vec_nr),
88 90
89 TP_ARGS(h, vec), 91 TP_ARGS(vec_nr),
90 92
91 TP_STRUCT__entry( 93 TP_STRUCT__entry(
92 __field( int, vec ) 94 __field( unsigned int, vec )
93 ), 95 ),
94 96
95 TP_fast_assign( 97 TP_fast_assign(
96 __entry->vec = (int)(h - vec); 98 __entry->vec = vec_nr;
97 ), 99 ),
98 100
99 TP_printk("vec=%d [action=%s]", __entry->vec, 101 TP_printk("vec=%u [action=%s]", __entry->vec,
100 show_softirq_name(__entry->vec)) 102 show_softirq_name(__entry->vec))
101); 103);
102 104
103/** 105/**
104 * softirq_entry - called immediately before the softirq handler 106 * softirq_entry - called immediately before the softirq handler
105 * @h: pointer to struct softirq_action 107 * @vec_nr: softirq vector number
106 * @vec: pointer to first struct softirq_action in softirq_vec array
107 * 108 *
108 * The @h parameter, contains a pointer to the struct softirq_action 109 * When used in combination with the softirq_exit tracepoint
109 * which has a pointer to the action handler that is called. By subtracting 110 * we can determine the softirq handler runtine.
110 * the @vec pointer from the @h pointer, we can determine the softirq
111 * number. Also, when used in combination with the softirq_exit tracepoint
112 * we can determine the softirq latency.
113 */ 111 */
114DEFINE_EVENT(softirq, softirq_entry, 112DEFINE_EVENT(softirq, softirq_entry,
115 113
116 TP_PROTO(struct softirq_action *h, struct softirq_action *vec), 114 TP_PROTO(unsigned int vec_nr),
117 115
118 TP_ARGS(h, vec) 116 TP_ARGS(vec_nr)
119); 117);
120 118
121/** 119/**
122 * softirq_exit - called immediately after the softirq handler returns 120 * softirq_exit - called immediately after the softirq handler returns
123 * @h: pointer to struct softirq_action 121 * @vec_nr: softirq vector number
124 * @vec: pointer to first struct softirq_action in softirq_vec array
125 * 122 *
126 * The @h parameter contains a pointer to the struct softirq_action 123 * When used in combination with the softirq_entry tracepoint
127 * that has handled the softirq. By subtracting the @vec pointer from 124 * we can determine the softirq handler runtine.
128 * the @h pointer, we can determine the softirq number. Also, when used in
129 * combination with the softirq_entry tracepoint we can determine the softirq
130 * latency.
131 */ 125 */
132DEFINE_EVENT(softirq, softirq_exit, 126DEFINE_EVENT(softirq, softirq_exit,
133 127
134 TP_PROTO(struct softirq_action *h, struct softirq_action *vec), 128 TP_PROTO(unsigned int vec_nr),
129
130 TP_ARGS(vec_nr)
131);
132
133/**
134 * softirq_raise - called immediately when a softirq is raised
135 * @vec_nr: softirq vector number
136 *
137 * When used in combination with the softirq_entry tracepoint
138 * we can determine the softirq raise to run latency.
139 */
140DEFINE_EVENT(softirq, softirq_raise,
141
142 TP_PROTO(unsigned int vec_nr),
135 143
136 TP_ARGS(h, vec) 144 TP_ARGS(vec_nr)
137); 145);
138 146
139#endif /* _TRACE_IRQ_H */ 147#endif /* _TRACE_IRQ_H */
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index 6dd3a51ab1cb..46e3cd8e197a 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -6,6 +6,36 @@
6#undef TRACE_SYSTEM 6#undef TRACE_SYSTEM
7#define TRACE_SYSTEM kvm 7#define TRACE_SYSTEM kvm
8 8
9#define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
10
11#define kvm_trace_exit_reason \
12 ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL), \
13 ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN), \
14 ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \
15 ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
16 ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI)
17
18TRACE_EVENT(kvm_userspace_exit,
19 TP_PROTO(__u32 reason, int errno),
20 TP_ARGS(reason, errno),
21
22 TP_STRUCT__entry(
23 __field( __u32, reason )
24 __field( int, errno )
25 ),
26
27 TP_fast_assign(
28 __entry->reason = reason;
29 __entry->errno = errno;
30 ),
31
32 TP_printk("reason %s (%d)",
33 __entry->errno < 0 ?
34 (__entry->errno == -EINTR ? "restart" : "error") :
35 __print_symbolic(__entry->reason, kvm_trace_exit_reason),
36 __entry->errno < 0 ? -__entry->errno : __entry->reason)
37);
38
9#if defined(__KVM_HAVE_IOAPIC) 39#if defined(__KVM_HAVE_IOAPIC)
10TRACE_EVENT(kvm_set_irq, 40TRACE_EVENT(kvm_set_irq,
11 TP_PROTO(unsigned int gsi, int level, int irq_source_id), 41 TP_PROTO(unsigned int gsi, int level, int irq_source_id),
@@ -185,6 +215,97 @@ TRACE_EVENT(kvm_age_page,
185 __entry->referenced ? "YOUNG" : "OLD") 215 __entry->referenced ? "YOUNG" : "OLD")
186); 216);
187 217
218#ifdef CONFIG_KVM_ASYNC_PF
219DECLARE_EVENT_CLASS(kvm_async_get_page_class,
220
221 TP_PROTO(u64 gva, u64 gfn),
222
223 TP_ARGS(gva, gfn),
224
225 TP_STRUCT__entry(
226 __field(__u64, gva)
227 __field(u64, gfn)
228 ),
229
230 TP_fast_assign(
231 __entry->gva = gva;
232 __entry->gfn = gfn;
233 ),
234
235 TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
236);
237
238DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page,
239
240 TP_PROTO(u64 gva, u64 gfn),
241
242 TP_ARGS(gva, gfn)
243);
244
245DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_doublefault,
246
247 TP_PROTO(u64 gva, u64 gfn),
248
249 TP_ARGS(gva, gfn)
250);
251
252DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready,
253
254 TP_PROTO(u64 token, u64 gva),
255
256 TP_ARGS(token, gva),
257
258 TP_STRUCT__entry(
259 __field(__u64, token)
260 __field(__u64, gva)
261 ),
262
263 TP_fast_assign(
264 __entry->token = token;
265 __entry->gva = gva;
266 ),
267
268 TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva)
269
270);
271
272DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present,
273
274 TP_PROTO(u64 token, u64 gva),
275
276 TP_ARGS(token, gva)
277);
278
279DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready,
280
281 TP_PROTO(u64 token, u64 gva),
282
283 TP_ARGS(token, gva)
284);
285
286TRACE_EVENT(
287 kvm_async_pf_completed,
288 TP_PROTO(unsigned long address, struct page *page, u64 gva),
289 TP_ARGS(address, page, gva),
290
291 TP_STRUCT__entry(
292 __field(unsigned long, address)
293 __field(pfn_t, pfn)
294 __field(u64, gva)
295 ),
296
297 TP_fast_assign(
298 __entry->address = address;
299 __entry->pfn = page ? page_to_pfn(page) : 0;
300 __entry->gva = gva;
301 ),
302
303 TP_printk("gva %#llx address %#lx pfn %#llx", __entry->gva,
304 __entry->address, __entry->pfn)
305);
306
307#endif
308
188#endif /* _TRACE_KVM_MAIN_H */ 309#endif /* _TRACE_KVM_MAIN_H */
189 310
190/* This part must be outside protection */ 311/* This part must be outside protection */
diff --git a/include/trace/events/mce.h b/include/trace/events/mce.h
index 7eee77895cb3..4cbbcef6baa8 100644
--- a/include/trace/events/mce.h
+++ b/include/trace/events/mce.h
@@ -17,36 +17,36 @@ TRACE_EVENT(mce_record,
17 TP_STRUCT__entry( 17 TP_STRUCT__entry(
18 __field( u64, mcgcap ) 18 __field( u64, mcgcap )
19 __field( u64, mcgstatus ) 19 __field( u64, mcgstatus )
20 __field( u8, bank )
21 __field( u64, status ) 20 __field( u64, status )
22 __field( u64, addr ) 21 __field( u64, addr )
23 __field( u64, misc ) 22 __field( u64, misc )
24 __field( u64, ip ) 23 __field( u64, ip )
25 __field( u8, cs )
26 __field( u64, tsc ) 24 __field( u64, tsc )
27 __field( u64, walltime ) 25 __field( u64, walltime )
28 __field( u32, cpu ) 26 __field( u32, cpu )
29 __field( u32, cpuid ) 27 __field( u32, cpuid )
30 __field( u32, apicid ) 28 __field( u32, apicid )
31 __field( u32, socketid ) 29 __field( u32, socketid )
30 __field( u8, cs )
31 __field( u8, bank )
32 __field( u8, cpuvendor ) 32 __field( u8, cpuvendor )
33 ), 33 ),
34 34
35 TP_fast_assign( 35 TP_fast_assign(
36 __entry->mcgcap = m->mcgcap; 36 __entry->mcgcap = m->mcgcap;
37 __entry->mcgstatus = m->mcgstatus; 37 __entry->mcgstatus = m->mcgstatus;
38 __entry->bank = m->bank;
39 __entry->status = m->status; 38 __entry->status = m->status;
40 __entry->addr = m->addr; 39 __entry->addr = m->addr;
41 __entry->misc = m->misc; 40 __entry->misc = m->misc;
42 __entry->ip = m->ip; 41 __entry->ip = m->ip;
43 __entry->cs = m->cs;
44 __entry->tsc = m->tsc; 42 __entry->tsc = m->tsc;
45 __entry->walltime = m->time; 43 __entry->walltime = m->time;
46 __entry->cpu = m->extcpu; 44 __entry->cpu = m->extcpu;
47 __entry->cpuid = m->cpuid; 45 __entry->cpuid = m->cpuid;
48 __entry->apicid = m->apicid; 46 __entry->apicid = m->apicid;
49 __entry->socketid = m->socketid; 47 __entry->socketid = m->socketid;
48 __entry->cs = m->cs;
49 __entry->bank = m->bank;
50 __entry->cpuvendor = m->cpuvendor; 50 __entry->cpuvendor = m->cpuvendor;
51 ), 51 ),
52 52
diff --git a/include/trace/events/module.h b/include/trace/events/module.h
index c7bb2f0482fe..21a546d27c0c 100644
--- a/include/trace/events/module.h
+++ b/include/trace/events/module.h
@@ -1,5 +1,15 @@
1/*
2 * Because linux/module.h has tracepoints in the header, and ftrace.h
3 * eventually includes this file, define_trace.h includes linux/module.h
4 * But we do not want the module.h to override the TRACE_SYSTEM macro
5 * variable that define_trace.h is processing, so we only set it
6 * when module events are being processed, which would happen when
7 * CREATE_TRACE_POINTS is defined.
8 */
9#ifdef CREATE_TRACE_POINTS
1#undef TRACE_SYSTEM 10#undef TRACE_SYSTEM
2#define TRACE_SYSTEM module 11#define TRACE_SYSTEM module
12#endif
3 13
4#if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) 14#if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_MODULE_H 15#define _TRACE_MODULE_H
@@ -98,14 +108,14 @@ TRACE_EVENT(module_request,
98 TP_ARGS(name, wait, ip), 108 TP_ARGS(name, wait, ip),
99 109
100 TP_STRUCT__entry( 110 TP_STRUCT__entry(
101 __field( bool, wait )
102 __field( unsigned long, ip ) 111 __field( unsigned long, ip )
112 __field( bool, wait )
103 __string( name, name ) 113 __string( name, name )
104 ), 114 ),
105 115
106 TP_fast_assign( 116 TP_fast_assign(
107 __entry->wait = wait;
108 __entry->ip = ip; 117 __entry->ip = ip;
118 __entry->wait = wait;
109 __assign_str(name, name); 119 __assign_str(name, name);
110 ), 120 ),
111 121
@@ -119,4 +129,3 @@ TRACE_EVENT(module_request,
119 129
120/* This part must be outside protection */ 130/* This part must be outside protection */
121#include <trace/define_trace.h> 131#include <trace/define_trace.h>
122
diff --git a/include/trace/events/napi.h b/include/trace/events/napi.h
index 188deca2f3c7..8fe1e93f531d 100644
--- a/include/trace/events/napi.h
+++ b/include/trace/events/napi.h
@@ -6,10 +6,31 @@
6 6
7#include <linux/netdevice.h> 7#include <linux/netdevice.h>
8#include <linux/tracepoint.h> 8#include <linux/tracepoint.h>
9#include <linux/ftrace.h>
10
11#define NO_DEV "(no_device)"
12
13TRACE_EVENT(napi_poll,
9 14
10DECLARE_TRACE(napi_poll,
11 TP_PROTO(struct napi_struct *napi), 15 TP_PROTO(struct napi_struct *napi),
12 TP_ARGS(napi)); 16
17 TP_ARGS(napi),
18
19 TP_STRUCT__entry(
20 __field( struct napi_struct *, napi)
21 __string( dev_name, napi->dev ? napi->dev->name : NO_DEV)
22 ),
23
24 TP_fast_assign(
25 __entry->napi = napi;
26 __assign_str(dev_name, napi->dev ? napi->dev->name : NO_DEV);
27 ),
28
29 TP_printk("napi poll on napi struct %p for device %s",
30 __entry->napi, __get_str(dev_name))
31);
32
33#undef NO_DEV
13 34
14#endif /* _TRACE_NAPI_H_ */ 35#endif /* _TRACE_NAPI_H_ */
15 36
diff --git a/include/trace/events/net.h b/include/trace/events/net.h
new file mode 100644
index 000000000000..f99645d05a8f
--- /dev/null
+++ b/include/trace/events/net.h
@@ -0,0 +1,84 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM net
3
4#if !defined(_TRACE_NET_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_NET_H
6
7#include <linux/skbuff.h>
8#include <linux/netdevice.h>
9#include <linux/ip.h>
10#include <linux/tracepoint.h>
11
12TRACE_EVENT(net_dev_xmit,
13
14 TP_PROTO(struct sk_buff *skb,
15 int rc,
16 struct net_device *dev,
17 unsigned int skb_len),
18
19 TP_ARGS(skb, rc, dev, skb_len),
20
21 TP_STRUCT__entry(
22 __field( void *, skbaddr )
23 __field( unsigned int, len )
24 __field( int, rc )
25 __string( name, dev->name )
26 ),
27
28 TP_fast_assign(
29 __entry->skbaddr = skb;
30 __entry->len = skb_len;
31 __entry->rc = rc;
32 __assign_str(name, dev->name);
33 ),
34
35 TP_printk("dev=%s skbaddr=%p len=%u rc=%d",
36 __get_str(name), __entry->skbaddr, __entry->len, __entry->rc)
37);
38
39DECLARE_EVENT_CLASS(net_dev_template,
40
41 TP_PROTO(struct sk_buff *skb),
42
43 TP_ARGS(skb),
44
45 TP_STRUCT__entry(
46 __field( void *, skbaddr )
47 __field( unsigned int, len )
48 __string( name, skb->dev->name )
49 ),
50
51 TP_fast_assign(
52 __entry->skbaddr = skb;
53 __entry->len = skb->len;
54 __assign_str(name, skb->dev->name);
55 ),
56
57 TP_printk("dev=%s skbaddr=%p len=%u",
58 __get_str(name), __entry->skbaddr, __entry->len)
59)
60
61DEFINE_EVENT(net_dev_template, net_dev_queue,
62
63 TP_PROTO(struct sk_buff *skb),
64
65 TP_ARGS(skb)
66);
67
68DEFINE_EVENT(net_dev_template, netif_receive_skb,
69
70 TP_PROTO(struct sk_buff *skb),
71
72 TP_ARGS(skb)
73);
74
75DEFINE_EVENT(net_dev_template, netif_rx,
76
77 TP_PROTO(struct sk_buff *skb),
78
79 TP_ARGS(skb)
80);
81#endif /* _TRACE_NET_H */
82
83/* This part must be outside protection */
84#include <trace/define_trace.h>
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 35a2a6e7bf1e..1bcc2a8c00e2 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -7,15 +7,71 @@
7#include <linux/ktime.h> 7#include <linux/ktime.h>
8#include <linux/tracepoint.h> 8#include <linux/tracepoint.h>
9 9
10#ifndef _TRACE_POWER_ENUM_ 10DECLARE_EVENT_CLASS(cpu,
11#define _TRACE_POWER_ENUM_ 11
12enum { 12 TP_PROTO(unsigned int state, unsigned int cpu_id),
13 POWER_NONE = 0, 13
14 POWER_CSTATE = 1, 14 TP_ARGS(state, cpu_id),
15 POWER_PSTATE = 2, 15
16}; 16 TP_STRUCT__entry(
17 __field( u32, state )
18 __field( u32, cpu_id )
19 ),
20
21 TP_fast_assign(
22 __entry->state = state;
23 __entry->cpu_id = cpu_id;
24 ),
25
26 TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
27 (unsigned long)__entry->cpu_id)
28);
29
30DEFINE_EVENT(cpu, cpu_idle,
31
32 TP_PROTO(unsigned int state, unsigned int cpu_id),
33
34 TP_ARGS(state, cpu_id)
35);
36
37/* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
38#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
39#define _PWR_EVENT_AVOID_DOUBLE_DEFINING
40
41#define PWR_EVENT_EXIT -1
17#endif 42#endif
18 43
44DEFINE_EVENT(cpu, cpu_frequency,
45
46 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
47
48 TP_ARGS(frequency, cpu_id)
49);
50
51TRACE_EVENT(machine_suspend,
52
53 TP_PROTO(unsigned int state),
54
55 TP_ARGS(state),
56
57 TP_STRUCT__entry(
58 __field( u32, state )
59 ),
60
61 TP_fast_assign(
62 __entry->state = state;
63 ),
64
65 TP_printk("state=%lu", (unsigned long)__entry->state)
66);
67
68/* This code will be removed after deprecation time exceeded (2.6.41) */
69#ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
70
71/*
72 * The power events are used for cpuidle & suspend (power_start, power_end)
73 * and for cpufreq (power_frequency)
74 */
19DECLARE_EVENT_CLASS(power, 75DECLARE_EVENT_CLASS(power,
20 76
21 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id), 77 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
@@ -70,6 +126,114 @@ TRACE_EVENT(power_end,
70 126
71); 127);
72 128
129/* Deprecated dummy functions must be protected against multi-declartion */
130#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
131#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
132
133enum {
134 POWER_NONE = 0,
135 POWER_CSTATE = 1,
136 POWER_PSTATE = 2,
137};
138#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
139
140#else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
141
142#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
143#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
144enum {
145 POWER_NONE = 0,
146 POWER_CSTATE = 1,
147 POWER_PSTATE = 2,
148};
149
150/* These dummy declaration have to be ripped out when the deprecated
151 events get removed */
152static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
153static inline void trace_power_end(u64 cpuid) {};
154static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
155#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
156
157#endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
158
159/*
160 * The clock events are used for clock enable/disable and for
161 * clock rate change
162 */
163DECLARE_EVENT_CLASS(clock,
164
165 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
166
167 TP_ARGS(name, state, cpu_id),
168
169 TP_STRUCT__entry(
170 __string( name, name )
171 __field( u64, state )
172 __field( u64, cpu_id )
173 ),
174
175 TP_fast_assign(
176 __assign_str(name, name);
177 __entry->state = state;
178 __entry->cpu_id = cpu_id;
179 ),
180
181 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
182 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
183);
184
185DEFINE_EVENT(clock, clock_enable,
186
187 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
188
189 TP_ARGS(name, state, cpu_id)
190);
191
192DEFINE_EVENT(clock, clock_disable,
193
194 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
195
196 TP_ARGS(name, state, cpu_id)
197);
198
199DEFINE_EVENT(clock, clock_set_rate,
200
201 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
202
203 TP_ARGS(name, state, cpu_id)
204);
205
206/*
207 * The power domain events are used for power domains transitions
208 */
209DECLARE_EVENT_CLASS(power_domain,
210
211 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
212
213 TP_ARGS(name, state, cpu_id),
214
215 TP_STRUCT__entry(
216 __string( name, name )
217 __field( u64, state )
218 __field( u64, cpu_id )
219 ),
220
221 TP_fast_assign(
222 __assign_str(name, name);
223 __entry->state = state;
224 __entry->cpu_id = cpu_id;
225),
226
227 TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
228 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
229);
230
231DEFINE_EVENT(power_domain, power_domain_target,
232
233 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
234
235 TP_ARGS(name, state, cpu_id)
236);
73#endif /* _TRACE_POWER_H */ 237#endif /* _TRACE_POWER_H */
74 238
75/* This part must be outside protection */ 239/* This part must be outside protection */
diff --git a/include/trace/events/regulator.h b/include/trace/events/regulator.h
new file mode 100644
index 000000000000..37502a7404b7
--- /dev/null
+++ b/include/trace/events/regulator.h
@@ -0,0 +1,141 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM regulator
3
4#if !defined(_TRACE_REGULATOR_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_REGULATOR_H
6
7#include <linux/ktime.h>
8#include <linux/tracepoint.h>
9
10/*
11 * Events which just log themselves and the regulator name for enable/disable
12 * type tracking.
13 */
14DECLARE_EVENT_CLASS(regulator_basic,
15
16 TP_PROTO(const char *name),
17
18 TP_ARGS(name),
19
20 TP_STRUCT__entry(
21 __string( name, name )
22 ),
23
24 TP_fast_assign(
25 __assign_str(name, name);
26 ),
27
28 TP_printk("name=%s", __get_str(name))
29
30);
31
32DEFINE_EVENT(regulator_basic, regulator_enable,
33
34 TP_PROTO(const char *name),
35
36 TP_ARGS(name)
37
38);
39
40DEFINE_EVENT(regulator_basic, regulator_enable_delay,
41
42 TP_PROTO(const char *name),
43
44 TP_ARGS(name)
45
46);
47
48DEFINE_EVENT(regulator_basic, regulator_enable_complete,
49
50 TP_PROTO(const char *name),
51
52 TP_ARGS(name)
53
54);
55
56DEFINE_EVENT(regulator_basic, regulator_disable,
57
58 TP_PROTO(const char *name),
59
60 TP_ARGS(name)
61
62);
63
64DEFINE_EVENT(regulator_basic, regulator_disable_complete,
65
66 TP_PROTO(const char *name),
67
68 TP_ARGS(name)
69
70);
71
72/*
73 * Events that take a range of numerical values, mostly for voltages
74 * and so on.
75 */
76DECLARE_EVENT_CLASS(regulator_range,
77
78 TP_PROTO(const char *name, int min, int max),
79
80 TP_ARGS(name, min, max),
81
82 TP_STRUCT__entry(
83 __string( name, name )
84 __field( int, min )
85 __field( int, max )
86 ),
87
88 TP_fast_assign(
89 __assign_str(name, name);
90 __entry->min = min;
91 __entry->max = max;
92 ),
93
94 TP_printk("name=%s (%d-%d)", __get_str(name),
95 (int)__entry->min, (int)__entry->max)
96);
97
98DEFINE_EVENT(regulator_range, regulator_set_voltage,
99
100 TP_PROTO(const char *name, int min, int max),
101
102 TP_ARGS(name, min, max)
103
104);
105
106
107/*
108 * Events that take a single value, mostly for readback and refcounts.
109 */
110DECLARE_EVENT_CLASS(regulator_value,
111
112 TP_PROTO(const char *name, unsigned int val),
113
114 TP_ARGS(name, val),
115
116 TP_STRUCT__entry(
117 __string( name, name )
118 __field( unsigned int, val )
119 ),
120
121 TP_fast_assign(
122 __assign_str(name, name);
123 __entry->val = val;
124 ),
125
126 TP_printk("name=%s, val=%u", __get_str(name),
127 (int)__entry->val)
128);
129
130DEFINE_EVENT(regulator_value, regulator_set_voltage_complete,
131
132 TP_PROTO(const char *name, unsigned int value),
133
134 TP_ARGS(name, value)
135
136);
137
138#endif /* _TRACE_POWER_H */
139
140/* This part must be outside protection */
141#include <trace/define_trace.h>
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 9208c92aeab5..f6334782a593 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -362,6 +362,35 @@ TRACE_EVENT(sched_stat_runtime,
362 (unsigned long long)__entry->vruntime) 362 (unsigned long long)__entry->vruntime)
363); 363);
364 364
365/*
366 * Tracepoint for showing priority inheritance modifying a tasks
367 * priority.
368 */
369TRACE_EVENT(sched_pi_setprio,
370
371 TP_PROTO(struct task_struct *tsk, int newprio),
372
373 TP_ARGS(tsk, newprio),
374
375 TP_STRUCT__entry(
376 __array( char, comm, TASK_COMM_LEN )
377 __field( pid_t, pid )
378 __field( int, oldprio )
379 __field( int, newprio )
380 ),
381
382 TP_fast_assign(
383 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
384 __entry->pid = tsk->pid;
385 __entry->oldprio = tsk->prio;
386 __entry->newprio = newprio;
387 ),
388
389 TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
390 __entry->comm, __entry->pid,
391 __entry->oldprio, __entry->newprio)
392);
393
365#endif /* _TRACE_SCHED_H */ 394#endif /* _TRACE_SCHED_H */
366 395
367/* This part must be outside protection */ 396/* This part must be outside protection */
diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index 25fbefdf2f2e..db6c93510f74 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -184,6 +184,17 @@
184 scsi_statusbyte_name(SAM_STAT_ACA_ACTIVE), \ 184 scsi_statusbyte_name(SAM_STAT_ACA_ACTIVE), \
185 scsi_statusbyte_name(SAM_STAT_TASK_ABORTED)) 185 scsi_statusbyte_name(SAM_STAT_TASK_ABORTED))
186 186
187#define scsi_prot_op_name(result) { result, #result }
188#define show_prot_op_name(val) \
189 __print_symbolic(val, \
190 scsi_prot_op_name(SCSI_PROT_NORMAL), \
191 scsi_prot_op_name(SCSI_PROT_READ_INSERT), \
192 scsi_prot_op_name(SCSI_PROT_WRITE_STRIP), \
193 scsi_prot_op_name(SCSI_PROT_READ_STRIP), \
194 scsi_prot_op_name(SCSI_PROT_WRITE_INSERT), \
195 scsi_prot_op_name(SCSI_PROT_READ_PASS), \
196 scsi_prot_op_name(SCSI_PROT_WRITE_PASS))
197
187const char *scsi_trace_parse_cdb(struct trace_seq*, unsigned char*, int); 198const char *scsi_trace_parse_cdb(struct trace_seq*, unsigned char*, int);
188#define __parse_cdb(cdb, len) scsi_trace_parse_cdb(p, cdb, len) 199#define __parse_cdb(cdb, len) scsi_trace_parse_cdb(p, cdb, len)
189 200
@@ -202,6 +213,7 @@ TRACE_EVENT(scsi_dispatch_cmd_start,
202 __field( unsigned int, cmd_len ) 213 __field( unsigned int, cmd_len )
203 __field( unsigned int, data_sglen ) 214 __field( unsigned int, data_sglen )
204 __field( unsigned int, prot_sglen ) 215 __field( unsigned int, prot_sglen )
216 __field( unsigned char, prot_op )
205 __dynamic_array(unsigned char, cmnd, cmd->cmd_len) 217 __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
206 ), 218 ),
207 219
@@ -214,13 +226,15 @@ TRACE_EVENT(scsi_dispatch_cmd_start,
214 __entry->cmd_len = cmd->cmd_len; 226 __entry->cmd_len = cmd->cmd_len;
215 __entry->data_sglen = scsi_sg_count(cmd); 227 __entry->data_sglen = scsi_sg_count(cmd);
216 __entry->prot_sglen = scsi_prot_sg_count(cmd); 228 __entry->prot_sglen = scsi_prot_sg_count(cmd);
229 __entry->prot_op = scsi_get_prot_op(cmd);
217 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); 230 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
218 ), 231 ),
219 232
220 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \ 233 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
221 " cmnd=(%s %s raw=%s)", 234 " prot_op=%s cmnd=(%s %s raw=%s)",
222 __entry->host_no, __entry->channel, __entry->id, 235 __entry->host_no, __entry->channel, __entry->id,
223 __entry->lun, __entry->data_sglen, __entry->prot_sglen, 236 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
237 show_prot_op_name(__entry->prot_op),
224 show_opcode_name(__entry->opcode), 238 show_opcode_name(__entry->opcode),
225 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), 239 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
226 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len)) 240 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len))
@@ -242,6 +256,7 @@ TRACE_EVENT(scsi_dispatch_cmd_error,
242 __field( unsigned int, cmd_len ) 256 __field( unsigned int, cmd_len )
243 __field( unsigned int, data_sglen ) 257 __field( unsigned int, data_sglen )
244 __field( unsigned int, prot_sglen ) 258 __field( unsigned int, prot_sglen )
259 __field( unsigned char, prot_op )
245 __dynamic_array(unsigned char, cmnd, cmd->cmd_len) 260 __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
246 ), 261 ),
247 262
@@ -255,13 +270,15 @@ TRACE_EVENT(scsi_dispatch_cmd_error,
255 __entry->cmd_len = cmd->cmd_len; 270 __entry->cmd_len = cmd->cmd_len;
256 __entry->data_sglen = scsi_sg_count(cmd); 271 __entry->data_sglen = scsi_sg_count(cmd);
257 __entry->prot_sglen = scsi_prot_sg_count(cmd); 272 __entry->prot_sglen = scsi_prot_sg_count(cmd);
273 __entry->prot_op = scsi_get_prot_op(cmd);
258 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); 274 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
259 ), 275 ),
260 276
261 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \ 277 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
262 " cmnd=(%s %s raw=%s) rtn=%d", 278 " prot_op=%s cmnd=(%s %s raw=%s) rtn=%d",
263 __entry->host_no, __entry->channel, __entry->id, 279 __entry->host_no, __entry->channel, __entry->id,
264 __entry->lun, __entry->data_sglen, __entry->prot_sglen, 280 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
281 show_prot_op_name(__entry->prot_op),
265 show_opcode_name(__entry->opcode), 282 show_opcode_name(__entry->opcode),
266 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), 283 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
267 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), 284 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
@@ -284,6 +301,7 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
284 __field( unsigned int, cmd_len ) 301 __field( unsigned int, cmd_len )
285 __field( unsigned int, data_sglen ) 302 __field( unsigned int, data_sglen )
286 __field( unsigned int, prot_sglen ) 303 __field( unsigned int, prot_sglen )
304 __field( unsigned char, prot_op )
287 __dynamic_array(unsigned char, cmnd, cmd->cmd_len) 305 __dynamic_array(unsigned char, cmnd, cmd->cmd_len)
288 ), 306 ),
289 307
@@ -297,14 +315,16 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
297 __entry->cmd_len = cmd->cmd_len; 315 __entry->cmd_len = cmd->cmd_len;
298 __entry->data_sglen = scsi_sg_count(cmd); 316 __entry->data_sglen = scsi_sg_count(cmd);
299 __entry->prot_sglen = scsi_prot_sg_count(cmd); 317 __entry->prot_sglen = scsi_prot_sg_count(cmd);
318 __entry->prot_op = scsi_get_prot_op(cmd);
300 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); 319 memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
301 ), 320 ),
302 321
303 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \ 322 TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \
304 "prot_sgl=%u cmnd=(%s %s raw=%s) result=(driver=%s host=%s " \ 323 "prot_sgl=%u prot_op=%s cmnd=(%s %s raw=%s) result=(driver=" \
305 "message=%s status=%s)", 324 "%s host=%s message=%s status=%s)",
306 __entry->host_no, __entry->channel, __entry->id, 325 __entry->host_no, __entry->channel, __entry->id,
307 __entry->lun, __entry->data_sglen, __entry->prot_sglen, 326 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
327 show_prot_op_name(__entry->prot_op),
308 show_opcode_name(__entry->opcode), 328 show_opcode_name(__entry->opcode),
309 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len), 329 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
310 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len), 330 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 4b2be6dc76f0..0c68ae22da22 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -19,22 +19,37 @@ TRACE_EVENT(kfree_skb,
19 19
20 TP_STRUCT__entry( 20 TP_STRUCT__entry(
21 __field( void *, skbaddr ) 21 __field( void *, skbaddr )
22 __field( unsigned short, protocol )
23 __field( void *, location ) 22 __field( void *, location )
23 __field( unsigned short, protocol )
24 ), 24 ),
25 25
26 TP_fast_assign( 26 TP_fast_assign(
27 __entry->skbaddr = skb; 27 __entry->skbaddr = skb;
28 if (skb) {
29 __entry->protocol = ntohs(skb->protocol);
30 }
31 __entry->location = location; 28 __entry->location = location;
29 __entry->protocol = ntohs(skb->protocol);
32 ), 30 ),
33 31
34 TP_printk("skbaddr=%p protocol=%u location=%p", 32 TP_printk("skbaddr=%p protocol=%u location=%p",
35 __entry->skbaddr, __entry->protocol, __entry->location) 33 __entry->skbaddr, __entry->protocol, __entry->location)
36); 34);
37 35
36TRACE_EVENT(consume_skb,
37
38 TP_PROTO(struct sk_buff *skb),
39
40 TP_ARGS(skb),
41
42 TP_STRUCT__entry(
43 __field( void *, skbaddr )
44 ),
45
46 TP_fast_assign(
47 __entry->skbaddr = skb;
48 ),
49
50 TP_printk("skbaddr=%p", __entry->skbaddr)
51);
52
38TRACE_EVENT(skb_copy_datagram_iovec, 53TRACE_EVENT(skb_copy_datagram_iovec,
39 54
40 TP_PROTO(const struct sk_buff *skb, int len), 55 TP_PROTO(const struct sk_buff *skb, int len),
diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
index fb726ac7caee..5a4c04a75b3d 100644
--- a/include/trace/events/syscalls.h
+++ b/include/trace/events/syscalls.h
@@ -40,6 +40,8 @@ TRACE_EVENT_FN(sys_enter,
40 syscall_regfunc, syscall_unregfunc 40 syscall_regfunc, syscall_unregfunc
41); 41);
42 42
43TRACE_EVENT_FLAGS(sys_enter, TRACE_EVENT_FL_CAP_ANY)
44
43TRACE_EVENT_FN(sys_exit, 45TRACE_EVENT_FN(sys_exit,
44 46
45 TP_PROTO(struct pt_regs *regs, long ret), 47 TP_PROTO(struct pt_regs *regs, long ret),
@@ -62,6 +64,8 @@ TRACE_EVENT_FN(sys_exit,
62 syscall_regfunc, syscall_unregfunc 64 syscall_regfunc, syscall_unregfunc
63); 65);
64 66
67TRACE_EVENT_FLAGS(sys_exit, TRACE_EVENT_FL_CAP_ANY)
68
65#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */ 69#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
66 70
67#endif /* _TRACE_EVENTS_SYSCALLS_H */ 71#endif /* _TRACE_EVENTS_SYSCALLS_H */
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index 370aa5a87322..b2c33bd955fa 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -6,10 +6,13 @@
6 6
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/tracepoint.h> 8#include <linux/tracepoint.h>
9#include <linux/mm.h>
10#include <linux/memcontrol.h>
9#include "gfpflags.h" 11#include "gfpflags.h"
10 12
11#define RECLAIM_WB_ANON 0x0001u 13#define RECLAIM_WB_ANON 0x0001u
12#define RECLAIM_WB_FILE 0x0002u 14#define RECLAIM_WB_FILE 0x0002u
15#define RECLAIM_WB_MIXED 0x0010u
13#define RECLAIM_WB_SYNC 0x0004u 16#define RECLAIM_WB_SYNC 0x0004u
14#define RECLAIM_WB_ASYNC 0x0008u 17#define RECLAIM_WB_ASYNC 0x0008u
15 18
@@ -17,13 +20,20 @@
17 (flags) ? __print_flags(flags, "|", \ 20 (flags) ? __print_flags(flags, "|", \
18 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \ 21 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
19 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \ 22 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
23 {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
20 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \ 24 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
21 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \ 25 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
22 ) : "RECLAIM_WB_NONE" 26 ) : "RECLAIM_WB_NONE"
23 27
24#define trace_reclaim_flags(page, sync) ( \ 28#define trace_reclaim_flags(page, sync) ( \
25 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \ 29 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
26 (sync == PAGEOUT_IO_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC) \ 30 (sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC) \
31 )
32
33#define trace_shrink_flags(file, sync) ( \
34 (sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_MIXED : \
35 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON)) | \
36 (sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC) \
27 ) 37 )
28 38
29TRACE_EVENT(mm_vmscan_kswapd_sleep, 39TRACE_EVENT(mm_vmscan_kswapd_sleep,
@@ -269,6 +279,121 @@ TRACE_EVENT(mm_vmscan_writepage,
269 show_reclaim_flags(__entry->reclaim_flags)) 279 show_reclaim_flags(__entry->reclaim_flags))
270); 280);
271 281
282TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
283
284 TP_PROTO(int nid, int zid,
285 unsigned long nr_scanned, unsigned long nr_reclaimed,
286 int priority, int reclaim_flags),
287
288 TP_ARGS(nid, zid, nr_scanned, nr_reclaimed, priority, reclaim_flags),
289
290 TP_STRUCT__entry(
291 __field(int, nid)
292 __field(int, zid)
293 __field(unsigned long, nr_scanned)
294 __field(unsigned long, nr_reclaimed)
295 __field(int, priority)
296 __field(int, reclaim_flags)
297 ),
298
299 TP_fast_assign(
300 __entry->nid = nid;
301 __entry->zid = zid;
302 __entry->nr_scanned = nr_scanned;
303 __entry->nr_reclaimed = nr_reclaimed;
304 __entry->priority = priority;
305 __entry->reclaim_flags = reclaim_flags;
306 ),
307
308 TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
309 __entry->nid, __entry->zid,
310 __entry->nr_scanned, __entry->nr_reclaimed,
311 __entry->priority,
312 show_reclaim_flags(__entry->reclaim_flags))
313);
314
315TRACE_EVENT(replace_swap_token,
316 TP_PROTO(struct mm_struct *old_mm,
317 struct mm_struct *new_mm),
318
319 TP_ARGS(old_mm, new_mm),
320
321 TP_STRUCT__entry(
322 __field(struct mm_struct*, old_mm)
323 __field(unsigned int, old_prio)
324 __field(struct mm_struct*, new_mm)
325 __field(unsigned int, new_prio)
326 ),
327
328 TP_fast_assign(
329 __entry->old_mm = old_mm;
330 __entry->old_prio = old_mm ? old_mm->token_priority : 0;
331 __entry->new_mm = new_mm;
332 __entry->new_prio = new_mm->token_priority;
333 ),
334
335 TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u",
336 __entry->old_mm, __entry->old_prio,
337 __entry->new_mm, __entry->new_prio)
338);
339
340DECLARE_EVENT_CLASS(put_swap_token_template,
341 TP_PROTO(struct mm_struct *swap_token_mm),
342
343 TP_ARGS(swap_token_mm),
344
345 TP_STRUCT__entry(
346 __field(struct mm_struct*, swap_token_mm)
347 ),
348
349 TP_fast_assign(
350 __entry->swap_token_mm = swap_token_mm;
351 ),
352
353 TP_printk("token_mm=%p", __entry->swap_token_mm)
354);
355
356DEFINE_EVENT(put_swap_token_template, put_swap_token,
357 TP_PROTO(struct mm_struct *swap_token_mm),
358 TP_ARGS(swap_token_mm)
359);
360
361DEFINE_EVENT_CONDITION(put_swap_token_template, disable_swap_token,
362 TP_PROTO(struct mm_struct *swap_token_mm),
363 TP_ARGS(swap_token_mm),
364 TP_CONDITION(swap_token_mm != NULL)
365);
366
367TRACE_EVENT_CONDITION(update_swap_token_priority,
368 TP_PROTO(struct mm_struct *mm,
369 unsigned int old_prio,
370 struct mm_struct *swap_token_mm),
371
372 TP_ARGS(mm, old_prio, swap_token_mm),
373
374 TP_CONDITION(mm->token_priority != old_prio),
375
376 TP_STRUCT__entry(
377 __field(struct mm_struct*, mm)
378 __field(unsigned int, old_prio)
379 __field(unsigned int, new_prio)
380 __field(struct mm_struct*, swap_token_mm)
381 __field(unsigned int, swap_token_prio)
382 ),
383
384 TP_fast_assign(
385 __entry->mm = mm;
386 __entry->old_prio = old_prio;
387 __entry->new_prio = mm->token_priority;
388 __entry->swap_token_mm = swap_token_mm;
389 __entry->swap_token_prio = swap_token_mm ? swap_token_mm->token_priority : 0;
390 ),
391
392 TP_printk("mm=%p old_prio=%u new_prio=%u swap_token_mm=%p token_prio=%u",
393 __entry->mm, __entry->old_prio, __entry->new_prio,
394 __entry->swap_token_mm, __entry->swap_token_prio)
395);
396
272#endif /* _TRACE_VMSCAN_H */ 397#endif /* _TRACE_VMSCAN_H */
273 398
274/* This part must be outside protection */ 399/* This part must be outside protection */
diff --git a/include/trace/events/workqueue.h b/include/trace/events/workqueue.h
index 49682d7e9d60..7d497291c85d 100644
--- a/include/trace/events/workqueue.h
+++ b/include/trace/events/workqueue.h
@@ -7,38 +7,83 @@
7#include <linux/tracepoint.h> 7#include <linux/tracepoint.h>
8#include <linux/workqueue.h> 8#include <linux/workqueue.h>
9 9
10DECLARE_EVENT_CLASS(workqueue_work,
11
12 TP_PROTO(struct work_struct *work),
13
14 TP_ARGS(work),
15
16 TP_STRUCT__entry(
17 __field( void *, work )
18 ),
19
20 TP_fast_assign(
21 __entry->work = work;
22 ),
23
24 TP_printk("work struct %p", __entry->work)
25);
26
10/** 27/**
11 * workqueue_execute_start - called immediately before the workqueue callback 28 * workqueue_queue_work - called when a work gets queued
29 * @req_cpu: the requested cpu
30 * @cwq: pointer to struct cpu_workqueue_struct
12 * @work: pointer to struct work_struct 31 * @work: pointer to struct work_struct
13 * 32 *
14 * Allows to track workqueue execution. 33 * This event occurs when a work is queued immediately or once a
34 * delayed work is actually queued on a workqueue (ie: once the delay
35 * has been reached).
15 */ 36 */
16TRACE_EVENT(workqueue_execute_start, 37TRACE_EVENT(workqueue_queue_work,
17 38
18 TP_PROTO(struct work_struct *work), 39 TP_PROTO(unsigned int req_cpu, struct cpu_workqueue_struct *cwq,
40 struct work_struct *work),
19 41
20 TP_ARGS(work), 42 TP_ARGS(req_cpu, cwq, work),
21 43
22 TP_STRUCT__entry( 44 TP_STRUCT__entry(
23 __field( void *, work ) 45 __field( void *, work )
24 __field( void *, function) 46 __field( void *, function)
47 __field( void *, workqueue)
48 __field( unsigned int, req_cpu )
49 __field( unsigned int, cpu )
25 ), 50 ),
26 51
27 TP_fast_assign( 52 TP_fast_assign(
28 __entry->work = work; 53 __entry->work = work;
29 __entry->function = work->func; 54 __entry->function = work->func;
55 __entry->workqueue = cwq->wq;
56 __entry->req_cpu = req_cpu;
57 __entry->cpu = cwq->gcwq->cpu;
30 ), 58 ),
31 59
32 TP_printk("work struct %p: function %pf", __entry->work, __entry->function) 60 TP_printk("work struct=%p function=%pf workqueue=%p req_cpu=%u cpu=%u",
61 __entry->work, __entry->function, __entry->workqueue,
62 __entry->req_cpu, __entry->cpu)
33); 63);
34 64
35/** 65/**
36 * workqueue_execute_end - called immediately before the workqueue callback 66 * workqueue_activate_work - called when a work gets activated
67 * @work: pointer to struct work_struct
68 *
69 * This event occurs when a queued work is put on the active queue,
70 * which happens immediately after queueing unless @max_active limit
71 * is reached.
72 */
73DEFINE_EVENT(workqueue_work, workqueue_activate_work,
74
75 TP_PROTO(struct work_struct *work),
76
77 TP_ARGS(work)
78);
79
80/**
81 * workqueue_execute_start - called immediately before the workqueue callback
37 * @work: pointer to struct work_struct 82 * @work: pointer to struct work_struct
38 * 83 *
39 * Allows to track workqueue execution. 84 * Allows to track workqueue execution.
40 */ 85 */
41TRACE_EVENT(workqueue_execute_end, 86TRACE_EVENT(workqueue_execute_start,
42 87
43 TP_PROTO(struct work_struct *work), 88 TP_PROTO(struct work_struct *work),
44 89
@@ -46,15 +91,29 @@ TRACE_EVENT(workqueue_execute_end,
46 91
47 TP_STRUCT__entry( 92 TP_STRUCT__entry(
48 __field( void *, work ) 93 __field( void *, work )
94 __field( void *, function)
49 ), 95 ),
50 96
51 TP_fast_assign( 97 TP_fast_assign(
52 __entry->work = work; 98 __entry->work = work;
99 __entry->function = work->func;
53 ), 100 ),
54 101
55 TP_printk("work struct %p", __entry->work) 102 TP_printk("work struct %p: function %pf", __entry->work, __entry->function)
56); 103);
57 104
105/**
106 * workqueue_execute_end - called immediately before the workqueue callback
107 * @work: pointer to struct work_struct
108 *
109 * Allows to track workqueue execution.
110 */
111DEFINE_EVENT(workqueue_work, workqueue_execute_end,
112
113 TP_PROTO(struct work_struct *work),
114
115 TP_ARGS(work)
116);
58 117
59#endif /* _TRACE_WORKQUEUE_H */ 118#endif /* _TRACE_WORKQUEUE_H */
60 119
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index f345f66ae9d1..4e249b927eaa 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -81,6 +81,7 @@ DEFINE_EVENT(writeback_class, name, \
81 TP_ARGS(bdi)) 81 TP_ARGS(bdi))
82 82
83DEFINE_WRITEBACK_EVENT(writeback_nowork); 83DEFINE_WRITEBACK_EVENT(writeback_nowork);
84DEFINE_WRITEBACK_EVENT(writeback_wake_background);
84DEFINE_WRITEBACK_EVENT(writeback_wake_thread); 85DEFINE_WRITEBACK_EVENT(writeback_wake_thread);
85DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread); 86DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread);
86DEFINE_WRITEBACK_EVENT(writeback_bdi_register); 87DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
@@ -96,8 +97,6 @@ DECLARE_EVENT_CLASS(wbc_class,
96 __field(long, nr_to_write) 97 __field(long, nr_to_write)
97 __field(long, pages_skipped) 98 __field(long, pages_skipped)
98 __field(int, sync_mode) 99 __field(int, sync_mode)
99 __field(int, nonblocking)
100 __field(int, encountered_congestion)
101 __field(int, for_kupdate) 100 __field(int, for_kupdate)
102 __field(int, for_background) 101 __field(int, for_background)
103 __field(int, for_reclaim) 102 __field(int, for_reclaim)
@@ -153,6 +152,41 @@ DEFINE_WBC_EVENT(wbc_balance_dirty_written);
153DEFINE_WBC_EVENT(wbc_balance_dirty_wait); 152DEFINE_WBC_EVENT(wbc_balance_dirty_wait);
154DEFINE_WBC_EVENT(wbc_writepage); 153DEFINE_WBC_EVENT(wbc_writepage);
155 154
155DECLARE_EVENT_CLASS(writeback_congest_waited_template,
156
157 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
158
159 TP_ARGS(usec_timeout, usec_delayed),
160
161 TP_STRUCT__entry(
162 __field( unsigned int, usec_timeout )
163 __field( unsigned int, usec_delayed )
164 ),
165
166 TP_fast_assign(
167 __entry->usec_timeout = usec_timeout;
168 __entry->usec_delayed = usec_delayed;
169 ),
170
171 TP_printk("usec_timeout=%u usec_delayed=%u",
172 __entry->usec_timeout,
173 __entry->usec_delayed)
174);
175
176DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
177
178 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
179
180 TP_ARGS(usec_timeout, usec_delayed)
181);
182
183DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
184
185 TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
186
187 TP_ARGS(usec_timeout, usec_delayed)
188);
189
156#endif /* _TRACE_WRITEBACK_H */ 190#endif /* _TRACE_WRITEBACK_H */
157 191
158/* This part must be outside protection */ 192/* This part must be outside protection */
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index a9377c0083ad..533c49f48047 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -82,6 +82,10 @@
82 TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \ 82 TRACE_EVENT(name, PARAMS(proto), PARAMS(args), \
83 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \ 83 PARAMS(tstruct), PARAMS(assign), PARAMS(print)) \
84 84
85#undef TRACE_EVENT_FLAGS
86#define TRACE_EVENT_FLAGS(name, value) \
87 __TRACE_EVENT_FLAGS(name, value)
88
85#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 89#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
86 90
87 91
@@ -129,6 +133,9 @@
129#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ 133#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
130 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) 134 DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
131 135
136#undef TRACE_EVENT_FLAGS
137#define TRACE_EVENT_FLAGS(event, flag)
138
132#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 139#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
133 140
134/* 141/*
@@ -198,6 +205,19 @@
198 ftrace_print_symbols_seq(p, value, symbols); \ 205 ftrace_print_symbols_seq(p, value, symbols); \
199 }) 206 })
200 207
208#undef __print_symbolic_u64
209#if BITS_PER_LONG == 32
210#define __print_symbolic_u64(value, symbol_array...) \
211 ({ \
212 static const struct trace_print_flags_u64 symbols[] = \
213 { symbol_array, { -1, NULL } }; \
214 ftrace_print_symbols_seq_u64(p, value, symbols); \
215 })
216#else
217#define __print_symbolic_u64(value, symbol_array...) \
218 __print_symbolic(value, symbol_array)
219#endif
220
201#undef __print_hex 221#undef __print_hex
202#define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len) 222#define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len)
203 223
@@ -289,13 +309,19 @@ static struct trace_event_functions ftrace_event_type_funcs_##call = { \
289 309
290#undef __array 310#undef __array
291#define __array(type, item, len) \ 311#define __array(type, item, len) \
292 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ 312 do { \
293 ret = trace_define_field(event_call, #type "[" #len "]", #item, \ 313 mutex_lock(&event_storage_mutex); \
314 BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \
315 snprintf(event_storage, sizeof(event_storage), \
316 "%s[%d]", #type, len); \
317 ret = trace_define_field(event_call, event_storage, #item, \
294 offsetof(typeof(field), item), \ 318 offsetof(typeof(field), item), \
295 sizeof(field.item), \ 319 sizeof(field.item), \
296 is_signed_type(type), FILTER_OTHER); \ 320 is_signed_type(type), FILTER_OTHER); \
297 if (ret) \ 321 mutex_unlock(&event_storage_mutex); \
298 return ret; 322 if (ret) \
323 return ret; \
324 } while (0);
299 325
300#undef __dynamic_array 326#undef __dynamic_array
301#define __dynamic_array(type, item, len) \ 327#define __dynamic_array(type, item, len) \
@@ -433,14 +459,16 @@ static inline notrace int ftrace_get_offsets_##call( \
433 * .reg = ftrace_event_reg, 459 * .reg = ftrace_event_reg,
434 * }; 460 * };
435 * 461 *
436 * static struct ftrace_event_call __used 462 * static struct ftrace_event_call event_<call> = {
437 * __attribute__((__aligned__(4)))
438 * __attribute__((section("_ftrace_events"))) event_<call> = {
439 * .name = "<call>", 463 * .name = "<call>",
440 * .class = event_class_<template>, 464 * .class = event_class_<template>,
441 * .event = &ftrace_event_type_<call>, 465 * .event = &ftrace_event_type_<call>,
442 * .print_fmt = print_fmt_<call>, 466 * .print_fmt = print_fmt_<call>,
443 * }; 467 * };
468 * // its only safe to use pointers when doing linker tricks to
469 * // create an array.
470 * static struct ftrace_event_call __used
471 * __attribute__((section("_ftrace_events"))) *__event_<call> = &event_<call>;
444 * 472 *
445 */ 473 */
446 474
@@ -566,28 +594,28 @@ static struct ftrace_event_class __used event_class_##call = { \
566#undef DEFINE_EVENT 594#undef DEFINE_EVENT
567#define DEFINE_EVENT(template, call, proto, args) \ 595#define DEFINE_EVENT(template, call, proto, args) \
568 \ 596 \
569static struct ftrace_event_call __used \ 597static struct ftrace_event_call __used event_##call = { \
570__attribute__((__aligned__(4))) \
571__attribute__((section("_ftrace_events"))) event_##call = { \
572 .name = #call, \ 598 .name = #call, \
573 .class = &event_class_##template, \ 599 .class = &event_class_##template, \
574 .event.funcs = &ftrace_event_type_funcs_##template, \ 600 .event.funcs = &ftrace_event_type_funcs_##template, \
575 .print_fmt = print_fmt_##template, \ 601 .print_fmt = print_fmt_##template, \
576}; 602}; \
603static struct ftrace_event_call __used \
604__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
577 605
578#undef DEFINE_EVENT_PRINT 606#undef DEFINE_EVENT_PRINT
579#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ 607#define DEFINE_EVENT_PRINT(template, call, proto, args, print) \
580 \ 608 \
581static const char print_fmt_##call[] = print; \ 609static const char print_fmt_##call[] = print; \
582 \ 610 \
583static struct ftrace_event_call __used \ 611static struct ftrace_event_call __used event_##call = { \
584__attribute__((__aligned__(4))) \
585__attribute__((section("_ftrace_events"))) event_##call = { \
586 .name = #call, \ 612 .name = #call, \
587 .class = &event_class_##template, \ 613 .class = &event_class_##template, \
588 .event.funcs = &ftrace_event_type_funcs_##call, \ 614 .event.funcs = &ftrace_event_type_funcs_##call, \
589 .print_fmt = print_fmt_##call, \ 615 .print_fmt = print_fmt_##call, \
590} 616}; \
617static struct ftrace_event_call __used \
618__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
591 619
592#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 620#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
593 621
diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
index 0c864db1a466..28447f1594fa 100644
--- a/include/video/atmel_lcdc.h
+++ b/include/video/atmel_lcdc.h
@@ -52,6 +52,7 @@ struct atmel_lcdfb_info {
52 u8 bl_power; 52 u8 bl_power;
53#endif 53#endif
54 bool lcdcon_is_backlight; 54 bool lcdcon_is_backlight;
55 bool lcdcon_pol_negative;
55 u8 saved_lcdcon; 56 u8 saved_lcdcon;
56 57
57 u8 default_bpp; 58 u8 default_bpp;
diff --git a/include/video/da8xx-fb.h b/include/video/da8xx-fb.h
index 6316cdabf73f..89d43b3d4cb9 100644
--- a/include/video/da8xx-fb.h
+++ b/include/video/da8xx-fb.h
@@ -99,7 +99,6 @@ struct lcd_sync_arg {
99#define FBIPUT_COLOR _IOW('F', 6, int) 99#define FBIPUT_COLOR _IOW('F', 6, int)
100#define FBIPUT_HSYNC _IOW('F', 9, int) 100#define FBIPUT_HSYNC _IOW('F', 9, int)
101#define FBIPUT_VSYNC _IOW('F', 10, int) 101#define FBIPUT_VSYNC _IOW('F', 10, int)
102#define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t)
103 102
104#endif /* ifndef DA8XX_FB_H */ 103#endif /* ifndef DA8XX_FB_H */
105 104
diff --git a/include/video/kyro.h b/include/video/kyro.h
index dba7de2ee4a8..c563968e926c 100644
--- a/include/video/kyro.h
+++ b/include/video/kyro.h
@@ -32,7 +32,7 @@ struct kyrofb_info {
32 u32 PIXCLK; /* Pixel Clock */ 32 u32 PIXCLK; /* Pixel Clock */
33 u32 HCLK; /* Hor Clock */ 33 u32 HCLK; /* Hor Clock */
34 34
35 /* Usefull to hold depth here for Linux */ 35 /* Useful to hold depth here for Linux */
36 u8 PIXDEPTH; 36 u8 PIXDEPTH;
37 37
38#ifdef CONFIG_MTRR 38#ifdef CONFIG_MTRR
diff --git a/include/video/neomagic.h b/include/video/neomagic.h
index 08b663782956..bc5013e8059d 100644
--- a/include/video/neomagic.h
+++ b/include/video/neomagic.h
@@ -129,7 +129,7 @@ struct neofb_par {
129 unsigned char CRTC[25]; /* Crtc Controller */ 129 unsigned char CRTC[25]; /* Crtc Controller */
130 unsigned char Sequencer[5]; /* Video Sequencer */ 130 unsigned char Sequencer[5]; /* Video Sequencer */
131 unsigned char Graphics[9]; /* Video Graphics */ 131 unsigned char Graphics[9]; /* Video Graphics */
132 unsigned char Attribute[21]; /* Video Atribute */ 132 unsigned char Attribute[21]; /* Video Attribute */
133 133
134 unsigned char GeneralLockReg; 134 unsigned char GeneralLockReg;
135 unsigned char ExtCRTDispAddr; 135 unsigned char ExtCRTDispAddr;
diff --git a/include/video/newport.h b/include/video/newport.h
index 001b935e71c4..de980a3b60c9 100644
--- a/include/video/newport.h
+++ b/include/video/newport.h
@@ -3,9 +3,9 @@
3 * newport.h: Defines and register layout for NEWPORT graphics 3 * newport.h: Defines and register layout for NEWPORT graphics
4 * hardware. 4 * hardware.
5 * 5 *
6 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) 6 * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
7 * 7 *
8 * Ulf Carlsson - Compability with the IRIX structures added 8 * Ulf Carlsson - Compatibility with the IRIX structures added
9 */ 9 */
10 10
11#ifndef _SGI_NEWPORT_H 11#ifndef _SGI_NEWPORT_H
diff --git a/include/video/omap-panel-generic-dpi.h b/include/video/omap-panel-generic-dpi.h
new file mode 100644
index 000000000000..127e3f20328e
--- /dev/null
+++ b/include/video/omap-panel-generic-dpi.h
@@ -0,0 +1,37 @@
1/*
2 * Header for generic DPI panel driver
3 *
4 * Copyright (C) 2010 Canonical Ltd.
5 * Author: Bryan Wu <bryan.wu@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __OMAP_PANEL_GENERIC_DPI_H
21#define __OMAP_PANEL_GENERIC_DPI_H
22
23struct omap_dss_device;
24
25/**
26 * struct panel_generic_dpi_data - panel driver configuration data
27 * @name: panel name
28 * @platform_enable: platform specific panel enable function
29 * @platform_disable: platform specific panel disable function
30 */
31struct panel_generic_dpi_data {
32 const char *name;
33 int (*platform_enable)(struct omap_dss_device *dssdev);
34 void (*platform_disable)(struct omap_dss_device *dssdev);
35};
36
37#endif /* __OMAP_PANEL_GENERIC_DPI_H */
diff --git a/include/video/omap-panel-nokia-dsi.h b/include/video/omap-panel-nokia-dsi.h
new file mode 100644
index 000000000000..921ae9327228
--- /dev/null
+++ b/include/video/omap-panel-nokia-dsi.h
@@ -0,0 +1,33 @@
1#ifndef __OMAP_NOKIA_DSI_PANEL_H
2#define __OMAP_NOKIA_DSI_PANEL_H
3
4struct omap_dss_device;
5
6/**
7 * struct nokia_dsi_panel_data - Nokia DSI panel driver configuration
8 * @name: panel name
9 * @use_ext_te: use external TE
10 * @ext_te_gpio: external TE GPIO
11 * @esd_interval: interval of ESD checks, 0 = disabled (ms)
12 * @ulps_timeout: time to wait before entering ULPS, 0 = disabled (ms)
13 * @max_backlight_level: maximum backlight level
14 * @set_backlight: pointer to backlight set function
15 * @get_backlight: pointer to backlight get function
16 */
17struct nokia_dsi_panel_data {
18 const char *name;
19
20 int reset_gpio;
21
22 bool use_ext_te;
23 int ext_te_gpio;
24
25 unsigned esd_interval;
26 unsigned ulps_timeout;
27
28 int max_backlight_level;
29 int (*set_backlight)(struct omap_dss_device *dssdev, int level);
30 int (*get_backlight)(struct omap_dss_device *dssdev);
31};
32
33#endif /* __OMAP_NOKIA_DSI_PANEL_H */
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
new file mode 100644
index 000000000000..892b97f8e157
--- /dev/null
+++ b/include/video/omapdss.h
@@ -0,0 +1,641 @@
1/*
2 * Copyright (C) 2008 Nokia Corporation
3 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __OMAP_OMAPDSS_H
19#define __OMAP_OMAPDSS_H
20
21#include <linux/list.h>
22#include <linux/kobject.h>
23#include <linux/device.h>
24#include <linux/platform_device.h>
25#include <asm/atomic.h>
26
27#define DISPC_IRQ_FRAMEDONE (1 << 0)
28#define DISPC_IRQ_VSYNC (1 << 1)
29#define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
30#define DISPC_IRQ_EVSYNC_ODD (1 << 3)
31#define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
32#define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
33#define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
34#define DISPC_IRQ_GFX_END_WIN (1 << 7)
35#define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
36#define DISPC_IRQ_OCP_ERR (1 << 9)
37#define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
38#define DISPC_IRQ_VID1_END_WIN (1 << 11)
39#define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
40#define DISPC_IRQ_VID2_END_WIN (1 << 13)
41#define DISPC_IRQ_SYNC_LOST (1 << 14)
42#define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
43#define DISPC_IRQ_WAKEUP (1 << 16)
44#define DISPC_IRQ_SYNC_LOST2 (1 << 17)
45#define DISPC_IRQ_VSYNC2 (1 << 18)
46#define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21)
47#define DISPC_IRQ_FRAMEDONE2 (1 << 22)
48
49struct omap_dss_device;
50struct omap_overlay_manager;
51
52enum omap_display_type {
53 OMAP_DISPLAY_TYPE_NONE = 0,
54 OMAP_DISPLAY_TYPE_DPI = 1 << 0,
55 OMAP_DISPLAY_TYPE_DBI = 1 << 1,
56 OMAP_DISPLAY_TYPE_SDI = 1 << 2,
57 OMAP_DISPLAY_TYPE_DSI = 1 << 3,
58 OMAP_DISPLAY_TYPE_VENC = 1 << 4,
59 OMAP_DISPLAY_TYPE_HDMI = 1 << 5,
60};
61
62enum omap_plane {
63 OMAP_DSS_GFX = 0,
64 OMAP_DSS_VIDEO1 = 1,
65 OMAP_DSS_VIDEO2 = 2
66};
67
68enum omap_channel {
69 OMAP_DSS_CHANNEL_LCD = 0,
70 OMAP_DSS_CHANNEL_DIGIT = 1,
71 OMAP_DSS_CHANNEL_LCD2 = 2,
72};
73
74enum omap_color_mode {
75 OMAP_DSS_COLOR_CLUT1 = 1 << 0, /* BITMAP 1 */
76 OMAP_DSS_COLOR_CLUT2 = 1 << 1, /* BITMAP 2 */
77 OMAP_DSS_COLOR_CLUT4 = 1 << 2, /* BITMAP 4 */
78 OMAP_DSS_COLOR_CLUT8 = 1 << 3, /* BITMAP 8 */
79 OMAP_DSS_COLOR_RGB12U = 1 << 4, /* RGB12, 16-bit container */
80 OMAP_DSS_COLOR_ARGB16 = 1 << 5, /* ARGB16 */
81 OMAP_DSS_COLOR_RGB16 = 1 << 6, /* RGB16 */
82 OMAP_DSS_COLOR_RGB24U = 1 << 7, /* RGB24, 32-bit container */
83 OMAP_DSS_COLOR_RGB24P = 1 << 8, /* RGB24, 24-bit container */
84 OMAP_DSS_COLOR_YUV2 = 1 << 9, /* YUV2 4:2:2 co-sited */
85 OMAP_DSS_COLOR_UYVY = 1 << 10, /* UYVY 4:2:2 co-sited */
86 OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */
87 OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */
88 OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */
89 OMAP_DSS_COLOR_NV12 = 1 << 14, /* NV12 format: YUV 4:2:0 */
90 OMAP_DSS_COLOR_RGBA16 = 1 << 15, /* RGBA16 - 4444 */
91 OMAP_DSS_COLOR_RGBX16 = 1 << 16, /* RGBx16 - 4444 */
92 OMAP_DSS_COLOR_ARGB16_1555 = 1 << 17, /* ARGB16 - 1555 */
93 OMAP_DSS_COLOR_XRGB16_1555 = 1 << 18, /* xRGB16 - 1555 */
94};
95
96enum omap_lcd_display_type {
97 OMAP_DSS_LCD_DISPLAY_STN,
98 OMAP_DSS_LCD_DISPLAY_TFT,
99};
100
101enum omap_dss_load_mode {
102 OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
103 OMAP_DSS_LOAD_CLUT_ONLY = 1,
104 OMAP_DSS_LOAD_FRAME_ONLY = 2,
105 OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
106};
107
108enum omap_dss_trans_key_type {
109 OMAP_DSS_COLOR_KEY_GFX_DST = 0,
110 OMAP_DSS_COLOR_KEY_VID_SRC = 1,
111};
112
113enum omap_rfbi_te_mode {
114 OMAP_DSS_RFBI_TE_MODE_1 = 1,
115 OMAP_DSS_RFBI_TE_MODE_2 = 2,
116};
117
118enum omap_panel_config {
119 OMAP_DSS_LCD_IVS = 1<<0,
120 OMAP_DSS_LCD_IHS = 1<<1,
121 OMAP_DSS_LCD_IPC = 1<<2,
122 OMAP_DSS_LCD_IEO = 1<<3,
123 OMAP_DSS_LCD_RF = 1<<4,
124 OMAP_DSS_LCD_ONOFF = 1<<5,
125
126 OMAP_DSS_LCD_TFT = 1<<20,
127};
128
129enum omap_dss_venc_type {
130 OMAP_DSS_VENC_TYPE_COMPOSITE,
131 OMAP_DSS_VENC_TYPE_SVIDEO,
132};
133
134enum omap_display_caps {
135 OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE = 1 << 0,
136 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM = 1 << 1,
137};
138
139enum omap_dss_update_mode {
140 OMAP_DSS_UPDATE_DISABLED = 0,
141 OMAP_DSS_UPDATE_AUTO,
142 OMAP_DSS_UPDATE_MANUAL,
143};
144
145enum omap_dss_display_state {
146 OMAP_DSS_DISPLAY_DISABLED = 0,
147 OMAP_DSS_DISPLAY_ACTIVE,
148 OMAP_DSS_DISPLAY_SUSPENDED,
149};
150
151/* XXX perhaps this should be removed */
152enum omap_dss_overlay_managers {
153 OMAP_DSS_OVL_MGR_LCD,
154 OMAP_DSS_OVL_MGR_TV,
155 OMAP_DSS_OVL_MGR_LCD2,
156};
157
158enum omap_dss_rotation_type {
159 OMAP_DSS_ROT_DMA = 0,
160 OMAP_DSS_ROT_VRFB = 1,
161};
162
163/* clockwise rotation angle */
164enum omap_dss_rotation_angle {
165 OMAP_DSS_ROT_0 = 0,
166 OMAP_DSS_ROT_90 = 1,
167 OMAP_DSS_ROT_180 = 2,
168 OMAP_DSS_ROT_270 = 3,
169};
170
171enum omap_overlay_caps {
172 OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
173 OMAP_DSS_OVL_CAP_DISPC = 1 << 1,
174};
175
176enum omap_overlay_manager_caps {
177 OMAP_DSS_OVL_MGR_CAP_DISPC = 1 << 0,
178};
179
180enum omap_dss_clk_source {
181 OMAP_DSS_CLK_SRC_FCK = 0, /* OMAP2/3: DSS1_ALWON_FCLK
182 * OMAP4: DSS_FCLK */
183 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, /* OMAP3: DSI1_PLL_FCLK
184 * OMAP4: PLL1_CLK1 */
185 OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, /* OMAP3: DSI2_PLL_FCLK
186 * OMAP4: PLL1_CLK2 */
187 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC, /* OMAP4: PLL2_CLK1 */
188 OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI, /* OMAP4: PLL2_CLK2 */
189};
190
191/* RFBI */
192
193struct rfbi_timings {
194 int cs_on_time;
195 int cs_off_time;
196 int we_on_time;
197 int we_off_time;
198 int re_on_time;
199 int re_off_time;
200 int we_cycle_time;
201 int re_cycle_time;
202 int cs_pulse_width;
203 int access_time;
204
205 int clk_div;
206
207 u32 tim[5]; /* set by rfbi_convert_timings() */
208
209 int converted;
210};
211
212void omap_rfbi_write_command(const void *buf, u32 len);
213void omap_rfbi_read_data(void *buf, u32 len);
214void omap_rfbi_write_data(const void *buf, u32 len);
215void omap_rfbi_write_pixels(const void __iomem *buf, int scr_width,
216 u16 x, u16 y,
217 u16 w, u16 h);
218int omap_rfbi_enable_te(bool enable, unsigned line);
219int omap_rfbi_setup_te(enum omap_rfbi_te_mode mode,
220 unsigned hs_pulse_time, unsigned vs_pulse_time,
221 int hs_pol_inv, int vs_pol_inv, int extif_div);
222void rfbi_bus_lock(void);
223void rfbi_bus_unlock(void);
224
225/* DSI */
226void dsi_bus_lock(struct omap_dss_device *dssdev);
227void dsi_bus_unlock(struct omap_dss_device *dssdev);
228int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, u8 *data,
229 int len);
230int dsi_vc_dcs_write_0(struct omap_dss_device *dssdev, int channel,
231 u8 dcs_cmd);
232int dsi_vc_dcs_write_1(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
233 u8 param);
234int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
235 u8 *data, int len);
236int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
237 u8 *buf, int buflen);
238int dsi_vc_dcs_read_1(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
239 u8 *data);
240int dsi_vc_dcs_read_2(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
241 u8 *data1, u8 *data2);
242int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel,
243 u16 len);
244int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel);
245int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel);
246
247/* Board specific data */
248struct omap_dss_board_info {
249 int (*get_last_off_on_transaction_id)(struct device *dev);
250 int num_devices;
251 struct omap_dss_device **devices;
252 struct omap_dss_device *default_device;
253 void (*dsi_mux_pads)(bool enable);
254};
255
256#if defined(CONFIG_OMAP2_DSS_MODULE) || defined(CONFIG_OMAP2_DSS)
257/* Init with the board info */
258extern int omap_display_init(struct omap_dss_board_info *board_data);
259#else
260static inline int omap_display_init(struct omap_dss_board_info *board_data)
261{
262 return 0;
263}
264#endif
265
266struct omap_display_platform_data {
267 struct omap_dss_board_info *board_data;
268 /* TODO: Additional members to be added when PM is considered */
269
270 bool (*opt_clock_available)(const char *clk_role);
271};
272
273struct omap_video_timings {
274 /* Unit: pixels */
275 u16 x_res;
276 /* Unit: pixels */
277 u16 y_res;
278 /* Unit: KHz */
279 u32 pixel_clock;
280 /* Unit: pixel clocks */
281 u16 hsw; /* Horizontal synchronization pulse width */
282 /* Unit: pixel clocks */
283 u16 hfp; /* Horizontal front porch */
284 /* Unit: pixel clocks */
285 u16 hbp; /* Horizontal back porch */
286 /* Unit: line clocks */
287 u16 vsw; /* Vertical synchronization pulse width */
288 /* Unit: line clocks */
289 u16 vfp; /* Vertical front porch */
290 /* Unit: line clocks */
291 u16 vbp; /* Vertical back porch */
292};
293
294#ifdef CONFIG_OMAP2_DSS_VENC
295/* Hardcoded timings for tv modes. Venc only uses these to
296 * identify the mode, and does not actually use the configs
297 * itself. However, the configs should be something that
298 * a normal monitor can also show */
299extern const struct omap_video_timings omap_dss_pal_timings;
300extern const struct omap_video_timings omap_dss_ntsc_timings;
301#endif
302
303struct omap_overlay_info {
304 bool enabled;
305
306 u32 paddr;
307 void __iomem *vaddr;
308 u32 p_uv_addr; /* for NV12 format */
309 u16 screen_width;
310 u16 width;
311 u16 height;
312 enum omap_color_mode color_mode;
313 u8 rotation;
314 enum omap_dss_rotation_type rotation_type;
315 bool mirror;
316
317 u16 pos_x;
318 u16 pos_y;
319 u16 out_width; /* if 0, out_width == width */
320 u16 out_height; /* if 0, out_height == height */
321 u8 global_alpha;
322 u8 pre_mult_alpha;
323};
324
325struct omap_overlay {
326 struct kobject kobj;
327 struct list_head list;
328
329 /* static fields */
330 const char *name;
331 int id;
332 enum omap_color_mode supported_modes;
333 enum omap_overlay_caps caps;
334
335 /* dynamic fields */
336 struct omap_overlay_manager *manager;
337 struct omap_overlay_info info;
338
339 /* if true, info has been changed, but not applied() yet */
340 bool info_dirty;
341
342 int (*set_manager)(struct omap_overlay *ovl,
343 struct omap_overlay_manager *mgr);
344 int (*unset_manager)(struct omap_overlay *ovl);
345
346 int (*set_overlay_info)(struct omap_overlay *ovl,
347 struct omap_overlay_info *info);
348 void (*get_overlay_info)(struct omap_overlay *ovl,
349 struct omap_overlay_info *info);
350
351 int (*wait_for_go)(struct omap_overlay *ovl);
352};
353
354struct omap_overlay_manager_info {
355 u32 default_color;
356
357 enum omap_dss_trans_key_type trans_key_type;
358 u32 trans_key;
359 bool trans_enabled;
360
361 bool alpha_enabled;
362};
363
364struct omap_overlay_manager {
365 struct kobject kobj;
366 struct list_head list;
367
368 /* static fields */
369 const char *name;
370 int id;
371 enum omap_overlay_manager_caps caps;
372 int num_overlays;
373 struct omap_overlay **overlays;
374 enum omap_display_type supported_displays;
375
376 /* dynamic fields */
377 struct omap_dss_device *device;
378 struct omap_overlay_manager_info info;
379
380 bool device_changed;
381 /* if true, info has been changed but not applied() yet */
382 bool info_dirty;
383
384 int (*set_device)(struct omap_overlay_manager *mgr,
385 struct omap_dss_device *dssdev);
386 int (*unset_device)(struct omap_overlay_manager *mgr);
387
388 int (*set_manager_info)(struct omap_overlay_manager *mgr,
389 struct omap_overlay_manager_info *info);
390 void (*get_manager_info)(struct omap_overlay_manager *mgr,
391 struct omap_overlay_manager_info *info);
392
393 int (*apply)(struct omap_overlay_manager *mgr);
394 int (*wait_for_go)(struct omap_overlay_manager *mgr);
395 int (*wait_for_vsync)(struct omap_overlay_manager *mgr);
396
397 int (*enable)(struct omap_overlay_manager *mgr);
398 int (*disable)(struct omap_overlay_manager *mgr);
399};
400
401struct omap_dss_device {
402 struct device dev;
403
404 enum omap_display_type type;
405
406 enum omap_channel channel;
407
408 union {
409 struct {
410 u8 data_lines;
411 } dpi;
412
413 struct {
414 u8 channel;
415 u8 data_lines;
416 } rfbi;
417
418 struct {
419 u8 datapairs;
420 } sdi;
421
422 struct {
423 u8 clk_lane;
424 u8 clk_pol;
425 u8 data1_lane;
426 u8 data1_pol;
427 u8 data2_lane;
428 u8 data2_pol;
429 u8 data3_lane;
430 u8 data3_pol;
431 u8 data4_lane;
432 u8 data4_pol;
433
434 int module;
435
436 bool ext_te;
437 u8 ext_te_gpio;
438 } dsi;
439
440 struct {
441 enum omap_dss_venc_type type;
442 bool invert_polarity;
443 } venc;
444 } phy;
445
446 struct {
447 struct {
448 struct {
449 u16 lck_div;
450 u16 pck_div;
451 enum omap_dss_clk_source lcd_clk_src;
452 } channel;
453
454 enum omap_dss_clk_source dispc_fclk_src;
455 } dispc;
456
457 struct {
458 u16 regn;
459 u16 regm;
460 u16 regm_dispc;
461 u16 regm_dsi;
462
463 u16 lp_clk_div;
464 enum omap_dss_clk_source dsi_fclk_src;
465 } dsi;
466
467 struct {
468 u16 regn;
469 u16 regm2;
470 } hdmi;
471 } clocks;
472
473 struct {
474 struct omap_video_timings timings;
475
476 int acbi; /* ac-bias pin transitions per interrupt */
477 /* Unit: line clocks */
478 int acb; /* ac-bias pin frequency */
479
480 enum omap_panel_config config;
481 } panel;
482
483 struct {
484 u8 pixel_size;
485 struct rfbi_timings rfbi_timings;
486 } ctrl;
487
488 int reset_gpio;
489
490 int max_backlight_level;
491
492 const char *name;
493
494 /* used to match device to driver */
495 const char *driver_name;
496
497 void *data;
498
499 struct omap_dss_driver *driver;
500
501 /* helper variable for driver suspend/resume */
502 bool activate_after_resume;
503
504 enum omap_display_caps caps;
505
506 struct omap_overlay_manager *manager;
507
508 enum omap_dss_display_state state;
509
510 /* platform specific */
511 int (*platform_enable)(struct omap_dss_device *dssdev);
512 void (*platform_disable)(struct omap_dss_device *dssdev);
513 int (*set_backlight)(struct omap_dss_device *dssdev, int level);
514 int (*get_backlight)(struct omap_dss_device *dssdev);
515};
516
517struct omap_dss_driver {
518 struct device_driver driver;
519
520 int (*probe)(struct omap_dss_device *);
521 void (*remove)(struct omap_dss_device *);
522
523 int (*enable)(struct omap_dss_device *display);
524 void (*disable)(struct omap_dss_device *display);
525 int (*suspend)(struct omap_dss_device *display);
526 int (*resume)(struct omap_dss_device *display);
527 int (*run_test)(struct omap_dss_device *display, int test);
528
529 int (*set_update_mode)(struct omap_dss_device *dssdev,
530 enum omap_dss_update_mode);
531 enum omap_dss_update_mode (*get_update_mode)(
532 struct omap_dss_device *dssdev);
533
534 int (*update)(struct omap_dss_device *dssdev,
535 u16 x, u16 y, u16 w, u16 h);
536 int (*sync)(struct omap_dss_device *dssdev);
537
538 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
539 int (*get_te)(struct omap_dss_device *dssdev);
540
541 u8 (*get_rotate)(struct omap_dss_device *dssdev);
542 int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
543
544 bool (*get_mirror)(struct omap_dss_device *dssdev);
545 int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
546
547 int (*memory_read)(struct omap_dss_device *dssdev,
548 void *buf, size_t size,
549 u16 x, u16 y, u16 w, u16 h);
550
551 void (*get_resolution)(struct omap_dss_device *dssdev,
552 u16 *xres, u16 *yres);
553 void (*get_dimensions)(struct omap_dss_device *dssdev,
554 u32 *width, u32 *height);
555 int (*get_recommended_bpp)(struct omap_dss_device *dssdev);
556
557 int (*check_timings)(struct omap_dss_device *dssdev,
558 struct omap_video_timings *timings);
559 void (*set_timings)(struct omap_dss_device *dssdev,
560 struct omap_video_timings *timings);
561 void (*get_timings)(struct omap_dss_device *dssdev,
562 struct omap_video_timings *timings);
563
564 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
565 u32 (*get_wss)(struct omap_dss_device *dssdev);
566};
567
568int omap_dss_register_driver(struct omap_dss_driver *);
569void omap_dss_unregister_driver(struct omap_dss_driver *);
570
571void omap_dss_get_device(struct omap_dss_device *dssdev);
572void omap_dss_put_device(struct omap_dss_device *dssdev);
573#define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
574struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
575struct omap_dss_device *omap_dss_find_device(void *data,
576 int (*match)(struct omap_dss_device *dssdev, void *data));
577
578int omap_dss_start_device(struct omap_dss_device *dssdev);
579void omap_dss_stop_device(struct omap_dss_device *dssdev);
580
581int omap_dss_get_num_overlay_managers(void);
582struct omap_overlay_manager *omap_dss_get_overlay_manager(int num);
583
584int omap_dss_get_num_overlays(void);
585struct omap_overlay *omap_dss_get_overlay(int num);
586
587void omapdss_default_get_resolution(struct omap_dss_device *dssdev,
588 u16 *xres, u16 *yres);
589int omapdss_default_get_recommended_bpp(struct omap_dss_device *dssdev);
590
591typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
592int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
593int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
594
595int omap_dispc_wait_for_irq_timeout(u32 irqmask, unsigned long timeout);
596int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask,
597 unsigned long timeout);
598
599#define to_dss_driver(x) container_of((x), struct omap_dss_driver, driver)
600#define to_dss_device(x) container_of((x), struct omap_dss_device, dev)
601
602void omapdss_dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
603 bool enable);
604int omapdss_dsi_enable_te(struct omap_dss_device *dssdev, bool enable);
605
606int omap_dsi_prepare_update(struct omap_dss_device *dssdev,
607 u16 *x, u16 *y, u16 *w, u16 *h,
608 bool enlarge_update_area);
609int omap_dsi_update(struct omap_dss_device *dssdev,
610 int channel,
611 u16 x, u16 y, u16 w, u16 h,
612 void (*callback)(int, void *), void *data);
613int omap_dsi_request_vc(struct omap_dss_device *dssdev, int *channel);
614int omap_dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id);
615void omap_dsi_release_vc(struct omap_dss_device *dssdev, int channel);
616
617int omapdss_dsi_display_enable(struct omap_dss_device *dssdev);
618void omapdss_dsi_display_disable(struct omap_dss_device *dssdev,
619 bool disconnect_lanes, bool enter_ulps);
620
621int omapdss_dpi_display_enable(struct omap_dss_device *dssdev);
622void omapdss_dpi_display_disable(struct omap_dss_device *dssdev);
623void dpi_set_timings(struct omap_dss_device *dssdev,
624 struct omap_video_timings *timings);
625int dpi_check_timings(struct omap_dss_device *dssdev,
626 struct omap_video_timings *timings);
627
628int omapdss_sdi_display_enable(struct omap_dss_device *dssdev);
629void omapdss_sdi_display_disable(struct omap_dss_device *dssdev);
630
631int omapdss_rfbi_display_enable(struct omap_dss_device *dssdev);
632void omapdss_rfbi_display_disable(struct omap_dss_device *dssdev);
633int omap_rfbi_prepare_update(struct omap_dss_device *dssdev,
634 u16 *x, u16 *y, u16 *w, u16 *h);
635int omap_rfbi_update(struct omap_dss_device *dssdev,
636 u16 x, u16 y, u16 w, u16 h,
637 void (*callback)(void *), void *data);
638int omap_rfbi_configure(struct omap_dss_device *dssdev, int pixel_size,
639 int data_lines);
640
641#endif
diff --git a/include/video/s1d13xxxfb.h b/include/video/s1d13xxxfb.h
index f0736cff2ca3..55f534491a3d 100644
--- a/include/video/s1d13xxxfb.h
+++ b/include/video/s1d13xxxfb.h
@@ -136,12 +136,6 @@
136#define S1DREG_DELAYOFF 0xFFFE 136#define S1DREG_DELAYOFF 0xFFFE
137#define S1DREG_DELAYON 0xFFFF 137#define S1DREG_DELAYON 0xFFFF
138 138
139#define BBLT_FIFO_EMPTY 0x00
140#define BBLT_FIFO_NOT_EMPTY 0x40
141#define BBLT_FIFO_NOT_FULL 0x30
142#define BBLT_FIFO_HALF_FULL 0x20
143#define BBLT_FIFO_FULL 0x10
144
145#define BBLT_SOLID_FILL 0x0c 139#define BBLT_SOLID_FILL 0x0c
146 140
147 141
diff --git a/include/video/sh_mipi_dsi.h b/include/video/sh_mipi_dsi.h
index 18bca08f9f59..6cb95c977de9 100644
--- a/include/video/sh_mipi_dsi.h
+++ b/include/video/sh_mipi_dsi.h
@@ -27,9 +27,15 @@ enum sh_mipi_dsi_data_fmt {
27 27
28struct sh_mobile_lcdc_chan_cfg; 28struct sh_mobile_lcdc_chan_cfg;
29 29
30#define SH_MIPI_DSI_HSABM (1 << 0)
31#define SH_MIPI_DSI_HSPBM (1 << 1)
32
30struct sh_mipi_dsi_info { 33struct sh_mipi_dsi_info {
31 enum sh_mipi_dsi_data_fmt data_format; 34 enum sh_mipi_dsi_data_fmt data_format;
32 struct sh_mobile_lcdc_chan_cfg *lcd_chan; 35 struct sh_mobile_lcdc_chan_cfg *lcd_chan;
36 unsigned long flags;
37 u32 clksrc;
38 unsigned int vsynw_offset;
33}; 39};
34 40
35#endif 41#endif
diff --git a/include/video/sh_mobile_hdmi.h b/include/video/sh_mobile_hdmi.h
index 577cf18cce89..b56932927d0a 100644
--- a/include/video/sh_mobile_hdmi.h
+++ b/include/video/sh_mobile_hdmi.h
@@ -13,10 +13,29 @@
13 13
14struct sh_mobile_lcdc_chan_cfg; 14struct sh_mobile_lcdc_chan_cfg;
15struct device; 15struct device;
16struct clk;
17
18/*
19 * flags format
20 *
21 * 0x0000000A
22 *
23 * A: Audio source select
24 */
25
26/* Audio source select */
27#define HDMI_SND_SRC_MASK (0xF << 0)
28#define HDMI_SND_SRC_I2S (0 << 0) /* default */
29#define HDMI_SND_SRC_SPDIF (1 << 0)
30#define HDMI_SND_SRC_DSD (2 << 0)
31#define HDMI_SND_SRC_HBR (3 << 0)
16 32
17struct sh_mobile_hdmi_info { 33struct sh_mobile_hdmi_info {
18 struct sh_mobile_lcdc_chan_cfg *lcd_chan; 34 struct sh_mobile_lcdc_chan_cfg *lcd_chan;
19 struct device *lcd_dev; 35 struct device *lcd_dev;
36 unsigned int flags;
37 long (*clk_optimize_parent)(unsigned long target, unsigned long *best_freq,
38 unsigned long *parent_freq);
20}; 39};
21 40
22#endif 41#endif
diff --git a/include/video/sh_mobile_lcdc.h b/include/video/sh_mobile_lcdc.h
index 55d700e8566e..d964e68fc61d 100644
--- a/include/video/sh_mobile_lcdc.h
+++ b/include/video/sh_mobile_lcdc.h
@@ -2,6 +2,7 @@
2#define __ASM_SH_MOBILE_LCDC_H__ 2#define __ASM_SH_MOBILE_LCDC_H__
3 3
4#include <linux/fb.h> 4#include <linux/fb.h>
5#include <video/sh_mobile_meram.h>
5 6
6enum { 7enum {
7 RGB8, /* 24bpp, 8:8:8 */ 8 RGB8, /* 24bpp, 8:8:8 */
@@ -49,7 +50,9 @@ struct sh_mobile_lcdc_sys_bus_ops {
49 unsigned long (*read_data)(void *handle); 50 unsigned long (*read_data)(void *handle);
50}; 51};
51 52
53struct module;
52struct sh_mobile_lcdc_board_cfg { 54struct sh_mobile_lcdc_board_cfg {
55 struct module *owner;
53 void *board_data; 56 void *board_data;
54 int (*setup_sys)(void *board_data, void *sys_ops_handle, 57 int (*setup_sys)(void *board_data, void *sys_ops_handle,
55 struct sh_mobile_lcdc_sys_bus_ops *sys_ops); 58 struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
@@ -57,6 +60,8 @@ struct sh_mobile_lcdc_board_cfg {
57 struct sh_mobile_lcdc_sys_bus_ops *sys_ops); 60 struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
58 void (*display_on)(void *board_data, struct fb_info *info); 61 void (*display_on)(void *board_data, struct fb_info *info);
59 void (*display_off)(void *board_data); 62 void (*display_off)(void *board_data);
63 int (*set_brightness)(void *board_data, int brightness);
64 int (*get_brightness)(void *board_data);
60}; 65};
61 66
62struct sh_mobile_lcdc_lcd_size_cfg { /* width and height of panel in mm */ 67struct sh_mobile_lcdc_lcd_size_cfg { /* width and height of panel in mm */
@@ -64,21 +69,32 @@ struct sh_mobile_lcdc_lcd_size_cfg { /* width and height of panel in mm */
64 unsigned long height; 69 unsigned long height;
65}; 70};
66 71
72/* backlight info */
73struct sh_mobile_lcdc_bl_info {
74 const char *name;
75 int max_brightness;
76};
77
67struct sh_mobile_lcdc_chan_cfg { 78struct sh_mobile_lcdc_chan_cfg {
68 int chan; 79 int chan;
69 int bpp; 80 int bpp;
70 int interface_type; /* selects RGBn or SYSn I/F, see above */ 81 int interface_type; /* selects RGBn or SYSn I/F, see above */
71 int clock_divider; 82 int clock_divider;
72 unsigned long flags; /* LCDC_FLAGS_... */ 83 unsigned long flags; /* LCDC_FLAGS_... */
73 struct fb_videomode lcd_cfg; 84 const struct fb_videomode *lcd_cfg;
85 int num_cfg;
74 struct sh_mobile_lcdc_lcd_size_cfg lcd_size_cfg; 86 struct sh_mobile_lcdc_lcd_size_cfg lcd_size_cfg;
75 struct sh_mobile_lcdc_board_cfg board_cfg; 87 struct sh_mobile_lcdc_board_cfg board_cfg;
88 struct sh_mobile_lcdc_bl_info bl_info;
76 struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */ 89 struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
90 int nonstd;
91 struct sh_mobile_meram_cfg *meram_cfg;
77}; 92};
78 93
79struct sh_mobile_lcdc_info { 94struct sh_mobile_lcdc_info {
80 int clock_source; 95 int clock_source;
81 struct sh_mobile_lcdc_chan_cfg ch[2]; 96 struct sh_mobile_lcdc_chan_cfg ch[2];
97 struct sh_mobile_meram_info *meram_dev;
82}; 98};
83 99
84#endif /* __ASM_SH_MOBILE_LCDC_H__ */ 100#endif /* __ASM_SH_MOBILE_LCDC_H__ */
diff --git a/include/video/sh_mobile_meram.h b/include/video/sh_mobile_meram.h
new file mode 100644
index 000000000000..af602d602b28
--- /dev/null
+++ b/include/video/sh_mobile_meram.h
@@ -0,0 +1,68 @@
1#ifndef __VIDEO_SH_MOBILE_MERAM_H__
2#define __VIDEO_SH_MOBILE_MERAM_H__
3
4/* For sh_mobile_meram_info.addr_mode */
5enum {
6 SH_MOBILE_MERAM_MODE0 = 0,
7 SH_MOBILE_MERAM_MODE1
8};
9
10enum {
11 SH_MOBILE_MERAM_PF_NV = 0,
12 SH_MOBILE_MERAM_PF_RGB,
13 SH_MOBILE_MERAM_PF_NV24
14};
15
16
17struct sh_mobile_meram_priv;
18struct sh_mobile_meram_ops;
19
20struct sh_mobile_meram_info {
21 int addr_mode;
22 struct sh_mobile_meram_ops *ops;
23 struct sh_mobile_meram_priv *priv;
24 struct platform_device *pdev;
25};
26
27/* icb config */
28struct sh_mobile_meram_icb {
29 int marker_icb; /* ICB # for Marker ICB */
30 int cache_icb; /* ICB # for Cache ICB */
31 int meram_offset; /* MERAM Buffer Offset to use */
32 int meram_size; /* MERAM Buffer Size to use */
33
34 int cache_unit; /* bytes to cache per ICB */
35};
36
37struct sh_mobile_meram_cfg {
38 struct sh_mobile_meram_icb icb[2];
39 int pixelformat;
40 int current_reg;
41};
42
43struct module;
44struct sh_mobile_meram_ops {
45 struct module *module;
46 /* register usage of meram */
47 int (*meram_register)(struct sh_mobile_meram_info *meram_dev,
48 struct sh_mobile_meram_cfg *cfg,
49 int xres, int yres, int pixelformat,
50 unsigned long base_addr_y,
51 unsigned long base_addr_c,
52 unsigned long *icb_addr_y,
53 unsigned long *icb_addr_c, int *pitch);
54
55 /* unregister usage of meram */
56 int (*meram_unregister)(struct sh_mobile_meram_info *meram_dev,
57 struct sh_mobile_meram_cfg *cfg);
58
59 /* update meram settings */
60 int (*meram_update)(struct sh_mobile_meram_info *meram_dev,
61 struct sh_mobile_meram_cfg *cfg,
62 unsigned long base_addr_y,
63 unsigned long base_addr_c,
64 unsigned long *icb_addr_y,
65 unsigned long *icb_addr_c);
66};
67
68#endif /* __VIDEO_SH_MOBILE_MERAM_H__ */
diff --git a/include/video/sisfb.h b/include/video/sisfb.h
index fdd74f1a6791..6dc5df9e43f3 100644
--- a/include/video/sisfb.h
+++ b/include/video/sisfb.h
@@ -151,7 +151,7 @@ struct sisfb_cmd {
151 __u32 sisfb_result[4]; 151 __u32 sisfb_result[4];
152}; 152};
153 153
154/* Addtional IOCTLs for communication sisfb <> X driver */ 154/* Additional IOCTLs for communication sisfb <> X driver */
155/* If changing this, vgatypes.h must also be changed (for X driver) */ 155/* If changing this, vgatypes.h must also be changed (for X driver) */
156 156
157/* ioctl for identifying and giving some info (esp. memory heap start) */ 157/* ioctl for identifying and giving some info (esp. memory heap start) */
diff --git a/include/video/sstfb.h b/include/video/sstfb.h
index b52f07381243..c449eace12cd 100644
--- a/include/video/sstfb.h
+++ b/include/video/sstfb.h
@@ -156,7 +156,7 @@
156#define DAC_READ FBIINIT2 /* in remap mode */ 156#define DAC_READ FBIINIT2 /* in remap mode */
157#define FBIINIT3 0x021c /* fbi controls */ 157#define FBIINIT3 0x021c /* fbi controls */
158# define DISABLE_TEXTURE BIT(6) 158# define DISABLE_TEXTURE BIT(6)
159# define Y_SWAP_ORIGIN_SHIFT 22 /* Y swap substraction value */ 159# define Y_SWAP_ORIGIN_SHIFT 22 /* Y swap subtraction value */
160#define HSYNC 0x0220 160#define HSYNC 0x0220
161#define VSYNC 0x0224 161#define VSYNC 0x0224
162#define DAC_DATA 0x022c 162#define DAC_DATA 0x022c
@@ -212,9 +212,9 @@
212# define DACREG_CR0_24BPP 0x50 /* mode 5 */ 212# define DACREG_CR0_24BPP 0x50 /* mode 5 */
213#define DACREG_CR1_I 0x05 213#define DACREG_CR1_I 0x05
214#define DACREG_CC_I 0x06 214#define DACREG_CC_I 0x06
215# define DACREG_CC_CLKA BIT(7) /* clk A controled by regs */ 215# define DACREG_CC_CLKA BIT(7) /* clk A controlled by regs */
216# define DACREG_CC_CLKA_C (2<<4) /* clk A uses reg C */ 216# define DACREG_CC_CLKA_C (2<<4) /* clk A uses reg C */
217# define DACREG_CC_CLKB BIT(3) /* clk B controled by regs */ 217# define DACREG_CC_CLKB BIT(3) /* clk B controlled by regs */
218# define DACREG_CC_CLKB_D 3 /* clkB uses reg D */ 218# define DACREG_CC_CLKB_D 3 /* clkB uses reg D */
219#define DACREG_AC0_I 0x48 /* clock A reg C */ 219#define DACREG_AC0_I 0x48 /* clock A reg C */
220#define DACREG_AC1_I 0x49 220#define DACREG_AC1_I 0x49
diff --git a/include/video/udlfb.h b/include/video/udlfb.h
new file mode 100644
index 000000000000..69d485a4a026
--- /dev/null
+++ b/include/video/udlfb.h
@@ -0,0 +1,95 @@
1#ifndef UDLFB_H
2#define UDLFB_H
3
4/*
5 * TODO: Propose standard fb.h ioctl for reporting damage,
6 * using _IOWR() and one of the existing area structs from fb.h
7 * Consider these ioctls deprecated, but they're still used by the
8 * DisplayLink X server as yet - need both to be modified in tandem
9 * when new ioctl(s) are ready.
10 */
11#define DLFB_IOCTL_RETURN_EDID 0xAD
12#define DLFB_IOCTL_REPORT_DAMAGE 0xAA
13struct dloarea {
14 int x, y;
15 int w, h;
16 int x2, y2;
17};
18
19struct urb_node {
20 struct list_head entry;
21 struct dlfb_data *dev;
22 struct delayed_work release_urb_work;
23 struct urb *urb;
24};
25
26struct urb_list {
27 struct list_head list;
28 spinlock_t lock;
29 struct semaphore limit_sem;
30 int available;
31 int count;
32 size_t size;
33};
34
35struct dlfb_data {
36 struct usb_device *udev;
37 struct device *gdev; /* &udev->dev */
38 struct fb_info *info;
39 struct urb_list urbs;
40 struct kref kref;
41 char *backing_buffer;
42 int fb_count;
43 bool virtualized; /* true when physical usb device not present */
44 struct delayed_work free_framebuffer_work;
45 atomic_t usb_active; /* 0 = update virtual buffer, but no usb traffic */
46 atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */
47 char *edid; /* null until we read edid from hw or get from sysfs */
48 size_t edid_size;
49 int sku_pixel_limit;
50 int base16;
51 int base8;
52 u32 pseudo_palette[256];
53 /* blit-only rendering path metrics, exposed through sysfs */
54 atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
55 atomic_t bytes_identical; /* saved effort with backbuffer comparison */
56 atomic_t bytes_sent; /* to usb, after compression including overhead */
57 atomic_t cpu_kcycles_used; /* transpired during pixel processing */
58};
59
60#define NR_USB_REQUEST_I2C_SUB_IO 0x02
61#define NR_USB_REQUEST_CHANNEL 0x12
62
63/* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */
64#define BULK_SIZE 512
65#define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE)
66#define WRITES_IN_FLIGHT (4)
67
68#define MAX_VENDOR_DESCRIPTOR_SIZE 256
69
70#define GET_URB_TIMEOUT HZ
71#define FREE_URB_TIMEOUT (HZ*2)
72
73#define BPP 2
74#define MAX_CMD_PIXELS 255
75
76#define RLX_HEADER_BYTES 7
77#define MIN_RLX_PIX_BYTES 4
78#define MIN_RLX_CMD_BYTES (RLX_HEADER_BYTES + MIN_RLX_PIX_BYTES)
79
80#define RLE_HEADER_BYTES 6
81#define MIN_RLE_PIX_BYTES 3
82#define MIN_RLE_CMD_BYTES (RLE_HEADER_BYTES + MIN_RLE_PIX_BYTES)
83
84#define RAW_HEADER_BYTES 6
85#define MIN_RAW_PIX_BYTES 2
86#define MIN_RAW_CMD_BYTES (RAW_HEADER_BYTES + MIN_RAW_PIX_BYTES)
87
88#define DL_DEFIO_WRITE_DELAY 5 /* fb_deferred_io.delay in jiffies */
89#define DL_DEFIO_WRITE_DISABLE (HZ*60) /* "disable" with long delay */
90
91/* remove these once align.h patch is taken into kernel */
92#define DL_ALIGN_UP(x, a) ALIGN(x, a)
93#define DL_ALIGN_DOWN(x, a) ALIGN(x-(a-1), a)
94
95#endif
diff --git a/include/video/vga.h b/include/video/vga.h
index b49a5120ca2d..2b8691f7d256 100644
--- a/include/video/vga.h
+++ b/include/video/vga.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright history from vga16fb.c: 6 * Copyright history from vga16fb.c:
7 * Copyright 1999 Ben Pfaff and Petr Vandrovec 7 * Copyright 1999 Ben Pfaff and Petr Vandrovec
8 * Based on VGA info at http://www.goodnet.com/~tinara/FreeVGA/home.htm 8 * Based on VGA info at http://www.osdever.net/FreeVGA/home.htm
9 * Based on VESA framebuffer (c) 1998 Gerd Knorr 9 * Based on VESA framebuffer (c) 1998 Gerd Knorr
10 * 10 *
11 * This file is subject to the terms and conditions of the GNU General 11 * This file is subject to the terms and conditions of the GNU General
diff --git a/include/xen/Kbuild b/include/xen/Kbuild
index 4e65c16a445b..84ad8f02fee5 100644
--- a/include/xen/Kbuild
+++ b/include/xen/Kbuild
@@ -1 +1,2 @@
1header-y += evtchn.h 1header-y += evtchn.h
2header-y += privcmd.h
diff --git a/include/xen/balloon.h b/include/xen/balloon.h
new file mode 100644
index 000000000000..a2b22f01a51d
--- /dev/null
+++ b/include/xen/balloon.h
@@ -0,0 +1,25 @@
1/******************************************************************************
2 * Xen balloon functionality
3 */
4
5#define RETRY_UNLIMITED 0
6
7struct balloon_stats {
8 /* We aim for 'current allocation' == 'target allocation'. */
9 unsigned long current_pages;
10 unsigned long target_pages;
11 /* Number of pages in high- and low-memory balloons. */
12 unsigned long balloon_low;
13 unsigned long balloon_high;
14 unsigned long schedule_delay;
15 unsigned long max_schedule_delay;
16 unsigned long retry_count;
17 unsigned long max_retry_count;
18};
19
20extern struct balloon_stats balloon_stats;
21
22void balloon_set_new_target(unsigned long target);
23
24int alloc_xenballooned_pages(int nr_pages, struct page** pages);
25void free_xenballooned_pages(int nr_pages, struct page** pages);
diff --git a/include/xen/events.h b/include/xen/events.h
index a15d93262e30..9af21e19545a 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -12,6 +12,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn,
12 irq_handler_t handler, 12 irq_handler_t handler,
13 unsigned long irqflags, const char *devname, 13 unsigned long irqflags, const char *devname,
14 void *dev_id); 14 void *dev_id);
15int bind_virq_to_irq(unsigned int virq, unsigned int cpu);
15int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, 16int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
16 irq_handler_t handler, 17 irq_handler_t handler,
17 unsigned long irqflags, const char *devname, 18 unsigned long irqflags, const char *devname,
@@ -22,6 +23,12 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
22 unsigned long irqflags, 23 unsigned long irqflags,
23 const char *devname, 24 const char *devname,
24 void *dev_id); 25 void *dev_id);
26int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain,
27 unsigned int remote_port,
28 irq_handler_t handler,
29 unsigned long irqflags,
30 const char *devname,
31 void *dev_id);
25 32
26/* 33/*
27 * Common unbind function for all event sources. Takes IRQ to unbind from. 34 * Common unbind function for all event sources. Takes IRQ to unbind from.
@@ -40,9 +47,9 @@ static inline void notify_remote_via_evtchn(int port)
40 (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send); 47 (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
41} 48}
42 49
43extern void notify_remote_via_irq(int irq); 50void notify_remote_via_irq(int irq);
44 51
45extern void xen_irq_resume(void); 52void xen_irq_resume(void);
46 53
47/* Clear an irq's pending state, in preparation for polling on it */ 54/* Clear an irq's pending state, in preparation for polling on it */
48void xen_clear_irq_pending(int irq); 55void xen_clear_irq_pending(int irq);
@@ -53,14 +60,45 @@ bool xen_test_irq_pending(int irq);
53 irq will be disabled so it won't deliver an interrupt. */ 60 irq will be disabled so it won't deliver an interrupt. */
54void xen_poll_irq(int irq); 61void xen_poll_irq(int irq);
55 62
63/* Poll waiting for an irq to become pending with a timeout. In the usual case,
64 * the irq will be disabled so it won't deliver an interrupt. */
65void xen_poll_irq_timeout(int irq, u64 timeout);
66
56/* Determine the IRQ which is bound to an event channel */ 67/* Determine the IRQ which is bound to an event channel */
57unsigned irq_from_evtchn(unsigned int evtchn); 68unsigned irq_from_evtchn(unsigned int evtchn);
58 69
59/* Xen HVM evtchn vector callback */ 70/* Xen HVM evtchn vector callback */
60extern void xen_hvm_callback_vector(void); 71void xen_hvm_callback_vector(void);
61extern int xen_have_vector_callback; 72extern int xen_have_vector_callback;
62int xen_set_callback_via(uint64_t via); 73int xen_set_callback_via(uint64_t via);
63void xen_evtchn_do_upcall(struct pt_regs *regs); 74void xen_evtchn_do_upcall(struct pt_regs *regs);
64void xen_hvm_evtchn_do_upcall(void); 75void xen_hvm_evtchn_do_upcall(void);
65 76
77/* Allocate a pirq for a physical interrupt, given a gsi. */
78int xen_allocate_pirq_gsi(unsigned gsi);
79/* Bind a pirq for a physical interrupt to an irq. */
80int xen_bind_pirq_gsi_to_irq(unsigned gsi,
81 unsigned pirq, int shareable, char *name);
82
83#ifdef CONFIG_PCI_MSI
84/* Allocate a pirq for a MSI style physical interrupt. */
85int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc);
86/* Bind an PSI pirq to an irq. */
87int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc,
88 int pirq, int vector, const char *name,
89 domid_t domid);
90#endif
91
92/* De-allocates the above mentioned physical interrupt. */
93int xen_destroy_irq(int irq);
94
95/* Return irq from pirq */
96int xen_irq_from_pirq(unsigned pirq);
97
98/* Return the pirq allocated to the irq. */
99int xen_pirq_from_irq(unsigned irq);
100
101/* Determine whether to ignore this IRQ if it is passed to a guest. */
102int xen_test_irq_shared(int irq);
103
66#endif /* _XEN_EVENTS_H */ 104#endif /* _XEN_EVENTS_H */
diff --git a/include/xen/gntalloc.h b/include/xen/gntalloc.h
new file mode 100644
index 000000000000..76bd58065f4f
--- /dev/null
+++ b/include/xen/gntalloc.h
@@ -0,0 +1,82 @@
1/******************************************************************************
2 * gntalloc.h
3 *
4 * Interface to /dev/xen/gntalloc.
5 *
6 * Author: Daniel De Graaf <dgdegra@tycho.nsa.gov>
7 *
8 * This file is in the public domain.
9 */
10
11#ifndef __LINUX_PUBLIC_GNTALLOC_H__
12#define __LINUX_PUBLIC_GNTALLOC_H__
13
14/*
15 * Allocates a new page and creates a new grant reference.
16 */
17#define IOCTL_GNTALLOC_ALLOC_GREF \
18_IOC(_IOC_NONE, 'G', 5, sizeof(struct ioctl_gntalloc_alloc_gref))
19struct ioctl_gntalloc_alloc_gref {
20 /* IN parameters */
21 /* The ID of the domain to be given access to the grants. */
22 uint16_t domid;
23 /* Flags for this mapping */
24 uint16_t flags;
25 /* Number of pages to map */
26 uint32_t count;
27 /* OUT parameters */
28 /* The offset to be used on a subsequent call to mmap(). */
29 uint64_t index;
30 /* The grant references of the newly created grant, one per page */
31 /* Variable size, depending on count */
32 uint32_t gref_ids[1];
33};
34
35#define GNTALLOC_FLAG_WRITABLE 1
36
37/*
38 * Deallocates the grant reference, allowing the associated page to be freed if
39 * no other domains are using it.
40 */
41#define IOCTL_GNTALLOC_DEALLOC_GREF \
42_IOC(_IOC_NONE, 'G', 6, sizeof(struct ioctl_gntalloc_dealloc_gref))
43struct ioctl_gntalloc_dealloc_gref {
44 /* IN parameters */
45 /* The offset returned in the map operation */
46 uint64_t index;
47 /* Number of references to unmap */
48 uint32_t count;
49};
50
51/*
52 * Sets up an unmap notification within the page, so that the other side can do
53 * cleanup if this side crashes. Required to implement cross-domain robust
54 * mutexes or close notification on communication channels.
55 *
56 * Each mapped page only supports one notification; multiple calls referring to
57 * the same page overwrite the previous notification. You must clear the
58 * notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it
59 * to occur.
60 */
61#define IOCTL_GNTALLOC_SET_UNMAP_NOTIFY \
62_IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntalloc_unmap_notify))
63struct ioctl_gntalloc_unmap_notify {
64 /* IN parameters */
65 /* Offset in the file descriptor for a byte within the page (same as
66 * used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to
67 * be cleared. Otherwise, it can be any byte in the page whose
68 * notification we are adjusting.
69 */
70 uint64_t index;
71 /* Action(s) to take on unmap */
72 uint32_t action;
73 /* Event channel to notify */
74 uint32_t event_channel_port;
75};
76
77/* Clear (set to zero) the byte specified by index */
78#define UNMAP_NOTIFY_CLEAR_BYTE 0x1
79/* Send an interrupt on the indicated event channel */
80#define UNMAP_NOTIFY_SEND_EVENT 0x2
81
82#endif /* __LINUX_PUBLIC_GNTALLOC_H__ */
diff --git a/include/xen/gntdev.h b/include/xen/gntdev.h
new file mode 100644
index 000000000000..5304bd3c84c5
--- /dev/null
+++ b/include/xen/gntdev.h
@@ -0,0 +1,150 @@
1/******************************************************************************
2 * gntdev.h
3 *
4 * Interface to /dev/xen/gntdev.
5 *
6 * Copyright (c) 2007, D G Murray
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
32
33#ifndef __LINUX_PUBLIC_GNTDEV_H__
34#define __LINUX_PUBLIC_GNTDEV_H__
35
36struct ioctl_gntdev_grant_ref {
37 /* The domain ID of the grant to be mapped. */
38 uint32_t domid;
39 /* The grant reference of the grant to be mapped. */
40 uint32_t ref;
41};
42
43/*
44 * Inserts the grant references into the mapping table of an instance
45 * of gntdev. N.B. This does not perform the mapping, which is deferred
46 * until mmap() is called with @index as the offset.
47 */
48#define IOCTL_GNTDEV_MAP_GRANT_REF \
49_IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))
50struct ioctl_gntdev_map_grant_ref {
51 /* IN parameters */
52 /* The number of grants to be mapped. */
53 uint32_t count;
54 uint32_t pad;
55 /* OUT parameters */
56 /* The offset to be used on a subsequent call to mmap(). */
57 uint64_t index;
58 /* Variable IN parameter. */
59 /* Array of grant references, of size @count. */
60 struct ioctl_gntdev_grant_ref refs[1];
61};
62
63/*
64 * Removes the grant references from the mapping table of an instance of
65 * of gntdev. N.B. munmap() must be called on the relevant virtual address(es)
66 * before this ioctl is called, or an error will result.
67 */
68#define IOCTL_GNTDEV_UNMAP_GRANT_REF \
69_IOC(_IOC_NONE, 'G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref))
70struct ioctl_gntdev_unmap_grant_ref {
71 /* IN parameters */
72 /* The offset was returned by the corresponding map operation. */
73 uint64_t index;
74 /* The number of pages to be unmapped. */
75 uint32_t count;
76 uint32_t pad;
77};
78
79/*
80 * Returns the offset in the driver's address space that corresponds
81 * to @vaddr. This can be used to perform a munmap(), followed by an
82 * UNMAP_GRANT_REF ioctl, where no state about the offset is retained by
83 * the caller. The number of pages that were allocated at the same time as
84 * @vaddr is returned in @count.
85 *
86 * N.B. Where more than one page has been mapped into a contiguous range, the
87 * supplied @vaddr must correspond to the start of the range; otherwise
88 * an error will result. It is only possible to munmap() the entire
89 * contiguously-allocated range at once, and not any subrange thereof.
90 */
91#define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \
92_IOC(_IOC_NONE, 'G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr))
93struct ioctl_gntdev_get_offset_for_vaddr {
94 /* IN parameters */
95 /* The virtual address of the first mapped page in a range. */
96 uint64_t vaddr;
97 /* OUT parameters */
98 /* The offset that was used in the initial mmap() operation. */
99 uint64_t offset;
100 /* The number of pages mapped in the VM area that begins at @vaddr. */
101 uint32_t count;
102 uint32_t pad;
103};
104
105/*
106 * Sets the maximum number of grants that may mapped at once by this gntdev
107 * instance.
108 *
109 * N.B. This must be called before any other ioctl is performed on the device.
110 */
111#define IOCTL_GNTDEV_SET_MAX_GRANTS \
112_IOC(_IOC_NONE, 'G', 3, sizeof(struct ioctl_gntdev_set_max_grants))
113struct ioctl_gntdev_set_max_grants {
114 /* IN parameter */
115 /* The maximum number of grants that may be mapped at once. */
116 uint32_t count;
117};
118
119/*
120 * Sets up an unmap notification within the page, so that the other side can do
121 * cleanup if this side crashes. Required to implement cross-domain robust
122 * mutexes or close notification on communication channels.
123 *
124 * Each mapped page only supports one notification; multiple calls referring to
125 * the same page overwrite the previous notification. You must clear the
126 * notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it
127 * to occur.
128 */
129#define IOCTL_GNTDEV_SET_UNMAP_NOTIFY \
130_IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntdev_unmap_notify))
131struct ioctl_gntdev_unmap_notify {
132 /* IN parameters */
133 /* Offset in the file descriptor for a byte within the page (same as
134 * used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to
135 * be cleared. Otherwise, it can be any byte in the page whose
136 * notification we are adjusting.
137 */
138 uint64_t index;
139 /* Action(s) to take on unmap */
140 uint32_t action;
141 /* Event channel to notify */
142 uint32_t event_channel_port;
143};
144
145/* Clear (set to zero) the byte specified by index */
146#define UNMAP_NOTIFY_CLEAR_BYTE 0x1
147/* Send an interrupt on the indicated event channel */
148#define UNMAP_NOTIFY_SEND_EVENT 0x2
149
150#endif /* __LINUX_PUBLIC_GNTDEV_H__ */
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 9a731706a016..b1fab6b5b3ef 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -37,10 +37,16 @@
37#ifndef __ASM_GNTTAB_H__ 37#ifndef __ASM_GNTTAB_H__
38#define __ASM_GNTTAB_H__ 38#define __ASM_GNTTAB_H__
39 39
40#include <asm/xen/hypervisor.h> 40#include <asm/page.h>
41
42#include <xen/interface/xen.h>
41#include <xen/interface/grant_table.h> 43#include <xen/interface/grant_table.h>
44
45#include <asm/xen/hypervisor.h>
42#include <asm/xen/grant_table.h> 46#include <asm/xen/grant_table.h>
43 47
48#include <xen/features.h>
49
44/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */ 50/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
45#define NR_GRANT_FRAMES 4 51#define NR_GRANT_FRAMES 4
46 52
@@ -107,6 +113,37 @@ void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
107void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid, 113void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid,
108 unsigned long pfn); 114 unsigned long pfn);
109 115
116static inline void
117gnttab_set_map_op(struct gnttab_map_grant_ref *map, phys_addr_t addr,
118 uint32_t flags, grant_ref_t ref, domid_t domid)
119{
120 if (flags & GNTMAP_contains_pte)
121 map->host_addr = addr;
122 else if (xen_feature(XENFEAT_auto_translated_physmap))
123 map->host_addr = __pa(addr);
124 else
125 map->host_addr = addr;
126
127 map->flags = flags;
128 map->ref = ref;
129 map->dom = domid;
130}
131
132static inline void
133gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, phys_addr_t addr,
134 uint32_t flags, grant_handle_t handle)
135{
136 if (flags & GNTMAP_contains_pte)
137 unmap->host_addr = addr;
138 else if (xen_feature(XENFEAT_auto_translated_physmap))
139 unmap->host_addr = __pa(addr);
140 else
141 unmap->host_addr = addr;
142
143 unmap->handle = handle;
144 unmap->dev_bus_addr = 0;
145}
146
110int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, 147int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,
111 unsigned long max_nr_gframes, 148 unsigned long max_nr_gframes,
112 struct grant_entry **__shared); 149 struct grant_entry **__shared);
@@ -118,4 +155,9 @@ unsigned int gnttab_max_grant_frames(void);
118 155
119#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) 156#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
120 157
158int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
159 struct page **pages, unsigned int count);
160int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
161 struct page **pages, unsigned int count);
162
121#endif /* __ASM_GNTTAB_H__ */ 163#endif /* __ASM_GNTTAB_H__ */
diff --git a/include/xen/interface/elfnote.h b/include/xen/interface/elfnote.h
index 7a8262c375cc..0360b15f4883 100644
--- a/include/xen/interface/elfnote.h
+++ b/include/xen/interface/elfnote.h
@@ -51,7 +51,7 @@
51 51
52/* 52/*
53 * The offset of the ELF paddr field from the acutal required 53 * The offset of the ELF paddr field from the acutal required
54 * psuedo-physical address (numeric). 54 * pseudo-physical address (numeric).
55 * 55 *
56 * This is used to maintain backwards compatibility with older kernels 56 * This is used to maintain backwards compatibility with older kernels
57 * which wrote __PAGE_OFFSET into that field. This field defaults to 0 57 * which wrote __PAGE_OFFSET into that field. This field defaults to 0
diff --git a/include/xen/interface/features.h b/include/xen/interface/features.h
index 70d2563ab166..b6ca39a069d8 100644
--- a/include/xen/interface/features.h
+++ b/include/xen/interface/features.h
@@ -47,6 +47,9 @@
47/* x86: pvclock algorithm is safe to use on HVM */ 47/* x86: pvclock algorithm is safe to use on HVM */
48#define XENFEAT_hvm_safe_pvclock 9 48#define XENFEAT_hvm_safe_pvclock 9
49 49
50/* x86: pirq can be used by HVM guests */
51#define XENFEAT_hvm_pirqs 10
52
50#define XENFEAT_NR_SUBMAPS 1 53#define XENFEAT_NR_SUBMAPS 1
51 54
52#endif /* __XEN_PUBLIC_FEATURES_H__ */ 55#endif /* __XEN_PUBLIC_FEATURES_H__ */
diff --git a/include/xen/interface/io/blkif.h b/include/xen/interface/io/blkif.h
index c2d1fa4dc1ee..3d5d6db864fe 100644
--- a/include/xen/interface/io/blkif.h
+++ b/include/xen/interface/io/blkif.h
@@ -45,17 +45,26 @@ typedef uint64_t blkif_sector_t;
45#define BLKIF_OP_WRITE_BARRIER 2 45#define BLKIF_OP_WRITE_BARRIER 2
46 46
47/* 47/*
48 * Recognised if "feature-flush-cache" is present in backend xenbus
49 * info. A flush will ask the underlying storage hardware to flush its
50 * non-volatile caches as appropriate. The "feature-flush-cache" node
51 * contains a boolean indicating whether flush requests are likely to
52 * succeed or fail. Either way, a flush request may fail at any time
53 * with BLKIF_RSP_EOPNOTSUPP if it is unsupported by the underlying
54 * block-device hardware. The boolean simply indicates whether or not it
55 * is worthwhile for the frontend to attempt flushes. If a backend does
56 * not recognise BLKIF_OP_WRITE_FLUSH_CACHE, it should *not* create the
57 * "feature-flush-cache" node!
58 */
59#define BLKIF_OP_FLUSH_DISKCACHE 3
60/*
48 * Maximum scatter/gather segments per request. 61 * Maximum scatter/gather segments per request.
49 * This is carefully chosen so that sizeof(struct blkif_ring) <= PAGE_SIZE. 62 * This is carefully chosen so that sizeof(struct blkif_ring) <= PAGE_SIZE.
50 * NB. This could be 12 if the ring indexes weren't stored in the same page. 63 * NB. This could be 12 if the ring indexes weren't stored in the same page.
51 */ 64 */
52#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 65#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
53 66
54struct blkif_request { 67struct blkif_request_rw {
55 uint8_t operation; /* BLKIF_OP_??? */
56 uint8_t nr_segments; /* number of segments */
57 blkif_vdev_t handle; /* only for read/write requests */
58 uint64_t id; /* private guest value, echoed in resp */
59 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 68 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
60 struct blkif_request_segment { 69 struct blkif_request_segment {
61 grant_ref_t gref; /* reference to I/O buffer frame */ 70 grant_ref_t gref; /* reference to I/O buffer frame */
@@ -65,6 +74,16 @@ struct blkif_request {
65 } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 74 } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
66}; 75};
67 76
77struct blkif_request {
78 uint8_t operation; /* BLKIF_OP_??? */
79 uint8_t nr_segments; /* number of segments */
80 blkif_vdev_t handle; /* only for read/write requests */
81 uint64_t id; /* private guest value, echoed in resp */
82 union {
83 struct blkif_request_rw rw;
84 } u;
85};
86
68struct blkif_response { 87struct blkif_response {
69 uint64_t id; /* copied from request */ 88 uint64_t id; /* copied from request */
70 uint8_t operation; /* copied from request */ 89 uint8_t operation; /* copied from request */
@@ -91,4 +110,25 @@ DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
91#define VDISK_REMOVABLE 0x2 110#define VDISK_REMOVABLE 0x2
92#define VDISK_READONLY 0x4 111#define VDISK_READONLY 0x4
93 112
113/* Xen-defined major numbers for virtual disks, they look strangely
114 * familiar */
115#define XEN_IDE0_MAJOR 3
116#define XEN_IDE1_MAJOR 22
117#define XEN_SCSI_DISK0_MAJOR 8
118#define XEN_SCSI_DISK1_MAJOR 65
119#define XEN_SCSI_DISK2_MAJOR 66
120#define XEN_SCSI_DISK3_MAJOR 67
121#define XEN_SCSI_DISK4_MAJOR 68
122#define XEN_SCSI_DISK5_MAJOR 69
123#define XEN_SCSI_DISK6_MAJOR 70
124#define XEN_SCSI_DISK7_MAJOR 71
125#define XEN_SCSI_DISK8_MAJOR 128
126#define XEN_SCSI_DISK9_MAJOR 129
127#define XEN_SCSI_DISK10_MAJOR 130
128#define XEN_SCSI_DISK11_MAJOR 131
129#define XEN_SCSI_DISK12_MAJOR 132
130#define XEN_SCSI_DISK13_MAJOR 133
131#define XEN_SCSI_DISK14_MAJOR 134
132#define XEN_SCSI_DISK15_MAJOR 135
133
94#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */ 134#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
diff --git a/include/xen/interface/io/netif.h b/include/xen/interface/io/netif.h
index 518481c95f18..cb94668f6e9f 100644
--- a/include/xen/interface/io/netif.h
+++ b/include/xen/interface/io/netif.h
@@ -22,50 +22,50 @@
22 22
23/* 23/*
24 * This is the 'wire' format for packets: 24 * This is the 'wire' format for packets:
25 * Request 1: netif_tx_request -- NETTXF_* (any flags) 25 * Request 1: xen_netif_tx_request -- XEN_NETTXF_* (any flags)
26 * [Request 2: netif_tx_extra] (only if request 1 has NETTXF_extra_info) 26 * [Request 2: xen_netif_extra_info] (only if request 1 has XEN_NETTXF_extra_info)
27 * [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_MORE) 27 * [Request 3: xen_netif_extra_info] (only if request 2 has XEN_NETIF_EXTRA_MORE)
28 * Request 4: netif_tx_request -- NETTXF_more_data 28 * Request 4: xen_netif_tx_request -- XEN_NETTXF_more_data
29 * Request 5: netif_tx_request -- NETTXF_more_data 29 * Request 5: xen_netif_tx_request -- XEN_NETTXF_more_data
30 * ... 30 * ...
31 * Request N: netif_tx_request -- 0 31 * Request N: xen_netif_tx_request -- 0
32 */ 32 */
33 33
34/* Protocol checksum field is blank in the packet (hardware offload)? */ 34/* Protocol checksum field is blank in the packet (hardware offload)? */
35#define _NETTXF_csum_blank (0) 35#define _XEN_NETTXF_csum_blank (0)
36#define NETTXF_csum_blank (1U<<_NETTXF_csum_blank) 36#define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank)
37 37
38/* Packet data has been validated against protocol checksum. */ 38/* Packet data has been validated against protocol checksum. */
39#define _NETTXF_data_validated (1) 39#define _XEN_NETTXF_data_validated (1)
40#define NETTXF_data_validated (1U<<_NETTXF_data_validated) 40#define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated)
41 41
42/* Packet continues in the next request descriptor. */ 42/* Packet continues in the next request descriptor. */
43#define _NETTXF_more_data (2) 43#define _XEN_NETTXF_more_data (2)
44#define NETTXF_more_data (1U<<_NETTXF_more_data) 44#define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data)
45 45
46/* Packet to be followed by extra descriptor(s). */ 46/* Packet to be followed by extra descriptor(s). */
47#define _NETTXF_extra_info (3) 47#define _XEN_NETTXF_extra_info (3)
48#define NETTXF_extra_info (1U<<_NETTXF_extra_info) 48#define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info)
49 49
50struct xen_netif_tx_request { 50struct xen_netif_tx_request {
51 grant_ref_t gref; /* Reference to buffer page */ 51 grant_ref_t gref; /* Reference to buffer page */
52 uint16_t offset; /* Offset within buffer page */ 52 uint16_t offset; /* Offset within buffer page */
53 uint16_t flags; /* NETTXF_* */ 53 uint16_t flags; /* XEN_NETTXF_* */
54 uint16_t id; /* Echoed in response message. */ 54 uint16_t id; /* Echoed in response message. */
55 uint16_t size; /* Packet size in bytes. */ 55 uint16_t size; /* Packet size in bytes. */
56}; 56};
57 57
58/* Types of netif_extra_info descriptors. */ 58/* Types of xen_netif_extra_info descriptors. */
59#define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */ 59#define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */
60#define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */ 60#define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */
61#define XEN_NETIF_EXTRA_TYPE_MAX (2) 61#define XEN_NETIF_EXTRA_TYPE_MAX (2)
62 62
63/* netif_extra_info flags. */ 63/* xen_netif_extra_info flags. */
64#define _XEN_NETIF_EXTRA_FLAG_MORE (0) 64#define _XEN_NETIF_EXTRA_FLAG_MORE (0)
65#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE) 65#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
66 66
67/* GSO types - only TCPv4 currently supported. */ 67/* GSO types - only TCPv4 currently supported. */
68#define XEN_NETIF_GSO_TYPE_TCPV4 (1) 68#define XEN_NETIF_GSO_TYPE_TCPV4 (1)
69 69
70/* 70/*
71 * This structure needs to fit within both netif_tx_request and 71 * This structure needs to fit within both netif_tx_request and
@@ -107,7 +107,7 @@ struct xen_netif_extra_info {
107 107
108struct xen_netif_tx_response { 108struct xen_netif_tx_response {
109 uint16_t id; 109 uint16_t id;
110 int16_t status; /* NETIF_RSP_* */ 110 int16_t status; /* XEN_NETIF_RSP_* */
111}; 111};
112 112
113struct xen_netif_rx_request { 113struct xen_netif_rx_request {
@@ -116,25 +116,29 @@ struct xen_netif_rx_request {
116}; 116};
117 117
118/* Packet data has been validated against protocol checksum. */ 118/* Packet data has been validated against protocol checksum. */
119#define _NETRXF_data_validated (0) 119#define _XEN_NETRXF_data_validated (0)
120#define NETRXF_data_validated (1U<<_NETRXF_data_validated) 120#define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated)
121 121
122/* Protocol checksum field is blank in the packet (hardware offload)? */ 122/* Protocol checksum field is blank in the packet (hardware offload)? */
123#define _NETRXF_csum_blank (1) 123#define _XEN_NETRXF_csum_blank (1)
124#define NETRXF_csum_blank (1U<<_NETRXF_csum_blank) 124#define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank)
125 125
126/* Packet continues in the next request descriptor. */ 126/* Packet continues in the next request descriptor. */
127#define _NETRXF_more_data (2) 127#define _XEN_NETRXF_more_data (2)
128#define NETRXF_more_data (1U<<_NETRXF_more_data) 128#define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data)
129 129
130/* Packet to be followed by extra descriptor(s). */ 130/* Packet to be followed by extra descriptor(s). */
131#define _NETRXF_extra_info (3) 131#define _XEN_NETRXF_extra_info (3)
132#define NETRXF_extra_info (1U<<_NETRXF_extra_info) 132#define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info)
133
134/* GSO Prefix descriptor. */
135#define _XEN_NETRXF_gso_prefix (4)
136#define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix)
133 137
134struct xen_netif_rx_response { 138struct xen_netif_rx_response {
135 uint16_t id; 139 uint16_t id;
136 uint16_t offset; /* Offset in page of start of received packet */ 140 uint16_t offset; /* Offset in page of start of received packet */
137 uint16_t flags; /* NETRXF_* */ 141 uint16_t flags; /* XEN_NETRXF_* */
138 int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */ 142 int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
139}; 143};
140 144
@@ -149,10 +153,10 @@ DEFINE_RING_TYPES(xen_netif_rx,
149 struct xen_netif_rx_request, 153 struct xen_netif_rx_request,
150 struct xen_netif_rx_response); 154 struct xen_netif_rx_response);
151 155
152#define NETIF_RSP_DROPPED -2 156#define XEN_NETIF_RSP_DROPPED -2
153#define NETIF_RSP_ERROR -1 157#define XEN_NETIF_RSP_ERROR -1
154#define NETIF_RSP_OKAY 0 158#define XEN_NETIF_RSP_OKAY 0
155/* No response: used for auxiliary requests (e.g., netif_tx_extra). */ 159/* No response: used for auxiliary requests (e.g., xen_netif_extra_info). */
156#define NETIF_RSP_NULL 1 160#define XEN_NETIF_RSP_NULL 1
157 161
158#endif 162#endif
diff --git a/include/xen/interface/io/pciif.h b/include/xen/interface/io/pciif.h
new file mode 100644
index 000000000000..d9922ae36eb5
--- /dev/null
+++ b/include/xen/interface/io/pciif.h
@@ -0,0 +1,112 @@
1/*
2 * PCI Backend/Frontend Common Data Structures & Macros
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 *
22 * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
23 */
24#ifndef __XEN_PCI_COMMON_H__
25#define __XEN_PCI_COMMON_H__
26
27/* Be sure to bump this number if you change this file */
28#define XEN_PCI_MAGIC "7"
29
30/* xen_pci_sharedinfo flags */
31#define _XEN_PCIF_active (0)
32#define XEN_PCIF_active (1<<_XEN_PCIF_active)
33#define _XEN_PCIB_AERHANDLER (1)
34#define XEN_PCIB_AERHANDLER (1<<_XEN_PCIB_AERHANDLER)
35#define _XEN_PCIB_active (2)
36#define XEN_PCIB_active (1<<_XEN_PCIB_active)
37
38/* xen_pci_op commands */
39#define XEN_PCI_OP_conf_read (0)
40#define XEN_PCI_OP_conf_write (1)
41#define XEN_PCI_OP_enable_msi (2)
42#define XEN_PCI_OP_disable_msi (3)
43#define XEN_PCI_OP_enable_msix (4)
44#define XEN_PCI_OP_disable_msix (5)
45#define XEN_PCI_OP_aer_detected (6)
46#define XEN_PCI_OP_aer_resume (7)
47#define XEN_PCI_OP_aer_mmio (8)
48#define XEN_PCI_OP_aer_slotreset (9)
49
50/* xen_pci_op error numbers */
51#define XEN_PCI_ERR_success (0)
52#define XEN_PCI_ERR_dev_not_found (-1)
53#define XEN_PCI_ERR_invalid_offset (-2)
54#define XEN_PCI_ERR_access_denied (-3)
55#define XEN_PCI_ERR_not_implemented (-4)
56/* XEN_PCI_ERR_op_failed - backend failed to complete the operation */
57#define XEN_PCI_ERR_op_failed (-5)
58
59/*
60 * it should be PAGE_SIZE-sizeof(struct xen_pci_op))/sizeof(struct msix_entry))
61 * Should not exceed 128
62 */
63#define SH_INFO_MAX_VEC 128
64
65struct xen_msix_entry {
66 uint16_t vector;
67 uint16_t entry;
68};
69struct xen_pci_op {
70 /* IN: what action to perform: XEN_PCI_OP_* */
71 uint32_t cmd;
72
73 /* OUT: will contain an error number (if any) from errno.h */
74 int32_t err;
75
76 /* IN: which device to touch */
77 uint32_t domain; /* PCI Domain/Segment */
78 uint32_t bus;
79 uint32_t devfn;
80
81 /* IN: which configuration registers to touch */
82 int32_t offset;
83 int32_t size;
84
85 /* IN/OUT: Contains the result after a READ or the value to WRITE */
86 uint32_t value;
87 /* IN: Contains extra infor for this operation */
88 uint32_t info;
89 /*IN: param for msi-x */
90 struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
91};
92
93/*used for pcie aer handling*/
94struct xen_pcie_aer_op {
95 /* IN: what action to perform: XEN_PCI_OP_* */
96 uint32_t cmd;
97 /*IN/OUT: return aer_op result or carry error_detected state as input*/
98 int32_t err;
99
100 /* IN: which device to touch */
101 uint32_t domain; /* PCI Domain/Segment*/
102 uint32_t bus;
103 uint32_t devfn;
104};
105struct xen_pci_sharedinfo {
106 /* flags - XEN_PCIF_* */
107 uint32_t flags;
108 struct xen_pci_op op;
109 struct xen_pcie_aer_op aer_op;
110};
111
112#endif /* __XEN_PCI_COMMON_H__ */
diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h
index e8cbf431c8cc..75271b9a8f61 100644
--- a/include/xen/interface/io/ring.h
+++ b/include/xen/interface/io/ring.h
@@ -24,8 +24,15 @@ typedef unsigned int RING_IDX;
24 * A ring contains as many entries as will fit, rounded down to the nearest 24 * A ring contains as many entries as will fit, rounded down to the nearest
25 * power of two (so we can mask with (size-1) to loop around). 25 * power of two (so we can mask with (size-1) to loop around).
26 */ 26 */
27#define __RING_SIZE(_s, _sz) \ 27#define __CONST_RING_SIZE(_s, _sz) \
28 (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) 28 (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
29 sizeof(((struct _s##_sring *)0)->ring[0])))
30
31/*
32 * The same for passing in an actual pointer instead of a name tag.
33 */
34#define __RING_SIZE(_s, _sz) \
35 (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
29 36
30/* 37/*
31 * Macros to make the correct C datatypes for a new kind of ring. 38 * Macros to make the correct C datatypes for a new kind of ring.
diff --git a/include/xen/interface/io/xenbus.h b/include/xen/interface/io/xenbus.h
index 46508c7fa399..9fda532973a5 100644
--- a/include/xen/interface/io/xenbus.h
+++ b/include/xen/interface/io/xenbus.h
@@ -27,8 +27,14 @@ enum xenbus_state
27 XenbusStateClosing = 5, /* The device is being closed 27 XenbusStateClosing = 5, /* The device is being closed
28 due to an error or an unplug 28 due to an error or an unplug
29 event. */ 29 event. */
30 XenbusStateClosed = 6 30 XenbusStateClosed = 6,
31 31
32 /*
33 * Reconfiguring: The device is being reconfigured.
34 */
35 XenbusStateReconfiguring = 7,
36
37 XenbusStateReconfigured = 8
32}; 38};
33 39
34#endif /* _XEN_PUBLIC_IO_XENBUS_H */ 40#endif /* _XEN_PUBLIC_IO_XENBUS_H */
diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index d3938d3e71f8..eac3ce153719 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -141,6 +141,19 @@ struct xen_machphys_mfn_list {
141DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list); 141DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
142 142
143/* 143/*
144 * Returns the location in virtual address space of the machine_to_phys
145 * mapping table. Architectures which do not have a m2p table, or which do not
146 * map it by default into guest address space, do not implement this command.
147 * arg == addr of xen_machphys_mapping_t.
148 */
149#define XENMEM_machphys_mapping 12
150struct xen_machphys_mapping {
151 unsigned long v_start, v_end; /* Start and end virtual addresses. */
152 unsigned long max_mfn; /* Maximum MFN that can be looked up. */
153};
154DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
155
156/*
144 * Sets the GPFN at which a particular page appears in the specified guest's 157 * Sets the GPFN at which a particular page appears in the specified guest's
145 * pseudophysical address space. 158 * pseudophysical address space.
146 * arg == addr of xen_add_to_physmap_t. 159 * arg == addr of xen_add_to_physmap_t.
@@ -186,6 +199,35 @@ struct xen_translate_gpfn_list {
186}; 199};
187DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list); 200DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
188 201
202/*
203 * Returns the pseudo-physical memory map as it was when the domain
204 * was started (specified by XENMEM_set_memory_map).
205 * arg == addr of struct xen_memory_map.
206 */
207#define XENMEM_memory_map 9
208struct xen_memory_map {
209 /*
210 * On call the number of entries which can be stored in buffer. On
211 * return the number of entries which have been stored in
212 * buffer.
213 */
214 unsigned int nr_entries;
215
216 /*
217 * Entries in the buffer are in the same format as returned by the
218 * BIOS INT 0x15 EAX=0xE820 call.
219 */
220 GUEST_HANDLE(void) buffer;
221};
222DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map);
223
224/*
225 * Returns the real physical memory map. Passes the same structure as
226 * XENMEM_memory_map.
227 * arg == addr of struct xen_memory_map.
228 */
229#define XENMEM_machine_memory_map 10
230
189 231
190/* 232/*
191 * Prevent the balloon driver from changing the memory reservation 233 * Prevent the balloon driver from changing the memory reservation
diff --git a/include/xen/interface/physdev.h b/include/xen/interface/physdev.h
index cd6939147cb6..534cac89a77d 100644
--- a/include/xen/interface/physdev.h
+++ b/include/xen/interface/physdev.h
@@ -106,6 +106,57 @@ struct physdev_irq {
106 uint32_t vector; 106 uint32_t vector;
107}; 107};
108 108
109#define MAP_PIRQ_TYPE_MSI 0x0
110#define MAP_PIRQ_TYPE_GSI 0x1
111#define MAP_PIRQ_TYPE_UNKNOWN 0x2
112
113#define PHYSDEVOP_map_pirq 13
114struct physdev_map_pirq {
115 domid_t domid;
116 /* IN */
117 int type;
118 /* IN */
119 int index;
120 /* IN or OUT */
121 int pirq;
122 /* IN */
123 int bus;
124 /* IN */
125 int devfn;
126 /* IN */
127 int entry_nr;
128 /* IN */
129 uint64_t table_base;
130};
131
132#define PHYSDEVOP_unmap_pirq 14
133struct physdev_unmap_pirq {
134 domid_t domid;
135 /* IN */
136 int pirq;
137};
138
139#define PHYSDEVOP_manage_pci_add 15
140#define PHYSDEVOP_manage_pci_remove 16
141struct physdev_manage_pci {
142 /* IN */
143 uint8_t bus;
144 uint8_t devfn;
145};
146
147#define PHYSDEVOP_manage_pci_add_ext 20
148struct physdev_manage_pci_ext {
149 /* IN */
150 uint8_t bus;
151 uint8_t devfn;
152 unsigned is_extfn;
153 unsigned is_virtfn;
154 struct {
155 uint8_t bus;
156 uint8_t devfn;
157 } physfn;
158};
159
109/* 160/*
110 * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() 161 * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
111 * hypercall since 0x00030202. 162 * hypercall since 0x00030202.
@@ -121,6 +172,32 @@ struct physdev_op {
121 } u; 172 } u;
122}; 173};
123 174
175#define PHYSDEVOP_setup_gsi 21
176struct physdev_setup_gsi {
177 int gsi;
178 /* IN */
179 uint8_t triggering;
180 /* IN */
181 uint8_t polarity;
182 /* IN */
183};
184
185#define PHYSDEVOP_get_nr_pirqs 22
186struct physdev_nr_pirqs {
187 /* OUT */
188 uint32_t nr_pirqs;
189};
190
191/* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI
192 * the hypercall returns a free pirq */
193#define PHYSDEVOP_get_free_pirq 23
194struct physdev_get_free_pirq {
195 /* IN */
196 int type;
197 /* OUT */
198 uint32_t pirq;
199};
200
124/* 201/*
125 * Notify that some PIRQ-bound event channels have been unmasked. 202 * Notify that some PIRQ-bound event channels have been unmasked.
126 * ** This command is obsolete since interface version 0x00030202 and is ** 203 * ** This command is obsolete since interface version 0x00030202 and is **
diff --git a/include/xen/interface/sched.h b/include/xen/interface/sched.h
index 5fec575a800a..dd55dac340de 100644
--- a/include/xen/interface/sched.h
+++ b/include/xen/interface/sched.h
@@ -65,6 +65,39 @@ struct sched_poll {
65DEFINE_GUEST_HANDLE_STRUCT(sched_poll); 65DEFINE_GUEST_HANDLE_STRUCT(sched_poll);
66 66
67/* 67/*
68 * Declare a shutdown for another domain. The main use of this function is
69 * in interpreting shutdown requests and reasons for fully-virtualized
70 * domains. A para-virtualized domain may use SCHEDOP_shutdown directly.
71 * @arg == pointer to sched_remote_shutdown structure.
72 */
73#define SCHEDOP_remote_shutdown 4
74struct sched_remote_shutdown {
75 domid_t domain_id; /* Remote domain ID */
76 unsigned int reason; /* SHUTDOWN_xxx reason */
77};
78
79/*
80 * Latch a shutdown code, so that when the domain later shuts down it
81 * reports this code to the control tools.
82 * @arg == as for SCHEDOP_shutdown.
83 */
84#define SCHEDOP_shutdown_code 5
85
86/*
87 * Setup, poke and destroy a domain watchdog timer.
88 * @arg == pointer to sched_watchdog structure.
89 * With id == 0, setup a domain watchdog timer to cause domain shutdown
90 * after timeout, returns watchdog id.
91 * With id != 0 and timeout == 0, destroy domain watchdog timer.
92 * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
93 */
94#define SCHEDOP_watchdog 6
95struct sched_watchdog {
96 uint32_t id; /* watchdog ID */
97 uint32_t timeout; /* timeout */
98};
99
100/*
68 * Reason codes for SCHEDOP_shutdown. These may be interpreted by control 101 * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
69 * software to determine the appropriate action. For the most part, Xen does 102 * software to determine the appropriate action. For the most part, Xen does
70 * not care about the shutdown code. 103 * not care about the shutdown code.
@@ -73,5 +106,6 @@ DEFINE_GUEST_HANDLE_STRUCT(sched_poll);
73#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */ 106#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
74#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */ 107#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
75#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */ 108#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
109#define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */
76 110
77#endif /* __XEN_PUBLIC_SCHED_H__ */ 111#endif /* __XEN_PUBLIC_SCHED_H__ */
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index 2befa3e2f1bc..70213b4515eb 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -30,7 +30,7 @@
30#define __HYPERVISOR_stack_switch 3 30#define __HYPERVISOR_stack_switch 3
31#define __HYPERVISOR_set_callbacks 4 31#define __HYPERVISOR_set_callbacks 4
32#define __HYPERVISOR_fpu_taskswitch 5 32#define __HYPERVISOR_fpu_taskswitch 5
33#define __HYPERVISOR_sched_op 6 33#define __HYPERVISOR_sched_op_compat 6
34#define __HYPERVISOR_dom0_op 7 34#define __HYPERVISOR_dom0_op 7
35#define __HYPERVISOR_set_debugreg 8 35#define __HYPERVISOR_set_debugreg 8
36#define __HYPERVISOR_get_debugreg 9 36#define __HYPERVISOR_get_debugreg 9
@@ -52,12 +52,13 @@
52#define __HYPERVISOR_mmuext_op 26 52#define __HYPERVISOR_mmuext_op 26
53#define __HYPERVISOR_acm_op 27 53#define __HYPERVISOR_acm_op 27
54#define __HYPERVISOR_nmi_op 28 54#define __HYPERVISOR_nmi_op 28
55#define __HYPERVISOR_sched_op_new 29 55#define __HYPERVISOR_sched_op 29
56#define __HYPERVISOR_callback_op 30 56#define __HYPERVISOR_callback_op 30
57#define __HYPERVISOR_xenoprof_op 31 57#define __HYPERVISOR_xenoprof_op 31
58#define __HYPERVISOR_event_channel_op 32 58#define __HYPERVISOR_event_channel_op 32
59#define __HYPERVISOR_physdev_op 33 59#define __HYPERVISOR_physdev_op 33
60#define __HYPERVISOR_hvm_op 34 60#define __HYPERVISOR_hvm_op 34
61#define __HYPERVISOR_tmem_op 38
61 62
62/* Architecture-specific hypercall definitions. */ 63/* Architecture-specific hypercall definitions. */
63#define __HYPERVISOR_arch_0 48 64#define __HYPERVISOR_arch_0 48
@@ -461,6 +462,27 @@ typedef uint8_t xen_domain_handle_t[16];
461#define __mk_unsigned_long(x) x ## UL 462#define __mk_unsigned_long(x) x ## UL
462#define mk_unsigned_long(x) __mk_unsigned_long(x) 463#define mk_unsigned_long(x) __mk_unsigned_long(x)
463 464
465#define TMEM_SPEC_VERSION 1
466
467struct tmem_op {
468 uint32_t cmd;
469 int32_t pool_id;
470 union {
471 struct { /* for cmd == TMEM_NEW_POOL */
472 uint64_t uuid[2];
473 uint32_t flags;
474 } new;
475 struct {
476 uint64_t oid[3];
477 uint32_t index;
478 uint32_t tmem_offset;
479 uint32_t pfn_offset;
480 uint32_t len;
481 GUEST_HANDLE(void) gmfn; /* guest machine page frame */
482 } gen;
483 } u;
484};
485
464#else /* __ASSEMBLY__ */ 486#else /* __ASSEMBLY__ */
465 487
466/* In assembly code we cannot use C numeric constant suffixes. */ 488/* In assembly code we cannot use C numeric constant suffixes. */
diff --git a/include/xen/page.h b/include/xen/page.h
index eaf85fab1263..0be36b976f4b 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -1 +1,8 @@
1#ifndef _XEN_PAGE_H
2#define _XEN_PAGE_H
3
1#include <asm/xen/page.h> 4#include <asm/xen/page.h>
5
6extern phys_addr_t xen_extra_mem_start, xen_extra_mem_size;
7
8#endif /* _XEN_PAGE_H */
diff --git a/include/xen/privcmd.h b/include/xen/privcmd.h
new file mode 100644
index 000000000000..17857fb4d550
--- /dev/null
+++ b/include/xen/privcmd.h
@@ -0,0 +1,77 @@
1/******************************************************************************
2 * privcmd.h
3 *
4 * Interface to /proc/xen/privcmd.
5 *
6 * Copyright (c) 2003-2005, K A Fraser
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
32
33#ifndef __LINUX_PUBLIC_PRIVCMD_H__
34#define __LINUX_PUBLIC_PRIVCMD_H__
35
36#include <linux/types.h>
37#include <linux/compiler.h>
38
39typedef unsigned long xen_pfn_t;
40
41struct privcmd_hypercall {
42 __u64 op;
43 __u64 arg[5];
44};
45
46struct privcmd_mmap_entry {
47 __u64 va;
48 __u64 mfn;
49 __u64 npages;
50};
51
52struct privcmd_mmap {
53 int num;
54 domid_t dom; /* target domain */
55 struct privcmd_mmap_entry __user *entry;
56};
57
58struct privcmd_mmapbatch {
59 int num; /* number of pages to populate */
60 domid_t dom; /* target domain */
61 __u64 addr; /* virtual address */
62 xen_pfn_t __user *arr; /* array of mfns - top nibble set on err */
63};
64
65/*
66 * @cmd: IOCTL_PRIVCMD_HYPERCALL
67 * @arg: &privcmd_hypercall_t
68 * Return: Value returned from execution of the specified hypercall.
69 */
70#define IOCTL_PRIVCMD_HYPERCALL \
71 _IOC(_IOC_NONE, 'P', 0, sizeof(struct privcmd_hypercall))
72#define IOCTL_PRIVCMD_MMAP \
73 _IOC(_IOC_NONE, 'P', 2, sizeof(struct privcmd_mmap))
74#define IOCTL_PRIVCMD_MMAPBATCH \
75 _IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch))
76
77#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index 351f4051f6d8..03c85d7387fb 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -5,9 +5,9 @@
5 5
6DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); 6DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
7 7
8void xen_pre_suspend(void); 8void xen_arch_pre_suspend(void);
9void xen_post_suspend(int suspend_cancelled); 9void xen_arch_post_suspend(int suspend_cancelled);
10void xen_hvm_post_suspend(int suspend_cancelled); 10void xen_arch_hvm_post_suspend(int suspend_cancelled);
11 11
12void xen_mm_pin_all(void); 12void xen_mm_pin_all(void);
13void xen_mm_unpin_all(void); 13void xen_mm_unpin_all(void);
@@ -23,4 +23,9 @@ int xen_create_contiguous_region(unsigned long vstart, unsigned int order,
23 23
24void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order); 24void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
25 25
26int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
27 unsigned long addr,
28 unsigned long mfn, int nr,
29 pgprot_t prot, unsigned domid);
30
26#endif /* INCLUDE_XEN_OPS_H */ 31#endif /* INCLUDE_XEN_OPS_H */
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index 43e2d7d33976..5467369e0889 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -92,9 +92,9 @@ struct xenbus_driver {
92 void (*otherend_changed)(struct xenbus_device *dev, 92 void (*otherend_changed)(struct xenbus_device *dev,
93 enum xenbus_state backend_state); 93 enum xenbus_state backend_state);
94 int (*remove)(struct xenbus_device *dev); 94 int (*remove)(struct xenbus_device *dev);
95 int (*suspend)(struct xenbus_device *dev, pm_message_t state); 95 int (*suspend)(struct xenbus_device *dev);
96 int (*resume)(struct xenbus_device *dev); 96 int (*resume)(struct xenbus_device *dev);
97 int (*uevent)(struct xenbus_device *, char **, int, char *, int); 97 int (*uevent)(struct xenbus_device *, struct kobj_uevent_env *);
98 struct device_driver driver; 98 struct device_driver driver;
99 int (*read_otherend_details)(struct xenbus_device *dev); 99 int (*read_otherend_details)(struct xenbus_device *dev);
100 int (*is_ready)(struct xenbus_device *dev); 100 int (*is_ready)(struct xenbus_device *dev);