aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-arm/plat-s3c/iic.h33
-rw-r--r--include/asm-arm/plat-s3c/nand.h50
-rw-r--r--include/asm-arm/plat-s3c/regs-ac97.h67
-rw-r--r--include/asm-arm/plat-s3c/regs-iic.h56
-rw-r--r--include/asm-arm/plat-s3c/regs-nand.h123
-rw-r--r--include/asm-arm/plat-s3c/regs-rtc.h61
-rw-r--r--include/asm-arm/plat-s3c/regs-watchdog.h41
-rw-r--r--include/asm-arm/plat-s3c24xx/mci.h15
-rw-r--r--include/asm-arm/plat-s3c24xx/regs-spi.h82
-rw-r--r--include/asm-arm/plat-s3c24xx/regs-udc.h153
-rw-r--r--include/asm-arm/plat-s3c24xx/udc.h36
-rw-r--r--include/asm-generic/bug.h7
-rw-r--r--include/drm/Kbuild2
-rw-r--r--include/drm/drm.h24
-rw-r--r--include/drm/drmP.h108
-rw-r--r--include/drm/drm_crtc.h733
-rw-r--r--include/drm/drm_crtc_helper.h124
-rw-r--r--include/drm/drm_edid.h202
-rw-r--r--include/drm/drm_mode.h271
-rw-r--r--include/drm/drm_sarea.h6
-rw-r--r--include/drm/i915_drm.h41
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/aio.h5
-rw-r--r--include/linux/bio.h26
-rw-r--r--include/linux/blkdev.h52
-rw-r--r--include/linux/bottom_half.h1
-rw-r--r--include/linux/buffer_head.h1
-rw-r--r--include/linux/console.h4
-rw-r--r--include/linux/debug_locks.h2
-rw-r--r--include/linux/dmi.h3
-rw-r--r--include/linux/elevator.h8
-rw-r--r--include/linux/fault-inject.h9
-rw-r--r--include/linux/futex.h5
-rw-r--r--include/linux/genhd.h1
-rw-r--r--include/linux/hardirq.h13
-rw-r--r--include/linux/hrtimer.h34
-rw-r--r--include/linux/ide.h37
-rw-r--r--include/linux/interrupt.h5
-rw-r--r--include/linux/irq.h62
-rw-r--r--include/linux/irqnr.h26
-rw-r--r--include/linux/jiffies.h10
-rw-r--r--include/linux/kernel.h11
-rw-r--r--include/linux/kernel_stat.h14
-rw-r--r--include/linux/lguest_launcher.h6
-rw-r--r--include/linux/libata.h71
-rw-r--r--include/linux/lockd/bind.h1
-rw-r--r--include/linux/lockd/lockd.h4
-rw-r--r--include/linux/lockdep.h45
-rw-r--r--include/linux/mm_types.h5
-rw-r--r--include/linux/msi.h3
-rw-r--r--include/linux/mutex.h2
-rw-r--r--include/linux/nfs_fs.h17
-rw-r--r--include/linux/nfs_fs_sb.h6
-rw-r--r--include/linux/nfs_mount.h3
-rw-r--r--include/linux/nfs_xdr.h7
-rw-r--r--include/linux/nfsd/state.h2
-rw-r--r--include/linux/of_platform.h3
-rw-r--r--include/linux/oprofile.h3
-rw-r--r--include/linux/posix-timers.h6
-rw-r--r--include/linux/random.h51
-rw-r--r--include/linux/rcuclassic.h2
-rw-r--r--include/linux/rcupdate.h10
-rw-r--r--include/linux/rcutree.h329
-rw-r--r--include/linux/ring_buffer.h2
-rw-r--r--include/linux/serial_core.h2
-rw-r--r--include/linux/slab.h10
-rw-r--r--include/linux/sunrpc/clnt.h2
-rw-r--r--include/linux/sunrpc/rpc_pipe_fs.h1
-rw-r--r--include/linux/sunrpc/svcauth_gss.h1
-rw-r--r--include/linux/sunrpc/xdr.h15
-rw-r--r--include/linux/sunrpc/xprt.h3
-rw-r--r--include/linux/swiotlb.h22
-rw-r--r--include/linux/timex.h73
-rw-r--r--include/linux/types.h11
-rw-r--r--include/linux/uaccess.h2
-rw-r--r--include/linux/videodev2.h14
-rw-r--r--include/linux/virtio_balloon.h3
-rw-r--r--include/linux/virtio_console.h11
-rw-r--r--include/linux/virtio_pci.h8
-rw-r--r--include/linux/virtio_ring.h13
-rw-r--r--include/media/i2c-addr.h2
-rw-r--r--include/media/ir-common.h2
-rw-r--r--include/media/ov772x.h21
-rw-r--r--include/media/saa7146_vv.h3
-rw-r--r--include/media/soc_camera.h111
-rw-r--r--include/media/tvp514x.h118
-rw-r--r--include/media/tw9910.h39
-rw-r--r--include/media/v4l2-chip-ident.h10
-rw-r--r--include/media/v4l2-common.h41
-rw-r--r--include/media/v4l2-dev.h51
-rw-r--r--include/media/v4l2-device.h109
-rw-r--r--include/media/v4l2-int-device.h6
-rw-r--r--include/media/v4l2-ioctl.h14
-rw-r--r--include/media/v4l2-subdev.h189
-rw-r--r--include/scsi/fc/fc_els.h816
-rw-r--r--include/scsi/fc/fc_encaps.h138
-rw-r--r--include/scsi/fc/fc_fc2.h124
-rw-r--r--include/scsi/fc/fc_fcoe.h114
-rw-r--r--include/scsi/fc/fc_fcp.h199
-rw-r--r--include/scsi/fc/fc_fs.h340
-rw-r--r--include/scsi/fc/fc_gs.h93
-rw-r--r--include/scsi/fc/fc_ns.h159
-rw-r--r--include/scsi/fc_encode.h309
-rw-r--r--include/scsi/fc_frame.h242
-rw-r--r--include/scsi/fc_transport_fcoe.h54
-rw-r--r--include/scsi/iscsi_if.h7
-rw-r--r--include/scsi/libfc.h938
-rw-r--r--include/scsi/libfcoe.h176
-rw-r--r--include/scsi/libiscsi.h39
-rw-r--r--include/scsi/libiscsi_tcp.h132
-rw-r--r--include/scsi/scsi_device.h7
-rw-r--r--include/scsi/scsi_transport_iscsi.h12
112 files changed, 6917 insertions, 1032 deletions
diff --git a/include/asm-arm/plat-s3c/iic.h b/include/asm-arm/plat-s3c/iic.h
deleted file mode 100644
index 5106acaa1d0e..000000000000
--- a/include/asm-arm/plat-s3c/iic.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/iic.h
2 *
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - I2C Controller platfrom_device info
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 __ASM_ARCH_IIC_H
14#define __ASM_ARCH_IIC_H __FILE__
15
16#define S3C_IICFLG_FILTER (1<<0) /* enable s3c2440 filter */
17
18/* Notes:
19 * 1) All frequencies are expressed in Hz
20 * 2) A value of zero is `do not care`
21*/
22
23struct s3c2410_platform_i2c {
24 int bus_num; /* bus number to use */
25 unsigned int flags;
26 unsigned int slave_addr; /* slave address for controller */
27 unsigned long bus_freq; /* standard bus frequency */
28 unsigned long max_freq; /* max frequency for the bus */
29 unsigned long min_freq; /* min frequency for the bus */
30 unsigned int sda_delay; /* pclks (s3c2440 only) */
31};
32
33#endif /* __ASM_ARCH_IIC_H */
diff --git a/include/asm-arm/plat-s3c/nand.h b/include/asm-arm/plat-s3c/nand.h
deleted file mode 100644
index f4dcd14af059..000000000000
--- a/include/asm-arm/plat-s3c/nand.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/nand.h
2 *
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - NAND device controller platfrom_device info
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/* struct s3c2410_nand_set
14 *
15 * define an set of one or more nand chips registered with an unique mtd
16 *
17 * nr_chips = number of chips in this set
18 * nr_partitions = number of partitions pointed to be partitoons (or zero)
19 * name = name of set (optional)
20 * nr_map = map for low-layer logical to physical chip numbers (option)
21 * partitions = mtd partition list
22*/
23
24struct s3c2410_nand_set {
25 unsigned int disable_ecc : 1;
26
27 int nr_chips;
28 int nr_partitions;
29 char *name;
30 int *nr_map;
31 struct mtd_partition *partitions;
32 struct nand_ecclayout *ecc_layout;
33};
34
35struct s3c2410_platform_nand {
36 /* timing information for controller, all times in nanoseconds */
37
38 int tacls; /* time for active CLE/ALE to nWE/nOE */
39 int twrph0; /* active time for nWE/nOE */
40 int twrph1; /* time for release CLE/ALE from nWE/nOE inactive */
41
42 unsigned int ignore_unset_ecc : 1;
43
44 int nr_sets;
45 struct s3c2410_nand_set *sets;
46
47 void (*select_chip)(struct s3c2410_nand_set *,
48 int chip);
49};
50
diff --git a/include/asm-arm/plat-s3c/regs-ac97.h b/include/asm-arm/plat-s3c/regs-ac97.h
deleted file mode 100644
index c3878f7acb83..000000000000
--- a/include/asm-arm/plat-s3c/regs-ac97.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-ac97.h
2 *
3 * Copyright (c) 2006 Simtec Electronics <linux@simtec.co.uk>
4 * http://www.simtec.co.uk/products/SWLINUX/
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 * S3C2440 AC97 Controller
11*/
12
13#ifndef __ASM_ARCH_REGS_AC97_H
14#define __ASM_ARCH_REGS_AC97_H __FILE__
15
16#define S3C_AC97_GLBCTRL (0x00)
17
18#define S3C_AC97_GLBCTRL_CODECREADYIE (1<<22)
19#define S3C_AC97_GLBCTRL_PCMOUTURIE (1<<21)
20#define S3C_AC97_GLBCTRL_PCMINORIE (1<<20)
21#define S3C_AC97_GLBCTRL_MICINORIE (1<<19)
22#define S3C_AC97_GLBCTRL_PCMOUTTIE (1<<18)
23#define S3C_AC97_GLBCTRL_PCMINTIE (1<<17)
24#define S3C_AC97_GLBCTRL_MICINTIE (1<<16)
25#define S3C_AC97_GLBCTRL_PCMOUTTM_OFF (0<<12)
26#define S3C_AC97_GLBCTRL_PCMOUTTM_PIO (1<<12)
27#define S3C_AC97_GLBCTRL_PCMOUTTM_DMA (2<<12)
28#define S3C_AC97_GLBCTRL_PCMOUTTM_MASK (3<<12)
29#define S3C_AC97_GLBCTRL_PCMINTM_OFF (0<<10)
30#define S3C_AC97_GLBCTRL_PCMINTM_PIO (1<<10)
31#define S3C_AC97_GLBCTRL_PCMINTM_DMA (2<<10)
32#define S3C_AC97_GLBCTRL_PCMINTM_MASK (3<<10)
33#define S3C_AC97_GLBCTRL_MICINTM_OFF (0<<8)
34#define S3C_AC97_GLBCTRL_MICINTM_PIO (1<<8)
35#define S3C_AC97_GLBCTRL_MICINTM_DMA (2<<8)
36#define S3C_AC97_GLBCTRL_MICINTM_MASK (3<<8)
37#define S3C_AC97_GLBCTRL_TRANSFERDATAENABLE (1<<3)
38#define S3C_AC97_GLBCTRL_ACLINKON (1<<2)
39#define S3C_AC97_GLBCTRL_WARMRESET (1<<1)
40#define S3C_AC97_GLBCTRL_COLDRESET (1<<0)
41
42#define S3C_AC97_GLBSTAT (0x04)
43
44#define S3C_AC97_GLBSTAT_CODECREADY (1<<22)
45#define S3C_AC97_GLBSTAT_PCMOUTUR (1<<21)
46#define S3C_AC97_GLBSTAT_PCMINORI (1<<20)
47#define S3C_AC97_GLBSTAT_MICINORI (1<<19)
48#define S3C_AC97_GLBSTAT_PCMOUTTI (1<<18)
49#define S3C_AC97_GLBSTAT_PCMINTI (1<<17)
50#define S3C_AC97_GLBSTAT_MICINTI (1<<16)
51#define S3C_AC97_GLBSTAT_MAINSTATE_IDLE (0<<0)
52#define S3C_AC97_GLBSTAT_MAINSTATE_INIT (1<<0)
53#define S3C_AC97_GLBSTAT_MAINSTATE_READY (2<<0)
54#define S3C_AC97_GLBSTAT_MAINSTATE_ACTIVE (3<<0)
55#define S3C_AC97_GLBSTAT_MAINSTATE_LP (4<<0)
56#define S3C_AC97_GLBSTAT_MAINSTATE_WARM (5<<0)
57
58#define S3C_AC97_CODEC_CMD (0x08)
59
60#define S3C_AC97_CODEC_CMD_READ (1<<23)
61
62#define S3C_AC97_STAT (0x0c)
63#define S3C_AC97_PCM_ADDR (0x10)
64#define S3C_AC97_PCM_DATA (0x18)
65#define S3C_AC97_MIC_DATA (0x1C)
66
67#endif /* __ASM_ARCH_REGS_AC97_H */
diff --git a/include/asm-arm/plat-s3c/regs-iic.h b/include/asm-arm/plat-s3c/regs-iic.h
deleted file mode 100644
index 2f7c17de8ac8..000000000000
--- a/include/asm-arm/plat-s3c/regs-iic.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-iic.h
2 *
3 * Copyright (c) 2004 Simtec Electronics <linux@simtec.co.uk>
4 * http://www.simtec.co.uk/products/SWLINUX/
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 * S3C2410 I2C Controller
11*/
12
13#ifndef __ASM_ARCH_REGS_IIC_H
14#define __ASM_ARCH_REGS_IIC_H __FILE__
15
16/* see s3c2410x user guide, v1.1, section 9 (p447) for more info */
17
18#define S3C2410_IICREG(x) (x)
19
20#define S3C2410_IICCON S3C2410_IICREG(0x00)
21#define S3C2410_IICSTAT S3C2410_IICREG(0x04)
22#define S3C2410_IICADD S3C2410_IICREG(0x08)
23#define S3C2410_IICDS S3C2410_IICREG(0x0C)
24#define S3C2440_IICLC S3C2410_IICREG(0x10)
25
26#define S3C2410_IICCON_ACKEN (1<<7)
27#define S3C2410_IICCON_TXDIV_16 (0<<6)
28#define S3C2410_IICCON_TXDIV_512 (1<<6)
29#define S3C2410_IICCON_IRQEN (1<<5)
30#define S3C2410_IICCON_IRQPEND (1<<4)
31#define S3C2410_IICCON_SCALE(x) ((x)&15)
32#define S3C2410_IICCON_SCALEMASK (0xf)
33
34#define S3C2410_IICSTAT_MASTER_RX (2<<6)
35#define S3C2410_IICSTAT_MASTER_TX (3<<6)
36#define S3C2410_IICSTAT_SLAVE_RX (0<<6)
37#define S3C2410_IICSTAT_SLAVE_TX (1<<6)
38#define S3C2410_IICSTAT_MODEMASK (3<<6)
39
40#define S3C2410_IICSTAT_START (1<<5)
41#define S3C2410_IICSTAT_BUSBUSY (1<<5)
42#define S3C2410_IICSTAT_TXRXEN (1<<4)
43#define S3C2410_IICSTAT_ARBITR (1<<3)
44#define S3C2410_IICSTAT_ASSLAVE (1<<2)
45#define S3C2410_IICSTAT_ADDR0 (1<<1)
46#define S3C2410_IICSTAT_LASTBIT (1<<0)
47
48#define S3C2410_IICLC_SDA_DELAY0 (0 << 0)
49#define S3C2410_IICLC_SDA_DELAY5 (1 << 0)
50#define S3C2410_IICLC_SDA_DELAY10 (2 << 0)
51#define S3C2410_IICLC_SDA_DELAY15 (3 << 0)
52#define S3C2410_IICLC_SDA_DELAY_MASK (3 << 0)
53
54#define S3C2410_IICLC_FILTER_ON (1<<2)
55
56#endif /* __ASM_ARCH_REGS_IIC_H */
diff --git a/include/asm-arm/plat-s3c/regs-nand.h b/include/asm-arm/plat-s3c/regs-nand.h
deleted file mode 100644
index b2caa4bca270..000000000000
--- a/include/asm-arm/plat-s3c/regs-nand.h
+++ /dev/null
@@ -1,123 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-nand.h
2 *
3 * Copyright (c) 2004,2005 Simtec Electronics <linux@simtec.co.uk>
4 * http://www.simtec.co.uk/products/SWLINUX/
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 * S3C2410 NAND register definitions
11*/
12
13#ifndef __ASM_ARM_REGS_NAND
14#define __ASM_ARM_REGS_NAND
15
16
17#define S3C2410_NFREG(x) (x)
18
19#define S3C2410_NFCONF S3C2410_NFREG(0x00)
20#define S3C2410_NFCMD S3C2410_NFREG(0x04)
21#define S3C2410_NFADDR S3C2410_NFREG(0x08)
22#define S3C2410_NFDATA S3C2410_NFREG(0x0C)
23#define S3C2410_NFSTAT S3C2410_NFREG(0x10)
24#define S3C2410_NFECC S3C2410_NFREG(0x14)
25
26#define S3C2440_NFCONT S3C2410_NFREG(0x04)
27#define S3C2440_NFCMD S3C2410_NFREG(0x08)
28#define S3C2440_NFADDR S3C2410_NFREG(0x0C)
29#define S3C2440_NFDATA S3C2410_NFREG(0x10)
30#define S3C2440_NFECCD0 S3C2410_NFREG(0x14)
31#define S3C2440_NFECCD1 S3C2410_NFREG(0x18)
32#define S3C2440_NFECCD S3C2410_NFREG(0x1C)
33#define S3C2440_NFSTAT S3C2410_NFREG(0x20)
34#define S3C2440_NFESTAT0 S3C2410_NFREG(0x24)
35#define S3C2440_NFESTAT1 S3C2410_NFREG(0x28)
36#define S3C2440_NFMECC0 S3C2410_NFREG(0x2C)
37#define S3C2440_NFMECC1 S3C2410_NFREG(0x30)
38#define S3C2440_NFSECC S3C2410_NFREG(0x34)
39#define S3C2440_NFSBLK S3C2410_NFREG(0x38)
40#define S3C2440_NFEBLK S3C2410_NFREG(0x3C)
41
42#define S3C2412_NFSBLK S3C2410_NFREG(0x20)
43#define S3C2412_NFEBLK S3C2410_NFREG(0x24)
44#define S3C2412_NFSTAT S3C2410_NFREG(0x28)
45#define S3C2412_NFMECC_ERR0 S3C2410_NFREG(0x2C)
46#define S3C2412_NFMECC_ERR1 S3C2410_NFREG(0x30)
47#define S3C2412_NFMECC0 S3C2410_NFREG(0x34)
48#define S3C2412_NFMECC1 S3C2410_NFREG(0x38)
49#define S3C2412_NFSECC S3C2410_NFREG(0x3C)
50
51#define S3C2410_NFCONF_EN (1<<15)
52#define S3C2410_NFCONF_512BYTE (1<<14)
53#define S3C2410_NFCONF_4STEP (1<<13)
54#define S3C2410_NFCONF_INITECC (1<<12)
55#define S3C2410_NFCONF_nFCE (1<<11)
56#define S3C2410_NFCONF_TACLS(x) ((x)<<8)
57#define S3C2410_NFCONF_TWRPH0(x) ((x)<<4)
58#define S3C2410_NFCONF_TWRPH1(x) ((x)<<0)
59
60#define S3C2410_NFSTAT_BUSY (1<<0)
61
62#define S3C2440_NFCONF_BUSWIDTH_8 (0<<0)
63#define S3C2440_NFCONF_BUSWIDTH_16 (1<<0)
64#define S3C2440_NFCONF_ADVFLASH (1<<3)
65#define S3C2440_NFCONF_TACLS(x) ((x)<<12)
66#define S3C2440_NFCONF_TWRPH0(x) ((x)<<8)
67#define S3C2440_NFCONF_TWRPH1(x) ((x)<<4)
68
69#define S3C2440_NFCONT_LOCKTIGHT (1<<13)
70#define S3C2440_NFCONT_SOFTLOCK (1<<12)
71#define S3C2440_NFCONT_ILLEGALACC_EN (1<<10)
72#define S3C2440_NFCONT_RNBINT_EN (1<<9)
73#define S3C2440_NFCONT_RN_FALLING (1<<8)
74#define S3C2440_NFCONT_SPARE_ECCLOCK (1<<6)
75#define S3C2440_NFCONT_MAIN_ECCLOCK (1<<5)
76#define S3C2440_NFCONT_INITECC (1<<4)
77#define S3C2440_NFCONT_nFCE (1<<1)
78#define S3C2440_NFCONT_ENABLE (1<<0)
79
80#define S3C2440_NFSTAT_READY (1<<0)
81#define S3C2440_NFSTAT_nCE (1<<1)
82#define S3C2440_NFSTAT_RnB_CHANGE (1<<2)
83#define S3C2440_NFSTAT_ILLEGAL_ACCESS (1<<3)
84
85#define S3C2412_NFCONF_NANDBOOT (1<<31)
86#define S3C2412_NFCONF_ECCCLKCON (1<<30)
87#define S3C2412_NFCONF_ECC_MLC (1<<24)
88#define S3C2412_NFCONF_TACLS_MASK (7<<12) /* 1 extra bit of Tacls */
89
90#define S3C2412_NFCONT_ECC4_DIRWR (1<<18)
91#define S3C2412_NFCONT_LOCKTIGHT (1<<17)
92#define S3C2412_NFCONT_SOFTLOCK (1<<16)
93#define S3C2412_NFCONT_ECC4_ENCINT (1<<13)
94#define S3C2412_NFCONT_ECC4_DECINT (1<<12)
95#define S3C2412_NFCONT_MAIN_ECC_LOCK (1<<7)
96#define S3C2412_NFCONT_INIT_MAIN_ECC (1<<5)
97#define S3C2412_NFCONT_nFCE1 (1<<2)
98#define S3C2412_NFCONT_nFCE0 (1<<1)
99
100#define S3C2412_NFSTAT_ECC_ENCDONE (1<<7)
101#define S3C2412_NFSTAT_ECC_DECDONE (1<<6)
102#define S3C2412_NFSTAT_ILLEGAL_ACCESS (1<<5)
103#define S3C2412_NFSTAT_RnB_CHANGE (1<<4)
104#define S3C2412_NFSTAT_nFCE1 (1<<3)
105#define S3C2412_NFSTAT_nFCE0 (1<<2)
106#define S3C2412_NFSTAT_Res1 (1<<1)
107#define S3C2412_NFSTAT_READY (1<<0)
108
109#define S3C2412_NFECCERR_SERRDATA(x) (((x) >> 21) & 0xf)
110#define S3C2412_NFECCERR_SERRBIT(x) (((x) >> 18) & 0x7)
111#define S3C2412_NFECCERR_MERRDATA(x) (((x) >> 7) & 0x3ff)
112#define S3C2412_NFECCERR_MERRBIT(x) (((x) >> 4) & 0x7)
113#define S3C2412_NFECCERR_SPARE_ERR(x) (((x) >> 2) & 0x3)
114#define S3C2412_NFECCERR_MAIN_ERR(x) (((x) >> 2) & 0x3)
115#define S3C2412_NFECCERR_NONE (0)
116#define S3C2412_NFECCERR_1BIT (1)
117#define S3C2412_NFECCERR_MULTIBIT (2)
118#define S3C2412_NFECCERR_ECCAREA (3)
119
120
121
122#endif /* __ASM_ARM_REGS_NAND */
123
diff --git a/include/asm-arm/plat-s3c/regs-rtc.h b/include/asm-arm/plat-s3c/regs-rtc.h
deleted file mode 100644
index d5837cf8e402..000000000000
--- a/include/asm-arm/plat-s3c/regs-rtc.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-rtc.h
2 *
3 * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
4 * http://www.simtec.co.uk/products/SWLINUX/
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 * S3C2410 Internal RTC register definition
11*/
12
13#ifndef __ASM_ARCH_REGS_RTC_H
14#define __ASM_ARCH_REGS_RTC_H __FILE__
15
16#define S3C2410_RTCREG(x) (x)
17
18#define S3C2410_RTCCON S3C2410_RTCREG(0x40)
19#define S3C2410_RTCCON_RTCEN (1<<0)
20#define S3C2410_RTCCON_CLKSEL (1<<1)
21#define S3C2410_RTCCON_CNTSEL (1<<2)
22#define S3C2410_RTCCON_CLKRST (1<<3)
23
24#define S3C2410_TICNT S3C2410_RTCREG(0x44)
25#define S3C2410_TICNT_ENABLE (1<<7)
26
27#define S3C2410_RTCALM S3C2410_RTCREG(0x50)
28#define S3C2410_RTCALM_ALMEN (1<<6)
29#define S3C2410_RTCALM_YEAREN (1<<5)
30#define S3C2410_RTCALM_MONEN (1<<4)
31#define S3C2410_RTCALM_DAYEN (1<<3)
32#define S3C2410_RTCALM_HOUREN (1<<2)
33#define S3C2410_RTCALM_MINEN (1<<1)
34#define S3C2410_RTCALM_SECEN (1<<0)
35
36#define S3C2410_RTCALM_ALL \
37 S3C2410_RTCALM_ALMEN | S3C2410_RTCALM_YEAREN | S3C2410_RTCALM_MONEN |\
38 S3C2410_RTCALM_DAYEN | S3C2410_RTCALM_HOUREN | S3C2410_RTCALM_MINEN |\
39 S3C2410_RTCALM_SECEN
40
41
42#define S3C2410_ALMSEC S3C2410_RTCREG(0x54)
43#define S3C2410_ALMMIN S3C2410_RTCREG(0x58)
44#define S3C2410_ALMHOUR S3C2410_RTCREG(0x5c)
45
46#define S3C2410_ALMDATE S3C2410_RTCREG(0x60)
47#define S3C2410_ALMMON S3C2410_RTCREG(0x64)
48#define S3C2410_ALMYEAR S3C2410_RTCREG(0x68)
49
50#define S3C2410_RTCRST S3C2410_RTCREG(0x6c)
51
52#define S3C2410_RTCSEC S3C2410_RTCREG(0x70)
53#define S3C2410_RTCMIN S3C2410_RTCREG(0x74)
54#define S3C2410_RTCHOUR S3C2410_RTCREG(0x78)
55#define S3C2410_RTCDATE S3C2410_RTCREG(0x7c)
56#define S3C2410_RTCDAY S3C2410_RTCREG(0x80)
57#define S3C2410_RTCMON S3C2410_RTCREG(0x84)
58#define S3C2410_RTCYEAR S3C2410_RTCREG(0x88)
59
60
61#endif /* __ASM_ARCH_REGS_RTC_H */
diff --git a/include/asm-arm/plat-s3c/regs-watchdog.h b/include/asm-arm/plat-s3c/regs-watchdog.h
deleted file mode 100644
index 4938492470f7..000000000000
--- a/include/asm-arm/plat-s3c/regs-watchdog.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-watchdog.h
2 *
3 * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
4 * http://www.simtec.co.uk/products/SWLINUX/
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 * S3C2410 Watchdog timer control
11*/
12
13
14#ifndef __ASM_ARCH_REGS_WATCHDOG_H
15#define __ASM_ARCH_REGS_WATCHDOG_H
16
17#define S3C_WDOGREG(x) ((x) + S3C_VA_WATCHDOG)
18
19#define S3C2410_WTCON S3C_WDOGREG(0x00)
20#define S3C2410_WTDAT S3C_WDOGREG(0x04)
21#define S3C2410_WTCNT S3C_WDOGREG(0x08)
22
23/* the watchdog can either generate a reset pulse, or an
24 * interrupt.
25 */
26
27#define S3C2410_WTCON_RSTEN (0x01)
28#define S3C2410_WTCON_INTEN (1<<2)
29#define S3C2410_WTCON_ENABLE (1<<5)
30
31#define S3C2410_WTCON_DIV16 (0<<3)
32#define S3C2410_WTCON_DIV32 (1<<3)
33#define S3C2410_WTCON_DIV64 (2<<3)
34#define S3C2410_WTCON_DIV128 (3<<3)
35
36#define S3C2410_WTCON_PRESCALE(x) ((x) << 8)
37#define S3C2410_WTCON_PRESCALE_MASK (0xff00)
38
39#endif /* __ASM_ARCH_REGS_WATCHDOG_H */
40
41
diff --git a/include/asm-arm/plat-s3c24xx/mci.h b/include/asm-arm/plat-s3c24xx/mci.h
deleted file mode 100644
index 2d0852ac3b27..000000000000
--- a/include/asm-arm/plat-s3c24xx/mci.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _ARCH_MCI_H
2#define _ARCH_MCI_H
3
4struct s3c24xx_mci_pdata {
5 unsigned int wprotect_invert : 1;
6 unsigned int detect_invert : 1; /* set => detect active high. */
7
8 unsigned int gpio_detect;
9 unsigned int gpio_wprotect;
10 unsigned long ocr_avail;
11 void (*set_power)(unsigned char power_mode,
12 unsigned short vdd);
13};
14
15#endif /* _ARCH_NCI_H */
diff --git a/include/asm-arm/plat-s3c24xx/regs-spi.h b/include/asm-arm/plat-s3c24xx/regs-spi.h
deleted file mode 100644
index 2b35479ee35c..000000000000
--- a/include/asm-arm/plat-s3c24xx/regs-spi.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-spi.h
2 *
3 * Copyright (c) 2004 Fetron GmbH
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 * S3C2410 SPI register definition
10*/
11
12#ifndef __ASM_ARCH_REGS_SPI_H
13#define __ASM_ARCH_REGS_SPI_H
14
15#define S3C2410_SPI1 (0x20)
16#define S3C2412_SPI1 (0x100)
17
18#define S3C2410_SPCON (0x00)
19
20#define S3C2412_SPCON_RXFIFO_RB2 (0<<14)
21#define S3C2412_SPCON_RXFIFO_RB4 (1<<14)
22#define S3C2412_SPCON_RXFIFO_RB12 (2<<14)
23#define S3C2412_SPCON_RXFIFO_RB14 (3<<14)
24#define S3C2412_SPCON_TXFIFO_RB2 (0<<12)
25#define S3C2412_SPCON_TXFIFO_RB4 (1<<12)
26#define S3C2412_SPCON_TXFIFO_RB12 (2<<12)
27#define S3C2412_SPCON_TXFIFO_RB14 (3<<12)
28#define S3C2412_SPCON_RXFIFO_RESET (1<<11) /* RxFIFO reset */
29#define S3C2412_SPCON_TXFIFO_RESET (1<<10) /* TxFIFO reset */
30#define S3C2412_SPCON_RXFIFO_EN (1<<9) /* RxFIFO Enable */
31#define S3C2412_SPCON_TXFIFO_EN (1<<8) /* TxFIFO Enable */
32
33#define S3C2412_SPCON_DIRC_RX (1<<7)
34
35#define S3C2410_SPCON_SMOD_DMA (2<<5) /* DMA mode */
36#define S3C2410_SPCON_SMOD_INT (1<<5) /* interrupt mode */
37#define S3C2410_SPCON_SMOD_POLL (0<<5) /* polling mode */
38#define S3C2410_SPCON_ENSCK (1<<4) /* Enable SCK */
39#define S3C2410_SPCON_MSTR (1<<3) /* Master/Slave select
40 0: slave, 1: master */
41#define S3C2410_SPCON_CPOL_HIGH (1<<2) /* Clock polarity select */
42#define S3C2410_SPCON_CPOL_LOW (0<<2) /* Clock polarity select */
43
44#define S3C2410_SPCON_CPHA_FMTB (1<<1) /* Clock Phase Select */
45#define S3C2410_SPCON_CPHA_FMTA (0<<1) /* Clock Phase Select */
46
47#define S3C2410_SPCON_TAGD (1<<0) /* Tx auto garbage data mode */
48
49
50#define S3C2410_SPSTA (0x04)
51
52#define S3C2412_SPSTA_RXFIFO_AE (1<<11)
53#define S3C2412_SPSTA_TXFIFO_AE (1<<10)
54#define S3C2412_SPSTA_RXFIFO_ERROR (1<<9)
55#define S3C2412_SPSTA_TXFIFO_ERROR (1<<8)
56#define S3C2412_SPSTA_RXFIFO_FIFO (1<<7)
57#define S3C2412_SPSTA_RXFIFO_EMPTY (1<<6)
58#define S3C2412_SPSTA_TXFIFO_NFULL (1<<5)
59#define S3C2412_SPSTA_TXFIFO_EMPTY (1<<4)
60
61#define S3C2410_SPSTA_DCOL (1<<2) /* Data Collision Error */
62#define S3C2410_SPSTA_MULD (1<<1) /* Multi Master Error */
63#define S3C2410_SPSTA_READY (1<<0) /* Data Tx/Rx ready */
64#define S3C2412_SPSTA_READY_ORG (1<<3)
65
66#define S3C2410_SPPIN (0x08)
67
68#define S3C2410_SPPIN_ENMUL (1<<2) /* Multi Master Error detect */
69#define S3C2410_SPPIN_RESERVED (1<<1)
70#define S3C2400_SPPIN_nCS (1<<1) /* SPI Card Select */
71#define S3C2410_SPPIN_KEEP (1<<0) /* Master Out keep */
72
73#define S3C2410_SPPRE (0x0C)
74#define S3C2410_SPTDAT (0x10)
75#define S3C2410_SPRDAT (0x14)
76
77#define S3C2412_TXFIFO (0x18)
78#define S3C2412_RXFIFO (0x18)
79#define S3C2412_SPFIC (0x24)
80
81
82#endif /* __ASM_ARCH_REGS_SPI_H */
diff --git a/include/asm-arm/plat-s3c24xx/regs-udc.h b/include/asm-arm/plat-s3c24xx/regs-udc.h
deleted file mode 100644
index f0dd4a41b37b..000000000000
--- a/include/asm-arm/plat-s3c24xx/regs-udc.h
+++ /dev/null
@@ -1,153 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/regs-udc.h
2 *
3 * Copyright (C) 2004 Herbert Poetzl <herbert@13thfloor.at>
4 *
5 * This include file is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9*/
10
11#ifndef __ASM_ARCH_REGS_UDC_H
12#define __ASM_ARCH_REGS_UDC_H
13
14#define S3C2410_USBDREG(x) (x)
15
16#define S3C2410_UDC_FUNC_ADDR_REG S3C2410_USBDREG(0x0140)
17#define S3C2410_UDC_PWR_REG S3C2410_USBDREG(0x0144)
18#define S3C2410_UDC_EP_INT_REG S3C2410_USBDREG(0x0148)
19
20#define S3C2410_UDC_USB_INT_REG S3C2410_USBDREG(0x0158)
21#define S3C2410_UDC_EP_INT_EN_REG S3C2410_USBDREG(0x015c)
22
23#define S3C2410_UDC_USB_INT_EN_REG S3C2410_USBDREG(0x016c)
24
25#define S3C2410_UDC_FRAME_NUM1_REG S3C2410_USBDREG(0x0170)
26#define S3C2410_UDC_FRAME_NUM2_REG S3C2410_USBDREG(0x0174)
27
28#define S3C2410_UDC_EP0_FIFO_REG S3C2410_USBDREG(0x01c0)
29#define S3C2410_UDC_EP1_FIFO_REG S3C2410_USBDREG(0x01c4)
30#define S3C2410_UDC_EP2_FIFO_REG S3C2410_USBDREG(0x01c8)
31#define S3C2410_UDC_EP3_FIFO_REG S3C2410_USBDREG(0x01cc)
32#define S3C2410_UDC_EP4_FIFO_REG S3C2410_USBDREG(0x01d0)
33
34#define S3C2410_UDC_EP1_DMA_CON S3C2410_USBDREG(0x0200)
35#define S3C2410_UDC_EP1_DMA_UNIT S3C2410_USBDREG(0x0204)
36#define S3C2410_UDC_EP1_DMA_FIFO S3C2410_USBDREG(0x0208)
37#define S3C2410_UDC_EP1_DMA_TTC_L S3C2410_USBDREG(0x020c)
38#define S3C2410_UDC_EP1_DMA_TTC_M S3C2410_USBDREG(0x0210)
39#define S3C2410_UDC_EP1_DMA_TTC_H S3C2410_USBDREG(0x0214)
40
41#define S3C2410_UDC_EP2_DMA_CON S3C2410_USBDREG(0x0218)
42#define S3C2410_UDC_EP2_DMA_UNIT S3C2410_USBDREG(0x021c)
43#define S3C2410_UDC_EP2_DMA_FIFO S3C2410_USBDREG(0x0220)
44#define S3C2410_UDC_EP2_DMA_TTC_L S3C2410_USBDREG(0x0224)
45#define S3C2410_UDC_EP2_DMA_TTC_M S3C2410_USBDREG(0x0228)
46#define S3C2410_UDC_EP2_DMA_TTC_H S3C2410_USBDREG(0x022c)
47
48#define S3C2410_UDC_EP3_DMA_CON S3C2410_USBDREG(0x0240)
49#define S3C2410_UDC_EP3_DMA_UNIT S3C2410_USBDREG(0x0244)
50#define S3C2410_UDC_EP3_DMA_FIFO S3C2410_USBDREG(0x0248)
51#define S3C2410_UDC_EP3_DMA_TTC_L S3C2410_USBDREG(0x024c)
52#define S3C2410_UDC_EP3_DMA_TTC_M S3C2410_USBDREG(0x0250)
53#define S3C2410_UDC_EP3_DMA_TTC_H S3C2410_USBDREG(0x0254)
54
55#define S3C2410_UDC_EP4_DMA_CON S3C2410_USBDREG(0x0258)
56#define S3C2410_UDC_EP4_DMA_UNIT S3C2410_USBDREG(0x025c)
57#define S3C2410_UDC_EP4_DMA_FIFO S3C2410_USBDREG(0x0260)
58#define S3C2410_UDC_EP4_DMA_TTC_L S3C2410_USBDREG(0x0264)
59#define S3C2410_UDC_EP4_DMA_TTC_M S3C2410_USBDREG(0x0268)
60#define S3C2410_UDC_EP4_DMA_TTC_H S3C2410_USBDREG(0x026c)
61
62#define S3C2410_UDC_INDEX_REG S3C2410_USBDREG(0x0178)
63
64/* indexed registers */
65
66#define S3C2410_UDC_MAXP_REG S3C2410_USBDREG(0x0180)
67
68#define S3C2410_UDC_EP0_CSR_REG S3C2410_USBDREG(0x0184)
69
70#define S3C2410_UDC_IN_CSR1_REG S3C2410_USBDREG(0x0184)
71#define S3C2410_UDC_IN_CSR2_REG S3C2410_USBDREG(0x0188)
72
73#define S3C2410_UDC_OUT_CSR1_REG S3C2410_USBDREG(0x0190)
74#define S3C2410_UDC_OUT_CSR2_REG S3C2410_USBDREG(0x0194)
75#define S3C2410_UDC_OUT_FIFO_CNT1_REG S3C2410_USBDREG(0x0198)
76#define S3C2410_UDC_OUT_FIFO_CNT2_REG S3C2410_USBDREG(0x019c)
77
78#define S3C2410_UDC_FUNCADDR_UPDATE (1<<7)
79
80#define S3C2410_UDC_PWR_ISOUP (1<<7) // R/W
81#define S3C2410_UDC_PWR_RESET (1<<3) // R
82#define S3C2410_UDC_PWR_RESUME (1<<2) // R/W
83#define S3C2410_UDC_PWR_SUSPEND (1<<1) // R
84#define S3C2410_UDC_PWR_ENSUSPEND (1<<0) // R/W
85
86#define S3C2410_UDC_PWR_DEFAULT 0x00
87
88#define S3C2410_UDC_INT_EP4 (1<<4) // R/W (clear only)
89#define S3C2410_UDC_INT_EP3 (1<<3) // R/W (clear only)
90#define S3C2410_UDC_INT_EP2 (1<<2) // R/W (clear only)
91#define S3C2410_UDC_INT_EP1 (1<<1) // R/W (clear only)
92#define S3C2410_UDC_INT_EP0 (1<<0) // R/W (clear only)
93
94#define S3C2410_UDC_USBINT_RESET (1<<2) // R/W (clear only)
95#define S3C2410_UDC_USBINT_RESUME (1<<1) // R/W (clear only)
96#define S3C2410_UDC_USBINT_SUSPEND (1<<0) // R/W (clear only)
97
98#define S3C2410_UDC_INTE_EP4 (1<<4) // R/W
99#define S3C2410_UDC_INTE_EP3 (1<<3) // R/W
100#define S3C2410_UDC_INTE_EP2 (1<<2) // R/W
101#define S3C2410_UDC_INTE_EP1 (1<<1) // R/W
102#define S3C2410_UDC_INTE_EP0 (1<<0) // R/W
103
104#define S3C2410_UDC_USBINTE_RESET (1<<2) // R/W
105#define S3C2410_UDC_USBINTE_SUSPEND (1<<0) // R/W
106
107
108#define S3C2410_UDC_INDEX_EP0 (0x00)
109#define S3C2410_UDC_INDEX_EP1 (0x01) // ??
110#define S3C2410_UDC_INDEX_EP2 (0x02) // ??
111#define S3C2410_UDC_INDEX_EP3 (0x03) // ??
112#define S3C2410_UDC_INDEX_EP4 (0x04) // ??
113
114#define S3C2410_UDC_ICSR1_CLRDT (1<<6) // R/W
115#define S3C2410_UDC_ICSR1_SENTSTL (1<<5) // R/W (clear only)
116#define S3C2410_UDC_ICSR1_SENDSTL (1<<4) // R/W
117#define S3C2410_UDC_ICSR1_FFLUSH (1<<3) // W (set only)
118#define S3C2410_UDC_ICSR1_UNDRUN (1<<2) // R/W (clear only)
119#define S3C2410_UDC_ICSR1_PKTRDY (1<<0) // R/W (set only)
120
121#define S3C2410_UDC_ICSR2_AUTOSET (1<<7) // R/W
122#define S3C2410_UDC_ICSR2_ISO (1<<6) // R/W
123#define S3C2410_UDC_ICSR2_MODEIN (1<<5) // R/W
124#define S3C2410_UDC_ICSR2_DMAIEN (1<<4) // R/W
125
126#define S3C2410_UDC_OCSR1_CLRDT (1<<7) // R/W
127#define S3C2410_UDC_OCSR1_SENTSTL (1<<6) // R/W (clear only)
128#define S3C2410_UDC_OCSR1_SENDSTL (1<<5) // R/W
129#define S3C2410_UDC_OCSR1_FFLUSH (1<<4) // R/W
130#define S3C2410_UDC_OCSR1_DERROR (1<<3) // R
131#define S3C2410_UDC_OCSR1_OVRRUN (1<<2) // R/W (clear only)
132#define S3C2410_UDC_OCSR1_PKTRDY (1<<0) // R/W (clear only)
133
134#define S3C2410_UDC_OCSR2_AUTOCLR (1<<7) // R/W
135#define S3C2410_UDC_OCSR2_ISO (1<<6) // R/W
136#define S3C2410_UDC_OCSR2_DMAIEN (1<<5) // R/W
137
138#define S3C2410_UDC_EP0_CSR_OPKRDY (1<<0)
139#define S3C2410_UDC_EP0_CSR_IPKRDY (1<<1)
140#define S3C2410_UDC_EP0_CSR_SENTSTL (1<<2)
141#define S3C2410_UDC_EP0_CSR_DE (1<<3)
142#define S3C2410_UDC_EP0_CSR_SE (1<<4)
143#define S3C2410_UDC_EP0_CSR_SENDSTL (1<<5)
144#define S3C2410_UDC_EP0_CSR_SOPKTRDY (1<<6)
145#define S3C2410_UDC_EP0_CSR_SSE (1<<7)
146
147#define S3C2410_UDC_MAXP_8 (1<<0)
148#define S3C2410_UDC_MAXP_16 (1<<1)
149#define S3C2410_UDC_MAXP_32 (1<<2)
150#define S3C2410_UDC_MAXP_64 (1<<3)
151
152
153#endif
diff --git a/include/asm-arm/plat-s3c24xx/udc.h b/include/asm-arm/plat-s3c24xx/udc.h
deleted file mode 100644
index 546bb4008f49..000000000000
--- a/include/asm-arm/plat-s3c24xx/udc.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/udc.h
2 *
3 * Copyright (c) 2005 Arnaud Patard <arnaud.patard@rtp-net.org>
4 *
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 * Changelog:
12 * 14-Mar-2005 RTP Created file
13 * 02-Aug-2005 RTP File rename
14 * 07-Sep-2005 BJD Minor cleanups, changed cmd to enum
15 * 18-Jan-2007 HMW Add per-platform vbus_draw function
16*/
17
18#ifndef __ASM_ARM_ARCH_UDC_H
19#define __ASM_ARM_ARCH_UDC_H
20
21enum s3c2410_udc_cmd_e {
22 S3C2410_UDC_P_ENABLE = 1, /* Pull-up enable */
23 S3C2410_UDC_P_DISABLE = 2, /* Pull-up disable */
24 S3C2410_UDC_P_RESET = 3, /* UDC reset, in case of */
25};
26
27struct s3c2410_udc_mach_info {
28 void (*udc_command)(enum s3c2410_udc_cmd_e);
29 void (*vbus_draw)(unsigned int ma);
30 unsigned int vbus_pin;
31 unsigned char vbus_pin_inverted;
32};
33
34extern void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *);
35
36#endif /* __ASM_ARM_ARCH_UDC_H */
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 4c794d73fb84..8af276361bf2 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -41,15 +41,14 @@ struct bug_entry {
41 41
42#ifndef __WARN 42#ifndef __WARN
43#ifndef __ASSEMBLY__ 43#ifndef __ASSEMBLY__
44extern void warn_on_slowpath(const char *file, const int line);
45extern void warn_slowpath(const char *file, const int line, 44extern void warn_slowpath(const char *file, const int line,
46 const char *fmt, ...) __attribute__((format(printf, 3, 4))); 45 const char *fmt, ...) __attribute__((format(printf, 3, 4)));
47#define WANT_WARN_ON_SLOWPATH 46#define WANT_WARN_ON_SLOWPATH
48#endif 47#endif
49#define __WARN() warn_on_slowpath(__FILE__, __LINE__) 48#define __WARN() warn_slowpath(__FILE__, __LINE__, NULL)
50#define __WARN_printf(arg...) warn_slowpath(__FILE__, __LINE__, arg) 49#define __WARN_printf(arg...) warn_slowpath(__FILE__, __LINE__, arg)
51#else 50#else
52#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0) 51#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
53#endif 52#endif
54 53
55#ifndef WARN_ON 54#ifndef WARN_ON
diff --git a/include/drm/Kbuild b/include/drm/Kbuild
index 82b6983b7fbb..b940fdfa3b25 100644
--- a/include/drm/Kbuild
+++ b/include/drm/Kbuild
@@ -1,4 +1,4 @@
1unifdef-y += drm.h drm_sarea.h 1unifdef-y += drm.h drm_sarea.h drm_mode.h
2unifdef-y += i810_drm.h 2unifdef-y += i810_drm.h
3unifdef-y += i830_drm.h 3unifdef-y += i830_drm.h
4unifdef-y += i915_drm.h 4unifdef-y += i915_drm.h
diff --git a/include/drm/drm.h b/include/drm/drm.h
index f46ba4b57da4..32e5096554e9 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -173,6 +173,7 @@ enum drm_map_type {
173 _DRM_AGP = 3, /**< AGP/GART */ 173 _DRM_AGP = 3, /**< AGP/GART */
174 _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */ 174 _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */
175 _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ 175 _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */
176 _DRM_GEM = 6, /**< GEM object */
176}; 177};
177 178
178/** 179/**
@@ -598,6 +599,8 @@ struct drm_gem_open {
598 uint64_t size; 599 uint64_t size;
599}; 600};
600 601
602#include "drm_mode.h"
603
601#define DRM_IOCTL_BASE 'd' 604#define DRM_IOCTL_BASE 'd'
602#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) 605#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
603#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type) 606#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type)
@@ -634,6 +637,9 @@ struct drm_gem_open {
634#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, struct drm_ctx_priv_map) 637#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, struct drm_ctx_priv_map)
635#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, struct drm_ctx_priv_map) 638#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, struct drm_ctx_priv_map)
636 639
640#define DRM_IOCTL_SET_MASTER DRM_IO(0x1e)
641#define DRM_IOCTL_DROP_MASTER DRM_IO(0x1f)
642
637#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, struct drm_ctx) 643#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, struct drm_ctx)
638#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, struct drm_ctx) 644#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, struct drm_ctx)
639#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, struct drm_ctx) 645#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, struct drm_ctx)
@@ -664,6 +670,24 @@ struct drm_gem_open {
664 670
665#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw) 671#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw)
666 672
673#define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res)
674#define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc)
675#define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA2, struct drm_mode_crtc)
676#define DRM_IOCTL_MODE_CURSOR DRM_IOWR(0xA3, struct drm_mode_cursor)
677#define DRM_IOCTL_MODE_GETGAMMA DRM_IOWR(0xA4, struct drm_mode_crtc_lut)
678#define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xA5, struct drm_mode_crtc_lut)
679#define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xA6, struct drm_mode_get_encoder)
680#define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA7, struct drm_mode_get_connector)
681#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd)
682#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd)
683
684#define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAA, struct drm_mode_get_property)
685#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_connector_set_property)
686#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob)
687#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
688#define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
689#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int)
690
667/** 691/**
668 * Device specific ioctls should only be in their respective headers 692 * Device specific ioctls should only be in their respective headers
669 * The device specific ioctl range is from 0x40 to 0x99. 693 * The device specific ioctl range is from 0x40 to 0x99.
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d5e8e5c89548..afb7858c068d 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -105,6 +105,7 @@ struct drm_device;
105#define DRIVER_FB_DMA 0x400 105#define DRIVER_FB_DMA 0x400
106#define DRIVER_IRQ_VBL2 0x800 106#define DRIVER_IRQ_VBL2 0x800
107#define DRIVER_GEM 0x1000 107#define DRIVER_GEM 0x1000
108#define DRIVER_MODESET 0x2000
108 109
109/***********************************************************************/ 110/***********************************************************************/
110/** \name Begin the DRM... */ 111/** \name Begin the DRM... */
@@ -238,11 +239,11 @@ struct drm_device;
238 */ 239 */
239#define LOCK_TEST_WITH_RETURN( dev, file_priv ) \ 240#define LOCK_TEST_WITH_RETURN( dev, file_priv ) \
240do { \ 241do { \
241 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ 242 if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock) || \
242 dev->lock.file_priv != file_priv ) { \ 243 file_priv->master->lock.file_priv != file_priv) { \
243 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ 244 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
244 __func__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\ 245 __func__, _DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock),\
245 dev->lock.file_priv, file_priv ); \ 246 file_priv->master->lock.file_priv, file_priv); \
246 return -EINVAL; \ 247 return -EINVAL; \
247 } \ 248 } \
248} while (0) 249} while (0)
@@ -276,6 +277,7 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
276#define DRM_AUTH 0x1 277#define DRM_AUTH 0x1
277#define DRM_MASTER 0x2 278#define DRM_MASTER 0x2
278#define DRM_ROOT_ONLY 0x4 279#define DRM_ROOT_ONLY 0x4
280#define DRM_CONTROL_ALLOW 0x8
279 281
280struct drm_ioctl_desc { 282struct drm_ioctl_desc {
281 unsigned int cmd; 283 unsigned int cmd;
@@ -379,21 +381,26 @@ struct drm_buf_entry {
379/** File private data */ 381/** File private data */
380struct drm_file { 382struct drm_file {
381 int authenticated; 383 int authenticated;
382 int master;
383 pid_t pid; 384 pid_t pid;
384 uid_t uid; 385 uid_t uid;
385 drm_magic_t magic; 386 drm_magic_t magic;
386 unsigned long ioctl_count; 387 unsigned long ioctl_count;
387 struct list_head lhead; 388 struct list_head lhead;
388 struct drm_minor *minor; 389 struct drm_minor *minor;
389 int remove_auth_on_close;
390 unsigned long lock_count; 390 unsigned long lock_count;
391
391 /** Mapping of mm object handles to object pointers. */ 392 /** Mapping of mm object handles to object pointers. */
392 struct idr object_idr; 393 struct idr object_idr;
393 /** Lock for synchronization of access to object_idr. */ 394 /** Lock for synchronization of access to object_idr. */
394 spinlock_t table_lock; 395 spinlock_t table_lock;
396
395 struct file *filp; 397 struct file *filp;
396 void *driver_priv; 398 void *driver_priv;
399
400 int is_master; /* this file private is a master for a minor */
401 struct drm_master *master; /* master this node is currently associated with
402 N.B. not always minor->master */
403 struct list_head fbs;
397}; 404};
398 405
399/** Wait queue */ 406/** Wait queue */
@@ -523,6 +530,8 @@ struct drm_map_list {
523 struct drm_hash_item hash; 530 struct drm_hash_item hash;
524 struct drm_map *map; /**< mapping */ 531 struct drm_map *map; /**< mapping */
525 uint64_t user_token; 532 uint64_t user_token;
533 struct drm_master *master;
534 struct drm_mm_node *file_offset_node; /**< fake offset */
526}; 535};
527 536
528typedef struct drm_map drm_local_map_t; 537typedef struct drm_map drm_local_map_t;
@@ -563,6 +572,14 @@ struct drm_ati_pcigart_info {
563}; 572};
564 573
565/** 574/**
575 * GEM specific mm private for tracking GEM objects
576 */
577struct drm_gem_mm {
578 struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */
579 struct drm_open_hash offset_hash; /**< User token hash table for maps */
580};
581
582/**
566 * This structure defines the drm_mm memory object, which will be used by the 583 * This structure defines the drm_mm memory object, which will be used by the
567 * DRM for its buffer objects. 584 * DRM for its buffer objects.
568 */ 585 */
@@ -579,6 +596,9 @@ struct drm_gem_object {
579 /** File representing the shmem storage */ 596 /** File representing the shmem storage */
580 struct file *filp; 597 struct file *filp;
581 598
599 /* Mapping info for this object */
600 struct drm_map_list map_list;
601
582 /** 602 /**
583 * Size of the object, in bytes. Immutable over the object's 603 * Size of the object, in bytes. Immutable over the object's
584 * lifetime. 604 * lifetime.
@@ -612,6 +632,33 @@ struct drm_gem_object {
612 void *driver_private; 632 void *driver_private;
613}; 633};
614 634
635#include "drm_crtc.h"
636
637/* per-master structure */
638struct drm_master {
639
640 struct kref refcount; /* refcount for this master */
641
642 struct list_head head; /**< each minor contains a list of masters */
643 struct drm_minor *minor; /**< link back to minor we are a master for */
644
645 char *unique; /**< Unique identifier: e.g., busid */
646 int unique_len; /**< Length of unique field */
647 int unique_size; /**< amount allocated */
648
649 int blocked; /**< Blocked due to VC switch? */
650
651 /** \name Authentication */
652 /*@{ */
653 struct drm_open_hash magiclist;
654 struct list_head magicfree;
655 /*@} */
656
657 struct drm_lock_data lock; /**< Information on hardware lock */
658
659 void *driver_priv; /**< Private structure for driver to use */
660};
661
615/** 662/**
616 * DRM driver structure. This structure represent the common code for 663 * DRM driver structure. This structure represent the common code for
617 * a family of cards. There will one drm_device for each card present 664 * a family of cards. There will one drm_device for each card present
@@ -712,6 +759,10 @@ struct drm_driver {
712 void (*set_version) (struct drm_device *dev, 759 void (*set_version) (struct drm_device *dev,
713 struct drm_set_version *sv); 760 struct drm_set_version *sv);
714 761
762 /* Master routines */
763 int (*master_create)(struct drm_device *dev, struct drm_master *master);
764 void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
765
715 int (*proc_init)(struct drm_minor *minor); 766 int (*proc_init)(struct drm_minor *minor);
716 void (*proc_cleanup)(struct drm_minor *minor); 767 void (*proc_cleanup)(struct drm_minor *minor);
717 768
@@ -724,6 +775,9 @@ struct drm_driver {
724 int (*gem_init_object) (struct drm_gem_object *obj); 775 int (*gem_init_object) (struct drm_gem_object *obj);
725 void (*gem_free_object) (struct drm_gem_object *obj); 776 void (*gem_free_object) (struct drm_gem_object *obj);
726 777
778 /* Driver private ops for this object */
779 struct vm_operations_struct *gem_vm_ops;
780
727 int major; 781 int major;
728 int minor; 782 int minor;
729 int patchlevel; 783 int patchlevel;
@@ -737,10 +791,14 @@ struct drm_driver {
737 int num_ioctls; 791 int num_ioctls;
738 struct file_operations fops; 792 struct file_operations fops;
739 struct pci_driver pci_driver; 793 struct pci_driver pci_driver;
794 /* List of devices hanging off this driver */
795 struct list_head device_list;
740}; 796};
741 797
742#define DRM_MINOR_UNASSIGNED 0 798#define DRM_MINOR_UNASSIGNED 0
743#define DRM_MINOR_LEGACY 1 799#define DRM_MINOR_LEGACY 1
800#define DRM_MINOR_CONTROL 2
801#define DRM_MINOR_RENDER 3
744 802
745/** 803/**
746 * DRM minor structure. This structure represents a drm minor number. 804 * DRM minor structure. This structure represents a drm minor number.
@@ -752,6 +810,9 @@ struct drm_minor {
752 struct device kdev; /**< Linux device */ 810 struct device kdev; /**< Linux device */
753 struct drm_device *dev; 811 struct drm_device *dev;
754 struct proc_dir_entry *dev_root; /**< proc directory entry */ 812 struct proc_dir_entry *dev_root; /**< proc directory entry */
813 struct drm_master *master; /* currently active master for this node */
814 struct list_head master_list;
815 struct drm_mode_group mode_group;
755}; 816};
756 817
757/** 818/**
@@ -759,13 +820,10 @@ struct drm_minor {
759 * may contain multiple heads. 820 * may contain multiple heads.
760 */ 821 */
761struct drm_device { 822struct drm_device {
762 char *unique; /**< Unique identifier: e.g., busid */ 823 struct list_head driver_item; /**< list of devices per driver */
763 int unique_len; /**< Length of unique field */
764 char *devname; /**< For /proc/interrupts */ 824 char *devname; /**< For /proc/interrupts */
765 int if_version; /**< Highest interface version set */ 825 int if_version; /**< Highest interface version set */
766 826
767 int blocked; /**< Blocked due to VC switch? */
768
769 /** \name Locks */ 827 /** \name Locks */
770 /*@{ */ 828 /*@{ */
771 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ 829 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
@@ -788,12 +846,7 @@ struct drm_device {
788 atomic_t counts[15]; 846 atomic_t counts[15];
789 /*@} */ 847 /*@} */
790 848
791 /** \name Authentication */
792 /*@{ */
793 struct list_head filelist; 849 struct list_head filelist;
794 struct drm_open_hash magiclist; /**< magic hash table */
795 struct list_head magicfree;
796 /*@} */
797 850
798 /** \name Memory management */ 851 /** \name Memory management */
799 /*@{ */ 852 /*@{ */
@@ -810,7 +863,7 @@ struct drm_device {
810 struct idr ctx_idr; 863 struct idr ctx_idr;
811 864
812 struct list_head vmalist; /**< List of vmas (for debugging) */ 865 struct list_head vmalist; /**< List of vmas (for debugging) */
813 struct drm_lock_data lock; /**< Information on hardware lock */ 866
814 /*@} */ 867 /*@} */
815 868
816 /** \name DMA queues (contexts) */ 869 /** \name DMA queues (contexts) */
@@ -858,6 +911,7 @@ struct drm_device {
858 int *vblank_enabled; /* so we don't call enable more than 911 int *vblank_enabled; /* so we don't call enable more than
859 once per disable */ 912 once per disable */
860 int *vblank_inmodeset; /* Display driver is setting mode */ 913 int *vblank_inmodeset; /* Display driver is setting mode */
914 u32 *last_vblank_wait; /* Last vblank seqno waited per CRTC */
861 struct timer_list vblank_disable_timer; 915 struct timer_list vblank_disable_timer;
862 916
863 u32 max_vblank_count; /**< size of vblank counter register */ 917 u32 max_vblank_count; /**< size of vblank counter register */
@@ -881,12 +935,15 @@ struct drm_device {
881 struct drm_sg_mem *sg; /**< Scatter gather memory */ 935 struct drm_sg_mem *sg; /**< Scatter gather memory */
882 int num_crtcs; /**< Number of CRTCs on this device */ 936 int num_crtcs; /**< Number of CRTCs on this device */
883 void *dev_private; /**< device private data */ 937 void *dev_private; /**< device private data */
938 void *mm_private;
939 struct address_space *dev_mapping;
884 struct drm_sigdata sigdata; /**< For block_all_signals */ 940 struct drm_sigdata sigdata; /**< For block_all_signals */
885 sigset_t sigmask; 941 sigset_t sigmask;
886 942
887 struct drm_driver *driver; 943 struct drm_driver *driver;
888 drm_local_map_t *agp_buffer_map; 944 drm_local_map_t *agp_buffer_map;
889 unsigned int agp_buffer_token; 945 unsigned int agp_buffer_token;
946 struct drm_minor *control; /**< Control node for card */
890 struct drm_minor *primary; /**< render type primary screen head */ 947 struct drm_minor *primary; /**< render type primary screen head */
891 948
892 /** \name Drawable information */ 949 /** \name Drawable information */
@@ -895,6 +952,8 @@ struct drm_device {
895 struct idr drw_idr; 952 struct idr drw_idr;
896 /*@} */ 953 /*@} */
897 954
955 struct drm_mode_config mode_config; /**< Current mode config */
956
898 /** \name GEM information */ 957 /** \name GEM information */
899 /*@{ */ 958 /*@{ */
900 spinlock_t object_name_lock; 959 spinlock_t object_name_lock;
@@ -997,6 +1056,8 @@ extern int drm_release(struct inode *inode, struct file *filp);
997 1056
998 /* Mapping support (drm_vm.h) */ 1057 /* Mapping support (drm_vm.h) */
999extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); 1058extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1059extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1060extern void drm_vm_open_locked(struct vm_area_struct *vma);
1000extern unsigned long drm_core_get_map_ofs(struct drm_map * map); 1061extern unsigned long drm_core_get_map_ofs(struct drm_map * map);
1001extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); 1062extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
1002extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 1063extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
@@ -1153,6 +1214,8 @@ extern int drm_vblank_get(struct drm_device *dev, int crtc);
1153extern void drm_vblank_put(struct drm_device *dev, int crtc); 1214extern void drm_vblank_put(struct drm_device *dev, int crtc);
1154extern void drm_vblank_cleanup(struct drm_device *dev); 1215extern void drm_vblank_cleanup(struct drm_device *dev);
1155/* Modesetting support */ 1216/* Modesetting support */
1217extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1218extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1156extern int drm_modeset_ctl(struct drm_device *dev, void *data, 1219extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1157 struct drm_file *file_priv); 1220 struct drm_file *file_priv);
1158 1221
@@ -1189,6 +1252,13 @@ extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
1189extern void drm_agp_chipset_flush(struct drm_device *dev); 1252extern void drm_agp_chipset_flush(struct drm_device *dev);
1190 1253
1191 /* Stub support (drm_stub.h) */ 1254 /* Stub support (drm_stub.h) */
1255extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1256 struct drm_file *file_priv);
1257extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1258 struct drm_file *file_priv);
1259struct drm_master *drm_master_create(struct drm_minor *minor);
1260extern struct drm_master *drm_master_get(struct drm_master *master);
1261extern void drm_master_put(struct drm_master **master);
1192extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 1262extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
1193 struct drm_driver *driver); 1263 struct drm_driver *driver);
1194extern int drm_put_dev(struct drm_device *dev); 1264extern int drm_put_dev(struct drm_device *dev);
@@ -1231,7 +1301,11 @@ struct drm_sysfs_class;
1231extern struct class *drm_sysfs_create(struct module *owner, char *name); 1301extern struct class *drm_sysfs_create(struct module *owner, char *name);
1232extern void drm_sysfs_destroy(void); 1302extern void drm_sysfs_destroy(void);
1233extern int drm_sysfs_device_add(struct drm_minor *minor); 1303extern int drm_sysfs_device_add(struct drm_minor *minor);
1304extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1234extern void drm_sysfs_device_remove(struct drm_minor *minor); 1305extern void drm_sysfs_device_remove(struct drm_minor *minor);
1306extern char *drm_get_connector_status_name(enum drm_connector_status status);
1307extern int drm_sysfs_connector_add(struct drm_connector *connector);
1308extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1235 1309
1236/* 1310/*
1237 * Basic memory manager support (drm_mm.c) 1311 * Basic memory manager support (drm_mm.c)
@@ -1251,10 +1325,12 @@ extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size);
1251 1325
1252/* Graphics Execution Manager library functions (drm_gem.c) */ 1326/* Graphics Execution Manager library functions (drm_gem.c) */
1253int drm_gem_init(struct drm_device *dev); 1327int drm_gem_init(struct drm_device *dev);
1328void drm_gem_destroy(struct drm_device *dev);
1254void drm_gem_object_free(struct kref *kref); 1329void drm_gem_object_free(struct kref *kref);
1255struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, 1330struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1256 size_t size); 1331 size_t size);
1257void drm_gem_object_handle_free(struct kref *kref); 1332void drm_gem_object_handle_free(struct kref *kref);
1333int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1258 1334
1259static inline void 1335static inline void
1260drm_gem_object_reference(struct drm_gem_object *obj) 1336drm_gem_object_reference(struct drm_gem_object *obj)
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
new file mode 100644
index 000000000000..0acb07f31fa4
--- /dev/null
+++ b/include/drm/drm_crtc.h
@@ -0,0 +1,733 @@
1/*
2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25#ifndef __DRM_CRTC_H__
26#define __DRM_CRTC_H__
27
28#include <linux/i2c.h>
29#include <linux/spinlock.h>
30#include <linux/types.h>
31#include <linux/idr.h>
32
33#include <linux/fb.h>
34
35struct drm_device;
36struct drm_mode_set;
37struct drm_framebuffer;
38
39
40#define DRM_MODE_OBJECT_CRTC 0xcccccccc
41#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
42#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
43#define DRM_MODE_OBJECT_MODE 0xdededede
44#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
45#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
46#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
47
48struct drm_mode_object {
49 uint32_t id;
50 uint32_t type;
51};
52
53/*
54 * Note on terminology: here, for brevity and convenience, we refer to connector
55 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS,
56 * DVI, etc. And 'screen' refers to the whole of the visible display, which
57 * may span multiple monitors (and therefore multiple CRTC and connector
58 * structures).
59 */
60
61enum drm_mode_status {
62 MODE_OK = 0, /* Mode OK */
63 MODE_HSYNC, /* hsync out of range */
64 MODE_VSYNC, /* vsync out of range */
65 MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
66 MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
67 MODE_BAD_WIDTH, /* requires an unsupported linepitch */
68 MODE_NOMODE, /* no mode with a maching name */
69 MODE_NO_INTERLACE, /* interlaced mode not supported */
70 MODE_NO_DBLESCAN, /* doublescan mode not supported */
71 MODE_NO_VSCAN, /* multiscan mode not supported */
72 MODE_MEM, /* insufficient video memory */
73 MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
74 MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
75 MODE_MEM_VIRT, /* insufficient video memory given virtual size */
76 MODE_NOCLOCK, /* no fixed clock available */
77 MODE_CLOCK_HIGH, /* clock required is too high */
78 MODE_CLOCK_LOW, /* clock required is too low */
79 MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
80 MODE_BAD_HVALUE, /* horizontal timing was out of range */
81 MODE_BAD_VVALUE, /* vertical timing was out of range */
82 MODE_BAD_VSCAN, /* VScan value out of range */
83 MODE_HSYNC_NARROW, /* horizontal sync too narrow */
84 MODE_HSYNC_WIDE, /* horizontal sync too wide */
85 MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
86 MODE_HBLANK_WIDE, /* horizontal blanking too wide */
87 MODE_VSYNC_NARROW, /* vertical sync too narrow */
88 MODE_VSYNC_WIDE, /* vertical sync too wide */
89 MODE_VBLANK_NARROW, /* vertical blanking too narrow */
90 MODE_VBLANK_WIDE, /* vertical blanking too wide */
91 MODE_PANEL, /* exceeds panel dimensions */
92 MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
93 MODE_ONE_WIDTH, /* only one width is supported */
94 MODE_ONE_HEIGHT, /* only one height is supported */
95 MODE_ONE_SIZE, /* only one resolution is supported */
96 MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
97 MODE_UNVERIFIED = -3, /* mode needs to reverified */
98 MODE_BAD = -2, /* unspecified reason */
99 MODE_ERROR = -1 /* error condition */
100};
101
102#define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
103 DRM_MODE_TYPE_CRTC_C)
104
105#define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
106 .name = nm, .status = 0, .type = (t), .clock = (c), \
107 .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
108 .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
109 .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
110 .vscan = (vs), .flags = (f), .vrefresh = 0
111
112#define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
113
114struct drm_display_mode {
115 /* Header */
116 struct list_head head;
117 struct drm_mode_object base;
118
119 char name[DRM_DISPLAY_MODE_LEN];
120
121 int connector_count;
122 enum drm_mode_status status;
123 int type;
124
125 /* Proposed mode values */
126 int clock;
127 int hdisplay;
128 int hsync_start;
129 int hsync_end;
130 int htotal;
131 int hskew;
132 int vdisplay;
133 int vsync_start;
134 int vsync_end;
135 int vtotal;
136 int vscan;
137 unsigned int flags;
138
139 /* Addressable image size (may be 0 for projectors, etc.) */
140 int width_mm;
141 int height_mm;
142
143 /* Actual mode we give to hw */
144 int clock_index;
145 int synth_clock;
146 int crtc_hdisplay;
147 int crtc_hblank_start;
148 int crtc_hblank_end;
149 int crtc_hsync_start;
150 int crtc_hsync_end;
151 int crtc_htotal;
152 int crtc_hskew;
153 int crtc_vdisplay;
154 int crtc_vblank_start;
155 int crtc_vblank_end;
156 int crtc_vsync_start;
157 int crtc_vsync_end;
158 int crtc_vtotal;
159 int crtc_hadjusted;
160 int crtc_vadjusted;
161
162 /* Driver private mode info */
163 int private_size;
164 int *private;
165 int private_flags;
166
167 int vrefresh;
168 float hsync;
169};
170
171enum drm_connector_status {
172 connector_status_connected = 1,
173 connector_status_disconnected = 2,
174 connector_status_unknown = 3,
175};
176
177enum subpixel_order {
178 SubPixelUnknown = 0,
179 SubPixelHorizontalRGB,
180 SubPixelHorizontalBGR,
181 SubPixelVerticalRGB,
182 SubPixelVerticalBGR,
183 SubPixelNone,
184};
185
186
187/*
188 * Describes a given display (e.g. CRT or flat panel) and its limitations.
189 */
190struct drm_display_info {
191 char name[DRM_DISPLAY_INFO_LEN];
192 /* Input info */
193 bool serration_vsync;
194 bool sync_on_green;
195 bool composite_sync;
196 bool separate_syncs;
197 bool blank_to_black;
198 unsigned char video_level;
199 bool digital;
200 /* Physical size */
201 unsigned int width_mm;
202 unsigned int height_mm;
203
204 /* Display parameters */
205 unsigned char gamma; /* FIXME: storage format */
206 bool gtf_supported;
207 bool standard_color;
208 enum {
209 monochrome = 0,
210 rgb,
211 other,
212 unknown,
213 } display_type;
214 bool active_off_supported;
215 bool suspend_supported;
216 bool standby_supported;
217
218 /* Color info FIXME: storage format */
219 unsigned short redx, redy;
220 unsigned short greenx, greeny;
221 unsigned short bluex, bluey;
222 unsigned short whitex, whitey;
223
224 /* Clock limits FIXME: storage format */
225 unsigned int min_vfreq, max_vfreq;
226 unsigned int min_hfreq, max_hfreq;
227 unsigned int pixel_clock;
228
229 /* White point indices FIXME: storage format */
230 unsigned int wpx1, wpy1;
231 unsigned int wpgamma1;
232 unsigned int wpx2, wpy2;
233 unsigned int wpgamma2;
234
235 enum subpixel_order subpixel_order;
236
237 char *raw_edid; /* if any */
238};
239
240struct drm_framebuffer_funcs {
241 void (*destroy)(struct drm_framebuffer *framebuffer);
242 int (*create_handle)(struct drm_framebuffer *fb,
243 struct drm_file *file_priv,
244 unsigned int *handle);
245};
246
247struct drm_framebuffer {
248 struct drm_device *dev;
249 struct list_head head;
250 struct drm_mode_object base;
251 const struct drm_framebuffer_funcs *funcs;
252 unsigned int pitch;
253 unsigned int width;
254 unsigned int height;
255 /* depth can be 15 or 16 */
256 unsigned int depth;
257 int bits_per_pixel;
258 int flags;
259 void *fbdev;
260 u32 pseudo_palette[17];
261 struct list_head filp_head;
262};
263
264struct drm_property_blob {
265 struct drm_mode_object base;
266 struct list_head head;
267 unsigned int length;
268 void *data;
269};
270
271struct drm_property_enum {
272 uint64_t value;
273 struct list_head head;
274 char name[DRM_PROP_NAME_LEN];
275};
276
277struct drm_property {
278 struct list_head head;
279 struct drm_mode_object base;
280 uint32_t flags;
281 char name[DRM_PROP_NAME_LEN];
282 uint32_t num_values;
283 uint64_t *values;
284
285 struct list_head enum_blob_list;
286};
287
288struct drm_crtc;
289struct drm_connector;
290struct drm_encoder;
291
292/**
293 * drm_crtc_funcs - control CRTCs for a given device
294 * @dpms: control display power levels
295 * @save: save CRTC state
296 * @resore: restore CRTC state
297 * @lock: lock the CRTC
298 * @unlock: unlock the CRTC
299 * @shadow_allocate: allocate shadow pixmap
300 * @shadow_create: create shadow pixmap for rotation support
301 * @shadow_destroy: free shadow pixmap
302 * @mode_fixup: fixup proposed mode
303 * @mode_set: set the desired mode on the CRTC
304 * @gamma_set: specify color ramp for CRTC
305 * @destroy: deinit and free object.
306 *
307 * The drm_crtc_funcs structure is the central CRTC management structure
308 * in the DRM. Each CRTC controls one or more connectors (note that the name
309 * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
310 * connectors, not just CRTs).
311 *
312 * Each driver is responsible for filling out this structure at startup time,
313 * in addition to providing other modesetting features, like i2c and DDC
314 * bus accessors.
315 */
316struct drm_crtc_funcs {
317 /* Save CRTC state */
318 void (*save)(struct drm_crtc *crtc); /* suspend? */
319 /* Restore CRTC state */
320 void (*restore)(struct drm_crtc *crtc); /* resume? */
321
322 /* cursor controls */
323 int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
324 uint32_t handle, uint32_t width, uint32_t height);
325 int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
326
327 /* Set gamma on the CRTC */
328 void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
329 uint32_t size);
330 /* Object destroy routine */
331 void (*destroy)(struct drm_crtc *crtc);
332
333 int (*set_config)(struct drm_mode_set *set);
334};
335
336/**
337 * drm_crtc - central CRTC control structure
338 * @enabled: is this CRTC enabled?
339 * @x: x position on screen
340 * @y: y position on screen
341 * @desired_mode: new desired mode
342 * @desired_x: desired x for desired_mode
343 * @desired_y: desired y for desired_mode
344 * @funcs: CRTC control functions
345 *
346 * Each CRTC may have one or more connectors associated with it. This structure
347 * allows the CRTC to be controlled.
348 */
349struct drm_crtc {
350 struct drm_device *dev;
351 struct list_head head;
352
353 struct drm_mode_object base;
354
355 /* framebuffer the connector is currently bound to */
356 struct drm_framebuffer *fb;
357
358 bool enabled;
359
360 struct drm_display_mode mode;
361
362 int x, y;
363 struct drm_display_mode *desired_mode;
364 int desired_x, desired_y;
365 const struct drm_crtc_funcs *funcs;
366
367 /* CRTC gamma size for reporting to userspace */
368 uint32_t gamma_size;
369 uint16_t *gamma_store;
370
371 /* if you are using the helper */
372 void *helper_private;
373};
374
375
376/**
377 * drm_connector_funcs - control connectors on a given device
378 * @dpms: set power state (see drm_crtc_funcs above)
379 * @save: save connector state
380 * @restore: restore connector state
381 * @mode_valid: is this mode valid on the given connector?
382 * @mode_fixup: try to fixup proposed mode for this connector
383 * @mode_set: set this mode
384 * @detect: is this connector active?
385 * @get_modes: get mode list for this connector
386 * @set_property: property for this connector may need update
387 * @destroy: make object go away
388 *
389 * Each CRTC may have one or more connectors attached to it. The functions
390 * below allow the core DRM code to control connectors, enumerate available modes,
391 * etc.
392 */
393struct drm_connector_funcs {
394 void (*dpms)(struct drm_connector *connector, int mode);
395 void (*save)(struct drm_connector *connector);
396 void (*restore)(struct drm_connector *connector);
397 enum drm_connector_status (*detect)(struct drm_connector *connector);
398 void (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
399 int (*set_property)(struct drm_connector *connector, struct drm_property *property,
400 uint64_t val);
401 void (*destroy)(struct drm_connector *connector);
402};
403
404struct drm_encoder_funcs {
405 void (*destroy)(struct drm_encoder *encoder);
406};
407
408#define DRM_CONNECTOR_MAX_UMODES 16
409#define DRM_CONNECTOR_MAX_PROPERTY 16
410#define DRM_CONNECTOR_LEN 32
411#define DRM_CONNECTOR_MAX_ENCODER 2
412
413/**
414 * drm_encoder - central DRM encoder structure
415 */
416struct drm_encoder {
417 struct drm_device *dev;
418 struct list_head head;
419
420 struct drm_mode_object base;
421 int encoder_type;
422 uint32_t possible_crtcs;
423 uint32_t possible_clones;
424
425 struct drm_crtc *crtc;
426 const struct drm_encoder_funcs *funcs;
427 void *helper_private;
428};
429
430/**
431 * drm_connector - central DRM connector control structure
432 * @crtc: CRTC this connector is currently connected to, NULL if none
433 * @interlace_allowed: can this connector handle interlaced modes?
434 * @doublescan_allowed: can this connector handle doublescan?
435 * @available_modes: modes available on this connector (from get_modes() + user)
436 * @initial_x: initial x position for this connector
437 * @initial_y: initial y position for this connector
438 * @status: connector connected?
439 * @funcs: connector control functions
440 *
441 * Each connector may be connected to one or more CRTCs, or may be clonable by
442 * another connector if they can share a CRTC. Each connector also has a specific
443 * position in the broader display (referred to as a 'screen' though it could
444 * span multiple monitors).
445 */
446struct drm_connector {
447 struct drm_device *dev;
448 struct device kdev;
449 struct device_attribute *attr;
450 struct list_head head;
451
452 struct drm_mode_object base;
453
454 int connector_type;
455 int connector_type_id;
456 bool interlace_allowed;
457 bool doublescan_allowed;
458 struct list_head modes; /* list of modes on this connector */
459
460 int initial_x, initial_y;
461 enum drm_connector_status status;
462
463 /* these are modes added by probing with DDC or the BIOS */
464 struct list_head probed_modes;
465
466 struct drm_display_info display_info;
467 const struct drm_connector_funcs *funcs;
468
469 struct list_head user_modes;
470 struct drm_property_blob *edid_blob_ptr;
471 u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
472 uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
473
474 void *helper_private;
475
476 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
477 uint32_t force_encoder_id;
478 struct drm_encoder *encoder; /* currently active encoder */
479};
480
481/**
482 * struct drm_mode_set
483 *
484 * Represents a single crtc the connectors that it drives with what mode
485 * and from which framebuffer it scans out from.
486 *
487 * This is used to set modes.
488 */
489struct drm_mode_set {
490 struct list_head head;
491
492 struct drm_framebuffer *fb;
493 struct drm_crtc *crtc;
494 struct drm_display_mode *mode;
495
496 uint32_t x;
497 uint32_t y;
498
499 struct drm_connector **connectors;
500 size_t num_connectors;
501};
502
503/**
504 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
505 * @resize: adjust CRTCs as necessary for the proposed layout
506 *
507 * Currently only a resize hook is available. DRM will call back into the
508 * driver with a new screen width and height. If the driver can't support
509 * the proposed size, it can return false. Otherwise it should adjust
510 * the CRTC<->connector mappings as needed and update its view of the screen.
511 */
512struct drm_mode_config_funcs {
513 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
514 int (*fb_changed)(struct drm_device *dev);
515};
516
517struct drm_mode_group {
518 uint32_t num_crtcs;
519 uint32_t num_encoders;
520 uint32_t num_connectors;
521
522 /* list of object IDs for this group */
523 uint32_t *id_list;
524};
525
526/**
527 * drm_mode_config - Mode configuration control structure
528 *
529 */
530struct drm_mode_config {
531 struct mutex mutex; /* protects configuration and IDR */
532 struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
533 /* this is limited to one for now */
534 int num_fb;
535 struct list_head fb_list;
536 int num_connector;
537 struct list_head connector_list;
538 int num_encoder;
539 struct list_head encoder_list;
540
541 int num_crtc;
542 struct list_head crtc_list;
543
544 struct list_head property_list;
545
546 /* in-kernel framebuffers - hung of filp_head in drm_framebuffer */
547 struct list_head fb_kernel_list;
548
549 int min_width, min_height;
550 int max_width, max_height;
551 struct drm_mode_config_funcs *funcs;
552 unsigned long fb_base;
553
554 /* pointers to standard properties */
555 struct list_head property_blob_list;
556 struct drm_property *edid_property;
557 struct drm_property *dpms_property;
558
559 /* DVI-I properties */
560 struct drm_property *dvi_i_subconnector_property;
561 struct drm_property *dvi_i_select_subconnector_property;
562
563 /* TV properties */
564 struct drm_property *tv_subconnector_property;
565 struct drm_property *tv_select_subconnector_property;
566 struct drm_property *tv_mode_property;
567 struct drm_property *tv_left_margin_property;
568 struct drm_property *tv_right_margin_property;
569 struct drm_property *tv_top_margin_property;
570 struct drm_property *tv_bottom_margin_property;
571
572 /* Optional properties */
573 struct drm_property *scaling_mode_property;
574 struct drm_property *dithering_mode_property;
575};
576
577#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
578#define obj_to_connector(x) container_of(x, struct drm_connector, base)
579#define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
580#define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
581#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
582#define obj_to_property(x) container_of(x, struct drm_property, base)
583#define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
584
585
586extern void drm_crtc_init(struct drm_device *dev,
587 struct drm_crtc *crtc,
588 const struct drm_crtc_funcs *funcs);
589extern void drm_crtc_cleanup(struct drm_crtc *crtc);
590
591extern void drm_connector_init(struct drm_device *dev,
592 struct drm_connector *connector,
593 const struct drm_connector_funcs *funcs,
594 int connector_type);
595
596extern void drm_connector_cleanup(struct drm_connector *connector);
597
598extern void drm_encoder_init(struct drm_device *dev,
599 struct drm_encoder *encoder,
600 const struct drm_encoder_funcs *funcs,
601 int encoder_type);
602
603extern void drm_encoder_cleanup(struct drm_encoder *encoder);
604
605extern char *drm_get_connector_name(struct drm_connector *connector);
606extern char *drm_get_dpms_name(int val);
607extern char *drm_get_dvi_i_subconnector_name(int val);
608extern char *drm_get_dvi_i_select_name(int val);
609extern char *drm_get_tv_subconnector_name(int val);
610extern char *drm_get_tv_select_name(int val);
611extern void drm_fb_release(struct file *filp);
612extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
613extern struct edid *drm_get_edid(struct drm_connector *connector,
614 struct i2c_adapter *adapter);
615extern unsigned char *drm_do_probe_ddc_edid(struct i2c_adapter *adapter);
616extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
617extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
618extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
619extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
620 struct drm_display_mode *mode);
621extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
622extern void drm_mode_config_init(struct drm_device *dev);
623extern void drm_mode_config_cleanup(struct drm_device *dev);
624extern void drm_mode_set_name(struct drm_display_mode *mode);
625extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2);
626extern int drm_mode_width(struct drm_display_mode *mode);
627extern int drm_mode_height(struct drm_display_mode *mode);
628
629/* for us by fb module */
630extern int drm_mode_attachmode_crtc(struct drm_device *dev,
631 struct drm_crtc *crtc,
632 struct drm_display_mode *mode);
633extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode);
634
635extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
636extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
637extern void drm_mode_list_concat(struct list_head *head,
638 struct list_head *new);
639extern void drm_mode_validate_size(struct drm_device *dev,
640 struct list_head *mode_list,
641 int maxX, int maxY, int maxPitch);
642extern void drm_mode_prune_invalid(struct drm_device *dev,
643 struct list_head *mode_list, bool verbose);
644extern void drm_mode_sort(struct list_head *mode_list);
645extern int drm_mode_vrefresh(struct drm_display_mode *mode);
646extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
647 int adjust_flags);
648extern void drm_mode_connector_list_update(struct drm_connector *connector);
649extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
650 struct edid *edid);
651extern int drm_connector_property_set_value(struct drm_connector *connector,
652 struct drm_property *property,
653 uint64_t value);
654extern int drm_connector_property_get_value(struct drm_connector *connector,
655 struct drm_property *property,
656 uint64_t *value);
657extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev);
658extern void drm_framebuffer_set_object(struct drm_device *dev,
659 unsigned long handle);
660extern int drm_framebuffer_init(struct drm_device *dev,
661 struct drm_framebuffer *fb,
662 const struct drm_framebuffer_funcs *funcs);
663extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
664extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc);
665extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
666extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY);
667extern bool drm_crtc_in_use(struct drm_crtc *crtc);
668
669extern int drm_connector_attach_property(struct drm_connector *connector,
670 struct drm_property *property, uint64_t init_val);
671extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
672 const char *name, int num_values);
673extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
674extern int drm_property_add_enum(struct drm_property *property, int index,
675 uint64_t value, const char *name);
676extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
677extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
678 char *formats[]);
679extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
680extern int drm_mode_create_dithering_property(struct drm_device *dev);
681extern char *drm_get_encoder_name(struct drm_encoder *encoder);
682
683extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
684 struct drm_encoder *encoder);
685extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
686 struct drm_encoder *encoder);
687extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
688 int gamma_size);
689extern void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type);
690/* IOCTLs */
691extern int drm_mode_getresources(struct drm_device *dev,
692 void *data, struct drm_file *file_priv);
693
694extern int drm_mode_getcrtc(struct drm_device *dev,
695 void *data, struct drm_file *file_priv);
696extern int drm_mode_getconnector(struct drm_device *dev,
697 void *data, struct drm_file *file_priv);
698extern int drm_mode_setcrtc(struct drm_device *dev,
699 void *data, struct drm_file *file_priv);
700extern int drm_mode_cursor_ioctl(struct drm_device *dev,
701 void *data, struct drm_file *file_priv);
702extern int drm_mode_addfb(struct drm_device *dev,
703 void *data, struct drm_file *file_priv);
704extern int drm_mode_rmfb(struct drm_device *dev,
705 void *data, struct drm_file *file_priv);
706extern int drm_mode_getfb(struct drm_device *dev,
707 void *data, struct drm_file *file_priv);
708extern int drm_mode_addmode_ioctl(struct drm_device *dev,
709 void *data, struct drm_file *file_priv);
710extern int drm_mode_rmmode_ioctl(struct drm_device *dev,
711 void *data, struct drm_file *file_priv);
712extern int drm_mode_attachmode_ioctl(struct drm_device *dev,
713 void *data, struct drm_file *file_priv);
714extern int drm_mode_detachmode_ioctl(struct drm_device *dev,
715 void *data, struct drm_file *file_priv);
716
717extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
718 void *data, struct drm_file *file_priv);
719extern int drm_mode_getblob_ioctl(struct drm_device *dev,
720 void *data, struct drm_file *file_priv);
721extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
722 void *data, struct drm_file *file_priv);
723extern int drm_mode_hotplug_ioctl(struct drm_device *dev,
724 void *data, struct drm_file *file_priv);
725extern int drm_mode_replacefb(struct drm_device *dev,
726 void *data, struct drm_file *file_priv);
727extern int drm_mode_getencoder(struct drm_device *dev,
728 void *data, struct drm_file *file_priv);
729extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
730 void *data, struct drm_file *file_priv);
731extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
732 void *data, struct drm_file *file_priv);
733#endif /* __DRM_CRTC_H__ */
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
new file mode 100644
index 000000000000..4bc04cf460a7
--- /dev/null
+++ b/include/drm/drm_crtc_helper.h
@@ -0,0 +1,124 @@
1/*
2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26/*
27 * The DRM mode setting helper functions are common code for drivers to use if
28 * they wish. Drivers are not forced to use this code in their
29 * implementations but it would be useful if they code they do use at least
30 * provides a consistent interface and operation to userspace
31 */
32
33#ifndef __DRM_CRTC_HELPER_H__
34#define __DRM_CRTC_HELPER_H__
35
36#include <linux/i2c.h>
37#include <linux/spinlock.h>
38#include <linux/types.h>
39#include <linux/idr.h>
40
41#include <linux/fb.h>
42
43struct drm_crtc_helper_funcs {
44 /*
45 * Control power levels on the CRTC. If the mode passed in is
46 * unsupported, the provider must use the next lowest power level.
47 */
48 void (*dpms)(struct drm_crtc *crtc, int mode);
49 void (*prepare)(struct drm_crtc *crtc);
50 void (*commit)(struct drm_crtc *crtc);
51
52 /* Provider can fixup or change mode timings before modeset occurs */
53 bool (*mode_fixup)(struct drm_crtc *crtc,
54 struct drm_display_mode *mode,
55 struct drm_display_mode *adjusted_mode);
56 /* Actually set the mode */
57 void (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
58 struct drm_display_mode *adjusted_mode, int x, int y,
59 struct drm_framebuffer *old_fb);
60
61 /* Move the crtc on the current fb to the given position *optional* */
62 void (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
63 struct drm_framebuffer *old_fb);
64};
65
66struct drm_encoder_helper_funcs {
67 void (*dpms)(struct drm_encoder *encoder, int mode);
68 void (*save)(struct drm_encoder *encoder);
69 void (*restore)(struct drm_encoder *encoder);
70
71 bool (*mode_fixup)(struct drm_encoder *encoder,
72 struct drm_display_mode *mode,
73 struct drm_display_mode *adjusted_mode);
74 void (*prepare)(struct drm_encoder *encoder);
75 void (*commit)(struct drm_encoder *encoder);
76 void (*mode_set)(struct drm_encoder *encoder,
77 struct drm_display_mode *mode,
78 struct drm_display_mode *adjusted_mode);
79 /* detect for DAC style encoders */
80 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
81 struct drm_connector *connector);
82};
83
84struct drm_connector_helper_funcs {
85 int (*get_modes)(struct drm_connector *connector);
86 int (*mode_valid)(struct drm_connector *connector,
87 struct drm_display_mode *mode);
88 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
89};
90
91extern void drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY);
92extern void drm_helper_disable_unused_functions(struct drm_device *dev);
93extern int drm_helper_hotplug_stage_two(struct drm_device *dev);
94extern bool drm_helper_initial_config(struct drm_device *dev, bool can_grow);
95extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
96extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
97 struct drm_display_mode *mode,
98 int x, int y,
99 struct drm_framebuffer *old_fb);
100extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
101
102extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
103 struct drm_mode_fb_cmd *mode_cmd);
104
105static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
106 const struct drm_crtc_helper_funcs *funcs)
107{
108 crtc->helper_private = (void *)funcs;
109}
110
111static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
112 const struct drm_encoder_helper_funcs *funcs)
113{
114 encoder->helper_private = (void *)funcs;
115}
116
117static inline void drm_connector_helper_add(struct drm_connector *connector,
118 const struct drm_connector_helper_funcs *funcs)
119{
120 connector->helper_private = (void *)funcs;
121}
122
123extern int drm_helper_resume_force_mode(struct drm_device *dev);
124#endif
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
new file mode 100644
index 000000000000..c707c15f5164
--- /dev/null
+++ b/include/drm/drm_edid.h
@@ -0,0 +1,202 @@
1/*
2 * Copyright © 2007-2008 Intel Corporation
3 * Jesse Barnes <jesse.barnes@intel.com>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 */
23#ifndef __DRM_EDID_H__
24#define __DRM_EDID_H__
25
26#include <linux/types.h>
27
28#define EDID_LENGTH 128
29#define DDC_ADDR 0x50
30
31#ifdef BIG_ENDIAN
32#error "EDID structure is little endian, need big endian versions"
33#else
34
35struct est_timings {
36 u8 t1;
37 u8 t2;
38 u8 mfg_rsvd;
39} __attribute__((packed));
40
41struct std_timing {
42 u8 hsize; /* need to multiply by 8 then add 248 */
43 u8 vfreq:6; /* need to add 60 */
44 u8 aspect_ratio:2; /* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
45} __attribute__((packed));
46
47/* If detailed data is pixel timing */
48struct detailed_pixel_timing {
49 u8 hactive_lo;
50 u8 hblank_lo;
51 u8 hblank_hi:4;
52 u8 hactive_hi:4;
53 u8 vactive_lo;
54 u8 vblank_lo;
55 u8 vblank_hi:4;
56 u8 vactive_hi:4;
57 u8 hsync_offset_lo;
58 u8 hsync_pulse_width_lo;
59 u8 vsync_pulse_width_lo:4;
60 u8 vsync_offset_lo:4;
61 u8 hsync_pulse_width_hi:2;
62 u8 hsync_offset_hi:2;
63 u8 vsync_pulse_width_hi:2;
64 u8 vsync_offset_hi:2;
65 u8 width_mm_lo;
66 u8 height_mm_lo;
67 u8 height_mm_hi:4;
68 u8 width_mm_hi:4;
69 u8 hborder;
70 u8 vborder;
71 u8 unknown0:1;
72 u8 vsync_positive:1;
73 u8 hsync_positive:1;
74 u8 separate_sync:2;
75 u8 stereo:1;
76 u8 unknown6:1;
77 u8 interlaced:1;
78} __attribute__((packed));
79
80/* If it's not pixel timing, it'll be one of the below */
81struct detailed_data_string {
82 u8 str[13];
83} __attribute__((packed));
84
85struct detailed_data_monitor_range {
86 u8 min_vfreq;
87 u8 max_vfreq;
88 u8 min_hfreq_khz;
89 u8 max_hfreq_khz;
90 u8 pixel_clock_mhz; /* need to multiply by 10 */
91 u16 sec_gtf_toggle; /* A000=use above, 20=use below */ /* FIXME: byte order */
92 u8 hfreq_start_khz; /* need to multiply by 2 */
93 u8 c; /* need to divide by 2 */
94 u16 m; /* FIXME: byte order */
95 u8 k;
96 u8 j; /* need to divide by 2 */
97} __attribute__((packed));
98
99struct detailed_data_wpindex {
100 u8 white_y_lo:2;
101 u8 white_x_lo:2;
102 u8 pad:4;
103 u8 white_x_hi;
104 u8 white_y_hi;
105 u8 gamma; /* need to divide by 100 then add 1 */
106} __attribute__((packed));
107
108struct detailed_data_color_point {
109 u8 windex1;
110 u8 wpindex1[3];
111 u8 windex2;
112 u8 wpindex2[3];
113} __attribute__((packed));
114
115struct detailed_non_pixel {
116 u8 pad1;
117 u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
118 fb=color point data, fa=standard timing data,
119 f9=undefined, f8=mfg. reserved */
120 u8 pad2;
121 union {
122 struct detailed_data_string str;
123 struct detailed_data_monitor_range range;
124 struct detailed_data_wpindex color;
125 struct std_timing timings[5];
126 } data;
127} __attribute__((packed));
128
129#define EDID_DETAIL_STD_MODES 0xfa
130#define EDID_DETAIL_MONITOR_CPDATA 0xfb
131#define EDID_DETAIL_MONITOR_NAME 0xfc
132#define EDID_DETAIL_MONITOR_RANGE 0xfd
133#define EDID_DETAIL_MONITOR_STRING 0xfe
134#define EDID_DETAIL_MONITOR_SERIAL 0xff
135
136struct detailed_timing {
137 u16 pixel_clock; /* need to multiply by 10 KHz */ /* FIXME: byte order */
138 union {
139 struct detailed_pixel_timing pixel_data;
140 struct detailed_non_pixel other_data;
141 } data;
142} __attribute__((packed));
143
144struct edid {
145 u8 header[8];
146 /* Vendor & product info */
147 u8 mfg_id[2];
148 u8 prod_code[2];
149 u32 serial; /* FIXME: byte order */
150 u8 mfg_week;
151 u8 mfg_year;
152 /* EDID version */
153 u8 version;
154 u8 revision;
155 /* Display info: */
156 /* input definition */
157 u8 serration_vsync:1;
158 u8 sync_on_green:1;
159 u8 composite_sync:1;
160 u8 separate_syncs:1;
161 u8 blank_to_black:1;
162 u8 video_level:2;
163 u8 digital:1; /* bits below must be zero if set */
164 u8 width_cm;
165 u8 height_cm;
166 u8 gamma;
167 /* feature support */
168 u8 default_gtf:1;
169 u8 preferred_timing:1;
170 u8 standard_color:1;
171 u8 display_type:2; /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
172 u8 pm_active_off:1;
173 u8 pm_suspend:1;
174 u8 pm_standby:1;
175 /* Color characteristics */
176 u8 red_green_lo;
177 u8 black_white_lo;
178 u8 red_x;
179 u8 red_y;
180 u8 green_x;
181 u8 green_y;
182 u8 blue_x;
183 u8 blue_y;
184 u8 white_x;
185 u8 white_y;
186 /* Est. timings and mfg rsvd timings*/
187 struct est_timings established_timings;
188 /* Standard timings 1-8*/
189 struct std_timing standard_timings[8];
190 /* Detailing timings 1-4 */
191 struct detailed_timing detailed_timings[4];
192 /* Number of 128 byte ext. blocks */
193 u8 extensions;
194 /* Checksum */
195 u8 checksum;
196} __attribute__((packed));
197
198#endif /* little endian structs */
199
200#define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
201
202#endif /* __DRM_EDID_H__ */
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
new file mode 100644
index 000000000000..601d2bd839f6
--- /dev/null
+++ b/include/drm/drm_mode.h
@@ -0,0 +1,271 @@
1/*
2 * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
3 * Copyright (c) 2007 Jakob Bornecrantz <wallbraker@gmail.com>
4 * Copyright (c) 2008 Red Hat Inc.
5 * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
6 * Copyright (c) 2007-2008 Intel Corporation
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * IN THE SOFTWARE.
25 */
26
27#ifndef _DRM_MODE_H
28#define _DRM_MODE_H
29
30#if !defined(__KERNEL__) && !defined(_KERNEL)
31#include <stdint.h>
32#else
33#include <linux/kernel.h>
34#endif
35
36#define DRM_DISPLAY_INFO_LEN 32
37#define DRM_CONNECTOR_NAME_LEN 32
38#define DRM_DISPLAY_MODE_LEN 32
39#define DRM_PROP_NAME_LEN 32
40
41#define DRM_MODE_TYPE_BUILTIN (1<<0)
42#define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
43#define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN)
44#define DRM_MODE_TYPE_PREFERRED (1<<3)
45#define DRM_MODE_TYPE_DEFAULT (1<<4)
46#define DRM_MODE_TYPE_USERDEF (1<<5)
47#define DRM_MODE_TYPE_DRIVER (1<<6)
48
49/* Video mode flags */
50/* bit compatible with the xorg definitions. */
51#define DRM_MODE_FLAG_PHSYNC (1<<0)
52#define DRM_MODE_FLAG_NHSYNC (1<<1)
53#define DRM_MODE_FLAG_PVSYNC (1<<2)
54#define DRM_MODE_FLAG_NVSYNC (1<<3)
55#define DRM_MODE_FLAG_INTERLACE (1<<4)
56#define DRM_MODE_FLAG_DBLSCAN (1<<5)
57#define DRM_MODE_FLAG_CSYNC (1<<6)
58#define DRM_MODE_FLAG_PCSYNC (1<<7)
59#define DRM_MODE_FLAG_NCSYNC (1<<8)
60#define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
61#define DRM_MODE_FLAG_BCAST (1<<10)
62#define DRM_MODE_FLAG_PIXMUX (1<<11)
63#define DRM_MODE_FLAG_DBLCLK (1<<12)
64#define DRM_MODE_FLAG_CLKDIV2 (1<<13)
65
66/* DPMS flags */
67/* bit compatible with the xorg definitions. */
68#define DRM_MODE_DPMS_ON 0
69#define DRM_MODE_DPMS_STANDBY 1
70#define DRM_MODE_DPMS_SUSPEND 2
71#define DRM_MODE_DPMS_OFF 3
72
73/* Scaling mode options */
74#define DRM_MODE_SCALE_NON_GPU 0
75#define DRM_MODE_SCALE_FULLSCREEN 1
76#define DRM_MODE_SCALE_NO_SCALE 2
77#define DRM_MODE_SCALE_ASPECT 3
78
79/* Dithering mode options */
80#define DRM_MODE_DITHERING_OFF 0
81#define DRM_MODE_DITHERING_ON 1
82
83struct drm_mode_modeinfo {
84 uint32_t clock;
85 uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
86 uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
87
88 uint32_t vrefresh; /* vertical refresh * 1000 */
89
90 uint32_t flags;
91 uint32_t type;
92 char name[DRM_DISPLAY_MODE_LEN];
93};
94
95struct drm_mode_card_res {
96 uint64_t fb_id_ptr;
97 uint64_t crtc_id_ptr;
98 uint64_t connector_id_ptr;
99 uint64_t encoder_id_ptr;
100 uint32_t count_fbs;
101 uint32_t count_crtcs;
102 uint32_t count_connectors;
103 uint32_t count_encoders;
104 uint32_t min_width, max_width;
105 uint32_t min_height, max_height;
106};
107
108struct drm_mode_crtc {
109 uint64_t set_connectors_ptr;
110 uint32_t count_connectors;
111
112 uint32_t crtc_id; /**< Id */
113 uint32_t fb_id; /**< Id of framebuffer */
114
115 uint32_t x, y; /**< Position on the frameuffer */
116
117 uint32_t gamma_size;
118 uint32_t mode_valid;
119 struct drm_mode_modeinfo mode;
120};
121
122#define DRM_MODE_ENCODER_NONE 0
123#define DRM_MODE_ENCODER_DAC 1
124#define DRM_MODE_ENCODER_TMDS 2
125#define DRM_MODE_ENCODER_LVDS 3
126#define DRM_MODE_ENCODER_TVDAC 4
127
128struct drm_mode_get_encoder {
129 uint32_t encoder_id;
130 uint32_t encoder_type;
131
132 uint32_t crtc_id; /**< Id of crtc */
133
134 uint32_t possible_crtcs;
135 uint32_t possible_clones;
136};
137
138/* This is for connectors with multiple signal types. */
139/* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
140#define DRM_MODE_SUBCONNECTOR_Automatic 0
141#define DRM_MODE_SUBCONNECTOR_Unknown 0
142#define DRM_MODE_SUBCONNECTOR_DVID 3
143#define DRM_MODE_SUBCONNECTOR_DVIA 4
144#define DRM_MODE_SUBCONNECTOR_Composite 5
145#define DRM_MODE_SUBCONNECTOR_SVIDEO 6
146#define DRM_MODE_SUBCONNECTOR_Component 8
147
148#define DRM_MODE_CONNECTOR_Unknown 0
149#define DRM_MODE_CONNECTOR_VGA 1
150#define DRM_MODE_CONNECTOR_DVII 2
151#define DRM_MODE_CONNECTOR_DVID 3
152#define DRM_MODE_CONNECTOR_DVIA 4
153#define DRM_MODE_CONNECTOR_Composite 5
154#define DRM_MODE_CONNECTOR_SVIDEO 6
155#define DRM_MODE_CONNECTOR_LVDS 7
156#define DRM_MODE_CONNECTOR_Component 8
157#define DRM_MODE_CONNECTOR_9PinDIN 9
158#define DRM_MODE_CONNECTOR_DisplayPort 10
159#define DRM_MODE_CONNECTOR_HDMIA 11
160#define DRM_MODE_CONNECTOR_HDMIB 12
161
162struct drm_mode_get_connector {
163
164 uint64_t encoders_ptr;
165 uint64_t modes_ptr;
166 uint64_t props_ptr;
167 uint64_t prop_values_ptr;
168
169 uint32_t count_modes;
170 uint32_t count_props;
171 uint32_t count_encoders;
172
173 uint32_t encoder_id; /**< Current Encoder */
174 uint32_t connector_id; /**< Id */
175 uint32_t connector_type;
176 uint32_t connector_type_id;
177
178 uint32_t connection;
179 uint32_t mm_width, mm_height; /**< HxW in millimeters */
180 uint32_t subpixel;
181};
182
183#define DRM_MODE_PROP_PENDING (1<<0)
184#define DRM_MODE_PROP_RANGE (1<<1)
185#define DRM_MODE_PROP_IMMUTABLE (1<<2)
186#define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
187#define DRM_MODE_PROP_BLOB (1<<4)
188
189struct drm_mode_property_enum {
190 uint64_t value;
191 char name[DRM_PROP_NAME_LEN];
192};
193
194struct drm_mode_get_property {
195 uint64_t values_ptr; /* values and blob lengths */
196 uint64_t enum_blob_ptr; /* enum and blob id ptrs */
197
198 uint32_t prop_id;
199 uint32_t flags;
200 char name[DRM_PROP_NAME_LEN];
201
202 uint32_t count_values;
203 uint32_t count_enum_blobs;
204};
205
206struct drm_mode_connector_set_property {
207 uint64_t value;
208 uint32_t prop_id;
209 uint32_t connector_id;
210};
211
212struct drm_mode_get_blob {
213 uint32_t blob_id;
214 uint32_t length;
215 uint64_t data;
216};
217
218struct drm_mode_fb_cmd {
219 uint32_t fb_id;
220 uint32_t width, height;
221 uint32_t pitch;
222 uint32_t bpp;
223 uint32_t depth;
224 /* driver specific handle */
225 uint32_t handle;
226};
227
228struct drm_mode_mode_cmd {
229 uint32_t connector_id;
230 struct drm_mode_modeinfo mode;
231};
232
233#define DRM_MODE_CURSOR_BO (1<<0)
234#define DRM_MODE_CURSOR_MOVE (1<<1)
235
236/*
237 * depending on the value in flags diffrent members are used.
238 *
239 * CURSOR_BO uses
240 * crtc
241 * width
242 * height
243 * handle - if 0 turns the cursor of
244 *
245 * CURSOR_MOVE uses
246 * crtc
247 * x
248 * y
249 */
250struct drm_mode_cursor {
251 uint32_t flags;
252 uint32_t crtc_id;
253 int32_t x;
254 int32_t y;
255 uint32_t width;
256 uint32_t height;
257 /* driver specific handle */
258 uint32_t handle;
259};
260
261struct drm_mode_crtc_lut {
262 uint32_t crtc_id;
263 uint32_t gamma_size;
264
265 /* pointers to arrays */
266 uint64_t red;
267 uint64_t green;
268 uint64_t blue;
269};
270
271#endif
diff --git a/include/drm/drm_sarea.h b/include/drm/drm_sarea.h
index 480037331e4e..ee5389d22c64 100644
--- a/include/drm/drm_sarea.h
+++ b/include/drm/drm_sarea.h
@@ -36,12 +36,12 @@
36 36
37/* SAREA area needs to be at least a page */ 37/* SAREA area needs to be at least a page */
38#if defined(__alpha__) 38#if defined(__alpha__)
39#define SAREA_MAX 0x2000 39#define SAREA_MAX 0x2000U
40#elif defined(__ia64__) 40#elif defined(__ia64__)
41#define SAREA_MAX 0x10000 /* 64kB */ 41#define SAREA_MAX 0x10000U /* 64kB */
42#else 42#else
43/* Intel 830M driver needs at least 8k SAREA */ 43/* Intel 830M driver needs at least 8k SAREA */
44#define SAREA_MAX 0x2000 44#define SAREA_MAX 0x2000U
45#endif 45#endif
46 46
47/** Maximum number of drawables in the SAREA */ 47/** Maximum number of drawables in the SAREA */
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 152b34da927c..b3bcf72dc656 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -113,8 +113,31 @@ typedef struct _drm_i915_sarea {
113 int pipeB_y; 113 int pipeB_y;
114 int pipeB_w; 114 int pipeB_w;
115 int pipeB_h; 115 int pipeB_h;
116
117 /* fill out some space for old userspace triple buffer */
118 drm_handle_t unused_handle;
119 uint32_t unused1, unused2, unused3;
120
121 /* buffer object handles for static buffers. May change
122 * over the lifetime of the client.
123 */
124 uint32_t front_bo_handle;
125 uint32_t back_bo_handle;
126 uint32_t unused_bo_handle;
127 uint32_t depth_bo_handle;
128
116} drm_i915_sarea_t; 129} drm_i915_sarea_t;
117 130
131/* due to userspace building against these headers we need some compat here */
132#define planeA_x pipeA_x
133#define planeA_y pipeA_y
134#define planeA_w pipeA_w
135#define planeA_h pipeA_h
136#define planeB_x pipeB_x
137#define planeB_y pipeB_y
138#define planeB_w pipeB_w
139#define planeB_h pipeB_h
140
118/* Flags for perf_boxes 141/* Flags for perf_boxes
119 */ 142 */
120#define I915_BOX_RING_EMPTY 0x1 143#define I915_BOX_RING_EMPTY 0x1
@@ -160,6 +183,7 @@ typedef struct _drm_i915_sarea {
160#define DRM_I915_GEM_SET_TILING 0x21 183#define DRM_I915_GEM_SET_TILING 0x21
161#define DRM_I915_GEM_GET_TILING 0x22 184#define DRM_I915_GEM_GET_TILING 0x22
162#define DRM_I915_GEM_GET_APERTURE 0x23 185#define DRM_I915_GEM_GET_APERTURE 0x23
186#define DRM_I915_GEM_MMAP_GTT 0x24
163 187
164#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 188#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
165#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 189#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -177,6 +201,8 @@ typedef struct _drm_i915_sarea {
177#define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t) 201#define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
178#define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t) 202#define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
179#define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t) 203#define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
204#define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
205#define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
180#define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin) 206#define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
181#define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin) 207#define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
182#define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy) 208#define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
@@ -187,6 +213,7 @@ typedef struct _drm_i915_sarea {
187#define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread) 213#define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)
188#define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite) 214#define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)
189#define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap) 215#define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)
216#define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)
190#define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain) 217#define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)
191#define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish) 218#define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
192#define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) 219#define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
@@ -196,7 +223,7 @@ typedef struct _drm_i915_sarea {
196/* Allow drivers to submit batchbuffers directly to hardware, relying 223/* Allow drivers to submit batchbuffers directly to hardware, relying
197 * on the security mechanisms provided by hardware. 224 * on the security mechanisms provided by hardware.
198 */ 225 */
199typedef struct _drm_i915_batchbuffer { 226typedef struct drm_i915_batchbuffer {
200 int start; /* agp offset */ 227 int start; /* agp offset */
201 int used; /* nr bytes in use */ 228 int used; /* nr bytes in use */
202 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */ 229 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
@@ -382,6 +409,18 @@ struct drm_i915_gem_mmap {
382 uint64_t addr_ptr; 409 uint64_t addr_ptr;
383}; 410};
384 411
412struct drm_i915_gem_mmap_gtt {
413 /** Handle for the object being mapped. */
414 uint32_t handle;
415 uint32_t pad;
416 /**
417 * Fake offset to use for subsequent mmap call
418 *
419 * This is a fixed-size type for 32/64 compatibility.
420 */
421 uint64_t offset;
422};
423
385struct drm_i915_gem_set_domain { 424struct drm_i915_gem_set_domain {
386 /** Handle for the object */ 425 /** Handle for the object */
387 uint32_t handle; 426 uint32_t handle;
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index e531783e5d78..95ac82340c3b 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -313,6 +313,7 @@ unifdef-y += ptrace.h
313unifdef-y += qnx4_fs.h 313unifdef-y += qnx4_fs.h
314unifdef-y += quota.h 314unifdef-y += quota.h
315unifdef-y += random.h 315unifdef-y += random.h
316unifdef-y += irqnr.h
316unifdef-y += reboot.h 317unifdef-y += reboot.h
317unifdef-y += reiserfs_fs.h 318unifdef-y += reiserfs_fs.h
318unifdef-y += reiserfs_xattr.h 319unifdef-y += reiserfs_xattr.h
diff --git a/include/linux/aio.h b/include/linux/aio.h
index f6b8cf99b596..b16a957030f8 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -5,6 +5,7 @@
5#include <linux/workqueue.h> 5#include <linux/workqueue.h>
6#include <linux/aio_abi.h> 6#include <linux/aio_abi.h>
7#include <linux/uio.h> 7#include <linux/uio.h>
8#include <linux/rcupdate.h>
8 9
9#include <asm/atomic.h> 10#include <asm/atomic.h>
10 11
@@ -183,7 +184,7 @@ struct kioctx {
183 184
184 /* This needs improving */ 185 /* This needs improving */
185 unsigned long user_id; 186 unsigned long user_id;
186 struct kioctx *next; 187 struct hlist_node list;
187 188
188 wait_queue_head_t wait; 189 wait_queue_head_t wait;
189 190
@@ -199,6 +200,8 @@ struct kioctx {
199 struct aio_ring_info ring_info; 200 struct aio_ring_info ring_info;
200 201
201 struct delayed_work wq; 202 struct delayed_work wq;
203
204 struct rcu_head rcu_head;
202}; 205};
203 206
204/* prototypes */ 207/* prototypes */
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 6a642098e5c3..18462c5b8fff 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -90,10 +90,11 @@ struct bio {
90 90
91 unsigned int bi_comp_cpu; /* completion CPU */ 91 unsigned int bi_comp_cpu; /* completion CPU */
92 92
93 atomic_t bi_cnt; /* pin count */
94
93 struct bio_vec *bi_io_vec; /* the actual vec list */ 95 struct bio_vec *bi_io_vec; /* the actual vec list */
94 96
95 bio_end_io_t *bi_end_io; 97 bio_end_io_t *bi_end_io;
96 atomic_t bi_cnt; /* pin count */
97 98
98 void *bi_private; 99 void *bi_private;
99#if defined(CONFIG_BLK_DEV_INTEGRITY) 100#if defined(CONFIG_BLK_DEV_INTEGRITY)
@@ -101,6 +102,13 @@ struct bio {
101#endif 102#endif
102 103
103 bio_destructor_t *bi_destructor; /* destructor */ 104 bio_destructor_t *bi_destructor; /* destructor */
105
106 /*
107 * We can inline a number of vecs at the end of the bio, to avoid
108 * double allocations for a small number of bio_vecs. This member
109 * MUST obviously be kept at the very end of the bio.
110 */
111 struct bio_vec bi_inline_vecs[0];
104}; 112};
105 113
106/* 114/*
@@ -117,6 +125,7 @@ struct bio {
117#define BIO_CPU_AFFINE 8 /* complete bio on same CPU as submitted */ 125#define BIO_CPU_AFFINE 8 /* complete bio on same CPU as submitted */
118#define BIO_NULL_MAPPED 9 /* contains invalid user pages */ 126#define BIO_NULL_MAPPED 9 /* contains invalid user pages */
119#define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */ 127#define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */
128#define BIO_QUIET 11 /* Make BIO Quiet */
120#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) 129#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag)))
121 130
122/* 131/*
@@ -211,6 +220,11 @@ static inline void *bio_data(struct bio *bio)
211 return NULL; 220 return NULL;
212} 221}
213 222
223static inline int bio_has_allocated_vec(struct bio *bio)
224{
225 return bio->bi_io_vec && bio->bi_io_vec != bio->bi_inline_vecs;
226}
227
214/* 228/*
215 * will die 229 * will die
216 */ 230 */
@@ -332,7 +346,7 @@ struct bio_pair {
332extern struct bio_pair *bio_split(struct bio *bi, int first_sectors); 346extern struct bio_pair *bio_split(struct bio *bi, int first_sectors);
333extern void bio_pair_release(struct bio_pair *dbio); 347extern void bio_pair_release(struct bio_pair *dbio);
334 348
335extern struct bio_set *bioset_create(int, int); 349extern struct bio_set *bioset_create(unsigned int, unsigned int);
336extern void bioset_free(struct bio_set *); 350extern void bioset_free(struct bio_set *);
337 351
338extern struct bio *bio_alloc(gfp_t, int); 352extern struct bio *bio_alloc(gfp_t, int);
@@ -377,6 +391,7 @@ extern struct bio *bio_copy_user_iov(struct request_queue *,
377extern int bio_uncopy_user(struct bio *); 391extern int bio_uncopy_user(struct bio *);
378void zero_fill_bio(struct bio *bio); 392void zero_fill_bio(struct bio *bio);
379extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); 393extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *);
394extern void bvec_free_bs(struct bio_set *, struct bio_vec *, unsigned int);
380extern unsigned int bvec_nr_vecs(unsigned short idx); 395extern unsigned int bvec_nr_vecs(unsigned short idx);
381 396
382/* 397/*
@@ -395,13 +410,17 @@ static inline void bio_set_completion_cpu(struct bio *bio, unsigned int cpu)
395 */ 410 */
396#define BIO_POOL_SIZE 2 411#define BIO_POOL_SIZE 2
397#define BIOVEC_NR_POOLS 6 412#define BIOVEC_NR_POOLS 6
413#define BIOVEC_MAX_IDX (BIOVEC_NR_POOLS - 1)
398 414
399struct bio_set { 415struct bio_set {
416 struct kmem_cache *bio_slab;
417 unsigned int front_pad;
418
400 mempool_t *bio_pool; 419 mempool_t *bio_pool;
401#if defined(CONFIG_BLK_DEV_INTEGRITY) 420#if defined(CONFIG_BLK_DEV_INTEGRITY)
402 mempool_t *bio_integrity_pool; 421 mempool_t *bio_integrity_pool;
403#endif 422#endif
404 mempool_t *bvec_pools[BIOVEC_NR_POOLS]; 423 mempool_t *bvec_pool;
405}; 424};
406 425
407struct biovec_slab { 426struct biovec_slab {
@@ -411,6 +430,7 @@ struct biovec_slab {
411}; 430};
412 431
413extern struct bio_set *fs_bio_set; 432extern struct bio_set *fs_bio_set;
433extern struct biovec_slab bvec_slabs[BIOVEC_NR_POOLS] __read_mostly;
414 434
415/* 435/*
416 * a small number of entries is fine, not going to be performance critical. 436 * a small number of entries is fine, not going to be performance critical.
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 031a315c0509..7035cec583b6 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -26,7 +26,6 @@ struct scsi_ioctl_command;
26 26
27struct request_queue; 27struct request_queue;
28struct elevator_queue; 28struct elevator_queue;
29typedef struct elevator_queue elevator_t;
30struct request_pm_state; 29struct request_pm_state;
31struct blk_trace; 30struct blk_trace;
32struct request; 31struct request;
@@ -313,7 +312,7 @@ struct request_queue
313 */ 312 */
314 struct list_head queue_head; 313 struct list_head queue_head;
315 struct request *last_merge; 314 struct request *last_merge;
316 elevator_t *elevator; 315 struct elevator_queue *elevator;
317 316
318 /* 317 /*
319 * the queue request freelist, one for reads and one for writes 318 * the queue request freelist, one for reads and one for writes
@@ -449,6 +448,7 @@ struct request_queue
449#define QUEUE_FLAG_FAIL_IO 12 /* fake timeout */ 448#define QUEUE_FLAG_FAIL_IO 12 /* fake timeout */
450#define QUEUE_FLAG_STACKABLE 13 /* supports request stacking */ 449#define QUEUE_FLAG_STACKABLE 13 /* supports request stacking */
451#define QUEUE_FLAG_NONROT 14 /* non-rotational device (SSD) */ 450#define QUEUE_FLAG_NONROT 14 /* non-rotational device (SSD) */
451#define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */
452 452
453static inline int queue_is_locked(struct request_queue *q) 453static inline int queue_is_locked(struct request_queue *q)
454{ 454{
@@ -522,22 +522,32 @@ enum {
522 * TAG_FLUSH : ordering by tag w/ pre and post flushes 522 * TAG_FLUSH : ordering by tag w/ pre and post flushes
523 * TAG_FUA : ordering by tag w/ pre flush and FUA write 523 * TAG_FUA : ordering by tag w/ pre flush and FUA write
524 */ 524 */
525 QUEUE_ORDERED_NONE = 0x00, 525 QUEUE_ORDERED_BY_DRAIN = 0x01,
526 QUEUE_ORDERED_DRAIN = 0x01, 526 QUEUE_ORDERED_BY_TAG = 0x02,
527 QUEUE_ORDERED_TAG = 0x02, 527 QUEUE_ORDERED_DO_PREFLUSH = 0x10,
528 528 QUEUE_ORDERED_DO_BAR = 0x20,
529 QUEUE_ORDERED_PREFLUSH = 0x10, 529 QUEUE_ORDERED_DO_POSTFLUSH = 0x40,
530 QUEUE_ORDERED_POSTFLUSH = 0x20, 530 QUEUE_ORDERED_DO_FUA = 0x80,
531 QUEUE_ORDERED_FUA = 0x40, 531
532 532 QUEUE_ORDERED_NONE = 0x00,
533 QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN | 533
534 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH, 534 QUEUE_ORDERED_DRAIN = QUEUE_ORDERED_BY_DRAIN |
535 QUEUE_ORDERED_DRAIN_FUA = QUEUE_ORDERED_DRAIN | 535 QUEUE_ORDERED_DO_BAR,
536 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA, 536 QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN |
537 QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG | 537 QUEUE_ORDERED_DO_PREFLUSH |
538 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH, 538 QUEUE_ORDERED_DO_POSTFLUSH,
539 QUEUE_ORDERED_TAG_FUA = QUEUE_ORDERED_TAG | 539 QUEUE_ORDERED_DRAIN_FUA = QUEUE_ORDERED_DRAIN |
540 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA, 540 QUEUE_ORDERED_DO_PREFLUSH |
541 QUEUE_ORDERED_DO_FUA,
542
543 QUEUE_ORDERED_TAG = QUEUE_ORDERED_BY_TAG |
544 QUEUE_ORDERED_DO_BAR,
545 QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG |
546 QUEUE_ORDERED_DO_PREFLUSH |
547 QUEUE_ORDERED_DO_POSTFLUSH,
548 QUEUE_ORDERED_TAG_FUA = QUEUE_ORDERED_TAG |
549 QUEUE_ORDERED_DO_PREFLUSH |
550 QUEUE_ORDERED_DO_FUA,
541 551
542 /* 552 /*
543 * Ordered operation sequence 553 * Ordered operation sequence
@@ -585,7 +595,6 @@ enum {
585#define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA) 595#define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA)
586#define blk_discard_rq(rq) ((rq)->cmd_flags & REQ_DISCARD) 596#define blk_discard_rq(rq) ((rq)->cmd_flags & REQ_DISCARD)
587#define blk_bidi_rq(rq) ((rq)->next_rq != NULL) 597#define blk_bidi_rq(rq) ((rq)->next_rq != NULL)
588#define blk_empty_barrier(rq) (blk_barrier_rq(rq) && blk_fs_request(rq) && !(rq)->hard_nr_sectors)
589/* rq->queuelist of dequeued request must be list_empty() */ 598/* rq->queuelist of dequeued request must be list_empty() */
590#define blk_queued_rq(rq) (!list_empty(&(rq)->queuelist)) 599#define blk_queued_rq(rq) (!list_empty(&(rq)->queuelist))
591 600
@@ -855,10 +864,10 @@ extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *);
855extern void blk_queue_rq_timeout(struct request_queue *, unsigned int); 864extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
856extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); 865extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
857extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *); 866extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *);
858extern int blk_do_ordered(struct request_queue *, struct request **); 867extern bool blk_do_ordered(struct request_queue *, struct request **);
859extern unsigned blk_ordered_cur_seq(struct request_queue *); 868extern unsigned blk_ordered_cur_seq(struct request_queue *);
860extern unsigned blk_ordered_req_seq(struct request *); 869extern unsigned blk_ordered_req_seq(struct request *);
861extern void blk_ordered_complete_seq(struct request_queue *, unsigned, int); 870extern bool blk_ordered_complete_seq(struct request_queue *, unsigned, int);
862 871
863extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *); 872extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *);
864extern void blk_dump_rq_flags(struct request *, char *); 873extern void blk_dump_rq_flags(struct request *, char *);
@@ -977,7 +986,6 @@ static inline void put_dev_sector(Sector p)
977 986
978struct work_struct; 987struct work_struct;
979int kblockd_schedule_work(struct request_queue *q, struct work_struct *work); 988int kblockd_schedule_work(struct request_queue *q, struct work_struct *work);
980void kblockd_flush_work(struct work_struct *work);
981 989
982#define MODULE_ALIAS_BLOCKDEV(major,minor) \ 990#define MODULE_ALIAS_BLOCKDEV(major,minor) \
983 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor)) 991 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
index 777dbf695d44..27b1bcffe408 100644
--- a/include/linux/bottom_half.h
+++ b/include/linux/bottom_half.h
@@ -2,7 +2,6 @@
2#define _LINUX_BH_H 2#define _LINUX_BH_H
3 3
4extern void local_bh_disable(void); 4extern void local_bh_disable(void);
5extern void __local_bh_enable(void);
6extern void _local_bh_enable(void); 5extern void _local_bh_enable(void);
7extern void local_bh_enable(void); 6extern void local_bh_enable(void);
8extern void local_bh_enable_ip(unsigned long ip); 7extern void local_bh_enable_ip(unsigned long ip);
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 3ce64b90118c..8605f8a74df9 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -35,6 +35,7 @@ enum bh_state_bits {
35 BH_Ordered, /* ordered write */ 35 BH_Ordered, /* ordered write */
36 BH_Eopnotsupp, /* operation not supported (barrier) */ 36 BH_Eopnotsupp, /* operation not supported (barrier) */
37 BH_Unwritten, /* Buffer is allocated on disk but not written */ 37 BH_Unwritten, /* Buffer is allocated on disk but not written */
38 BH_Quiet, /* Buffer Error Prinks to be quiet */
38 39
39 BH_PrivateStart,/* not a state bit, but the first bit available 40 BH_PrivateStart,/* not a state bit, but the first bit available
40 * for private allocation by other entities 41 * for private allocation by other entities
diff --git a/include/linux/console.h b/include/linux/console.h
index 248e6e3b9b73..a67a90cf8268 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -153,4 +153,8 @@ void vcs_remove_sysfs(struct tty_struct *tty);
153#define VESA_HSYNC_SUSPEND 2 153#define VESA_HSYNC_SUSPEND 2
154#define VESA_POWERDOWN 3 154#define VESA_POWERDOWN 3
155 155
156#ifdef CONFIG_VGA_CONSOLE
157extern bool vgacon_text_force(void);
158#endif
159
156#endif /* _LINUX_CONSOLE_H */ 160#endif /* _LINUX_CONSOLE_H */
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h
index 4aaa4afb1cb9..096476f1fb35 100644
--- a/include/linux/debug_locks.h
+++ b/include/linux/debug_locks.h
@@ -17,7 +17,7 @@ extern int debug_locks_off(void);
17({ \ 17({ \
18 int __ret = 0; \ 18 int __ret = 0; \
19 \ 19 \
20 if (unlikely(c)) { \ 20 if (!oops_in_progress && unlikely(c)) { \
21 if (debug_locks_off() && !debug_locks_silent) \ 21 if (debug_locks_off() && !debug_locks_silent) \
22 WARN_ON(1); \ 22 WARN_ON(1); \
23 __ret = 1; \ 23 __ret = 1; \
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 2bfda178f274..34161907b2f8 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -47,6 +47,7 @@ extern int dmi_name_in_vendors(const char *str);
47extern int dmi_name_in_serial(const char *str); 47extern int dmi_name_in_serial(const char *str);
48extern int dmi_available; 48extern int dmi_available;
49extern int dmi_walk(void (*decode)(const struct dmi_header *)); 49extern int dmi_walk(void (*decode)(const struct dmi_header *));
50extern bool dmi_match(enum dmi_field f, const char *str);
50 51
51#else 52#else
52 53
@@ -61,6 +62,8 @@ static inline int dmi_name_in_serial(const char *s) { return 0; }
61#define dmi_available 0 62#define dmi_available 0
62static inline int dmi_walk(void (*decode)(const struct dmi_header *)) 63static inline int dmi_walk(void (*decode)(const struct dmi_header *))
63 { return -1; } 64 { return -1; }
65static inline bool dmi_match(enum dmi_field f, const char *str)
66 { return false; }
64 67
65#endif 68#endif
66 69
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 92f6f634e3e6..7a204256b155 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -28,7 +28,7 @@ typedef void (elevator_activate_req_fn) (struct request_queue *, struct request
28typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct request *); 28typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct request *);
29 29
30typedef void *(elevator_init_fn) (struct request_queue *); 30typedef void *(elevator_init_fn) (struct request_queue *);
31typedef void (elevator_exit_fn) (elevator_t *); 31typedef void (elevator_exit_fn) (struct elevator_queue *);
32 32
33struct elevator_ops 33struct elevator_ops
34{ 34{
@@ -62,8 +62,8 @@ struct elevator_ops
62 62
63struct elv_fs_entry { 63struct elv_fs_entry {
64 struct attribute attr; 64 struct attribute attr;
65 ssize_t (*show)(elevator_t *, char *); 65 ssize_t (*show)(struct elevator_queue *, char *);
66 ssize_t (*store)(elevator_t *, const char *, size_t); 66 ssize_t (*store)(struct elevator_queue *, const char *, size_t);
67}; 67};
68 68
69/* 69/*
@@ -130,7 +130,7 @@ extern ssize_t elv_iosched_show(struct request_queue *, char *);
130extern ssize_t elv_iosched_store(struct request_queue *, const char *, size_t); 130extern ssize_t elv_iosched_store(struct request_queue *, const char *, size_t);
131 131
132extern int elevator_init(struct request_queue *, char *); 132extern int elevator_init(struct request_queue *, char *);
133extern void elevator_exit(elevator_t *); 133extern void elevator_exit(struct elevator_queue *);
134extern int elv_rq_merge_ok(struct request *, struct bio *); 134extern int elv_rq_merge_ok(struct request *, struct bio *);
135 135
136/* 136/*
diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h
index 32368c4f0326..06ca9b21dad2 100644
--- a/include/linux/fault-inject.h
+++ b/include/linux/fault-inject.h
@@ -81,4 +81,13 @@ static inline void cleanup_fault_attr_dentries(struct fault_attr *attr)
81 81
82#endif /* CONFIG_FAULT_INJECTION */ 82#endif /* CONFIG_FAULT_INJECTION */
83 83
84#ifdef CONFIG_FAILSLAB
85extern bool should_failslab(size_t size, gfp_t gfpflags);
86#else
87static inline bool should_failslab(size_t size, gfp_t gfpflags)
88{
89 return false;
90}
91#endif /* CONFIG_FAILSLAB */
92
84#endif /* _LINUX_FAULT_INJECT_H */ 93#endif /* _LINUX_FAULT_INJECT_H */
diff --git a/include/linux/futex.h b/include/linux/futex.h
index 586ab56a3ec3..3bf5bb5a34f9 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -25,7 +25,8 @@ union ktime;
25#define FUTEX_WAKE_BITSET 10 25#define FUTEX_WAKE_BITSET 10
26 26
27#define FUTEX_PRIVATE_FLAG 128 27#define FUTEX_PRIVATE_FLAG 128
28#define FUTEX_CMD_MASK ~FUTEX_PRIVATE_FLAG 28#define FUTEX_CLOCK_REALTIME 256
29#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
29 30
30#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG) 31#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)
31#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG) 32#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG)
@@ -164,6 +165,8 @@ union futex_key {
164 } both; 165 } both;
165}; 166};
166 167
168#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
169
167#ifdef CONFIG_FUTEX 170#ifdef CONFIG_FUTEX
168extern void exit_robust_list(struct task_struct *curr); 171extern void exit_robust_list(struct task_struct *curr);
169extern void exit_pi_state_list(struct task_struct *curr); 172extern void exit_pi_state_list(struct task_struct *curr);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 3df7742ce246..16948eaecae3 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -126,6 +126,7 @@ struct blk_scsi_cmd_filter {
126struct disk_part_tbl { 126struct disk_part_tbl {
127 struct rcu_head rcu_head; 127 struct rcu_head rcu_head;
128 int len; 128 int len;
129 struct hd_struct *last_lookup;
129 struct hd_struct *part[]; 130 struct hd_struct *part[];
130}; 131};
131 132
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 89a56d79e4c6..f83288347dda 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -119,13 +119,17 @@ static inline void account_system_vtime(struct task_struct *tsk)
119} 119}
120#endif 120#endif
121 121
122#if defined(CONFIG_PREEMPT_RCU) && defined(CONFIG_NO_HZ) 122#if defined(CONFIG_NO_HZ) && !defined(CONFIG_CLASSIC_RCU)
123extern void rcu_irq_enter(void); 123extern void rcu_irq_enter(void);
124extern void rcu_irq_exit(void); 124extern void rcu_irq_exit(void);
125extern void rcu_nmi_enter(void);
126extern void rcu_nmi_exit(void);
125#else 127#else
126# define rcu_irq_enter() do { } while (0) 128# define rcu_irq_enter() do { } while (0)
127# define rcu_irq_exit() do { } while (0) 129# define rcu_irq_exit() do { } while (0)
128#endif /* CONFIG_PREEMPT_RCU */ 130# define rcu_nmi_enter() do { } while (0)
131# define rcu_nmi_exit() do { } while (0)
132#endif /* #if defined(CONFIG_NO_HZ) && !defined(CONFIG_CLASSIC_RCU) */
129 133
130/* 134/*
131 * It is safe to do non-atomic ops on ->hardirq_context, 135 * It is safe to do non-atomic ops on ->hardirq_context,
@@ -135,7 +139,6 @@ extern void rcu_irq_exit(void);
135 */ 139 */
136#define __irq_enter() \ 140#define __irq_enter() \
137 do { \ 141 do { \
138 rcu_irq_enter(); \
139 account_system_vtime(current); \ 142 account_system_vtime(current); \
140 add_preempt_count(HARDIRQ_OFFSET); \ 143 add_preempt_count(HARDIRQ_OFFSET); \
141 trace_hardirq_enter(); \ 144 trace_hardirq_enter(); \
@@ -154,7 +157,6 @@ extern void irq_enter(void);
154 trace_hardirq_exit(); \ 157 trace_hardirq_exit(); \
155 account_system_vtime(current); \ 158 account_system_vtime(current); \
156 sub_preempt_count(HARDIRQ_OFFSET); \ 159 sub_preempt_count(HARDIRQ_OFFSET); \
157 rcu_irq_exit(); \
158 } while (0) 160 } while (0)
159 161
160/* 162/*
@@ -166,11 +168,14 @@ extern void irq_exit(void);
166 do { \ 168 do { \
167 ftrace_nmi_enter(); \ 169 ftrace_nmi_enter(); \
168 lockdep_off(); \ 170 lockdep_off(); \
171 rcu_nmi_enter(); \
169 __irq_enter(); \ 172 __irq_enter(); \
170 } while (0) 173 } while (0)
174
171#define nmi_exit() \ 175#define nmi_exit() \
172 do { \ 176 do { \
173 __irq_exit(); \ 177 __irq_exit(); \
178 rcu_nmi_exit(); \
174 lockdep_on(); \ 179 lockdep_on(); \
175 ftrace_nmi_exit(); \ 180 ftrace_nmi_exit(); \
176 } while (0) 181 } while (0)
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 3eba43878dcb..bd37078c2d7d 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -43,26 +43,6 @@ enum hrtimer_restart {
43}; 43};
44 44
45/* 45/*
46 * hrtimer callback modes:
47 *
48 * HRTIMER_CB_SOFTIRQ: Callback must run in softirq context
49 * HRTIMER_CB_IRQSAFE_PERCPU: Callback must run in hardirq context
50 * Special mode for tick emulation and
51 * scheduler timer. Such timers are per
52 * cpu and not allowed to be migrated on
53 * cpu unplug.
54 * HRTIMER_CB_IRQSAFE_UNLOCKED: Callback should run in hardirq context
55 * with timer->base lock unlocked
56 * used for timers which call wakeup to
57 * avoid lock order problems with rq->lock
58 */
59enum hrtimer_cb_mode {
60 HRTIMER_CB_SOFTIRQ,
61 HRTIMER_CB_IRQSAFE_PERCPU,
62 HRTIMER_CB_IRQSAFE_UNLOCKED,
63};
64
65/*
66 * Values to track state of the timer 46 * Values to track state of the timer
67 * 47 *
68 * Possible states: 48 * Possible states:
@@ -70,7 +50,6 @@ enum hrtimer_cb_mode {
70 * 0x00 inactive 50 * 0x00 inactive
71 * 0x01 enqueued into rbtree 51 * 0x01 enqueued into rbtree
72 * 0x02 callback function running 52 * 0x02 callback function running
73 * 0x04 callback pending (high resolution mode)
74 * 53 *
75 * Special cases: 54 * Special cases:
76 * 0x03 callback function running and enqueued 55 * 0x03 callback function running and enqueued
@@ -92,8 +71,7 @@ enum hrtimer_cb_mode {
92#define HRTIMER_STATE_INACTIVE 0x00 71#define HRTIMER_STATE_INACTIVE 0x00
93#define HRTIMER_STATE_ENQUEUED 0x01 72#define HRTIMER_STATE_ENQUEUED 0x01
94#define HRTIMER_STATE_CALLBACK 0x02 73#define HRTIMER_STATE_CALLBACK 0x02
95#define HRTIMER_STATE_PENDING 0x04 74#define HRTIMER_STATE_MIGRATE 0x04
96#define HRTIMER_STATE_MIGRATE 0x08
97 75
98/** 76/**
99 * struct hrtimer - the basic hrtimer structure 77 * struct hrtimer - the basic hrtimer structure
@@ -109,8 +87,6 @@ enum hrtimer_cb_mode {
109 * @function: timer expiry callback function 87 * @function: timer expiry callback function
110 * @base: pointer to the timer base (per cpu and per clock) 88 * @base: pointer to the timer base (per cpu and per clock)
111 * @state: state information (See bit values above) 89 * @state: state information (See bit values above)
112 * @cb_mode: high resolution timer feature to select the callback execution
113 * mode
114 * @cb_entry: list head to enqueue an expired timer into the callback list 90 * @cb_entry: list head to enqueue an expired timer into the callback list
115 * @start_site: timer statistics field to store the site where the timer 91 * @start_site: timer statistics field to store the site where the timer
116 * was started 92 * was started
@@ -129,7 +105,6 @@ struct hrtimer {
129 struct hrtimer_clock_base *base; 105 struct hrtimer_clock_base *base;
130 unsigned long state; 106 unsigned long state;
131 struct list_head cb_entry; 107 struct list_head cb_entry;
132 enum hrtimer_cb_mode cb_mode;
133#ifdef CONFIG_TIMER_STATS 108#ifdef CONFIG_TIMER_STATS
134 int start_pid; 109 int start_pid;
135 void *start_site; 110 void *start_site;
@@ -188,15 +163,11 @@ struct hrtimer_clock_base {
188 * @check_clocks: Indictator, when set evaluate time source and clock 163 * @check_clocks: Indictator, when set evaluate time source and clock
189 * event devices whether high resolution mode can be 164 * event devices whether high resolution mode can be
190 * activated. 165 * activated.
191 * @cb_pending: Expired timers are moved from the rbtree to this
192 * list in the timer interrupt. The list is processed
193 * in the softirq.
194 * @nr_events: Total number of timer interrupt events 166 * @nr_events: Total number of timer interrupt events
195 */ 167 */
196struct hrtimer_cpu_base { 168struct hrtimer_cpu_base {
197 spinlock_t lock; 169 spinlock_t lock;
198 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; 170 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
199 struct list_head cb_pending;
200#ifdef CONFIG_HIGH_RES_TIMERS 171#ifdef CONFIG_HIGH_RES_TIMERS
201 ktime_t expires_next; 172 ktime_t expires_next;
202 int hres_active; 173 int hres_active;
@@ -404,8 +375,7 @@ static inline int hrtimer_active(const struct hrtimer *timer)
404 */ 375 */
405static inline int hrtimer_is_queued(struct hrtimer *timer) 376static inline int hrtimer_is_queued(struct hrtimer *timer)
406{ 377{
407 return timer->state & 378 return timer->state & HRTIMER_STATE_ENQUEUED;
408 (HRTIMER_STATE_ENQUEUED | HRTIMER_STATE_PENDING);
409} 379}
410 380
411/* 381/*
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 010fb26a1579..e99c56de7f56 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -122,8 +122,6 @@ struct ide_io_ports {
122#define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ 122#define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */
123#define SECTOR_SIZE 512 123#define SECTOR_SIZE 512
124 124
125#define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
126
127/* 125/*
128 * Timeouts for various operations: 126 * Timeouts for various operations:
129 */ 127 */
@@ -172,9 +170,7 @@ typedef int (ide_ack_intr_t)(struct hwif_s *);
172enum { ide_unknown, ide_generic, ide_pci, 170enum { ide_unknown, ide_generic, ide_pci,
173 ide_cmd640, ide_dtc2278, ide_ali14xx, 171 ide_cmd640, ide_dtc2278, ide_ali14xx,
174 ide_qd65xx, ide_umc8672, ide_ht6560b, 172 ide_qd65xx, ide_umc8672, ide_ht6560b,
175 ide_rz1000, ide_trm290, 173 ide_4drives, ide_pmac, ide_acorn,
176 ide_cmd646, ide_cy82c693, ide_4drives,
177 ide_pmac, ide_acorn,
178 ide_au1xxx, ide_palm3710 174 ide_au1xxx, ide_palm3710
179}; 175};
180 176
@@ -496,8 +492,6 @@ enum {
496 * when more than one interrupt is needed. 492 * when more than one interrupt is needed.
497 */ 493 */
498 IDE_AFLAG_LIMIT_NFRAMES = (1 << 7), 494 IDE_AFLAG_LIMIT_NFRAMES = (1 << 7),
499 /* Seeking in progress. */
500 IDE_AFLAG_SEEKING = (1 << 8),
501 /* Saved TOC information is current. */ 495 /* Saved TOC information is current. */
502 IDE_AFLAG_TOC_VALID = (1 << 9), 496 IDE_AFLAG_TOC_VALID = (1 << 9),
503 /* We think that the drive door is locked. */ 497 /* We think that the drive door is locked. */
@@ -845,8 +839,6 @@ typedef struct hwif_s {
845 unsigned extra_ports; /* number of extra dma ports */ 839 unsigned extra_ports; /* number of extra dma ports */
846 840
847 unsigned present : 1; /* this interface exists */ 841 unsigned present : 1; /* this interface exists */
848 unsigned serialized : 1; /* serialized all channel operation */
849 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
850 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 842 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
851 843
852 struct device gendev; 844 struct device gendev;
@@ -909,6 +901,8 @@ typedef struct hwgroup_s {
909 901
910 int req_gen; 902 int req_gen;
911 int req_gen_timer; 903 int req_gen_timer;
904
905 spinlock_t lock;
912} ide_hwgroup_t; 906} ide_hwgroup_t;
913 907
914typedef struct ide_driver_s ide_driver_t; 908typedef struct ide_driver_s ide_driver_t;
@@ -1122,6 +1116,14 @@ enum {
1122 IDE_PM_COMPLETED, 1116 IDE_PM_COMPLETED,
1123}; 1117};
1124 1118
1119int generic_ide_suspend(struct device *, pm_message_t);
1120int generic_ide_resume(struct device *);
1121
1122void ide_complete_power_step(ide_drive_t *, struct request *);
1123ide_startstop_t ide_start_power_step(ide_drive_t *, struct request *);
1124void ide_complete_pm_request(ide_drive_t *, struct request *);
1125void ide_check_pm_state(ide_drive_t *, struct request *);
1126
1125/* 1127/*
1126 * Subdrivers support. 1128 * Subdrivers support.
1127 * 1129 *
@@ -1376,8 +1378,8 @@ enum {
1376 IDE_HFLAG_LEGACY_IRQS = (1 << 21), 1378 IDE_HFLAG_LEGACY_IRQS = (1 << 21),
1377 /* force use of legacy IRQs */ 1379 /* force use of legacy IRQs */
1378 IDE_HFLAG_FORCE_LEGACY_IRQS = (1 << 22), 1380 IDE_HFLAG_FORCE_LEGACY_IRQS = (1 << 22),
1379 /* limit LBA48 requests to 256 sectors */ 1381 /* host is TRM290 */
1380 IDE_HFLAG_RQSIZE_256 = (1 << 23), 1382 IDE_HFLAG_TRM290 = (1 << 23),
1381 /* use 32-bit I/O ops */ 1383 /* use 32-bit I/O ops */
1382 IDE_HFLAG_IO_32BIT = (1 << 24), 1384 IDE_HFLAG_IO_32BIT = (1 << 24),
1383 /* unmask IRQs */ 1385 /* unmask IRQs */
@@ -1415,6 +1417,9 @@ struct ide_port_info {
1415 1417
1416 ide_pci_enablebit_t enablebits[2]; 1418 ide_pci_enablebit_t enablebits[2];
1417 hwif_chipset_t chipset; 1419 hwif_chipset_t chipset;
1420
1421 u16 max_sectors; /* if < than the default one */
1422
1418 u32 host_flags; 1423 u32 host_flags;
1419 u8 pio_mask; 1424 u8 pio_mask;
1420 u8 swdma_mask; 1425 u8 swdma_mask;
@@ -1610,13 +1615,13 @@ extern struct mutex ide_cfg_mtx;
1610/* 1615/*
1611 * Structure locking: 1616 * Structure locking:
1612 * 1617 *
1613 * ide_cfg_mtx and ide_lock together protect changes to 1618 * ide_cfg_mtx and hwgroup->lock together protect changes to
1614 * ide_hwif_t->{next,hwgroup} 1619 * ide_hwif_t->next
1615 * ide_drive_t->next 1620 * ide_drive_t->next
1616 * 1621 *
1617 * ide_hwgroup_t->busy: ide_lock 1622 * ide_hwgroup_t->busy: hwgroup->lock
1618 * ide_hwgroup_t->hwif: ide_lock 1623 * ide_hwgroup_t->hwif: hwgroup->lock
1619 * ide_hwif_t->mate: constant, no locking 1624 * ide_hwif_t->{hwgroup,mate}: constant, no locking
1620 * ide_drive_t->hwif: constant, no locking 1625 * ide_drive_t->hwif: constant, no locking
1621 */ 1626 */
1622 1627
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index f58a0cf8929a..be3c484b5242 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -14,6 +14,8 @@
14#include <linux/irqflags.h> 14#include <linux/irqflags.h>
15#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/percpu.h> 16#include <linux/percpu.h>
17#include <linux/irqnr.h>
18
17#include <asm/atomic.h> 19#include <asm/atomic.h>
18#include <asm/ptrace.h> 20#include <asm/ptrace.h>
19#include <asm/system.h> 21#include <asm/system.h>
@@ -251,9 +253,6 @@ enum
251 BLOCK_SOFTIRQ, 253 BLOCK_SOFTIRQ,
252 TASKLET_SOFTIRQ, 254 TASKLET_SOFTIRQ,
253 SCHED_SOFTIRQ, 255 SCHED_SOFTIRQ,
254#ifdef CONFIG_HIGH_RES_TIMERS
255 HRTIMER_SOFTIRQ,
256#endif
257 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */ 256 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
258 257
259 NR_SOFTIRQS 258 NR_SOFTIRQS
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 3dddfa703ebd..98564dc64476 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -129,9 +129,14 @@ struct irq_chip {
129 const char *typename; 129 const char *typename;
130}; 130};
131 131
132struct timer_rand_state;
133struct irq_2_iommu;
132/** 134/**
133 * struct irq_desc - interrupt descriptor 135 * struct irq_desc - interrupt descriptor
134 * @irq: interrupt number for this descriptor 136 * @irq: interrupt number for this descriptor
137 * @timer_rand_state: pointer to timer rand state struct
138 * @kstat_irqs: irq stats per cpu
139 * @irq_2_iommu: iommu with this irq
135 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()] 140 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
136 * @chip: low level interrupt hardware access 141 * @chip: low level interrupt hardware access
137 * @msi_desc: MSI descriptor 142 * @msi_desc: MSI descriptor
@@ -143,8 +148,8 @@ struct irq_chip {
143 * @depth: disable-depth, for nested irq_disable() calls 148 * @depth: disable-depth, for nested irq_disable() calls
144 * @wake_depth: enable depth, for multiple set_irq_wake() callers 149 * @wake_depth: enable depth, for multiple set_irq_wake() callers
145 * @irq_count: stats field to detect stalled irqs 150 * @irq_count: stats field to detect stalled irqs
146 * @irqs_unhandled: stats field for spurious unhandled interrupts
147 * @last_unhandled: aging timer for unhandled count 151 * @last_unhandled: aging timer for unhandled count
152 * @irqs_unhandled: stats field for spurious unhandled interrupts
148 * @lock: locking for SMP 153 * @lock: locking for SMP
149 * @affinity: IRQ affinity on SMP 154 * @affinity: IRQ affinity on SMP
150 * @cpu: cpu index useful for balancing 155 * @cpu: cpu index useful for balancing
@@ -154,6 +159,13 @@ struct irq_chip {
154 */ 159 */
155struct irq_desc { 160struct irq_desc {
156 unsigned int irq; 161 unsigned int irq;
162#ifdef CONFIG_SPARSE_IRQ
163 struct timer_rand_state *timer_rand_state;
164 unsigned int *kstat_irqs;
165# ifdef CONFIG_INTR_REMAP
166 struct irq_2_iommu *irq_2_iommu;
167# endif
168#endif
157 irq_flow_handler_t handle_irq; 169 irq_flow_handler_t handle_irq;
158 struct irq_chip *chip; 170 struct irq_chip *chip;
159 struct msi_desc *msi_desc; 171 struct msi_desc *msi_desc;
@@ -165,8 +177,8 @@ struct irq_desc {
165 unsigned int depth; /* nested irq disables */ 177 unsigned int depth; /* nested irq disables */
166 unsigned int wake_depth; /* nested wake enables */ 178 unsigned int wake_depth; /* nested wake enables */
167 unsigned int irq_count; /* For detecting broken IRQs */ 179 unsigned int irq_count; /* For detecting broken IRQs */
168 unsigned int irqs_unhandled;
169 unsigned long last_unhandled; /* Aging timer for unhandled count */ 180 unsigned long last_unhandled; /* Aging timer for unhandled count */
181 unsigned int irqs_unhandled;
170 spinlock_t lock; 182 spinlock_t lock;
171#ifdef CONFIG_SMP 183#ifdef CONFIG_SMP
172 cpumask_t affinity; 184 cpumask_t affinity;
@@ -181,12 +193,51 @@ struct irq_desc {
181 const char *name; 193 const char *name;
182} ____cacheline_internodealigned_in_smp; 194} ____cacheline_internodealigned_in_smp;
183 195
196extern void early_irq_init(void);
197extern void arch_early_irq_init(void);
198extern void arch_init_chip_data(struct irq_desc *desc, int cpu);
199extern void arch_init_copy_chip_data(struct irq_desc *old_desc,
200 struct irq_desc *desc, int cpu);
201extern void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc);
184 202
203#ifndef CONFIG_SPARSE_IRQ
185extern struct irq_desc irq_desc[NR_IRQS]; 204extern struct irq_desc irq_desc[NR_IRQS];
186 205
187static inline struct irq_desc *irq_to_desc(unsigned int irq) 206static inline struct irq_desc *irq_to_desc(unsigned int irq)
188{ 207{
189 return (irq < nr_irqs) ? irq_desc + irq : NULL; 208 return (irq < NR_IRQS) ? irq_desc + irq : NULL;
209}
210static inline struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
211{
212 return irq_to_desc(irq);
213}
214
215#else
216
217extern struct irq_desc *irq_to_desc(unsigned int irq);
218extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu);
219extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu);
220
221# define for_each_irq_desc(irq, desc) \
222 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; irq++, desc = irq_to_desc(irq))
223# define for_each_irq_desc_reverse(irq, desc) \
224 for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; irq--, desc = irq_to_desc(irq))
225
226#define kstat_irqs_this_cpu(DESC) \
227 ((DESC)->kstat_irqs[smp_processor_id()])
228#define kstat_incr_irqs_this_cpu(irqno, DESC) \
229 ((DESC)->kstat_irqs[smp_processor_id()]++)
230
231#endif
232
233static inline struct irq_desc *
234irq_remap_to_desc(unsigned int irq, struct irq_desc *desc)
235{
236#ifdef CONFIG_NUMA_MIGRATE_IRQ_DESC
237 return irq_to_desc(irq);
238#else
239 return desc;
240#endif
190} 241}
191 242
192/* 243/*
@@ -380,6 +431,11 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
380#define get_irq_data(irq) (irq_to_desc(irq)->handler_data) 431#define get_irq_data(irq) (irq_to_desc(irq)->handler_data)
381#define get_irq_msi(irq) (irq_to_desc(irq)->msi_desc) 432#define get_irq_msi(irq) (irq_to_desc(irq)->msi_desc)
382 433
434#define get_irq_desc_chip(desc) ((desc)->chip)
435#define get_irq_desc_chip_data(desc) ((desc)->chip_data)
436#define get_irq_desc_data(desc) ((desc)->handler_data)
437#define get_irq_desc_msi(desc) ((desc)->msi_desc)
438
383#endif /* CONFIG_GENERIC_HARDIRQS */ 439#endif /* CONFIG_GENERIC_HARDIRQS */
384 440
385#endif /* !CONFIG_S390 */ 441#endif /* !CONFIG_S390 */
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 452c280c8115..95d2b74641f5 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -1,24 +1,38 @@
1#ifndef _LINUX_IRQNR_H 1#ifndef _LINUX_IRQNR_H
2#define _LINUX_IRQNR_H 2#define _LINUX_IRQNR_H
3 3
4/*
5 * Generic irq_desc iterators:
6 */
7#ifdef __KERNEL__
8
4#ifndef CONFIG_GENERIC_HARDIRQS 9#ifndef CONFIG_GENERIC_HARDIRQS
5#include <asm/irq.h> 10#include <asm/irq.h>
6# define nr_irqs NR_IRQS 11# define nr_irqs NR_IRQS
7 12
8# define for_each_irq_desc(irq, desc) \ 13# define for_each_irq_desc(irq, desc) \
9 for (irq = 0; irq < nr_irqs; irq++) 14 for (irq = 0; irq < nr_irqs; irq++)
15
16# define for_each_irq_desc_reverse(irq, desc) \
17 for (irq = nr_irqs - 1; irq >= 0; irq--)
10#else 18#else
19
11extern int nr_irqs; 20extern int nr_irqs;
12 21
22#ifndef CONFIG_SPARSE_IRQ
23
24struct irq_desc;
13# define for_each_irq_desc(irq, desc) \ 25# define for_each_irq_desc(irq, desc) \
14 for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc++) 26 for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc++)
15 27# define for_each_irq_desc_reverse(irq, desc) \
16# define for_each_irq_desc_reverse(irq, desc) \ 28 for (irq = nr_irqs - 1, desc = irq_desc + (nr_irqs - 1); \
17 for (irq = nr_irqs - 1, desc = irq_desc + (nr_irqs - 1); \ 29 irq >= 0; irq--, desc--)
18 irq >= 0; irq--, desc--) 30#endif
19#endif 31#endif
20 32
21#define for_each_irq_nr(irq) \ 33#define for_each_irq_nr(irq) \
22 for (irq = 0; irq < nr_irqs; irq++) 34 for (irq = 0; irq < nr_irqs; irq++)
35
36#endif /* __KERNEL__ */
23 37
24#endif 38#endif
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index abb6ac639e8e..1a9cf78bfce5 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -115,10 +115,20 @@ static inline u64 get_jiffies_64(void)
115 ((long)(a) - (long)(b) >= 0)) 115 ((long)(a) - (long)(b) >= 0))
116#define time_before_eq(a,b) time_after_eq(b,a) 116#define time_before_eq(a,b) time_after_eq(b,a)
117 117
118/*
119 * Calculate whether a is in the range of [b, c].
120 */
118#define time_in_range(a,b,c) \ 121#define time_in_range(a,b,c) \
119 (time_after_eq(a,b) && \ 122 (time_after_eq(a,b) && \
120 time_before_eq(a,c)) 123 time_before_eq(a,c))
121 124
125/*
126 * Calculate whether a is in the range of [b, c).
127 */
128#define time_in_range_open(a,b,c) \
129 (time_after_eq(a,b) && \
130 time_before(a,c))
131
122/* Same as above, but does so with platform independent 64bit types. 132/* Same as above, but does so with platform independent 64bit types.
123 * These must be used when utilizing jiffies_64 (i.e. return value of 133 * These must be used when utilizing jiffies_64 (i.e. return value of
124 * get_jiffies_64() */ 134 * get_jiffies_64() */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 6002ae76785c..ca9ff6411dfa 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -141,6 +141,15 @@ extern int _cond_resched(void);
141 (__x < 0) ? -__x : __x; \ 141 (__x < 0) ? -__x : __x; \
142 }) 142 })
143 143
144#ifdef CONFIG_PROVE_LOCKING
145void might_fault(void);
146#else
147static inline void might_fault(void)
148{
149 might_sleep();
150}
151#endif
152
144extern struct atomic_notifier_head panic_notifier_list; 153extern struct atomic_notifier_head panic_notifier_list;
145extern long (*panic_blink)(long time); 154extern long (*panic_blink)(long time);
146NORET_TYPE void panic(const char * fmt, ...) 155NORET_TYPE void panic(const char * fmt, ...)
@@ -188,6 +197,8 @@ extern unsigned long long memparse(const char *ptr, char **retptr);
188extern int core_kernel_text(unsigned long addr); 197extern int core_kernel_text(unsigned long addr);
189extern int __kernel_text_address(unsigned long addr); 198extern int __kernel_text_address(unsigned long addr);
190extern int kernel_text_address(unsigned long addr); 199extern int kernel_text_address(unsigned long addr);
200extern int func_ptr_is_kernel_text(void *ptr);
201
191struct pid; 202struct pid;
192extern struct pid *session_of_pgrp(struct pid *pgrp); 203extern struct pid *session_of_pgrp(struct pid *pgrp);
193 204
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 4a145caeee07..4ee4b3d2316f 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -28,7 +28,9 @@ struct cpu_usage_stat {
28 28
29struct kernel_stat { 29struct kernel_stat {
30 struct cpu_usage_stat cpustat; 30 struct cpu_usage_stat cpustat;
31 unsigned int irqs[NR_IRQS]; 31#ifndef CONFIG_SPARSE_IRQ
32 unsigned int irqs[NR_IRQS];
33#endif
32}; 34};
33 35
34DECLARE_PER_CPU(struct kernel_stat, kstat); 36DECLARE_PER_CPU(struct kernel_stat, kstat);
@@ -39,6 +41,10 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
39 41
40extern unsigned long long nr_context_switches(void); 42extern unsigned long long nr_context_switches(void);
41 43
44#ifndef CONFIG_SPARSE_IRQ
45#define kstat_irqs_this_cpu(irq) \
46 (kstat_this_cpu.irqs[irq])
47
42struct irq_desc; 48struct irq_desc;
43 49
44static inline void kstat_incr_irqs_this_cpu(unsigned int irq, 50static inline void kstat_incr_irqs_this_cpu(unsigned int irq,
@@ -46,11 +52,17 @@ static inline void kstat_incr_irqs_this_cpu(unsigned int irq,
46{ 52{
47 kstat_this_cpu.irqs[irq]++; 53 kstat_this_cpu.irqs[irq]++;
48} 54}
55#endif
56
49 57
58#ifndef CONFIG_SPARSE_IRQ
50static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) 59static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
51{ 60{
52 return kstat_cpu(cpu).irqs[irq]; 61 return kstat_cpu(cpu).irqs[irq];
53} 62}
63#else
64extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu);
65#endif
54 66
55/* 67/*
56 * Number of interrupts per specific IRQ source, since bootup 68 * Number of interrupts per specific IRQ source, since bootup
diff --git a/include/linux/lguest_launcher.h b/include/linux/lguest_launcher.h
index e7217dc58f39..a53407a4165c 100644
--- a/include/linux/lguest_launcher.h
+++ b/include/linux/lguest_launcher.h
@@ -54,9 +54,13 @@ struct lguest_vqconfig {
54/* Write command first word is a request. */ 54/* Write command first word is a request. */
55enum lguest_req 55enum lguest_req
56{ 56{
57 LHREQ_INITIALIZE, /* + base, pfnlimit, pgdir, start */ 57 LHREQ_INITIALIZE, /* + base, pfnlimit, start */
58 LHREQ_GETDMA, /* No longer used */ 58 LHREQ_GETDMA, /* No longer used */
59 LHREQ_IRQ, /* + irq */ 59 LHREQ_IRQ, /* + irq */
60 LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */ 60 LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */
61}; 61};
62
63/* The alignment to use between consumer and producer parts of vring.
64 * x86 pagesize for historical reasons. */
65#define LGUEST_VRING_ALIGN 4096
62#endif /* _LINUX_LGUEST_LAUNCHER */ 66#endif /* _LINUX_LGUEST_LAUNCHER */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ed3f26eb5df1..3449de597eff 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -213,10 +213,11 @@ enum {
213 ATA_PFLAG_FROZEN = (1 << 2), /* port is frozen */ 213 ATA_PFLAG_FROZEN = (1 << 2), /* port is frozen */
214 ATA_PFLAG_RECOVERED = (1 << 3), /* recovery action performed */ 214 ATA_PFLAG_RECOVERED = (1 << 3), /* recovery action performed */
215 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ 215 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */
216 ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */
217 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ 216 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */
218 ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */ 217 ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */
219 ATA_PFLAG_RESETTING = (1 << 8), /* reset in progress */ 218 ATA_PFLAG_RESETTING = (1 << 8), /* reset in progress */
219 ATA_PFLAG_UNLOADING = (1 << 9), /* driver is being unloaded */
220 ATA_PFLAG_UNLOADED = (1 << 10), /* driver is unloaded */
220 221
221 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ 222 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */
222 ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ 223 ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */
@@ -1285,26 +1286,62 @@ static inline int ata_link_active(struct ata_link *link)
1285 return ata_tag_valid(link->active_tag) || link->sactive; 1286 return ata_tag_valid(link->active_tag) || link->sactive;
1286} 1287}
1287 1288
1288extern struct ata_link *__ata_port_next_link(struct ata_port *ap, 1289/*
1289 struct ata_link *link, 1290 * Iterators
1290 bool dev_only); 1291 *
1292 * ATA_LITER_* constants are used to select link iteration mode and
1293 * ATA_DITER_* device iteration mode.
1294 *
1295 * For a custom iteration directly using ata_{link|dev}_next(), if
1296 * @link or @dev, respectively, is NULL, the first element is
1297 * returned. @dev and @link can be any valid device or link and the
1298 * next element according to the iteration mode will be returned.
1299 * After the last element, NULL is returned.
1300 */
1301enum ata_link_iter_mode {
1302 ATA_LITER_EDGE, /* if present, PMP links only; otherwise,
1303 * host link. no slave link */
1304 ATA_LITER_HOST_FIRST, /* host link followed by PMP or slave links */
1305 ATA_LITER_PMP_FIRST, /* PMP links followed by host link,
1306 * slave link still comes after host link */
1307};
1291 1308
1292#define __ata_port_for_each_link(link, ap) \ 1309enum ata_dev_iter_mode {
1293 for ((link) = __ata_port_next_link((ap), NULL, false); (link); \ 1310 ATA_DITER_ENABLED,
1294 (link) = __ata_port_next_link((ap), (link), false)) 1311 ATA_DITER_ENABLED_REVERSE,
1312 ATA_DITER_ALL,
1313 ATA_DITER_ALL_REVERSE,
1314};
1295 1315
1296#define ata_port_for_each_link(link, ap) \ 1316extern struct ata_link *ata_link_next(struct ata_link *link,
1297 for ((link) = __ata_port_next_link((ap), NULL, true); (link); \ 1317 struct ata_port *ap,
1298 (link) = __ata_port_next_link((ap), (link), true)) 1318 enum ata_link_iter_mode mode);
1299 1319
1300#define ata_link_for_each_dev(dev, link) \ 1320extern struct ata_device *ata_dev_next(struct ata_device *dev,
1301 for ((dev) = (link)->device; \ 1321 struct ata_link *link,
1302 (dev) < (link)->device + ata_link_max_devices(link) || ((dev) = NULL); \ 1322 enum ata_dev_iter_mode mode);
1303 (dev)++) 1323
1324/*
1325 * Shortcut notation for iterations
1326 *
1327 * ata_for_each_link() iterates over each link of @ap according to
1328 * @mode. @link points to the current link in the loop. @link is
1329 * NULL after loop termination. ata_for_each_dev() works the same way
1330 * except that it iterates over each device of @link.
1331 *
1332 * Note that the mode prefixes ATA_{L|D}ITER_ shouldn't need to be
1333 * specified when using the following shorthand notations. Only the
1334 * mode itself (EDGE, HOST_FIRST, ENABLED, etc...) should be
1335 * specified. This not only increases brevity but also makes it
1336 * impossible to use ATA_LITER_* for device iteration or vice-versa.
1337 */
1338#define ata_for_each_link(link, ap, mode) \
1339 for ((link) = ata_link_next(NULL, (ap), ATA_LITER_##mode); (link); \
1340 (link) = ata_link_next((link), (ap), ATA_LITER_##mode))
1304 1341
1305#define ata_link_for_each_dev_reverse(dev, link) \ 1342#define ata_for_each_dev(dev, link, mode) \
1306 for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \ 1343 for ((dev) = ata_dev_next(NULL, (link), ATA_DITER_##mode); (dev); \
1307 (dev) >= (link)->device || ((dev) = NULL); (dev)--) 1344 (dev) = ata_dev_next((dev), (link), ATA_DITER_##mode))
1308 1345
1309/** 1346/**
1310 * ata_ncq_enabled - Test whether NCQ is enabled 1347 * ata_ncq_enabled - Test whether NCQ is enabled
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index e5872dc994c0..fbc48f898521 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -41,6 +41,7 @@ struct nlmclnt_initdata {
41 size_t addrlen; 41 size_t addrlen;
42 unsigned short protocol; 42 unsigned short protocol;
43 u32 nfs_version; 43 u32 nfs_version;
44 int noresvport;
44}; 45};
45 46
46/* 47/*
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index b56d5aa9b194..23da3fa69efa 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -49,6 +49,7 @@ struct nlm_host {
49 unsigned short h_proto; /* transport proto */ 49 unsigned short h_proto; /* transport proto */
50 unsigned short h_reclaiming : 1, 50 unsigned short h_reclaiming : 1,
51 h_server : 1, /* server side, not client side */ 51 h_server : 1, /* server side, not client side */
52 h_noresvport : 1,
52 h_inuse : 1; 53 h_inuse : 1;
53 wait_queue_head_t h_gracewait; /* wait while reclaiming */ 54 wait_queue_head_t h_gracewait; /* wait while reclaiming */
54 struct rw_semaphore h_rwsem; /* Reboot recovery lock */ 55 struct rw_semaphore h_rwsem; /* Reboot recovery lock */
@@ -220,7 +221,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
220 const size_t salen, 221 const size_t salen,
221 const unsigned short protocol, 222 const unsigned short protocol,
222 const u32 version, 223 const u32 version,
223 const char *hostname); 224 const char *hostname,
225 int noresvport);
224struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, 226struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
225 const char *hostname, 227 const char *hostname,
226 const size_t hostname_len); 228 const size_t hostname_len);
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 29aec6e10020..23bf02fb124f 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -73,6 +73,8 @@ struct lock_class_key {
73 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; 73 struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES];
74}; 74};
75 75
76#define LOCKSTAT_POINTS 4
77
76/* 78/*
77 * The lock-class itself: 79 * The lock-class itself:
78 */ 80 */
@@ -119,7 +121,8 @@ struct lock_class {
119 int name_version; 121 int name_version;
120 122
121#ifdef CONFIG_LOCK_STAT 123#ifdef CONFIG_LOCK_STAT
122 unsigned long contention_point[4]; 124 unsigned long contention_point[LOCKSTAT_POINTS];
125 unsigned long contending_point[LOCKSTAT_POINTS];
123#endif 126#endif
124}; 127};
125 128
@@ -144,6 +147,7 @@ enum bounce_type {
144 147
145struct lock_class_stats { 148struct lock_class_stats {
146 unsigned long contention_point[4]; 149 unsigned long contention_point[4];
150 unsigned long contending_point[4];
147 struct lock_time read_waittime; 151 struct lock_time read_waittime;
148 struct lock_time write_waittime; 152 struct lock_time write_waittime;
149 struct lock_time read_holdtime; 153 struct lock_time read_holdtime;
@@ -165,6 +169,7 @@ struct lockdep_map {
165 const char *name; 169 const char *name;
166#ifdef CONFIG_LOCK_STAT 170#ifdef CONFIG_LOCK_STAT
167 int cpu; 171 int cpu;
172 unsigned long ip;
168#endif 173#endif
169}; 174};
170 175
@@ -309,8 +314,15 @@ extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
309extern void lock_release(struct lockdep_map *lock, int nested, 314extern void lock_release(struct lockdep_map *lock, int nested,
310 unsigned long ip); 315 unsigned long ip);
311 316
312extern void lock_set_subclass(struct lockdep_map *lock, unsigned int subclass, 317extern void lock_set_class(struct lockdep_map *lock, const char *name,
313 unsigned long ip); 318 struct lock_class_key *key, unsigned int subclass,
319 unsigned long ip);
320
321static inline void lock_set_subclass(struct lockdep_map *lock,
322 unsigned int subclass, unsigned long ip)
323{
324 lock_set_class(lock, lock->name, lock->key, subclass, ip);
325}
314 326
315# define INIT_LOCKDEP .lockdep_recursion = 0, 327# define INIT_LOCKDEP .lockdep_recursion = 0,
316 328
@@ -328,6 +340,7 @@ static inline void lockdep_on(void)
328 340
329# define lock_acquire(l, s, t, r, c, n, i) do { } while (0) 341# define lock_acquire(l, s, t, r, c, n, i) do { } while (0)
330# define lock_release(l, n, i) do { } while (0) 342# define lock_release(l, n, i) do { } while (0)
343# define lock_set_class(l, n, k, s, i) do { } while (0)
331# define lock_set_subclass(l, s, i) do { } while (0) 344# define lock_set_subclass(l, s, i) do { } while (0)
332# define lockdep_init() do { } while (0) 345# define lockdep_init() do { } while (0)
333# define lockdep_info() do { } while (0) 346# define lockdep_info() do { } while (0)
@@ -356,7 +369,7 @@ struct lock_class_key { };
356#ifdef CONFIG_LOCK_STAT 369#ifdef CONFIG_LOCK_STAT
357 370
358extern void lock_contended(struct lockdep_map *lock, unsigned long ip); 371extern void lock_contended(struct lockdep_map *lock, unsigned long ip);
359extern void lock_acquired(struct lockdep_map *lock); 372extern void lock_acquired(struct lockdep_map *lock, unsigned long ip);
360 373
361#define LOCK_CONTENDED(_lock, try, lock) \ 374#define LOCK_CONTENDED(_lock, try, lock) \
362do { \ 375do { \
@@ -364,20 +377,20 @@ do { \
364 lock_contended(&(_lock)->dep_map, _RET_IP_); \ 377 lock_contended(&(_lock)->dep_map, _RET_IP_); \
365 lock(_lock); \ 378 lock(_lock); \
366 } \ 379 } \
367 lock_acquired(&(_lock)->dep_map); \ 380 lock_acquired(&(_lock)->dep_map, _RET_IP_); \
368} while (0) 381} while (0)
369 382
370#else /* CONFIG_LOCK_STAT */ 383#else /* CONFIG_LOCK_STAT */
371 384
372#define lock_contended(lockdep_map, ip) do {} while (0) 385#define lock_contended(lockdep_map, ip) do {} while (0)
373#define lock_acquired(lockdep_map) do {} while (0) 386#define lock_acquired(lockdep_map, ip) do {} while (0)
374 387
375#define LOCK_CONTENDED(_lock, try, lock) \ 388#define LOCK_CONTENDED(_lock, try, lock) \
376 lock(_lock) 389 lock(_lock)
377 390
378#endif /* CONFIG_LOCK_STAT */ 391#endif /* CONFIG_LOCK_STAT */
379 392
380#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS) 393#ifdef CONFIG_GENERIC_HARDIRQS
381extern void early_init_irq_lock_class(void); 394extern void early_init_irq_lock_class(void);
382#else 395#else
383static inline void early_init_irq_lock_class(void) 396static inline void early_init_irq_lock_class(void)
@@ -481,4 +494,22 @@ static inline void print_irqtrace_events(struct task_struct *curr)
481# define lock_map_release(l) do { } while (0) 494# define lock_map_release(l) do { } while (0)
482#endif 495#endif
483 496
497#ifdef CONFIG_PROVE_LOCKING
498# define might_lock(lock) \
499do { \
500 typecheck(struct lockdep_map *, &(lock)->dep_map); \
501 lock_acquire(&(lock)->dep_map, 0, 0, 0, 2, NULL, _THIS_IP_); \
502 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
503} while (0)
504# define might_lock_read(lock) \
505do { \
506 typecheck(struct lockdep_map *, &(lock)->dep_map); \
507 lock_acquire(&(lock)->dep_map, 0, 0, 1, 2, NULL, _THIS_IP_); \
508 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
509} while (0)
510#else
511# define might_lock(lock) do { } while (0)
512# define might_lock_read(lock) do { } while (0)
513#endif
514
484#endif /* __LINUX_LOCKDEP_H */ 515#endif /* __LINUX_LOCKDEP_H */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index fe825471d5aa..9cfc9b627fdd 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -232,8 +232,9 @@ struct mm_struct {
232 struct core_state *core_state; /* coredumping support */ 232 struct core_state *core_state; /* coredumping support */
233 233
234 /* aio bits */ 234 /* aio bits */
235 rwlock_t ioctx_list_lock; /* aio lock */ 235 spinlock_t ioctx_lock;
236 struct kioctx *ioctx_list; 236 struct hlist_head ioctx_list;
237
237#ifdef CONFIG_MM_OWNER 238#ifdef CONFIG_MM_OWNER
238 /* 239 /*
239 * "owner" points to a task that is regarded as the canonical 240 * "owner" points to a task that is regarded as the canonical
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 8f2939227207..d2b8a1e8ca11 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -10,8 +10,11 @@ struct msi_msg {
10}; 10};
11 11
12/* Helper functions */ 12/* Helper functions */
13struct irq_desc;
13extern void mask_msi_irq(unsigned int irq); 14extern void mask_msi_irq(unsigned int irq);
14extern void unmask_msi_irq(unsigned int irq); 15extern void unmask_msi_irq(unsigned int irq);
16extern void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg);
17extern void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg);
15extern void read_msi_msg(unsigned int irq, struct msi_msg *msg); 18extern void read_msi_msg(unsigned int irq, struct msi_msg *msg);
16extern void write_msi_msg(unsigned int irq, struct msi_msg *msg); 19extern void write_msi_msg(unsigned int irq, struct msi_msg *msg);
17 20
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index bc6da10ceee0..7a0e5c4f8072 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -144,6 +144,8 @@ extern int __must_check mutex_lock_killable(struct mutex *lock);
144/* 144/*
145 * NOTE: mutex_trylock() follows the spin_trylock() convention, 145 * NOTE: mutex_trylock() follows the spin_trylock() convention,
146 * not the down_trylock() convention! 146 * not the down_trylock() convention!
147 *
148 * Returns 1 if the mutex has been acquired successfully, and 0 on contention.
147 */ 149 */
148extern int mutex_trylock(struct mutex *lock); 150extern int mutex_trylock(struct mutex *lock);
149extern void mutex_unlock(struct mutex *lock); 151extern void mutex_unlock(struct mutex *lock);
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 4eaa8347a0d9..db867b04ac3c 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -83,7 +83,7 @@ struct nfs_open_context {
83 struct rpc_cred *cred; 83 struct rpc_cred *cred;
84 struct nfs4_state *state; 84 struct nfs4_state *state;
85 fl_owner_t lockowner; 85 fl_owner_t lockowner;
86 int mode; 86 fmode_t mode;
87 87
88 unsigned long flags; 88 unsigned long flags;
89#define NFS_CONTEXT_ERROR_WRITE (0) 89#define NFS_CONTEXT_ERROR_WRITE (0)
@@ -130,7 +130,10 @@ struct nfs_inode {
130 * 130 *
131 * We need to revalidate the cached attrs for this inode if 131 * We need to revalidate the cached attrs for this inode if
132 * 132 *
133 * jiffies - read_cache_jiffies > attrtimeo 133 * jiffies - read_cache_jiffies >= attrtimeo
134 *
135 * Please note the comparison is greater than or equal
136 * so that zero timeout values can be specified.
134 */ 137 */
135 unsigned long read_cache_jiffies; 138 unsigned long read_cache_jiffies;
136 unsigned long attrtimeo; 139 unsigned long attrtimeo;
@@ -180,7 +183,7 @@ struct nfs_inode {
180 /* NFSv4 state */ 183 /* NFSv4 state */
181 struct list_head open_states; 184 struct list_head open_states;
182 struct nfs_delegation *delegation; 185 struct nfs_delegation *delegation;
183 int delegation_state; 186 fmode_t delegation_state;
184 struct rw_semaphore rwsem; 187 struct rw_semaphore rwsem;
185#endif /* CONFIG_NFS_V4*/ 188#endif /* CONFIG_NFS_V4*/
186 struct inode vfs_inode; 189 struct inode vfs_inode;
@@ -342,7 +345,7 @@ extern int nfs_setattr(struct dentry *, struct iattr *);
342extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr); 345extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr);
343extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); 346extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
344extern void put_nfs_open_context(struct nfs_open_context *ctx); 347extern void put_nfs_open_context(struct nfs_open_context *ctx);
345extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); 348extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode);
346extern u64 nfs_compat_user_ino64(u64 fileid); 349extern u64 nfs_compat_user_ino64(u64 fileid);
347extern void nfs_fattr_init(struct nfs_fattr *fattr); 350extern void nfs_fattr_init(struct nfs_fattr *fattr);
348 351
@@ -533,12 +536,6 @@ static inline void nfs3_forget_cached_acls(struct inode *inode)
533#endif /* CONFIG_NFS_V3_ACL */ 536#endif /* CONFIG_NFS_V3_ACL */
534 537
535/* 538/*
536 * linux/fs/mount_clnt.c
537 */
538extern int nfs_mount(struct sockaddr *, size_t, char *, char *,
539 int, int, struct nfs_fh *);
540
541/*
542 * inline functions 539 * inline functions
543 */ 540 */
544 541
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 4e477ae58699..9bb81aec91cf 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -42,12 +42,6 @@ struct nfs_client {
42 struct rb_root cl_openowner_id; 42 struct rb_root cl_openowner_id;
43 struct rb_root cl_lockowner_id; 43 struct rb_root cl_lockowner_id;
44 44
45 /*
46 * The following rwsem ensures exclusive access to the server
47 * while we recover the state following a lease expiration.
48 */
49 struct rw_semaphore cl_sem;
50
51 struct list_head cl_delegations; 45 struct list_head cl_delegations;
52 struct rb_root cl_state_owners; 46 struct rb_root cl_state_owners;
53 spinlock_t cl_lock; 47 spinlock_t cl_lock;
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index 6549a06ac16e..4499016e6d0d 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -45,7 +45,7 @@ struct nfs_mount_data {
45 char context[NFS_MAX_CONTEXT_LEN + 1]; /* 6 */ 45 char context[NFS_MAX_CONTEXT_LEN + 1]; /* 6 */
46}; 46};
47 47
48/* bits in the flags field */ 48/* bits in the flags field visible to user space */
49 49
50#define NFS_MOUNT_SOFT 0x0001 /* 1 */ 50#define NFS_MOUNT_SOFT 0x0001 /* 1 */
51#define NFS_MOUNT_INTR 0x0002 /* 1 */ /* now unused, but ABI */ 51#define NFS_MOUNT_INTR 0x0002 /* 1 */ /* now unused, but ABI */
@@ -68,5 +68,6 @@ struct nfs_mount_data {
68/* The following are for internal use only */ 68/* The following are for internal use only */
69#define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000 69#define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
70#define NFS_MOUNT_LOOKUP_CACHE_NONE 0x20000 70#define NFS_MOUNT_LOOKUP_CACHE_NONE 0x20000
71#define NFS_MOUNT_NORESVPORT 0x40000
71 72
72#endif 73#endif
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index c1c31acb8a2b..a550b528319f 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -120,13 +120,14 @@ struct nfs_openargs {
120 const struct nfs_fh * fh; 120 const struct nfs_fh * fh;
121 struct nfs_seqid * seqid; 121 struct nfs_seqid * seqid;
122 int open_flags; 122 int open_flags;
123 fmode_t fmode;
123 __u64 clientid; 124 __u64 clientid;
124 __u64 id; 125 __u64 id;
125 union { 126 union {
126 struct iattr * attrs; /* UNCHECKED, GUARDED */ 127 struct iattr * attrs; /* UNCHECKED, GUARDED */
127 nfs4_verifier verifier; /* EXCLUSIVE */ 128 nfs4_verifier verifier; /* EXCLUSIVE */
128 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */ 129 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
129 int delegation_type; /* CLAIM_PREVIOUS */ 130 fmode_t delegation_type; /* CLAIM_PREVIOUS */
130 } u; 131 } u;
131 const struct qstr * name; 132 const struct qstr * name;
132 const struct nfs_server *server; /* Needed for ID mapping */ 133 const struct nfs_server *server; /* Needed for ID mapping */
@@ -143,7 +144,7 @@ struct nfs_openres {
143 struct nfs_fattr * dir_attr; 144 struct nfs_fattr * dir_attr;
144 struct nfs_seqid * seqid; 145 struct nfs_seqid * seqid;
145 const struct nfs_server *server; 146 const struct nfs_server *server;
146 int delegation_type; 147 fmode_t delegation_type;
147 nfs4_stateid delegation; 148 nfs4_stateid delegation;
148 __u32 do_recall; 149 __u32 do_recall;
149 __u64 maxsize; 150 __u64 maxsize;
@@ -171,7 +172,7 @@ struct nfs_closeargs {
171 struct nfs_fh * fh; 172 struct nfs_fh * fh;
172 nfs4_stateid * stateid; 173 nfs4_stateid * stateid;
173 struct nfs_seqid * seqid; 174 struct nfs_seqid * seqid;
174 int open_flags; 175 fmode_t fmode;
175 const u32 * bitmask; 176 const u32 * bitmask;
176}; 177};
177 178
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
index d0fe2e378452..128298c0362d 100644
--- a/include/linux/nfsd/state.h
+++ b/include/linux/nfsd/state.h
@@ -124,6 +124,8 @@ struct nfs4_client {
124 nfs4_verifier cl_verifier; /* generated by client */ 124 nfs4_verifier cl_verifier; /* generated by client */
125 time_t cl_time; /* time of last lease renewal */ 125 time_t cl_time; /* time of last lease renewal */
126 __be32 cl_addr; /* client ipaddress */ 126 __be32 cl_addr; /* client ipaddress */
127 u32 cl_flavor; /* setclientid pseudoflavor */
128 char *cl_principal; /* setclientid principal name */
127 struct svc_cred cl_cred; /* setclientid principal */ 129 struct svc_cred cl_cred; /* setclientid principal */
128 clientid_t cl_clientid; /* generated by server */ 130 clientid_t cl_clientid; /* generated by server */
129 nfs4_verifier cl_confirm; /* generated by server */ 131 nfs4_verifier cl_confirm; /* generated by server */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index a8efcfeea732..3d327b67d7e2 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -26,8 +26,7 @@ extern struct bus_type of_platform_bus_type;
26 26
27/* 27/*
28 * An of_platform_driver driver is attached to a basic of_device on 28 * An of_platform_driver driver is attached to a basic of_device on
29 * the "platform bus" (of_platform_bus_type) (or ISA, EBUS and SBUS 29 * the "platform bus" (of_platform_bus_type).
30 * busses on sparc).
31 */ 30 */
32struct of_platform_driver 31struct of_platform_driver
33{ 32{
diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
index 5231861f357d..1ce9fe572e51 100644
--- a/include/linux/oprofile.h
+++ b/include/linux/oprofile.h
@@ -86,8 +86,7 @@ int oprofile_arch_init(struct oprofile_operations * ops);
86void oprofile_arch_exit(void); 86void oprofile_arch_exit(void);
87 87
88/** 88/**
89 * Add a sample. This may be called from any context. Pass 89 * Add a sample. This may be called from any context.
90 * smp_processor_id() as cpu.
91 */ 90 */
92void oprofile_add_sample(struct pt_regs * const regs, unsigned long event); 91void oprofile_add_sample(struct pt_regs * const regs, unsigned long event);
93 92
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index a7c721355549..4f71bf4e628c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -45,7 +45,11 @@ struct k_itimer {
45 int it_requeue_pending; /* waiting to requeue this timer */ 45 int it_requeue_pending; /* waiting to requeue this timer */
46#define REQUEUE_PENDING 1 46#define REQUEUE_PENDING 1
47 int it_sigev_notify; /* notify word of sigevent struct */ 47 int it_sigev_notify; /* notify word of sigevent struct */
48 struct task_struct *it_process; /* process to send signal to */ 48 struct signal_struct *it_signal;
49 union {
50 struct pid *it_pid; /* pid of process to send signal to */
51 struct task_struct *it_process; /* for clock_nanosleep */
52 };
49 struct sigqueue *sigq; /* signal queue entry. */ 53 struct sigqueue *sigq; /* signal queue entry. */
50 union { 54 union {
51 struct { 55 struct {
diff --git a/include/linux/random.h b/include/linux/random.h
index 36f125c0c603..adbf3bd3c6b3 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -8,6 +8,7 @@
8#define _LINUX_RANDOM_H 8#define _LINUX_RANDOM_H
9 9
10#include <linux/ioctl.h> 10#include <linux/ioctl.h>
11#include <linux/irqnr.h>
11 12
12/* ioctl()'s for the random number generator */ 13/* ioctl()'s for the random number generator */
13 14
@@ -44,6 +45,56 @@ struct rand_pool_info {
44 45
45extern void rand_initialize_irq(int irq); 46extern void rand_initialize_irq(int irq);
46 47
48struct timer_rand_state;
49#ifndef CONFIG_SPARSE_IRQ
50
51extern struct timer_rand_state *irq_timer_state[];
52
53static inline struct timer_rand_state *get_timer_rand_state(unsigned int irq)
54{
55 if (irq >= nr_irqs)
56 return NULL;
57
58 return irq_timer_state[irq];
59}
60
61static inline void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state)
62{
63 if (irq >= nr_irqs)
64 return;
65
66 irq_timer_state[irq] = state;
67}
68
69#else
70
71#include <linux/irq.h>
72static inline struct timer_rand_state *get_timer_rand_state(unsigned int irq)
73{
74 struct irq_desc *desc;
75
76 desc = irq_to_desc(irq);
77
78 if (!desc)
79 return NULL;
80
81 return desc->timer_rand_state;
82}
83
84static inline void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state)
85{
86 struct irq_desc *desc;
87
88 desc = irq_to_desc(irq);
89
90 if (!desc)
91 return;
92
93 desc->timer_rand_state = state;
94}
95#endif
96
97
47extern void add_input_randomness(unsigned int type, unsigned int code, 98extern void add_input_randomness(unsigned int type, unsigned int code,
48 unsigned int value); 99 unsigned int value);
49extern void add_interrupt_randomness(int irq); 100extern void add_interrupt_randomness(int irq);
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index 5f89b62e6983..301dda829e37 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -41,7 +41,7 @@
41#include <linux/seqlock.h> 41#include <linux/seqlock.h>
42 42
43#ifdef CONFIG_RCU_CPU_STALL_DETECTOR 43#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
44#define RCU_SECONDS_TILL_STALL_CHECK ( 3 * HZ) /* for rcp->jiffies_stall */ 44#define RCU_SECONDS_TILL_STALL_CHECK (10 * HZ) /* for rcp->jiffies_stall */
45#define RCU_SECONDS_TILL_STALL_RECHECK (30 * HZ) /* for rcp->jiffies_stall */ 45#define RCU_SECONDS_TILL_STALL_RECHECK (30 * HZ) /* for rcp->jiffies_stall */
46#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ 46#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
47 47
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 895dc9c1088c..1168fbcea8d4 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -52,11 +52,15 @@ struct rcu_head {
52 void (*func)(struct rcu_head *head); 52 void (*func)(struct rcu_head *head);
53}; 53};
54 54
55#ifdef CONFIG_CLASSIC_RCU 55#if defined(CONFIG_CLASSIC_RCU)
56#include <linux/rcuclassic.h> 56#include <linux/rcuclassic.h>
57#else /* #ifdef CONFIG_CLASSIC_RCU */ 57#elif defined(CONFIG_TREE_RCU)
58#include <linux/rcutree.h>
59#elif defined(CONFIG_PREEMPT_RCU)
58#include <linux/rcupreempt.h> 60#include <linux/rcupreempt.h>
59#endif /* #else #ifdef CONFIG_CLASSIC_RCU */ 61#else
62#error "Unknown RCU implementation specified to kernel configuration"
63#endif /* #else #if defined(CONFIG_CLASSIC_RCU) */
60 64
61#define RCU_HEAD_INIT { .next = NULL, .func = NULL } 65#define RCU_HEAD_INIT { .next = NULL, .func = NULL }
62#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT 66#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT
diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
new file mode 100644
index 000000000000..d4368b7975c3
--- /dev/null
+++ b/include/linux/rcutree.h
@@ -0,0 +1,329 @@
1/*
2 * Read-Copy Update mechanism for mutual exclusion (tree-based version)
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright IBM Corporation, 2008
19 *
20 * Author: Dipankar Sarma <dipankar@in.ibm.com>
21 * Paul E. McKenney <paulmck@linux.vnet.ibm.com> Hierarchical algorithm
22 *
23 * Based on the original work by Paul McKenney <paulmck@us.ibm.com>
24 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
25 *
26 * For detailed explanation of Read-Copy Update mechanism see -
27 * Documentation/RCU
28 */
29
30#ifndef __LINUX_RCUTREE_H
31#define __LINUX_RCUTREE_H
32
33#include <linux/cache.h>
34#include <linux/spinlock.h>
35#include <linux/threads.h>
36#include <linux/percpu.h>
37#include <linux/cpumask.h>
38#include <linux/seqlock.h>
39
40/*
41 * Define shape of hierarchy based on NR_CPUS and CONFIG_RCU_FANOUT.
42 * In theory, it should be possible to add more levels straightforwardly.
43 * In practice, this has not been tested, so there is probably some
44 * bug somewhere.
45 */
46#define MAX_RCU_LVLS 3
47#define RCU_FANOUT (CONFIG_RCU_FANOUT)
48#define RCU_FANOUT_SQ (RCU_FANOUT * RCU_FANOUT)
49#define RCU_FANOUT_CUBE (RCU_FANOUT_SQ * RCU_FANOUT)
50
51#if NR_CPUS <= RCU_FANOUT
52# define NUM_RCU_LVLS 1
53# define NUM_RCU_LVL_0 1
54# define NUM_RCU_LVL_1 (NR_CPUS)
55# define NUM_RCU_LVL_2 0
56# define NUM_RCU_LVL_3 0
57#elif NR_CPUS <= RCU_FANOUT_SQ
58# define NUM_RCU_LVLS 2
59# define NUM_RCU_LVL_0 1
60# define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT - 1) / RCU_FANOUT)
61# define NUM_RCU_LVL_2 (NR_CPUS)
62# define NUM_RCU_LVL_3 0
63#elif NR_CPUS <= RCU_FANOUT_CUBE
64# define NUM_RCU_LVLS 3
65# define NUM_RCU_LVL_0 1
66# define NUM_RCU_LVL_1 (((NR_CPUS) + RCU_FANOUT_SQ - 1) / RCU_FANOUT_SQ)
67# define NUM_RCU_LVL_2 (((NR_CPUS) + (RCU_FANOUT) - 1) / (RCU_FANOUT))
68# define NUM_RCU_LVL_3 NR_CPUS
69#else
70# error "CONFIG_RCU_FANOUT insufficient for NR_CPUS"
71#endif /* #if (NR_CPUS) <= RCU_FANOUT */
72
73#define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3)
74#define NUM_RCU_NODES (RCU_SUM - NR_CPUS)
75
76/*
77 * Dynticks per-CPU state.
78 */
79struct rcu_dynticks {
80 int dynticks_nesting; /* Track nesting level, sort of. */
81 int dynticks; /* Even value for dynticks-idle, else odd. */
82 int dynticks_nmi; /* Even value for either dynticks-idle or */
83 /* not in nmi handler, else odd. So this */
84 /* remains even for nmi from irq handler. */
85};
86
87/*
88 * Definition for node within the RCU grace-period-detection hierarchy.
89 */
90struct rcu_node {
91 spinlock_t lock;
92 unsigned long qsmask; /* CPUs or groups that need to switch in */
93 /* order for current grace period to proceed.*/
94 unsigned long qsmaskinit;
95 /* Per-GP initialization for qsmask. */
96 unsigned long grpmask; /* Mask to apply to parent qsmask. */
97 int grplo; /* lowest-numbered CPU or group here. */
98 int grphi; /* highest-numbered CPU or group here. */
99 u8 grpnum; /* CPU/group number for next level up. */
100 u8 level; /* root is at level 0. */
101 struct rcu_node *parent;
102} ____cacheline_internodealigned_in_smp;
103
104/* Index values for nxttail array in struct rcu_data. */
105#define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */
106#define RCU_WAIT_TAIL 1 /* Also RCU_NEXT_READY head. */
107#define RCU_NEXT_READY_TAIL 2 /* Also RCU_NEXT head. */
108#define RCU_NEXT_TAIL 3
109#define RCU_NEXT_SIZE 4
110
111/* Per-CPU data for read-copy update. */
112struct rcu_data {
113 /* 1) quiescent-state and grace-period handling : */
114 long completed; /* Track rsp->completed gp number */
115 /* in order to detect GP end. */
116 long gpnum; /* Highest gp number that this CPU */
117 /* is aware of having started. */
118 long passed_quiesc_completed;
119 /* Value of completed at time of qs. */
120 bool passed_quiesc; /* User-mode/idle loop etc. */
121 bool qs_pending; /* Core waits for quiesc state. */
122 bool beenonline; /* CPU online at least once. */
123 struct rcu_node *mynode; /* This CPU's leaf of hierarchy */
124 unsigned long grpmask; /* Mask to apply to leaf qsmask. */
125
126 /* 2) batch handling */
127 /*
128 * If nxtlist is not NULL, it is partitioned as follows.
129 * Any of the partitions might be empty, in which case the
130 * pointer to that partition will be equal to the pointer for
131 * the following partition. When the list is empty, all of
132 * the nxttail elements point to nxtlist, which is NULL.
133 *
134 * [*nxttail[RCU_NEXT_READY_TAIL], NULL = *nxttail[RCU_NEXT_TAIL]):
135 * Entries that might have arrived after current GP ended
136 * [*nxttail[RCU_WAIT_TAIL], *nxttail[RCU_NEXT_READY_TAIL]):
137 * Entries known to have arrived before current GP ended
138 * [*nxttail[RCU_DONE_TAIL], *nxttail[RCU_WAIT_TAIL]):
139 * Entries that batch # <= ->completed - 1: waiting for current GP
140 * [nxtlist, *nxttail[RCU_DONE_TAIL]):
141 * Entries that batch # <= ->completed
142 * The grace period for these entries has completed, and
143 * the other grace-period-completed entries may be moved
144 * here temporarily in rcu_process_callbacks().
145 */
146 struct rcu_head *nxtlist;
147 struct rcu_head **nxttail[RCU_NEXT_SIZE];
148 long qlen; /* # of queued callbacks */
149 long blimit; /* Upper limit on a processed batch */
150
151#ifdef CONFIG_NO_HZ
152 /* 3) dynticks interface. */
153 struct rcu_dynticks *dynticks; /* Shared per-CPU dynticks state. */
154 int dynticks_snap; /* Per-GP tracking for dynticks. */
155 int dynticks_nmi_snap; /* Per-GP tracking for dynticks_nmi. */
156#endif /* #ifdef CONFIG_NO_HZ */
157
158 /* 4) reasons this CPU needed to be kicked by force_quiescent_state */
159#ifdef CONFIG_NO_HZ
160 unsigned long dynticks_fqs; /* Kicked due to dynticks idle. */
161#endif /* #ifdef CONFIG_NO_HZ */
162 unsigned long offline_fqs; /* Kicked due to being offline. */
163 unsigned long resched_ipi; /* Sent a resched IPI. */
164
165 /* 5) state to allow this CPU to force_quiescent_state on others */
166 long n_rcu_pending; /* rcu_pending() calls since boot. */
167 long n_rcu_pending_force_qs; /* when to force quiescent states. */
168
169 int cpu;
170};
171
172/* Values for signaled field in struct rcu_state. */
173#define RCU_GP_INIT 0 /* Grace period being initialized. */
174#define RCU_SAVE_DYNTICK 1 /* Need to scan dyntick state. */
175#define RCU_FORCE_QS 2 /* Need to force quiescent state. */
176#ifdef CONFIG_NO_HZ
177#define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK
178#else /* #ifdef CONFIG_NO_HZ */
179#define RCU_SIGNAL_INIT RCU_FORCE_QS
180#endif /* #else #ifdef CONFIG_NO_HZ */
181
182#define RCU_JIFFIES_TILL_FORCE_QS 3 /* for rsp->jiffies_force_qs */
183#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
184#define RCU_SECONDS_TILL_STALL_CHECK (10 * HZ) /* for rsp->jiffies_stall */
185#define RCU_SECONDS_TILL_STALL_RECHECK (30 * HZ) /* for rsp->jiffies_stall */
186#define RCU_STALL_RAT_DELAY 2 /* Allow other CPUs time */
187 /* to take at least one */
188 /* scheduling clock irq */
189 /* before ratting on them. */
190
191#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
192
193/*
194 * RCU global state, including node hierarchy. This hierarchy is
195 * represented in "heap" form in a dense array. The root (first level)
196 * of the hierarchy is in ->node[0] (referenced by ->level[0]), the second
197 * level in ->node[1] through ->node[m] (->node[1] referenced by ->level[1]),
198 * and the third level in ->node[m+1] and following (->node[m+1] referenced
199 * by ->level[2]). The number of levels is determined by the number of
200 * CPUs and by CONFIG_RCU_FANOUT. Small systems will have a "hierarchy"
201 * consisting of a single rcu_node.
202 */
203struct rcu_state {
204 struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */
205 struct rcu_node *level[NUM_RCU_LVLS]; /* Hierarchy levels. */
206 u32 levelcnt[MAX_RCU_LVLS + 1]; /* # nodes in each level. */
207 u8 levelspread[NUM_RCU_LVLS]; /* kids/node in each level. */
208 struct rcu_data *rda[NR_CPUS]; /* array of rdp pointers. */
209
210 /* The following fields are guarded by the root rcu_node's lock. */
211
212 u8 signaled ____cacheline_internodealigned_in_smp;
213 /* Force QS state. */
214 long gpnum; /* Current gp number. */
215 long completed; /* # of last completed gp. */
216 spinlock_t onofflock; /* exclude on/offline and */
217 /* starting new GP. */
218 spinlock_t fqslock; /* Only one task forcing */
219 /* quiescent states. */
220 unsigned long jiffies_force_qs; /* Time at which to invoke */
221 /* force_quiescent_state(). */
222 unsigned long n_force_qs; /* Number of calls to */
223 /* force_quiescent_state(). */
224 unsigned long n_force_qs_lh; /* ~Number of calls leaving */
225 /* due to lock unavailable. */
226 unsigned long n_force_qs_ngp; /* Number of calls leaving */
227 /* due to no GP active. */
228#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
229 unsigned long gp_start; /* Time at which GP started, */
230 /* but in jiffies. */
231 unsigned long jiffies_stall; /* Time at which to check */
232 /* for CPU stalls. */
233#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
234#ifdef CONFIG_NO_HZ
235 long dynticks_completed; /* Value of completed @ snap. */
236#endif /* #ifdef CONFIG_NO_HZ */
237};
238
239extern struct rcu_state rcu_state;
240DECLARE_PER_CPU(struct rcu_data, rcu_data);
241
242extern struct rcu_state rcu_bh_state;
243DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
244
245/*
246 * Increment the quiescent state counter.
247 * The counter is a bit degenerated: We do not need to know
248 * how many quiescent states passed, just if there was at least
249 * one since the start of the grace period. Thus just a flag.
250 */
251static inline void rcu_qsctr_inc(int cpu)
252{
253 struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
254 rdp->passed_quiesc = 1;
255 rdp->passed_quiesc_completed = rdp->completed;
256}
257static inline void rcu_bh_qsctr_inc(int cpu)
258{
259 struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
260 rdp->passed_quiesc = 1;
261 rdp->passed_quiesc_completed = rdp->completed;
262}
263
264extern int rcu_pending(int cpu);
265extern int rcu_needs_cpu(int cpu);
266
267#ifdef CONFIG_DEBUG_LOCK_ALLOC
268extern struct lockdep_map rcu_lock_map;
269# define rcu_read_acquire() \
270 lock_acquire(&rcu_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_)
271# define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_)
272#else
273# define rcu_read_acquire() do { } while (0)
274# define rcu_read_release() do { } while (0)
275#endif
276
277static inline void __rcu_read_lock(void)
278{
279 preempt_disable();
280 __acquire(RCU);
281 rcu_read_acquire();
282}
283static inline void __rcu_read_unlock(void)
284{
285 rcu_read_release();
286 __release(RCU);
287 preempt_enable();
288}
289static inline void __rcu_read_lock_bh(void)
290{
291 local_bh_disable();
292 __acquire(RCU_BH);
293 rcu_read_acquire();
294}
295static inline void __rcu_read_unlock_bh(void)
296{
297 rcu_read_release();
298 __release(RCU_BH);
299 local_bh_enable();
300}
301
302#define __synchronize_sched() synchronize_rcu()
303
304#define call_rcu_sched(head, func) call_rcu(head, func)
305
306static inline void rcu_init_sched(void)
307{
308}
309
310extern void __rcu_init(void);
311extern void rcu_check_callbacks(int cpu, int user);
312extern void rcu_restart_cpu(int cpu);
313
314extern long rcu_batches_completed(void);
315extern long rcu_batches_completed_bh(void);
316
317#ifdef CONFIG_NO_HZ
318void rcu_enter_nohz(void);
319void rcu_exit_nohz(void);
320#else /* CONFIG_NO_HZ */
321static inline void rcu_enter_nohz(void)
322{
323}
324static inline void rcu_exit_nohz(void)
325{
326}
327#endif /* CONFIG_NO_HZ */
328
329#endif /* __LINUX_RCUTREE_H */
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index d363467c8f13..b3b359660082 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -118,6 +118,8 @@ void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);
118 118
119unsigned long ring_buffer_entries(struct ring_buffer *buffer); 119unsigned long ring_buffer_entries(struct ring_buffer *buffer);
120unsigned long ring_buffer_overruns(struct ring_buffer *buffer); 120unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
121unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu);
122unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);
121 123
122u64 ring_buffer_time_stamp(int cpu); 124u64 ring_buffer_time_stamp(int cpu);
123void ring_buffer_normalize_time_stamp(int cpu, u64 *ts); 125void ring_buffer_normalize_time_stamp(int cpu, u64 *ts);
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 4e4f1277f3bf..feb3b939ec4b 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -158,6 +158,8 @@
158/* SH-SCI */ 158/* SH-SCI */
159#define PORT_SCIFA 83 159#define PORT_SCIFA 83
160 160
161#define PORT_S3C6400 84
162
161#ifdef __KERNEL__ 163#ifdef __KERNEL__
162 164
163#include <linux/compiler.h> 165#include <linux/compiler.h>
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 000da12b5cf0..f96d13c281e8 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -253,9 +253,9 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
253 * request comes from. 253 * request comes from.
254 */ 254 */
255#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) 255#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
256extern void *__kmalloc_track_caller(size_t, gfp_t, void*); 256extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
257#define kmalloc_track_caller(size, flags) \ 257#define kmalloc_track_caller(size, flags) \
258 __kmalloc_track_caller(size, flags, __builtin_return_address(0)) 258 __kmalloc_track_caller(size, flags, _RET_IP_)
259#else 259#else
260#define kmalloc_track_caller(size, flags) \ 260#define kmalloc_track_caller(size, flags) \
261 __kmalloc(size, flags) 261 __kmalloc(size, flags)
@@ -271,10 +271,10 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
271 * allocation request comes from. 271 * allocation request comes from.
272 */ 272 */
273#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) 273#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
274extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *); 274extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
275#define kmalloc_node_track_caller(size, flags, node) \ 275#define kmalloc_node_track_caller(size, flags, node) \
276 __kmalloc_node_track_caller(size, flags, node, \ 276 __kmalloc_node_track_caller(size, flags, node, \
277 __builtin_return_address(0)) 277 _RET_IP_)
278#else 278#else
279#define kmalloc_node_track_caller(size, flags, node) \ 279#define kmalloc_node_track_caller(size, flags, node) \
280 __kmalloc_node(size, flags, node) 280 __kmalloc_node(size, flags, node)
@@ -285,7 +285,7 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
285#define kmalloc_node_track_caller(size, flags, node) \ 285#define kmalloc_node_track_caller(size, flags, node) \
286 kmalloc_track_caller(size, flags) 286 kmalloc_track_caller(size, flags)
287 287
288#endif /* DEBUG_SLAB */ 288#endif /* CONFIG_NUMA */
289 289
290/* 290/*
291 * Shortcuts 291 * Shortcuts
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 6f0ee1b84a4f..c39a21040dcb 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -58,6 +58,7 @@ struct rpc_clnt {
58 struct rpc_timeout cl_timeout_default; 58 struct rpc_timeout cl_timeout_default;
59 struct rpc_program * cl_program; 59 struct rpc_program * cl_program;
60 char cl_inline_name[32]; 60 char cl_inline_name[32];
61 char *cl_principal; /* target to authenticate to */
61}; 62};
62 63
63/* 64/*
@@ -108,6 +109,7 @@ struct rpc_create_args {
108 u32 version; 109 u32 version;
109 rpc_authflavor_t authflavor; 110 rpc_authflavor_t authflavor;
110 unsigned long flags; 111 unsigned long flags;
112 char *client_name;
111}; 113};
112 114
113/* Values for "flags" field */ 115/* Values for "flags" field */
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h
index 51b977a4ca20..cea764c2359f 100644
--- a/include/linux/sunrpc/rpc_pipe_fs.h
+++ b/include/linux/sunrpc/rpc_pipe_fs.h
@@ -15,6 +15,7 @@ struct rpc_pipe_ops {
15 ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t); 15 ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t);
16 ssize_t (*downcall)(struct file *, const char __user *, size_t); 16 ssize_t (*downcall)(struct file *, const char __user *, size_t);
17 void (*release_pipe)(struct inode *); 17 void (*release_pipe)(struct inode *);
18 int (*open_pipe)(struct inode *);
18 void (*destroy_msg)(struct rpc_pipe_msg *); 19 void (*destroy_msg)(struct rpc_pipe_msg *);
19}; 20};
20 21
diff --git a/include/linux/sunrpc/svcauth_gss.h b/include/linux/sunrpc/svcauth_gss.h
index c9165d9771a8..ca7d725861fc 100644
--- a/include/linux/sunrpc/svcauth_gss.h
+++ b/include/linux/sunrpc/svcauth_gss.h
@@ -20,6 +20,7 @@ int gss_svc_init(void);
20void gss_svc_shutdown(void); 20void gss_svc_shutdown(void);
21int svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name); 21int svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name);
22u32 svcauth_gss_flavor(struct auth_domain *dom); 22u32 svcauth_gss_flavor(struct auth_domain *dom);
23char *svc_gss_principal(struct svc_rqst *);
23 24
24#endif /* __KERNEL__ */ 25#endif /* __KERNEL__ */
25#endif /* _LINUX_SUNRPC_SVCAUTH_GSS_H */ 26#endif /* _LINUX_SUNRPC_SVCAUTH_GSS_H */
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index e4057d729f03..49e1eb454465 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -37,21 +37,6 @@ struct xdr_netobj {
37typedef int (*kxdrproc_t)(void *rqstp, __be32 *data, void *obj); 37typedef int (*kxdrproc_t)(void *rqstp, __be32 *data, void *obj);
38 38
39/* 39/*
40 * We're still requiring the BKL in the xdr code until it's been
41 * more carefully audited, at which point this wrapper will become
42 * unnecessary.
43 */
44static inline int rpc_call_xdrproc(kxdrproc_t xdrproc, void *rqstp, __be32 *data, void *obj)
45{
46 int ret;
47
48 lock_kernel();
49 ret = xdrproc(rqstp, data, obj);
50 unlock_kernel();
51 return ret;
52}
53
54/*
55 * Basic structure for transmission/reception of a client XDR message. 40 * Basic structure for transmission/reception of a client XDR message.
56 * Features a header (for a linear buffer containing RPC headers 41 * Features a header (for a linear buffer containing RPC headers
57 * and the data payload for short messages), and then an array of 42 * and the data payload for short messages), and then an array of
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 4d80a118d538..11fc71d50c1e 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -76,8 +76,7 @@ struct rpc_rqst {
76 struct list_head rq_list; 76 struct list_head rq_list;
77 77
78 __u32 * rq_buffer; /* XDR encode buffer */ 78 __u32 * rq_buffer; /* XDR encode buffer */
79 size_t rq_bufsize, 79 size_t rq_callsize,
80 rq_callsize,
81 rq_rcvsize; 80 rq_rcvsize;
82 81
83 struct xdr_buf rq_private_buf; /* The receive buffer 82 struct xdr_buf rq_private_buf; /* The receive buffer
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index b18ec5533e8c..325af1de0351 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -7,9 +7,31 @@ struct device;
7struct dma_attrs; 7struct dma_attrs;
8struct scatterlist; 8struct scatterlist;
9 9
10/*
11 * Maximum allowable number of contiguous slabs to map,
12 * must be a power of 2. What is the appropriate value ?
13 * The complexity of {map,unmap}_single is linearly dependent on this value.
14 */
15#define IO_TLB_SEGSIZE 128
16
17
18/*
19 * log of the size of each IO TLB slab. The number of slabs is command line
20 * controllable.
21 */
22#define IO_TLB_SHIFT 11
23
10extern void 24extern void
11swiotlb_init(void); 25swiotlb_init(void);
12 26
27extern void *swiotlb_alloc_boot(size_t bytes, unsigned long nslabs);
28extern void *swiotlb_alloc(unsigned order, unsigned long nslabs);
29
30extern dma_addr_t swiotlb_phys_to_bus(phys_addr_t address);
31extern phys_addr_t swiotlb_bus_to_phys(dma_addr_t address);
32
33extern int swiotlb_arch_range_needs_mapping(void *ptr, size_t size);
34
13extern void 35extern void
14*swiotlb_alloc_coherent(struct device *hwdev, size_t size, 36*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
15 dma_addr_t *dma_handle, gfp_t flags); 37 dma_addr_t *dma_handle, gfp_t flags);
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 9007313b5b71..998a55d80acf 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -53,47 +53,11 @@
53#ifndef _LINUX_TIMEX_H 53#ifndef _LINUX_TIMEX_H
54#define _LINUX_TIMEX_H 54#define _LINUX_TIMEX_H
55 55
56#include <linux/compiler.h>
57#include <linux/time.h> 56#include <linux/time.h>
58 57
59#include <asm/param.h>
60
61#define NTP_API 4 /* NTP API version */ 58#define NTP_API 4 /* NTP API version */
62 59
63/* 60/*
64 * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
65 * for a slightly underdamped convergence characteristic. SHIFT_KH
66 * establishes the damping of the FLL and is chosen by wisdom and black
67 * art.
68 *
69 * MAXTC establishes the maximum time constant of the PLL. With the
70 * SHIFT_KG and SHIFT_KF values given and a time constant range from
71 * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
72 * respectively.
73 */
74#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
75#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
76#define MAXTC 10 /* maximum time constant (shift) */
77
78/*
79 * SHIFT_USEC defines the scaling (shift) of the time_freq and
80 * time_tolerance variables, which represent the current frequency
81 * offset and maximum frequency tolerance.
82 */
83#define SHIFT_USEC 16 /* frequency offset scale (shift) */
84#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
85#define PPM_SCALE_INV_SHIFT 19
86#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
87 PPM_SCALE + 1)
88
89#define MAXPHASE 500000000l /* max phase error (ns) */
90#define MAXFREQ 500000 /* max frequency error (ns/s) */
91#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
92#define MINSEC 256 /* min interval between updates (s) */
93#define MAXSEC 2048 /* max interval between updates (s) */
94#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
95
96/*
97 * syscall interface - used (mainly by NTP daemon) 61 * syscall interface - used (mainly by NTP daemon)
98 * to discipline kernel clock oscillator 62 * to discipline kernel clock oscillator
99 */ 63 */
@@ -199,9 +163,46 @@ struct timex {
199#define TIME_BAD TIME_ERROR /* bw compat */ 163#define TIME_BAD TIME_ERROR /* bw compat */
200 164
201#ifdef __KERNEL__ 165#ifdef __KERNEL__
166#include <linux/compiler.h>
167#include <linux/types.h>
168#include <linux/param.h>
169
202#include <asm/timex.h> 170#include <asm/timex.h>
203 171
204/* 172/*
173 * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
174 * for a slightly underdamped convergence characteristic. SHIFT_KH
175 * establishes the damping of the FLL and is chosen by wisdom and black
176 * art.
177 *
178 * MAXTC establishes the maximum time constant of the PLL. With the
179 * SHIFT_KG and SHIFT_KF values given and a time constant range from
180 * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
181 * respectively.
182 */
183#define SHIFT_PLL 4 /* PLL frequency factor (shift) */
184#define SHIFT_FLL 2 /* FLL frequency factor (shift) */
185#define MAXTC 10 /* maximum time constant (shift) */
186
187/*
188 * SHIFT_USEC defines the scaling (shift) of the time_freq and
189 * time_tolerance variables, which represent the current frequency
190 * offset and maximum frequency tolerance.
191 */
192#define SHIFT_USEC 16 /* frequency offset scale (shift) */
193#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
194#define PPM_SCALE_INV_SHIFT 19
195#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
196 PPM_SCALE + 1)
197
198#define MAXPHASE 500000000l /* max phase error (ns) */
199#define MAXFREQ 500000 /* max frequency error (ns/s) */
200#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
201#define MINSEC 256 /* min interval between updates (s) */
202#define MAXSEC 2048 /* max interval between updates (s) */
203#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
204
205/*
205 * kernel variables 206 * kernel variables
206 * Note: maximum error = NTP synch distance = dispersion + delay / 2; 207 * Note: maximum error = NTP synch distance = dispersion + delay / 2;
207 * estimated error = NTP dispersion. 208 * estimated error = NTP dispersion.
diff --git a/include/linux/types.h b/include/linux/types.h
index 1d98330b1f2c..121f349cb7ec 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -135,19 +135,14 @@ typedef __s64 int64_t;
135 * 135 *
136 * Linux always considers sectors to be 512 bytes long independently 136 * Linux always considers sectors to be 512 bytes long independently
137 * of the devices real block size. 137 * of the devices real block size.
138 *
139 * blkcnt_t is the type of the inode's block count.
138 */ 140 */
139#ifdef CONFIG_LBD 141#ifdef CONFIG_LBD
140typedef u64 sector_t; 142typedef u64 sector_t;
141#else
142typedef unsigned long sector_t;
143#endif
144
145/*
146 * The type of the inode's block count.
147 */
148#ifdef CONFIG_LSF
149typedef u64 blkcnt_t; 143typedef u64 blkcnt_t;
150#else 144#else
145typedef unsigned long sector_t;
151typedef unsigned long blkcnt_t; 146typedef unsigned long blkcnt_t;
152#endif 147#endif
153 148
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index fec6decfb983..6b58367d145e 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -78,7 +78,7 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78 \ 78 \
79 set_fs(KERNEL_DS); \ 79 set_fs(KERNEL_DS); \
80 pagefault_disable(); \ 80 pagefault_disable(); \
81 ret = __get_user(retval, (__force typeof(retval) __user *)(addr)); \ 81 ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
82 pagefault_enable(); \ 82 pagefault_enable(); \
83 set_fs(old_fs); \ 83 set_fs(old_fs); \
84 ret; \ 84 ret; \
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 4669d7e72e75..1f126e30766c 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -293,6 +293,7 @@ struct v4l2_pix_format {
293#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ 293#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
294#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ 294#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
295#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ 295#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
296#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */
296#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */ 297#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
297#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */ 298#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */
298#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ 299#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */
@@ -304,6 +305,8 @@ struct v4l2_pix_format {
304/* two planes -- one Y, one Cr + Cb interleaved */ 305/* two planes -- one Y, one Cr + Cb interleaved */
305#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ 306#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
306#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */ 307#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
308#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
309#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
307 310
308/* The following formats are not defined in the V4L2 specification */ 311/* The following formats are not defined in the V4L2 specification */
309#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */ 312#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
@@ -1050,7 +1053,7 @@ enum v4l2_mpeg_video_bitrate_mode {
1050#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210) 1053#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210)
1051#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211) 1054#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211)
1052 1055
1053/* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ 1056/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
1054#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) 1057#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
1055#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) 1058#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0)
1056enum v4l2_mpeg_cx2341x_video_spatial_filter_mode { 1059enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
@@ -1117,6 +1120,12 @@ enum v4l2_exposure_auto_type {
1117#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11) 1120#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
1118#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12) 1121#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
1119 1122
1123#define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13)
1124#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14)
1125#define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE+15)
1126
1127#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16)
1128
1120/* 1129/*
1121 * T U N I N G 1130 * T U N I N G
1122 */ 1131 */
@@ -1369,6 +1378,7 @@ struct v4l2_streamparm {
1369#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ 1378#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */
1370#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */ 1379#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */
1371#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ 1380#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */
1381#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */
1372 1382
1373struct v4l2_register { 1383struct v4l2_register {
1374 __u32 match_type; /* Match type */ 1384 __u32 match_type; /* Match type */
@@ -1458,6 +1468,8 @@ struct v4l2_chip_ident {
1458#define VIDIOC_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_chip_ident) 1468#define VIDIOC_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_chip_ident)
1459#endif 1469#endif
1460#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) 1470#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
1471/* Reminder: when adding new ioctls please add support for them to
1472 drivers/media/video/v4l2-compat-ioctl32.c as well! */
1461 1473
1462#ifdef __OLD_VIDIOC_ 1474#ifdef __OLD_VIDIOC_
1463/* for compatibility, will go away some day */ 1475/* for compatibility, will go away some day */
diff --git a/include/linux/virtio_balloon.h b/include/linux/virtio_balloon.h
index c30c7bfbf39b..8726ff77763e 100644
--- a/include/linux/virtio_balloon.h
+++ b/include/linux/virtio_balloon.h
@@ -10,6 +10,9 @@
10/* The feature bitmap for virtio balloon */ 10/* The feature bitmap for virtio balloon */
11#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */ 11#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
12 12
13/* Size of a PFN in the balloon interface. */
14#define VIRTIO_BALLOON_PFN_SHIFT 12
15
13struct virtio_balloon_config 16struct virtio_balloon_config
14{ 17{
15 /* Number of pages host wants Guest to give up. */ 18 /* Number of pages host wants Guest to give up. */
diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h
index 19a0da0dba41..7615ffcdd555 100644
--- a/include/linux/virtio_console.h
+++ b/include/linux/virtio_console.h
@@ -7,6 +7,17 @@
7/* The ID for virtio console */ 7/* The ID for virtio console */
8#define VIRTIO_ID_CONSOLE 3 8#define VIRTIO_ID_CONSOLE 3
9 9
10/* Feature bits */
11#define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */
12
13struct virtio_console_config {
14 /* colums of the screens */
15 __u16 cols;
16 /* rows of the screens */
17 __u16 rows;
18} __attribute__((packed));
19
20
10#ifdef __KERNEL__ 21#ifdef __KERNEL__
11int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)); 22int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int));
12#endif /* __KERNEL__ */ 23#endif /* __KERNEL__ */
diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
index cdef35742932..cd0fd5d181a6 100644
--- a/include/linux/virtio_pci.h
+++ b/include/linux/virtio_pci.h
@@ -53,4 +53,12 @@
53 53
54/* Virtio ABI version, this must match exactly */ 54/* Virtio ABI version, this must match exactly */
55#define VIRTIO_PCI_ABI_VERSION 0 55#define VIRTIO_PCI_ABI_VERSION 0
56
57/* How many bits to shift physical queue address written to QUEUE_PFN.
58 * 12 is historical, and due to x86 page size. */
59#define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12
60
61/* The alignment to use between consumer and producer parts of vring.
62 * x86 pagesize again. */
63#define VIRTIO_PCI_VRING_ALIGN 4096
56#endif 64#endif
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index c4a598fb3826..71e03722fb59 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -83,7 +83,7 @@ struct vring {
83 * __u16 avail_idx; 83 * __u16 avail_idx;
84 * __u16 available[num]; 84 * __u16 available[num];
85 * 85 *
86 * // Padding to the next page boundary. 86 * // Padding to the next align boundary.
87 * char pad[]; 87 * char pad[];
88 * 88 *
89 * // A ring of used descriptor heads with free-running index. 89 * // A ring of used descriptor heads with free-running index.
@@ -93,19 +93,19 @@ struct vring {
93 * }; 93 * };
94 */ 94 */
95static inline void vring_init(struct vring *vr, unsigned int num, void *p, 95static inline void vring_init(struct vring *vr, unsigned int num, void *p,
96 unsigned long pagesize) 96 unsigned long align)
97{ 97{
98 vr->num = num; 98 vr->num = num;
99 vr->desc = p; 99 vr->desc = p;
100 vr->avail = p + num*sizeof(struct vring_desc); 100 vr->avail = p + num*sizeof(struct vring_desc);
101 vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + pagesize-1) 101 vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1)
102 & ~(pagesize - 1)); 102 & ~(align - 1));
103} 103}
104 104
105static inline unsigned vring_size(unsigned int num, unsigned long pagesize) 105static inline unsigned vring_size(unsigned int num, unsigned long align)
106{ 106{
107 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) 107 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
108 + pagesize - 1) & ~(pagesize - 1)) 108 + align - 1) & ~(align - 1))
109 + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; 109 + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num;
110} 110}
111 111
@@ -115,6 +115,7 @@ struct virtio_device;
115struct virtqueue; 115struct virtqueue;
116 116
117struct virtqueue *vring_new_virtqueue(unsigned int num, 117struct virtqueue *vring_new_virtqueue(unsigned int num,
118 unsigned int vring_align,
118 struct virtio_device *vdev, 119 struct virtio_device *vdev,
119 void *pages, 120 void *pages,
120 void (*notify)(struct virtqueue *vq), 121 void (*notify)(struct virtqueue *vq),
diff --git a/include/media/i2c-addr.h b/include/media/i2c-addr.h
index e7ff44a35ca0..5d0f56054d26 100644
--- a/include/media/i2c-addr.h
+++ b/include/media/i2c-addr.h
@@ -12,8 +12,6 @@
12/* bttv address list */ 12/* bttv address list */
13#define I2C_ADDR_TSA5522 0xc2 13#define I2C_ADDR_TSA5522 0xc2
14#define I2C_ADDR_TDA7432 0x8a 14#define I2C_ADDR_TDA7432 0x8a
15#define I2C_ADDR_BT832_ALT1 0x88
16#define I2C_ADDR_BT832_ALT2 0x8a // alternate setting
17#define I2C_ADDR_TDA8425 0x82 15#define I2C_ADDR_TDA8425 0x82
18#define I2C_ADDR_TDA9840 0x84 16#define I2C_ADDR_TDA9840 0x84
19#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */ 17#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 38f2d93c3957..5bf2ea00678c 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -157,6 +157,8 @@ extern IR_KEYTAB_TYPE ir_codes_avermedia_a16d[IR_KEYTAB_SIZE];
157extern IR_KEYTAB_TYPE ir_codes_encore_enltv_fm53[IR_KEYTAB_SIZE]; 157extern IR_KEYTAB_TYPE ir_codes_encore_enltv_fm53[IR_KEYTAB_SIZE];
158extern IR_KEYTAB_TYPE ir_codes_real_audio_220_32_keys[IR_KEYTAB_SIZE]; 158extern IR_KEYTAB_TYPE ir_codes_real_audio_220_32_keys[IR_KEYTAB_SIZE];
159extern IR_KEYTAB_TYPE ir_codes_msi_tvanywhere_plus[IR_KEYTAB_SIZE]; 159extern IR_KEYTAB_TYPE ir_codes_msi_tvanywhere_plus[IR_KEYTAB_SIZE];
160extern IR_KEYTAB_TYPE ir_codes_ati_tv_wonder_hd_600[IR_KEYTAB_SIZE];
161extern IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE];
160#endif 162#endif
161 163
162/* 164/*
diff --git a/include/media/ov772x.h b/include/media/ov772x.h
new file mode 100644
index 000000000000..e391d55edb95
--- /dev/null
+++ b/include/media/ov772x.h
@@ -0,0 +1,21 @@
1/* ov772x Camera
2 *
3 * Copyright (C) 2008 Renesas Solutions Corp.
4 * Kuninori Morimoto <morimoto.kuninori@renesas.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 __OV772X_H__
12#define __OV772X_H__
13
14#include <media/soc_camera.h>
15
16struct ov772x_camera_info {
17 unsigned long buswidth;
18 struct soc_camera_link link;
19};
20
21#endif /* __OV772X_H__ */
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index 1d104096619c..6bbb0d93bb5f 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -216,8 +216,7 @@ void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data);
216extern struct saa7146_use_ops saa7146_video_uops; 216extern struct saa7146_use_ops saa7146_video_uops;
217int saa7146_start_preview(struct saa7146_fh *fh); 217int saa7146_start_preview(struct saa7146_fh *fh);
218int saa7146_stop_preview(struct saa7146_fh *fh); 218int saa7146_stop_preview(struct saa7146_fh *fh);
219int saa7146_video_do_ioctl(struct inode *inode, struct file *file, 219int saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg);
220 unsigned int cmd, void *arg);
221 220
222/* from saa7146_vbi.c */ 221/* from saa7146_vbi.c */
223extern struct saa7146_use_ops saa7146_vbi_uops; 222extern struct saa7146_use_ops saa7146_vbi_uops;
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index c5de7bb19fda..425b6a98c95c 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -12,9 +12,10 @@
12#ifndef SOC_CAMERA_H 12#ifndef SOC_CAMERA_H
13#define SOC_CAMERA_H 13#define SOC_CAMERA_H
14 14
15#include <linux/mutex.h>
16#include <linux/pm.h>
15#include <linux/videodev2.h> 17#include <linux/videodev2.h>
16#include <media/videobuf-core.h> 18#include <media/videobuf-core.h>
17#include <linux/pm.h>
18 19
19struct soc_camera_device { 20struct soc_camera_device {
20 struct list_head list; 21 struct list_head list;
@@ -36,14 +37,19 @@ struct soc_camera_device {
36 unsigned char iface; /* Host number */ 37 unsigned char iface; /* Host number */
37 unsigned char devnum; /* Device number per host */ 38 unsigned char devnum; /* Device number per host */
38 unsigned char buswidth; /* See comment in .c */ 39 unsigned char buswidth; /* See comment in .c */
40 struct soc_camera_sense *sense; /* See comment in struct definition */
39 struct soc_camera_ops *ops; 41 struct soc_camera_ops *ops;
40 struct video_device *vdev; 42 struct video_device *vdev;
41 const struct soc_camera_data_format *current_fmt; 43 const struct soc_camera_data_format *current_fmt;
42 const struct soc_camera_data_format *formats; 44 const struct soc_camera_data_format *formats;
43 int num_formats; 45 int num_formats;
46 struct soc_camera_format_xlate *user_formats;
47 int num_user_formats;
44 struct module *owner; 48 struct module *owner;
45 /* soc_camera.c private count. Only accessed with video_lock held */ 49 void *host_priv; /* Per-device host private data */
50 /* soc_camera.c private count. Only accessed with .video_lock held */
46 int use_count; 51 int use_count;
52 struct mutex video_lock; /* Protects device data */
47}; 53};
48 54
49struct soc_camera_file { 55struct soc_camera_file {
@@ -56,7 +62,7 @@ struct soc_camera_host {
56 struct device dev; 62 struct device dev;
57 unsigned char nr; /* Host number */ 63 unsigned char nr; /* Host number */
58 void *priv; 64 void *priv;
59 char *drv_name; 65 const char *drv_name;
60 struct soc_camera_host_ops *ops; 66 struct soc_camera_host_ops *ops;
61}; 67};
62 68
@@ -64,25 +70,33 @@ struct soc_camera_host_ops {
64 struct module *owner; 70 struct module *owner;
65 int (*add)(struct soc_camera_device *); 71 int (*add)(struct soc_camera_device *);
66 void (*remove)(struct soc_camera_device *); 72 void (*remove)(struct soc_camera_device *);
67 int (*suspend)(struct soc_camera_device *, pm_message_t state); 73 int (*suspend)(struct soc_camera_device *, pm_message_t);
68 int (*resume)(struct soc_camera_device *); 74 int (*resume)(struct soc_camera_device *);
69 int (*set_fmt_cap)(struct soc_camera_device *, __u32, 75 int (*get_formats)(struct soc_camera_device *, int,
70 struct v4l2_rect *); 76 struct soc_camera_format_xlate *);
71 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *); 77 int (*set_fmt)(struct soc_camera_device *, __u32, struct v4l2_rect *);
78 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
72 void (*init_videobuf)(struct videobuf_queue *, 79 void (*init_videobuf)(struct videobuf_queue *,
73 struct soc_camera_device *); 80 struct soc_camera_device *);
74 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); 81 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *);
75 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); 82 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
76 int (*try_bus_param)(struct soc_camera_device *, __u32);
77 int (*set_bus_param)(struct soc_camera_device *, __u32); 83 int (*set_bus_param)(struct soc_camera_device *, __u32);
78 unsigned int (*poll)(struct file *, poll_table *); 84 unsigned int (*poll)(struct file *, poll_table *);
79}; 85};
80 86
87#define SOCAM_SENSOR_INVERT_PCLK (1 << 0)
88#define SOCAM_SENSOR_INVERT_MCLK (1 << 1)
89#define SOCAM_SENSOR_INVERT_HSYNC (1 << 2)
90#define SOCAM_SENSOR_INVERT_VSYNC (1 << 3)
91#define SOCAM_SENSOR_INVERT_DATA (1 << 4)
92
81struct soc_camera_link { 93struct soc_camera_link {
82 /* Camera bus id, used to match a camera and a bus */ 94 /* Camera bus id, used to match a camera and a bus */
83 int bus_id; 95 int bus_id;
84 /* GPIO number to switch between 8 and 10 bit modes */ 96 /* GPIO number to switch between 8 and 10 bit modes */
85 unsigned int gpio; 97 unsigned int gpio;
98 /* Per camera SOCAM_SENSOR_* bus flags */
99 unsigned long flags;
86 /* Optional callbacks to power on or off and reset the sensor */ 100 /* Optional callbacks to power on or off and reset the sensor */
87 int (*power)(struct device *, int); 101 int (*power)(struct device *, int);
88 int (*reset)(struct device *); 102 int (*reset)(struct device *);
@@ -106,13 +120,35 @@ extern void soc_camera_device_unregister(struct soc_camera_device *icd);
106extern int soc_camera_video_start(struct soc_camera_device *icd); 120extern int soc_camera_video_start(struct soc_camera_device *icd);
107extern void soc_camera_video_stop(struct soc_camera_device *icd); 121extern void soc_camera_video_stop(struct soc_camera_device *icd);
108 122
123extern const struct soc_camera_data_format *soc_camera_format_by_fourcc(
124 struct soc_camera_device *icd, unsigned int fourcc);
125extern const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
126 struct soc_camera_device *icd, unsigned int fourcc);
127
109struct soc_camera_data_format { 128struct soc_camera_data_format {
110 char *name; 129 const char *name;
111 unsigned int depth; 130 unsigned int depth;
112 __u32 fourcc; 131 __u32 fourcc;
113 enum v4l2_colorspace colorspace; 132 enum v4l2_colorspace colorspace;
114}; 133};
115 134
135/**
136 * struct soc_camera_format_xlate - match between host and sensor formats
137 * @cam_fmt: sensor format provided by the sensor
138 * @host_fmt: host format after host translation from cam_fmt
139 * @buswidth: bus width for this format
140 *
141 * Host and sensor translation structure. Used in table of host and sensor
142 * formats matchings in soc_camera_device. A host can override the generic list
143 * generation by implementing get_formats(), and use it for format checks and
144 * format setup.
145 */
146struct soc_camera_format_xlate {
147 const struct soc_camera_data_format *cam_fmt;
148 const struct soc_camera_data_format *host_fmt;
149 unsigned char buswidth;
150};
151
116struct soc_camera_ops { 152struct soc_camera_ops {
117 struct module *owner; 153 struct module *owner;
118 int (*probe)(struct soc_camera_device *); 154 int (*probe)(struct soc_camera_device *);
@@ -123,13 +159,14 @@ struct soc_camera_ops {
123 int (*release)(struct soc_camera_device *); 159 int (*release)(struct soc_camera_device *);
124 int (*start_capture)(struct soc_camera_device *); 160 int (*start_capture)(struct soc_camera_device *);
125 int (*stop_capture)(struct soc_camera_device *); 161 int (*stop_capture)(struct soc_camera_device *);
126 int (*set_fmt_cap)(struct soc_camera_device *, __u32, 162 int (*set_fmt)(struct soc_camera_device *, __u32, struct v4l2_rect *);
127 struct v4l2_rect *); 163 int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *);
128 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
129 unsigned long (*query_bus_param)(struct soc_camera_device *); 164 unsigned long (*query_bus_param)(struct soc_camera_device *);
130 int (*set_bus_param)(struct soc_camera_device *, unsigned long); 165 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
131 int (*get_chip_id)(struct soc_camera_device *, 166 int (*get_chip_id)(struct soc_camera_device *,
132 struct v4l2_chip_ident *); 167 struct v4l2_chip_ident *);
168 int (*set_std)(struct soc_camera_device *, v4l2_std_id *);
169 int (*enum_input)(struct soc_camera_device *, struct v4l2_input *);
133#ifdef CONFIG_VIDEO_ADV_DEBUG 170#ifdef CONFIG_VIDEO_ADV_DEBUG
134 int (*get_register)(struct soc_camera_device *, struct v4l2_register *); 171 int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
135 int (*set_register)(struct soc_camera_device *, struct v4l2_register *); 172 int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
@@ -140,6 +177,32 @@ struct soc_camera_ops {
140 int num_controls; 177 int num_controls;
141}; 178};
142 179
180#define SOCAM_SENSE_PCLK_CHANGED (1 << 0)
181
182/**
183 * This struct can be attached to struct soc_camera_device by the host driver
184 * to request sense from the camera, for example, when calling .set_fmt(). The
185 * host then can check which flags are set and verify respective values if any.
186 * For example, if SOCAM_SENSE_PCLK_CHANGED is set, it means, pixclock has
187 * changed during this operation. After completion the host should detach sense.
188 *
189 * @flags ored SOCAM_SENSE_* flags
190 * @master_clock if the host wants to be informed about pixel-clock
191 * change, it better set master_clock.
192 * @pixel_clock_max maximum pixel clock frequency supported by the host,
193 * camera is not allowed to exceed this.
194 * @pixel_clock if the camera driver changed pixel clock during this
195 * operation, it sets SOCAM_SENSE_PCLK_CHANGED, uses
196 * master_clock to calculate the new pixel-clock and
197 * sets this field.
198 */
199struct soc_camera_sense {
200 unsigned long flags;
201 unsigned long master_clock;
202 unsigned long pixel_clock_max;
203 unsigned long pixel_clock;
204};
205
143static inline struct v4l2_queryctrl const *soc_camera_find_qctrl( 206static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
144 struct soc_camera_ops *ops, int id) 207 struct soc_camera_ops *ops, int id)
145{ 208{
@@ -158,15 +221,20 @@ static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
158#define SOCAM_HSYNC_ACTIVE_LOW (1 << 3) 221#define SOCAM_HSYNC_ACTIVE_LOW (1 << 3)
159#define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4) 222#define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4)
160#define SOCAM_VSYNC_ACTIVE_LOW (1 << 5) 223#define SOCAM_VSYNC_ACTIVE_LOW (1 << 5)
161#define SOCAM_DATAWIDTH_8 (1 << 6) 224#define SOCAM_DATAWIDTH_4 (1 << 6)
162#define SOCAM_DATAWIDTH_9 (1 << 7) 225#define SOCAM_DATAWIDTH_8 (1 << 7)
163#define SOCAM_DATAWIDTH_10 (1 << 8) 226#define SOCAM_DATAWIDTH_9 (1 << 8)
164#define SOCAM_DATAWIDTH_16 (1 << 9) 227#define SOCAM_DATAWIDTH_10 (1 << 9)
165#define SOCAM_PCLK_SAMPLE_RISING (1 << 10) 228#define SOCAM_DATAWIDTH_15 (1 << 10)
166#define SOCAM_PCLK_SAMPLE_FALLING (1 << 11) 229#define SOCAM_DATAWIDTH_16 (1 << 11)
230#define SOCAM_PCLK_SAMPLE_RISING (1 << 12)
231#define SOCAM_PCLK_SAMPLE_FALLING (1 << 13)
232#define SOCAM_DATA_ACTIVE_HIGH (1 << 14)
233#define SOCAM_DATA_ACTIVE_LOW (1 << 15)
167 234
168#define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_9 | \ 235#define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_4 | SOCAM_DATAWIDTH_8 | \
169 SOCAM_DATAWIDTH_10 | SOCAM_DATAWIDTH_16) 236 SOCAM_DATAWIDTH_9 | SOCAM_DATAWIDTH_10 | \
237 SOCAM_DATAWIDTH_15 | SOCAM_DATAWIDTH_16)
170 238
171static inline unsigned long soc_camera_bus_param_compatible( 239static inline unsigned long soc_camera_bus_param_compatible(
172 unsigned long camera_flags, unsigned long bus_flags) 240 unsigned long camera_flags, unsigned long bus_flags)
@@ -182,4 +250,7 @@ static inline unsigned long soc_camera_bus_param_compatible(
182 return (!hsync || !vsync || !pclk) ? 0 : common_flags; 250 return (!hsync || !vsync || !pclk) ? 0 : common_flags;
183} 251}
184 252
253extern unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl,
254 unsigned long flags);
255
185#endif 256#endif
diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
new file mode 100644
index 000000000000..5e7ee968c6dc
--- /dev/null
+++ b/include/media/tvp514x.h
@@ -0,0 +1,118 @@
1/*
2 * drivers/media/video/tvp514x.h
3 *
4 * Copyright (C) 2008 Texas Instruments Inc
5 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
6 *
7 * Contributors:
8 * Sivaraj R <sivaraj@ti.com>
9 * Brijesh R Jadav <brijesh.j@ti.com>
10 * Hardik Shah <hardik.shah@ti.com>
11 * Manjunath Hadli <mrh@ti.com>
12 * Karicheri Muralidharan <m-karicheri2@ti.com>
13 *
14 * This package is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29#ifndef _TVP514X_H
30#define _TVP514X_H
31
32/*
33 * Other macros
34 */
35#define TVP514X_MODULE_NAME "tvp514x"
36
37#define TVP514X_XCLK_BT656 (27000000)
38
39/* Number of pixels and number of lines per frame for different standards */
40#define NTSC_NUM_ACTIVE_PIXELS (720)
41#define NTSC_NUM_ACTIVE_LINES (480)
42#define PAL_NUM_ACTIVE_PIXELS (720)
43#define PAL_NUM_ACTIVE_LINES (576)
44
45/**
46 * enum tvp514x_input - enum for different decoder input pin
47 * configuration.
48 */
49enum tvp514x_input {
50 /*
51 * CVBS input selection
52 */
53 INPUT_CVBS_VI1A = 0x0,
54 INPUT_CVBS_VI1B,
55 INPUT_CVBS_VI1C,
56 INPUT_CVBS_VI2A = 0x04,
57 INPUT_CVBS_VI2B,
58 INPUT_CVBS_VI2C,
59 INPUT_CVBS_VI3A = 0x08,
60 INPUT_CVBS_VI3B,
61 INPUT_CVBS_VI3C,
62 INPUT_CVBS_VI4A = 0x0C,
63 /*
64 * S-Video input selection
65 */
66 INPUT_SVIDEO_VI2A_VI1A = 0x44,
67 INPUT_SVIDEO_VI2B_VI1B,
68 INPUT_SVIDEO_VI2C_VI1C,
69 INPUT_SVIDEO_VI2A_VI3A = 0x54,
70 INPUT_SVIDEO_VI2B_VI3B,
71 INPUT_SVIDEO_VI2C_VI3C,
72 INPUT_SVIDEO_VI4A_VI1A = 0x4C,
73 INPUT_SVIDEO_VI4A_VI1B,
74 INPUT_SVIDEO_VI4A_VI1C,
75 INPUT_SVIDEO_VI4A_VI3A = 0x5C,
76 INPUT_SVIDEO_VI4A_VI3B,
77 INPUT_SVIDEO_VI4A_VI3C,
78
79 /* Need to add entries for
80 * RGB, YPbPr and SCART.
81 */
82 INPUT_INVALID
83};
84
85/**
86 * enum tvp514x_output - enum for output format
87 * supported.
88 *
89 */
90enum tvp514x_output {
91 OUTPUT_10BIT_422_EMBEDDED_SYNC = 0,
92 OUTPUT_20BIT_422_SEPERATE_SYNC,
93 OUTPUT_10BIT_422_SEPERATE_SYNC = 3,
94 OUTPUT_INVALID
95};
96
97/**
98 * struct tvp514x_platform_data - Platform data values and access functions.
99 * @power_set: Power state access function, zero is off, non-zero is on.
100 * @ifparm: Interface parameters access function.
101 * @priv_data_set: Device private data (pointer) access function.
102 * @clk_polarity: Clock polarity of the current interface.
103 * @ hs_polarity: HSYNC Polarity configuration for current interface.
104 * @ vs_polarity: VSYNC Polarity configuration for current interface.
105 */
106struct tvp514x_platform_data {
107 char *master;
108 int (*power_set) (enum v4l2_power on);
109 int (*ifparm) (struct v4l2_ifparm *p);
110 int (*priv_data_set) (void *);
111 /* Interface control params */
112 bool clk_polarity;
113 bool hs_polarity;
114 bool vs_polarity;
115};
116
117
118#endif /* ifndef _TVP514X_H */
diff --git a/include/media/tw9910.h b/include/media/tw9910.h
new file mode 100644
index 000000000000..73231e7880d8
--- /dev/null
+++ b/include/media/tw9910.h
@@ -0,0 +1,39 @@
1/*
2 * tw9910 Driver header
3 *
4 * Copyright (C) 2008 Renesas Solutions Corp.
5 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
6 *
7 * Based on ov772x.h
8 *
9 * Copyright (C) Kuninori Morimoto <morimoto.kuninori@renesas.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#ifndef __TW9910_H__
17#define __TW9910_H__
18
19#include <media/soc_camera.h>
20
21enum tw9910_mpout_pin {
22 TW9910_MPO_VLOSS,
23 TW9910_MPO_HLOCK,
24 TW9910_MPO_SLOCK,
25 TW9910_MPO_VLOCK,
26 TW9910_MPO_MONO,
27 TW9910_MPO_DET50,
28 TW9910_MPO_FIELD,
29 TW9910_MPO_RTCO,
30};
31
32struct tw9910_video_info {
33 unsigned long buswidth;
34 enum tw9910_mpout_pin mpout;
35 struct soc_camera_link link;
36};
37
38
39#endif /* __TW9910_H__ */
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index d73a8e9028a5..43dbb659f1f5 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -60,6 +60,8 @@ enum {
60 60
61 /* OmniVision sensors: reserved range 250-299 */ 61 /* OmniVision sensors: reserved range 250-299 */
62 V4L2_IDENT_OV7670 = 250, 62 V4L2_IDENT_OV7670 = 250,
63 V4L2_IDENT_OV7720 = 251,
64 V4L2_IDENT_OV7725 = 252,
63 65
64 /* Conexant MPEG encoder/decoders: reserved range 410-420 */ 66 /* Conexant MPEG encoder/decoders: reserved range 410-420 */
65 V4L2_IDENT_CX23415 = 415, 67 V4L2_IDENT_CX23415 = 415,
@@ -69,6 +71,9 @@ enum {
69 /* module vp27smpx: just ident 2700 */ 71 /* module vp27smpx: just ident 2700 */
70 V4L2_IDENT_VP27SMPX = 2700, 72 V4L2_IDENT_VP27SMPX = 2700,
71 73
74 /* module tvp5150 */
75 V4L2_IDENT_TVP5150 = 5150,
76
72 /* module cs5345: just ident 5345 */ 77 /* module cs5345: just ident 5345 */
73 V4L2_IDENT_CS5345 = 5345, 78 V4L2_IDENT_CS5345 = 5345,
74 79
@@ -82,6 +87,9 @@ enum {
82 /* module wm8775: just ident 8775 */ 87 /* module wm8775: just ident 8775 */
83 V4L2_IDENT_WM8775 = 8775, 88 V4L2_IDENT_WM8775 = 8775,
84 89
90 /* module tw9910: just ident 9910 */
91 V4L2_IDENT_TW9910 = 9910,
92
85 /* module cs53132a: just ident 53132 */ 93 /* module cs53132a: just ident 53132 */
86 V4L2_IDENT_CS53l32A = 53132, 94 V4L2_IDENT_CS53l32A = 53132,
87 95
@@ -166,8 +174,10 @@ enum {
166 V4L2_IDENT_MT9M001C12ST = 45000, 174 V4L2_IDENT_MT9M001C12ST = 45000,
167 V4L2_IDENT_MT9M001C12STM = 45005, 175 V4L2_IDENT_MT9M001C12STM = 45005,
168 V4L2_IDENT_MT9M111 = 45007, 176 V4L2_IDENT_MT9M111 = 45007,
177 V4L2_IDENT_MT9M112 = 45008,
169 V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */ 178 V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */
170 V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */ 179 V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */
180 V4L2_IDENT_MT9T031 = 45020,
171}; 181};
172 182
173#endif 183#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 2f8719abf5cb..f99c866d8c37 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -57,6 +57,29 @@
57 57
58/* ------------------------------------------------------------------------- */ 58/* ------------------------------------------------------------------------- */
59 59
60/* These printk constructs can be used with v4l2_device and v4l2_subdev */
61#define v4l2_printk(level, dev, fmt, arg...) \
62 printk(level "%s: " fmt, (dev)->name , ## arg)
63
64#define v4l2_err(dev, fmt, arg...) \
65 v4l2_printk(KERN_ERR, dev, fmt , ## arg)
66
67#define v4l2_warn(dev, fmt, arg...) \
68 v4l2_printk(KERN_WARNING, dev, fmt , ## arg)
69
70#define v4l2_info(dev, fmt, arg...) \
71 v4l2_printk(KERN_INFO, dev, fmt , ## arg)
72
73/* These three macros assume that the debug level is set with a module
74 parameter called 'debug'. */
75#define v4l2_dbg(level, debug, dev, fmt, arg...) \
76 do { \
77 if (debug >= (level)) \
78 v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \
79 } while (0)
80
81/* ------------------------------------------------------------------------- */
82
60/* Priority helper functions */ 83/* Priority helper functions */
61 84
62struct v4l2_prio_state { 85struct v4l2_prio_state {
@@ -104,11 +127,29 @@ struct i2c_driver;
104struct i2c_adapter; 127struct i2c_adapter;
105struct i2c_client; 128struct i2c_client;
106struct i2c_device_id; 129struct i2c_device_id;
130struct v4l2_device;
131struct v4l2_subdev;
132struct v4l2_subdev_ops;
107 133
108int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, 134int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
109 const char *name, 135 const char *name,
110 int (*probe)(struct i2c_client *, const struct i2c_device_id *)); 136 int (*probe)(struct i2c_client *, const struct i2c_device_id *));
111 137
138/* Load an i2c module and return an initialized v4l2_subdev struct.
139 Only call request_module if module_name != NULL.
140 The client_type argument is the name of the chip that's on the adapter. */
141struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
142 const char *module_name, const char *client_type, u8 addr);
143/* Probe and load an i2c module and return an initialized v4l2_subdev struct.
144 Only call request_module if module_name != NULL.
145 The client_type argument is the name of the chip that's on the adapter. */
146struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
147 const char *module_name, const char *client_type,
148 const unsigned short *addrs);
149/* Initialize an v4l2_subdev with data from an i2c_client struct */
150void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
151 const struct v4l2_subdev_ops *ops);
152
112/* ------------------------------------------------------------------------- */ 153/* ------------------------------------------------------------------------- */
113 154
114/* Internal ioctls */ 155/* Internal ioctls */
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index a0a6b41c5e09..0a88d1d17d30 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -25,6 +25,12 @@
25#define VFL_TYPE_MAX 4 25#define VFL_TYPE_MAX 4
26 26
27struct v4l2_ioctl_callbacks; 27struct v4l2_ioctl_callbacks;
28struct v4l2_device;
29
30/* Flag to mark the video_device struct as unregistered.
31 Drivers can set this flag if they want to block all future
32 device access. It is set by video_unregister_device. */
33#define V4L2_FL_UNREGISTERED (0)
28 34
29/* 35/*
30 * Newer version of video_device, handled by videodev2.c 36 * Newer version of video_device, handled by videodev2.c
@@ -39,15 +45,20 @@ struct video_device
39 45
40 /* sysfs */ 46 /* sysfs */
41 struct device dev; /* v4l device */ 47 struct device dev; /* v4l device */
42 struct cdev cdev; /* character device */ 48 struct cdev *cdev; /* character device */
43 void (*cdev_release)(struct kobject *kobj); 49
50 /* Set either parent or v4l2_dev if your driver uses v4l2_device */
44 struct device *parent; /* device parent */ 51 struct device *parent; /* device parent */
52 struct v4l2_device *v4l2_dev; /* v4l2_device parent */
45 53
46 /* device info */ 54 /* device info */
47 char name[32]; 55 char name[32];
48 int vfl_type; 56 int vfl_type;
57 /* 'minor' is set to -1 if the registration failed */
49 int minor; 58 int minor;
50 u16 num; 59 u16 num;
60 /* use bitops to set/clear/test flags */
61 unsigned long flags;
51 /* attribute to differentiate multiple indices on one physical device */ 62 /* attribute to differentiate multiple indices on one physical device */
52 int index; 63 int index;
53 64
@@ -58,7 +69,7 @@ struct video_device
58 v4l2_std_id current_norm; /* Current tvnorm */ 69 v4l2_std_id current_norm; /* Current tvnorm */
59 70
60 /* callbacks */ 71 /* callbacks */
61 void (*release)(struct video_device *vfd); 72 void (*release)(struct video_device *vdev);
62 73
63 /* ioctl callbacks */ 74 /* ioctl callbacks */
64 const struct v4l2_ioctl_ops *ioctl_ops; 75 const struct v4l2_ioctl_ops *ioctl_ops;
@@ -67,36 +78,41 @@ struct video_device
67/* dev to video-device */ 78/* dev to video-device */
68#define to_video_device(cd) container_of(cd, struct video_device, dev) 79#define to_video_device(cd) container_of(cd, struct video_device, dev)
69 80
70/* Register and unregister devices. Note that if video_register_device fails, 81/* Register video devices. Note that if video_register_device fails,
71 the release() callback of the video_device structure is *not* called, so 82 the release() callback of the video_device structure is *not* called, so
72 the caller is responsible for freeing any data. Usually that means that 83 the caller is responsible for freeing any data. Usually that means that
73 you call video_device_release() on failure. */ 84 you call video_device_release() on failure.
74int __must_check video_register_device(struct video_device *vfd, int type, int nr); 85
75int __must_check video_register_device_index(struct video_device *vfd, 86 Also note that vdev->minor is set to -1 if the registration failed. */
87int __must_check video_register_device(struct video_device *vdev, int type, int nr);
88int __must_check video_register_device_index(struct video_device *vdev,
76 int type, int nr, int index); 89 int type, int nr, int index);
77void video_unregister_device(struct video_device *vfd); 90
91/* Unregister video devices. Will do nothing if vdev == NULL or
92 vdev->minor < 0. */
93void video_unregister_device(struct video_device *vdev);
78 94
79/* helper functions to alloc/release struct video_device, the 95/* helper functions to alloc/release struct video_device, the
80 latter can also be used for video_device->release(). */ 96 latter can also be used for video_device->release(). */
81struct video_device * __must_check video_device_alloc(void); 97struct video_device * __must_check video_device_alloc(void);
82 98
83/* this release function frees the vfd pointer */ 99/* this release function frees the vdev pointer */
84void video_device_release(struct video_device *vfd); 100void video_device_release(struct video_device *vdev);
85 101
86/* this release function does nothing, use when the video_device is a 102/* this release function does nothing, use when the video_device is a
87 static global struct. Note that having a static video_device is 103 static global struct. Note that having a static video_device is
88 a dubious construction at best. */ 104 a dubious construction at best. */
89void video_device_release_empty(struct video_device *vfd); 105void video_device_release_empty(struct video_device *vdev);
90 106
91/* helper functions to access driver private data. */ 107/* helper functions to access driver private data. */
92static inline void *video_get_drvdata(struct video_device *dev) 108static inline void *video_get_drvdata(struct video_device *vdev)
93{ 109{
94 return dev_get_drvdata(&dev->dev); 110 return dev_get_drvdata(&vdev->dev);
95} 111}
96 112
97static inline void video_set_drvdata(struct video_device *dev, void *data) 113static inline void video_set_drvdata(struct video_device *vdev, void *data)
98{ 114{
99 dev_set_drvdata(&dev->dev, data); 115 dev_set_drvdata(&vdev->dev, data);
100} 116}
101 117
102struct video_device *video_devdata(struct file *file); 118struct video_device *video_devdata(struct file *file);
@@ -108,4 +124,9 @@ static inline void *video_drvdata(struct file *file)
108 return video_get_drvdata(video_devdata(file)); 124 return video_get_drvdata(video_devdata(file));
109} 125}
110 126
127static inline int video_is_unregistered(struct video_device *vdev)
128{
129 return test_bit(V4L2_FL_UNREGISTERED, &vdev->flags);
130}
131
111#endif /* _V4L2_DEV_H */ 132#endif /* _V4L2_DEV_H */
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
new file mode 100644
index 000000000000..97b283a04289
--- /dev/null
+++ b/include/media/v4l2-device.h
@@ -0,0 +1,109 @@
1/*
2 V4L2 device support header.
3
4 Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl>
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 _V4L2_DEVICE_H
22#define _V4L2_DEVICE_H
23
24#include <media/v4l2-subdev.h>
25
26/* Each instance of a V4L2 device should create the v4l2_device struct,
27 either stand-alone or embedded in a larger struct.
28
29 It allows easy access to sub-devices (see v4l2-subdev.h) and provides
30 basic V4L2 device-level support.
31 */
32
33#define V4L2_DEVICE_NAME_SIZE (BUS_ID_SIZE + 16)
34
35struct v4l2_device {
36 /* dev->driver_data points to this struct */
37 struct device *dev;
38 /* used to keep track of the registered subdevs */
39 struct list_head subdevs;
40 /* lock this struct; can be used by the driver as well if this
41 struct is embedded into a larger struct. */
42 spinlock_t lock;
43 /* unique device name, by default the driver name + bus ID */
44 char name[V4L2_DEVICE_NAME_SIZE];
45};
46
47/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev */
48int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev);
49/* Set v4l2_dev->dev->driver_data to NULL and unregister all sub-devices */
50void v4l2_device_unregister(struct v4l2_device *v4l2_dev);
51
52/* Register a subdev with a v4l2 device. While registered the subdev module
53 is marked as in-use. An error is returned if the module is no longer
54 loaded when you attempt to register it. */
55int __must_check v4l2_device_register_subdev(struct v4l2_device *dev, struct v4l2_subdev *sd);
56/* Unregister a subdev with a v4l2 device. Can also be called if the subdev
57 wasn't registered. In that case it will do nothing. */
58void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
59
60/* Iterate over all subdevs. */
61#define v4l2_device_for_each_subdev(sd, dev) \
62 list_for_each_entry(sd, &(dev)->subdevs, list)
63
64/* Call the specified callback for all subdevs matching the condition.
65 Ignore any errors. Note that you cannot add or delete a subdev
66 while walking the subdevs list. */
67#define __v4l2_device_call_subdevs(dev, cond, o, f, args...) \
68 do { \
69 struct v4l2_subdev *sd; \
70 \
71 list_for_each_entry(sd, &(dev)->subdevs, list) \
72 if ((cond) && sd->ops->o && sd->ops->o->f) \
73 sd->ops->o->f(sd , ##args); \
74 } while (0)
75
76/* Call the specified callback for all subdevs matching the condition.
77 If the callback returns an error other than 0 or -ENOIOCTLCMD, then
78 return with that error code. Note that you cannot add or delete a
79 subdev while walking the subdevs list. */
80#define __v4l2_device_call_subdevs_until_err(dev, cond, o, f, args...) \
81({ \
82 struct v4l2_subdev *sd; \
83 int err = 0; \
84 \
85 list_for_each_entry(sd, &(dev)->subdevs, list) { \
86 if ((cond) && sd->ops->o && sd->ops->o->f) \
87 err = sd->ops->o->f(sd , ##args); \
88 if (err && err != -ENOIOCTLCMD) \
89 break; \
90 } \
91 (err == -ENOIOCTLCMD) ? 0 : err; \
92})
93
94/* Call the specified callback for all subdevs matching grp_id (if 0, then
95 match them all). Ignore any errors. Note that you cannot add or delete
96 a subdev while walking the subdevs list. */
97#define v4l2_device_call_all(dev, grp_id, o, f, args...) \
98 __v4l2_device_call_subdevs(dev, \
99 !(grp_id) || sd->grp_id == (grp_id), o, f , ##args)
100
101/* Call the specified callback for all subdevs matching grp_id (if 0, then
102 match them all). If the callback returns an error other than 0 or
103 -ENOIOCTLCMD, then return with that error code. Note that you cannot
104 add or delete a subdev while walking the subdevs list. */
105#define v4l2_device_call_until_err(dev, grp_id, o, f, args...) \
106 __v4l2_device_call_subdevs_until_err(dev, \
107 !(grp_id) || sd->grp_id == (grp_id), o, f , ##args)
108
109#endif
diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h
index 9c2df41dbf92..ecda3c725837 100644
--- a/include/media/v4l2-int-device.h
+++ b/include/media/v4l2-int-device.h
@@ -183,6 +183,9 @@ enum v4l2_int_ioctl_num {
183 vidioc_int_s_crop_num, 183 vidioc_int_s_crop_num,
184 vidioc_int_g_parm_num, 184 vidioc_int_g_parm_num,
185 vidioc_int_s_parm_num, 185 vidioc_int_s_parm_num,
186 vidioc_int_querystd_num,
187 vidioc_int_s_std_num,
188 vidioc_int_s_video_routing_num,
186 189
187 /* 190 /*
188 * 191 *
@@ -284,6 +287,9 @@ V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *);
284V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *); 287V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *);
285V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *); 288V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
286V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *); 289V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
290V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *);
291V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *);
292V4L2_INT_WRAPPER_1(s_video_routing, struct v4l2_routing, *);
287 293
288V4L2_INT_WRAPPER_0(dev_init); 294V4L2_INT_WRAPPER_0(dev_init);
289V4L2_INT_WRAPPER_0(dev_exit); 295V4L2_INT_WRAPPER_0(dev_exit);
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index e6ba25b3d7c8..fcdb58c4ce07 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -232,6 +232,12 @@ struct v4l2_ioctl_ops {
232 int (*vidioc_g_chip_ident) (struct file *file, void *fh, 232 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
233 struct v4l2_chip_ident *chip); 233 struct v4l2_chip_ident *chip);
234 234
235 int (*vidioc_enum_framesizes) (struct file *file, void *fh,
236 struct v4l2_frmsizeenum *fsize);
237
238 int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
239 struct v4l2_frmivalenum *fival);
240
235 /* For other private ioctls */ 241 /* For other private ioctls */
236 int (*vidioc_default) (struct file *file, void *fh, 242 int (*vidioc_default) (struct file *file, void *fh,
237 int cmd, void *arg); 243 int cmd, void *arg);
@@ -285,15 +291,13 @@ extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
285 unsigned long arg); 291 unsigned long arg);
286 292
287/* Include support for obsoleted stuff */ 293/* Include support for obsoleted stuff */
288extern int video_usercopy(struct inode *inode, struct file *file, 294extern int video_usercopy(struct file *file, unsigned int cmd,
289 unsigned int cmd, unsigned long arg, 295 unsigned long arg, v4l2_kioctl func);
290 int (*func)(struct inode *inode, struct file *file,
291 unsigned int cmd, void *arg));
292 296
293/* Standard handlers for V4L ioctl's */ 297/* Standard handlers for V4L ioctl's */
294 298
295/* This prototype is used on fops.unlocked_ioctl */ 299/* This prototype is used on fops.unlocked_ioctl */
296extern int __video_ioctl2(struct file *file, 300extern long __video_ioctl2(struct file *file,
297 unsigned int cmd, unsigned long arg); 301 unsigned int cmd, unsigned long arg);
298 302
299/* This prototype is used on fops.ioctl 303/* This prototype is used on fops.ioctl
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
new file mode 100644
index 000000000000..ceef016bb0b7
--- /dev/null
+++ b/include/media/v4l2-subdev.h
@@ -0,0 +1,189 @@
1/*
2 V4L2 sub-device support header.
3
4 Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl>
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 _V4L2_SUBDEV_H
22#define _V4L2_SUBDEV_H
23
24#include <media/v4l2-common.h>
25
26struct v4l2_device;
27struct v4l2_subdev;
28struct tuner_setup;
29
30/* Sub-devices are devices that are connected somehow to the main bridge
31 device. These devices are usually audio/video muxers/encoders/decoders or
32 sensors and webcam controllers.
33
34 Usually these devices are controlled through an i2c bus, but other busses
35 may also be used.
36
37 The v4l2_subdev struct provides a way of accessing these devices in a
38 generic manner. Most operations that these sub-devices support fall in
39 a few categories: core ops, audio ops, video ops and tuner ops.
40
41 More categories can be added if needed, although this should remain a
42 limited set (no more than approx. 8 categories).
43
44 Each category has its own set of ops that subdev drivers can implement.
45
46 A subdev driver can leave the pointer to the category ops NULL if
47 it does not implement them (e.g. an audio subdev will generally not
48 implement the video category ops). The exception is the core category:
49 this must always be present.
50
51 These ops are all used internally so it is no problem to change, remove
52 or add ops or move ops from one to another category. Currently these
53 ops are based on the original ioctls, but since ops are not limited to
54 one argument there is room for improvement here once all i2c subdev
55 drivers are converted to use these ops.
56 */
57
58/* Core ops: it is highly recommended to implement at least these ops:
59
60 g_chip_ident
61 log_status
62 g_register
63 s_register
64
65 This provides basic debugging support.
66
67 The ioctl ops is meant for generic ioctl-like commands. Depending on
68 the use-case it might be better to use subdev-specific ops (currently
69 not yet implemented) since ops provide proper type-checking.
70 */
71struct v4l2_subdev_core_ops {
72 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip);
73 int (*log_status)(struct v4l2_subdev *sd);
74 int (*init)(struct v4l2_subdev *sd, u32 val);
75 int (*s_standby)(struct v4l2_subdev *sd, u32 standby);
76 int (*reset)(struct v4l2_subdev *sd, u32 val);
77 int (*s_gpio)(struct v4l2_subdev *sd, u32 val);
78 int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
79 int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
80 int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
81 int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
82 int (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
83#ifdef CONFIG_VIDEO_ADV_DEBUG
84 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_register *reg);
85 int (*s_register)(struct v4l2_subdev *sd, struct v4l2_register *reg);
86#endif
87};
88
89struct v4l2_subdev_tuner_ops {
90 int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
91 int (*s_radio)(struct v4l2_subdev *sd);
92 int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
93 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
94 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
95 int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
96 int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
97 int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type);
98 int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
99};
100
101struct v4l2_subdev_audio_ops {
102 int (*s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
103 int (*s_i2s_clock_freq)(struct v4l2_subdev *sd, u32 freq);
104 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route);
105};
106
107struct v4l2_subdev_video_ops {
108 int (*s_routing)(struct v4l2_subdev *sd, const struct v4l2_routing *route);
109 int (*s_crystal_freq)(struct v4l2_subdev *sd, struct v4l2_crystal_freq *freq);
110 int (*decode_vbi_line)(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi_line);
111 int (*s_vbi_data)(struct v4l2_subdev *sd, const struct v4l2_sliced_vbi_data *vbi_data);
112 int (*g_vbi_data)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_data *vbi_data);
113 int (*g_sliced_vbi_cap)(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_cap *cap);
114 int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std);
115 int (*s_stream)(struct v4l2_subdev *sd, int enable);
116 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
117 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
118};
119
120struct v4l2_subdev_ops {
121 const struct v4l2_subdev_core_ops *core;
122 const struct v4l2_subdev_tuner_ops *tuner;
123 const struct v4l2_subdev_audio_ops *audio;
124 const struct v4l2_subdev_video_ops *video;
125};
126
127#define V4L2_SUBDEV_NAME_SIZE 32
128
129/* Each instance of a subdev driver should create this struct, either
130 stand-alone or embedded in a larger struct.
131 */
132struct v4l2_subdev {
133 struct list_head list;
134 struct module *owner;
135 struct v4l2_device *dev;
136 const struct v4l2_subdev_ops *ops;
137 /* name must be unique */
138 char name[V4L2_SUBDEV_NAME_SIZE];
139 /* can be used to group similar subdevs, value is driver-specific */
140 u32 grp_id;
141 /* pointer to private data */
142 void *priv;
143};
144
145static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p)
146{
147 sd->priv = p;
148}
149
150static inline void *v4l2_get_subdevdata(const struct v4l2_subdev *sd)
151{
152 return sd->priv;
153}
154
155/* Convert an ioctl-type command to the proper v4l2_subdev_ops function call.
156 This is used by subdev modules that can be called by both old-style ioctl
157 commands and through the v4l2_subdev_ops.
158
159 The ioctl API of the subdev driver can call this function to call the
160 right ops based on the ioctl cmd and arg.
161
162 Once all subdev drivers have been converted and all drivers no longer
163 use the ioctl interface, then this function can be removed.
164 */
165int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg);
166
167static inline void v4l2_subdev_init(struct v4l2_subdev *sd,
168 const struct v4l2_subdev_ops *ops)
169{
170 INIT_LIST_HEAD(&sd->list);
171 /* ops->core MUST be set */
172 BUG_ON(!ops || !ops->core);
173 sd->ops = ops;
174 sd->dev = NULL;
175 sd->name[0] = '\0';
176 sd->grp_id = 0;
177 sd->priv = NULL;
178}
179
180/* Call an ops of a v4l2_subdev, doing the right checks against
181 NULL pointers.
182
183 Example: err = v4l2_subdev_call(sd, core, g_chip_ident, &chip);
184 */
185#define v4l2_subdev_call(sd, o, f, args...) \
186 (!(sd) ? -ENODEV : (((sd) && (sd)->ops->o && (sd)->ops->o->f) ? \
187 (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD))
188
189#endif
diff --git a/include/scsi/fc/fc_els.h b/include/scsi/fc/fc_els.h
new file mode 100644
index 000000000000..195ca014d3ce
--- /dev/null
+++ b/include/scsi/fc/fc_els.h
@@ -0,0 +1,816 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_ELS_H_
21#define _FC_ELS_H_
22
23/*
24 * Fibre Channel Switch - Enhanced Link Services definitions.
25 * From T11 FC-LS Rev 1.2 June 7, 2005.
26 */
27
28/*
29 * ELS Command codes - byte 0 of the frame payload
30 */
31enum fc_els_cmd {
32 ELS_LS_RJT = 0x01, /* ESL reject */
33 ELS_LS_ACC = 0x02, /* ESL Accept */
34 ELS_PLOGI = 0x03, /* N_Port login */
35 ELS_FLOGI = 0x04, /* F_Port login */
36 ELS_LOGO = 0x05, /* Logout */
37 ELS_ABTX = 0x06, /* Abort exchange - obsolete */
38 ELS_RCS = 0x07, /* read connection status */
39 ELS_RES = 0x08, /* read exchange status block */
40 ELS_RSS = 0x09, /* read sequence status block */
41 ELS_RSI = 0x0a, /* read sequence initiative */
42 ELS_ESTS = 0x0b, /* establish streaming */
43 ELS_ESTC = 0x0c, /* estimate credit */
44 ELS_ADVC = 0x0d, /* advise credit */
45 ELS_RTV = 0x0e, /* read timeout value */
46 ELS_RLS = 0x0f, /* read link error status block */
47 ELS_ECHO = 0x10, /* echo */
48 ELS_TEST = 0x11, /* test */
49 ELS_RRQ = 0x12, /* reinstate recovery qualifier */
50 ELS_REC = 0x13, /* read exchange concise */
51 ELS_SRR = 0x14, /* sequence retransmission request */
52 ELS_PRLI = 0x20, /* process login */
53 ELS_PRLO = 0x21, /* process logout */
54 ELS_SCN = 0x22, /* state change notification */
55 ELS_TPLS = 0x23, /* test process login state */
56 ELS_TPRLO = 0x24, /* third party process logout */
57 ELS_LCLM = 0x25, /* login control list mgmt (obs) */
58 ELS_GAID = 0x30, /* get alias_ID */
59 ELS_FACT = 0x31, /* fabric activate alias_id */
60 ELS_FDACDT = 0x32, /* fabric deactivate alias_id */
61 ELS_NACT = 0x33, /* N-port activate alias_id */
62 ELS_NDACT = 0x34, /* N-port deactivate alias_id */
63 ELS_QOSR = 0x40, /* quality of service request */
64 ELS_RVCS = 0x41, /* read virtual circuit status */
65 ELS_PDISC = 0x50, /* discover N_port service params */
66 ELS_FDISC = 0x51, /* discover F_port service params */
67 ELS_ADISC = 0x52, /* discover address */
68 ELS_RNC = 0x53, /* report node cap (obs) */
69 ELS_FARP_REQ = 0x54, /* FC ARP request */
70 ELS_FARP_REPL = 0x55, /* FC ARP reply */
71 ELS_RPS = 0x56, /* read port status block */
72 ELS_RPL = 0x57, /* read port list */
73 ELS_RPBC = 0x58, /* read port buffer condition */
74 ELS_FAN = 0x60, /* fabric address notification */
75 ELS_RSCN = 0x61, /* registered state change notification */
76 ELS_SCR = 0x62, /* state change registration */
77 ELS_RNFT = 0x63, /* report node FC-4 types */
78 ELS_CSR = 0x68, /* clock synch. request */
79 ELS_CSU = 0x69, /* clock synch. update */
80 ELS_LINIT = 0x70, /* loop initialize */
81 ELS_LSTS = 0x72, /* loop status */
82 ELS_RNID = 0x78, /* request node ID data */
83 ELS_RLIR = 0x79, /* registered link incident report */
84 ELS_LIRR = 0x7a, /* link incident record registration */
85 ELS_SRL = 0x7b, /* scan remote loop */
86 ELS_SBRP = 0x7c, /* set bit-error reporting params */
87 ELS_RPSC = 0x7d, /* report speed capabilities */
88 ELS_QSA = 0x7e, /* query security attributes */
89 ELS_EVFP = 0x7f, /* exchange virt. fabrics params */
90 ELS_LKA = 0x80, /* link keep-alive */
91 ELS_AUTH_ELS = 0x90, /* authentication ELS */
92};
93
94/*
95 * Initializer useful for decoding table.
96 * Please keep this in sync with the above definitions.
97 */
98#define FC_ELS_CMDS_INIT { \
99 [ELS_LS_RJT] = "LS_RJT", \
100 [ELS_LS_ACC] = "LS_ACC", \
101 [ELS_PLOGI] = "PLOGI", \
102 [ELS_FLOGI] = "FLOGI", \
103 [ELS_LOGO] = "LOGO", \
104 [ELS_ABTX] = "ABTX", \
105 [ELS_RCS] = "RCS", \
106 [ELS_RES] = "RES", \
107 [ELS_RSS] = "RSS", \
108 [ELS_RSI] = "RSI", \
109 [ELS_ESTS] = "ESTS", \
110 [ELS_ESTC] = "ESTC", \
111 [ELS_ADVC] = "ADVC", \
112 [ELS_RTV] = "RTV", \
113 [ELS_RLS] = "RLS", \
114 [ELS_ECHO] = "ECHO", \
115 [ELS_TEST] = "TEST", \
116 [ELS_RRQ] = "RRQ", \
117 [ELS_REC] = "REC", \
118 [ELS_SRR] = "SRR", \
119 [ELS_PRLI] = "PRLI", \
120 [ELS_PRLO] = "PRLO", \
121 [ELS_SCN] = "SCN", \
122 [ELS_TPLS] = "TPLS", \
123 [ELS_TPRLO] = "TPRLO", \
124 [ELS_LCLM] = "LCLM", \
125 [ELS_GAID] = "GAID", \
126 [ELS_FACT] = "FACT", \
127 [ELS_FDACDT] = "FDACDT", \
128 [ELS_NACT] = "NACT", \
129 [ELS_NDACT] = "NDACT", \
130 [ELS_QOSR] = "QOSR", \
131 [ELS_RVCS] = "RVCS", \
132 [ELS_PDISC] = "PDISC", \
133 [ELS_FDISC] = "FDISC", \
134 [ELS_ADISC] = "ADISC", \
135 [ELS_RNC] = "RNC", \
136 [ELS_FARP_REQ] = "FARP_REQ", \
137 [ELS_FARP_REPL] = "FARP_REPL", \
138 [ELS_RPS] = "RPS", \
139 [ELS_RPL] = "RPL", \
140 [ELS_RPBC] = "RPBC", \
141 [ELS_FAN] = "FAN", \
142 [ELS_RSCN] = "RSCN", \
143 [ELS_SCR] = "SCR", \
144 [ELS_RNFT] = "RNFT", \
145 [ELS_CSR] = "CSR", \
146 [ELS_CSU] = "CSU", \
147 [ELS_LINIT] = "LINIT", \
148 [ELS_LSTS] = "LSTS", \
149 [ELS_RNID] = "RNID", \
150 [ELS_RLIR] = "RLIR", \
151 [ELS_LIRR] = "LIRR", \
152 [ELS_SRL] = "SRL", \
153 [ELS_SBRP] = "SBRP", \
154 [ELS_RPSC] = "RPSC", \
155 [ELS_QSA] = "QSA", \
156 [ELS_EVFP] = "EVFP", \
157 [ELS_LKA] = "LKA", \
158 [ELS_AUTH_ELS] = "AUTH_ELS", \
159}
160
161/*
162 * LS_ACC payload.
163 */
164struct fc_els_ls_acc {
165 __u8 la_cmd; /* command code ELS_LS_ACC */
166 __u8 la_resv[3]; /* reserved */
167};
168
169/*
170 * ELS reject payload.
171 */
172struct fc_els_ls_rjt {
173 __u8 er_cmd; /* command code ELS_LS_RJT */
174 __u8 er_resv[4]; /* reserved must be zero */
175 __u8 er_reason; /* reason (enum fc_els_rjt_reason below) */
176 __u8 er_explan; /* explanation (enum fc_els_rjt_explan below) */
177 __u8 er_vendor; /* vendor specific code */
178};
179
180/*
181 * ELS reject reason codes (er_reason).
182 */
183enum fc_els_rjt_reason {
184 ELS_RJT_NONE = 0, /* no reject - not to be sent */
185 ELS_RJT_INVAL = 0x01, /* invalid ELS command code */
186 ELS_RJT_LOGIC = 0x03, /* logical error */
187 ELS_RJT_BUSY = 0x05, /* logical busy */
188 ELS_RJT_PROT = 0x07, /* protocol error */
189 ELS_RJT_UNAB = 0x09, /* unable to perform command request */
190 ELS_RJT_UNSUP = 0x0b, /* command not supported */
191 ELS_RJT_INPROG = 0x0e, /* command already in progress */
192 ELS_RJT_VENDOR = 0xff, /* vendor specific error */
193};
194
195
196/*
197 * reason code explanation (er_explan).
198 */
199enum fc_els_rjt_explan {
200 ELS_EXPL_NONE = 0x00, /* No additional explanation */
201 ELS_EXPL_SPP_OPT_ERR = 0x01, /* service parameter error - options */
202 ELS_EXPL_SPP_ICTL_ERR = 0x03, /* service parm error - initiator ctl */
203 ELS_EXPL_AH = 0x11, /* invalid association header */
204 ELS_EXPL_AH_REQ = 0x13, /* association_header required */
205 ELS_EXPL_SID = 0x15, /* invalid originator S_ID */
206 ELS_EXPL_OXID_RXID = 0x17, /* invalid OX_ID-RX_ID combination */
207 ELS_EXPL_INPROG = 0x19, /* Request already in progress */
208 ELS_EXPL_PLOGI_REQD = 0x1e, /* N_Port login required */
209 ELS_EXPL_INSUF_RES = 0x29, /* insufficient resources */
210 ELS_EXPL_UNAB_DATA = 0x2a, /* unable to supply requested data */
211 ELS_EXPL_UNSUPR = 0x2c, /* Request not supported */
212 ELS_EXPL_INV_LEN = 0x2d, /* Invalid payload length */
213 /* TBD - above definitions incomplete */
214};
215
216/*
217 * Common service parameters (N ports).
218 */
219struct fc_els_csp {
220 __u8 sp_hi_ver; /* highest version supported (obs.) */
221 __u8 sp_lo_ver; /* highest version supported (obs.) */
222 __be16 sp_bb_cred; /* buffer-to-buffer credits */
223 __be16 sp_features; /* common feature flags */
224 __be16 sp_bb_data; /* b-b state number and data field sz */
225 union {
226 struct {
227 __be16 _sp_tot_seq; /* total concurrent sequences */
228 __be16 _sp_rel_off; /* rel. offset by info cat */
229 } sp_plogi;
230 struct {
231 __be32 _sp_r_a_tov; /* resource alloc. timeout msec */
232 } sp_flogi_acc;
233 } sp_u;
234 __be32 sp_e_d_tov; /* error detect timeout value */
235};
236#define sp_tot_seq sp_u.sp_plogi._sp_tot_seq
237#define sp_rel_off sp_u.sp_plogi._sp_rel_off
238#define sp_r_a_tov sp_u.sp_flogi_acc._sp_r_a_tov
239
240#define FC_SP_BB_DATA_MASK 0xfff /* mask for data field size in sp_bb_data */
241
242/*
243 * Minimum and maximum values for max data field size in service parameters.
244 */
245#define FC_SP_MIN_MAX_PAYLOAD FC_MIN_MAX_PAYLOAD
246#define FC_SP_MAX_MAX_PAYLOAD FC_MAX_PAYLOAD
247
248/*
249 * sp_features
250 */
251#define FC_SP_FT_CIRO 0x8000 /* continuously increasing rel. off. */
252#define FC_SP_FT_CLAD 0x8000 /* clean address (in FLOGI LS_ACC) */
253#define FC_SP_FT_RAND 0x4000 /* random relative offset */
254#define FC_SP_FT_VAL 0x2000 /* valid vendor version level */
255#define FC_SP_FT_FPORT 0x1000 /* F port (1) vs. N port (0) */
256#define FC_SP_FT_ABB 0x0800 /* alternate BB_credit management */
257#define FC_SP_FT_EDTR 0x0400 /* E_D_TOV Resolution is nanoseconds */
258#define FC_SP_FT_MCAST 0x0200 /* multicast */
259#define FC_SP_FT_BCAST 0x0100 /* broadcast */
260#define FC_SP_FT_HUNT 0x0080 /* hunt group */
261#define FC_SP_FT_SIMP 0x0040 /* dedicated simplex */
262#define FC_SP_FT_SEC 0x0020 /* reserved for security */
263#define FC_SP_FT_CSYN 0x0010 /* clock synch. supported */
264#define FC_SP_FT_RTTOV 0x0008 /* R_T_TOV value 100 uS, else 100 mS */
265#define FC_SP_FT_HALF 0x0004 /* dynamic half duplex */
266#define FC_SP_FT_SEQC 0x0002 /* SEQ_CNT */
267#define FC_SP_FT_PAYL 0x0001 /* FLOGI payload length 256, else 116 */
268
269/*
270 * Class-specific service parameters.
271 */
272struct fc_els_cssp {
273 __be16 cp_class; /* class flags */
274 __be16 cp_init; /* initiator flags */
275 __be16 cp_recip; /* recipient flags */
276 __be16 cp_rdfs; /* receive data field size */
277 __be16 cp_con_seq; /* concurrent sequences */
278 __be16 cp_ee_cred; /* N-port end-to-end credit */
279 __u8 cp_resv1; /* reserved */
280 __u8 cp_open_seq; /* open sequences per exchange */
281 __u8 _cp_resv2[2]; /* reserved */
282};
283
284/*
285 * cp_class flags.
286 */
287#define FC_CPC_VALID 0x8000 /* class valid */
288#define FC_CPC_IMIX 0x4000 /* intermix mode */
289#define FC_CPC_SEQ 0x0800 /* sequential delivery */
290#define FC_CPC_CAMP 0x0200 /* camp-on */
291#define FC_CPC_PRI 0x0080 /* priority */
292
293/*
294 * cp_init flags.
295 * (TBD: not all flags defined here).
296 */
297#define FC_CPI_CSYN 0x0010 /* clock synch. capable */
298
299/*
300 * cp_recip flags.
301 */
302#define FC_CPR_CSYN 0x0008 /* clock synch. capable */
303
304/*
305 * NFC_ELS_FLOGI: Fabric login request.
306 * NFC_ELS_PLOGI: Port login request (same format).
307 */
308struct fc_els_flogi {
309 __u8 fl_cmd; /* command */
310 __u8 _fl_resvd[3]; /* must be zero */
311 struct fc_els_csp fl_csp; /* common service parameters */
312 __be64 fl_wwpn; /* port name */
313 __be64 fl_wwnn; /* node name */
314 struct fc_els_cssp fl_cssp[4]; /* class 1-4 service parameters */
315 __u8 fl_vend[16]; /* vendor version level */
316} __attribute__((__packed__));
317
318/*
319 * Process login service parameter page.
320 */
321struct fc_els_spp {
322 __u8 spp_type; /* type code or common service params */
323 __u8 spp_type_ext; /* type code extension */
324 __u8 spp_flags;
325 __u8 _spp_resvd;
326 __be32 spp_orig_pa; /* originator process associator */
327 __be32 spp_resp_pa; /* responder process associator */
328 __be32 spp_params; /* service parameters */
329};
330
331/*
332 * spp_flags.
333 */
334#define FC_SPP_OPA_VAL 0x80 /* originator proc. assoc. valid */
335#define FC_SPP_RPA_VAL 0x40 /* responder proc. assoc. valid */
336#define FC_SPP_EST_IMG_PAIR 0x20 /* establish image pair */
337#define FC_SPP_RESP_MASK 0x0f /* mask for response code (below) */
338
339/*
340 * SPP response code in spp_flags - lower 4 bits.
341 */
342enum fc_els_spp_resp {
343 FC_SPP_RESP_ACK = 1, /* request executed */
344 FC_SPP_RESP_RES = 2, /* unable due to lack of resources */
345 FC_SPP_RESP_INIT = 3, /* initialization not complete */
346 FC_SPP_RESP_NO_PA = 4, /* unknown process associator */
347 FC_SPP_RESP_CONF = 5, /* configuration precludes image pair */
348 FC_SPP_RESP_COND = 6, /* request completed conditionally */
349 FC_SPP_RESP_MULT = 7, /* unable to handle multiple SPPs */
350 FC_SPP_RESP_INVL = 8, /* SPP is invalid */
351};
352
353/*
354 * ELS_RRQ - Reinstate Recovery Qualifier
355 */
356struct fc_els_rrq {
357 __u8 rrq_cmd; /* command (0x12) */
358 __u8 rrq_zero[3]; /* specified as zero - part of cmd */
359 __u8 rrq_resvd; /* reserved */
360 __u8 rrq_s_id[3]; /* originator FID */
361 __be16 rrq_ox_id; /* originator exchange ID */
362 __be16 rrq_rx_id; /* responders exchange ID */
363};
364
365/*
366 * ELS_REC - Read exchange concise.
367 */
368struct fc_els_rec {
369 __u8 rec_cmd; /* command (0x13) */
370 __u8 rec_zero[3]; /* specified as zero - part of cmd */
371 __u8 rec_resvd; /* reserved */
372 __u8 rec_s_id[3]; /* originator FID */
373 __be16 rec_ox_id; /* originator exchange ID */
374 __be16 rec_rx_id; /* responders exchange ID */
375};
376
377/*
378 * ELS_REC LS_ACC payload.
379 */
380struct fc_els_rec_acc {
381 __u8 reca_cmd; /* accept (0x02) */
382 __u8 reca_zero[3]; /* specified as zero - part of cmd */
383 __be16 reca_ox_id; /* originator exchange ID */
384 __be16 reca_rx_id; /* responders exchange ID */
385 __u8 reca_resvd1; /* reserved */
386 __u8 reca_ofid[3]; /* originator FID */
387 __u8 reca_resvd2; /* reserved */
388 __u8 reca_rfid[3]; /* responder FID */
389 __be32 reca_fc4value; /* FC4 value */
390 __be32 reca_e_stat; /* ESB (exchange status block) status */
391};
392
393/*
394 * ELS_PRLI - Process login request and response.
395 */
396struct fc_els_prli {
397 __u8 prli_cmd; /* command */
398 __u8 prli_spp_len; /* length of each serv. parm. page */
399 __be16 prli_len; /* length of entire payload */
400 /* service parameter pages follow */
401};
402
403/*
404 * ELS_ADISC payload
405 */
406struct fc_els_adisc {
407 __u8 adisc_cmd;
408 __u8 adisc_resv[3];
409 __u8 adisc_resv1;
410 __u8 adisc_hard_addr[3];
411 __be64 adisc_wwpn;
412 __be64 adisc_wwnn;
413 __u8 adisc_resv2;
414 __u8 adisc_port_id[3];
415} __attribute__((__packed__));
416
417/*
418 * ELS_LOGO - process or fabric logout.
419 */
420struct fc_els_logo {
421 __u8 fl_cmd; /* command code */
422 __u8 fl_zero[3]; /* specified as zero - part of cmd */
423 __u8 fl_resvd; /* reserved */
424 __u8 fl_n_port_id[3];/* N port ID */
425 __be64 fl_n_port_wwn; /* port name */
426};
427
428/*
429 * ELS_RTV - read timeout value.
430 */
431struct fc_els_rtv {
432 __u8 rtv_cmd; /* command code 0x0e */
433 __u8 rtv_zero[3]; /* specified as zero - part of cmd */
434};
435
436/*
437 * LS_ACC for ELS_RTV - read timeout value.
438 */
439struct fc_els_rtv_acc {
440 __u8 rtv_cmd; /* command code 0x02 */
441 __u8 rtv_zero[3]; /* specified as zero - part of cmd */
442 __be32 rtv_r_a_tov; /* resource allocation timeout value */
443 __be32 rtv_e_d_tov; /* error detection timeout value */
444 __be32 rtv_toq; /* timeout qualifier (see below) */
445};
446
447/*
448 * rtv_toq bits.
449 */
450#define FC_ELS_RTV_EDRES (1 << 26) /* E_D_TOV resolution is nS else mS */
451#define FC_ELS_RTV_RTTOV (1 << 19) /* R_T_TOV is 100 uS else 100 mS */
452
453/*
454 * ELS_SCR - state change registration payload.
455 */
456struct fc_els_scr {
457 __u8 scr_cmd; /* command code */
458 __u8 scr_resv[6]; /* reserved */
459 __u8 scr_reg_func; /* registration function (see below) */
460};
461
462enum fc_els_scr_func {
463 ELS_SCRF_FAB = 1, /* fabric-detected registration */
464 ELS_SCRF_NPORT = 2, /* Nx_Port-detected registration */
465 ELS_SCRF_FULL = 3, /* full registration */
466 ELS_SCRF_CLEAR = 255, /* remove any current registrations */
467};
468
469/*
470 * ELS_RSCN - registered state change notification payload.
471 */
472struct fc_els_rscn {
473 __u8 rscn_cmd; /* RSCN opcode (0x61) */
474 __u8 rscn_page_len; /* page length (4) */
475 __be16 rscn_plen; /* payload length including this word */
476
477 /* followed by 4-byte generic affected Port_ID pages */
478};
479
480struct fc_els_rscn_page {
481 __u8 rscn_page_flags; /* event and address format */
482 __u8 rscn_fid[3]; /* fabric ID */
483};
484
485#define ELS_RSCN_EV_QUAL_BIT 2 /* shift count for event qualifier */
486#define ELS_RSCN_EV_QUAL_MASK 0xf /* mask for event qualifier */
487#define ELS_RSCN_ADDR_FMT_BIT 0 /* shift count for address format */
488#define ELS_RSCN_ADDR_FMT_MASK 0x3 /* mask for address format */
489
490enum fc_els_rscn_ev_qual {
491 ELS_EV_QUAL_NONE = 0, /* unspecified */
492 ELS_EV_QUAL_NS_OBJ = 1, /* changed name server object */
493 ELS_EV_QUAL_PORT_ATTR = 2, /* changed port attribute */
494 ELS_EV_QUAL_SERV_OBJ = 3, /* changed service object */
495 ELS_EV_QUAL_SW_CONFIG = 4, /* changed switch configuration */
496 ELS_EV_QUAL_REM_OBJ = 5, /* removed object */
497};
498
499enum fc_els_rscn_addr_fmt {
500 ELS_ADDR_FMT_PORT = 0, /* rscn_fid is a port address */
501 ELS_ADDR_FMT_AREA = 1, /* rscn_fid is a area address */
502 ELS_ADDR_FMT_DOM = 2, /* rscn_fid is a domain address */
503 ELS_ADDR_FMT_FAB = 3, /* anything on fabric may have changed */
504};
505
506/*
507 * ELS_RNID - request Node ID.
508 */
509struct fc_els_rnid {
510 __u8 rnid_cmd; /* RNID opcode (0x78) */
511 __u8 rnid_resv[3]; /* reserved */
512 __u8 rnid_fmt; /* data format */
513 __u8 rnid_resv2[3]; /* reserved */
514};
515
516/*
517 * Node Identification Data formats (rnid_fmt)
518 */
519enum fc_els_rnid_fmt {
520 ELS_RNIDF_NONE = 0, /* no specific identification data */
521 ELS_RNIDF_GEN = 0xdf, /* general topology discovery format */
522};
523
524/*
525 * ELS_RNID response.
526 */
527struct fc_els_rnid_resp {
528 __u8 rnid_cmd; /* response code (LS_ACC) */
529 __u8 rnid_resv[3]; /* reserved */
530 __u8 rnid_fmt; /* data format */
531 __u8 rnid_cid_len; /* common ID data length */
532 __u8 rnid_resv2; /* reserved */
533 __u8 rnid_sid_len; /* specific ID data length */
534};
535
536struct fc_els_rnid_cid {
537 __be64 rnid_wwpn; /* N port name */
538 __be64 rnid_wwnn; /* node name */
539};
540
541struct fc_els_rnid_gen {
542 __u8 rnid_vend_id[16]; /* vendor-unique ID */
543 __be32 rnid_atype; /* associated type (see below) */
544 __be32 rnid_phys_port; /* physical port number */
545 __be32 rnid_att_nodes; /* number of attached nodes */
546 __u8 rnid_node_mgmt; /* node management (see below) */
547 __u8 rnid_ip_ver; /* IP version (see below) */
548 __be16 rnid_prot_port; /* UDP / TCP port number */
549 __be32 rnid_ip_addr[4]; /* IP address */
550 __u8 rnid_resvd[2]; /* reserved */
551 __be16 rnid_vend_spec; /* vendor-specific field */
552};
553
554enum fc_els_rnid_atype {
555 ELS_RNIDA_UNK = 0x01, /* unknown */
556 ELS_RNIDA_OTHER = 0x02, /* none of the following */
557 ELS_RNIDA_HUB = 0x03,
558 ELS_RNIDA_SWITCH = 0x04,
559 ELS_RNIDA_GATEWAY = 0x05,
560 ELS_RNIDA_CONV = 0x06, /* Obsolete, do not use this value */
561 ELS_RNIDA_HBA = 0x07, /* Obsolete, do not use this value */
562 ELS_RNIDA_PROXY = 0x08, /* Obsolete, do not use this value */
563 ELS_RNIDA_STORAGE = 0x09,
564 ELS_RNIDA_HOST = 0x0a,
565 ELS_RNIDA_SUBSYS = 0x0b, /* storage subsystem (e.g., RAID) */
566 ELS_RNIDA_ACCESS = 0x0e, /* access device (e.g. media changer) */
567 ELS_RNIDA_NAS = 0x11, /* NAS server */
568 ELS_RNIDA_BRIDGE = 0x12, /* bridge */
569 ELS_RNIDA_VIRT = 0x13, /* virtualization device */
570 ELS_RNIDA_MF = 0xff, /* multifunction device (bits below) */
571 ELS_RNIDA_MF_HUB = 1UL << 31, /* hub */
572 ELS_RNIDA_MF_SW = 1UL << 30, /* switch */
573 ELS_RNIDA_MF_GW = 1UL << 29, /* gateway */
574 ELS_RNIDA_MF_ST = 1UL << 28, /* storage */
575 ELS_RNIDA_MF_HOST = 1UL << 27, /* host */
576 ELS_RNIDA_MF_SUB = 1UL << 26, /* storage subsystem */
577 ELS_RNIDA_MF_ACC = 1UL << 25, /* storage access dev */
578 ELS_RNIDA_MF_WDM = 1UL << 24, /* wavelength division mux */
579 ELS_RNIDA_MF_NAS = 1UL << 23, /* NAS server */
580 ELS_RNIDA_MF_BR = 1UL << 22, /* bridge */
581 ELS_RNIDA_MF_VIRT = 1UL << 21, /* virtualization device */
582};
583
584enum fc_els_rnid_mgmt {
585 ELS_RNIDM_SNMP = 0,
586 ELS_RNIDM_TELNET = 1,
587 ELS_RNIDM_HTTP = 2,
588 ELS_RNIDM_HTTPS = 3,
589 ELS_RNIDM_XML = 4, /* HTTP + XML */
590};
591
592enum fc_els_rnid_ipver {
593 ELS_RNIDIP_NONE = 0, /* no IP support or node mgmt. */
594 ELS_RNIDIP_V4 = 1, /* IPv4 */
595 ELS_RNIDIP_V6 = 2, /* IPv6 */
596};
597
598/*
599 * ELS RPL - Read Port List.
600 */
601struct fc_els_rpl {
602 __u8 rpl_cmd; /* command */
603 __u8 rpl_resv[5]; /* reserved - must be zero */
604 __be16 rpl_max_size; /* maximum response size or zero */
605 __u8 rpl_resv1; /* reserved - must be zero */
606 __u8 rpl_index[3]; /* starting index */
607};
608
609/*
610 * Port number block in RPL response.
611 */
612struct fc_els_pnb {
613 __be32 pnb_phys_pn; /* physical port number */
614 __u8 pnb_resv; /* reserved */
615 __u8 pnb_port_id[3]; /* port ID */
616 __be64 pnb_wwpn; /* port name */
617};
618
619/*
620 * RPL LS_ACC response.
621 */
622struct fc_els_rpl_resp {
623 __u8 rpl_cmd; /* ELS_LS_ACC */
624 __u8 rpl_resv1; /* reserved - must be zero */
625 __be16 rpl_plen; /* payload length */
626 __u8 rpl_resv2; /* reserved - must be zero */
627 __u8 rpl_llen[3]; /* list length */
628 __u8 rpl_resv3; /* reserved - must be zero */
629 __u8 rpl_index[3]; /* starting index */
630 struct fc_els_pnb rpl_pnb[1]; /* variable number of PNBs */
631};
632
633/*
634 * Link Error Status Block.
635 */
636struct fc_els_lesb {
637 __be32 lesb_link_fail; /* link failure count */
638 __be32 lesb_sync_loss; /* loss of synchronization count */
639 __be32 lesb_sig_loss; /* loss of signal count */
640 __be32 lesb_prim_err; /* primitive sequence error count */
641 __be32 lesb_inv_word; /* invalid transmission word count */
642 __be32 lesb_inv_crc; /* invalid CRC count */
643};
644
645/*
646 * ELS RPS - Read Port Status Block request.
647 */
648struct fc_els_rps {
649 __u8 rps_cmd; /* command */
650 __u8 rps_resv[2]; /* reserved - must be zero */
651 __u8 rps_flag; /* flag - see below */
652 __be64 rps_port_spec; /* port selection */
653};
654
655enum fc_els_rps_flag {
656 FC_ELS_RPS_DID = 0x00, /* port identified by D_ID of req. */
657 FC_ELS_RPS_PPN = 0x01, /* port_spec is physical port number */
658 FC_ELS_RPS_WWPN = 0x02, /* port_spec is port WWN */
659};
660
661/*
662 * ELS RPS LS_ACC response.
663 */
664struct fc_els_rps_resp {
665 __u8 rps_cmd; /* command - LS_ACC */
666 __u8 rps_resv[2]; /* reserved - must be zero */
667 __u8 rps_flag; /* flag - see below */
668 __u8 rps_resv2[2]; /* reserved */
669 __be16 rps_status; /* port status - see below */
670 struct fc_els_lesb rps_lesb; /* link error status block */
671};
672
673enum fc_els_rps_resp_flag {
674 FC_ELS_RPS_LPEV = 0x01, /* L_port extension valid */
675};
676
677enum fc_els_rps_resp_status {
678 FC_ELS_RPS_PTP = 1 << 5, /* point-to-point connection */
679 FC_ELS_RPS_LOOP = 1 << 4, /* loop mode */
680 FC_ELS_RPS_FAB = 1 << 3, /* fabric present */
681 FC_ELS_RPS_NO_SIG = 1 << 2, /* loss of signal */
682 FC_ELS_RPS_NO_SYNC = 1 << 1, /* loss of synchronization */
683 FC_ELS_RPS_RESET = 1 << 0, /* in link reset protocol */
684};
685
686/*
687 * ELS LIRR - Link Incident Record Registration request.
688 */
689struct fc_els_lirr {
690 __u8 lirr_cmd; /* command */
691 __u8 lirr_resv[3]; /* reserved - must be zero */
692 __u8 lirr_func; /* registration function */
693 __u8 lirr_fmt; /* FC-4 type of RLIR requested */
694 __u8 lirr_resv2[2]; /* reserved - must be zero */
695};
696
697enum fc_els_lirr_func {
698 ELS_LIRR_SET_COND = 0x01, /* set - conditionally receive */
699 ELS_LIRR_SET_UNCOND = 0x02, /* set - unconditionally receive */
700 ELS_LIRR_CLEAR = 0xff /* clear registration */
701};
702
703/*
704 * ELS SRL - Scan Remote Loop request.
705 */
706struct fc_els_srl {
707 __u8 srl_cmd; /* command */
708 __u8 srl_resv[3]; /* reserved - must be zero */
709 __u8 srl_flag; /* flag - see below */
710 __u8 srl_flag_param[3]; /* flag parameter */
711};
712
713enum fc_els_srl_flag {
714 FC_ELS_SRL_ALL = 0x00, /* scan all FL ports */
715 FC_ELS_SRL_ONE = 0x01, /* scan specified loop */
716 FC_ELS_SRL_EN_PER = 0x02, /* enable periodic scanning (param) */
717 FC_ELS_SRL_DIS_PER = 0x03, /* disable periodic scanning */
718};
719
720/*
721 * ELS RLS - Read Link Error Status Block request.
722 */
723struct fc_els_rls {
724 __u8 rls_cmd; /* command */
725 __u8 rls_resv[4]; /* reserved - must be zero */
726 __u8 rls_port_id[3]; /* port ID */
727};
728
729/*
730 * ELS RLS LS_ACC Response.
731 */
732struct fc_els_rls_resp {
733 __u8 rls_cmd; /* ELS_LS_ACC */
734 __u8 rls_resv[3]; /* reserved - must be zero */
735 struct fc_els_lesb rls_lesb; /* link error status block */
736};
737
738/*
739 * ELS RLIR - Registered Link Incident Report.
740 * This is followed by the CLIR and the CLID, described below.
741 */
742struct fc_els_rlir {
743 __u8 rlir_cmd; /* command */
744 __u8 rlir_resv[3]; /* reserved - must be zero */
745 __u8 rlir_fmt; /* format (FC4-type if type specific) */
746 __u8 rlir_clr_len; /* common link incident record length */
747 __u8 rlir_cld_len; /* common link incident desc. length */
748 __u8 rlir_slr_len; /* spec. link incident record length */
749};
750
751/*
752 * CLIR - Common Link Incident Record Data. - Sent via RLIR.
753 */
754struct fc_els_clir {
755 __be64 clir_wwpn; /* incident port name */
756 __be64 clir_wwnn; /* incident port node name */
757 __u8 clir_port_type; /* incident port type */
758 __u8 clir_port_id[3]; /* incident port ID */
759
760 __be64 clir_conn_wwpn; /* connected port name */
761 __be64 clir_conn_wwnn; /* connected node name */
762 __be64 clir_fab_name; /* fabric name */
763 __be32 clir_phys_port; /* physical port number */
764 __be32 clir_trans_id; /* transaction ID */
765 __u8 clir_resv[3]; /* reserved */
766 __u8 clir_ts_fmt; /* time stamp format */
767 __be64 clir_timestamp; /* time stamp */
768};
769
770/*
771 * CLIR clir_ts_fmt - time stamp format values.
772 */
773enum fc_els_clir_ts_fmt {
774 ELS_CLIR_TS_UNKNOWN = 0, /* time stamp field unknown */
775 ELS_CLIR_TS_SEC_FRAC = 1, /* time in seconds and fractions */
776 ELS_CLIR_TS_CSU = 2, /* time in clock synch update format */
777};
778
779/*
780 * Common Link Incident Descriptor - sent via RLIR.
781 */
782struct fc_els_clid {
783 __u8 clid_iq; /* incident qualifier flags */
784 __u8 clid_ic; /* incident code */
785 __be16 clid_epai; /* domain/area of ISL */
786};
787
788/*
789 * CLID incident qualifier flags.
790 */
791enum fc_els_clid_iq {
792 ELS_CLID_SWITCH = 0x20, /* incident port is a switch node */
793 ELS_CLID_E_PORT = 0x10, /* incident is an ISL (E) port */
794 ELS_CLID_SEV_MASK = 0x0c, /* severity 2-bit field mask */
795 ELS_CLID_SEV_INFO = 0x00, /* report is informational */
796 ELS_CLID_SEV_INOP = 0x08, /* link not operational */
797 ELS_CLID_SEV_DEG = 0x04, /* link degraded but operational */
798 ELS_CLID_LASER = 0x02, /* subassembly is a laser */
799 ELS_CLID_FRU = 0x01, /* format can identify a FRU */
800};
801
802/*
803 * CLID incident code.
804 */
805enum fc_els_clid_ic {
806 ELS_CLID_IC_IMPL = 1, /* implicit incident */
807 ELS_CLID_IC_BER = 2, /* bit-error-rate threshold exceeded */
808 ELS_CLID_IC_LOS = 3, /* loss of synch or signal */
809 ELS_CLID_IC_NOS = 4, /* non-operational primitive sequence */
810 ELS_CLID_IC_PST = 5, /* primitive sequence timeout */
811 ELS_CLID_IC_INVAL = 6, /* invalid primitive sequence */
812 ELS_CLID_IC_LOOP_TO = 7, /* loop initialization time out */
813 ELS_CLID_IC_LIP = 8, /* receiving LIP */
814};
815
816#endif /* _FC_ELS_H_ */
diff --git a/include/scsi/fc/fc_encaps.h b/include/scsi/fc/fc_encaps.h
new file mode 100644
index 000000000000..f180c3e16220
--- /dev/null
+++ b/include/scsi/fc/fc_encaps.h
@@ -0,0 +1,138 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19#ifndef _FC_ENCAPS_H_
20#define _FC_ENCAPS_H_
21
22/*
23 * Protocol definitions from RFC 3643 - Fibre Channel Frame Encapsulation.
24 *
25 * Note: The frame length field is the number of 32-bit words in
26 * the encapsulation including the fcip_encaps_header, CRC and EOF words.
27 * The minimum frame length value in bytes is (32 + 24 + 4 + 4) * 4 = 64.
28 * The maximum frame length value in bytes is (32 + 24 + 2112 + 4 + 4) = 2172.
29 */
30#define FC_ENCAPS_MIN_FRAME_LEN 64 /* min frame len (bytes) (see above) */
31#define FC_ENCAPS_MAX_FRAME_LEN (FC_ENCAPS_MIN_FRAME_LEN + FC_MAX_PAYLOAD)
32
33#define FC_ENCAPS_VER 1 /* current version number */
34
35struct fc_encaps_hdr {
36 __u8 fc_proto; /* protocol number */
37 __u8 fc_ver; /* version of encapsulation */
38 __u8 fc_proto_n; /* ones complement of protocol */
39 __u8 fc_ver_n; /* ones complement of version */
40
41 unsigned char fc_proto_data[8]; /* protocol specific data */
42
43 __be16 fc_len_flags; /* 10-bit length/4 w/ 6 flag bits */
44 __be16 fc_len_flags_n; /* ones complement of length / flags */
45
46 /*
47 * Offset 0x10
48 */
49 __be32 fc_time[2]; /* time stamp: seconds and fraction */
50 __be32 fc_crc; /* CRC */
51 __be32 fc_sof; /* start of frame (see FC_SOF below) */
52
53 /* 0x20 - FC frame content followed by EOF word */
54};
55
56#define FCIP_ENCAPS_HDR_LEN 0x20 /* expected length for asserts */
57
58/*
59 * Macro's for making redundant copies of EOF and SOF.
60 */
61#define FC_XY(x, y) ((((x) & 0xff) << 8) | ((y) & 0xff))
62#define FC_XYXY(x, y) ((FCIP_XY(x, y) << 16) | FCIP_XY(x, y))
63#define FC_XYNN(x, y) (FCIP_XYXY(x, y) ^ 0xffff)
64
65#define FC_SOF_ENCODE(n) FC_XYNN(n, n)
66#define FC_EOF_ENCODE(n) FC_XYNN(n, n)
67
68/*
69 * SOF / EOF bytes.
70 */
71enum fc_sof {
72 FC_SOF_F = 0x28, /* fabric */
73 FC_SOF_I4 = 0x29, /* initiate class 4 */
74 FC_SOF_I2 = 0x2d, /* initiate class 2 */
75 FC_SOF_I3 = 0x2e, /* initiate class 3 */
76 FC_SOF_N4 = 0x31, /* normal class 4 */
77 FC_SOF_N2 = 0x35, /* normal class 2 */
78 FC_SOF_N3 = 0x36, /* normal class 3 */
79 FC_SOF_C4 = 0x39, /* activate class 4 */
80} __attribute__((packed));
81
82enum fc_eof {
83 FC_EOF_N = 0x41, /* normal (not last frame of seq) */
84 FC_EOF_T = 0x42, /* terminate (last frame of sequence) */
85 FC_EOF_RT = 0x44,
86 FC_EOF_DT = 0x46, /* disconnect-terminate class-1 */
87 FC_EOF_NI = 0x49, /* normal-invalid */
88 FC_EOF_DTI = 0x4e, /* disconnect-terminate-invalid */
89 FC_EOF_RTI = 0x4f,
90 FC_EOF_A = 0x50, /* abort */
91} __attribute__((packed));
92
93#define FC_SOF_CLASS_MASK 0x06 /* mask for class of service in SOF */
94
95/*
96 * Define classes in terms of the SOF code (initial).
97 */
98enum fc_class {
99 FC_CLASS_NONE = 0, /* software value indicating no class */
100 FC_CLASS_2 = FC_SOF_I2,
101 FC_CLASS_3 = FC_SOF_I3,
102 FC_CLASS_4 = FC_SOF_I4,
103 FC_CLASS_F = FC_SOF_F,
104};
105
106/*
107 * Determine whether SOF code indicates the need for a BLS ACK.
108 */
109static inline int fc_sof_needs_ack(enum fc_sof sof)
110{
111 return (~sof) & 0x02; /* true for class 1, 2, 4, 6, or F */
112}
113
114/*
115 * Given an fc_class, return the normal (non-initial) SOF value.
116 */
117static inline enum fc_sof fc_sof_normal(enum fc_class class)
118{
119 return class + FC_SOF_N3 - FC_SOF_I3; /* diff is always 8 */
120}
121
122/*
123 * Compute class from SOF value.
124 */
125static inline enum fc_class fc_sof_class(enum fc_sof sof)
126{
127 return (sof & 0x7) | FC_SOF_F;
128}
129
130/*
131 * Determine whether SOF is for the initial frame of a sequence.
132 */
133static inline int fc_sof_is_init(enum fc_sof sof)
134{
135 return sof < 0x30;
136}
137
138#endif /* _FC_ENCAPS_H_ */
diff --git a/include/scsi/fc/fc_fc2.h b/include/scsi/fc/fc_fc2.h
new file mode 100644
index 000000000000..cff8a8c22f50
--- /dev/null
+++ b/include/scsi/fc/fc_fc2.h
@@ -0,0 +1,124 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_FC2_H_
21#define _FC_FC2_H_
22
23/*
24 * Fibre Channel Exchanges and Sequences.
25 */
26#ifndef PACKED
27#define PACKED __attribute__ ((__packed__))
28#endif /* PACKED */
29
30
31/*
32 * Sequence Status Block.
33 * This format is set by the FC-FS standard and is sent over the wire.
34 * Note that the fields aren't all naturally aligned.
35 */
36struct fc_ssb {
37 __u8 ssb_seq_id; /* sequence ID */
38 __u8 _ssb_resvd;
39 __be16 ssb_low_seq_cnt; /* lowest SEQ_CNT */
40
41 __be16 ssb_high_seq_cnt; /* highest SEQ_CNT */
42 __be16 ssb_s_stat; /* sequence status flags */
43
44 __be16 ssb_err_seq_cnt; /* error SEQ_CNT */
45 __u8 ssb_fh_cs_ctl; /* frame header CS_CTL */
46 __be16 ssb_fh_ox_id; /* frame header OX_ID */
47 __be16 ssb_rx_id; /* responder's exchange ID */
48 __u8 _ssb_resvd2[2];
49} PACKED;
50
51/*
52 * The SSB should be 17 bytes. Since it's layout is somewhat strange,
53 * we define the size here so that code can ASSERT that the size comes out
54 * correct.
55 */
56#define FC_SSB_SIZE 17 /* length of fc_ssb for assert */
57
58/*
59 * ssb_s_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.
60 */
61#define SSB_ST_RESP (1 << 15) /* sequence responder */
62#define SSB_ST_ACTIVE (1 << 14) /* sequence is active */
63#define SSB_ST_ABNORMAL (1 << 12) /* abnormal ending condition */
64
65#define SSB_ST_REQ_MASK (3 << 10) /* ACK, abort sequence condition */
66#define SSB_ST_REQ_CONT (0 << 10)
67#define SSB_ST_REQ_ABORT (1 << 10)
68#define SSB_ST_REQ_STOP (2 << 10)
69#define SSB_ST_REQ_RETRANS (3 << 10)
70
71#define SSB_ST_ABTS (1 << 9) /* ABTS protocol completed */
72#define SSB_ST_RETRANS (1 << 8) /* retransmission completed */
73#define SSB_ST_TIMEOUT (1 << 7) /* sequence timed out by recipient */
74#define SSB_ST_P_RJT (1 << 6) /* P_RJT transmitted */
75
76#define SSB_ST_CLASS_BIT 4 /* class of service field LSB */
77#define SSB_ST_CLASS_MASK 3 /* class of service mask */
78#define SSB_ST_ACK (1 << 3) /* ACK (EOFt or EOFdt) transmitted */
79
80/*
81 * Exchange Status Block.
82 * This format is set by the FC-FS standard and is sent over the wire.
83 * Note that the fields aren't all naturally aligned.
84 */
85struct fc_esb {
86 __u8 esb_cs_ctl; /* CS_CTL for frame header */
87 __be16 esb_ox_id; /* originator exchange ID */
88 __be16 esb_rx_id; /* responder exchange ID */
89 __be32 esb_orig_fid; /* fabric ID of originator */
90 __be32 esb_resp_fid; /* fabric ID of responder */
91 __be32 esb_e_stat; /* status */
92 __u8 _esb_resvd[4];
93 __u8 esb_service_params[112]; /* TBD */
94 __u8 esb_seq_status[8]; /* sequence statuses, 8 bytes each */
95} __attribute__((packed));;
96
97
98/*
99 * Define expected size for ASSERTs.
100 * See comments on FC_SSB_SIZE.
101 */
102#define FC_ESB_SIZE (1 + 5*4 + 112 + 8) /* expected size */
103
104/*
105 * esb_e_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.
106 */
107#define ESB_ST_RESP (1 << 31) /* responder to exchange */
108#define ESB_ST_SEQ_INIT (1 << 30) /* port holds sequence initiaive */
109#define ESB_ST_COMPLETE (1 << 29) /* exchange is complete */
110#define ESB_ST_ABNORMAL (1 << 28) /* abnormal ending condition */
111#define ESB_ST_REC_QUAL (1 << 26) /* recovery qualifier active */
112
113#define ESB_ST_ERRP_BIT 24 /* LSB for error policy */
114#define ESB_ST_ERRP_MASK (3 << 24) /* mask for error policy */
115#define ESB_ST_ERRP_MULT (0 << 24) /* abort, discard multiple sequences */
116#define ESB_ST_ERRP_SING (1 << 24) /* abort, discard single sequence */
117#define ESB_ST_ERRP_INF (2 << 24) /* process with infinite buffers */
118#define ESB_ST_ERRP_IMM (3 << 24) /* discard mult. with immed. retran. */
119
120#define ESB_ST_OX_ID_INVL (1 << 23) /* originator XID invalid */
121#define ESB_ST_RX_ID_INVL (1 << 22) /* responder XID invalid */
122#define ESB_ST_PRI_INUSE (1 << 21) /* priority / preemption in use */
123
124#endif /* _FC_FC2_H_ */
diff --git a/include/scsi/fc/fc_fcoe.h b/include/scsi/fc/fc_fcoe.h
new file mode 100644
index 000000000000..57aaa8f0d613
--- /dev/null
+++ b/include/scsi/fc/fc_fcoe.h
@@ -0,0 +1,114 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_FCOE_H_
21#define _FC_FCOE_H_
22
23/*
24 * FCoE - Fibre Channel over Ethernet.
25 */
26
27/*
28 * The FCoE ethertype eventually goes in net/if_ether.h.
29 */
30#ifndef ETH_P_FCOE
31#define ETH_P_FCOE 0x8906 /* FCOE ether type */
32#endif
33
34#ifndef ETH_P_8021Q
35#define ETH_P_8021Q 0x8100
36#endif
37
38/*
39 * FC_FCOE_OUI hasn't been standardized yet. XXX TBD.
40 */
41#ifndef FC_FCOE_OUI
42#define FC_FCOE_OUI 0x0efc00 /* upper 24 bits of FCOE dest MAC TBD */
43#endif
44
45/*
46 * The destination MAC address for the fabric login may get a different OUI.
47 * This isn't standardized yet.
48 */
49#ifndef FC_FCOE_FLOGI_MAC
50/* gateway MAC - TBD */
51#define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }
52#endif
53
54#define FC_FCOE_VER 0 /* version */
55
56/*
57 * Ethernet Addresses based on FC S_ID and D_ID.
58 * Generated by FC_FCOE_OUI | S_ID/D_ID
59 */
60#define FC_FCOE_ENCAPS_ID(n) (((u64) FC_FCOE_OUI << 24) | (n))
61#define FC_FCOE_DECAPS_ID(n) ((n) >> 24)
62
63/*
64 * FCoE frame header - 14 bytes
65 *
66 * This is the August 2007 version of the FCoE header as defined by T11.
67 * This follows the VLAN header, which includes the ethertype.
68 */
69struct fcoe_hdr {
70 __u8 fcoe_ver; /* version field - upper 4 bits */
71 __u8 fcoe_resvd[12]; /* reserved - send zero and ignore */
72 __u8 fcoe_sof; /* start of frame per RFC 3643 */
73};
74
75#define FC_FCOE_DECAPS_VER(hp) ((hp)->fcoe_ver >> 4)
76#define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)
77
78/*
79 * FCoE CRC & EOF - 8 bytes.
80 */
81struct fcoe_crc_eof {
82 __le32 fcoe_crc32; /* CRC for FC packet */
83 __u8 fcoe_eof; /* EOF from RFC 3643 */
84 __u8 fcoe_resvd[3]; /* reserved - send zero and ignore */
85} __attribute__((packed));
86
87/*
88 * Minimum FCoE + FC header length
89 * 14 bytes FCoE header + 24 byte FC header = 38 bytes
90 */
91#define FCOE_HEADER_LEN 38
92
93/*
94 * Minimum FCoE frame size
95 * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes
96 */
97#define FCOE_MIN_FRAME 46
98
99/*
100 * fc_fcoe_set_mac - Store OUI + DID into MAC address field.
101 * @mac: mac address to be set
102 * @did: fc dest id to use
103 */
104static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)
105{
106 mac[0] = (u8) (FC_FCOE_OUI >> 16);
107 mac[1] = (u8) (FC_FCOE_OUI >> 8);
108 mac[2] = (u8) FC_FCOE_OUI;
109 mac[3] = did[0];
110 mac[4] = did[1];
111 mac[5] = did[2];
112}
113
114#endif /* _FC_FCOE_H_ */
diff --git a/include/scsi/fc/fc_fcp.h b/include/scsi/fc/fc_fcp.h
new file mode 100644
index 000000000000..5d38f1989f37
--- /dev/null
+++ b/include/scsi/fc/fc_fcp.h
@@ -0,0 +1,199 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_FCP_H_
21#define _FC_FCP_H_
22
23/*
24 * Fibre Channel Protocol for SCSI.
25 * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005.
26 */
27
28/*
29 * fc/fs.h defines FC_TYPE_FCP.
30 */
31
32/*
33 * Service parameter page parameters (word 3 bits) for Process Login.
34 */
35#define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */
36#define FCP_SPPF_RETRY 0x0100 /* retry supported */
37#define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */
38#define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */
39#define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */
40#define FCP_SPPF_TARG_FCN 0x0010 /* target function */
41#define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */
42#define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */
43
44/*
45 * FCP_CMND IU Payload.
46 */
47struct fcp_cmnd {
48 __u8 fc_lun[8]; /* logical unit number */
49 __u8 fc_cmdref; /* commmand reference number */
50 __u8 fc_pri_ta; /* priority and task attribute */
51 __u8 fc_tm_flags; /* task management flags */
52 __u8 fc_flags; /* additional len & flags */
53 __u8 fc_cdb[16]; /* base CDB */
54 __be32 fc_dl; /* data length (must follow fc_cdb) */
55};
56
57#define FCP_CMND_LEN 32 /* expected length of structure */
58
59struct fcp_cmnd32 {
60 __u8 fc_lun[8]; /* logical unit number */
61 __u8 fc_cmdref; /* commmand reference number */
62 __u8 fc_pri_ta; /* priority and task attribute */
63 __u8 fc_tm_flags; /* task management flags */
64 __u8 fc_flags; /* additional len & flags */
65 __u8 fc_cdb[32]; /* base CDB */
66 __be32 fc_dl; /* data length (must follow fc_cdb) */
67};
68
69#define FCP_CMND32_LEN 48 /* expected length of structure */
70#define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */
71
72/*
73 * fc_pri_ta.
74 */
75#define FCP_PTA_SIMPLE 0 /* simple task attribute */
76#define FCP_PTA_HEADQ 1 /* head of queue task attribute */
77#define FCP_PTA_ORDERED 2 /* ordered task attribute */
78#define FCP_PTA_ACA 4 /* auto. contigent allegiance */
79#define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */
80#define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */
81
82/*
83 * fc_tm_flags - task management flags field.
84 */
85#define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */
86#define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */
87#define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */
88#define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */
89
90/*
91 * fc_flags.
92 * Bits 7:2 are the additional FCP_CDB length / 4.
93 */
94#define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */
95#define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */
96#define FCP_CFL_RDDATA 0x02 /* read data */
97#define FCP_CFL_WRDATA 0x01 /* write data */
98
99/*
100 * FCP_TXRDY IU - transfer ready payload.
101 */
102struct fcp_txrdy {
103 __be32 ft_data_ro; /* data relative offset */
104 __be32 ft_burst_len; /* burst length */
105 __u8 _ft_resvd[4]; /* reserved */
106};
107
108#define FCP_TXRDY_LEN 12 /* expected length of structure */
109
110/*
111 * FCP_RESP IU - response payload.
112 *
113 * The response payload comes in three parts: the flags/status, the
114 * sense/response lengths and the sense data/response info section.
115 *
116 * From FCP3r04, note 6 of section 9.5.13:
117 *
118 * Some early implementations presented the FCP_RSP IU without the FCP_RESID,
119 * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER,
120 * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This
121 * non-standard behavior should be tolerated.
122 *
123 * All response frames will always contain the fcp_resp template. Some
124 * will also include the fcp_resp_len template.
125 */
126struct fcp_resp {
127 __u8 _fr_resvd[8]; /* reserved */
128 __be16 fr_retry_delay; /* retry delay timer */
129 __u8 fr_flags; /* flags */
130 __u8 fr_status; /* SCSI status code */
131};
132
133#define FCP_RESP_LEN 12 /* expected length of structure */
134
135struct fcp_resp_ext {
136 __be32 fr_resid; /* Residual value */
137 __be32 fr_sns_len; /* SCSI Sense length */
138 __be32 fr_rsp_len; /* Response Info length */
139
140 /*
141 * Optionally followed by RSP info and/or SNS info and/or
142 * bidirectional read residual length, if any.
143 */
144};
145
146#define FCP_RESP_EXT_LEN 12 /* expected length of the structure */
147
148struct fcp_resp_rsp_info {
149 __u8 _fr_resvd[3]; /* reserved */
150 __u8 rsp_code; /* Response Info Code */
151 __u8 _fr_resvd2[4]; /* reserved */
152};
153
154struct fcp_resp_with_ext {
155 struct fcp_resp resp;
156 struct fcp_resp_ext ext;
157};
158
159#define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN)
160
161/*
162 * fr_flags.
163 */
164#define FCP_BIDI_RSP 0x80 /* bidirectional read response */
165#define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */
166#define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */
167#define FCP_CONF_REQ 0x10 /* confirmation requested */
168#define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */
169#define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */
170#define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */
171#define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */
172
173/*
174 * rsp_codes
175 */
176enum fcp_resp_rsp_codes {
177 FCP_TMF_CMPL = 0,
178 FCP_DATA_LEN_INVALID = 1,
179 FCP_CMND_FIELDS_INVALID = 2,
180 FCP_DATA_PARAM_MISMATCH = 3,
181 FCP_TMF_REJECTED = 4,
182 FCP_TMF_FAILED = 5,
183 FCP_TMF_INVALID_LUN = 9,
184};
185
186/*
187 * FCP SRR Link Service request - Sequence Retransmission Request.
188 */
189struct fcp_srr {
190 __u8 srr_op; /* opcode ELS_SRR */
191 __u8 srr_resvd[3]; /* opcode / reserved - must be zero */
192 __be16 srr_ox_id; /* OX_ID of failed command */
193 __be16 srr_rx_id; /* RX_ID of failed command */
194 __be32 srr_rel_off; /* relative offset */
195 __u8 srr_r_ctl; /* r_ctl for the information unit */
196 __u8 srr_resvd2[3]; /* reserved */
197};
198
199#endif /* _FC_FCP_H_ */
diff --git a/include/scsi/fc/fc_fs.h b/include/scsi/fc/fc_fs.h
new file mode 100644
index 000000000000..3e4801d2bdbb
--- /dev/null
+++ b/include/scsi/fc/fc_fs.h
@@ -0,0 +1,340 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_FS_H_
21#define _FC_FS_H_
22
23/*
24 * Fibre Channel Framing and Signalling definitions.
25 * From T11 FC-FS-2 Rev 0.90 - 9 August 2005.
26 */
27
28/*
29 * Frame header
30 */
31struct fc_frame_header {
32 __u8 fh_r_ctl; /* routing control */
33 __u8 fh_d_id[3]; /* Destination ID */
34
35 __u8 fh_cs_ctl; /* class of service control / pri */
36 __u8 fh_s_id[3]; /* Source ID */
37
38 __u8 fh_type; /* see enum fc_fh_type below */
39 __u8 fh_f_ctl[3]; /* frame control */
40
41 __u8 fh_seq_id; /* sequence ID */
42 __u8 fh_df_ctl; /* data field control */
43 __be16 fh_seq_cnt; /* sequence count */
44
45 __be16 fh_ox_id; /* originator exchange ID */
46 __be16 fh_rx_id; /* responder exchange ID */
47 __be32 fh_parm_offset; /* parameter or relative offset */
48};
49
50#define FC_FRAME_HEADER_LEN 24 /* expected length of structure */
51
52#define FC_MAX_PAYLOAD 2112U /* max payload length in bytes */
53#define FC_MIN_MAX_PAYLOAD 256U /* lower limit on max payload */
54
55#define FC_MAX_FRAME (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
56#define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
57
58/*
59 * fh_r_ctl - Routing control definitions.
60 */
61 /*
62 * FC-4 device_data.
63 */
64enum fc_rctl {
65 FC_RCTL_DD_UNCAT = 0x00, /* uncategorized information */
66 FC_RCTL_DD_SOL_DATA = 0x01, /* solicited data */
67 FC_RCTL_DD_UNSOL_CTL = 0x02, /* unsolicited control */
68 FC_RCTL_DD_SOL_CTL = 0x03, /* solicited control or reply */
69 FC_RCTL_DD_UNSOL_DATA = 0x04, /* unsolicited data */
70 FC_RCTL_DD_DATA_DESC = 0x05, /* data descriptor */
71 FC_RCTL_DD_UNSOL_CMD = 0x06, /* unsolicited command */
72 FC_RCTL_DD_CMD_STATUS = 0x07, /* command status */
73
74#define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL /* ILS request */
75#define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL /* ILS reply */
76
77 /*
78 * Extended Link_Data
79 */
80 FC_RCTL_ELS_REQ = 0x22, /* extended link services request */
81 FC_RCTL_ELS_REP = 0x23, /* extended link services reply */
82 FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */
83 FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */
84 /*
85 * Optional Extended Headers
86 */
87 FC_RCTL_VFTH = 0x50, /* virtual fabric tagging header */
88 FC_RCTL_IFRH = 0x51, /* inter-fabric routing header */
89 FC_RCTL_ENCH = 0x52, /* encapsulation header */
90 /*
91 * Basic Link Services fh_r_ctl values.
92 */
93 FC_RCTL_BA_NOP = 0x80, /* basic link service NOP */
94 FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */
95 FC_RCTL_BA_RMC = 0x82, /* remove connection */
96 FC_RCTL_BA_ACC = 0x84, /* basic accept */
97 FC_RCTL_BA_RJT = 0x85, /* basic reject */
98 FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */
99 /*
100 * Link Control Information.
101 */
102 FC_RCTL_ACK_1 = 0xc0, /* acknowledge_1 */
103 FC_RCTL_ACK_0 = 0xc1, /* acknowledge_0 */
104 FC_RCTL_P_RJT = 0xc2, /* port reject */
105 FC_RCTL_F_RJT = 0xc3, /* fabric reject */
106 FC_RCTL_P_BSY = 0xc4, /* port busy */
107 FC_RCTL_F_BSY = 0xc5, /* fabric busy to data frame */
108 FC_RCTL_F_BSYL = 0xc6, /* fabric busy to link control frame */
109 FC_RCTL_LCR = 0xc7, /* link credit reset */
110 FC_RCTL_END = 0xc9, /* end */
111};
112 /* incomplete list of definitions */
113
114/*
115 * R_CTL names initializer.
116 * Please keep this matching the above definitions.
117 */
118#define FC_RCTL_NAMES_INIT { \
119 [FC_RCTL_DD_UNCAT] = "uncat", \
120 [FC_RCTL_DD_SOL_DATA] = "sol data", \
121 [FC_RCTL_DD_UNSOL_CTL] = "unsol ctl", \
122 [FC_RCTL_DD_SOL_CTL] = "sol ctl/reply", \
123 [FC_RCTL_DD_UNSOL_DATA] = "unsol data", \
124 [FC_RCTL_DD_DATA_DESC] = "data desc", \
125 [FC_RCTL_DD_UNSOL_CMD] = "unsol cmd", \
126 [FC_RCTL_DD_CMD_STATUS] = "cmd status", \
127 [FC_RCTL_ELS_REQ] = "ELS req", \
128 [FC_RCTL_ELS_REP] = "ELS rep", \
129 [FC_RCTL_ELS4_REQ] = "FC-4 ELS req", \
130 [FC_RCTL_ELS4_REP] = "FC-4 ELS rep", \
131 [FC_RCTL_BA_NOP] = "BLS NOP", \
132 [FC_RCTL_BA_ABTS] = "BLS abort", \
133 [FC_RCTL_BA_RMC] = "BLS remove connection", \
134 [FC_RCTL_BA_ACC] = "BLS accept", \
135 [FC_RCTL_BA_RJT] = "BLS reject", \
136 [FC_RCTL_BA_PRMT] = "BLS dedicated connection preempted", \
137 [FC_RCTL_ACK_1] = "LC ACK_1", \
138 [FC_RCTL_ACK_0] = "LC ACK_0", \
139 [FC_RCTL_P_RJT] = "LC port reject", \
140 [FC_RCTL_F_RJT] = "LC fabric reject", \
141 [FC_RCTL_P_BSY] = "LC port busy", \
142 [FC_RCTL_F_BSY] = "LC fabric busy to data frame", \
143 [FC_RCTL_F_BSYL] = "LC fabric busy to link control frame",\
144 [FC_RCTL_LCR] = "LC link credit reset", \
145 [FC_RCTL_END] = "LC end", \
146}
147
148/*
149 * Well-known fabric addresses.
150 */
151enum fc_well_known_fid {
152 FC_FID_BCAST = 0xffffff, /* broadcast */
153 FC_FID_FLOGI = 0xfffffe, /* fabric login */
154 FC_FID_FCTRL = 0xfffffd, /* fabric controller */
155 FC_FID_DIR_SERV = 0xfffffc, /* directory server */
156 FC_FID_TIME_SERV = 0xfffffb, /* time server */
157 FC_FID_MGMT_SERV = 0xfffffa, /* management server */
158 FC_FID_QOS = 0xfffff9, /* QoS Facilitator */
159 FC_FID_ALIASES = 0xfffff8, /* alias server (FC-PH2) */
160 FC_FID_SEC_KEY = 0xfffff7, /* Security key dist. server */
161 FC_FID_CLOCK = 0xfffff6, /* clock synch server */
162 FC_FID_MCAST_SERV = 0xfffff5, /* multicast server */
163};
164
165#define FC_FID_WELL_KNOWN_MAX 0xffffff /* highest well-known fabric ID */
166#define FC_FID_WELL_KNOWN_BASE 0xfffff5 /* start of well-known fabric ID */
167
168/*
169 * Other well-known addresses, outside the above contiguous range.
170 */
171#define FC_FID_DOM_MGR 0xfffc00 /* domain manager base */
172
173/*
174 * Fabric ID bytes.
175 */
176#define FC_FID_DOMAIN 0
177#define FC_FID_PORT 1
178#define FC_FID_LINK 2
179
180/*
181 * fh_type codes
182 */
183enum fc_fh_type {
184 FC_TYPE_BLS = 0x00, /* basic link service */
185 FC_TYPE_ELS = 0x01, /* extended link service */
186 FC_TYPE_IP = 0x05, /* IP over FC, RFC 4338 */
187 FC_TYPE_FCP = 0x08, /* SCSI FCP */
188 FC_TYPE_CT = 0x20, /* Fibre Channel Services (FC-CT) */
189 FC_TYPE_ILS = 0x22, /* internal link service */
190};
191
192/*
193 * FC_TYPE names initializer.
194 * Please keep this matching the above definitions.
195 */
196#define FC_TYPE_NAMES_INIT { \
197 [FC_TYPE_BLS] = "BLS", \
198 [FC_TYPE_ELS] = "ELS", \
199 [FC_TYPE_IP] = "IP", \
200 [FC_TYPE_FCP] = "FCP", \
201 [FC_TYPE_CT] = "CT", \
202 [FC_TYPE_ILS] = "ILS", \
203}
204
205/*
206 * Exchange IDs.
207 */
208#define FC_XID_UNKNOWN 0xffff /* unknown exchange ID */
209#define FC_XID_MIN 0x0 /* supported min exchange ID */
210#define FC_XID_MAX 0xfffe /* supported max exchange ID */
211
212/*
213 * fh_f_ctl - Frame control flags.
214 */
215#define FC_FC_EX_CTX (1 << 23) /* sent by responder to exchange */
216#define FC_FC_SEQ_CTX (1 << 22) /* sent by responder to sequence */
217#define FC_FC_FIRST_SEQ (1 << 21) /* first sequence of this exchange */
218#define FC_FC_LAST_SEQ (1 << 20) /* last sequence of this exchange */
219#define FC_FC_END_SEQ (1 << 19) /* last frame of sequence */
220#define FC_FC_END_CONN (1 << 18) /* end of class 1 connection pending */
221#define FC_FC_RES_B17 (1 << 17) /* reserved */
222#define FC_FC_SEQ_INIT (1 << 16) /* transfer of sequence initiative */
223#define FC_FC_X_ID_REASS (1 << 15) /* exchange ID has been changed */
224#define FC_FC_X_ID_INVAL (1 << 14) /* exchange ID invalidated */
225
226#define FC_FC_ACK_1 (1 << 12) /* 13:12 = 1: ACK_1 expected */
227#define FC_FC_ACK_N (2 << 12) /* 13:12 = 2: ACK_N expected */
228#define FC_FC_ACK_0 (3 << 12) /* 13:12 = 3: ACK_0 expected */
229
230#define FC_FC_RES_B11 (1 << 11) /* reserved */
231#define FC_FC_RES_B10 (1 << 10) /* reserved */
232#define FC_FC_RETX_SEQ (1 << 9) /* retransmitted sequence */
233#define FC_FC_UNI_TX (1 << 8) /* unidirectional transmit (class 1) */
234#define FC_FC_CONT_SEQ(i) ((i) << 6)
235#define FC_FC_ABT_SEQ(i) ((i) << 4)
236#define FC_FC_REL_OFF (1 << 3) /* parameter is relative offset */
237#define FC_FC_RES2 (1 << 2) /* reserved */
238#define FC_FC_FILL(i) ((i) & 3) /* 1:0: bytes of trailing fill */
239
240/*
241 * BA_ACC payload.
242 */
243struct fc_ba_acc {
244 __u8 ba_seq_id_val; /* SEQ_ID validity */
245#define FC_BA_SEQ_ID_VAL 0x80
246 __u8 ba_seq_id; /* SEQ_ID of seq last deliverable */
247 __u8 ba_resvd[2]; /* reserved */
248 __be16 ba_ox_id; /* OX_ID for aborted seq or exch */
249 __be16 ba_rx_id; /* RX_ID for aborted seq or exch */
250 __be16 ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */
251 __be16 ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */
252};
253
254/*
255 * BA_RJT: Basic Reject payload.
256 */
257struct fc_ba_rjt {
258 __u8 br_resvd; /* reserved */
259 __u8 br_reason; /* reason code */
260 __u8 br_explan; /* reason explanation */
261 __u8 br_vendor; /* vendor unique code */
262};
263
264/*
265 * BA_RJT reason codes.
266 * From FS-2.
267 */
268enum fc_ba_rjt_reason {
269 FC_BA_RJT_NONE = 0, /* in software this means no reject */
270 FC_BA_RJT_INVL_CMD = 0x01, /* invalid command code */
271 FC_BA_RJT_LOG_ERR = 0x03, /* logical error */
272 FC_BA_RJT_LOG_BUSY = 0x05, /* logical busy */
273 FC_BA_RJT_PROTO_ERR = 0x07, /* protocol error */
274 FC_BA_RJT_UNABLE = 0x09, /* unable to perform request */
275 FC_BA_RJT_VENDOR = 0xff, /* vendor-specific (see br_vendor) */
276};
277
278/*
279 * BA_RJT reason code explanations.
280 */
281enum fc_ba_rjt_explan {
282 FC_BA_RJT_EXP_NONE = 0x00, /* no additional expanation */
283 FC_BA_RJT_INV_XID = 0x03, /* invalid OX_ID-RX_ID combination */
284 FC_BA_RJT_ABT = 0x05, /* sequence aborted, no seq info */
285};
286
287/*
288 * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.
289 */
290struct fc_pf_rjt {
291 __u8 rj_action; /* reserved */
292 __u8 rj_reason; /* reason code */
293 __u8 rj_resvd; /* reserved */
294 __u8 rj_vendor; /* vendor unique code */
295};
296
297/*
298 * P_RJT and F_RJT reject reason codes.
299 */
300enum fc_pf_rjt_reason {
301 FC_RJT_NONE = 0, /* non-reject (reserved by standard) */
302 FC_RJT_INVL_DID = 0x01, /* invalid destination ID */
303 FC_RJT_INVL_SID = 0x02, /* invalid source ID */
304 FC_RJT_P_UNAV_T = 0x03, /* port unavailable, temporary */
305 FC_RJT_P_UNAV = 0x04, /* port unavailable, permanent */
306 FC_RJT_CLS_UNSUP = 0x05, /* class not supported */
307 FC_RJT_DEL_USAGE = 0x06, /* delimiter usage error */
308 FC_RJT_TYPE_UNSUP = 0x07, /* type not supported */
309 FC_RJT_LINK_CTL = 0x08, /* invalid link control */
310 FC_RJT_R_CTL = 0x09, /* invalid R_CTL field */
311 FC_RJT_F_CTL = 0x0a, /* invalid F_CTL field */
312 FC_RJT_OX_ID = 0x0b, /* invalid originator exchange ID */
313 FC_RJT_RX_ID = 0x0c, /* invalid responder exchange ID */
314 FC_RJT_SEQ_ID = 0x0d, /* invalid sequence ID */
315 FC_RJT_DF_CTL = 0x0e, /* invalid DF_CTL field */
316 FC_RJT_SEQ_CNT = 0x0f, /* invalid SEQ_CNT field */
317 FC_RJT_PARAM = 0x10, /* invalid parameter field */
318 FC_RJT_EXCH_ERR = 0x11, /* exchange error */
319 FC_RJT_PROTO = 0x12, /* protocol error */
320 FC_RJT_LEN = 0x13, /* incorrect length */
321 FC_RJT_UNEXP_ACK = 0x14, /* unexpected ACK */
322 FC_RJT_FAB_CLASS = 0x15, /* class unsupported by fabric entity */
323 FC_RJT_LOGI_REQ = 0x16, /* login required */
324 FC_RJT_SEQ_XS = 0x17, /* excessive sequences attempted */
325 FC_RJT_EXCH_EST = 0x18, /* unable to establish exchange */
326 FC_RJT_FAB_UNAV = 0x1a, /* fabric unavailable */
327 FC_RJT_VC_ID = 0x1b, /* invalid VC_ID (class 4) */
328 FC_RJT_CS_CTL = 0x1c, /* invalid CS_CTL field */
329 FC_RJT_INSUF_RES = 0x1d, /* insuff. resources for VC (Class 4) */
330 FC_RJT_INVL_CLS = 0x1f, /* invalid class of service */
331 FC_RJT_PREEMT_RJT = 0x20, /* preemption request rejected */
332 FC_RJT_PREEMT_DIS = 0x21, /* preemption not enabled */
333 FC_RJT_MCAST_ERR = 0x22, /* multicast error */
334 FC_RJT_MCAST_ET = 0x23, /* multicast error terminate */
335 FC_RJT_PRLI_REQ = 0x24, /* process login required */
336 FC_RJT_INVL_ATT = 0x25, /* invalid attachment */
337 FC_RJT_VENDOR = 0xff, /* vendor specific reject */
338};
339
340#endif /* _FC_FS_H_ */
diff --git a/include/scsi/fc/fc_gs.h b/include/scsi/fc/fc_gs.h
new file mode 100644
index 000000000000..ffab0272c65a
--- /dev/null
+++ b/include/scsi/fc/fc_gs.h
@@ -0,0 +1,93 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_GS_H_
21#define _FC_GS_H_
22
23/*
24 * Fibre Channel Services - Common Transport.
25 * From T11.org FC-GS-2 Rev 5.3 November 1998.
26 */
27
28struct fc_ct_hdr {
29 __u8 ct_rev; /* revision */
30 __u8 ct_in_id[3]; /* N_Port ID of original requestor */
31 __u8 ct_fs_type; /* type of fibre channel service */
32 __u8 ct_fs_subtype; /* subtype */
33 __u8 ct_options;
34 __u8 _ct_resvd1;
35 __be16 ct_cmd; /* command / response code */
36 __be16 ct_mr_size; /* maximum / residual size */
37 __u8 _ct_resvd2;
38 __u8 ct_reason; /* reject reason */
39 __u8 ct_explan; /* reason code explanation */
40 __u8 ct_vendor; /* vendor unique data */
41};
42
43#define FC_CT_HDR_LEN 16 /* expected sizeof (struct fc_ct_hdr) */
44
45enum fc_ct_rev {
46 FC_CT_REV = 1 /* common transport revision */
47};
48
49/*
50 * ct_fs_type values.
51 */
52enum fc_ct_fs_type {
53 FC_FST_ALIAS = 0xf8, /* alias service */
54 FC_FST_MGMT = 0xfa, /* management service */
55 FC_FST_TIME = 0xfb, /* time service */
56 FC_FST_DIR = 0xfc, /* directory service */
57};
58
59/*
60 * ct_cmd: Command / response codes
61 */
62enum fc_ct_cmd {
63 FC_FS_RJT = 0x8001, /* reject */
64 FC_FS_ACC = 0x8002, /* accept */
65};
66
67/*
68 * FS_RJT reason codes.
69 */
70enum fc_ct_reason {
71 FC_FS_RJT_CMD = 0x01, /* invalid command code */
72 FC_FS_RJT_VER = 0x02, /* invalid version level */
73 FC_FS_RJT_LOG = 0x03, /* logical error */
74 FC_FS_RJT_IUSIZ = 0x04, /* invalid IU size */
75 FC_FS_RJT_BSY = 0x05, /* logical busy */
76 FC_FS_RJT_PROTO = 0x07, /* protocol error */
77 FC_FS_RJT_UNABL = 0x09, /* unable to perform command request */
78 FC_FS_RJT_UNSUP = 0x0b, /* command not supported */
79};
80
81/*
82 * FS_RJT reason code explanations.
83 */
84enum fc_ct_explan {
85 FC_FS_EXP_NONE = 0x00, /* no additional explanation */
86 FC_FS_EXP_PID = 0x01, /* port ID not registered */
87 FC_FS_EXP_PNAM = 0x02, /* port name not registered */
88 FC_FS_EXP_NNAM = 0x03, /* node name not registered */
89 FC_FS_EXP_COS = 0x04, /* class of service not registered */
90 /* definitions not complete */
91};
92
93#endif /* _FC_GS_H_ */
diff --git a/include/scsi/fc/fc_ns.h b/include/scsi/fc/fc_ns.h
new file mode 100644
index 000000000000..790d7b97d4bc
--- /dev/null
+++ b/include/scsi/fc/fc_ns.h
@@ -0,0 +1,159 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_NS_H_
21#define _FC_NS_H_
22
23/*
24 * Fibre Channel Services - Name Service (dNS)
25 * From T11.org FC-GS-2 Rev 5.3 November 1998.
26 */
27
28/*
29 * Common-transport sub-type for Name Server.
30 */
31#define FC_NS_SUBTYPE 2 /* fs_ct_hdr.ct_fs_subtype */
32
33/*
34 * Name server Requests.
35 * Note: this is an incomplete list, some unused requests are omitted.
36 */
37enum fc_ns_req {
38 FC_NS_GA_NXT = 0x0100, /* get all next */
39 FC_NS_GI_A = 0x0101, /* get identifiers - scope */
40 FC_NS_GPN_ID = 0x0112, /* get port name by ID */
41 FC_NS_GNN_ID = 0x0113, /* get node name by ID */
42 FC_NS_GID_PN = 0x0121, /* get ID for port name */
43 FC_NS_GID_NN = 0x0131, /* get IDs for node name */
44 FC_NS_GID_FT = 0x0171, /* get IDs by FC4 type */
45 FC_NS_GPN_FT = 0x0172, /* get port names by FC4 type */
46 FC_NS_GID_PT = 0x01a1, /* get IDs by port type */
47 FC_NS_RFT_ID = 0x0217, /* reg FC4 type for ID */
48 FC_NS_RPN_ID = 0x0212, /* reg port name for ID */
49 FC_NS_RNN_ID = 0x0213, /* reg node name for ID */
50};
51
52/*
53 * Port type values.
54 */
55enum fc_ns_pt {
56 FC_NS_UNID_PORT = 0x00, /* unidentified */
57 FC_NS_N_PORT = 0x01, /* N port */
58 FC_NS_NL_PORT = 0x02, /* NL port */
59 FC_NS_FNL_PORT = 0x03, /* F/NL port */
60 FC_NS_NX_PORT = 0x7f, /* Nx port */
61 FC_NS_F_PORT = 0x81, /* F port */
62 FC_NS_FL_PORT = 0x82, /* FL port */
63 FC_NS_E_PORT = 0x84, /* E port */
64 FC_NS_B_PORT = 0x85, /* B port */
65};
66
67/*
68 * Port type object.
69 */
70struct fc_ns_pt_obj {
71 __u8 pt_type;
72};
73
74/*
75 * Port ID object
76 */
77struct fc_ns_fid {
78 __u8 fp_flags; /* flags for responses only */
79 __u8 fp_fid[3];
80};
81
82/*
83 * fp_flags in port ID object, for responses only.
84 */
85#define FC_NS_FID_LAST 0x80 /* last object */
86
87/*
88 * FC4-types object.
89 */
90#define FC_NS_TYPES 256 /* number of possible FC-4 types */
91#define FC_NS_BPW 32 /* bits per word in bitmap */
92
93struct fc_ns_fts {
94 __be32 ff_type_map[FC_NS_TYPES / FC_NS_BPW]; /* bitmap of FC-4 types */
95};
96
97/*
98 * GID_PT request.
99 */
100struct fc_ns_gid_pt {
101 __u8 fn_pt_type;
102 __u8 fn_domain_id_scope;
103 __u8 fn_area_id_scope;
104 __u8 fn_resvd;
105};
106
107/*
108 * GID_FT or GPN_FT request.
109 */
110struct fc_ns_gid_ft {
111 __u8 fn_resvd;
112 __u8 fn_domain_id_scope;
113 __u8 fn_area_id_scope;
114 __u8 fn_fc4_type;
115};
116
117/*
118 * GPN_FT response.
119 */
120struct fc_gpn_ft_resp {
121 __u8 fp_flags; /* see fp_flags definitions above */
122 __u8 fp_fid[3]; /* port ID */
123 __be32 fp_resvd;
124 __be64 fp_wwpn; /* port name */
125};
126
127/*
128 * GID_PN request
129 */
130struct fc_ns_gid_pn {
131 __be64 fn_wwpn; /* port name */
132};
133
134/*
135 * GID_PN response
136 */
137struct fc_gid_pn_resp {
138 __u8 fp_resvd;
139 __u8 fp_fid[3]; /* port ID */
140};
141
142/*
143 * RFT_ID request - register FC-4 types for ID.
144 */
145struct fc_ns_rft_id {
146 struct fc_ns_fid fr_fid; /* port ID object */
147 struct fc_ns_fts fr_fts; /* FC-4 types object */
148};
149
150/*
151 * RPN_ID request - register port name for ID.
152 * RNN_ID request - register node name for ID.
153 */
154struct fc_ns_rn_id {
155 struct fc_ns_fid fr_fid; /* port ID object */
156 __be64 fr_wwn; /* node name or port name */
157} __attribute__((__packed__));
158
159#endif /* _FC_NS_H_ */
diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h
new file mode 100644
index 000000000000..6300f556bce5
--- /dev/null
+++ b/include/scsi/fc_encode.h
@@ -0,0 +1,309 @@
1/*
2 * Copyright(c) 2008 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_ENCODE_H_
21#define _FC_ENCODE_H_
22#include <asm/unaligned.h>
23
24struct fc_ns_rft {
25 struct fc_ns_fid fid; /* port ID object */
26 struct fc_ns_fts fts; /* FC4-types object */
27};
28
29struct fc_ct_req {
30 struct fc_ct_hdr hdr;
31 union {
32 struct fc_ns_gid_ft gid;
33 struct fc_ns_rn_id rn;
34 struct fc_ns_rft rft;
35 } payload;
36};
37
38/**
39 * fill FC header fields in specified fc_frame
40 */
41static inline void fc_fill_fc_hdr(struct fc_frame *fp, enum fc_rctl r_ctl,
42 u32 did, u32 sid, enum fc_fh_type type,
43 u32 f_ctl, u32 parm_offset)
44{
45 struct fc_frame_header *fh;
46
47 fh = fc_frame_header_get(fp);
48 WARN_ON(r_ctl == 0);
49 fh->fh_r_ctl = r_ctl;
50 hton24(fh->fh_d_id, did);
51 hton24(fh->fh_s_id, sid);
52 fh->fh_type = type;
53 hton24(fh->fh_f_ctl, f_ctl);
54 fh->fh_cs_ctl = 0;
55 fh->fh_df_ctl = 0;
56 fh->fh_parm_offset = htonl(parm_offset);
57}
58
59/**
60 * fc_ct_hdr_fill- fills ct header and reset ct payload
61 * returns pointer to ct request.
62 */
63static inline struct fc_ct_req *fc_ct_hdr_fill(const struct fc_frame *fp,
64 unsigned int op, size_t req_size)
65{
66 struct fc_ct_req *ct;
67 size_t ct_plen;
68
69 ct_plen = sizeof(struct fc_ct_hdr) + req_size;
70 ct = fc_frame_payload_get(fp, ct_plen);
71 memset(ct, 0, ct_plen);
72 ct->hdr.ct_rev = FC_CT_REV;
73 ct->hdr.ct_fs_type = FC_FST_DIR;
74 ct->hdr.ct_fs_subtype = FC_NS_SUBTYPE;
75 ct->hdr.ct_cmd = htons((u16) op);
76 return ct;
77}
78
79/**
80 * fc_ct_fill - Fill in a name service request frame
81 */
82static inline int fc_ct_fill(struct fc_lport *lport, struct fc_frame *fp,
83 unsigned int op, enum fc_rctl *r_ctl, u32 *did,
84 enum fc_fh_type *fh_type)
85{
86 struct fc_ct_req *ct;
87
88 switch (op) {
89 case FC_NS_GPN_FT:
90 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_gid_ft));
91 ct->payload.gid.fn_fc4_type = FC_TYPE_FCP;
92 break;
93
94 case FC_NS_RFT_ID:
95 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rft));
96 hton24(ct->payload.rft.fid.fp_fid,
97 fc_host_port_id(lport->host));
98 ct->payload.rft.fts = lport->fcts;
99 break;
100
101 case FC_NS_RPN_ID:
102 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rn_id));
103 hton24(ct->payload.rn.fr_fid.fp_fid,
104 fc_host_port_id(lport->host));
105 ct->payload.rft.fts = lport->fcts;
106 put_unaligned_be64(lport->wwpn, &ct->payload.rn.fr_wwn);
107 break;
108
109 default:
110 FC_DBG("Invalid op code %x \n", op);
111 return -EINVAL;
112 }
113 *r_ctl = FC_RCTL_DD_UNSOL_CTL;
114 *did = FC_FID_DIR_SERV;
115 *fh_type = FC_TYPE_CT;
116 return 0;
117}
118
119/**
120 * fc_plogi_fill - Fill in plogi request frame
121 */
122static inline void fc_plogi_fill(struct fc_lport *lport, struct fc_frame *fp,
123 unsigned int op)
124{
125 struct fc_els_flogi *plogi;
126 struct fc_els_csp *csp;
127 struct fc_els_cssp *cp;
128
129 plogi = fc_frame_payload_get(fp, sizeof(*plogi));
130 memset(plogi, 0, sizeof(*plogi));
131 plogi->fl_cmd = (u8) op;
132 put_unaligned_be64(lport->wwpn, &plogi->fl_wwpn);
133 put_unaligned_be64(lport->wwnn, &plogi->fl_wwnn);
134
135 csp = &plogi->fl_csp;
136 csp->sp_hi_ver = 0x20;
137 csp->sp_lo_ver = 0x20;
138 csp->sp_bb_cred = htons(10); /* this gets set by gateway */
139 csp->sp_bb_data = htons((u16) lport->mfs);
140 cp = &plogi->fl_cssp[3 - 1]; /* class 3 parameters */
141 cp->cp_class = htons(FC_CPC_VALID | FC_CPC_SEQ);
142 csp->sp_features = htons(FC_SP_FT_CIRO);
143 csp->sp_tot_seq = htons(255); /* seq. we accept */
144 csp->sp_rel_off = htons(0x1f);
145 csp->sp_e_d_tov = htonl(lport->e_d_tov);
146
147 cp->cp_rdfs = htons((u16) lport->mfs);
148 cp->cp_con_seq = htons(255);
149 cp->cp_open_seq = 1;
150}
151
152/**
153 * fc_flogi_fill - Fill in a flogi request frame.
154 */
155static inline void fc_flogi_fill(struct fc_lport *lport, struct fc_frame *fp)
156{
157 struct fc_els_csp *sp;
158 struct fc_els_cssp *cp;
159 struct fc_els_flogi *flogi;
160
161 flogi = fc_frame_payload_get(fp, sizeof(*flogi));
162 memset(flogi, 0, sizeof(*flogi));
163 flogi->fl_cmd = (u8) ELS_FLOGI;
164 put_unaligned_be64(lport->wwpn, &flogi->fl_wwpn);
165 put_unaligned_be64(lport->wwnn, &flogi->fl_wwnn);
166 sp = &flogi->fl_csp;
167 sp->sp_hi_ver = 0x20;
168 sp->sp_lo_ver = 0x20;
169 sp->sp_bb_cred = htons(10); /* this gets set by gateway */
170 sp->sp_bb_data = htons((u16) lport->mfs);
171 cp = &flogi->fl_cssp[3 - 1]; /* class 3 parameters */
172 cp->cp_class = htons(FC_CPC_VALID | FC_CPC_SEQ);
173}
174
175/**
176 * fc_logo_fill - Fill in a logo request frame.
177 */
178static inline void fc_logo_fill(struct fc_lport *lport, struct fc_frame *fp)
179{
180 struct fc_els_logo *logo;
181
182 logo = fc_frame_payload_get(fp, sizeof(*logo));
183 memset(logo, 0, sizeof(*logo));
184 logo->fl_cmd = ELS_LOGO;
185 hton24(logo->fl_n_port_id, fc_host_port_id(lport->host));
186 logo->fl_n_port_wwn = htonll(lport->wwpn);
187}
188
189/**
190 * fc_rtv_fill - Fill in RTV (read timeout value) request frame.
191 */
192static inline void fc_rtv_fill(struct fc_lport *lport, struct fc_frame *fp)
193{
194 struct fc_els_rtv *rtv;
195
196 rtv = fc_frame_payload_get(fp, sizeof(*rtv));
197 memset(rtv, 0, sizeof(*rtv));
198 rtv->rtv_cmd = ELS_RTV;
199}
200
201/**
202 * fc_rec_fill - Fill in rec request frame
203 */
204static inline void fc_rec_fill(struct fc_lport *lport, struct fc_frame *fp)
205{
206 struct fc_els_rec *rec;
207 struct fc_exch *ep = fc_seq_exch(fr_seq(fp));
208
209 rec = fc_frame_payload_get(fp, sizeof(*rec));
210 memset(rec, 0, sizeof(*rec));
211 rec->rec_cmd = ELS_REC;
212 hton24(rec->rec_s_id, fc_host_port_id(lport->host));
213 rec->rec_ox_id = htons(ep->oxid);
214 rec->rec_rx_id = htons(ep->rxid);
215}
216
217/**
218 * fc_prli_fill - Fill in prli request frame
219 */
220static inline void fc_prli_fill(struct fc_lport *lport, struct fc_frame *fp)
221{
222 struct {
223 struct fc_els_prli prli;
224 struct fc_els_spp spp;
225 } *pp;
226
227 pp = fc_frame_payload_get(fp, sizeof(*pp));
228 memset(pp, 0, sizeof(*pp));
229 pp->prli.prli_cmd = ELS_PRLI;
230 pp->prli.prli_spp_len = sizeof(struct fc_els_spp);
231 pp->prli.prli_len = htons(sizeof(*pp));
232 pp->spp.spp_type = FC_TYPE_FCP;
233 pp->spp.spp_flags = FC_SPP_EST_IMG_PAIR;
234 pp->spp.spp_params = htonl(lport->service_params);
235}
236
237/**
238 * fc_scr_fill - Fill in a scr request frame.
239 */
240static inline void fc_scr_fill(struct fc_lport *lport, struct fc_frame *fp)
241{
242 struct fc_els_scr *scr;
243
244 scr = fc_frame_payload_get(fp, sizeof(*scr));
245 memset(scr, 0, sizeof(*scr));
246 scr->scr_cmd = ELS_SCR;
247 scr->scr_reg_func = ELS_SCRF_FULL;
248}
249
250/**
251 * fc_els_fill - Fill in an ELS request frame
252 */
253static inline int fc_els_fill(struct fc_lport *lport, struct fc_rport *rport,
254 struct fc_frame *fp, unsigned int op,
255 enum fc_rctl *r_ctl, u32 *did, enum fc_fh_type *fh_type)
256{
257 switch (op) {
258 case ELS_PLOGI:
259 fc_plogi_fill(lport, fp, ELS_PLOGI);
260 *did = rport->port_id;
261 break;
262
263 case ELS_FLOGI:
264 fc_flogi_fill(lport, fp);
265 *did = FC_FID_FLOGI;
266 break;
267
268 case ELS_LOGO:
269 fc_logo_fill(lport, fp);
270 *did = FC_FID_FLOGI;
271 /*
272 * if rport is valid then it
273 * is port logo, therefore
274 * set did to rport id.
275 */
276 if (rport)
277 *did = rport->port_id;
278 break;
279
280 case ELS_RTV:
281 fc_rtv_fill(lport, fp);
282 *did = rport->port_id;
283 break;
284
285 case ELS_REC:
286 fc_rec_fill(lport, fp);
287 *did = rport->port_id;
288 break;
289
290 case ELS_PRLI:
291 fc_prli_fill(lport, fp);
292 *did = rport->port_id;
293 break;
294
295 case ELS_SCR:
296 fc_scr_fill(lport, fp);
297 *did = FC_FID_FCTRL;
298 break;
299
300 default:
301 FC_DBG("Invalid op code %x \n", op);
302 return -EINVAL;
303 }
304
305 *r_ctl = FC_RCTL_ELS_REQ;
306 *fh_type = FC_TYPE_ELS;
307 return 0;
308}
309#endif /* _FC_ENCODE_H_ */
diff --git a/include/scsi/fc_frame.h b/include/scsi/fc_frame.h
new file mode 100644
index 000000000000..04d34a71355f
--- /dev/null
+++ b/include/scsi/fc_frame.h
@@ -0,0 +1,242 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _FC_FRAME_H_
21#define _FC_FRAME_H_
22
23#include <linux/scatterlist.h>
24#include <linux/skbuff.h>
25#include <scsi/scsi_cmnd.h>
26
27#include <scsi/fc/fc_fs.h>
28#include <scsi/fc/fc_fcp.h>
29#include <scsi/fc/fc_encaps.h>
30
31/*
32 * The fc_frame interface is used to pass frame data between functions.
33 * The frame includes the data buffer, length, and SOF / EOF delimiter types.
34 * A pointer to the port structure of the receiving port is also includeded.
35 */
36
37#define FC_FRAME_HEADROOM 32 /* headroom for VLAN + FCoE headers */
38#define FC_FRAME_TAILROOM 8 /* trailer space for FCoE */
39
40/*
41 * Information about an individual fibre channel frame received or to be sent.
42 * The buffer may be in up to 4 additional non-contiguous sections,
43 * but the linear section must hold the frame header.
44 */
45#define FC_FRAME_SG_LEN 4 /* scatter/gather list maximum length */
46
47#define fp_skb(fp) (&((fp)->skb))
48#define fr_hdr(fp) ((fp)->skb.data)
49#define fr_len(fp) ((fp)->skb.len)
50#define fr_cb(fp) ((struct fcoe_rcv_info *)&((fp)->skb.cb[0]))
51#define fr_dev(fp) (fr_cb(fp)->fr_dev)
52#define fr_seq(fp) (fr_cb(fp)->fr_seq)
53#define fr_sof(fp) (fr_cb(fp)->fr_sof)
54#define fr_eof(fp) (fr_cb(fp)->fr_eof)
55#define fr_flags(fp) (fr_cb(fp)->fr_flags)
56#define fr_max_payload(fp) (fr_cb(fp)->fr_max_payload)
57#define fr_cmd(fp) (fr_cb(fp)->fr_cmd)
58#define fr_dir(fp) (fr_cmd(fp)->sc_data_direction)
59#define fr_crc(fp) (fr_cb(fp)->fr_crc)
60
61struct fc_frame {
62 struct sk_buff skb;
63};
64
65struct fcoe_rcv_info {
66 struct packet_type *ptype;
67 struct fc_lport *fr_dev; /* transport layer private pointer */
68 struct fc_seq *fr_seq; /* for use with exchange manager */
69 struct scsi_cmnd *fr_cmd; /* for use of scsi command */
70 u32 fr_crc;
71 u16 fr_max_payload; /* max FC payload */
72 enum fc_sof fr_sof; /* start of frame delimiter */
73 enum fc_eof fr_eof; /* end of frame delimiter */
74 u8 fr_flags; /* flags - see below */
75};
76
77
78/*
79 * Get fc_frame pointer for an skb that's already been imported.
80 */
81static inline struct fcoe_rcv_info *fcoe_dev_from_skb(const struct sk_buff *skb)
82{
83 BUILD_BUG_ON(sizeof(struct fcoe_rcv_info) > sizeof(skb->cb));
84 return (struct fcoe_rcv_info *) skb->cb;
85}
86
87/*
88 * fr_flags.
89 */
90#define FCPHF_CRC_UNCHECKED 0x01 /* CRC not computed, still appended */
91
92/*
93 * Initialize a frame.
94 * We don't do a complete memset here for performance reasons.
95 * The caller must set fr_free, fr_hdr, fr_len, fr_sof, and fr_eof eventually.
96 */
97static inline void fc_frame_init(struct fc_frame *fp)
98{
99 fr_dev(fp) = NULL;
100 fr_seq(fp) = NULL;
101 fr_flags(fp) = 0;
102}
103
104struct fc_frame *fc_frame_alloc_fill(struct fc_lport *, size_t payload_len);
105
106struct fc_frame *__fc_frame_alloc(size_t payload_len);
107
108/*
109 * Get frame for sending via port.
110 */
111static inline struct fc_frame *_fc_frame_alloc(struct fc_lport *dev,
112 size_t payload_len)
113{
114 return __fc_frame_alloc(payload_len);
115}
116
117/*
118 * Allocate fc_frame structure and buffer. Set the initial length to
119 * payload_size + sizeof (struct fc_frame_header).
120 */
121static inline struct fc_frame *fc_frame_alloc(struct fc_lport *dev, size_t len)
122{
123 struct fc_frame *fp;
124
125 /*
126 * Note: Since len will often be a constant multiple of 4,
127 * this check will usually be evaluated and eliminated at compile time.
128 */
129 if ((len % 4) != 0)
130 fp = fc_frame_alloc_fill(dev, len);
131 else
132 fp = _fc_frame_alloc(dev, len);
133 return fp;
134}
135
136/*
137 * Free the fc_frame structure and buffer.
138 */
139static inline void fc_frame_free(struct fc_frame *fp)
140{
141 kfree_skb(fp_skb(fp));
142}
143
144static inline int fc_frame_is_linear(struct fc_frame *fp)
145{
146 return !skb_is_nonlinear(fp_skb(fp));
147}
148
149/*
150 * Get frame header from message in fc_frame structure.
151 * This hides a cast and provides a place to add some checking.
152 */
153static inline
154struct fc_frame_header *fc_frame_header_get(const struct fc_frame *fp)
155{
156 WARN_ON(fr_len(fp) < sizeof(struct fc_frame_header));
157 return (struct fc_frame_header *) fr_hdr(fp);
158}
159
160/*
161 * Get frame payload from message in fc_frame structure.
162 * This hides a cast and provides a place to add some checking.
163 * The len parameter is the minimum length for the payload portion.
164 * Returns NULL if the frame is too short.
165 *
166 * This assumes the interesting part of the payload is in the first part
167 * of the buffer for received data. This may not be appropriate to use for
168 * buffers being transmitted.
169 */
170static inline void *fc_frame_payload_get(const struct fc_frame *fp,
171 size_t len)
172{
173 void *pp = NULL;
174
175 if (fr_len(fp) >= sizeof(struct fc_frame_header) + len)
176 pp = fc_frame_header_get(fp) + 1;
177 return pp;
178}
179
180/*
181 * Get frame payload opcode (first byte) from message in fc_frame structure.
182 * This hides a cast and provides a place to add some checking. Return 0
183 * if the frame has no payload.
184 */
185static inline u8 fc_frame_payload_op(const struct fc_frame *fp)
186{
187 u8 *cp;
188
189 cp = fc_frame_payload_get(fp, sizeof(u8));
190 if (!cp)
191 return 0;
192 return *cp;
193
194}
195
196/*
197 * Get FC class from frame.
198 */
199static inline enum fc_class fc_frame_class(const struct fc_frame *fp)
200{
201 return fc_sof_class(fr_sof(fp));
202}
203
204/*
205 * Check the CRC in a frame.
206 * The CRC immediately follows the last data item *AFTER* the length.
207 * The return value is zero if the CRC matches.
208 */
209u32 fc_frame_crc_check(struct fc_frame *);
210
211static inline u8 fc_frame_rctl(const struct fc_frame *fp)
212{
213 return fc_frame_header_get(fp)->fh_r_ctl;
214}
215
216static inline bool fc_frame_is_cmd(const struct fc_frame *fp)
217{
218 return fc_frame_rctl(fp) == FC_RCTL_DD_UNSOL_CMD;
219}
220
221static inline bool fc_frame_is_read(const struct fc_frame *fp)
222{
223 if (fc_frame_is_cmd(fp) && fr_cmd(fp))
224 return fr_dir(fp) == DMA_FROM_DEVICE;
225 return false;
226}
227
228static inline bool fc_frame_is_write(const struct fc_frame *fp)
229{
230 if (fc_frame_is_cmd(fp) && fr_cmd(fp))
231 return fr_dir(fp) == DMA_TO_DEVICE;
232 return false;
233}
234
235/*
236 * Check for leaks.
237 * Print the frame header of any currently allocated frame, assuming there
238 * should be none at this point.
239 */
240void fc_frame_leak_check(void);
241
242#endif /* _FC_FRAME_H_ */
diff --git a/include/scsi/fc_transport_fcoe.h b/include/scsi/fc_transport_fcoe.h
new file mode 100644
index 000000000000..8dca2af14ffc
--- /dev/null
+++ b/include/scsi/fc_transport_fcoe.h
@@ -0,0 +1,54 @@
1#ifndef FC_TRANSPORT_FCOE_H
2#define FC_TRANSPORT_FCOE_H
3
4#include <linux/device.h>
5#include <linux/netdevice.h>
6#include <scsi/scsi_host.h>
7#include <scsi/libfc.h>
8
9/**
10 * struct fcoe_transport - FCoE transport struct for generic transport
11 * for Ethernet devices as well as pure HBAs
12 *
13 * @name: name for thsi transport
14 * @bus: physical bus type (pci_bus_type)
15 * @driver: physical bus driver for network device
16 * @create: entry create function
17 * @destroy: exit destroy function
18 * @list: list of transports
19 */
20struct fcoe_transport {
21 char *name;
22 unsigned short vendor;
23 unsigned short device;
24 struct bus_type *bus;
25 struct device_driver *driver;
26 int (*create)(struct net_device *device);
27 int (*destroy)(struct net_device *device);
28 bool (*match)(struct net_device *device);
29 struct list_head list;
30 struct list_head devlist;
31 struct mutex devlock;
32};
33
34/**
35 * MODULE_ALIAS_FCOE_PCI
36 *
37 * some care must be taken with this, vendor and device MUST be a hex value
38 * preceded with 0x and with letters in lower case (0x12ab, not 0x12AB or 12AB)
39 */
40#define MODULE_ALIAS_FCOE_PCI(vendor, device) \
41 MODULE_ALIAS("fcoe-pci-" __stringify(vendor) "-" __stringify(device))
42
43/* exported funcs */
44int fcoe_transport_attach(struct net_device *netdev);
45int fcoe_transport_release(struct net_device *netdev);
46int fcoe_transport_register(struct fcoe_transport *t);
47int fcoe_transport_unregister(struct fcoe_transport *t);
48int fcoe_load_transport_driver(struct net_device *netdev);
49int __init fcoe_transport_init(void);
50int __exit fcoe_transport_exit(void);
51
52/* fcow_sw is the default transport */
53extern struct fcoe_transport fcoe_sw_transport;
54#endif /* FC_TRANSPORT_FCOE_H */
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 0c9514de5df7..d0ed5226f8c4 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -333,8 +333,11 @@ enum iscsi_host_param {
333#define CAP_TEXT_NEGO 0x80 333#define CAP_TEXT_NEGO 0x80
334#define CAP_MARKERS 0x100 334#define CAP_MARKERS 0x100
335#define CAP_FW_DB 0x200 335#define CAP_FW_DB 0x200
336#define CAP_SENDTARGETS_OFFLOAD 0x400 336#define CAP_SENDTARGETS_OFFLOAD 0x400 /* offload discovery process */
337#define CAP_DATA_PATH_OFFLOAD 0x800 337#define CAP_DATA_PATH_OFFLOAD 0x800 /* offload entire IO path */
338#define CAP_DIGEST_OFFLOAD 0x1000 /* offload hdr and data digests */
339#define CAP_PADDING_OFFLOAD 0x2000 /* offload padding insertion, removal,
340 and verification */
338 341
339/* 342/*
340 * These flags describes reason of stop_conn() call 343 * These flags describes reason of stop_conn() call
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
new file mode 100644
index 000000000000..9f2876397dda
--- /dev/null
+++ b/include/scsi/libfc.h
@@ -0,0 +1,938 @@
1/*
2 * Copyright(c) 2007 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _LIBFC_H_
21#define _LIBFC_H_
22
23#include <linux/timer.h>
24#include <linux/if.h>
25
26#include <scsi/scsi_transport.h>
27#include <scsi/scsi_transport_fc.h>
28
29#include <scsi/fc/fc_fcp.h>
30#include <scsi/fc/fc_ns.h>
31#include <scsi/fc/fc_els.h>
32#include <scsi/fc/fc_gs.h>
33
34#include <scsi/fc_frame.h>
35
36#define LIBFC_DEBUG
37
38#ifdef LIBFC_DEBUG
39/* Log messages */
40#define FC_DBG(fmt, args...) \
41 do { \
42 printk(KERN_INFO "%s " fmt, __func__, ##args); \
43 } while (0)
44#else
45#define FC_DBG(fmt, args...)
46#endif
47
48/*
49 * libfc error codes
50 */
51#define FC_NO_ERR 0 /* no error */
52#define FC_EX_TIMEOUT 1 /* Exchange timeout */
53#define FC_EX_CLOSED 2 /* Exchange closed */
54
55/* some helpful macros */
56
57#define ntohll(x) be64_to_cpu(x)
58#define htonll(x) cpu_to_be64(x)
59
60#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
61
62#define hton24(p, v) do { \
63 p[0] = (((v) >> 16) & 0xFF); \
64 p[1] = (((v) >> 8) & 0xFF); \
65 p[2] = ((v) & 0xFF); \
66 } while (0)
67
68/*
69 * FC HBA status
70 */
71#define FC_PAUSE (1 << 1)
72#define FC_LINK_UP (1 << 0)
73
74enum fc_lport_state {
75 LPORT_ST_NONE = 0,
76 LPORT_ST_FLOGI,
77 LPORT_ST_DNS,
78 LPORT_ST_RPN_ID,
79 LPORT_ST_RFT_ID,
80 LPORT_ST_SCR,
81 LPORT_ST_READY,
82 LPORT_ST_LOGO,
83 LPORT_ST_RESET
84};
85
86enum fc_disc_event {
87 DISC_EV_NONE = 0,
88 DISC_EV_SUCCESS,
89 DISC_EV_FAILED
90};
91
92enum fc_rport_state {
93 RPORT_ST_NONE = 0,
94 RPORT_ST_INIT, /* initialized */
95 RPORT_ST_PLOGI, /* waiting for PLOGI completion */
96 RPORT_ST_PRLI, /* waiting for PRLI completion */
97 RPORT_ST_RTV, /* waiting for RTV completion */
98 RPORT_ST_READY, /* ready for use */
99 RPORT_ST_LOGO, /* port logout sent */
100};
101
102enum fc_rport_trans_state {
103 FC_PORTSTATE_ROGUE,
104 FC_PORTSTATE_REAL,
105};
106
107/**
108 * struct fc_disc_port - temporary discovery port to hold rport identifiers
109 * @lp: Fibre Channel host port instance
110 * @peers: node for list management during discovery and RSCN processing
111 * @ids: identifiers structure to pass to fc_remote_port_add()
112 * @rport_work: work struct for starting the rport state machine
113 */
114struct fc_disc_port {
115 struct fc_lport *lp;
116 struct list_head peers;
117 struct fc_rport_identifiers ids;
118 struct work_struct rport_work;
119};
120
121enum fc_rport_event {
122 RPORT_EV_NONE = 0,
123 RPORT_EV_CREATED,
124 RPORT_EV_FAILED,
125 RPORT_EV_STOP,
126 RPORT_EV_LOGO
127};
128
129struct fc_rport_operations {
130 void (*event_callback)(struct fc_lport *, struct fc_rport *,
131 enum fc_rport_event);
132};
133
134/**
135 * struct fc_rport_libfc_priv - libfc internal information about a remote port
136 * @local_port: Fibre Channel host port instance
137 * @rp_state: state tracks progress of PLOGI, PRLI, and RTV exchanges
138 * @flags: REC and RETRY supported flags
139 * @max_seq: maximum number of concurrent sequences
140 * @retries: retry count in current state
141 * @e_d_tov: error detect timeout value (in msec)
142 * @r_a_tov: resource allocation timeout value (in msec)
143 * @rp_mutex: mutex protects rport
144 * @retry_work:
145 * @event_callback: Callback for rport READY, FAILED or LOGO
146 */
147struct fc_rport_libfc_priv {
148 struct fc_lport *local_port;
149 enum fc_rport_state rp_state;
150 u16 flags;
151 #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0)
152 #define FC_RP_FLAGS_RETRY (1 << 1)
153 u16 max_seq;
154 unsigned int retries;
155 unsigned int e_d_tov;
156 unsigned int r_a_tov;
157 enum fc_rport_trans_state trans_state;
158 struct mutex rp_mutex;
159 struct delayed_work retry_work;
160 enum fc_rport_event event;
161 struct fc_rport_operations *ops;
162 struct list_head peers;
163 struct work_struct event_work;
164};
165
166#define PRIV_TO_RPORT(x) \
167 (struct fc_rport *)((void *)x - sizeof(struct fc_rport));
168#define RPORT_TO_PRIV(x) \
169 (struct fc_rport_libfc_priv *)((void *)x + sizeof(struct fc_rport));
170
171struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *);
172
173static inline void fc_rport_set_name(struct fc_rport *rport, u64 wwpn, u64 wwnn)
174{
175 rport->node_name = wwnn;
176 rport->port_name = wwpn;
177}
178
179/*
180 * fcoe stats structure
181 */
182struct fcoe_dev_stats {
183 u64 SecondsSinceLastReset;
184 u64 TxFrames;
185 u64 TxWords;
186 u64 RxFrames;
187 u64 RxWords;
188 u64 ErrorFrames;
189 u64 DumpedFrames;
190 u64 LinkFailureCount;
191 u64 LossOfSignalCount;
192 u64 InvalidTxWordCount;
193 u64 InvalidCRCCount;
194 u64 InputRequests;
195 u64 OutputRequests;
196 u64 ControlRequests;
197 u64 InputMegabytes;
198 u64 OutputMegabytes;
199};
200
201/*
202 * els data is used for passing ELS respone specific
203 * data to send ELS response mainly using infomation
204 * in exchange and sequence in EM layer.
205 */
206struct fc_seq_els_data {
207 struct fc_frame *fp;
208 enum fc_els_rjt_reason reason;
209 enum fc_els_rjt_explan explan;
210};
211
212/*
213 * FCP request structure, one for each scsi cmd request
214 */
215struct fc_fcp_pkt {
216 /*
217 * housekeeping stuff
218 */
219 struct fc_lport *lp; /* handle to hba struct */
220 u16 state; /* scsi_pkt state state */
221 u16 tgt_flags; /* target flags */
222 atomic_t ref_cnt; /* fcp pkt ref count */
223 spinlock_t scsi_pkt_lock; /* Must be taken before the host lock
224 * if both are held at the same time */
225 /*
226 * SCSI I/O related stuff
227 */
228 struct scsi_cmnd *cmd; /* scsi command pointer. set/clear
229 * under host lock */
230 struct list_head list; /* tracks queued commands. access under
231 * host lock */
232 /*
233 * timeout related stuff
234 */
235 struct timer_list timer; /* command timer */
236 struct completion tm_done;
237 int wait_for_comp;
238 unsigned long start_time; /* start jiffie */
239 unsigned long end_time; /* end jiffie */
240 unsigned long last_pkt_time; /* jiffies of last frame received */
241
242 /*
243 * scsi cmd and data transfer information
244 */
245 u32 data_len;
246 /*
247 * transport related veriables
248 */
249 struct fcp_cmnd cdb_cmd;
250 size_t xfer_len;
251 u32 xfer_contig_end; /* offset of end of contiguous xfer */
252 u16 max_payload; /* max payload size in bytes */
253
254 /*
255 * scsi/fcp return status
256 */
257 u32 io_status; /* SCSI result upper 24 bits */
258 u8 cdb_status;
259 u8 status_code; /* FCP I/O status */
260 /* bit 3 Underrun bit 2: overrun */
261 u8 scsi_comp_flags;
262 u32 req_flags; /* bit 0: read bit:1 write */
263 u32 scsi_resid; /* residule length */
264
265 struct fc_rport *rport; /* remote port pointer */
266 struct fc_seq *seq_ptr; /* current sequence pointer */
267 /*
268 * Error Processing
269 */
270 u8 recov_retry; /* count of recovery retries */
271 struct fc_seq *recov_seq; /* sequence for REC or SRR */
272};
273
274/*
275 * Structure and function definitions for managing Fibre Channel Exchanges
276 * and Sequences
277 *
278 * fc_exch holds state for one exchange and links to its active sequence.
279 *
280 * fc_seq holds the state for an individual sequence.
281 */
282
283struct fc_exch_mgr;
284
285/*
286 * Sequence.
287 */
288struct fc_seq {
289 u8 id; /* seq ID */
290 u16 ssb_stat; /* status flags for sequence status block */
291 u16 cnt; /* frames sent so far on sequence */
292 u32 rec_data; /* FC-4 value for REC */
293};
294
295#define FC_EX_DONE (1 << 0) /* ep is completed */
296#define FC_EX_RST_CLEANUP (1 << 1) /* reset is forcing completion */
297
298/*
299 * Exchange.
300 *
301 * Locking notes: The ex_lock protects following items:
302 * state, esb_stat, f_ctl, seq.ssb_stat
303 * seq_id
304 * sequence allocation
305 */
306struct fc_exch {
307 struct fc_exch_mgr *em; /* exchange manager */
308 u32 state; /* internal driver state */
309 u16 xid; /* our exchange ID */
310 struct list_head ex_list; /* free or busy list linkage */
311 spinlock_t ex_lock; /* lock covering exchange state */
312 atomic_t ex_refcnt; /* reference counter */
313 struct delayed_work timeout_work; /* timer for upper level protocols */
314 struct fc_lport *lp; /* fc device instance */
315 u16 oxid; /* originator's exchange ID */
316 u16 rxid; /* responder's exchange ID */
317 u32 oid; /* originator's FCID */
318 u32 sid; /* source FCID */
319 u32 did; /* destination FCID */
320 u32 esb_stat; /* exchange status for ESB */
321 u32 r_a_tov; /* r_a_tov from rport (msec) */
322 u8 seq_id; /* next sequence ID to use */
323 u32 f_ctl; /* F_CTL flags for sequences */
324 u8 fh_type; /* frame type */
325 enum fc_class class; /* class of service */
326 struct fc_seq seq; /* single sequence */
327 /*
328 * Handler for responses to this current exchange.
329 */
330 void (*resp)(struct fc_seq *, struct fc_frame *, void *);
331 void (*destructor)(struct fc_seq *, void *);
332 /*
333 * arg is passed as void pointer to exchange
334 * resp and destructor handlers
335 */
336 void *arg;
337};
338#define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq)
339
340struct libfc_function_template {
341
342 /**
343 * Mandatory Fields
344 *
345 * These handlers must be implemented by the LLD.
346 */
347
348 /*
349 * Interface to send a FC frame
350 */
351 int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp);
352
353 /**
354 * Optional Fields
355 *
356 * The LLD may choose to implement any of the following handlers.
357 * If LLD doesn't specify hander and leaves its pointer NULL then
358 * the default libfc function will be used for that handler.
359 */
360
361 /**
362 * ELS/CT interfaces
363 */
364
365 /*
366 * elsct_send - sends ELS/CT frame
367 */
368 struct fc_seq *(*elsct_send)(struct fc_lport *lport,
369 struct fc_rport *rport,
370 struct fc_frame *fp,
371 unsigned int op,
372 void (*resp)(struct fc_seq *,
373 struct fc_frame *fp,
374 void *arg),
375 void *arg, u32 timer_msec);
376 /**
377 * Exhance Manager interfaces
378 */
379
380 /*
381 * Send the FC frame payload using a new exchange and sequence.
382 *
383 * The frame pointer with some of the header's fields must be
384 * filled before calling exch_seq_send(), those fields are,
385 *
386 * - routing control
387 * - FC port did
388 * - FC port sid
389 * - FC header type
390 * - frame control
391 * - parameter or relative offset
392 *
393 * The exchange response handler is set in this routine to resp()
394 * function pointer. It can be called in two scenarios: if a timeout
395 * occurs or if a response frame is received for the exchange. The
396 * fc_frame pointer in response handler will also indicate timeout
397 * as error using IS_ERR related macros.
398 *
399 * The exchange destructor handler is also set in this routine.
400 * The destructor handler is invoked by EM layer when exchange
401 * is about to free, this can be used by caller to free its
402 * resources along with exchange free.
403 *
404 * The arg is passed back to resp and destructor handler.
405 *
406 * The timeout value (in msec) for an exchange is set if non zero
407 * timer_msec argument is specified. The timer is canceled when
408 * it fires or when the exchange is done. The exchange timeout handler
409 * is registered by EM layer.
410 */
411 struct fc_seq *(*exch_seq_send)(struct fc_lport *lp,
412 struct fc_frame *fp,
413 void (*resp)(struct fc_seq *sp,
414 struct fc_frame *fp,
415 void *arg),
416 void (*destructor)(struct fc_seq *sp,
417 void *arg),
418 void *arg, unsigned int timer_msec);
419
420 /*
421 * send a frame using existing sequence and exchange.
422 */
423 int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp,
424 struct fc_frame *fp);
425
426 /*
427 * Send ELS response using mainly infomation
428 * in exchange and sequence in EM layer.
429 */
430 void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd,
431 struct fc_seq_els_data *els_data);
432
433 /*
434 * Abort an exchange and sequence. Generally called because of a
435 * exchange timeout or an abort from the upper layer.
436 *
437 * A timer_msec can be specified for abort timeout, if non-zero
438 * timer_msec value is specified then exchange resp handler
439 * will be called with timeout error if no response to abort.
440 */
441 int (*seq_exch_abort)(const struct fc_seq *req_sp,
442 unsigned int timer_msec);
443
444 /*
445 * Indicate that an exchange/sequence tuple is complete and the memory
446 * allocated for the related objects may be freed.
447 */
448 void (*exch_done)(struct fc_seq *sp);
449
450 /*
451 * Assigns a EM and a free XID for an new exchange and then
452 * allocates a new exchange and sequence pair.
453 * The fp can be used to determine free XID.
454 */
455 struct fc_exch *(*exch_get)(struct fc_lport *lp, struct fc_frame *fp);
456
457 /*
458 * Release previously assigned XID by exch_get API.
459 * The LLD may implement this if XID is assigned by LLD
460 * in exch_get().
461 */
462 void (*exch_put)(struct fc_lport *lp, struct fc_exch_mgr *mp,
463 u16 ex_id);
464
465 /*
466 * Start a new sequence on the same exchange/sequence tuple.
467 */
468 struct fc_seq *(*seq_start_next)(struct fc_seq *sp);
469
470 /*
471 * Reset an exchange manager, completing all sequences and exchanges.
472 * If s_id is non-zero, reset only exchanges originating from that FID.
473 * If d_id is non-zero, reset only exchanges sending to that FID.
474 */
475 void (*exch_mgr_reset)(struct fc_exch_mgr *,
476 u32 s_id, u32 d_id);
477
478 void (*rport_flush_queue)(void);
479 /**
480 * Local Port interfaces
481 */
482
483 /*
484 * Receive a frame to a local port.
485 */
486 void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp,
487 struct fc_frame *fp);
488
489 int (*lport_reset)(struct fc_lport *);
490
491 /**
492 * Remote Port interfaces
493 */
494
495 /*
496 * Initiates the RP state machine. It is called from the LP module.
497 * This function will issue the following commands to the N_Port
498 * identified by the FC ID provided.
499 *
500 * - PLOGI
501 * - PRLI
502 * - RTV
503 */
504 int (*rport_login)(struct fc_rport *rport);
505
506 /*
507 * Logoff, and remove the rport from the transport if
508 * it had been added. This will send a LOGO to the target.
509 */
510 int (*rport_logoff)(struct fc_rport *rport);
511
512 /*
513 * Recieve a request from a remote port.
514 */
515 void (*rport_recv_req)(struct fc_seq *, struct fc_frame *,
516 struct fc_rport *);
517
518 struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32);
519
520 /**
521 * FCP interfaces
522 */
523
524 /*
525 * Send a fcp cmd from fsp pkt.
526 * Called with the SCSI host lock unlocked and irqs disabled.
527 *
528 * The resp handler is called when FCP_RSP received.
529 *
530 */
531 int (*fcp_cmd_send)(struct fc_lport *lp, struct fc_fcp_pkt *fsp,
532 void (*resp)(struct fc_seq *, struct fc_frame *fp,
533 void *arg));
534
535 /*
536 * Used at least durring linkdown and reset
537 */
538 void (*fcp_cleanup)(struct fc_lport *lp);
539
540 /*
541 * Abort all I/O on a local port
542 */
543 void (*fcp_abort_io)(struct fc_lport *lp);
544
545 /**
546 * Discovery interfaces
547 */
548
549 void (*disc_recv_req)(struct fc_seq *,
550 struct fc_frame *, struct fc_lport *);
551
552 /*
553 * Start discovery for a local port.
554 */
555 void (*disc_start)(void (*disc_callback)(struct fc_lport *,
556 enum fc_disc_event),
557 struct fc_lport *);
558
559 /*
560 * Stop discovery for a given lport. This will remove
561 * all discovered rports
562 */
563 void (*disc_stop) (struct fc_lport *);
564
565 /*
566 * Stop discovery for a given lport. This will block
567 * until all discovered rports are deleted from the
568 * FC transport class
569 */
570 void (*disc_stop_final) (struct fc_lport *);
571};
572
573/* information used by the discovery layer */
574struct fc_disc {
575 unsigned char retry_count;
576 unsigned char delay;
577 unsigned char pending;
578 unsigned char requested;
579 unsigned short seq_count;
580 unsigned char buf_len;
581 enum fc_disc_event event;
582
583 void (*disc_callback)(struct fc_lport *,
584 enum fc_disc_event);
585
586 struct list_head rports;
587 struct fc_lport *lport;
588 struct mutex disc_mutex;
589 struct fc_gpn_ft_resp partial_buf; /* partial name buffer */
590 struct delayed_work disc_work;
591};
592
593struct fc_lport {
594 struct list_head list;
595
596 /* Associations */
597 struct Scsi_Host *host;
598 struct fc_exch_mgr *emp;
599 struct fc_rport *dns_rp;
600 struct fc_rport *ptp_rp;
601 void *scsi_priv;
602 struct fc_disc disc;
603
604 /* Operational Information */
605 struct libfc_function_template tt;
606 u16 link_status;
607 enum fc_lport_state state;
608 unsigned long boot_time;
609
610 struct fc_host_statistics host_stats;
611 struct fcoe_dev_stats *dev_stats[NR_CPUS];
612 u64 wwpn;
613 u64 wwnn;
614 u8 retry_count;
615
616 /* Capabilities */
617 u32 sg_supp:1; /* scatter gather supported */
618 u32 seq_offload:1; /* seq offload supported */
619 u32 crc_offload:1; /* crc offload supported */
620 u32 lro_enabled:1; /* large receive offload */
621 u32 mfs; /* max FC payload size */
622 unsigned int service_params;
623 unsigned int e_d_tov;
624 unsigned int r_a_tov;
625 u8 max_retry_count;
626 u16 link_speed;
627 u16 link_supported_speeds;
628 u16 lro_xid; /* max xid for fcoe lro */
629 struct fc_ns_fts fcts; /* FC-4 type masks */
630 struct fc_els_rnid_gen rnid_gen; /* RNID information */
631
632 /* Semaphores */
633 struct mutex lp_mutex;
634
635 /* Miscellaneous */
636 struct delayed_work retry_work;
637 struct delayed_work disc_work;
638};
639
640/**
641 * FC_LPORT HELPER FUNCTIONS
642 *****************************/
643static inline void *lport_priv(const struct fc_lport *lp)
644{
645 return (void *)(lp + 1);
646}
647
648static inline int fc_lport_test_ready(struct fc_lport *lp)
649{
650 return lp->state == LPORT_ST_READY;
651}
652
653static inline void fc_set_wwnn(struct fc_lport *lp, u64 wwnn)
654{
655 lp->wwnn = wwnn;
656}
657
658static inline void fc_set_wwpn(struct fc_lport *lp, u64 wwnn)
659{
660 lp->wwpn = wwnn;
661}
662
663static inline void fc_lport_state_enter(struct fc_lport *lp,
664 enum fc_lport_state state)
665{
666 if (state != lp->state)
667 lp->retry_count = 0;
668 lp->state = state;
669}
670
671
672/**
673 * LOCAL PORT LAYER
674 *****************************/
675int fc_lport_init(struct fc_lport *lp);
676
677/*
678 * Destroy the specified local port by finding and freeing all
679 * fc_rports associated with it and then by freeing the fc_lport
680 * itself.
681 */
682int fc_lport_destroy(struct fc_lport *lp);
683
684/*
685 * Logout the specified local port from the fabric
686 */
687int fc_fabric_logoff(struct fc_lport *lp);
688
689/*
690 * Initiate the LP state machine. This handler will use fc_host_attr
691 * to store the FLOGI service parameters, so fc_host_attr must be
692 * initialized before calling this handler.
693 */
694int fc_fabric_login(struct fc_lport *lp);
695
696/*
697 * The link is up for the given local port.
698 */
699void fc_linkup(struct fc_lport *);
700
701/*
702 * Link is down for the given local port.
703 */
704void fc_linkdown(struct fc_lport *);
705
706/*
707 * Pause and unpause traffic.
708 */
709void fc_pause(struct fc_lport *);
710void fc_unpause(struct fc_lport *);
711
712/*
713 * Configure the local port.
714 */
715int fc_lport_config(struct fc_lport *);
716
717/*
718 * Reset the local port.
719 */
720int fc_lport_reset(struct fc_lport *);
721
722/*
723 * Set the mfs or reset
724 */
725int fc_set_mfs(struct fc_lport *lp, u32 mfs);
726
727
728/**
729 * REMOTE PORT LAYER
730 *****************************/
731int fc_rport_init(struct fc_lport *lp);
732void fc_rport_terminate_io(struct fc_rport *rp);
733
734/**
735 * DISCOVERY LAYER
736 *****************************/
737int fc_disc_init(struct fc_lport *lp);
738
739
740/**
741 * SCSI LAYER
742 *****************************/
743/*
744 * Initialize the SCSI block of libfc
745 */
746int fc_fcp_init(struct fc_lport *);
747
748/*
749 * This section provides an API which allows direct interaction
750 * with the SCSI-ml. Each of these functions satisfies a function
751 * pointer defined in Scsi_Host and therefore is always called
752 * directly from the SCSI-ml.
753 */
754int fc_queuecommand(struct scsi_cmnd *sc_cmd,
755 void (*done)(struct scsi_cmnd *));
756
757/*
758 * complete processing of a fcp packet
759 *
760 * This function may sleep if a fsp timer is pending.
761 * The host lock must not be held by caller.
762 */
763void fc_fcp_complete(struct fc_fcp_pkt *fsp);
764
765/*
766 * Send an ABTS frame to the target device. The sc_cmd argument
767 * is a pointer to the SCSI command to be aborted.
768 */
769int fc_eh_abort(struct scsi_cmnd *sc_cmd);
770
771/*
772 * Reset a LUN by sending send the tm cmd to the target.
773 */
774int fc_eh_device_reset(struct scsi_cmnd *sc_cmd);
775
776/*
777 * Reset the host adapter.
778 */
779int fc_eh_host_reset(struct scsi_cmnd *sc_cmd);
780
781/*
782 * Check rport status.
783 */
784int fc_slave_alloc(struct scsi_device *sdev);
785
786/*
787 * Adjust the queue depth.
788 */
789int fc_change_queue_depth(struct scsi_device *sdev, int qdepth);
790
791/*
792 * Change the tag type.
793 */
794int fc_change_queue_type(struct scsi_device *sdev, int tag_type);
795
796/*
797 * Free memory pools used by the FCP layer.
798 */
799void fc_fcp_destroy(struct fc_lport *);
800
801/**
802 * ELS/CT interface
803 *****************************/
804/*
805 * Initializes ELS/CT interface
806 */
807int fc_elsct_init(struct fc_lport *lp);
808
809
810/**
811 * EXCHANGE MANAGER LAYER
812 *****************************/
813/*
814 * Initializes Exchange Manager related
815 * function pointers in struct libfc_function_template.
816 */
817int fc_exch_init(struct fc_lport *lp);
818
819/*
820 * Allocates an Exchange Manager (EM).
821 *
822 * The EM manages exchanges for their allocation and
823 * free, also allows exchange lookup for received
824 * frame.
825 *
826 * The class is used for initializing FC class of
827 * allocated exchange from EM.
828 *
829 * The min_xid and max_xid will limit new
830 * exchange ID (XID) within this range for
831 * a new exchange.
832 * The LLD may choose to have multiple EMs,
833 * e.g. one EM instance per CPU receive thread in LLD.
834 * The LLD can use exch_get() of struct libfc_function_template
835 * to specify XID for a new exchange within
836 * a specified EM instance.
837 *
838 * The em_idx to uniquely identify an EM instance.
839 */
840struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp,
841 enum fc_class class,
842 u16 min_xid,
843 u16 max_xid);
844
845/*
846 * Free an exchange manager.
847 */
848void fc_exch_mgr_free(struct fc_exch_mgr *mp);
849
850/*
851 * Receive a frame on specified local port and exchange manager.
852 */
853void fc_exch_recv(struct fc_lport *lp, struct fc_exch_mgr *mp,
854 struct fc_frame *fp);
855
856/*
857 * This function is for exch_seq_send function pointer in
858 * struct libfc_function_template, see comment block on
859 * exch_seq_send for description of this function.
860 */
861struct fc_seq *fc_exch_seq_send(struct fc_lport *lp,
862 struct fc_frame *fp,
863 void (*resp)(struct fc_seq *sp,
864 struct fc_frame *fp,
865 void *arg),
866 void (*destructor)(struct fc_seq *sp,
867 void *arg),
868 void *arg, u32 timer_msec);
869
870/*
871 * send a frame using existing sequence and exchange.
872 */
873int fc_seq_send(struct fc_lport *lp, struct fc_seq *sp, struct fc_frame *fp);
874
875/*
876 * Send ELS response using mainly infomation
877 * in exchange and sequence in EM layer.
878 */
879void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd,
880 struct fc_seq_els_data *els_data);
881
882/*
883 * This function is for seq_exch_abort function pointer in
884 * struct libfc_function_template, see comment block on
885 * seq_exch_abort for description of this function.
886 */
887int fc_seq_exch_abort(const struct fc_seq *req_sp, unsigned int timer_msec);
888
889/*
890 * Indicate that an exchange/sequence tuple is complete and the memory
891 * allocated for the related objects may be freed.
892 */
893void fc_exch_done(struct fc_seq *sp);
894
895/*
896 * Assigns a EM and XID for a frame and then allocates
897 * a new exchange and sequence pair.
898 * The fp can be used to determine free XID.
899 */
900struct fc_exch *fc_exch_get(struct fc_lport *lp, struct fc_frame *fp);
901
902/*
903 * Allocate a new exchange and sequence pair.
904 * if ex_id is zero then next free exchange id
905 * from specified exchange manger mp will be assigned.
906 */
907struct fc_exch *fc_exch_alloc(struct fc_exch_mgr *mp,
908 struct fc_frame *fp, u16 ex_id);
909/*
910 * Start a new sequence on the same exchange as the supplied sequence.
911 */
912struct fc_seq *fc_seq_start_next(struct fc_seq *sp);
913
914/*
915 * Reset an exchange manager, completing all sequences and exchanges.
916 * If s_id is non-zero, reset only exchanges originating from that FID.
917 * If d_id is non-zero, reset only exchanges sending to that FID.
918 */
919void fc_exch_mgr_reset(struct fc_exch_mgr *, u32 s_id, u32 d_id);
920
921/*
922 * Functions for fc_functions_template
923 */
924void fc_get_host_speed(struct Scsi_Host *shost);
925void fc_get_host_port_type(struct Scsi_Host *shost);
926void fc_get_host_port_state(struct Scsi_Host *shost);
927void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout);
928struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *);
929
930/*
931 * module setup functions.
932 */
933int fc_setup_exch_mgr(void);
934void fc_destroy_exch_mgr(void);
935int fc_setup_rport(void);
936void fc_destroy_rport(void);
937
938#endif /* _LIBFC_H_ */
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
new file mode 100644
index 000000000000..89fdbb9a6a1b
--- /dev/null
+++ b/include/scsi/libfcoe.h
@@ -0,0 +1,176 @@
1/*
2 * Copyright(c) 2007 - 2008 Intel Corporation. All rights reserved.
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.,
15 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 * Maintained at www.Open-FCoE.org
18 */
19
20#ifndef _LIBFCOE_H
21#define _LIBFCOE_H
22
23#include <linux/netdevice.h>
24#include <linux/skbuff.h>
25#include <scsi/fc/fc_fcoe.h>
26#include <scsi/libfc.h>
27
28/*
29 * this percpu struct for fcoe
30 */
31struct fcoe_percpu_s {
32 int cpu;
33 struct task_struct *thread;
34 struct sk_buff_head fcoe_rx_list;
35 struct page *crc_eof_page;
36 int crc_eof_offset;
37};
38
39/*
40 * the fcoe sw transport private data
41 */
42struct fcoe_softc {
43 struct list_head list;
44 struct fc_lport *lp;
45 struct net_device *real_dev;
46 struct net_device *phys_dev; /* device with ethtool_ops */
47 struct packet_type fcoe_packet_type;
48 struct sk_buff_head fcoe_pending_queue;
49
50 u8 dest_addr[ETH_ALEN];
51 u8 ctl_src_addr[ETH_ALEN];
52 u8 data_src_addr[ETH_ALEN];
53 /*
54 * fcoe protocol address learning related stuff
55 */
56 u16 flogi_oxid;
57 u8 flogi_progress;
58 u8 address_mode;
59};
60
61static inline struct fcoe_softc *fcoe_softc(
62 const struct fc_lport *lp)
63{
64 return (struct fcoe_softc *)lport_priv(lp);
65}
66
67static inline struct net_device *fcoe_netdev(
68 const struct fc_lport *lp)
69{
70 return fcoe_softc(lp)->real_dev;
71}
72
73static inline struct fcoe_hdr *skb_fcoe_header(const struct sk_buff *skb)
74{
75 return (struct fcoe_hdr *)skb_network_header(skb);
76}
77
78static inline int skb_fcoe_offset(const struct sk_buff *skb)
79{
80 return skb_network_offset(skb);
81}
82
83static inline struct fc_frame_header *skb_fc_header(const struct sk_buff *skb)
84{
85 return (struct fc_frame_header *)skb_transport_header(skb);
86}
87
88static inline int skb_fc_offset(const struct sk_buff *skb)
89{
90 return skb_transport_offset(skb);
91}
92
93static inline void skb_reset_fc_header(struct sk_buff *skb)
94{
95 skb_reset_network_header(skb);
96 skb_set_transport_header(skb, skb_network_offset(skb) +
97 sizeof(struct fcoe_hdr));
98}
99
100static inline bool skb_fc_is_data(const struct sk_buff *skb)
101{
102 return skb_fc_header(skb)->fh_r_ctl == FC_RCTL_DD_SOL_DATA;
103}
104
105static inline bool skb_fc_is_cmd(const struct sk_buff *skb)
106{
107 return skb_fc_header(skb)->fh_r_ctl == FC_RCTL_DD_UNSOL_CMD;
108}
109
110static inline bool skb_fc_has_exthdr(const struct sk_buff *skb)
111{
112 return (skb_fc_header(skb)->fh_r_ctl == FC_RCTL_VFTH) ||
113 (skb_fc_header(skb)->fh_r_ctl == FC_RCTL_IFRH) ||
114 (skb_fc_header(skb)->fh_r_ctl == FC_RCTL_ENCH);
115}
116
117static inline bool skb_fc_is_roff(const struct sk_buff *skb)
118{
119 return skb_fc_header(skb)->fh_f_ctl[2] & FC_FC_REL_OFF;
120}
121
122static inline u16 skb_fc_oxid(const struct sk_buff *skb)
123{
124 return be16_to_cpu(skb_fc_header(skb)->fh_ox_id);
125}
126
127static inline u16 skb_fc_rxid(const struct sk_buff *skb)
128{
129 return be16_to_cpu(skb_fc_header(skb)->fh_rx_id);
130}
131
132/* FIXME - DMA_BIDIRECTIONAL ? */
133#define skb_cb(skb) ((struct fcoe_rcv_info *)&((skb)->cb[0]))
134#define skb_cmd(skb) (skb_cb(skb)->fr_cmd)
135#define skb_dir(skb) (skb_cmd(skb)->sc_data_direction)
136static inline bool skb_fc_is_read(const struct sk_buff *skb)
137{
138 if (skb_fc_is_cmd(skb) && skb_cmd(skb))
139 return skb_dir(skb) == DMA_FROM_DEVICE;
140 return false;
141}
142
143static inline bool skb_fc_is_write(const struct sk_buff *skb)
144{
145 if (skb_fc_is_cmd(skb) && skb_cmd(skb))
146 return skb_dir(skb) == DMA_TO_DEVICE;
147 return false;
148}
149
150/* libfcoe funcs */
151int fcoe_reset(struct Scsi_Host *shost);
152u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
153 unsigned int scheme, unsigned int port);
154
155u32 fcoe_fc_crc(struct fc_frame *fp);
156int fcoe_xmit(struct fc_lport *, struct fc_frame *);
157int fcoe_rcv(struct sk_buff *, struct net_device *,
158 struct packet_type *, struct net_device *);
159
160int fcoe_percpu_receive_thread(void *arg);
161void fcoe_clean_pending_queue(struct fc_lport *lp);
162void fcoe_percpu_clean(struct fc_lport *lp);
163void fcoe_watchdog(ulong vp);
164int fcoe_link_ok(struct fc_lport *lp);
165
166struct fc_lport *fcoe_hostlist_lookup(const struct net_device *);
167int fcoe_hostlist_add(const struct fc_lport *);
168int fcoe_hostlist_remove(const struct fc_lport *);
169
170struct Scsi_Host *fcoe_host_alloc(struct scsi_host_template *, int);
171int fcoe_libfc_config(struct fc_lport *, struct libfc_function_template *);
172
173/* fcoe sw hba */
174int __init fcoe_sw_init(void);
175int __exit fcoe_sw_exit(void);
176#endif /* _LIBFCOE_H */
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 61e53f14f7e1..7360e1916e75 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -30,6 +30,7 @@
30#include <linux/workqueue.h> 30#include <linux/workqueue.h>
31#include <scsi/iscsi_proto.h> 31#include <scsi/iscsi_proto.h>
32#include <scsi/iscsi_if.h> 32#include <scsi/iscsi_if.h>
33#include <scsi/scsi_transport_iscsi.h>
33 34
34struct scsi_transport_template; 35struct scsi_transport_template;
35struct scsi_host_template; 36struct scsi_host_template;
@@ -70,12 +71,12 @@ enum {
70/* Connection suspend "bit" */ 71/* Connection suspend "bit" */
71#define ISCSI_SUSPEND_BIT 1 72#define ISCSI_SUSPEND_BIT 1
72 73
73#define ISCSI_ITT_MASK (0x1fff) 74#define ISCSI_ITT_MASK 0x1fff
74#define ISCSI_TOTAL_CMDS_MAX 4096 75#define ISCSI_TOTAL_CMDS_MAX 4096
75/* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */ 76/* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */
76#define ISCSI_TOTAL_CMDS_MIN 16 77#define ISCSI_TOTAL_CMDS_MIN 16
77#define ISCSI_AGE_SHIFT 28 78#define ISCSI_AGE_SHIFT 28
78#define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT) 79#define ISCSI_AGE_MASK 0xf
79 80
80#define ISCSI_ADDRESS_BUF_LEN 64 81#define ISCSI_ADDRESS_BUF_LEN 64
81 82
@@ -93,24 +94,38 @@ enum {
93 ISCSI_TASK_RUNNING, 94 ISCSI_TASK_RUNNING,
94}; 95};
95 96
97struct iscsi_r2t_info {
98 __be32 ttt; /* copied from R2T */
99 __be32 exp_statsn; /* copied from R2T */
100 uint32_t data_length; /* copied from R2T */
101 uint32_t data_offset; /* copied from R2T */
102 int data_count; /* DATA-Out payload progress */
103 int datasn;
104 /* LLDs should set/update these values */
105 int sent; /* R2T sequence progress */
106};
107
96struct iscsi_task { 108struct iscsi_task {
97 /* 109 /*
98 * Because LLDs allocate their hdr differently, this is a pointer 110 * Because LLDs allocate their hdr differently, this is a pointer
99 * and length to that storage. It must be setup at session 111 * and length to that storage. It must be setup at session
100 * creation time. 112 * creation time.
101 */ 113 */
102 struct iscsi_cmd *hdr; 114 struct iscsi_hdr *hdr;
103 unsigned short hdr_max; 115 unsigned short hdr_max;
104 unsigned short hdr_len; /* accumulated size of hdr used */ 116 unsigned short hdr_len; /* accumulated size of hdr used */
117 /* copied values in case we need to send tmfs */
118 itt_t hdr_itt;
119 __be32 cmdsn;
120 uint8_t lun[8];
121
105 int itt; /* this ITT */ 122 int itt; /* this ITT */
106 123
107 uint32_t unsol_datasn;
108 unsigned imm_count; /* imm-data (bytes) */ 124 unsigned imm_count; /* imm-data (bytes) */
109 unsigned unsol_count; /* unsolicited (bytes)*/
110 /* offset in unsolicited stream (bytes); */ 125 /* offset in unsolicited stream (bytes); */
111 unsigned unsol_offset; 126 struct iscsi_r2t_info unsol_r2t;
112 unsigned data_count; /* remaining Data-Out */
113 char *data; /* mgmt payload */ 127 char *data; /* mgmt payload */
128 unsigned data_count;
114 struct scsi_cmnd *sc; /* associated SCSI cmd*/ 129 struct scsi_cmnd *sc; /* associated SCSI cmd*/
115 struct iscsi_conn *conn; /* used connection */ 130 struct iscsi_conn *conn; /* used connection */
116 131
@@ -121,6 +136,11 @@ struct iscsi_task {
121 void *dd_data; /* driver/transport data */ 136 void *dd_data; /* driver/transport data */
122}; 137};
123 138
139static inline int iscsi_task_has_unsol_data(struct iscsi_task *task)
140{
141 return task->unsol_r2t.data_length > task->unsol_r2t.sent;
142}
143
124static inline void* iscsi_next_hdr(struct iscsi_task *task) 144static inline void* iscsi_next_hdr(struct iscsi_task *task)
125{ 145{
126 return (void*)task->hdr + task->hdr_len; 146 return (void*)task->hdr + task->hdr_len;
@@ -376,8 +396,9 @@ extern void iscsi_suspend_tx(struct iscsi_conn *conn);
376 * pdu and task processing 396 * pdu and task processing
377 */ 397 */
378extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *); 398extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *);
379extern void iscsi_prep_unsolicit_data_pdu(struct iscsi_task *, 399extern void iscsi_prep_data_out_pdu(struct iscsi_task *task,
380 struct iscsi_data *hdr); 400 struct iscsi_r2t_info *r2t,
401 struct iscsi_data *hdr);
381extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *, 402extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
382 char *, uint32_t); 403 char *, uint32_t);
383extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *, 404extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
new file mode 100644
index 000000000000..83e32f6d7859
--- /dev/null
+++ b/include/scsi/libiscsi_tcp.h
@@ -0,0 +1,132 @@
1/*
2 * iSCSI over TCP/IP Data-Path lib
3 *
4 * Copyright (C) 2008 Mike Christie
5 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
6 * maintained by open-iscsi@googlegroups.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
10 * by 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, 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 * See the file COPYING included with this distribution for more details.
19 */
20
21#ifndef LIBISCSI_TCP_H
22#define LIBISCSI_TCP_H
23
24#include <scsi/libiscsi.h>
25
26struct iscsi_tcp_conn;
27struct iscsi_segment;
28struct sk_buff;
29struct hash_desc;
30
31typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *,
32 struct iscsi_segment *);
33
34struct iscsi_segment {
35 unsigned char *data;
36 unsigned int size;
37 unsigned int copied;
38 unsigned int total_size;
39 unsigned int total_copied;
40
41 struct hash_desc *hash;
42 unsigned char recv_digest[ISCSI_DIGEST_SIZE];
43 unsigned char digest[ISCSI_DIGEST_SIZE];
44 unsigned int digest_len;
45
46 struct scatterlist *sg;
47 void *sg_mapped;
48 unsigned int sg_offset;
49
50 iscsi_segment_done_fn_t *done;
51};
52
53/* Socket connection recieve helper */
54struct iscsi_tcp_recv {
55 struct iscsi_hdr *hdr;
56 struct iscsi_segment segment;
57
58 /* Allocate buffer for BHS + AHS */
59 uint32_t hdr_buf[64];
60
61 /* copied and flipped values */
62 int datalen;
63};
64
65struct iscsi_tcp_conn {
66 struct iscsi_conn *iscsi_conn;
67 void *dd_data;
68 int stop_stage; /* conn_stop() flag: *
69 * stop to recover, *
70 * stop to terminate */
71 /* control data */
72 struct iscsi_tcp_recv in; /* TCP receive context */
73 /* CRC32C (Rx) LLD should set this is they do not offload */
74 struct hash_desc *rx_hash;
75};
76
77struct iscsi_tcp_task {
78 uint32_t exp_datasn; /* expected target's R2TSN/DataSN */
79 int data_offset;
80 struct iscsi_r2t_info *r2t; /* in progress solict R2T */
81 struct iscsi_pool r2tpool;
82 struct kfifo *r2tqueue;
83 void *dd_data;
84};
85
86enum {
87 ISCSI_TCP_SEGMENT_DONE, /* curr seg has been processed */
88 ISCSI_TCP_SKB_DONE, /* skb is out of data */
89 ISCSI_TCP_CONN_ERR, /* iscsi layer has fired a conn err */
90 ISCSI_TCP_SUSPENDED, /* conn is suspended */
91};
92
93extern void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn);
94extern int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
95 unsigned int offset, bool offloaded, int *status);
96extern void iscsi_tcp_cleanup_task(struct iscsi_task *task);
97extern int iscsi_tcp_task_init(struct iscsi_task *task);
98extern int iscsi_tcp_task_xmit(struct iscsi_task *task);
99
100/* segment helpers */
101extern int iscsi_tcp_recv_segment_is_hdr(struct iscsi_tcp_conn *tcp_conn);
102extern int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
103 struct iscsi_segment *segment, int recv,
104 unsigned copied);
105extern void iscsi_tcp_segment_unmap(struct iscsi_segment *segment);
106
107extern void iscsi_segment_init_linear(struct iscsi_segment *segment,
108 void *data, size_t size,
109 iscsi_segment_done_fn_t *done,
110 struct hash_desc *hash);
111extern int
112iscsi_segment_seek_sg(struct iscsi_segment *segment,
113 struct scatterlist *sg_list, unsigned int sg_count,
114 unsigned int offset, size_t size,
115 iscsi_segment_done_fn_t *done, struct hash_desc *hash);
116
117/* digest helpers */
118extern void iscsi_tcp_dgst_header(struct hash_desc *hash, const void *hdr,
119 size_t hdrlen,
120 unsigned char digest[ISCSI_DIGEST_SIZE]);
121extern struct iscsi_cls_conn *
122iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
123 uint32_t conn_idx);
124extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn);
125
126/* misc helpers */
127extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session);
128extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session);
129
130extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn,
131 struct iscsi_stats *stats);
132#endif /* LIBISCSI_TCP_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index a37a8148a310..01a4c58f8bad 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -159,8 +159,6 @@ struct scsi_device {
159 atomic_t iodone_cnt; 159 atomic_t iodone_cnt;
160 atomic_t ioerr_cnt; 160 atomic_t ioerr_cnt;
161 161
162 int timeout;
163
164 struct device sdev_gendev, 162 struct device sdev_gendev,
165 sdev_dev; 163 sdev_dev;
166 164
@@ -367,10 +365,11 @@ extern int scsi_is_target_device(const struct device *);
367extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, 365extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
368 int data_direction, void *buffer, unsigned bufflen, 366 int data_direction, void *buffer, unsigned bufflen,
369 unsigned char *sense, int timeout, int retries, 367 unsigned char *sense, int timeout, int retries,
370 int flag); 368 int flag, int *resid);
371extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, 369extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
372 int data_direction, void *buffer, unsigned bufflen, 370 int data_direction, void *buffer, unsigned bufflen,
373 struct scsi_sense_hdr *, int timeout, int retries); 371 struct scsi_sense_hdr *, int timeout, int retries,
372 int *resid);
374extern int scsi_execute_async(struct scsi_device *sdev, 373extern int scsi_execute_async(struct scsi_device *sdev,
375 const unsigned char *cmd, int cmd_len, int data_direction, 374 const unsigned char *cmd, int cmd_len, int data_direction,
376 void *buffer, unsigned bufflen, int use_sg, 375 void *buffer, unsigned bufflen, int use_sg,
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index c667cc396545..b50aabe2861e 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -113,10 +113,18 @@ struct iscsi_transport {
113 char *data, uint32_t data_size); 113 char *data, uint32_t data_size);
114 void (*get_stats) (struct iscsi_cls_conn *conn, 114 void (*get_stats) (struct iscsi_cls_conn *conn,
115 struct iscsi_stats *stats); 115 struct iscsi_stats *stats);
116
116 int (*init_task) (struct iscsi_task *task); 117 int (*init_task) (struct iscsi_task *task);
117 int (*xmit_task) (struct iscsi_task *task); 118 int (*xmit_task) (struct iscsi_task *task);
118 void (*cleanup_task) (struct iscsi_conn *conn, 119 void (*cleanup_task) (struct iscsi_task *task);
119 struct iscsi_task *task); 120
121 int (*alloc_pdu) (struct iscsi_task *task, uint8_t opcode);
122 int (*xmit_pdu) (struct iscsi_task *task);
123 int (*init_pdu) (struct iscsi_task *task, unsigned int offset,
124 unsigned int count);
125 void (*parse_pdu_itt) (struct iscsi_conn *conn, itt_t itt,
126 int *index, int *age);
127
120 void (*session_recovery_timedout) (struct iscsi_cls_session *session); 128 void (*session_recovery_timedout) (struct iscsi_cls_session *session);
121 struct iscsi_endpoint *(*ep_connect) (struct sockaddr *dst_addr, 129 struct iscsi_endpoint *(*ep_connect) (struct sockaddr *dst_addr,
122 int non_blocking); 130 int non_blocking);