linux/drivers/block/xen-blkback/common.h

/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation; or, when distributed
 * separately from the Linux kernel or incorporated into other
 * software packages, subject to the following license:
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this source file (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy, modify,
 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#ifndef __XEN_BLKIF__BACKEND__COMMON_H__
#define __XEN_BLKIF__BACKEND__COMMON_H__

#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/blkdev.h>
#include <linux/vmalloc.h>
#include <linux/wait.h>
#include <linux/io.h>
#include <linux/rbtree.h>
#include <asm/setup.h>
#include <asm/hypervisor.h>
#include <xen/grant_table.h>
#include <xen/page.h>
#include <xen/xenbus.h>
#include <xen/interface/io/ring.h>
#include <xen/interface/io/blkif.h>
#include <xen/interface/io/protocols.h>

extern unsigned int xen_blkif_max_ring_order;
extern unsigned int xenblk_max_queues;
/*
 * This is the maximum number of segments that would be allowed in indirect
 * requests. This value will also be passed to the frontend.
 */
#define MAX_INDIRECT_SEGMENTS

/*
 * Xen use 4K pages. The guest may use different page size (4K or 64K)
 * Number of Xen pages per segment
 */
#define XEN_PAGES_PER_SEGMENT

#define XEN_PAGES_PER_INDIRECT_FRAME
#define SEGS_PER_INDIRECT_FRAME

#define MAX_INDIRECT_PAGES
#define INDIRECT_PAGES(_segs)

/* Not a real protocol.  Used to generate ring structs which contain
 * the elements common to all protocols only.  This way we get a
 * compiler-checkable way to use common struct elements, so we can
 * avoid using switch(protocol) in a number of places.  */
struct blkif_common_request {};

/* i386 protocol version */

struct blkif_x86_32_request_rw {} __attribute__((packed));

struct blkif_x86_32_request_discard {} __attribute__((packed));

struct blkif_x86_32_request_other {} __attribute__((packed));

struct blkif_x86_32_request_indirect {} __attribute__((packed));

struct blkif_x86_32_request {} __attribute__((packed));

/* x86_64 protocol version */

struct blkif_x86_64_request_rw {} __attribute__((packed));

struct blkif_x86_64_request_discard {} __attribute__((packed));

struct blkif_x86_64_request_other {} __attribute__((packed));

struct blkif_x86_64_request_indirect {} __attribute__((packed));

struct blkif_x86_64_request {} __attribute__((packed));

DEFINE_RING_TYPES(blkif_common, struct blkif_common_request,
		  struct blkif_response);
DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request,
		  struct blkif_response __packed);
DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request,
		  struct blkif_response);

blkif_back_rings;

enum blkif_protocol {};

/*
 * Default protocol if the frontend doesn't specify one.
 */
#ifdef CONFIG_X86
#define BLKIF_PROTOCOL_DEFAULT
#else
#define BLKIF_PROTOCOL_DEFAULT
#endif

struct xen_vbd {};

struct backend_info;

/* Number of requests that we can fit in a ring */
#define XEN_BLKIF_REQS_PER_PAGE

struct persistent_gnt {};

/* Per-ring information. */
struct xen_blkif_ring {};

struct xen_blkif {};

struct seg_buf {};

struct grant_page {};

/*
 * Each outstanding request that we've passed to the lower device layers has a
 * 'pending_req' allocated to it. Each buffer_head that completes decrements
 * the pendcnt towards zero. When it hits zero, the specified domain has a
 * response queued for it, with the saved 'id' passed back.
 */
struct pending_req {};


#define vbd_sz(_v)

#define xen_blkif_get(_b)
#define xen_blkif_put(_b)

struct phys_req {};

int xen_blkif_interface_init(void);
void xen_blkif_interface_fini(void);

int xen_blkif_xenbus_init(void);
void xen_blkif_xenbus_fini(void);

irqreturn_t xen_blkif_be_int(int irq, void *dev_id);
int xen_blkif_schedule(void *arg);
void xen_blkbk_free_caches(struct xen_blkif_ring *ring);

int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
			      struct backend_info *be, int state);

int xen_blkbk_barrier(struct xenbus_transaction xbt,
		      struct backend_info *be, int state);
struct xenbus_device *xen_blkbk_xenbus(struct backend_info *be);
void xen_blkbk_unmap_purged_grants(struct work_struct *work);

#endif /* __XEN_BLKIF__BACKEND__COMMON_H__ */