#ifndef _G_GATE_H_
#define _G_GATE_H_
#include <sys/param.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/queue.h>
#include <geom/geom.h>
#define G_GATE_CLASS_NAME "GATE"
#define G_GATE_PROVIDER_NAME "ggate"
#define G_GATE_MOD_NAME "ggate"
#define G_GATE_CTL_NAME "ggctl"
#define G_GATE_VERSION 3
#define G_GATE_MAX_QUEUE_SIZE 4096
#define G_GATE_FLAG_READONLY 0x0001
#define G_GATE_FLAG_WRITEONLY 0x0002
#define G_GATE_FLAG_DESTROY 0x1000
#define G_GATE_USERFLAGS (G_GATE_FLAG_READONLY | G_GATE_FLAG_WRITEONLY)
#define G_GATE_UNIT_AUTO (-1)
#define G_GATE_NAME_GIVEN (-2)
#define G_GATE_CMD_CREATE _IOWR('m', 0, struct g_gate_ctl_create)
#define G_GATE_CMD_MODIFY _IOWR('m', 1, struct g_gate_ctl_modify)
#define G_GATE_CMD_DESTROY _IOWR('m', 2, struct g_gate_ctl_destroy)
#define G_GATE_CMD_CANCEL _IOWR('m', 3, struct g_gate_ctl_cancel)
#define G_GATE_CMD_START _IOWR('m', 4, struct g_gate_ctl_io)
#define G_GATE_CMD_DONE _IOWR('m', 5, struct g_gate_ctl_io)
#define G_GATE_INFOSIZE 2048
#ifdef _KERNEL
struct g_gate_softc {
char *sc_name;
int sc_unit;
int sc_ref;
struct g_provider *sc_provider;
uint32_t sc_flags;
struct bio_queue_head sc_inqueue;
struct bio_queue_head sc_outqueue;
struct mtx sc_queue_mtx;
uint32_t sc_queue_count;
uint32_t sc_queue_size;
u_int sc_timeout;
struct g_consumer *sc_readcons;
off_t sc_readoffset;
struct callout sc_callout;
uintptr_t sc_seq;
LIST_ENTRY(g_gate_softc) sc_next;
char sc_info[G_GATE_INFOSIZE];
struct mtx sc_read_mtx;
};
#define G_GATE_DEBUG(lvl, ...) \
_GEOM_DEBUG("GEOM_GATE", g_gate_debug, (lvl), NULL, __VA_ARGS__)
#define G_GATE_LOGREQ(lvl, bp, ...) \
_GEOM_DEBUG("GEOM_GATE", g_gate_debug, (lvl), (bp), __VA_ARGS__)
#endif
struct g_gate_ctl_create {
u_int gctl_version;
off_t gctl_mediasize;
u_int gctl_sectorsize;
u_int gctl_flags;
u_int gctl_maxcount;
u_int gctl_timeout;
char gctl_name[NAME_MAX];
char gctl_info[G_GATE_INFOSIZE];
char gctl_readprov[NAME_MAX];
off_t gctl_readoffset;
int gctl_unit;
};
#define GG_MODIFY_MEDIASIZE 0x01
#define GG_MODIFY_INFO 0x02
#define GG_MODIFY_READPROV 0x04
#define GG_MODIFY_READOFFSET 0x08
struct g_gate_ctl_modify {
u_int gctl_version;
int gctl_unit;
uint32_t gctl_modify;
off_t gctl_mediasize;
char gctl_info[G_GATE_INFOSIZE];
char gctl_readprov[NAME_MAX];
off_t gctl_readoffset;
};
struct g_gate_ctl_destroy {
u_int gctl_version;
int gctl_unit;
int gctl_force;
char gctl_name[NAME_MAX];
};
struct g_gate_ctl_cancel {
u_int gctl_version;
int gctl_unit;
uintptr_t gctl_seq;
char gctl_name[NAME_MAX];
};
struct g_gate_ctl_io {
u_int gctl_version;
int gctl_unit;
uintptr_t gctl_seq;
u_int gctl_cmd;
off_t gctl_offset;
off_t gctl_length;
void *gctl_data;
int gctl_error;
};
#endif