Commit 1807abcf authored by Hyunchul Lee's avatar Hyunchul Lee Committed by Steve French

ksmbd: smbd: change prototypes of RDMA read/write related functions

Change the prototypes of RDMA read/write
operations to accept a pointer and length
of buffer descriptors.
Signed-off-by: default avatarHyunchul Lee <hyc.lee@gmail.com>
Acked-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 158a66b2
...@@ -205,31 +205,31 @@ int ksmbd_conn_write(struct ksmbd_work *work) ...@@ -205,31 +205,31 @@ int ksmbd_conn_write(struct ksmbd_work *work)
return 0; return 0;
} }
int ksmbd_conn_rdma_read(struct ksmbd_conn *conn, void *buf, int ksmbd_conn_rdma_read(struct ksmbd_conn *conn,
unsigned int buflen, u32 remote_key, u64 remote_offset, void *buf, unsigned int buflen,
u32 remote_len) struct smb2_buffer_desc_v1 *desc,
unsigned int desc_len)
{ {
int ret = -EINVAL; int ret = -EINVAL;
if (conn->transport->ops->rdma_read) if (conn->transport->ops->rdma_read)
ret = conn->transport->ops->rdma_read(conn->transport, ret = conn->transport->ops->rdma_read(conn->transport,
buf, buflen, buf, buflen,
remote_key, remote_offset, desc, desc_len);
remote_len);
return ret; return ret;
} }
int ksmbd_conn_rdma_write(struct ksmbd_conn *conn, void *buf, int ksmbd_conn_rdma_write(struct ksmbd_conn *conn,
unsigned int buflen, u32 remote_key, void *buf, unsigned int buflen,
u64 remote_offset, u32 remote_len) struct smb2_buffer_desc_v1 *desc,
unsigned int desc_len)
{ {
int ret = -EINVAL; int ret = -EINVAL;
if (conn->transport->ops->rdma_write) if (conn->transport->ops->rdma_write)
ret = conn->transport->ops->rdma_write(conn->transport, ret = conn->transport->ops->rdma_write(conn->transport,
buf, buflen, buf, buflen,
remote_key, remote_offset, desc, desc_len);
remote_len);
return ret; return ret;
} }
......
...@@ -122,11 +122,14 @@ struct ksmbd_transport_ops { ...@@ -122,11 +122,14 @@ struct ksmbd_transport_ops {
int (*writev)(struct ksmbd_transport *t, struct kvec *iovs, int niov, int (*writev)(struct ksmbd_transport *t, struct kvec *iovs, int niov,
int size, bool need_invalidate_rkey, int size, bool need_invalidate_rkey,
unsigned int remote_key); unsigned int remote_key);
int (*rdma_read)(struct ksmbd_transport *t, void *buf, unsigned int len, int (*rdma_read)(struct ksmbd_transport *t,
u32 remote_key, u64 remote_offset, u32 remote_len); void *buf, unsigned int len,
int (*rdma_write)(struct ksmbd_transport *t, void *buf, struct smb2_buffer_desc_v1 *desc,
unsigned int len, u32 remote_key, u64 remote_offset, unsigned int desc_len);
u32 remote_len); int (*rdma_write)(struct ksmbd_transport *t,
void *buf, unsigned int len,
struct smb2_buffer_desc_v1 *desc,
unsigned int desc_len);
}; };
struct ksmbd_transport { struct ksmbd_transport {
...@@ -148,12 +151,14 @@ struct ksmbd_conn *ksmbd_conn_alloc(void); ...@@ -148,12 +151,14 @@ struct ksmbd_conn *ksmbd_conn_alloc(void);
void ksmbd_conn_free(struct ksmbd_conn *conn); void ksmbd_conn_free(struct ksmbd_conn *conn);
bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c); bool ksmbd_conn_lookup_dialect(struct ksmbd_conn *c);
int ksmbd_conn_write(struct ksmbd_work *work); int ksmbd_conn_write(struct ksmbd_work *work);
int ksmbd_conn_rdma_read(struct ksmbd_conn *conn, void *buf, int ksmbd_conn_rdma_read(struct ksmbd_conn *conn,
unsigned int buflen, u32 remote_key, u64 remote_offset, void *buf, unsigned int buflen,
u32 remote_len); struct smb2_buffer_desc_v1 *desc,
int ksmbd_conn_rdma_write(struct ksmbd_conn *conn, void *buf, unsigned int desc_len);
unsigned int buflen, u32 remote_key, u64 remote_offset, int ksmbd_conn_rdma_write(struct ksmbd_conn *conn,
u32 remote_len); void *buf, unsigned int buflen,
struct smb2_buffer_desc_v1 *desc,
unsigned int desc_len);
void ksmbd_conn_enqueue_request(struct ksmbd_work *work); void ksmbd_conn_enqueue_request(struct ksmbd_work *work);
int ksmbd_conn_try_dequeue_request(struct ksmbd_work *work); int ksmbd_conn_try_dequeue_request(struct ksmbd_work *work);
void ksmbd_conn_init_server_callbacks(struct ksmbd_conn_ops *ops); void ksmbd_conn_init_server_callbacks(struct ksmbd_conn_ops *ops);
......
...@@ -6116,7 +6116,6 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work) ...@@ -6116,7 +6116,6 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
static int smb2_set_remote_key_for_rdma(struct ksmbd_work *work, static int smb2_set_remote_key_for_rdma(struct ksmbd_work *work,
struct smb2_buffer_desc_v1 *desc, struct smb2_buffer_desc_v1 *desc,
__le32 Channel, __le32 Channel,
__le16 ChannelInfoOffset,
__le16 ChannelInfoLength) __le16 ChannelInfoLength)
{ {
unsigned int i, ch_count; unsigned int i, ch_count;
...@@ -6142,7 +6141,8 @@ static int smb2_set_remote_key_for_rdma(struct ksmbd_work *work, ...@@ -6142,7 +6141,8 @@ static int smb2_set_remote_key_for_rdma(struct ksmbd_work *work,
work->need_invalidate_rkey = work->need_invalidate_rkey =
(Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE); (Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE);
work->remote_key = le32_to_cpu(desc->token); if (Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE)
work->remote_key = le32_to_cpu(desc->token);
return 0; return 0;
} }
...@@ -6150,14 +6150,12 @@ static ssize_t smb2_read_rdma_channel(struct ksmbd_work *work, ...@@ -6150,14 +6150,12 @@ static ssize_t smb2_read_rdma_channel(struct ksmbd_work *work,
struct smb2_read_req *req, void *data_buf, struct smb2_read_req *req, void *data_buf,
size_t length) size_t length)
{ {
struct smb2_buffer_desc_v1 *desc =
(struct smb2_buffer_desc_v1 *)&req->Buffer[0];
int err; int err;
err = ksmbd_conn_rdma_write(work->conn, data_buf, length, err = ksmbd_conn_rdma_write(work->conn, data_buf, length,
le32_to_cpu(desc->token), (struct smb2_buffer_desc_v1 *)
le64_to_cpu(desc->offset), ((char *)req + le16_to_cpu(req->ReadChannelInfoOffset)),
le32_to_cpu(desc->length)); le16_to_cpu(req->ReadChannelInfoLength));
if (err) if (err)
return err; return err;
...@@ -6201,7 +6199,6 @@ int smb2_read(struct ksmbd_work *work) ...@@ -6201,7 +6199,6 @@ int smb2_read(struct ksmbd_work *work)
(struct smb2_buffer_desc_v1 *) (struct smb2_buffer_desc_v1 *)
((char *)req + ch_offset), ((char *)req + ch_offset),
req->Channel, req->Channel,
req->ReadChannelInfoOffset,
req->ReadChannelInfoLength); req->ReadChannelInfoLength);
if (err) if (err)
goto out; goto out;
...@@ -6379,21 +6376,18 @@ static ssize_t smb2_write_rdma_channel(struct ksmbd_work *work, ...@@ -6379,21 +6376,18 @@ static ssize_t smb2_write_rdma_channel(struct ksmbd_work *work,
struct ksmbd_file *fp, struct ksmbd_file *fp,
loff_t offset, size_t length, bool sync) loff_t offset, size_t length, bool sync)
{ {
struct smb2_buffer_desc_v1 *desc;
char *data_buf; char *data_buf;
int ret; int ret;
ssize_t nbytes; ssize_t nbytes;
desc = (struct smb2_buffer_desc_v1 *)&req->Buffer[0];
data_buf = kvmalloc(length, GFP_KERNEL | __GFP_ZERO); data_buf = kvmalloc(length, GFP_KERNEL | __GFP_ZERO);
if (!data_buf) if (!data_buf)
return -ENOMEM; return -ENOMEM;
ret = ksmbd_conn_rdma_read(work->conn, data_buf, length, ret = ksmbd_conn_rdma_read(work->conn, data_buf, length,
le32_to_cpu(desc->token), (struct smb2_buffer_desc_v1 *)
le64_to_cpu(desc->offset), ((char *)req + le16_to_cpu(req->WriteChannelInfoOffset)),
le32_to_cpu(desc->length)); le16_to_cpu(req->WriteChannelInfoLength));
if (ret < 0) { if (ret < 0) {
kvfree(data_buf); kvfree(data_buf);
return ret; return ret;
...@@ -6445,7 +6439,6 @@ int smb2_write(struct ksmbd_work *work) ...@@ -6445,7 +6439,6 @@ int smb2_write(struct ksmbd_work *work)
(struct smb2_buffer_desc_v1 *) (struct smb2_buffer_desc_v1 *)
((char *)req + ch_offset), ((char *)req + ch_offset),
req->Channel, req->Channel,
req->WriteChannelInfoOffset,
req->WriteChannelInfoLength); req->WriteChannelInfoLength);
if (err) if (err)
goto out; goto out;
......
...@@ -1351,14 +1351,18 @@ static void write_done(struct ib_cq *cq, struct ib_wc *wc) ...@@ -1351,14 +1351,18 @@ static void write_done(struct ib_cq *cq, struct ib_wc *wc)
read_write_done(cq, wc, DMA_TO_DEVICE); read_write_done(cq, wc, DMA_TO_DEVICE);
} }
static int smb_direct_rdma_xmit(struct smb_direct_transport *t, void *buf, static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
int buf_len, u32 remote_key, u64 remote_offset, void *buf, int buf_len,
u32 remote_len, bool is_read) struct smb2_buffer_desc_v1 *desc,
unsigned int desc_len,
bool is_read)
{ {
struct smb_direct_rdma_rw_msg *msg; struct smb_direct_rdma_rw_msg *msg;
int ret; int ret;
DECLARE_COMPLETION_ONSTACK(completion); DECLARE_COMPLETION_ONSTACK(completion);
struct ib_send_wr *first_wr = NULL; struct ib_send_wr *first_wr = NULL;
u32 remote_key = le32_to_cpu(desc[0].token);
u64 remote_offset = le64_to_cpu(desc[0].offset);
ret = wait_for_credits(t, &t->wait_rw_avail_ops, &t->rw_avail_ops); ret = wait_for_credits(t, &t->wait_rw_avail_ops, &t->rw_avail_ops);
if (ret < 0) if (ret < 0)
...@@ -1423,22 +1427,22 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t, void *buf, ...@@ -1423,22 +1427,22 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t, void *buf,
return ret; return ret;
} }
static int smb_direct_rdma_write(struct ksmbd_transport *t, void *buf, static int smb_direct_rdma_write(struct ksmbd_transport *t,
unsigned int buflen, u32 remote_key, void *buf, unsigned int buflen,
u64 remote_offset, u32 remote_len) struct smb2_buffer_desc_v1 *desc,
unsigned int desc_len)
{ {
return smb_direct_rdma_xmit(smb_trans_direct_transfort(t), buf, buflen, return smb_direct_rdma_xmit(smb_trans_direct_transfort(t), buf, buflen,
remote_key, remote_offset, desc, desc_len, false);
remote_len, false);
} }
static int smb_direct_rdma_read(struct ksmbd_transport *t, void *buf, static int smb_direct_rdma_read(struct ksmbd_transport *t,
unsigned int buflen, u32 remote_key, void *buf, unsigned int buflen,
u64 remote_offset, u32 remote_len) struct smb2_buffer_desc_v1 *desc,
unsigned int desc_len)
{ {
return smb_direct_rdma_xmit(smb_trans_direct_transfort(t), buf, buflen, return smb_direct_rdma_xmit(smb_trans_direct_transfort(t), buf, buflen,
remote_key, remote_offset, desc, desc_len, true);
remote_len, true);
} }
static void smb_direct_disconnect(struct ksmbd_transport *t) static void smb_direct_disconnect(struct ksmbd_transport *t)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment