Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp770729lqp; Sat, 13 Apr 2024 21:04:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUys2jQp+uwoi1mLm2HU0RaRXiJtHGciqSEEzC19dcoT5+rg3ROvw+GSQ9jZPkU/qLxOVlDoYV9nf6fG5rs/8UEoMxel6evC1eWsFOubQ== X-Google-Smtp-Source: AGHT+IF+bRpBGt1zZNZf4fxwFO/4MsAdMI/z2JdxTNEvj7vdYryk1R1ir9PQYhlrJ//zL/a92fQ1 X-Received: by 2002:ad4:55f3:0:b0:69b:6bec:75fb with SMTP id bu19-20020ad455f3000000b0069b6bec75fbmr1988624qvb.41.1713067479852; Sat, 13 Apr 2024 21:04:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713067479; cv=pass; d=google.com; s=arc-20160816; b=gyI+c32RI5eyDpb8DR9NAaDGq6xi/f+AAB5j8lPuUFme9+XLZSpWwMY9Aj/EEWx03L eyLEOyRbhxBa74hHYIqss+eqeizm1i8wuZHiSs+VNSZdZc1FLSiJXGR8bCH9pimDmb9X JjOPEJsW9PSzFHTbIVBiDEtplJjRSsGsM18IMyFzA5y9BdqT56ujVYko6KWsp/2kUTqM u7oEJG8xOomz0+mK6yDTRa0tpWRw/WgscweDC0fj3ziOWhX9WrU4rbq720IJa6LWLxHS jJUmVq5PSoAZOk0ZH2A3Cs5Q7NweqvRdwHb0qhmtwPSGdVdhAwIL2Ne6dkB7rBiEAcmY Jitw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eG6ReL9pq+zMQfcYcqJPjABDc7AH8aoIej1FGcZdQQ0=; fh=dZ+5j4HvJgOzvN8nB02tgPlkwHWSh0WzjxQ9fqEQCrY=; b=V9mXvKWrQsZdeEFdy1fg9gbnJ/tWlqx8AonvuPqvvHMCZAgYLuPx4sNCtHucuxD6Jl CApSSlfbVPuA/pilYZvSWUvg7K3DLXzNNyDAggYQxRPg+HyrwugWPy+kbEvMG1PDvdqp wcaFUrJ5MiSJIb4bmkYMCgMMKCw3s0bNnaQE1EOI6xeANSW2cwrOcTMX5iX8Yy3WDU8e ZASSoTLpJT+Qcss6tgpZdRy47/epwFMM1c4p33Tiv9rCDXaMqILsOsm3e56ykNzqhh7J qt3b/eS6lmLnwRGgeIL7ljx4Aq1FdCwat24yCI7eXamhIJTB34E4yxsXWxJQL9dfr7lV y3Dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=kItR4sTi; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-143961-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143961-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id px17-20020a056214051100b006993c143429si7084303qvb.384.2024.04.13.21.04.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 21:04:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143961-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=kItR4sTi; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-143961-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143961-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 919C71C20DB1 for ; Sun, 14 Apr 2024 04:04:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB064225D4; Sun, 14 Apr 2024 04:03:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="kItR4sTi" Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C1301CD18; Sun, 14 Apr 2024 04:03:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713067407; cv=none; b=L4X5JojPGygn6/5VMGLc56CmfY9ISKddEXsZCkWsGkKEl/nkmZSrifE4ecfkghjKzr2pwETd1M5e4IzVmFeqiGtoDyf9PHIbnT1RM0F2hIgQWQihTmKt5xGRwj4Er5zomJQUQ6TKxjy3BfoDC+254Lfu6Nh9/cnDmXGH6xPTDVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713067407; c=relaxed/simple; bh=fBK2PcH00VAAdDxKta1PMfrRrulLIAY8Gzvxh8htjmM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WycIoorZh3aQzDkVb2Qg3w1fUPyZuhNVubIBnZxec6xJc3Aws4waHPMgsCmh/rYCg0lkO+coHJmG7pwIil/o/BYjslzvUotJNAy6A+kM12nHKaOMX/CHl3jHIgYAXGIy/zPE6swWTfjPBQ4bGP9+SwlWRpulhwtrvFP0Y/yBbF0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=kItR4sTi; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1713067398; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=eG6ReL9pq+zMQfcYcqJPjABDc7AH8aoIej1FGcZdQQ0=; b=kItR4sTiQxnSH9NS4Ib0QxfRs5gAgoqmEqwILGiGcsP6bZ9sYR7Wq1R1vfZ+EYKcKDk+dEU6dW3MLRlNVZK3keAd+Q5BK/PZJfpHZOma52O+qMXAgEk75V3KCIYJk0MfpffOW7r8ldb2SLQBZUSq3jQaI2CBVtcHCJH5EkhZGO4= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0W4RuRxF_1713067396; Received: from localhost(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0W4RuRxF_1713067396) by smtp.aliyun-inc.com; Sun, 14 Apr 2024 12:03:17 +0800 From: Wen Gu To: wintera@linux.ibm.com, twinkler@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, wenjia@linux.ibm.com, jaka@linux.ibm.com Cc: borntraeger@linux.ibm.com, svens@linux.ibm.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v6 05/11] net/smc: mark optional smcd_ops and check for support when called Date: Sun, 14 Apr 2024 12:02:58 +0800 Message-Id: <20240414040304.54255-6-guwen@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240414040304.54255-1-guwen@linux.alibaba.com> References: <20240414040304.54255-1-guwen@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some operations are not supported by new introduced Emulated-ISM, so mark them as optional and check if the device supports them when called. Signed-off-by: Wen Gu --- include/net/smc.h | 14 ++++++++------ net/smc/smc_ism.c | 9 ++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/net/smc.h b/include/net/smc.h index 542d12372c18..33b753115e43 100644 --- a/include/net/smc.h +++ b/include/net/smc.h @@ -59,12 +59,6 @@ struct smcd_ops { int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb, void *client); int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb); - int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id); - int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id); - int (*set_vlan_required)(struct smcd_dev *dev); - int (*reset_vlan_required)(struct smcd_dev *dev); - int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid, - u32 trigger_irq, u32 event_code, u64 info); int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx, bool sf, unsigned int offset, void *data, unsigned int size); @@ -72,6 +66,14 @@ struct smcd_ops { void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid); u16 (*get_chid)(struct smcd_dev *dev); struct device* (*get_dev)(struct smcd_dev *dev); + + /* optional operations */ + int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id); + int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id); + int (*set_vlan_required)(struct smcd_dev *dev); + int (*reset_vlan_required)(struct smcd_dev *dev); + int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid, + u32 trigger_irq, u32 event_code, u64 info); }; struct smcd_dev { diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 051726586730..36459a3c739d 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -126,6 +126,8 @@ int smc_ism_get_vlan(struct smcd_dev *smcd, unsigned short vlanid) if (!vlanid) /* No valid vlan id */ return -EINVAL; + if (!smcd->ops->add_vlan_id) + return -EOPNOTSUPP; /* create new vlan entry, in case we need it */ new_vlan = kzalloc(sizeof(*new_vlan), GFP_KERNEL); @@ -171,6 +173,8 @@ int smc_ism_put_vlan(struct smcd_dev *smcd, unsigned short vlanid) if (!vlanid) /* No valid vlan id */ return -EINVAL; + if (!smcd->ops->del_vlan_id) + return -EOPNOTSUPP; spin_lock_irqsave(&smcd->lock, flags); list_for_each_entry(vlan, &smcd->vlan, list) { @@ -368,7 +372,8 @@ static void smcd_handle_sw_event(struct smc_ism_event_work *wrk) smc_smcd_terminate(wrk->smcd, &peer_gid, ev_info.vlan_id); break; case ISM_EVENT_CODE_TESTLINK: /* Activity timer */ - if (ev_info.code == ISM_EVENT_REQUEST) { + if (ev_info.code == ISM_EVENT_REQUEST && + wrk->smcd->ops->signal_event) { ev_info.code = ISM_EVENT_RESPONSE; wrk->smcd->ops->signal_event(wrk->smcd, &peer_gid, @@ -538,6 +543,8 @@ int smc_ism_signal_shutdown(struct smc_link_group *lgr) if (lgr->peer_shutdown) return 0; + if (!lgr->smcd->ops->signal_event) + return 0; memcpy(ev_info.uid, lgr->id, SMC_LGR_ID_SIZE); ev_info.vlan_id = lgr->vlan_id; -- 2.32.0.3.g01195cf9f