aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/drbd_nl.h
blob: 5f042810a56c3b265fe7f4bd0e6fa2acc6e3aa4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
   PAKET( name,
	  TYPE ( pn, pr, member )
	  ...
   )

   You may never reissue one of the pn arguments
*/

#if !defined(NL_PACKET) || !defined(NL_STRING) || !defined(NL_INTEGER) || !defined(NL_BIT) || !defined(NL_INT64)
#error "The macros NL_PACKET, NL_STRING, NL_INTEGER, NL_INT64 and NL_BIT needs to be defined"
#endif

NL_PACKET(primary, 1,
       NL_BIT(		1,	T_MAY_IGNORE,	primary_force)
)

NL_PACKET(secondary, 2, )

NL_PACKET(disk_conf, 3,
	NL_INT64(	2,	T_MAY_IGNORE,	disk_size)
	NL_STRING(	3,	T_MANDATORY,	backing_dev,	128)
	NL_STRING(	4,	T_MANDATORY,	meta_dev,	128)
	NL_INTEGER(	5,	T_MANDATORY,	meta_dev_idx)
	NL_INTEGER(	6,	T_MAY_IGNORE,	on_io_error)
	NL_INTEGER(	7,	T_MAY_IGNORE,	fencing)
	NL_BIT(		37,	T_MAY_IGNORE,	use_bmbv)
	NL_BIT(		53,	T_MAY_IGNORE,	no_disk_flush)
	NL_BIT(		54,	T_MAY_IGNORE,	no_md_flush)
	  /*  55 max_bio_size was available in 8.2.6rc2 */
	NL_INTEGER(	56,	T_MAY_IGNORE,	max_bio_bvecs)
	NL_BIT(		57,	T_MAY_IGNORE,	no_disk_barrier)
	NL_BIT(		58,	T_MAY_IGNORE,	no_disk_drain)
)

NL_PACKET(detach, 4, )

NL_PACKET(net_conf, 5,
	NL_STRING(	8,	T_MANDATORY,	my_addr,	128)
	NL_STRING(	9,	T_MANDATORY,	peer_addr,	128)
	NL_STRING(	10,	T_MAY_IGNORE,	shared_secret,	SHARED_SECRET_MAX)
	NL_STRING(	11,	T_MAY_IGNORE,	cram_hmac_alg,	SHARED_SECRET_MAX)
	NL_STRING(	44,	T_MAY_IGNORE,	integrity_alg,	SHARED_SECRET_MAX)
	NL_INTEGER(	14,	T_MAY_IGNORE,	timeout)
	NL_INTEGER(	15,	T_MANDATORY,	wire_protocol)
	NL_INTEGER(	16,	T_MAY_IGNORE,	try_connect_int)
	NL_INTEGER(	17,	T_MAY_IGNORE,	ping_int)
	NL_INTEGER(	18,	T_MAY_IGNORE,	max_epoch_size)
	NL_INTEGER(	19,	T_MAY_IGNORE,	max_buffers)
	NL_INTEGER(	20,	T_MAY_IGNORE,	unplug_watermark)
	NL_INTEGER(	21,	T_MAY_IGNORE,	sndbuf_size)
	NL_INTEGER(	22,	T_MAY_IGNORE,	ko_count)
	NL_INTEGER(	24,	T_MAY_IGNORE,	after_sb_0p)
	NL_INTEGER(	25,	T_MAY_IGNORE,	after_sb_1p)
	NL_INTEGER(	26,	T_MAY_IGNORE,	after_sb_2p)
	NL_INTEGER(	39,	T_MAY_IGNORE,	rr_conflict)
	NL_INTEGER(	40,	T_MAY_IGNORE,	ping_timeo)
	NL_INTEGER(	67,	T_MAY_IGNORE,	rcvbuf_size)
	  /* 59 addr_family was available in GIT, never released */
	NL_BIT(		60,	T_MANDATORY,	mind_af)
	NL_BIT(		27,	T_MAY_IGNORE,	want_lose)
	NL_BIT(		28,	T_MAY_IGNORE,	two_primaries)
	NL_BIT(		41,	T_MAY_IGNORE,	always_asbp)
	NL_BIT(		61,	T_MAY_IGNORE,	no_cork)
	NL_BIT(		62,	T_MANDATORY,	auto_sndbuf_size)
	NL_BIT(		70,	T_MANDATORY,	dry_run)
)

