# Re: \[RFC net-next 04/17\] net/smc: Decouple sf and attached send\_buf in smc\_loopback

- From: Dust Li \<dust.li@linux.alibaba.com\>
- Date: 2025-08-10 14:00:56 
- List: netdev
- Page: https://ratatoskr.run/netdev/2025/08/11334177
- Thread: https://ratatoskr.run/netdev/2025/08/11334011/t.md

```text
On 2025-08-06 17:41:09, Alexandra Winter wrote:
>Before this patch there was the following assumption in
>smc_loopback.c>smc_lo_move_data():
>sf (signalling flag) == 0 : data is already in an attached target dmb
>sf == 1 : data is not yet in the target dmb
>
>This is true for the 2 callers in smc client
>smcd_cdc_msg_send() : sf=1
>smcd_tx_rdma_writes() : sf=0
>but should not be a general assumption.
>
>Add a bool to struct smc_buf_desc to indicate whether an SMC-D sndbuf_desc
>is an attached buffer. Don't call move_data() for attached send_buffers,
>because it is not necessary.
>
>Move the data in smc_lo_move_data() if len != 0 and signal when requested.
>
>Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
>Reviewed-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
>---
> net/smc/smc_core.h     | 5 +++++
> net/smc/smc_ism.c      | 1 +
> net/smc/smc_loopback.c | 9 +++------
> net/smc/smc_tx.c       | 3 +++
> 4 files changed, 12 insertions(+), 6 deletions(-)
>
>diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h
>index 48a1b1dcb576..fe5f48d14323 100644
>--- a/net/smc/smc_core.h
>+++ b/net/smc/smc_core.h
>@@ -13,6 +13,7 @@
> #define _SMC_CORE_H
> 
> #include <linux/atomic.h>
>+#include <linux/types.h>
> #include <linux/smc.h>
> #include <linux/pci.h>
> #include <rdma/ib_verbs.h>
>@@ -221,12 +222,16 @@ struct smc_buf_desc {
> 					/* virtually contiguous */
> 		};
> 		struct { /* SMC-D */
>+			 /* SMC-D rx buffer: */
> 			unsigned short	sba_idx;
> 					/* SBA index number */
> 			u64		token;
> 					/* DMB token number */
> 			dma_addr_t	dma_addr;
> 					/* DMA address */
>+			/* SMC-D tx buffer */
>+			bool		is_attached;
>+					/* no need for explicit writes */

Reviewed-by: Dust Li <dust.li@linux.alibaba.com>

A small sugguestion: there is a hole between sba_idx and token, we can
put is_attached in that hole.
Not a big deal because this is a union and SMC-R use a much large space.

Best regards,
Dust

```
