blob: f2b5a363bb844c12aa586370679ee098ebac9ed0 [file] [log] [blame]
Christof Schmitt34c2b712010-02-17 11:18:59 +01001/*
2 * zfcp device driver
3 *
4 * Header file for zfcp qdio interface
5 *
6 * Copyright IBM Corporation 2010
7 */
8
9#ifndef ZFCP_QDIO_H
10#define ZFCP_QDIO_H
11
12#include <asm/qdio.h>
13
Christof Schmitt68322982010-04-30 18:09:33 +020014#define ZFCP_QDIO_SBALE_LEN PAGE_SIZE
15
Christof Schmitt34c2b712010-02-17 11:18:59 +010016/**
17 * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count
18 * @sbal: qdio buffers
19 * @first: index of next free buffer in queue
20 * @count: number of free buffers in queue
21 */
22struct zfcp_qdio_queue {
23 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
24 u8 first;
25 atomic_t count;
26};
27
28/**
29 * struct zfcp_qdio - basic qdio data structure
30 * @resp_q: response queue
31 * @req_q: request queue
32 * @stat_lock: lock to protect req_q_util and req_q_time
33 * @req_q_lock: lock to serialize access to request queue
34 * @req_q_time: time of last fill level change
35 * @req_q_util: used for accounting
36 * @req_q_full: queue full incidents
37 * @req_q_wq: used to wait for SBAL availability
38 * @adapter: adapter used in conjunction with this qdio structure
39 */
40struct zfcp_qdio {
41 struct zfcp_qdio_queue resp_q;
42 struct zfcp_qdio_queue req_q;
43 spinlock_t stat_lock;
44 spinlock_t req_q_lock;
45 unsigned long long req_q_time;
46 u64 req_q_util;
47 atomic_t req_q_full;
48 wait_queue_head_t req_q_wq;
49 struct zfcp_adapter *adapter;
50};
51
52/**
53 * struct zfcp_qdio_req - qdio queue related values for a request
54 * @sbal_number: number of free sbals
55 * @sbal_first: first sbal for this request
56 * @sbal_last: last sbal for this request
57 * @sbal_limit: last possible sbal for this request
58 * @sbale_curr: current sbale at creation of this request
59 * @sbal_response: sbal used in interrupt
60 * @qdio_outb_usage: usage of outbound queue
61 * @qdio_inb_usage: usage of inbound queue
62 */
63struct zfcp_qdio_req {
64 u8 sbal_number;
65 u8 sbal_first;
66 u8 sbal_last;
67 u8 sbal_limit;
68 u8 sbale_curr;
69 u8 sbal_response;
70 u16 qdio_outb_usage;
71 u16 qdio_inb_usage;
72};
73
74/**
75 * zfcp_qdio_sbale - return pointer to sbale in qdio queue
76 * @q: queue where to find sbal
77 * @sbal_idx: sbal index in queue
78 * @sbale_idx: sbale index in sbal
79 */
80static inline struct qdio_buffer_element *
81zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx)
82{
83 return &q->sbal[sbal_idx]->element[sbale_idx];
84}
85
86/**
87 * zfcp_qdio_sbale_req - return pointer to sbale on req_q for a request
88 * @qdio: pointer to struct zfcp_qdio
89 * @q_rec: pointer to struct zfcp_qdio_req
90 * Returns: pointer to qdio_buffer_element (sbale) structure
91 */
92static inline struct qdio_buffer_element *
93zfcp_qdio_sbale_req(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
94{
95 return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, 0);
96}
97
98/**
99 * zfcp_qdio_sbale_curr - return current sbale on req_q for a request
100 * @qdio: pointer to struct zfcp_qdio
101 * @fsf_req: pointer to struct zfcp_fsf_req
102 * Returns: pointer to qdio_buffer_element (sbale) structure
103 */
104static inline struct qdio_buffer_element *
105zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
106{
107 return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last,
108 q_req->sbale_curr);
109}
110
111#endif /* ZFCP_QDIO_H */