25 #include <linux/export.h>
27 #include <scsi/scsi.h>
34 #include <asm/cacheflush.h>
38 #if TGT_RING_SIZE < PAGE_SIZE
39 # define TGT_RING_SIZE PAGE_SIZE
42 #define TGT_RING_PAGES (TGT_RING_SIZE >> PAGE_SHIFT)
43 #define TGT_EVENT_PER_PAGE (PAGE_SIZE / sizeof(struct tgt_event))
44 #define TGT_MAX_EVENTS (TGT_EVENT_PER_PAGE * TGT_RING_PAGES)
56 static inline void tgt_ring_idx_inc(
struct tgt_ring *
ring)
84 ev = tgt_head_event(ring, ring->
tr_idx);
86 tgt_ring_idx_inc(ring);
90 spin_unlock_irqrestore(&ring->
tr_lock, flags);
95 memcpy(ev, p,
sizeof(*ev));
114 memset(&ev, 0,
sizeof(ev));
117 ev.
p.
cmd_req.data_len = scsi_bufflen(cmd);
125 (
unsigned long long) ev.
p.
cmd_req.tag);
129 eprintk(
"tx buf is full, could not send\n");
140 memset(&ev, 0,
sizeof(ev));
147 (
unsigned long long) ev.
p.
cmd_req.tag,
152 eprintk(
"tx buf is full, could not send\n");
163 memset(&ev, 0,
sizeof(ev));
171 dprintk(
"%d %x %llx %llx\n", host_no,
function, (
unsigned long long) tag,
176 eprintk(
"tx buf is full, could not send\n");
187 memset(&ev, 0,
sizeof(ev));
195 dprintk(
"%d %x %llx\n", host_no,
function, (
unsigned long long)itn_id);
199 eprintk(
"tx buf is full, could not send\n");
204 static int event_recv_msg(
struct tgt_event *ev)
208 switch (ev->
hdr.type) {
240 size_t count, loff_t * ppos)
246 ev = tgt_head_event(ring, ring->
tr_idx);
253 tgt_ring_idx_inc(ring);
266 unsigned int mask = 0;
269 poll_wait(file, &tgt_poll_wait, wait);
274 ev = tgt_head_event(ring, idx);
278 spin_unlock_irqrestore(&ring->
tr_lock, flags);
299 static int tgt_mmap(
struct file *filp,
struct vm_area_struct *vma)
308 eprintk(
"mmap size must be %lu, not %lu \n",
314 err = uspace_ring_map(vma, addr, &
tx_ring);
322 static int tgt_open(
struct inode *
inode,
struct file *file)
344 static void tgt_ring_exit(
struct tgt_ring *ring)
352 static int tgt_ring_init(
struct tgt_ring *ring)