net/smc: Two features for smc-r
Subsystems (5)
v3 cover net/smc: Two features for smc-r
v2 -> v3:
(https://lore.kernel.org/netdev/[email protected]/)
Patch #1 add 'Reviewed-by' tag.
Patch #2 remove the condition when IPV6 is disabled, and change the condition to an easier understanding way. Correct the typo and add 'Reviewed-by' tag.
v1 -> v2:
Patch #2 fix build error reported by kernel test robot <[email protected]>.
https://lore.kernel.org/oe-kbuild-all/[email protected]/
Guangguan Wang (2):
net/smc: support SMC-R V2 for rdma devices with max_recv_sge equals to
1
net/smc: support ipv4 mapped ipv6 addr client for smc-r v2
net/smc/af_smc.c | 5 ++++- net/smc/smc_core.c | 5 +++++ net/smc/smc_core.h | 11 ++++++++++- net/smc/smc_ib.c | 3 +-- net/smc/smc_llc.c | 21 +++++++++++++++------ net/smc/smc_wr.c | 42 +++++++++++++++++++++--------------------- 6 files changed, 56 insertions(+), 31 deletions(-)
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH RESEND v3 1/2 net/smc: support SMC-R V2 for rdma devices with max_recv_sge equals to 1
For SMC-R V2, llc msg can be larger than SMC_WR_BUF_SIZE, thus every recv wr has 2 sges, the first sge with length SMC_WR_BUF_SIZE is for V1/V2 compatible llc/cdc msg, and the second sge with length SMC_WR_BUF_V2_SIZE-SMC_WR_TX_SIZE is for V2 specific llc msg, like SMC_LLC_DELETE_RKEY and SMC_LLC_ADD_LINK for SMC-R V2. The memory buffer in the second sge is shared by all recv wr in one link and all link in one lgr for saving memory usage purpose.
But not all RDMA devices with max_recv_sge greater than 1. Thus SMC-R V2 can not support on such RDMA devices and SMC_CLC_DECL_INTERR fallback happens because of the failure of create qp.
This patch introduce the support for SMC-R V2 on RDMA devices with max_recv_sge equals to 1. Every recv wr has only one sge with individual buffer whose size is SMC_WR_BUF_V2_SIZE once the RDMA device's max_recv_sge equals to 1. It may use more memory, but it is better than SMC_CLC_DECL_INTERR fallback.
--- net/smc/smc_core.c | 5 +++++ net/smc/smc_core.h | 11 ++++++++++- net/smc/smc_ib.c | 3 +-- net/smc/smc_llc.c | 21 +++++++++++++++------ net/smc/smc_wr.c | 42 +++++++++++++++++++++--------------------- 5 files changed, 52 insertions(+), 30 deletions(-)
net/smc/smc_core.c +5 -0
@@ -795,9 +795,14 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,if (lgr->smc_version ==SMC_V2 ) { lnk->smcibdev = ini->smcrv2.ib_dev_v2; lnk->ibport = ini->smcrv2.ib_port_v2; + lnk->wr_rx_sge_cnt = lnk->smcibdev->ibdev->attrs.max_recv_sge <2 ?1 :2 ; + lnk->wr_rx_buflen =smc_link_shared_v2_rxbuf (lnk) ? +SMC_WR_BUF_SIZE :SMC_WR_BUF_V2_SIZE ; }else { lnk->smcibdev = ini->ib_dev; lnk->ibport = ini->ib_port; + lnk->wr_rx_sge_cnt =1 ; + lnk->wr_rx_buflen =SMC_WR_BUF_SIZE ; }get_device (&lnk->smcibdev->ibdev->dev);atomic_inc (&lnk->smcibdev->lnk_cnt);
net/smc/smc_core.h +10 -1
@@ -122,10 +122,14 @@ struct smc_link { }____cacheline_aligned_in_smp ;struct completion tx_ref_comp; -struct smc_wr_buf *wr_rx_bufs;/* WR recv payload buffers */ +u8 *wr_rx_bufs;/* WR recv payload buffers */ struct ib_recv_wr *wr_rx_ibs;/* WR recv meta data */ struct ib_sge *wr_rx_sges;/* WR recv scatter meta data */ /* above three vectors have wr_rx_cnt elements and use the same index */ +int wr_rx_sge_cnt;/* rx sge, V1 is 1, V2 is either 2 or 1 */ +int wr_rx_buflen;/* buffer len for the first sge, len for the +* second sge is lgr shared if rx sge is 2. +*/ dma_addr_t wr_rx_dma_addr;/* DMA address of wr_rx_bufs */ dma_addr_t wr_rx_v2_dma_addr;/* DMA address of v2 rx buf*/ u64 wr_rx_id;/* seq # of last recv WR */
@@ -506,6 +510,11 @@ static inline bool smc_link_active(struct smc_link *lnk)return lnk->state ==SMC_LNK_ACTIVE ; } +static inline bool smc_link_shared_v2_rxbuf (struct smc_link *lnk) +{ +return lnk->wr_rx_sge_cnt >1 ; +} +static inline void smc_gid_be16_convert (__u8 *buf,u8 *gid_raw) { sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
net/smc/smc_ib.c +1 -2
@@ -662,7 +662,6 @@ void smc_ib_destroy_queue_pair(struct smc_link *lnk)/* create a queue pair within the protection domain for a link */ int smc_ib_create_queue_pair (struct smc_link *lnk) { -int sges_per_buf = (lnk->lgr->smc_version ==SMC_V2 ) ?2 :1 ;struct ib_qp_init_attr qp_attr = { .event_handler = smc_ib_qp_event_handler, .qp_context = lnk,
@@ -676,7 +675,7 @@ int smc_ib_create_queue_pair(struct smc_link *lnk) .max_send_wr = SMC_WR_BUF_CNT * 3, .max_recv_wr = SMC_WR_BUF_CNT * 3, .max_send_sge = SMC_IB_MAX_SEND_SGE, - .max_recv_sge = sges_per_buf, + .max_recv_sge = lnk->wr_rx_sge_cnt, .max_inline_data = 0, }, .sq_sig_type = IB_SIGNAL_REQ_WR,
net/smc/smc_llc.c +15 -6
@@ -997,13 +997,14 @@ static int smc_llc_cli_conf_link(struct smc_link *link, }static void smc_llc_save_add_link_rkeys (struct smc_link *link, -struct smc_link *link_new) +struct smc_link *link_new, +u8 *llc_msg) {struct smc_llc_msg_add_link_v2_ext *ext;struct smc_link_group *lgr = link->lgr;int max, i; - ext = (struct smc_llc_msg_add_link_v2_ext *)((u8 *)lgr->wr_rx_buf_v2 + + ext = (struct smc_llc_msg_add_link_v2_ext *)(llc_msg +SMC_WR_TX_SIZE ); max =min_t (u8, ext->num_rkeys,SMC_LLC_RKEYS_PER_MSG_V2 );down_write (&lgr->rmbs_lock);
@@ -1098,7 +1099,9 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)if (rc) goto out_clear_lnk;if (lgr->smc_version ==SMC_V2 ) { -smc_llc_save_add_link_rkeys (link, lnk_new); +u8 *llc_msg =smc_link_shared_v2_rxbuf (link) ? + (u8 *)lgr->wr_rx_buf_v2 : (u8 *)llc; +smc_llc_save_add_link_rkeys (link, lnk_new, llc_msg); }else { rc =smc_llc_cli_rkey_exchange (link, lnk_new);if (rc) {
@@ -1498,7 +1501,9 @@ int smc_llc_srv_add_link(struct smc_link *link,if (rc) goto out_err;if (lgr->smc_version ==SMC_V2 ) { -smc_llc_save_add_link_rkeys (link, link_new); +u8 *llc_msg =smc_link_shared_v2_rxbuf (link) ? + (u8 *)lgr->wr_rx_buf_v2 : (u8 *)add_llc; +smc_llc_save_add_link_rkeys (link, link_new, llc_msg); }else { rc =smc_llc_srv_rkey_exchange (link, link_new);if (rc)
@@ -1807,8 +1812,12 @@ static void smc_llc_rmt_delete_rkey(struct smc_link_group *lgr)if (lgr->smc_version ==SMC_V2 ) {struct smc_llc_msg_delete_rkey_v2 *llcv2; -memcpy (lgr->wr_rx_buf_v2, llc,sizeof (*llc)); - llcv2 = (struct smc_llc_msg_delete_rkey_v2 *)lgr->wr_rx_buf_v2; +if (smc_link_shared_v2_rxbuf (link)) { +memcpy (lgr->wr_rx_buf_v2, llc,sizeof (*llc)); + llcv2 = (struct smc_llc_msg_delete_rkey_v2 *)lgr->wr_rx_buf_v2; + }else { + llcv2 = (struct smc_llc_msg_delete_rkey_v2 *)llc; + } llcv2->num_inval_rkeys =0 ; max =min_t (u8, llcv2->num_rkeys,SMC_LLC_RKEYS_PER_MSG_V2 );
net/smc/smc_wr.c +21 -21
109 lines not on this page · raw message
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH RESEND v3 2/2 net/smc: support ipv4 mapped ipv6 addr client for smc-r v2
In reply to Guangguan WangAF_INET6 is not supported for smc-r v2 client before, even if the ipv6 addr is ipv4 mapped. Thus, when using AF_INET6, smc-r connection will fallback to tcp, especially for java applications running smc-r. This patch support ipv4 mapped ipv6 addr client for smc-r v2. Clients using real global ipv6 addr is still not supported yet.
--- net/smc/af_smc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/smc/af_smc.c +4 -1
@@ -1116,7 +1116,10 @@ static int smc_find_proposal_devices(struct smc_sock *smc, ini->check_smcrv2 = true; ini->smcrv2.saddr = smc->clcsock->sk->sk_rcv_saddr;if (!(ini->smcr_version &SMC_V2 ) || - smc->clcsock->sk->sk_family !=AF_INET || +#if IS_ENABLED(CONFIG_IPV6) + (smc->clcsock->sk->sk_family ==AF_INET6 && + !ipv6_addr_v4mapped (&smc->clcsock->sk->sk_v6_rcv_saddr)) || +#endif !smc_clc_ueid_count () ||smc_find_rdma_device (smc, ini)) ini->smcr_version &= ~SMC_V2 ;
Signature · 1 line
2.24.3 (Apple Git-128)
Re: [PATCH net-next RESEND v3 2/2] net/smc: support ipv4 mapped ipv6 addr client for smc-r v2
Quoted 6 lines · On Wed, 11 Dec 2024 10:30:55 +0800 Guangguan Wang…
AF_INET6is not supported for smc-r v2 client before, even if the ipv6 addr is ipv4 mapped. Thus, when usingAF_INET6, smc-r connection will fallback to tcp, especially for java applications running smc-r. This patch support ipv4 mapped ipv6 addr client for smc-r v2. Clients using real global ipv6 addr is still not supported yet.
Quoted 6 lines
Signed-off-by Guangguan Wang <[email protected]>Reviewed-by Wen Gu <[email protected]>Reviewed-by Dust Li <[email protected]>Reviewed-by D. Wythe <[email protected]>Reviewed-by Wenjia Zhang <[email protected]>Reviewed-by Halil Pasic <[email protected]>
Sorry for the late remark, but does this need a Fixes tag? I mean my gut feeling is that this is a bugfix -- i.e. should have been working from the get go -- and not a mere enhancement. No strong opinions here.
Halil
Paolo Abeni
maintainerRe: [PATCH net-next RESEND v3 2/2] net/smc: support ipv4 mapped ipv6 addr client for smc-r v2
Quoted 16 lines · Halil Pasic
Quoted 6 lines · On Wed, 11 Dec 2024 10:30:55 +0800 Guangguan Wang…
AF_INET6is not supported for smc-r v2 client before, even if the ipv6 addr is ipv4 mapped. Thus, when usingAF_INET6, smc-r connection will fallback to tcp, especially for java applications running smc-r. This patch support ipv4 mapped ipv6 addr client for smc-r v2. Clients using real global ipv6 addr is still not supported yet.Quoted 6 lines
Signed-off-by Guangguan Wang <[email protected]>Reviewed-by Wen Gu <[email protected]>Reviewed-by Dust Li <[email protected]>Reviewed-by D. Wythe <[email protected]>Reviewed-by Wenjia Zhang <[email protected]>Reviewed-by Halil Pasic <[email protected]>
Quoted 4 lines
Sorry for the late remark, but does this need a Fixes tag? I mean my gut feeling is that this is a bugfix -- i.e. should have been working from the get go -- and not a mere enhancement. No strong opinions here.
FTR: my take is this is really a new feature, as the ipv6 support for missing from the smc-r v2 introduction and sub-system maintainers already implicitly agreed on that via RB tags.
Cheers,
/P
Re: [PATCH net-next RESEND v3 2/2] net/smc: support ipv4 mapped ipv6 addr client for smc-r v2
Quoted 22 lines · Paolo Abeni
Quoted 16 lines · Halil Pasic
Quoted 6 lines · On Wed, 11 Dec 2024 10:30:55 +0800 Guangguan Wang…
AF_INET6is not supported for smc-r v2 client before, even if the ipv6 addr is ipv4 mapped. Thus, when usingAF_INET6, smc-r connection will fallback to tcp, especially for java applications running smc-r. This patch support ipv4 mapped ipv6 addr client for smc-r v2. Clients using real global ipv6 addr is still not supported yet.Quoted 6 lines
Signed-off-by Guangguan Wang <[email protected]>Reviewed-by Wen Gu <[email protected]>Reviewed-by Dust Li <[email protected]>Reviewed-by D. Wythe <[email protected]>Reviewed-by Wenjia Zhang <[email protected]>Reviewed-by Halil Pasic <[email protected]>Quoted 4 lines
Sorry for the late remark, but does this need a Fixes tag? I mean my gut feeling is that this is a bugfix -- i.e. should have been working from the get go -- and not a mere enhancement. No strong opinions here.
Quoted 7 lines
FTR: my take is this is really a new feature, as the ipv6 support for missing from the smc-r v2 introduction and sub-system maintainers already implicitly agreed on that via RB tags.
Cheers,
/P
Agree.
This patch enlarges the scope of using SMCRv2, so I think it is a new feature.
Thanks,
Guangguan Wang
Re: [PATCH net-next RESEND v3 2/2] net/smc: support ipv4 mapped ipv6 addr client for smc-r v2
In reply to Paolo AbeniQuoted 8 lines · On Thu, 12 Dec 2024 13:49:29 +0100 Paolo Abeni <[email protected]> wrote:
Quoted 4 lines
Sorry for the late remark, but does this need a Fixes tag? I mean my gut feeling is that this is a bugfix -- i.e. should have been working from the get go -- and not a mere enhancement. No strong opinions here.
FTR: my take is this is really a new feature, as the ipv6 support for missing from the smc-r v2 introduction and sub-system maintainers already implicitly agreed on that via RB tags.
Works with me! Thanks!
Regards,
Halil
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Wed, 11 Dec 2024 10:30:53 +0800 you wrote:
v2 -> v3:
(https://lore.kernel.org/netdev/[email protected]/)
Patch #1 add 'Reviewed-by' tag.
Patch #2 remove the condition when IPV6 is disabled, and change the condition to an easier understanding way. Correct the typo and add 'Reviewed-by' tag.[...]
Here is the summary with links:
- [net-next,RESEND,v3,1/2] net/smc: support SMC-R V2 for rdma devices with max_recv_sge equals to 1
https://git.kernel.org/netdev/net-next/c/27ef6a9981fe - [net-next,RESEND,v3,2/2] net/smc: support ipv4 mapped ipv6 addr client for smc-r v2 https://git.kernel.org/netdev/net-next/c/c12b2704a678
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html