Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 1 | // 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 | |
| 9 | #include <linux/spinlock.h> |
Ursula Braun | 82087c0 | 2020-07-08 17:05:14 +0200 | [diff] [blame] | 10 | #include <linux/mutex.h> |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 11 | #include <linux/slab.h> |
| 12 | #include <asm/page.h> |
| 13 | |
| 14 | #include "smc.h" |
| 15 | #include "smc_core.h" |
| 16 | #include "smc_ism.h" |
Hans Wippel | 1619f77 | 2018-06-28 19:05:08 +0200 | [diff] [blame] | 17 | #include "smc_pnet.h" |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 18 | |
| 19 | struct smcd_dev_list smcd_dev_list = { |
| 20 | .list = LIST_HEAD_INIT(smcd_dev_list.list), |
Ursula Braun | 82087c0 | 2020-07-08 17:05:14 +0200 | [diff] [blame] | 21 | .mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex) |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 22 | }; |
| 23 | |
Ursula Braun | 201091e | 2020-09-26 12:44:24 +0200 | [diff] [blame^] | 24 | bool smc_ism_v2_capable; |
| 25 | |
| 26 | /* Test if an ISM communication is possible - same CPC */ |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 27 | int smc_ism_cantalk(u64 peer_gid, unsigned short vlan_id, struct smcd_dev *smcd) |
| 28 | { |
| 29 | return smcd->ops->query_remote_gid(smcd, peer_gid, vlan_id ? 1 : 0, |
| 30 | vlan_id); |
| 31 | } |
| 32 | |
| 33 | int smc_ism_write(struct smcd_dev *smcd, const struct smc_ism_position *pos, |
| 34 | void *data, size_t len) |
| 35 | { |
| 36 | int rc; |
| 37 | |
| 38 | rc = smcd->ops->move_data(smcd, pos->token, pos->index, pos->signal, |
| 39 | pos->offset, data, len); |
| 40 | |
| 41 | return rc < 0 ? rc : 0; |
| 42 | } |
| 43 | |
Ursula Braun | 201091e | 2020-09-26 12:44:24 +0200 | [diff] [blame^] | 44 | void smc_ism_get_system_eid(struct smcd_dev *smcd, u8 **eid) |
| 45 | { |
| 46 | smcd->ops->get_system_eid(smcd, eid); |
| 47 | } |
| 48 | |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 49 | /* Set a connection using this DMBE. */ |
| 50 | void smc_ism_set_conn(struct smc_connection *conn) |
| 51 | { |
| 52 | unsigned long flags; |
| 53 | |
| 54 | spin_lock_irqsave(&conn->lgr->smcd->lock, flags); |
| 55 | conn->lgr->smcd->conn[conn->rmb_desc->sba_idx] = conn; |
| 56 | spin_unlock_irqrestore(&conn->lgr->smcd->lock, flags); |
| 57 | } |
| 58 | |
| 59 | /* Unset a connection using this DMBE. */ |
| 60 | void smc_ism_unset_conn(struct smc_connection *conn) |
| 61 | { |
| 62 | unsigned long flags; |
| 63 | |
| 64 | if (!conn->rmb_desc) |
| 65 | return; |
| 66 | |
| 67 | spin_lock_irqsave(&conn->lgr->smcd->lock, flags); |
| 68 | conn->lgr->smcd->conn[conn->rmb_desc->sba_idx] = NULL; |
| 69 | spin_unlock_irqrestore(&conn->lgr->smcd->lock, flags); |
| 70 | } |
| 71 | |
| 72 | /* Register a VLAN identifier with the ISM device. Use a reference count |
| 73 | * and add a VLAN identifier only when the first DMB using this VLAN is |
| 74 | * registered. |
| 75 | */ |
| 76 | int smc_ism_get_vlan(struct smcd_dev *smcd, unsigned short vlanid) |
| 77 | { |
| 78 | struct smc_ism_vlanid *new_vlan, *vlan; |
| 79 | unsigned long flags; |
| 80 | int rc = 0; |
| 81 | |
| 82 | if (!vlanid) /* No valid vlan id */ |
| 83 | return -EINVAL; |
| 84 | |
| 85 | /* create new vlan entry, in case we need it */ |
| 86 | new_vlan = kzalloc(sizeof(*new_vlan), GFP_KERNEL); |
| 87 | if (!new_vlan) |
| 88 | return -ENOMEM; |
| 89 | new_vlan->vlanid = vlanid; |
| 90 | refcount_set(&new_vlan->refcnt, 1); |
| 91 | |
| 92 | /* if there is an existing entry, increase count and return */ |
| 93 | spin_lock_irqsave(&smcd->lock, flags); |
| 94 | list_for_each_entry(vlan, &smcd->vlan, list) { |
| 95 | if (vlan->vlanid == vlanid) { |
| 96 | refcount_inc(&vlan->refcnt); |
| 97 | kfree(new_vlan); |
| 98 | goto out; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /* no existing entry found. |
| 103 | * add new entry to device; might fail, e.g., if HW limit reached |
| 104 | */ |
| 105 | if (smcd->ops->add_vlan_id(smcd, vlanid)) { |
| 106 | kfree(new_vlan); |
| 107 | rc = -EIO; |
| 108 | goto out; |
| 109 | } |
| 110 | list_add_tail(&new_vlan->list, &smcd->vlan); |
| 111 | out: |
| 112 | spin_unlock_irqrestore(&smcd->lock, flags); |
| 113 | return rc; |
| 114 | } |
| 115 | |
| 116 | /* Unregister a VLAN identifier with the ISM device. Use a reference count |
| 117 | * and remove a VLAN identifier only when the last DMB using this VLAN is |
| 118 | * unregistered. |
| 119 | */ |
| 120 | int smc_ism_put_vlan(struct smcd_dev *smcd, unsigned short vlanid) |
| 121 | { |
| 122 | struct smc_ism_vlanid *vlan; |
| 123 | unsigned long flags; |
| 124 | bool found = false; |
| 125 | int rc = 0; |
| 126 | |
| 127 | if (!vlanid) /* No valid vlan id */ |
| 128 | return -EINVAL; |
| 129 | |
| 130 | spin_lock_irqsave(&smcd->lock, flags); |
| 131 | list_for_each_entry(vlan, &smcd->vlan, list) { |
| 132 | if (vlan->vlanid == vlanid) { |
| 133 | if (!refcount_dec_and_test(&vlan->refcnt)) |
| 134 | goto out; |
| 135 | found = true; |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | if (!found) { |
| 140 | rc = -ENOENT; |
| 141 | goto out; /* VLAN id not in table */ |
| 142 | } |
| 143 | |
| 144 | /* Found and the last reference just gone */ |
| 145 | if (smcd->ops->del_vlan_id(smcd, vlanid)) |
| 146 | rc = -EIO; |
| 147 | list_del(&vlan->list); |
| 148 | kfree(vlan); |
| 149 | out: |
| 150 | spin_unlock_irqrestore(&smcd->lock, flags); |
| 151 | return rc; |
| 152 | } |
| 153 | |
| 154 | int smc_ism_unregister_dmb(struct smcd_dev *smcd, struct smc_buf_desc *dmb_desc) |
| 155 | { |
| 156 | struct smcd_dmb dmb; |
Ursula Braun | 42bfba9 | 2019-11-14 13:02:41 +0100 | [diff] [blame] | 157 | int rc = 0; |
| 158 | |
| 159 | if (!dmb_desc->dma_addr) |
| 160 | return rc; |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 161 | |
| 162 | memset(&dmb, 0, sizeof(dmb)); |
| 163 | dmb.dmb_tok = dmb_desc->token; |
| 164 | dmb.sba_idx = dmb_desc->sba_idx; |
| 165 | dmb.cpu_addr = dmb_desc->cpu_addr; |
| 166 | dmb.dma_addr = dmb_desc->dma_addr; |
| 167 | dmb.dmb_len = dmb_desc->len; |
Ursula Braun | 42bfba9 | 2019-11-14 13:02:41 +0100 | [diff] [blame] | 168 | rc = smcd->ops->unregister_dmb(smcd, &dmb); |
| 169 | if (!rc || rc == ISM_ERROR) { |
| 170 | dmb_desc->cpu_addr = NULL; |
| 171 | dmb_desc->dma_addr = 0; |
| 172 | } |
| 173 | |
| 174 | return rc; |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len, |
| 178 | struct smc_buf_desc *dmb_desc) |
| 179 | { |
| 180 | struct smcd_dmb dmb; |
| 181 | int rc; |
| 182 | |
| 183 | memset(&dmb, 0, sizeof(dmb)); |
| 184 | dmb.dmb_len = dmb_len; |
| 185 | dmb.sba_idx = dmb_desc->sba_idx; |
| 186 | dmb.vlan_id = lgr->vlan_id; |
| 187 | dmb.rgid = lgr->peer_gid; |
| 188 | rc = lgr->smcd->ops->register_dmb(lgr->smcd, &dmb); |
| 189 | if (!rc) { |
| 190 | dmb_desc->sba_idx = dmb.sba_idx; |
| 191 | dmb_desc->token = dmb.dmb_tok; |
| 192 | dmb_desc->cpu_addr = dmb.cpu_addr; |
| 193 | dmb_desc->dma_addr = dmb.dma_addr; |
| 194 | dmb_desc->len = dmb.dmb_len; |
| 195 | } |
| 196 | return rc; |
| 197 | } |
| 198 | |
| 199 | struct smc_ism_event_work { |
| 200 | struct work_struct work; |
| 201 | struct smcd_dev *smcd; |
| 202 | struct smcd_event event; |
| 203 | }; |
| 204 | |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 205 | #define ISM_EVENT_REQUEST 0x0001 |
| 206 | #define ISM_EVENT_RESPONSE 0x0002 |
| 207 | #define ISM_EVENT_REQUEST_IR 0x00000001 |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 208 | #define ISM_EVENT_CODE_SHUTDOWN 0x80 |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 209 | #define ISM_EVENT_CODE_TESTLINK 0x83 |
| 210 | |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 211 | union smcd_sw_event_info { |
| 212 | u64 info; |
| 213 | struct { |
| 214 | u8 uid[SMC_LGR_ID_SIZE]; |
| 215 | unsigned short vlan_id; |
| 216 | u16 code; |
| 217 | }; |
| 218 | }; |
| 219 | |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 220 | static void smcd_handle_sw_event(struct smc_ism_event_work *wrk) |
| 221 | { |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 222 | union smcd_sw_event_info ev_info; |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 223 | |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 224 | ev_info.info = wrk->event.info; |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 225 | switch (wrk->event.code) { |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 226 | case ISM_EVENT_CODE_SHUTDOWN: /* Peer shut down DMBs */ |
| 227 | smc_smcd_terminate(wrk->smcd, wrk->event.tok, ev_info.vlan_id); |
| 228 | break; |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 229 | case ISM_EVENT_CODE_TESTLINK: /* Activity timer */ |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 230 | if (ev_info.code == ISM_EVENT_REQUEST) { |
| 231 | ev_info.code = ISM_EVENT_RESPONSE; |
| 232 | wrk->smcd->ops->signal_event(wrk->smcd, |
| 233 | wrk->event.tok, |
| 234 | ISM_EVENT_REQUEST_IR, |
| 235 | ISM_EVENT_CODE_TESTLINK, |
| 236 | ev_info.info); |
| 237 | } |
| 238 | break; |
| 239 | } |
| 240 | } |
| 241 | |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 242 | int smc_ism_signal_shutdown(struct smc_link_group *lgr) |
| 243 | { |
| 244 | int rc; |
| 245 | union smcd_sw_event_info ev_info; |
| 246 | |
Ursula Braun | 50c6b20 | 2019-11-14 13:02:40 +0100 | [diff] [blame] | 247 | if (lgr->peer_shutdown) |
| 248 | return 0; |
| 249 | |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 250 | memcpy(ev_info.uid, lgr->id, SMC_LGR_ID_SIZE); |
| 251 | ev_info.vlan_id = lgr->vlan_id; |
| 252 | ev_info.code = ISM_EVENT_REQUEST; |
| 253 | rc = lgr->smcd->ops->signal_event(lgr->smcd, lgr->peer_gid, |
| 254 | ISM_EVENT_REQUEST_IR, |
| 255 | ISM_EVENT_CODE_SHUTDOWN, |
| 256 | ev_info.info); |
| 257 | return rc; |
| 258 | } |
| 259 | |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 260 | /* worker for SMC-D events */ |
| 261 | static void smc_ism_event_work(struct work_struct *work) |
| 262 | { |
| 263 | struct smc_ism_event_work *wrk = |
| 264 | container_of(work, struct smc_ism_event_work, work); |
| 265 | |
| 266 | switch (wrk->event.type) { |
| 267 | case ISM_EVENT_GID: /* GID event, token is peer GID */ |
Hans Wippel | 0512f69 | 2018-11-20 16:46:41 +0100 | [diff] [blame] | 268 | smc_smcd_terminate(wrk->smcd, wrk->event.tok, VLAN_VID_MASK); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 269 | break; |
| 270 | case ISM_EVENT_DMB: |
| 271 | break; |
Ursula Braun | 0d86caf | 2018-08-10 17:45:11 +0200 | [diff] [blame] | 272 | case ISM_EVENT_SWR: /* Software defined event */ |
| 273 | smcd_handle_sw_event(wrk); |
| 274 | break; |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 275 | } |
| 276 | kfree(wrk); |
| 277 | } |
| 278 | |
| 279 | static void smcd_release(struct device *dev) |
| 280 | { |
| 281 | struct smcd_dev *smcd = container_of(dev, struct smcd_dev, dev); |
| 282 | |
| 283 | kfree(smcd->conn); |
| 284 | kfree(smcd); |
| 285 | } |
| 286 | |
| 287 | struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name, |
| 288 | const struct smcd_ops *ops, int max_dmbs) |
| 289 | { |
| 290 | struct smcd_dev *smcd; |
| 291 | |
| 292 | smcd = kzalloc(sizeof(*smcd), GFP_KERNEL); |
| 293 | if (!smcd) |
| 294 | return NULL; |
| 295 | smcd->conn = kcalloc(max_dmbs, sizeof(struct smc_connection *), |
| 296 | GFP_KERNEL); |
| 297 | if (!smcd->conn) { |
| 298 | kfree(smcd); |
| 299 | return NULL; |
| 300 | } |
| 301 | |
| 302 | smcd->dev.parent = parent; |
| 303 | smcd->dev.release = smcd_release; |
| 304 | device_initialize(&smcd->dev); |
| 305 | dev_set_name(&smcd->dev, name); |
| 306 | smcd->ops = ops; |
Karsten Graul | fdff704 | 2020-04-29 17:10:37 +0200 | [diff] [blame] | 307 | if (smc_pnetid_by_dev_port(parent, 0, smcd->pnetid)) |
| 308 | smc_pnetid_by_table_smcd(smcd); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 309 | |
| 310 | spin_lock_init(&smcd->lock); |
Ursula Braun | a0a62ee | 2019-10-09 10:07:44 +0200 | [diff] [blame] | 311 | spin_lock_init(&smcd->lgr_lock); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 312 | INIT_LIST_HEAD(&smcd->vlan); |
Ursula Braun | a2351c5 | 2019-10-09 10:07:43 +0200 | [diff] [blame] | 313 | INIT_LIST_HEAD(&smcd->lgr_list); |
Ursula Braun | 5edd6b9 | 2019-11-14 13:02:43 +0100 | [diff] [blame] | 314 | init_waitqueue_head(&smcd->lgrs_deleted); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 315 | smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)", |
| 316 | WQ_MEM_RECLAIM, name); |
Kangjie Lu | e183d4e | 2019-04-11 11:17:31 +0200 | [diff] [blame] | 317 | if (!smcd->event_wq) { |
| 318 | kfree(smcd->conn); |
| 319 | kfree(smcd); |
| 320 | return NULL; |
| 321 | } |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 322 | return smcd; |
| 323 | } |
| 324 | EXPORT_SYMBOL_GPL(smcd_alloc_dev); |
| 325 | |
| 326 | int smcd_register_dev(struct smcd_dev *smcd) |
| 327 | { |
Ursula Braun | 82087c0 | 2020-07-08 17:05:14 +0200 | [diff] [blame] | 328 | mutex_lock(&smcd_dev_list.mutex); |
Ursula Braun | 201091e | 2020-09-26 12:44:24 +0200 | [diff] [blame^] | 329 | if (list_empty(&smcd_dev_list.list)) { |
| 330 | u8 *system_eid = NULL; |
| 331 | |
| 332 | smc_ism_get_system_eid(smcd, &system_eid); |
| 333 | if ((*system_eid) + 24 != '0' || (*system_eid) + 28 != '0') |
| 334 | smc_ism_v2_capable = true; |
| 335 | } |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 336 | list_add_tail(&smcd->list, &smcd_dev_list.list); |
Ursula Braun | 82087c0 | 2020-07-08 17:05:14 +0200 | [diff] [blame] | 337 | mutex_unlock(&smcd_dev_list.mutex); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 338 | |
Karsten Graul | 0a99be4 | 2020-05-05 15:01:20 +0200 | [diff] [blame] | 339 | pr_warn_ratelimited("smc: adding smcd device %s with pnetid %.16s%s\n", |
| 340 | dev_name(&smcd->dev), smcd->pnetid, |
| 341 | smcd->pnetid_by_user ? " (user defined)" : ""); |
| 342 | |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 343 | return device_add(&smcd->dev); |
| 344 | } |
| 345 | EXPORT_SYMBOL_GPL(smcd_register_dev); |
| 346 | |
| 347 | void smcd_unregister_dev(struct smcd_dev *smcd) |
| 348 | { |
Karsten Graul | 0a99be4 | 2020-05-05 15:01:20 +0200 | [diff] [blame] | 349 | pr_warn_ratelimited("smc: removing smcd device %s\n", |
| 350 | dev_name(&smcd->dev)); |
Ursula Braun | 82087c0 | 2020-07-08 17:05:14 +0200 | [diff] [blame] | 351 | mutex_lock(&smcd_dev_list.mutex); |
Ursula Braun | 50c6b20 | 2019-11-14 13:02:40 +0100 | [diff] [blame] | 352 | list_del_init(&smcd->list); |
Ursula Braun | 82087c0 | 2020-07-08 17:05:14 +0200 | [diff] [blame] | 353 | mutex_unlock(&smcd_dev_list.mutex); |
Ursula Braun | c3d9494 | 2019-10-09 10:07:46 +0200 | [diff] [blame] | 354 | smcd->going_away = 1; |
Ursula Braun | 5421ec2 | 2019-11-14 13:02:42 +0100 | [diff] [blame] | 355 | smc_smcd_terminate_all(smcd); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 356 | flush_workqueue(smcd->event_wq); |
| 357 | destroy_workqueue(smcd->event_wq); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 358 | |
| 359 | device_del(&smcd->dev); |
| 360 | } |
| 361 | EXPORT_SYMBOL_GPL(smcd_unregister_dev); |
| 362 | |
| 363 | void smcd_free_dev(struct smcd_dev *smcd) |
| 364 | { |
| 365 | put_device(&smcd->dev); |
| 366 | } |
| 367 | EXPORT_SYMBOL_GPL(smcd_free_dev); |
| 368 | |
| 369 | /* SMCD Device event handler. Called from ISM device interrupt handler. |
| 370 | * Parameters are smcd device pointer, |
| 371 | * - event->type (0 --> DMB, 1 --> GID), |
| 372 | * - event->code (event code), |
| 373 | * - event->tok (either DMB token when event type 0, or GID when event type 1) |
| 374 | * - event->time (time of day) |
| 375 | * - event->info (debug info). |
| 376 | * |
| 377 | * Context: |
| 378 | * - Function called in IRQ context from ISM device driver event handler. |
| 379 | */ |
| 380 | void smcd_handle_event(struct smcd_dev *smcd, struct smcd_event *event) |
| 381 | { |
| 382 | struct smc_ism_event_work *wrk; |
| 383 | |
Ursula Braun | c3d9494 | 2019-10-09 10:07:46 +0200 | [diff] [blame] | 384 | if (smcd->going_away) |
| 385 | return; |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 386 | /* copy event to event work queue, and let it be handled there */ |
| 387 | wrk = kmalloc(sizeof(*wrk), GFP_ATOMIC); |
| 388 | if (!wrk) |
| 389 | return; |
| 390 | INIT_WORK(&wrk->work, smc_ism_event_work); |
| 391 | wrk->smcd = smcd; |
| 392 | wrk->event = *event; |
| 393 | queue_work(smcd->event_wq, &wrk->work); |
| 394 | } |
| 395 | EXPORT_SYMBOL_GPL(smcd_handle_event); |
| 396 | |
| 397 | /* SMCD Device interrupt handler. Called from ISM device interrupt handler. |
| 398 | * Parameters are smcd device pointer and DMB number. Find the connection and |
| 399 | * schedule the tasklet for this connection. |
| 400 | * |
| 401 | * Context: |
| 402 | * - Function called in IRQ context from ISM device driver IRQ handler. |
| 403 | */ |
| 404 | void smcd_handle_irq(struct smcd_dev *smcd, unsigned int dmbno) |
| 405 | { |
Hans Wippel | be244f2 | 2018-06-28 19:05:10 +0200 | [diff] [blame] | 406 | struct smc_connection *conn = NULL; |
| 407 | unsigned long flags; |
| 408 | |
| 409 | spin_lock_irqsave(&smcd->lock, flags); |
| 410 | conn = smcd->conn[dmbno]; |
Ursula Braun | 42bfba9 | 2019-11-14 13:02:41 +0100 | [diff] [blame] | 411 | if (conn && !conn->killed) |
Hans Wippel | be244f2 | 2018-06-28 19:05:10 +0200 | [diff] [blame] | 412 | tasklet_schedule(&conn->rx_tsklet); |
| 413 | spin_unlock_irqrestore(&smcd->lock, flags); |
Hans Wippel | c6ba7c9 | 2018-06-28 19:05:07 +0200 | [diff] [blame] | 414 | } |
| 415 | EXPORT_SYMBOL_GPL(smcd_handle_irq); |
Ursula Braun | 201091e | 2020-09-26 12:44:24 +0200 | [diff] [blame^] | 416 | |
| 417 | void __init smc_ism_init(void) |
| 418 | { |
| 419 | smc_ism_v2_capable = false; |
| 420 | } |