1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2019 Samsung Electronics Co., Ltd.
6 #ifndef __KSMBD_WORK_H__
7 #define __KSMBD_WORK_H__
9 #include <linux/ctype.h>
10 #include <linux/workqueue.h>
14 struct ksmbd_tree_connect;
17 KSMBD_WORK_ACTIVE = 0,
24 struct list_head entry;
27 /* one of these for every pending CIFS request at the connection */
29 /* Server corresponding to this mid */
30 struct ksmbd_conn *conn;
31 struct ksmbd_session *sess;
32 struct ksmbd_tree_connect *tcon;
34 /* Pointer to received SMB header */
39 struct list_head aux_read_list;
46 /* Next cmd hdr in compound req buf*/
47 int next_smb2_rcv_hdr_off;
48 /* Next cmd hdr in compound rsp buf*/
49 int next_smb2_rsp_hdr_off;
50 /* Current cmd hdr in compound rsp buf*/
51 int curr_smb2_rsp_hdr_off;
54 * Current Local FID assigned compound response if SMB2 CREATE
55 * command is present in compound request
61 const struct cred *saved_cred;
63 /* Number of granted credits */
64 unsigned int credits_granted;
66 /* response smb header size */
67 unsigned int response_sz;
72 /* No response for cancelled request */
73 bool send_no_response:1;
74 /* Request is encrypted */
76 /* Is this SYNC or ASYNC ksmbd_work */
78 bool need_invalidate_rkey:1;
80 unsigned int remote_key;
84 void (*cancel_fn)(void **argv);
86 struct work_struct work;
87 /* List head at conn->requests */
88 struct list_head request_entry;
89 /* List head at conn->async_requests */
90 struct list_head async_request_entry;
91 struct list_head fp_entry;
92 struct list_head interim_entry;
96 * ksmbd_resp_buf_next - Get next buffer on compound response.
97 * @work: smb work containing response buffer
99 static inline void *ksmbd_resp_buf_next(struct ksmbd_work *work)
101 return work->response_buf + work->next_smb2_rsp_hdr_off + 4;
105 * ksmbd_resp_buf_curr - Get current buffer on compound response.
106 * @work: smb work containing response buffer
108 static inline void *ksmbd_resp_buf_curr(struct ksmbd_work *work)
110 return work->response_buf + work->curr_smb2_rsp_hdr_off + 4;
114 * ksmbd_req_buf_next - Get next buffer on compound request.
115 * @work: smb work containing response buffer
117 static inline void *ksmbd_req_buf_next(struct ksmbd_work *work)
119 return work->request_buf + work->next_smb2_rcv_hdr_off + 4;
122 struct ksmbd_work *ksmbd_alloc_work_struct(void);
123 void ksmbd_free_work_struct(struct ksmbd_work *work);
125 void ksmbd_work_pool_destroy(void);
126 int ksmbd_work_pool_init(void);
128 int ksmbd_workqueue_init(void);
129 void ksmbd_workqueue_destroy(void);
130 bool ksmbd_queue_work(struct ksmbd_work *work);
131 int ksmbd_iov_pin_rsp_read(struct ksmbd_work *work, void *ib, int len,
132 void *aux_buf, unsigned int aux_size);
133 int ksmbd_iov_pin_rsp(struct ksmbd_work *work, void *ib, int len);
134 int allocate_interim_rsp_buf(struct ksmbd_work *work);
135 #endif /* __KSMBD_WORK_H__ */