From: Wen Gu <guwen@linux.alibaba.com>
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 v7 05/11] net/smc: mark optional smcd_ops and check for support when called
Date: Sun, 28 Apr 2024 14:07:32 +0800 [thread overview]
Message-ID: <20240428060738.60843-6-guwen@linux.alibaba.com> (raw)
In-Reply-To: <20240428060738.60843-1-guwen@linux.alibaba.com>
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 <guwen@linux.alibaba.com>
Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
Reviewed-and-tested-by: Jan Karcher <jaka@linux.ibm.com>
---
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
next prev parent reply other threads:[~2024-04-28 6:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 6:07 [PATCH net-next v7 00/11] net/smc: SMC intra-OS shortcut with loopback-ism Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 01/11] net/smc: decouple ism_client from SMC-D DMB registration Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 02/11] net/smc: introduce loopback-ism for SMC intra-OS shortcut Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 03/11] net/smc: implement ID-related operations of loopback-ism Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 04/11] net/smc: implement DMB-related " Wen Gu
2024-04-28 6:07 ` Wen Gu [this message]
2024-04-28 6:07 ` [PATCH net-next v7 06/11] net/smc: ignore loopback-ism when dumping SMC-D devices Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 07/11] net/smc: register loopback-ism into SMC-D device list Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 08/11] net/smc: add operations to merge sndbuf with peer DMB Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 09/11] net/smc: {at|de}tach sndbuf to peer DMB if supported Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 10/11] net/smc: adapt cursor update when sndbuf and peer DMB are merged Wen Gu
2024-04-28 6:07 ` [PATCH net-next v7 11/11] net/smc: implement DMB-merged operations of loopback-ism Wen Gu
2024-04-28 15:49 ` [PATCH net-next v7 00/11] net/smc: SMC intra-OS shortcut with loopback-ism Cong Wang
2024-05-07 14:34 ` Wen Gu
2024-05-07 16:10 ` Cong Wang
2024-05-08 3:48 ` Wen Gu
2024-05-08 6:39 ` Tony Lu
2024-04-30 11:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240428060738.60843-6-guwen@linux.alibaba.com \
--to=guwen@linux.alibaba.com \
--cc=agordeev@linux.ibm.com \
--cc=alibuda@linux.alibaba.com \
--cc=borntraeger@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jaka@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=svens@linux.ibm.com \
--cc=tonylu@linux.alibaba.com \
--cc=twinkler@linux.ibm.com \
--cc=wenjia@linux.ibm.com \
--cc=wintera@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).