diff options
author | Hans Wippel <hwippel@linux.ibm.com> | 2018-05-18 03:34:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-18 13:15:01 -0400 |
commit | 2f6becaf79cd16f35ee7cb108200b898235b5aa2 (patch) | |
tree | 8e287e836bb252d90310988c2878fe9152dda58c | |
parent | 95d8d26306ee19f9ba32b6381571a72ee924a0b6 (diff) |
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 <hwippel@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/smc/smc.h | 41 | ||||
-rw-r--r-- | net/smc/smc_core.c | 27 | ||||
-rw-r--r-- | net/smc/smc_core.h | 12 |
3 files changed, 39 insertions, 41 deletions
diff --git a/net/smc/smc.h b/net/smc/smc.h index 9bc37645e7d5..a1467e411645 100644 --- a/net/smc/smc.h +++ b/net/smc/smc.h | |||
@@ -220,41 +220,6 @@ static inline u32 ntoh24(u8 *net) | |||
220 | return be32_to_cpu(t); | 220 | return be32_to_cpu(t); |
221 | } | 221 | } |
222 | 222 | ||
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 | |||
258 | #ifdef CONFIG_XFRM | 223 | #ifdef CONFIG_XFRM |
259 | static inline bool using_ipsec(struct smc_sock *smc) | 224 | static inline bool using_ipsec(struct smc_sock *smc) |
260 | { | 225 | { |
@@ -268,12 +233,6 @@ static inline bool using_ipsec(struct smc_sock *smc) | |||
268 | } | 233 | } |
269 | #endif | 234 | #endif |
270 | 235 | ||
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); | ||
277 | struct sock *smc_accept_dequeue(struct sock *parent, struct socket *new_sock); | 236 | struct sock *smc_accept_dequeue(struct sock *parent, struct socket *new_sock); |
278 | void smc_close_non_accepted(struct sock *sk); | 237 | void smc_close_non_accepted(struct sock *sk); |
279 | 238 | ||
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 70ab2f716f83..66afa086ae72 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c | |||
@@ -543,6 +543,33 @@ out: | |||
543 | return rc ? rc : local_contact; | 543 | return rc ? rc : local_contact; |
544 | } | 544 | } |
545 | 545 | ||
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 | |||
546 | /* try to reuse a sndbuf or rmb description slot for a certain | 573 | /* try to reuse a sndbuf or rmb description slot for a certain |
547 | * buffer size; if not available, return NULL | 574 | * buffer size; if not available, return NULL |
548 | */ | 575 | */ |
diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h index 3d4bd7011ab3..93cb3523bf50 100644 --- a/net/smc/smc_core.h +++ b/net/smc/smc_core.h | |||
@@ -141,6 +141,12 @@ struct smc_rtoken { /* address/key of remote RMB */ | |||
141 | }; | 141 | }; |
142 | 142 | ||
143 | #define SMC_LGR_ID_SIZE 4 | 143 | #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 | */ | ||
144 | 150 | ||
145 | struct smc_link_group { | 151 | struct smc_link_group { |
146 | struct list_head list; | 152 | struct list_head list; |
@@ -205,12 +211,14 @@ static inline struct smc_connection *smc_lgr_find_conn( | |||
205 | 211 | ||
206 | struct smc_sock; | 212 | struct smc_sock; |
207 | struct smc_clc_msg_accept_confirm; | 213 | struct smc_clc_msg_accept_confirm; |
214 | struct smc_clc_msg_local; | ||
208 | 215 | ||
209 | void smc_lgr_free(struct smc_link_group *lgr); | 216 | void smc_lgr_free(struct smc_link_group *lgr); |
210 | void smc_lgr_forget(struct smc_link_group *lgr); | 217 | void smc_lgr_forget(struct smc_link_group *lgr); |
211 | void smc_lgr_terminate(struct smc_link_group *lgr); | 218 | void smc_lgr_terminate(struct smc_link_group *lgr); |
212 | void smc_port_terminate(struct smc_ib_device *smcibdev, u8 ibport); | 219 | void smc_port_terminate(struct smc_ib_device *smcibdev, u8 ibport); |
213 | int smc_buf_create(struct smc_sock *smc); | 220 | int smc_buf_create(struct smc_sock *smc); |
221 | int smc_uncompress_bufsize(u8 compressed); | ||
214 | int smc_rmb_rtoken_handling(struct smc_connection *conn, | 222 | int smc_rmb_rtoken_handling(struct smc_connection *conn, |
215 | struct smc_clc_msg_accept_confirm *clc); | 223 | struct smc_clc_msg_accept_confirm *clc); |
216 | int smc_rtoken_add(struct smc_link_group *lgr, __be64 nw_vaddr, __be32 nw_rkey); | 224 | 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); | |||
219 | void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn); | 227 | void smc_sndbuf_sync_sg_for_device(struct smc_connection *conn); |
220 | void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn); | 228 | void smc_rmb_sync_sg_for_cpu(struct smc_connection *conn); |
221 | void smc_rmb_sync_sg_for_device(struct smc_connection *conn); | 229 | 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); | ||
222 | void smc_core_exit(void); | 234 | void smc_core_exit(void); |
223 | #endif | 235 | #endif |