OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [linux/] [nbd.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * 1999 Copyright (C) Pavel Machek, pavel@ucw.cz. This code is GPL.
3
 * 1999/11/04 Copyright (C) 1999 VMware, Inc. (Regis "HPReg" Duchesne)
4
 *            Made nbd_end_request() use the io_request_lock
5
 * 2001 Copyright (C) Steven Whitehouse
6
 *            New nbd_end_request() for compatibility with new linux block
7
 *            layer code.
8
 */
9
 
10
#ifndef LINUX_NBD_H
11
#define LINUX_NBD_H
12
 
13
#define NBD_SET_SOCK    _IO( 0xab, 0 )
14
#define NBD_SET_BLKSIZE _IO( 0xab, 1 )
15
#define NBD_SET_SIZE    _IO( 0xab, 2 )
16
#define NBD_DO_IT       _IO( 0xab, 3 )
17
#define NBD_CLEAR_SOCK  _IO( 0xab, 4 )
18
#define NBD_CLEAR_QUE   _IO( 0xab, 5 )
19
#define NBD_PRINT_DEBUG _IO( 0xab, 6 )
20
#define NBD_SET_SIZE_BLOCKS     _IO( 0xab, 7 )
21
#define NBD_DISCONNECT  _IO( 0xab, 8 )
22
 
23
#ifdef MAJOR_NR
24
 
25
#include <linux/locks.h>
26
#include <asm/semaphore.h>
27
 
28
#define LOCAL_END_REQUEST
29
 
30
#include <linux/blk.h>
31
 
32
#ifdef PARANOIA
33
extern int requests_in;
34
extern int requests_out;
35
#endif
36
 
37
static void
38
nbd_end_request(struct request *req)
39
{
40
        struct buffer_head *bh;
41
        unsigned nsect;
42
        unsigned long flags;
43
        int uptodate = (req->errors == 0) ? 1 : 0;
44
 
45
#ifdef PARANOIA
46
        requests_out++;
47
#endif
48
        spin_lock_irqsave(&io_request_lock, flags);
49
        while((bh = req->bh) != NULL) {
50
                nsect = bh->b_size >> 9;
51
                blk_finished_io(nsect);
52
                req->bh = bh->b_reqnext;
53
                bh->b_reqnext = NULL;
54
                bh->b_end_io(bh, uptodate);
55
        }
56
        blkdev_release_request(req);
57
        spin_unlock_irqrestore(&io_request_lock, flags);
58
}
59
 
60
#define MAX_NBD 128
61
 
62
struct nbd_device {
63
        int refcnt;
64
        int flags;
65
        int harderror;          /* Code of hard error                   */
66
#define NBD_READ_ONLY 0x0001
67
#define NBD_WRITE_NOCHK 0x0002
68
        struct socket * sock;
69
        struct file * file;             /* If == NULL, device is not ready, yet */
70
        int magic;                      /* FIXME: not if debugging is off       */
71
        spinlock_t queue_lock;
72
        struct list_head queue_head;    /* Requests are added here...                   */
73
        struct semaphore tx_lock;
74
};
75
#endif
76
 
77
/* This now IS in some kind of include file...  */
78
 
79
/* These are send over network in request/reply magic field */
80
 
81
#define NBD_REQUEST_MAGIC 0x25609513
82
#define NBD_REPLY_MAGIC 0x67446698
83
/* Do *not* use magics: 0x12560953 0x96744668. */
84
 
85
/*
86
 * This is packet used for communication between client and
87
 * server. All data are in network byte order.
88
 */
89
struct nbd_request {
90
        u32 magic;
91
        u32 type;       /* == READ || == WRITE  */
92
        char handle[8];
93
        u64 from;
94
        u32 len;
95
}
96
#ifdef __GNUC__
97
        __attribute__ ((packed))
98
#endif
99
;
100
 
101
struct nbd_reply {
102
        u32 magic;
103
        u32 error;              /* 0 = ok, else error   */
104
        char handle[8];         /* handle you got from request  */
105
};
106
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.