blob: a2084ecdb97e0691f2fa2a7581501fa1c0eb08ee [file] [log] [blame]
Hans Wippelc6ba7c92018-06-28 19:05:07 +02001// SPDX-License-Identifier: GPL-2.0
2/* Shared Memory Communications Direct over ISM devices (SMC-D)
3 *
4 * Functions for ISM device.
5 *
6 * Copyright IBM Corp. 2018
7 */
8
Jakub Kicinskib6459412021-12-28 16:49:13 -08009#include <linux/if_vlan.h>
Hans Wippelc6ba7c92018-06-28 19:05:07 +020010#include <linux/spinlock.h>
Ursula Braun82087c02020-07-08 17:05:14 +020011#include <linux/mutex.h>
Hans Wippelc6ba7c92018-06-28 19:05:07 +020012#include <linux/slab.h>
13#include <asm/page.h>
14
15#include "smc.h"
16#include "smc_core.h"
17#include "smc_ism.h"
Hans Wippel1619f772018-06-28 19:05:08 +020018#include "smc_pnet.h"
Guvenc Gulceaaf95522020-12-01 20:20:48 +010019#include "smc_netlink.h"
Hans Wippelc6ba7c92018-06-28 19:05:07 +020020
21struct smcd_dev_list smcd_dev_list = {
22 .list = LIST_HEAD_INIT(smcd_dev_list.list),
Ursula Braun82087c02020-07-08 17:05:14 +020023 .mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex)
Hans Wippelc6ba7c92018-06-28 19:05:07 +020024};
25
Guvenc Gulce49407ae2020-12-01 20:20:42 +010026static bool smc_ism_v2_capable;
Karsten Graul11a26c52021-09-14 10:35:06 +020027static u8 smc_ism_v2_system_eid[SMC_MAX_EID_LEN];
Ursula Braun201091e2020-09-26 12:44:24 +020028
29/* Test if an ISM communication is possible - same CPC */
Hans Wippelc6ba7c92018-06-28 19:05:07 +020030int smc_ism_cantalk(u64 peer_gid, unsigned short vlan_id, struct smcd_dev *smcd)
31{
32 return smcd->ops->query_remote_gid(smcd, peer_gid, vlan_id ? 1 : 0,
33 vlan_id);
34}
35
36int smc_ism_write(struct smcd_dev *smcd, const struct smc_ism_position *pos,
37 void *data, size_t len)
38{
39 int rc;
40
41 rc = smcd->ops->move_data(smcd, pos->token, pos->index, pos->signal,
42 pos->offset, data, len);
43
44 return rc < 0 ? rc : 0;
45}
46
Karsten Graul11a26c52021-09-14 10:35:06 +020047void smc_ism_get_system_eid(u8 **eid)
Ursula Braun201091e2020-09-26 12:44:24 +020048{
Karsten Graul11a26c52021-09-14 10:35:06 +020049 if (!smc_ism_v2_capable)
50 *eid = NULL;
51 else
52 *eid = smc_ism_v2_system_eid;
Ursula Braun201091e2020-09-26 12:44:24 +020053}
54
Ursula Braun8caaccf2020-09-26 12:44:25 +020055u16 smc_ism_get_chid(struct smcd_dev *smcd)
56{
57 return smcd->ops->get_chid(smcd);
58}
59
Guvenc Gulce49407ae2020-12-01 20:20:42 +010060/* HW supports ISM V2 and thus System EID is defined */
61bool smc_ism_is_v2_capable(void)
62{
63 return smc_ism_v2_capable;
64}
65
Hans Wippelc6ba7c92018-06-28 19:05:07 +020066/* Set a connection using this DMBE. */
67void smc_ism_set_conn(struct smc_connection *conn)
68{
69 unsigned long flags;
70
71 spin_lock_irqsave(&conn->lgr->smcd->lock, flags);
72 conn->lgr->smcd->conn[conn->rmb_desc->sba_idx] = conn;
73 spin_unlock_irqrestore(&conn->lgr->smcd->lock, flags);
74}
75
76/* Unset a connection using this DMBE. */
77void smc_ism_unset_conn(struct smc_connection *conn)
78{
79 unsigned long flags;
80
81 if (!conn->rmb_desc)
82 return;
83
84 spin_lock_irqsave(&conn->lgr->smcd->lock, flags);
85 conn->lgr->smcd->conn[conn->rmb_desc->sba_idx] = NULL;
86 spin_unlock_irqrestore(&conn->lgr->smcd->lock, flags);
87}
88
89/* Register a VLAN identifier with the ISM device. Use a reference count
90 * and add a VLAN identifier only when the first DMB using this VLAN is
91 * registered.
92 */
93int smc_ism_get_vlan(struct smcd_dev *smcd, unsigned short vlanid)
94{
95 struct smc_ism_vlanid *new_vlan, *vlan;
96 unsigned long flags;
97 int rc = 0;
98
99 if (!vlanid) /* No valid vlan id */
100 return -EINVAL;
101
102 /* create new vlan entry, in case we need it */
103 new_vlan = kzalloc(sizeof(*new_vlan), GFP_KERNEL);
104 if (!new_vlan)
105 return -ENOMEM;
106 new_vlan->vlanid = vlanid;
107 refcount_set(&new_vlan->refcnt, 1);
108
109 /* if there is an existing entry, increase count and return */
110 spin_lock_irqsave(&smcd->lock, flags);
111 list_for_each_entry(vlan, &smcd->vlan, list) {
112 if (vlan->vlanid == vlanid) {
113 refcount_inc(&vlan->refcnt);
114 kfree(new_vlan);
115 goto out;
116 }
117 }
118
119 /* no existing entry found.
120 * add new entry to device; might fail, e.g., if HW limit reached
121 */
122 if (smcd->ops->add_vlan_id(smcd, vlanid)) {
123 kfree(new_vlan);
124 rc = -EIO;
125 goto out;
126 }
127 list_add_tail(&new_vlan->list, &smcd->vlan);
128out:
129 spin_unlock_irqrestore(&smcd->lock, flags);
130 return rc;
131}
132
133/* Unregister a VLAN identifier with the ISM device. Use a reference count
134 * and remove a VLAN identifier only when the last DMB using this VLAN is
135 * unregistered.
136 */
137int smc_ism_put_vlan(struct smcd_dev *smcd, unsigned short vlanid)
138{
139 struct smc_ism_vlanid *vlan;
140 unsigned long flags;
141 bool found = false;
142 int rc = 0;
143
144 if (!vlanid) /* No valid vlan id */
145 return -EINVAL;
146
147 spin_lock_irqsave(&smcd->lock, flags);
148 list_for_each_entry(vlan, &smcd->vlan, list) {
149 if (vlan->vlanid == vlanid) {
150 if (!refcount_dec_and_test(&vlan->refcnt))
151 goto out;
152 found = true;
153 break;
154 }
155 }
156 if (!found) {
157 rc = -ENOENT;
158 goto out; /* VLAN id not in table */
159 }
160
161 /* Found and the last reference just gone */
162 if (smcd->ops->del_vlan_id(smcd, vlanid))
163 rc = -EIO;
164 list_del(&vlan->list);
165 kfree(vlan);
166out:
167 spin_unlock_irqrestore(&smcd->lock, flags);
168 return rc;
169}
170
171int smc_ism_unregister_dmb(struct smcd_dev *smcd, struct smc_buf_desc *dmb_desc)
172{
173 struct smcd_dmb dmb;
Ursula Braun42bfba92019-11-14 13:02:41 +0100174 int rc = 0;
175
176 if (!dmb_desc->dma_addr)
177 return rc;
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200178
179 memset(&dmb, 0, sizeof(dmb));
180 dmb.dmb_tok = dmb_desc->token;
181 dmb.sba_idx = dmb_desc->sba_idx;
182 dmb.cpu_addr = dmb_desc->cpu_addr;
183 dmb.dma_addr = dmb_desc->dma_addr;
184 dmb.dmb_len = dmb_desc->len;
Ursula Braun42bfba92019-11-14 13:02:41 +0100185 rc = smcd->ops->unregister_dmb(smcd, &dmb);
186 if (!rc || rc == ISM_ERROR) {
187 dmb_desc->cpu_addr = NULL;
188 dmb_desc->dma_addr = 0;
189 }
190
191 return rc;
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200192}
193
194int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len,
195 struct smc_buf_desc *dmb_desc)
196{
197 struct smcd_dmb dmb;
198 int rc;
199
200 memset(&dmb, 0, sizeof(dmb));
201 dmb.dmb_len = dmb_len;
202 dmb.sba_idx = dmb_desc->sba_idx;
203 dmb.vlan_id = lgr->vlan_id;
204 dmb.rgid = lgr->peer_gid;
205 rc = lgr->smcd->ops->register_dmb(lgr->smcd, &dmb);
206 if (!rc) {
207 dmb_desc->sba_idx = dmb.sba_idx;
208 dmb_desc->token = dmb.dmb_tok;
209 dmb_desc->cpu_addr = dmb.cpu_addr;
210 dmb_desc->dma_addr = dmb.dma_addr;
211 dmb_desc->len = dmb.dmb_len;
212 }
213 return rc;
214}
215
Guvenc Gulceaaf95522020-12-01 20:20:48 +0100216static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd,
217 struct sk_buff *skb,
218 struct netlink_callback *cb)
219{
220 char smc_pnet[SMC_MAX_PNETID_LEN + 1];
221 struct smc_pci_dev smc_pci_dev;
222 struct nlattr *port_attrs;
223 struct nlattr *attrs;
224 int use_cnt = 0;
225 void *nlh;
226
227 nlh = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
228 &smc_gen_nl_family, NLM_F_MULTI,
229 SMC_NETLINK_GET_DEV_SMCD);
230 if (!nlh)
231 goto errmsg;
232 attrs = nla_nest_start(skb, SMC_GEN_DEV_SMCD);
233 if (!attrs)
234 goto errout;
235 use_cnt = atomic_read(&smcd->lgr_cnt);
236 if (nla_put_u32(skb, SMC_NLA_DEV_USE_CNT, use_cnt))
237 goto errattr;
238 if (nla_put_u8(skb, SMC_NLA_DEV_IS_CRIT, use_cnt > 0))
239 goto errattr;
240 memset(&smc_pci_dev, 0, sizeof(smc_pci_dev));
241 smc_set_pci_values(to_pci_dev(smcd->dev.parent), &smc_pci_dev);
242 if (nla_put_u32(skb, SMC_NLA_DEV_PCI_FID, smc_pci_dev.pci_fid))
243 goto errattr;
244 if (nla_put_u16(skb, SMC_NLA_DEV_PCI_CHID, smc_pci_dev.pci_pchid))
245 goto errattr;
246 if (nla_put_u16(skb, SMC_NLA_DEV_PCI_VENDOR, smc_pci_dev.pci_vendor))
247 goto errattr;
248 if (nla_put_u16(skb, SMC_NLA_DEV_PCI_DEVICE, smc_pci_dev.pci_device))
249 goto errattr;
250 if (nla_put_string(skb, SMC_NLA_DEV_PCI_ID, smc_pci_dev.pci_id))
251 goto errattr;
252
253 port_attrs = nla_nest_start(skb, SMC_NLA_DEV_PORT);
254 if (!port_attrs)
255 goto errattr;
256 if (nla_put_u8(skb, SMC_NLA_DEV_PORT_PNET_USR, smcd->pnetid_by_user))
257 goto errportattr;
Guvenc Gulce8a446532021-01-12 17:21:22 +0100258 memcpy(smc_pnet, smcd->pnetid, SMC_MAX_PNETID_LEN);
259 smc_pnet[SMC_MAX_PNETID_LEN] = 0;
Guvenc Gulceaaf95522020-12-01 20:20:48 +0100260 if (nla_put_string(skb, SMC_NLA_DEV_PORT_PNETID, smc_pnet))
261 goto errportattr;
262
263 nla_nest_end(skb, port_attrs);
264 nla_nest_end(skb, attrs);
265 genlmsg_end(skb, nlh);
266 return 0;
267
268errportattr:
269 nla_nest_cancel(skb, port_attrs);
270errattr:
271 nla_nest_cancel(skb, attrs);
272errout:
273 nlmsg_cancel(skb, nlh);
274errmsg:
275 return -EMSGSIZE;
276}
277
278static void smc_nl_prep_smcd_dev(struct smcd_dev_list *dev_list,
279 struct sk_buff *skb,
280 struct netlink_callback *cb)
281{
282 struct smc_nl_dmp_ctx *cb_ctx = smc_nl_dmp_ctx(cb);
283 int snum = cb_ctx->pos[0];
284 struct smcd_dev *smcd;
285 int num = 0;
286
287 mutex_lock(&dev_list->mutex);
288 list_for_each_entry(smcd, &dev_list->list, list) {
289 if (num < snum)
290 goto next;
291 if (smc_nl_handle_smcd_dev(smcd, skb, cb))
292 goto errout;
293next:
294 num++;
295 }
296errout:
297 mutex_unlock(&dev_list->mutex);
298 cb_ctx->pos[0] = num;
299}
300
301int smcd_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb)
302{
303 smc_nl_prep_smcd_dev(&smcd_dev_list, skb, cb);
304 return skb->len;
305}
306
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200307struct smc_ism_event_work {
308 struct work_struct work;
309 struct smcd_dev *smcd;
310 struct smcd_event event;
311};
312
Ursula Braun0d86caf2018-08-10 17:45:11 +0200313#define ISM_EVENT_REQUEST 0x0001
314#define ISM_EVENT_RESPONSE 0x0002
315#define ISM_EVENT_REQUEST_IR 0x00000001
Hans Wippel0512f692018-11-20 16:46:41 +0100316#define ISM_EVENT_CODE_SHUTDOWN 0x80
Ursula Braun0d86caf2018-08-10 17:45:11 +0200317#define ISM_EVENT_CODE_TESTLINK 0x83
318
Hans Wippel0512f692018-11-20 16:46:41 +0100319union smcd_sw_event_info {
320 u64 info;
321 struct {
322 u8 uid[SMC_LGR_ID_SIZE];
323 unsigned short vlan_id;
324 u16 code;
325 };
326};
327
Ursula Braun0d86caf2018-08-10 17:45:11 +0200328static void smcd_handle_sw_event(struct smc_ism_event_work *wrk)
329{
Hans Wippel0512f692018-11-20 16:46:41 +0100330 union smcd_sw_event_info ev_info;
Ursula Braun0d86caf2018-08-10 17:45:11 +0200331
Hans Wippel0512f692018-11-20 16:46:41 +0100332 ev_info.info = wrk->event.info;
Ursula Braun0d86caf2018-08-10 17:45:11 +0200333 switch (wrk->event.code) {
Hans Wippel0512f692018-11-20 16:46:41 +0100334 case ISM_EVENT_CODE_SHUTDOWN: /* Peer shut down DMBs */
335 smc_smcd_terminate(wrk->smcd, wrk->event.tok, ev_info.vlan_id);
336 break;
Ursula Braun0d86caf2018-08-10 17:45:11 +0200337 case ISM_EVENT_CODE_TESTLINK: /* Activity timer */
Ursula Braun0d86caf2018-08-10 17:45:11 +0200338 if (ev_info.code == ISM_EVENT_REQUEST) {
339 ev_info.code = ISM_EVENT_RESPONSE;
340 wrk->smcd->ops->signal_event(wrk->smcd,
341 wrk->event.tok,
342 ISM_EVENT_REQUEST_IR,
343 ISM_EVENT_CODE_TESTLINK,
344 ev_info.info);
345 }
346 break;
347 }
348}
349
Hans Wippel0512f692018-11-20 16:46:41 +0100350int smc_ism_signal_shutdown(struct smc_link_group *lgr)
351{
352 int rc;
353 union smcd_sw_event_info ev_info;
354
Ursula Braun50c6b202019-11-14 13:02:40 +0100355 if (lgr->peer_shutdown)
356 return 0;
357
Hans Wippel0512f692018-11-20 16:46:41 +0100358 memcpy(ev_info.uid, lgr->id, SMC_LGR_ID_SIZE);
359 ev_info.vlan_id = lgr->vlan_id;
360 ev_info.code = ISM_EVENT_REQUEST;
361 rc = lgr->smcd->ops->signal_event(lgr->smcd, lgr->peer_gid,
362 ISM_EVENT_REQUEST_IR,
363 ISM_EVENT_CODE_SHUTDOWN,
364 ev_info.info);
365 return rc;
366}
367
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200368/* worker for SMC-D events */
369static void smc_ism_event_work(struct work_struct *work)
370{
371 struct smc_ism_event_work *wrk =
372 container_of(work, struct smc_ism_event_work, work);
373
374 switch (wrk->event.type) {
375 case ISM_EVENT_GID: /* GID event, token is peer GID */
Hans Wippel0512f692018-11-20 16:46:41 +0100376 smc_smcd_terminate(wrk->smcd, wrk->event.tok, VLAN_VID_MASK);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200377 break;
378 case ISM_EVENT_DMB:
379 break;
Ursula Braun0d86caf2018-08-10 17:45:11 +0200380 case ISM_EVENT_SWR: /* Software defined event */
381 smcd_handle_sw_event(wrk);
382 break;
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200383 }
384 kfree(wrk);
385}
386
387static void smcd_release(struct device *dev)
388{
389 struct smcd_dev *smcd = container_of(dev, struct smcd_dev, dev);
390
391 kfree(smcd->conn);
392 kfree(smcd);
393}
394
395struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
396 const struct smcd_ops *ops, int max_dmbs)
397{
398 struct smcd_dev *smcd;
399
400 smcd = kzalloc(sizeof(*smcd), GFP_KERNEL);
401 if (!smcd)
402 return NULL;
403 smcd->conn = kcalloc(max_dmbs, sizeof(struct smc_connection *),
404 GFP_KERNEL);
405 if (!smcd->conn) {
406 kfree(smcd);
407 return NULL;
408 }
409
Anirudh Rayabharambbeb18f2021-05-03 13:56:44 +0200410 smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
411 WQ_MEM_RECLAIM, name);
412 if (!smcd->event_wq) {
413 kfree(smcd->conn);
414 kfree(smcd);
415 return NULL;
416 }
417
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200418 smcd->dev.parent = parent;
419 smcd->dev.release = smcd_release;
420 device_initialize(&smcd->dev);
421 dev_set_name(&smcd->dev, name);
422 smcd->ops = ops;
Karsten Graulfdff7042020-04-29 17:10:37 +0200423 if (smc_pnetid_by_dev_port(parent, 0, smcd->pnetid))
424 smc_pnetid_by_table_smcd(smcd);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200425
426 spin_lock_init(&smcd->lock);
Ursula Brauna0a62ee2019-10-09 10:07:44 +0200427 spin_lock_init(&smcd->lgr_lock);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200428 INIT_LIST_HEAD(&smcd->vlan);
Ursula Brauna2351c52019-10-09 10:07:43 +0200429 INIT_LIST_HEAD(&smcd->lgr_list);
Ursula Braun5edd6b92019-11-14 13:02:43 +0100430 init_waitqueue_head(&smcd->lgrs_deleted);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200431 return smcd;
432}
433EXPORT_SYMBOL_GPL(smcd_alloc_dev);
434
435int smcd_register_dev(struct smcd_dev *smcd)
436{
Julian Wiedmann444d7be2021-05-17 10:47:06 +0200437 int rc;
438
Ursula Braun82087c02020-07-08 17:05:14 +0200439 mutex_lock(&smcd_dev_list.mutex);
Ursula Braun201091e2020-09-26 12:44:24 +0200440 if (list_empty(&smcd_dev_list.list)) {
441 u8 *system_eid = NULL;
442
Karsten Graul11a26c52021-09-14 10:35:06 +0200443 smcd->ops->get_system_eid(smcd, &system_eid);
444 if (system_eid[24] != '0' || system_eid[28] != '0') {
Ursula Braun201091e2020-09-26 12:44:24 +0200445 smc_ism_v2_capable = true;
Karsten Graul11a26c52021-09-14 10:35:06 +0200446 memcpy(smc_ism_v2_system_eid, system_eid,
447 SMC_MAX_EID_LEN);
448 }
Ursula Braun201091e2020-09-26 12:44:24 +0200449 }
Ursula Braund70bf4f2020-09-26 12:44:27 +0200450 /* sort list: devices without pnetid before devices with pnetid */
451 if (smcd->pnetid[0])
452 list_add_tail(&smcd->list, &smcd_dev_list.list);
453 else
454 list_add(&smcd->list, &smcd_dev_list.list);
Ursula Braun82087c02020-07-08 17:05:14 +0200455 mutex_unlock(&smcd_dev_list.mutex);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200456
Karsten Graul0a99be42020-05-05 15:01:20 +0200457 pr_warn_ratelimited("smc: adding smcd device %s with pnetid %.16s%s\n",
458 dev_name(&smcd->dev), smcd->pnetid,
459 smcd->pnetid_by_user ? " (user defined)" : "");
460
Julian Wiedmann444d7be2021-05-17 10:47:06 +0200461 rc = device_add(&smcd->dev);
462 if (rc) {
463 mutex_lock(&smcd_dev_list.mutex);
464 list_del(&smcd->list);
465 mutex_unlock(&smcd_dev_list.mutex);
466 }
467
468 return rc;
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200469}
470EXPORT_SYMBOL_GPL(smcd_register_dev);
471
472void smcd_unregister_dev(struct smcd_dev *smcd)
473{
Karsten Graul0a99be42020-05-05 15:01:20 +0200474 pr_warn_ratelimited("smc: removing smcd device %s\n",
475 dev_name(&smcd->dev));
Ursula Braun82087c02020-07-08 17:05:14 +0200476 mutex_lock(&smcd_dev_list.mutex);
Ursula Braun50c6b202019-11-14 13:02:40 +0100477 list_del_init(&smcd->list);
Ursula Braun82087c02020-07-08 17:05:14 +0200478 mutex_unlock(&smcd_dev_list.mutex);
Ursula Braunc3d94942019-10-09 10:07:46 +0200479 smcd->going_away = 1;
Ursula Braun5421ec22019-11-14 13:02:42 +0100480 smc_smcd_terminate_all(smcd);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200481 destroy_workqueue(smcd->event_wq);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200482
483 device_del(&smcd->dev);
484}
485EXPORT_SYMBOL_GPL(smcd_unregister_dev);
486
487void smcd_free_dev(struct smcd_dev *smcd)
488{
489 put_device(&smcd->dev);
490}
491EXPORT_SYMBOL_GPL(smcd_free_dev);
492
493/* SMCD Device event handler. Called from ISM device interrupt handler.
494 * Parameters are smcd device pointer,
495 * - event->type (0 --> DMB, 1 --> GID),
496 * - event->code (event code),
497 * - event->tok (either DMB token when event type 0, or GID when event type 1)
498 * - event->time (time of day)
499 * - event->info (debug info).
500 *
501 * Context:
502 * - Function called in IRQ context from ISM device driver event handler.
503 */
504void smcd_handle_event(struct smcd_dev *smcd, struct smcd_event *event)
505{
506 struct smc_ism_event_work *wrk;
507
Ursula Braunc3d94942019-10-09 10:07:46 +0200508 if (smcd->going_away)
509 return;
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200510 /* copy event to event work queue, and let it be handled there */
511 wrk = kmalloc(sizeof(*wrk), GFP_ATOMIC);
512 if (!wrk)
513 return;
514 INIT_WORK(&wrk->work, smc_ism_event_work);
515 wrk->smcd = smcd;
516 wrk->event = *event;
517 queue_work(smcd->event_wq, &wrk->work);
518}
519EXPORT_SYMBOL_GPL(smcd_handle_event);
520
521/* SMCD Device interrupt handler. Called from ISM device interrupt handler.
522 * Parameters are smcd device pointer and DMB number. Find the connection and
523 * schedule the tasklet for this connection.
524 *
525 * Context:
526 * - Function called in IRQ context from ISM device driver IRQ handler.
527 */
528void smcd_handle_irq(struct smcd_dev *smcd, unsigned int dmbno)
529{
Hans Wippelbe244f22018-06-28 19:05:10 +0200530 struct smc_connection *conn = NULL;
531 unsigned long flags;
532
533 spin_lock_irqsave(&smcd->lock, flags);
534 conn = smcd->conn[dmbno];
Ursula Braun42bfba92019-11-14 13:02:41 +0100535 if (conn && !conn->killed)
Hans Wippelbe244f22018-06-28 19:05:10 +0200536 tasklet_schedule(&conn->rx_tsklet);
537 spin_unlock_irqrestore(&smcd->lock, flags);
Hans Wippelc6ba7c92018-06-28 19:05:07 +0200538}
539EXPORT_SYMBOL_GPL(smcd_handle_irq);
Ursula Braun201091e2020-09-26 12:44:24 +0200540
541void __init smc_ism_init(void)
542{
543 smc_ism_v2_capable = false;
Karsten Graul11a26c52021-09-14 10:35:06 +0200544 memset(smc_ism_v2_system_eid, 0, SMC_MAX_EID_LEN);
Ursula Braun201091e2020-09-26 12:44:24 +0200545}