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,
22 /* one of these for every pending CIFS request at the connection */
24 /* Server corresponding to this mid */
25 struct ksmbd_conn *conn;
26 struct ksmbd_session *sess;
27 struct ksmbd_tree_connect *tcon;
29 /* Pointer to received SMB header */
34 /* Read data buffer */
35 void *aux_payload_buf;
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;
43 * Current Local FID assigned compound response if SMB2 CREATE
44 * command is present in compound request
50 const struct cred *saved_cred;
52 /* Number of granted credits */
53 unsigned int credits_granted;
55 /* response smb header size */
56 unsigned int resp_hdr_sz;
57 unsigned int response_sz;
59 unsigned int aux_payload_sz;
64 /* Multiple responses for one request e.g. SMB ECHO */
66 /* No response for cancelled request */
67 bool send_no_response:1;
68 /* Request is encrypted */
70 /* Is this SYNC or ASYNC ksmbd_work */
72 bool need_invalidate_rkey:1;
74 unsigned int remote_key;
78 void (*cancel_fn)(void **argv);
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;
90 * ksmbd_resp_buf_next - Get next buffer on compound response.
91 * @work: smb work containing response buffer
93 static inline void *ksmbd_resp_buf_next(struct ksmbd_work *work)
95 return work->response_buf + work->next_smb2_rsp_hdr_off;
99 * ksmbd_req_buf_next - Get next buffer on compound request.
100 * @work: smb work containing response buffer
102 static inline void *ksmbd_req_buf_next(struct ksmbd_work *work)
104 return work->request_buf + work->next_smb2_rcv_hdr_off;
107 struct ksmbd_work *ksmbd_alloc_work_struct(void);
108 void ksmbd_free_work_struct(struct ksmbd_work *work);
110 void ksmbd_work_pool_destroy(void);
111 int ksmbd_work_pool_init(void);
113 int ksmbd_workqueue_init(void);
114 void ksmbd_workqueue_destroy(void);
115 bool ksmbd_queue_work(struct ksmbd_work *work);
117 #endif /* __KSMBD_WORK_H__ */