Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2270286rwo; Thu, 3 Aug 2023 07:11:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmAX+otYGZ2Vuwzw63/HnSJsAeM04gja0XAFmOgrxxsIMY+HBoLAgQVaxF7jt+vZVcxSby X-Received: by 2002:a17:902:d2c9:b0:1bb:3406:a612 with SMTP id n9-20020a170902d2c900b001bb3406a612mr18198830plc.57.1691071910392; Thu, 03 Aug 2023 07:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691071910; cv=none; d=google.com; s=arc-20160816; b=scKwmmzDRQJNuBOZHD5OTmtZ32VCnGd85am3Npe4W+MGVXYeKFaHT5ZYI+YF7Zlto4 HuCsDboPFSv+3j7OjQ4rsZNE/YLertr9cN4uQbNB8QHL2hqgYKiQrjfxxbNGsS+HvVII cI7vSXVD2OJgxYf+fT+hbwzeK8pxAzkCRo1K2hcFWNwwJn8uVZMqC9OX7FRpOGCOJLYA 0bI5U8NT6L5l+mmv1Mua89K46ykpsNsOsCpcCu5nPbqDJHSu6Q9tOnA0L9OuP0/6rObA CddDs2mS3XxVk5LKxfPd94k+EHl5ZyvqrZOzd0BPAjNFj2s3e0rT8f405+k6yHyMnOQH JWxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=aDT2aeLAGYSo41PBAZSFQVARYXfDKKEoeq5vO9hFcwA=; fh=8ip4DUddnTzabERi8TVpNN2xDOzoY7hIlOifJESapF8=; b=cLCcsmuXWjEvIUls0jgx7D7ui+bT1UvOqQUDCA/4/l9/0NIWMbd2KVgFjMyvI8W/tR WaAzEcBGHaHHMJoLkSUzkxgxzIpWbPs9NfdAjCrs4+YmPI0/IC1RInvc4bNj70Ia57j4 dXoxwS6aqwY9dNOiONi85wavj/cY5YVzE4vef7qU22kso7ohAcK/NN+w/4LGOS8a8OZW PB7/tJR7OkYUiJQb8fNZzLuPsaKWd166kiinq+auqvYL7gEiB9mo1YSIzHINFGGEQKRW 96vP1kpaGZsa6QWXROC0gFh98eyQ98qUvPma991A+DeWDtHLsRSGAN7vZkcUcoiu98s6 MmSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg15-20020a170902fb8f00b001bbd785e1d2si8745405plb.201.2023.08.03.07.11.37; Thu, 03 Aug 2023 07:11:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235614AbjHCNYl (ORCPT + 99 others); Thu, 3 Aug 2023 09:24:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234687AbjHCNYc (ORCPT ); Thu, 3 Aug 2023 09:24:32 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13E3E134; Thu, 3 Aug 2023 06:24:29 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R331e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=guangguan.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0Voz-FQk_1691069065; Received: from localhost.localdomain(mailfrom:guangguan.wang@linux.alibaba.com fp:SMTPD_---0Voz-FQk_1691069065) by smtp.aliyun-inc.com; Thu, 03 Aug 2023 21:24:26 +0800 From: Guangguan Wang To: wenjia@linux.ibm.com, jaka@linux.ibm.com, kgraul@linux.ibm.com, tonylu@linux.alibaba.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: alibuda@linux.alibaba.com, guwen@linux.alibaba.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 2/6] net/smc: add vendor unique experimental options area in clc handshake Date: Thu, 3 Aug 2023 21:24:18 +0800 Message-Id: <20230803132422.6280-3-guangguan.wang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230803132422.6280-1-guangguan.wang@linux.alibaba.com> References: <20230803132422.6280-1-guangguan.wang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add vendor unique experimental options area in clc handshake. In clc accept and confirm msg, vendor unique experimental options use the 16-Bytes reserved field, which defined in struct smc_clc_fce_gid_ext in previous version. Because of the struct smc_clc_first_contact_ext is widely used and limit the scope of modification, this patch moves the 16-Bytes reserved field out of struct smc_clc_fce_gid_ext, and followed with the struct smc_clc_first_contact_ext in a new struct names struct smc_clc_first_contact_ext_v2x. For SMC-R first connection, in previous version, the struct smc_clc_ first_contact_ext and the 16-Bytes reserved field has already been included in clc accept and confirm msg. Thus, this patch use struct smc_clc_first_contact_ext_v2x instead of the struct smc_clc_first_ contact_ext and the 16-Bytes reserved field in SMC-R clc accept and confirm msg is compatible with previous version. For SMC-D first connection, in previous version, only the struct smc_ clc_first_contact_ext is included in clc accept and confirm msg, and the 16-Bytes reserved field is not included. Thus, when the negotiated smc release version is the version before v2.1, we still use struct smc_clc_first_contact_ext for compatible consideration. If the negotiated smc release version is v2.1 or later, use struct smc_clc_first_contact_ ext_v2x instead. Signed-off-by: Guangguan Wang Reviewed-by: Tony Lu --- net/smc/af_smc.c | 2 +- net/smc/smc_clc.c | 44 +++++++++++++++++++++++--------------------- net/smc/smc_clc.h | 15 +++++++++++++-- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index bac73eb0542d..52279bdc100a 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1113,7 +1113,7 @@ static int smc_connect_ism_vlan_cleanup(struct smc_sock *smc, #define SMC_CLC_MAX_ACCEPT_LEN \ (sizeof(struct smc_clc_msg_accept_confirm_v2) + \ - sizeof(struct smc_clc_first_contact_ext) + \ + sizeof(struct smc_clc_first_contact_ext_v2x) + \ sizeof(struct smc_clc_msg_trail)) /* CLC handshake during connect */ diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index b838ad0749b4..df8d17491a25 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -391,9 +391,7 @@ smc_clc_msg_acc_conf_valid(struct smc_clc_msg_accept_confirm_v2 *clc_v2) return false; } else { if (hdr->typev1 == SMC_TYPE_D && - ntohs(hdr->length) != SMCD_CLC_ACCEPT_CONFIRM_LEN_V2 && - (ntohs(hdr->length) != SMCD_CLC_ACCEPT_CONFIRM_LEN_V2 + - sizeof(struct smc_clc_first_contact_ext))) + ntohs(hdr->length) < SMCD_CLC_ACCEPT_CONFIRM_LEN_V2) return false; if (hdr->typev1 == SMC_TYPE_R && ntohs(hdr->length) < SMCR_CLC_ACCEPT_CONFIRM_LEN_V2) @@ -420,13 +418,19 @@ smc_clc_msg_decl_valid(struct smc_clc_msg_decline *dclc) return true; } -static void smc_clc_fill_fce(struct smc_clc_first_contact_ext *fce, int *len, int release_ver) +static int smc_clc_fill_fce(struct smc_clc_first_contact_ext_v2x *fce, + struct smc_init_info *ini) { + int ret = sizeof(*fce); + memset(fce, 0, sizeof(*fce)); - fce->os_type = SMC_CLC_OS_LINUX; - fce->release = release_ver; - memcpy(fce->hostname, smc_hostname, sizeof(smc_hostname)); - (*len) += sizeof(*fce); + fce->fce_v20.os_type = SMC_CLC_OS_LINUX; + fce->fce_v20.release = ini->release_ver; + memcpy(fce->fce_v20.hostname, smc_hostname, sizeof(smc_hostname)); + if (ini->is_smcd && ini->release_ver < SMC_RELEASE_1) + ret = sizeof(struct smc_clc_first_contact_ext); + + return ret; } /* check if received message has a correct header length and contains valid @@ -987,12 +991,12 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc, { struct smc_connection *conn = &smc->conn; struct smc_clc_msg_accept_confirm *clc; - struct smc_clc_first_contact_ext fce; + struct smc_clc_first_contact_ext_v2x fce; struct smc_clc_fce_gid_ext gle; struct smc_clc_msg_trail trl; struct kvec vec[5]; struct msghdr msg; - int i, len; + int i, len, fce_len; /* send SMC Confirm CLC msg */ clc = (struct smc_clc_msg_accept_confirm *)clc_v2; @@ -1018,8 +1022,10 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc, if (eid && eid[0]) memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN); len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2; - if (first_contact) - smc_clc_fill_fce(&fce, &len, ini->release_ver); + if (first_contact) { + fce_len = smc_clc_fill_fce(&fce, ini); + len += fce_len; + } clc_v2->hdr.length = htons(len); } memcpy(trl.eyecatcher, SMCD_EYECATCHER, @@ -1063,15 +1069,14 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc, memcpy(clc_v2->r1.eid, eid, SMC_MAX_EID_LEN); len = SMCR_CLC_ACCEPT_CONFIRM_LEN_V2; if (first_contact) { - smc_clc_fill_fce(&fce, &len, ini->release_ver); - fce.v2_direct = !link->lgr->uses_gateway; - memset(&gle, 0, sizeof(gle)); + fce_len = smc_clc_fill_fce(&fce, ini); + len += fce_len; + fce.fce_v20.v2_direct = !link->lgr->uses_gateway; if (ini && clc->hdr.type == SMC_CLC_CONFIRM) { + memset(&gle, 0, sizeof(gle)); gle.gid_cnt = ini->smcrv2.gidlist.len; len += sizeof(gle); len += gle.gid_cnt * sizeof(gle.gid[0]); - } else { - len += sizeof(gle.reserved); } } clc_v2->hdr.length = htons(len); @@ -1094,7 +1099,7 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc, sizeof(trl); if (version > SMC_V1 && first_contact) { vec[i].iov_base = &fce; - vec[i++].iov_len = sizeof(fce); + vec[i++].iov_len = fce_len; if (!conn->lgr->is_smcd) { if (clc->hdr.type == SMC_CLC_CONFIRM) { vec[i].iov_base = &gle; @@ -1102,9 +1107,6 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc, vec[i].iov_base = &ini->smcrv2.gidlist.list; vec[i++].iov_len = gle.gid_cnt * sizeof(gle.gid[0]); - } else { - vec[i].iov_base = &gle.reserved; - vec[i++].iov_len = sizeof(gle.reserved); } } } diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h index b923e89acafb..6133276a8839 100644 --- a/net/smc/smc_clc.h +++ b/net/smc/smc_clc.h @@ -147,7 +147,9 @@ struct smc_clc_msg_proposal_prefix { /* prefix part of clc proposal message*/ struct smc_clc_msg_smcd { /* SMC-D GID information */ struct smc_clc_smcd_gid_chid ism; /* ISM native GID+CHID of requestor */ __be16 v2_ext_offset; /* SMC Version 2 Extension Offset */ - u8 reserved[28]; + u8 vendor_oui[3]; + u8 vendor_exp_options[5]; + u8 reserved[20]; }; struct smc_clc_smcd_v2_extension { @@ -231,8 +233,17 @@ struct smc_clc_first_contact_ext { u8 hostname[SMC_MAX_HOSTNAME_LEN]; }; +struct smc_clc_first_contact_ext_v2x { + struct smc_clc_first_contact_ext fce_v20; + u8 reserved3[4]; + __be32 vendor_exp_options; + u8 reserved4[8]; +} __packed; /* format defined in + * IBM Shared Memory Communications Version 2 (Third Edition) + * (https://www.ibm.com/support/pages/node/7009315) + */ + struct smc_clc_fce_gid_ext { - u8 reserved[16]; u8 gid_cnt; u8 reserved2[3]; u8 gid[][SMC_GID_SIZE]; -- 2.24.3 (Apple Git-128)