aboutsummaryrefslogtreecommitdiffstats
path: root/net/smc/smc_cdc.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/smc/smc_cdc.h')
-rw-r--r--net/smc/smc_cdc.h53
1 files changed, 42 insertions, 11 deletions
diff --git a/net/smc/smc_cdc.h b/net/smc/smc_cdc.h
index b5bfe38c7f9b..f1cdde9d4b89 100644
--- a/net/smc/smc_cdc.h
+++ b/net/smc/smc_cdc.h
@@ -160,7 +160,9 @@ static inline void smcd_curs_copy(union smcd_cdc_cursor *tgt,
160#endif 160#endif
161} 161}
162 162
163/* calculate cursor difference between old and new, where old <= new */ 163/* calculate cursor difference between old and new, where old <= new and
164 * difference cannot exceed size
165 */
164static inline int smc_curs_diff(unsigned int size, 166static inline int smc_curs_diff(unsigned int size,
165 union smc_host_cursor *old, 167 union smc_host_cursor *old,
166 union smc_host_cursor *new) 168 union smc_host_cursor *new)
@@ -185,28 +187,51 @@ static inline int smc_curs_comp(unsigned int size,
185 return smc_curs_diff(size, old, new); 187 return smc_curs_diff(size, old, new);
186} 188}
187 189
190/* calculate cursor difference between old and new, where old <= new and
191 * difference may exceed size
192 */
193static inline int smc_curs_diff_large(unsigned int size,
194 union smc_host_cursor *old,
195 union smc_host_cursor *new)
196{
197 if (old->wrap < new->wrap)
198 return min_t(int,
199 (size - old->count) + new->count +
200 (new->wrap - old->wrap - 1) * size,
201 size);
202
203 if (old->wrap > new->wrap) /* wrap has switched from 0xffff to 0x0000 */
204 return min_t(int,
205 (size - old->count) + new->count +
206 (new->wrap + 0xffff - old->wrap) * size,
207 size);
208
209 return max_t(int, 0, (new->count - old->count));
210}
211
188static inline void smc_host_cursor_to_cdc(union smc_cdc_cursor *peer, 212static inline void smc_host_cursor_to_cdc(union smc_cdc_cursor *peer,
189 union smc_host_cursor *local, 213 union smc_host_cursor *local,
214 union smc_host_cursor *save,
190 struct smc_connection *conn) 215 struct smc_connection *conn)
191{ 216{
192 union smc_host_cursor temp; 217 smc_curs_copy(save, local, conn);
193 218 peer->count = htonl(save->count);
194 smc_curs_copy(&temp, local, conn); 219 peer->wrap = htons(save->wrap);
195 peer->count = htonl(temp.count);
196 peer->wrap = htons(temp.wrap);
197 /* peer->reserved = htons(0); must be ensured by caller */ 220 /* peer->reserved = htons(0); must be ensured by caller */
198} 221}
199 222
200static inline void smc_host_msg_to_cdc(struct smc_cdc_msg *peer, 223static inline void smc_host_msg_to_cdc(struct smc_cdc_msg *peer,
201 struct smc_host_cdc_msg *local, 224 struct smc_connection *conn,
202 struct smc_connection *conn) 225 union smc_host_cursor *save)
203{ 226{
227 struct smc_host_cdc_msg *local = &conn->local_tx_ctrl;
228
204 peer->common.type = local->common.type; 229 peer->common.type = local->common.type;
205 peer->len = local->len; 230 peer->len = local->len;
206 peer->seqno = htons(local->seqno); 231 peer->seqno = htons(local->seqno);
207 peer->token = htonl(local->token); 232 peer->token = htonl(local->token);
208 smc_host_cursor_to_cdc(&peer->prod, &local->prod, conn); 233 smc_host_cursor_to_cdc(&peer->prod, &local->prod, save, conn);
209 smc_host_cursor_to_cdc(&peer->cons, &local->cons, conn); 234 smc_host_cursor_to_cdc(&peer->cons, &local->cons, save, conn);
210 peer->prod_flags = local->prod_flags; 235 peer->prod_flags = local->prod_flags;
211 peer->conn_state_flags = local->conn_state_flags; 236 peer->conn_state_flags = local->conn_state_flags;
212} 237}
@@ -270,10 +295,16 @@ static inline void smc_cdc_msg_to_host(struct smc_host_cdc_msg *local,
270 smcr_cdc_msg_to_host(local, peer, conn); 295 smcr_cdc_msg_to_host(local, peer, conn);
271} 296}
272 297
273struct smc_cdc_tx_pend; 298struct smc_cdc_tx_pend {
299 struct smc_connection *conn; /* socket connection */
300 union smc_host_cursor cursor; /* tx sndbuf cursor sent */
301 union smc_host_cursor p_cursor; /* rx RMBE cursor produced */
302 u16 ctrl_seq; /* conn. tx sequence # */
303};
274 304
275int smc_cdc_get_free_slot(struct smc_connection *conn, 305int smc_cdc_get_free_slot(struct smc_connection *conn,
276 struct smc_wr_buf **wr_buf, 306 struct smc_wr_buf **wr_buf,
307 struct smc_rdma_wr **wr_rdma_buf,
277 struct smc_cdc_tx_pend **pend); 308 struct smc_cdc_tx_pend **pend);
278void smc_cdc_tx_dismiss_slots(struct smc_connection *conn); 309void smc_cdc_tx_dismiss_slots(struct smc_connection *conn);
279int smc_cdc_msg_send(struct smc_connection *conn, struct smc_wr_buf *wr_buf, 310int smc_cdc_msg_send(struct smc_connection *conn, struct smc_wr_buf *wr_buf,