blob: 3c4a8d627aa3f512a4df106b8bbafb89ac8f8ec5 (
plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (c) 2025 Stefan Metzmacher
*/
#ifndef __FS_SMB_COMMON_SMBDIRECT_SMBDIRECT_SOCKET_H__
#define __FS_SMB_COMMON_SMBDIRECT_SMBDIRECT_SOCKET_H__
enum smbdirect_socket_status {
SMBDIRECT_SOCKET_CREATED,
SMBDIRECT_SOCKET_CONNECTING,
SMBDIRECT_SOCKET_CONNECTED,
SMBDIRECT_SOCKET_NEGOTIATE_FAILED,
SMBDIRECT_SOCKET_DISCONNECTING,
SMBDIRECT_SOCKET_DISCONNECTED,
SMBDIRECT_SOCKET_DESTROYED
};
struct smbdirect_socket {
enum smbdirect_socket_status status;
/* RDMA related */
struct {
struct rdma_cm_id *cm_id;
} rdma;
/* IB verbs related */
struct {
struct ib_pd *pd;
struct ib_cq *send_cq;
struct ib_cq *recv_cq;
/*
* shortcuts for rdma.cm_id->{qp,device};
*/
struct ib_qp *qp;
struct ib_device *dev;
} ib;
struct smbdirect_socket_parameters parameters;
/*
* The state for posted send buffers
*/
struct {
/*
* Memory pools for preallocating
* smbdirect_send_io buffers
*/
struct {
struct kmem_cache *cache;
mempool_t *pool;
} mem;
} send_io;
/*
* The state for posted receive buffers
*/
struct {
/*
* The type of PDU we are expecting
*/
enum {
SMBDIRECT_EXPECT_NEGOTIATE_REQ = 1,
SMBDIRECT_EXPECT_NEGOTIATE_REP = 2,
SMBDIRECT_EXPECT_DATA_TRANSFER = 3,
} expected;
/*
* Memory pools for preallocating
* smbdirect_recv_io buffers
*/
struct {
struct kmem_cache *cache;
mempool_t *pool;
} mem;
/*
* The list of free smbdirect_recv_io
* structures
*/
struct {
struct list_head list;
spinlock_t lock;
} free;
/*
* The list of arrived non-empty smbdirect_recv_io
* structures
*
* This represents the reassembly queue.
*/
struct {
struct list_head list;
spinlock_t lock;
wait_queue_head_t wait_queue;
/* total data length of reassembly queue */
int data_length;
int queue_length;
/* the offset to first buffer in reassembly queue */
int first_entry_offset;
/*
* Indicate if we have received a full packet on the
* connection This is used to identify the first SMBD
* packet of a assembled payload (SMB packet) in
* reassembly queue so we can return a RFC1002 length to
* upper layer to indicate the length of the SMB packet
* received
*/
bool full_packet_received;
} reassembly;
} recv_io;
};
struct smbdirect_send_io {
struct smbdirect_socket *socket;
struct ib_cqe cqe;
/*
* The SGE entries for this work request
*
* The first points to the packet header
*/
#define SMBDIRECT_SEND_IO_MAX_SGE 6
size_t num_sge;
struct ib_sge sge[SMBDIRECT_SEND_IO_MAX_SGE];
/*
* Link to the list of sibling smbdirect_send_io
* messages.
*/
struct list_head sibling_list;
struct ib_send_wr wr;
/* SMBD packet header follows this structure */
u8 packet[];
};
struct smbdirect_recv_io {
struct smbdirect_socket *socket;
struct ib_cqe cqe;
/*
* For now we only use a single SGE
* as we have just one large buffer
* per posted recv.
*/
#define SMBDIRECT_RECV_IO_MAX_SGE 1
struct ib_sge sge;
/* Link to free or reassembly list */
struct list_head list;
/* Indicate if this is the 1st packet of a payload */
bool first_segment;
/* SMBD packet header and payload follows this structure */
u8 packet[];
};
#endif /* __FS_SMB_COMMON_SMBDIRECT_SMBDIRECT_SOCKET_H__ */
|