-
Notifications
You must be signed in to change notification settings - Fork 2
/
smbdirect.h
118 lines (110 loc) · 3.19 KB
/
smbdirect.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*******************************************************************************
* This file contains the smbdirect driver for Samba
*
* (c) Richard Sharpe <rsharpe@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
****************************************************************************/
#include <linux/spinlock.h>
#include <linux/cdev.h>
#include <rdma/rdma_cm.h>
enum smbd_states {
SMBD_NEGOTIATE = 0, /* This is the PASSIVE state in the spec */
SMBD_TRANSFER, /* This is the ESTABLISHED state in the spec */
SMBD_ERROR, /* There's been an error, drop the connection */
};
struct smbd_negotiate_req {
uint16_t min_version;
uint16_t max_version;
uint16_t reserved;
uint16_t credits_requested;
uint32_t preferred_send_size;
uint32_t max_receive_size;
uint32_t max_fragmented_size;
} __attribute__((packed));
struct smbd_negotiate_resp {
uint16_t min_version;
uint16_t max_version;
uint16_t negotiated_version;
uint16_t reserved;
uint16_t credits_requested;
uint16_t credits_granted;
uint32_t status;
uint32_t max_read_write_size;
} __attribute__((packed));
struct smbd_params {
unsigned int send_credits;
unsigned int recv_credits;
unsigned int recv_credit_max;
unsigned int send_credit_target;
unsigned int max_snd_size;
unsigned int max_fragmented_size;
unsigned int max_receive_size;
unsigned int max_read_write_size;
unsigned int keepalive_interval;
unsigned int sec_blob_size;
void *sec_blob;
};
struct smbd_device {
int initialized;
struct smbd_params params;
struct mutex connection_list_mutex; /* Controls access to the list */
/*
* List of connections or pending connections
*/
struct list_head connection_list;
struct cdev cdev;
/*
* RDMA Related stuff, including our listen port.
*/
struct rdma_cm_id *cm_lid;
};
/*
* Defines connections or pending connections
*/
struct connection_struct {
struct list_head connect_ent;
wait_queue_head_t wait_queue;
enum smbd_states state;
unsigned long long session_id;
struct work_struct cq_work;
struct work_struct disconnect_work;
/*
* RDMA stuff
*/
struct rdma_cm_id *cm_id;
struct ib_cq *cq;
struct ib_pd *pd;
struct ib_qp *qp;
/*
* Structures for sending and receiving RDMA stuff
*/
struct ib_recv_wr recv_wr; /* Initial receive ... */
struct ib_sge recv_sgl; /* Single SGE for now */
struct ib_mr *recv_mr;
struct ib_send_wr send_wr;
struct ib_sge send_sgl;
struct ib_mr *send_mr;
/*
* Buffers ...
*/
u64 recv_buf_dma;
u64 send_buf_dma;
char recv_buf[20]; /* an SMB Direct Negotiate req */
char gap[32];
char send_buf[32]; /* The SMB Direct Neg response */
char gap1[32];
/*
* The device we are related to ...
*/
struct smbd_device *dev;
};