NL_PACKET(disconnect, 6, )

NL_PACKET(resize, 7,
	NL_INT64(		29,	T_MAY_IGNORE,	resize_size)
	NL_BIT(			68,	T_MAY_IGNORE,	resize_force)
	NL_BIT(			69,	T_MANDATORY,	no_resync)
)

NL_PACKET(syncer_conf, 8,
	NL_INTEGER(	30,	T_MAY_IGNORE,	rate)
	NL_INTEGER(	31,	T_MAY_IGNORE,	after)
	NL_INTEGER(	32,	T_MAY_IGNORE,	al_extents)
/*	NL_INTEGER(     71,	T_MAY_IGNORE,	dp_volume)
 *	NL_INTEGER(     72,	T_MAY_IGNORE,	dp_interval)
 *	NL_INTEGER(     73,	T_MAY_IGNORE,	throttle_th)
 *	NL_INTEGER(     74,	T_MAY_IGNORE,	hold_off_th)
 * feature will be reimplemented differently with 8.3.9 */
	NL_STRING(      52,     T_MAY_IGNORE,   verify_alg,     SHARED_SECRET_MAX)
	NL_STRING(      51,     T_MAY_IGNORE,   cpu_mask,       32)
	NL_STRING(	64,	T_MAY_IGNORE,	csums_alg,	SHARED_SECRET_MAX)
	NL_BIT(         65,     T_MAY_IGNORE,   use_rle)
)

NL_PACKET(invalidate, 9, )
NL_PACKET(invalidate_peer, 10, )
NL_PACKET(pause_sync, 11, )
NL_PACKET(resume_sync, 12, )
NL_PACKET(suspend_io, 13, )
NL_PACKET(resume_io, 14, )
NL_PACKET(outdate, 15, )
NL_PACKET(get_config, 16, )
NL_PACKET(get_state, 17,
	NL_INTEGER(	33,	T_MAY_IGNORE,	state_i)
)

NL_PACKET(get_uuids, 18,
	NL_STRING(	34,	T_MAY_IGNORE,	uuids,	(UI_SIZE*sizeof(__u64)))
	NL_INTEGER(	35,	T_MAY_IGNORE,	uuids_flags)
)

NL_PACKET(get_timeout_flag, 19,
	NL_BIT(		36,	T_MAY_IGNORE,	use_degraded)
)

NL_PACKET(call_helper, 20,
	NL_STRING(	38,	T_MAY_IGNORE,	helper,		32)
)

/* Tag nr 42 already allocated in drbd-8.1 development. */

NL_PACKET(sync_progress, 23,
	NL_INTEGER(	43,	T_MAY_IGNORE,	sync_progress)
)

NL_PACKET(dump_ee, 24,
	NL_STRING(	45,	T_MAY_IGNORE,	dump_ee_reason, 32)
	NL_STRING(	46,	T_MAY_IGNORE,	seen_digest, SHARED_SECRET_MAX)
	NL_STRING(	47,	T_MAY_IGNORE,	calc_digest, SHARED_SECRET_MAX)
	NL_INT64(	48,	T_MAY_IGNORE,	ee_sector)
	NL_INT64(	49,	T_MAY_IGNORE,	ee_block_id)
	NL_STRING(	50,	T_MAY_IGNORE,	ee_data,	32 << 10)
)

NL_PACKET(start_ov, 25,
	NL_INT64(	66,	T_MAY_IGNORE,	start_sector)
)

NL_PACKET(new_c_uuid, 26,
       NL_BIT(		63,	T_MANDATORY,	clear_bm)
)

#undef NL_PACKET
#undef NL_INTEGER
#undef NL_INT64
#undef NL_BIT
#undef NL_STRING

VBC Config */ }; #define CG14_CCR_ENABLE 0x04 #define CG14_CCR_SELECT 0x02 /* HW/Full screen */ struct cg14_cursor { u32 cpl0[32]; /* Enable plane 0 */ u32 cpl1[32]; /* Color selection plane */ u8 ccr; /* Cursor Control Reg */ u8 xxx0[3]; u16 cursx; /* Cursor x,y position */ u16 cursy; /* Cursor x,y position */ u32 color0; u32 color1; u32 xxx1[0x1bc]; u32 cpl0i[32]; /* Enable plane 0 autoinc */ u32 cpl1i[32]; /* Color selection autoinc */ }; struct cg14_dac { u8 addr; /* Address Register */ u8 xxx0[255]; u8 glut; /* Gamma table */ u8 xxx1[255]; u8 select; /* Register Select */ u8 xxx2[255]; u8 mode; /* Mode Register */ }; struct cg14_xlut{ u8 x_xlut [256]; u8 x_xlutd [256]; u8 xxx0[0x600]; u8 x_xlut_inc [256]; u8 x_xlutd_inc [256]; }; /* Color look up table (clut) */ /* Each one of these arrays hold the color lookup table (for 256 * colors) for each MDI page (I assume then there should be 4 MDI * pages, I still wonder what they are. I have seen NeXTStep split * the screen in four parts, while operating in 24 bits mode. Each * integer holds 4 values: alpha value (transparency channel, thanks * go to John Stone (johns@umr.edu) from OpenBSD), red, green and blue * * I currently use the clut instead of the Xlut */ struct cg14_clut { u32 c_clut [256]; u32 c_clutd [256]; /* i wonder what the 'd' is for */ u32 c_clut_inc [256]; u32 c_clutd_inc [256]; }; #define CG14_MMAP_ENTRIES 16 struct cg14_par { spinlock_t lock; struct cg14_regs __iomem *regs; struct cg14_clut __iomem *clut; struct cg14_cursor __iomem *cursor; u32 flags; #define CG14_FLAG_BLANKED 0x00000001 unsigned long iospace; struct sbus_mmap_map mmap_map[CG14_MMAP_ENTRIES]; int mode; int ramsize; }; static void __cg14_reset(struct cg14_par *par) { struct cg14_regs __iomem *regs = par->regs; u8 val; val = sbus_readb(&regs->mcr); val &= ~(CG14_MCR_PIXMODE_MASK); sbus_writeb(val, &regs->mcr); } static int cg14_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { struct cg14_par *par = (struct cg14_par *) info->par; unsigned long flags; /* We just use this to catch switches out of * graphics mode. */ spin_lock_irqsave(&par->lock, flags); __cg14_reset(par); spin_unlock_irqrestore(&par->lock, flags); if (var->xoffset || var->yoffset || var->vmode) return -EINVAL; return 0; } /** * cg14_setcolreg - Optional function. Sets a color register. * @regno: boolean, 0 copy local, 1 get_user() function * @red: frame buffer colormap structure * @green: The green value which can be up to 16 bits wide * @blue: The blue value which can be up to 16 bits wide. * @transp: If supported the alpha value which can be up to 16 bits wide. * @info: frame buffer info structure */ static int cg14_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { struct cg14_par *par = (struct cg14_par *) info->par; struct cg14_clut __iomem *clut = par->clut; unsigned long flags; u32 val; if (regno >= 256) return 1; red >>= 8; green >>= 8; blue >>= 8; val = (red | (green << 8) | (blue << 16)); spin_lock_irqsave(&par->lock, flags); sbus_writel(val, &clut->c_clut[regno]); spin_unlock_irqrestore(&par->lock, flags); return 0; } static int cg14_mmap(struct fb_info *info, struct vm_area_struct *vma) { struct cg14_par *par = (struct cg14_par *) info->par; return sbusfb_mmap_helper(par->mmap_map, info->fix.smem_start, info->fix.smem_len, par->iospace, vma); } static int cg14_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { struct cg14_par *par = (struct cg14_par *) info->par; struct cg14_regs __iomem *regs = par->regs; struct mdi_cfginfo kmdi, __user *mdii; unsigned long flags; int cur_mode, mode, ret = 0; switch (cmd) { case MDI_RESET: spin_lock_irqsave(&par->lock, flags); __cg14_reset(par); spin_unlock_irqrestore(&par->lock, flags); break; case MDI_GET_CFGINFO: memset(&kmdi, 0, sizeof(kmdi)); spin_lock_irqsave(&par->lock, flags); kmdi.mdi_type = FBTYPE_MDICOLOR; kmdi.mdi_height = info->var.yres; kmdi.mdi_width = info->var.xres; kmdi.mdi_mode = par->mode; kmdi.mdi_pixfreq = 72; /* FIXME */ kmdi.mdi_size = par->ramsize; spin_unlock_irqrestore(&par->lock, flags); mdii = (struct mdi_cfginfo __user *) arg; if (copy_to_user(mdii, &kmdi, sizeof(kmdi))) ret = -EFAULT; break; case MDI_SET_PIXELMODE: if (get_user(mode, (int __user *) arg)) { ret = -EFAULT; break; } spin_lock_irqsave(&par->lock, flags); cur_mode = sbus_readb(&regs->mcr); cur_mode &= ~CG14_MCR_PIXMODE_MASK; switch(mode) { case MDI_32_PIX: cur_mode |= (CG14_MCR_PIXMODE_32 << CG14_MCR_PIXMODE_SHIFT); break; case MDI_16_PIX: cur_mode |= (CG14_MCR_PIXMODE_16 << CG14_MCR_PIXMODE_SHIFT); break; case MDI_8_PIX: break; default: ret = -ENOSYS; break; }; if (!ret) { sbus_writeb(cur_mode, &regs->mcr); par->mode = mode; } spin_unlock_irqrestore(&par->lock, flags); break; default: ret = sbusfb_ioctl_helper(cmd, arg, info, FBTYPE_MDICOLOR, 8, info->fix.smem_len); break; }; return ret; } /* * Initialisation */ static void __devinit cg14_init_fix(struct fb_info *info, int linebytes, struct device_node *dp) { const char *name = dp->name; strlcpy(info->fix.id, name, sizeof(info->fix.id)); info->fix.type = FB_TYPE_PACKED_PIXELS; info->fix.visual = FB_VISUAL_PSEUDOCOLOR; info->fix.line_length = linebytes; info->fix.accel = FB_ACCEL_SUN_CG14; } static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] __devinitdata = { { .voff = CG14_REGS, .poff = 0x80000000, .size = 0x1000 }, { .voff = CG14_XLUT, .poff = 0x80003000, .size = 0x1000 }, { .voff = CG14_CLUT1, .poff = 0x80004000, .size = 0x1000 }, { .voff = CG14_CLUT2, .poff = 0x80005000, .size = 0x1000 }, { .voff = CG14_CLUT3, .poff = 0x80006000, .size = 0x1000 }, { .voff = CG3_MMAP_OFFSET - 0x7000, .poff = 0x80000000, .size = 0x7000 }, { .voff = CG3_MMAP_OFFSET, .poff = 0x00000000, .size = SBUS_MMAP_FBSIZE(1) }, { .voff = MDI_CURSOR_MAP, .poff = 0x80001000, .size = 0x1000 }, { .voff = MDI_CHUNKY_BGR_MAP, .poff = 0x01000000, .size = 0x400000 }, { .voff = MDI_PLANAR_X16_MAP, .poff = 0x02000000, .size = 0x200000 }, { .voff = MDI_PLANAR_C16_MAP, .poff = 0x02800000, .size = 0x200000 }, { .voff = MDI_PLANAR_X32_MAP, .poff = 0x03000000, .size = 0x100000 }, { .voff = MDI_PLANAR_B32_MAP, .poff = 0x03400000, .size = 0x100000 }, { .voff = MDI_PLANAR_G32_MAP, .poff = 0x03800000, .size = 0x100000 }, { .voff = MDI_PLANAR_R32_MAP, .poff = 0x03c00000, .size = 0x100000 }, { .size = 0 } }; static void cg14_unmap_regs(struct platform_device *op, struct fb_info *info, struct cg14_par *par) { if (par->regs) of_iounmap(&op->resource[0], par->regs, sizeof(struct cg14_regs)); if (par->clut) of_iounmap(&op->resource[0], par->clut, sizeof(struct cg14_clut)); if (par->cursor) of_iounmap(&op->resource[0], par->cursor, sizeof(struct cg14_cursor)); if (info->screen_base) of_iounmap(&op->resource[1], info->screen_base, info->fix.smem_len); } static int __devinit cg14_probe(struct platform_device *op) { struct device_node *dp = op->dev.of_node; struct fb_info *info; struct cg14_par *par; int is_8mb, linebytes, i, err; info = framebuffer_alloc(sizeof(struct cg14_par), &op->dev); err = -ENOMEM; if (!info) goto out_err; par = info->par; spin_lock_init(&par->lock); sbusfb_fill_var(&info->var, dp, 8); info->var.red.length = 8; info->var.green.length = 8; info->var.blue.length = 8; linebytes = of_getintprop_default(dp, "linebytes", info->var.xres); info->fix.smem_len = PAGE_ALIGN(linebytes * info->var.yres); if (!strcmp(dp->parent->name, "sbus") || !strcmp(dp->parent->name, "sbi")) { info->fix.smem_start = op->resource[0].start; par->iospace = op->resource[0].flags & IORESOURCE_BITS; } else { info->fix.smem_start = op->resource[1].start; par->iospace = op->resource[0].flags & IORESOURCE_BITS; } par->regs = of_ioremap(&op->resource[0], 0, sizeof(struct cg14_regs), "cg14 regs"); par->clut = of_ioremap(&op->resource[0], CG14_CLUT1, sizeof(struct cg14_clut), "cg14 clut"); par->cursor = of_ioremap(&op->resource[0], CG14_CURSORREGS, sizeof(struct cg14_cursor), "cg14 cursor"); info->screen_base = of_ioremap(&op->resource[1], 0, info->fix.smem_len, "cg14 ram"); if (!par->regs || !par->clut || !par->cursor || !info->screen_base) goto out_unmap_regs; is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) == (8 * 1024 * 1024)); BUILD_BUG_ON(sizeof(par->mmap_map) != sizeof(__cg14_mmap_map)); memcpy(&par->mmap_map, &__cg14_mmap_map, sizeof(par->mmap_map)); for (i = 0; i < CG14_MMAP_ENTRIES; i++) { struct sbus_mmap_map *map = &par->mmap_map[i]; if (!map->size) break; if (map->poff & 0x80000000) map->poff = (map->poff & 0x7fffffff) + (op->resource[0].start - op->resource[1].start); if (is_8mb && map->size >= 0x100000 && map->size <= 0x400000) map->size *= 2; } par->mode = MDI_8_PIX; par->ramsize = (is_8mb ? 0x800000 : 0x400000); info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; info->fbops = &cg14_ops; __cg14_reset(par); if (fb_alloc_cmap(&info->cmap, 256, 0)) goto out_unmap_regs; fb_set_cmap(&info->cmap, info); cg14_init_fix(info, linebytes, dp); err = register_framebuffer(info); if (err < 0) goto out_dealloc_cmap; dev_set_drvdata(&op->dev, info); printk(KERN_INFO "%s: cgfourteen at %lx:%lx, %dMB\n", dp->full_name, par->iospace, info->fix.smem_start, par->ramsize >> 20); return 0; out_dealloc_cmap: fb_dealloc_cmap(&info->cmap); out_unmap_regs: cg14_unmap_regs(op, info, par); framebuffer_release(info); out_err: return err; } static int __devexit cg14_remove(struct platform_device *op) { struct fb_info *info = dev_get_drvdata(&op->dev); struct cg14_par *par = info->par; unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); cg14_unmap_regs(op, info, par); framebuffer_release(info); dev_set_drvdata(&op->dev, NULL); return 0; } static const struct of_device_id cg14_match[] = { { .name = "cgfourteen", }, {}, }; MODULE_DEVICE_TABLE(of, cg14_match); static struct platform_driver cg14_driver = { .driver = { .name = "cg14", .owner = THIS_MODULE, .of_match_table = cg14_match, }, .probe = cg14_probe, .remove = __devexit_p(cg14_remove), }; static int __init cg14_init(void) { if (fb_get_options("cg14fb", NULL)) return -ENODEV; return platform_driver_register(&cg14_driver); } static void __exit cg14_exit(void) { platform_driver_unregister(&cg14_driver); } module_init(cg14_init); module_exit(cg14_exit); MODULE_DESCRIPTION("framebuffer driver for CGfourteen chipsets"); MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); MODULE_VERSION("2.0"); MODULE_LICENSE("GPL");