Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *   Copyright (C) 2019 Samsung Electronics Co., Ltd.
0004  */
0005 
0006 #ifndef __KSMBD_WORK_H__
0007 #define __KSMBD_WORK_H__
0008 
0009 #include <linux/ctype.h>
0010 #include <linux/workqueue.h>
0011 
0012 struct ksmbd_conn;
0013 struct ksmbd_session;
0014 struct ksmbd_tree_connect;
0015 
0016 enum {
0017     KSMBD_WORK_ACTIVE = 0,
0018     KSMBD_WORK_CANCELLED,
0019     KSMBD_WORK_CLOSED,
0020 };
0021 
0022 /* one of these for every pending CIFS request at the connection */
0023 struct ksmbd_work {
0024     /* Server corresponding to this mid */
0025     struct ksmbd_conn               *conn;
0026     struct ksmbd_session            *sess;
0027     struct ksmbd_tree_connect       *tcon;
0028 
0029     /* Pointer to received SMB header */
0030     void                            *request_buf;
0031     /* Response buffer */
0032     void                            *response_buf;
0033 
0034     /* Read data buffer */
0035     void                            *aux_payload_buf;
0036 
0037     /* Next cmd hdr in compound req buf*/
0038     int                             next_smb2_rcv_hdr_off;
0039     /* Next cmd hdr in compound rsp buf*/
0040     int                             next_smb2_rsp_hdr_off;
0041 
0042     /*
0043      * Current Local FID assigned compound response if SMB2 CREATE
0044      * command is present in compound request
0045      */
0046     u64             compound_fid;
0047     u64             compound_pfid;
0048     u64             compound_sid;
0049 
0050     const struct cred       *saved_cred;
0051 
0052     /* Number of granted credits */
0053     unsigned int            credits_granted;
0054 
0055     /* response smb header size */
0056     unsigned int                    resp_hdr_sz;
0057     unsigned int                    response_sz;
0058     /* Read data count */
0059     unsigned int                    aux_payload_sz;
0060 
0061     void                *tr_buf;
0062 
0063     unsigned char           state;
0064     /* Multiple responses for one request e.g. SMB ECHO */
0065     bool                            multiRsp:1;
0066     /* No response for cancelled request */
0067     bool                            send_no_response:1;
0068     /* Request is encrypted */
0069     bool                            encrypted:1;
0070     /* Is this SYNC or ASYNC ksmbd_work */
0071     bool                            syncronous:1;
0072     bool                            need_invalidate_rkey:1;
0073 
0074     unsigned int                    remote_key;
0075     /* cancel works */
0076     int                             async_id;
0077     void                            **cancel_argv;
0078     void                            (*cancel_fn)(void **argv);
0079 
0080     struct work_struct              work;
0081     /* List head at conn->requests */
0082     struct list_head                request_entry;
0083     /* List head at conn->async_requests */
0084     struct list_head                async_request_entry;
0085     struct list_head                fp_entry;
0086     struct list_head                interim_entry;
0087 };
0088 
0089 /**
0090  * ksmbd_resp_buf_next - Get next buffer on compound response.
0091  * @work: smb work containing response buffer
0092  */
0093 static inline void *ksmbd_resp_buf_next(struct ksmbd_work *work)
0094 {
0095     return work->response_buf + work->next_smb2_rsp_hdr_off + 4;
0096 }
0097 
0098 /**
0099  * ksmbd_req_buf_next - Get next buffer on compound request.
0100  * @work: smb work containing response buffer
0101  */
0102 static inline void *ksmbd_req_buf_next(struct ksmbd_work *work)
0103 {
0104     return work->request_buf + work->next_smb2_rcv_hdr_off + 4;
0105 }
0106 
0107 struct ksmbd_work *ksmbd_alloc_work_struct(void);
0108 void ksmbd_free_work_struct(struct ksmbd_work *work);
0109 
0110 void ksmbd_work_pool_destroy(void);
0111 int ksmbd_work_pool_init(void);
0112 
0113 int ksmbd_workqueue_init(void);
0114 void ksmbd_workqueue_destroy(void);
0115 bool ksmbd_queue_work(struct ksmbd_work *work);
0116 
0117 #endif /* __KSMBD_WORK_H__ */