Skip to content

Commit 2f6beca

Browse files
Hans Wippeldavem330
authored andcommitted
net/smc: move smc_core specific code from smc.h to smc_core
SMC connection and buffer handling belong to smc_core. So, this patch moves this code from smc.h to smc_core. Signed-off-by: Hans Wippel <[email protected]> Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 95d8d26 commit 2f6beca

File tree

3 files changed

+39
-41
lines changed

3 files changed

+39
-41
lines changed

net/smc/smc.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -220,41 +220,6 @@ static inline u32 ntoh24(u8 *net)
220220
return be32_to_cpu(t);
221221
}
222222

223-
#define SMC_BUF_MIN_SIZE 16384 /* minimum size of an RMB */
224-
225-
#define SMC_RMBE_SIZES 16 /* number of distinct sizes for an RMBE */
226-
/* theoretically, the RFC states that largest size would be 512K,
227-
* i.e. compressed 5 and thus 6 sizes (0..5), despite
228-
* struct smc_clc_msg_accept_confirm.rmbe_size being a 4 bit value (0..15)
229-
*/
230-
231-
/* convert the RMB size into the compressed notation - minimum 16K.
232-
* In contrast to plain ilog2, this rounds towards the next power of 2,
233-
* so the socket application gets at least its desired sndbuf / rcvbuf size.
234-
*/
235-
static inline u8 smc_compress_bufsize(int size)
236-
{
237-
u8 compressed;
238-
239-
if (size <= SMC_BUF_MIN_SIZE)
240-
return 0;
241-
242-
size = (size - 1) >> 14;
243-
compressed = ilog2(size) + 1;
244-
if (compressed >= SMC_RMBE_SIZES)
245-
compressed = SMC_RMBE_SIZES - 1;
246-
return compressed;
247-
}
248-
249-
/* convert the RMB size from compressed notation into integer */
250-
static inline int smc_uncompress_bufsize(u8 compressed)
251-
{
252-
u32 size;
253-
254-
size = 0x00000001 << (((int)compressed) + 14);
255-
return (int)size;
256-
}
257-
258223
#ifdef CONFIG_XFRM
259224
static inline bool using_ipsec(struct smc_sock *smc)
260225
{
@@ -268,12 +233,6 @@ static inline bool using_ipsec(struct smc_sock *smc)
268233
}
269234
#endif
270235

271-
struct smc_clc_msg_local;
272-
273-
void smc_conn_free(struct smc_connection *conn);
274-
int smc_conn_create(struct smc_sock *smc,
275-
struct smc_ib_device *smcibdev, u8 ibport,
276-
struct smc_clc_msg_local *lcl, int srv_first_contact);
277236
struct sock *smc_accept_dequeue(struct sock *parent, struct socket *new_sock);
278237
void smc_close_non_accepted(struct sock *sk);
279238

net/smc/smc_core.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,33 @@ int smc_conn_create(struct smc_sock *smc,
543543
return rc ? rc : local_contact;
544544
}
545545

546+
/* convert the RMB size into the compressed notation - minimum 16K.
547+
* In contrast to plain ilog2, this rounds towards the next power of 2,
548+
* so the socket application gets at least its desired sndbuf / rcvbuf size.
549+
*/
550+
static u8 smc_compress_bufsize(int size)
551+
{
552+
u8 compressed;
553+
554+
if (size <= SMC_BUF_MIN_SIZE)
555+
return 0;
556+
557+
size = (size - 1) >> 14;
558+
compressed = ilog2(size) + 1;
559+
if (compressed >= SMC_RMBE_SIZES)
560+
compressed = SMC_RMBE_SIZES - 1;
561+
return compressed;
562+
}
563+
564+
/* convert the RMB size from compressed notation into integer */
565+
int smc_uncompress_bufsize(u8 compressed)
566+
{
567+
u32 size;
568+
569+
size = 0x00000001 << (((int)compressed) + 14);
570+
return (int)size;
571+
}
572+
546573
/* try to reuse a sndbuf or rmb description slot for a certain
547574
* buffer size; if not available, return NULL
548575
*/

net/smc/smc_core.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ struct smc_rtoken { /* address/key of remote RMB */
141141
};
142142

143143
#define SMC_LGR_ID_SIZE 4
144+
#define SMC_BUF_MIN_SIZE 16384 /* minimum size of an RMB */
145+
#define SMC_RMBE_SIZES 16 /* number of distinct RMBE sizes */
146+
/* theoretically, the RFC states that largest size would be 512K,
147+
* i.e. compressed 5 and thus 6 sizes (0..5), despite
148+
* struct smc_clc_msg_accept_confirm.rmbe_size being a 4 bit value (0..15)
149+
*/
144150

145151
struct smc_link_group {
146152
struct list_head list;
@@ -205,12 +211,14 @@ static inline struct smc_connection *smc_lgr_find_conn(
205211

206212
struct smc_sock;
207213
struct smc_clc_msg_accept_confirm;
214+
struct smc_clc_msg_local;
208215

209216
void smc_lgr_free(struct smc_link_group *lgr);
210217
void smc_lgr_forget(struct smc_link_group *lgr);
211218
void smc_lgr_terminate(struct smc_link_group *lgr);
212219
void smc_port_terminate(struct smc_ib_device *smcibdev, u8 ibport);
213220
int smc_buf_create(struct smc_sock *smc);
221+
int smc_uncompress_bufsize(u8 compressed);
214222
int smc_rmb_rtoken_handling(struct smc_connection *conn,
215223
struct smc_clc_msg_accept_confirm *clc);
216224
int smc_rtoken_add(struct smc_link_group *lgr, __be64 nw_vaddr, __be32 nw_rkey);
@@ -219,5 +227,9 @@ void smc_sndbuf_sync_sg_for_cpu(struct smc_connection *conn);
219227
void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn);
220228
void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn);
221229
void smc_rmb_sync_sg_for_device(struct smc_connection *conn);
230+
void smc_conn_free(struct smc_connection *conn);
231+
int smc_conn_create(struct smc_sock *smc,
232+
struct smc_ib_device *smcibdev, u8 ibport,
233+
struct smc_clc_msg_local *lcl, int srv_first_contact);
222234
void smc_core_exit(void);
223235
#endif

0 commit comments

Comments
 (0)