Skip to content

Commit cc0ab80

Browse files
Wen GuPaolo Abeni
authored andcommitted
net/smc: adapt cursor update when sndbuf and peer DMB are merged
If the local sndbuf shares the same physical memory with peer DMB, the cursor update processing needs to be adapted to ensure that the data to be consumed won't be overwritten. So in this case, the fin_curs and sndbuf_space that were originally updated after sending the CDC message should be modified to not be update until the peer updates cons_curs. Signed-off-by: Wen Gu <guwen@linux.alibaba.com> Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com> Reviewed-and-tested-by: Jan Karcher <jaka@linux.ibm.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent ae2be35 commit cc0ab80

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

net/smc/smc_cdc.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "smc_tx.h"
1919
#include "smc_rx.h"
2020
#include "smc_close.h"
21+
#include "smc_ism.h"
2122

2223
/********************************** send *************************************/
2324

@@ -255,6 +256,14 @@ int smcd_cdc_msg_send(struct smc_connection *conn)
255256
return rc;
256257
smc_curs_copy(&conn->rx_curs_confirmed, &curs, conn);
257258
conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0;
259+
260+
if (smc_ism_support_dmb_nocopy(conn->lgr->smcd))
261+
/* if local sndbuf shares the same memory region with
262+
* peer DMB, then don't update the tx_curs_fin
263+
* and sndbuf_space until peer has consumed the data.
264+
*/
265+
return 0;
266+
258267
/* Calculate transmitted data and increment free send buffer space */
259268
diff = smc_curs_diff(conn->sndbuf_desc->len, &conn->tx_curs_fin,
260269
&conn->tx_curs_sent);
@@ -266,7 +275,7 @@ int smcd_cdc_msg_send(struct smc_connection *conn)
266275
smc_curs_copy(&conn->tx_curs_fin, &conn->tx_curs_sent, conn);
267276

268277
smc_tx_sndbuf_nonfull(smc);
269-
return rc;
278+
return 0;
270279
}
271280

272281
/********************************* receive ***********************************/
@@ -323,7 +332,7 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
323332
{
324333
union smc_host_cursor cons_old, prod_old;
325334
struct smc_connection *conn = &smc->conn;
326-
int diff_cons, diff_prod;
335+
int diff_cons, diff_prod, diff_tx;
327336

328337
smc_curs_copy(&prod_old, &conn->local_rx_ctrl.prod, conn);
329338
smc_curs_copy(&cons_old, &conn->local_rx_ctrl.cons, conn);
@@ -339,6 +348,29 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
339348
atomic_add(diff_cons, &conn->peer_rmbe_space);
340349
/* guarantee 0 <= peer_rmbe_space <= peer_rmbe_size */
341350
smp_mb__after_atomic();
351+
352+
/* if local sndbuf shares the same memory region with
353+
* peer RMB, then update tx_curs_fin and sndbuf_space
354+
* here since peer has already consumed the data.
355+
*/
356+
if (conn->lgr->is_smcd &&
357+
smc_ism_support_dmb_nocopy(conn->lgr->smcd)) {
358+
/* Calculate consumed data and
359+
* increment free send buffer space.
360+
*/
361+
diff_tx = smc_curs_diff(conn->sndbuf_desc->len,
362+
&conn->tx_curs_fin,
363+
&conn->local_rx_ctrl.cons);
364+
/* increase local sndbuf space and fin_curs */
365+
smp_mb__before_atomic();
366+
atomic_add(diff_tx, &conn->sndbuf_space);
367+
/* guarantee 0 <= sndbuf_space <= sndbuf_desc->len */
368+
smp_mb__after_atomic();
369+
smc_curs_copy(&conn->tx_curs_fin,
370+
&conn->local_rx_ctrl.cons, conn);
371+
372+
smc_tx_sndbuf_nonfull(smc);
373+
}
342374
}
343375

344376
diff_prod = smc_curs_diff(conn->rmb_desc->len, &prod_old,

0 commit comments

Comments
 (0)