Subject: Re: [PATCH net-next v6 10/11] net/smc: adapt cursor update when sndbuf and peer DMB are merged

From: Simon Horman <[email-masked]>
Date: Tue, 16 Apr 2024 12:05:38 +0100

On Sun, Apr 14, 2024 at 12:03:03PM +0800, Wen Gu wrote:
> 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 <[email-masked]>

...

> @@ -255,6 +256,14 @@ int smcd_cdc_msg_send(struct smc_connection *conn)
>  		return rc;
>  	smc_curs_copy(&conn->rx_curs_confirmed, &curs, conn);
>  	conn->local_rx_ctrl.prod_flags.cons_curs_upd_req = 0;
> +
> +	if (smc_ism_support_dmb_nocopy(conn->lgr->smcd))
> +		/* if local sndbuf shares the same memory region with
> +		 * peer DMB, then don't update the tx_curs_fin
> +		 * and sndbuf_space until peer has consumed the data.
> +		 */
> +		return rc;

Hi Wen Gu,

A minor nit from my side:

To my mind "return rc" implies returning an error value.
But here rc is 0, which based on the comment seems correct.
So perhaps it would be clearer to simply return 0.

Flagged by Smatch.

> +
>  	/* Calculate transmitted data and increment free send buffer space */
>  	diff = smc_curs_diff(conn->sndbuf_desc->len, &conn->tx_curs_fin,
>  			     &conn->tx_curs_sent);

...