ksmbd: use f_bsize in FS_SECTOR_SIZE_INFORMATION
[linux-2.6-microblaze.git] / fs / cifsd / ksmbd_work.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *   Copyright (C) 2019 Samsung Electronics Co., Ltd.
4  */
5
6 #ifndef __KSMBD_WORK_H__
7 #define __KSMBD_WORK_H__
8
9 #include <linux/ctype.h>
10 #include <linux/workqueue.h>
11
12 struct ksmbd_conn;
13 struct ksmbd_session;
14 struct ksmbd_tree_connect;
15
16 enum {
17         KSMBD_WORK_ACTIVE = 0,
18         KSMBD_WORK_CANCELLED,
19         KSMBD_WORK_CLOSED,
20 };
21
22 /* one of these for every pending CIFS request at the connection */
23 struct ksmbd_work {
24         /* Server corresponding to this mid */
25         struct ksmbd_conn               *conn;
26         struct ksmbd_session            *sess;
27         struct ksmbd_tree_connect       *tcon;
28
29         /* Pointer to received SMB header */
30         void                            *request_buf;
31         /* Response buffer */
32         void                            *response_buf;
33
34         /* Read data buffer */
35         void                            *aux_payload_buf;
36
37         /* Next cmd hdr in compound req buf*/
38         int                             next_smb2_rcv_hdr_off;
39         /* Next cmd hdr in compound rsp buf*/
40         int                             next_smb2_rsp_hdr_off;
41
42         /*
43          * Current Local FID assigned compound response if SMB2 CREATE
44          * command is present in compound request
45          */
46         unsigned int                    compound_fid;
47         unsigned int                    compound_pfid;
48         unsigned int                    compound_sid;
49
50         const struct cred               *saved_cred;
51
52         /* Number of granted credits */
53         unsigned int                    credits_granted;
54
55         /* response smb header size */
56         unsigned int                    resp_hdr_sz;
57         unsigned int                    response_sz;
58         /* Read data count */
59         unsigned int                    aux_payload_sz;
60
61         void                            *tr_buf;
62
63         unsigned char                   state;
64         /* Multiple responses for one request e.g. SMB ECHO */
65         bool                            multiRsp:1;
66         /* No response for cancelled request */
67         bool                            send_no_response:1;
68         /* Request is encrypted */
69         bool                            encrypted:1;
70         /* Is this SYNC or ASYNC ksmbd_work */
71         bool                            syncronous:1;
72         bool                            need_invalidate_rkey:1;
73
74         unsigned int                    remote_key;
75         /* cancel works */
76         int                             async_id;
77         void                            **cancel_argv;
78         void                            (*cancel_fn)(void **argv);
79
80         struct work_struct              work;
81         /* List head at conn->requests */
82         struct list_head                request_entry;
83         /* List head at conn->async_requests */
84         struct list_head                async_request_entry;
85         struct list_head                fp_entry;
86         struct list_head                interim_entry;
87 };
88
89 #define WORK_CANCELLED(w)       ((w)->state == KSMBD_WORK_CANCELLED)
90 #define WORK_CLOSED(w)          ((w)->state == KSMBD_WORK_CLOSED)
91 #define WORK_ACTIVE(w)          ((w)->state == KSMBD_WORK_ACTIVE)
92
93 #define RESPONSE_BUF_NEXT(w)    \
94         (((w)->response_buf + (w)->next_smb2_rsp_hdr_off))
95 #define REQUEST_BUF_NEXT(w)     \
96         (((w)->request_buf + (w)->next_smb2_rcv_hdr_off))
97
98 struct ksmbd_work *ksmbd_alloc_work_struct(void);
99 void ksmbd_free_work_struct(struct ksmbd_work *work);
100
101 void ksmbd_work_pool_destroy(void);
102 int ksmbd_work_pool_init(void);
103
104 int ksmbd_workqueue_init(void);
105 void ksmbd_workqueue_destroy(void);
106 bool ksmbd_queue_work(struct ksmbd_work *work);
107
108 #endif /* __KSMBD_WORK_H__ */