Skip to content

Commit 5f08318

Browse files
Ursula Braundavem330
Ursula Braun
authored andcommitted
smc: connection data control (CDC)
send and receive CDC messages (via IB message send and CQE) Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9bf9abe commit 5f08318

File tree

8 files changed

+641
-0
lines changed

8 files changed

+641
-0
lines changed

net/smc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
obj-$(CONFIG_SMC) += smc.o
22
smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o
3+
smc-y += smc_cdc.o

net/smc/af_smc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
#include <linux/socket.h>
2727
#include <linux/inetdevice.h>
2828
#include <linux/workqueue.h>
29+
#include <linux/in.h>
2930
#include <net/sock.h>
3031
#include <net/tcp.h>
3132

3233
#include "smc.h"
3334
#include "smc_clc.h"
3435
#include "smc_llc.h"
36+
#include "smc_cdc.h"
3537
#include "smc_core.h"
3638
#include "smc_ib.h"
3739
#include "smc_pnet.h"
@@ -285,6 +287,7 @@ static void smc_conn_save_peer_info(struct smc_sock *smc,
285287
struct smc_clc_msg_accept_confirm *clc)
286288
{
287289
smc->conn.peer_conn_idx = clc->conn_idx;
290+
smc->conn.local_tx_ctrl.token = ntohl(clc->rmbe_alert_token);
288291
smc->conn.peer_rmbe_size = smc_uncompress_bufsize(clc->rmbe_size);
289292
atomic_set(&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size);
290293
}
@@ -1201,6 +1204,12 @@ static int __init smc_init(void)
12011204
goto out_pnet;
12021205
}
12031206

1207+
rc = smc_cdc_init();
1208+
if (rc) {
1209+
pr_err("%s: smc_cdc_init fails with %d\n", __func__, rc);
1210+
goto out_pnet;
1211+
}
1212+
12041213
rc = proto_register(&smc_proto, 1);
12051214
if (rc) {
12061215
pr_err("%s: proto_register fails with %d\n", __func__, rc);

net/smc/smc.h

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
#define SMC_MAX_PORTS 2 /* Max # of ports */
2323

24+
#ifdef ATOMIC64_INIT
25+
#define KERNEL_HAS_ATOMIC64
26+
#endif
27+
2428
enum smc_state { /* possible states of an SMC socket */
2529
SMC_ACTIVE = 1,
2630
SMC_INIT = 2,
@@ -34,6 +38,67 @@ struct smc_wr_rx_hdr { /* common prefix part of LLC and CDC to demultiplex */
3438
u8 type;
3539
} __aligned(1);
3640

41+
struct smc_cdc_conn_state_flags {
42+
#if defined(__BIG_ENDIAN_BITFIELD)
43+
u8 peer_done_writing : 1; /* Sending done indicator */
44+
u8 peer_conn_closed : 1; /* Peer connection closed indicator */
45+
u8 peer_conn_abort : 1; /* Abnormal close indicator */
46+
u8 reserved : 5;
47+
#elif defined(__LITTLE_ENDIAN_BITFIELD)
48+
u8 reserved : 5;
49+
u8 peer_conn_abort : 1;
50+
u8 peer_conn_closed : 1;
51+
u8 peer_done_writing : 1;
52+
#endif
53+
};
54+
55+
struct smc_cdc_producer_flags {
56+
#if defined(__BIG_ENDIAN_BITFIELD)
57+
u8 write_blocked : 1; /* Writing Blocked, no rx buf space */
58+
u8 urg_data_pending : 1; /* Urgent Data Pending */
59+
u8 urg_data_present : 1; /* Urgent Data Present */
60+
u8 cons_curs_upd_req : 1; /* cursor update requested */
61+
u8 failover_validation : 1;/* message replay due to failover */
62+
u8 reserved : 3;
63+
#elif defined(__LITTLE_ENDIAN_BITFIELD)
64+
u8 reserved : 3;
65+
u8 failover_validation : 1;
66+
u8 cons_curs_upd_req : 1;
67+
u8 urg_data_present : 1;
68+
u8 urg_data_pending : 1;
69+
u8 write_blocked : 1;
70+
#endif
71+
};
72+
73+
/* in host byte order */
74+
union smc_host_cursor { /* SMC cursor - an offset in an RMBE */
75+
struct {
76+
u16 reserved;
77+
u16 wrap; /* window wrap sequence number */
78+
u32 count; /* cursor (= offset) part */
79+
};
80+
#ifdef KERNEL_HAS_ATOMIC64
81+
atomic64_t acurs; /* for atomic processing */
82+
#else
83+
u64 acurs; /* for atomic processing */
84+
#endif
85+
} __aligned(8);
86+
87+
/* in host byte order, except for flag bitfields in network byte order */
88+
struct smc_host_cdc_msg { /* Connection Data Control message */
89+
struct smc_wr_rx_hdr common; /* .type = 0xFE */
90+
u8 len; /* length = 44 */
91+
u16 seqno; /* connection seq # */
92+
u32 token; /* alert_token */
93+
union smc_host_cursor prod; /* producer cursor */
94+
union smc_host_cursor cons; /* consumer cursor,
95+
* piggy backed "ack"
96+
*/
97+
struct smc_cdc_producer_flags prod_flags; /* conn. tx/rx status */
98+
struct smc_cdc_conn_state_flags conn_state_flags; /* peer conn. status*/
99+
u8 reserved[18];
100+
} __aligned(8);
101+
37102
struct smc_connection {
38103
struct rb_node alert_node;
39104
struct smc_link_group *lgr; /* link group of connection */
@@ -50,6 +115,38 @@ struct smc_connection {
50115
struct smc_buf_desc *rmb_desc; /* RMBE descriptor */
51116
int rmbe_size; /* RMBE size <== sock rmem */
52117
int rmbe_size_short;/* compressed notation */
118+
119+
struct smc_host_cdc_msg local_tx_ctrl; /* host byte order staging
120+
* buffer for CDC msg send
121+
* .prod cf. TCP snd_nxt
122+
* .cons cf. TCP sends ack
123+
*/
124+
union smc_host_cursor tx_curs_prep; /* tx - prepared data
125+
* snd_max..wmem_alloc
126+
*/
127+
union smc_host_cursor tx_curs_sent; /* tx - sent data
128+
* snd_nxt ?
129+
*/
130+
union smc_host_cursor tx_curs_fin; /* tx - confirmed by peer
131+
* snd-wnd-begin ?
132+
*/
133+
atomic_t sndbuf_space; /* remaining space in sndbuf */
134+
u16 tx_cdc_seq; /* sequence # for CDC send */
135+
spinlock_t send_lock; /* protect wr_sends */
136+
137+
struct smc_host_cdc_msg local_rx_ctrl; /* filled during event_handl.
138+
* .prod cf. TCP rcv_nxt
139+
* .cons cf. TCP snd_una
140+
*/
141+
union smc_host_cursor rx_curs_confirmed; /* confirmed to peer
142+
* source of snd_una ?
143+
*/
144+
atomic_t bytes_to_rcv; /* arrived data,
145+
* not yet received
146+
*/
147+
#ifndef KERNEL_HAS_ATOMIC64
148+
spinlock_t acurs_lock; /* protect cursors */
149+
#endif
53150
};
54151

55152
struct smc_sock { /* smc sock container */

0 commit comments

Comments
 (0)