smc_ism.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. #include <linux/if_vlan.h>
  9. #include <linux/spinlock.h>
  10. #include <linux/mutex.h>
  11. #include <linux/slab.h>
  12. #include <asm/page.h>
  13. #include "smc.h"
  14. #include "smc_core.h"
  15. #include "smc_ism.h"
  16. #include "smc_pnet.h"
  17. #include "smc_netlink.h"
  18. #include "linux/ism.h"
  19. struct smcd_dev_list smcd_dev_list = {
  20. .list = LIST_HEAD_INIT(smcd_dev_list.list),
  21. .mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex)
  22. };
  23. static bool smc_ism_v2_capable;
  24. static u8 smc_ism_v2_system_eid[SMC_MAX_EID_LEN];
  25. #if IS_ENABLED(CONFIG_ISM)
  26. static void smcd_register_dev(struct ism_dev *ism);
  27. static void smcd_unregister_dev(struct ism_dev *ism);
  28. static void smcd_handle_event(struct ism_dev *ism, struct ism_event *event);
  29. static void smcd_handle_irq(struct ism_dev *ism, unsigned int dmbno,
  30. u16 dmbemask);
  31. static struct ism_client smc_ism_client = {
  32. .name = "SMC-D",
  33. .add = smcd_register_dev,
  34. .remove = smcd_unregister_dev,
  35. .handle_event = smcd_handle_event,
  36. .handle_irq = smcd_handle_irq,
  37. };
  38. #endif
  39. static void smc_ism_create_system_eid(void)
  40. {
  41. struct smc_ism_seid *seid =
  42. (struct smc_ism_seid *)smc_ism_v2_system_eid;
  43. #if IS_ENABLED(CONFIG_S390)
  44. struct cpuid id;
  45. u16 ident_tail;
  46. char tmp[5];
  47. memcpy(seid->seid_string, "IBM-SYSZ-ISMSEID00000000", 24);
  48. get_cpu_id(&id);
  49. ident_tail = (u16)(id.ident & SMC_ISM_IDENT_MASK);
  50. snprintf(tmp, 5, "%04X", ident_tail);
  51. memcpy(seid->serial_number, tmp, 4);
  52. snprintf(tmp, 5, "%04X", id.machine);
  53. memcpy(seid->type, tmp, 4);
  54. #else
  55. memset(seid, 0, SMC_MAX_EID_LEN);
  56. #endif
  57. }
  58. /* Test if an ISM communication is possible - same CPC */
  59. int smc_ism_cantalk(struct smcd_gid *peer_gid, unsigned short vlan_id,
  60. struct smcd_dev *smcd)
  61. {
  62. return smcd->ops->query_remote_gid(smcd, peer_gid, vlan_id ? 1 : 0,
  63. vlan_id);
  64. }
  65. void smc_ism_get_system_eid(u8 **eid)
  66. {
  67. if (!smc_ism_v2_capable)
  68. *eid = NULL;
  69. else
  70. *eid = smc_ism_v2_system_eid;
  71. }
  72. u16 smc_ism_get_chid(struct smcd_dev *smcd)
  73. {
  74. return smcd->ops->get_chid(smcd);
  75. }
  76. /* HW supports ISM V2 and thus System EID is defined */
  77. bool smc_ism_is_v2_capable(void)
  78. {
  79. return smc_ism_v2_capable;
  80. }
  81. void smc_ism_set_v2_capable(void)
  82. {
  83. smc_ism_v2_capable = true;
  84. }
  85. /* Set a connection using this DMBE. */
  86. void smc_ism_set_conn(struct smc_connection *conn)
  87. {
  88. unsigned long flags;
  89. spin_lock_irqsave(&conn->lgr->smcd->lock, flags);
  90. conn->lgr->smcd->conn[conn->rmb_desc->sba_idx] = conn;
  91. spin_unlock_irqrestore(&conn->lgr->smcd->lock, flags);
  92. }
  93. /* Unset a connection using this DMBE. */
  94. void smc_ism_unset_conn(struct smc_connection *conn)
  95. {
  96. unsigned long flags;
  97. if (!conn->rmb_desc)
  98. return;
  99. spin_lock_irqsave(&conn->lgr->smcd->lock, flags);
  100. conn->lgr->smcd->conn[conn->rmb_desc->sba_idx] = NULL;
  101. spin_unlock_irqrestore(&conn->lgr->smcd->lock, flags);
  102. }
  103. /* Register a VLAN identifier with the ISM device. Use a reference count
  104. * and add a VLAN identifier only when the first DMB using this VLAN is
  105. * registered.
  106. */
  107. int smc_ism_get_vlan(struct smcd_dev *smcd, unsigned short vlanid)
  108. {
  109. struct smc_ism_vlanid *new_vlan, *vlan;
  110. unsigned long flags;
  111. int rc = 0;
  112. if (!vlanid) /* No valid vlan id */
  113. return -EINVAL;
  114. if (!smcd->ops->add_vlan_id)
  115. return -EOPNOTSUPP;
  116. /* create new vlan entry, in case we need it */
  117. new_vlan = kzalloc(sizeof(*new_vlan), GFP_KERNEL);
  118. if (!new_vlan)
  119. return -ENOMEM;
  120. new_vlan->vlanid = vlanid;
  121. refcount_set(&new_vlan->refcnt, 1);
  122. /* if there is an existing entry, increase count and return */
  123. spin_lock_irqsave(&smcd->lock, flags);
  124. list_for_each_entry(vlan, &smcd->vlan, list) {
  125. if (vlan->vlanid == vlanid) {
  126. refcount_inc(&vlan->refcnt);
  127. kfree(new_vlan);
  128. goto out;
  129. }
  130. }
  131. /* no existing entry found.
  132. * add new entry to device; might fail, e.g., if HW limit reached
  133. */
  134. if (smcd->ops->add_vlan_id(smcd, vlanid)) {
  135. kfree(new_vlan);
  136. rc = -EIO;
  137. goto out;
  138. }
  139. list_add_tail(&new_vlan->list, &smcd->vlan);
  140. out:
  141. spin_unlock_irqrestore(&smcd->lock, flags);
  142. return rc;
  143. }
  144. /* Unregister a VLAN identifier with the ISM device. Use a reference count
  145. * and remove a VLAN identifier only when the last DMB using this VLAN is
  146. * unregistered.
  147. */
  148. int smc_ism_put_vlan(struct smcd_dev *smcd, unsigned short vlanid)
  149. {
  150. struct smc_ism_vlanid *vlan;
  151. unsigned long flags;
  152. bool found = false;
  153. int rc = 0;
  154. if (!vlanid) /* No valid vlan id */
  155. return -EINVAL;
  156. if (!smcd->ops->del_vlan_id)
  157. return -EOPNOTSUPP;
  158. spin_lock_irqsave(&smcd->lock, flags);
  159. list_for_each_entry(vlan, &smcd->vlan, list) {
  160. if (vlan->vlanid == vlanid) {
  161. if (!refcount_dec_and_test(&vlan->refcnt))
  162. goto out;
  163. found = true;
  164. break;
  165. }
  166. }
  167. if (!found) {
  168. rc = -ENOENT;
  169. goto out; /* VLAN id not in table */
  170. }
  171. /* Found and the last reference just gone */
  172. if (smcd->ops->del_vlan_id(smcd, vlanid))
  173. rc = -EIO;
  174. list_del(&vlan->list);
  175. kfree(vlan);
  176. out:
  177. spin_unlock_irqrestore(&smcd->lock, flags);
  178. return rc;
  179. }
  180. int smc_ism_unregister_dmb(struct smcd_dev *smcd, struct smc_buf_desc *dmb_desc)
  181. {
  182. struct smcd_dmb dmb;
  183. int rc = 0;
  184. if (!dmb_desc->dma_addr)
  185. return rc;
  186. memset(&dmb, 0, sizeof(dmb));
  187. dmb.dmb_tok = dmb_desc->token;
  188. dmb.sba_idx = dmb_desc->sba_idx;
  189. dmb.cpu_addr = dmb_desc->cpu_addr;
  190. dmb.dma_addr = dmb_desc->dma_addr;
  191. dmb.dmb_len = dmb_desc->len;
  192. rc = smcd->ops->unregister_dmb(smcd, &dmb);
  193. if (!rc || rc == ISM_ERROR) {
  194. dmb_desc->cpu_addr = NULL;
  195. dmb_desc->dma_addr = 0;
  196. }
  197. return rc;
  198. }
  199. int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len,
  200. struct smc_buf_desc *dmb_desc)
  201. {
  202. struct smcd_dmb dmb;
  203. int rc;
  204. memset(&dmb, 0, sizeof(dmb));
  205. dmb.dmb_len = dmb_len;
  206. dmb.sba_idx = dmb_desc->sba_idx;
  207. dmb.vlan_id = lgr->vlan_id;
  208. dmb.rgid = lgr->peer_gid.gid;
  209. rc = lgr->smcd->ops->register_dmb(lgr->smcd, &dmb, lgr->smcd->client);
  210. if (!rc) {
  211. dmb_desc->sba_idx = dmb.sba_idx;
  212. dmb_desc->token = dmb.dmb_tok;
  213. dmb_desc->cpu_addr = dmb.cpu_addr;
  214. dmb_desc->dma_addr = dmb.dma_addr;
  215. dmb_desc->len = dmb.dmb_len;
  216. }
  217. return rc;
  218. }
  219. bool smc_ism_support_dmb_nocopy(struct smcd_dev *smcd)
  220. {
  221. /* for now only loopback-ism supports
  222. * merging sndbuf with peer DMB to avoid
  223. * data copies between them.
  224. */
  225. return (smcd->ops->support_dmb_nocopy &&
  226. smcd->ops->support_dmb_nocopy(smcd));
  227. }
  228. int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token,
  229. struct smc_buf_desc *dmb_desc)
  230. {
  231. struct smcd_dmb dmb;
  232. int rc = 0;
  233. if (!dev->ops->attach_dmb)
  234. return -EINVAL;
  235. memset(&dmb, 0, sizeof(dmb));
  236. dmb.dmb_tok = token;
  237. rc = dev->ops->attach_dmb(dev, &dmb);
  238. if (!rc) {
  239. dmb_desc->sba_idx = dmb.sba_idx;
  240. dmb_desc->token = dmb.dmb_tok;
  241. dmb_desc->cpu_addr = dmb.cpu_addr;
  242. dmb_desc->dma_addr = dmb.dma_addr;
  243. dmb_desc->len = dmb.dmb_len;
  244. }
  245. return rc;
  246. }
  247. int smc_ism_detach_dmb(struct smcd_dev *dev, u64 token)
  248. {
  249. if (!dev->ops->detach_dmb)
  250. return -EINVAL;
  251. return dev->ops->detach_dmb(dev, token);
  252. }
  253. static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd,
  254. struct sk_buff *skb,
  255. struct netlink_callback *cb)
  256. {
  257. char smc_pnet[SMC_MAX_PNETID_LEN + 1];
  258. struct smc_pci_dev smc_pci_dev;
  259. struct nlattr *port_attrs;
  260. struct nlattr *attrs;
  261. struct ism_dev *ism;
  262. int use_cnt = 0;
  263. void *nlh;
  264. ism = smcd->priv;
  265. nlh = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
  266. &smc_gen_nl_family, NLM_F_MULTI,
  267. SMC_NETLINK_GET_DEV_SMCD);
  268. if (!nlh)
  269. goto errmsg;
  270. attrs = nla_nest_start(skb, SMC_GEN_DEV_SMCD);
  271. if (!attrs)
  272. goto errout;
  273. use_cnt = atomic_read(&smcd->lgr_cnt);
  274. if (nla_put_u32(skb, SMC_NLA_DEV_USE_CNT, use_cnt))
  275. goto errattr;
  276. if (nla_put_u8(skb, SMC_NLA_DEV_IS_CRIT, use_cnt > 0))
  277. goto errattr;
  278. memset(&smc_pci_dev, 0, sizeof(smc_pci_dev));
  279. smc_set_pci_values(to_pci_dev(ism->dev.parent), &smc_pci_dev);
  280. if (nla_put_u32(skb, SMC_NLA_DEV_PCI_FID, smc_pci_dev.pci_fid))
  281. goto errattr;
  282. if (nla_put_u16(skb, SMC_NLA_DEV_PCI_CHID, smc_pci_dev.pci_pchid))
  283. goto errattr;
  284. if (nla_put_u16(skb, SMC_NLA_DEV_PCI_VENDOR, smc_pci_dev.pci_vendor))
  285. goto errattr;
  286. if (nla_put_u16(skb, SMC_NLA_DEV_PCI_DEVICE, smc_pci_dev.pci_device))
  287. goto errattr;
  288. if (nla_put_string(skb, SMC_NLA_DEV_PCI_ID, smc_pci_dev.pci_id))
  289. goto errattr;
  290. port_attrs = nla_nest_start(skb, SMC_NLA_DEV_PORT);
  291. if (!port_attrs)
  292. goto errattr;
  293. if (nla_put_u8(skb, SMC_NLA_DEV_PORT_PNET_USR, smcd->pnetid_by_user))
  294. goto errportattr;
  295. memcpy(smc_pnet, smcd->pnetid, SMC_MAX_PNETID_LEN);
  296. smc_pnet[SMC_MAX_PNETID_LEN] = 0;
  297. if (nla_put_string(skb, SMC_NLA_DEV_PORT_PNETID, smc_pnet))
  298. goto errportattr;
  299. nla_nest_end(skb, port_attrs);
  300. nla_nest_end(skb, attrs);
  301. genlmsg_end(skb, nlh);
  302. return 0;
  303. errportattr:
  304. nla_nest_cancel(skb, port_attrs);
  305. errattr:
  306. nla_nest_cancel(skb, attrs);
  307. errout:
  308. nlmsg_cancel(skb, nlh);
  309. errmsg:
  310. return -EMSGSIZE;
  311. }
  312. static void smc_nl_prep_smcd_dev(struct smcd_dev_list *dev_list,
  313. struct sk_buff *skb,
  314. struct netlink_callback *cb)
  315. {
  316. struct smc_nl_dmp_ctx *cb_ctx = smc_nl_dmp_ctx(cb);
  317. int snum = cb_ctx->pos[0];
  318. struct smcd_dev *smcd;
  319. int num = 0;
  320. mutex_lock(&dev_list->mutex);
  321. list_for_each_entry(smcd, &dev_list->list, list) {
  322. if (num < snum)
  323. goto next;
  324. if (smc_ism_is_loopback(smcd))
  325. goto next;
  326. if (smc_nl_handle_smcd_dev(smcd, skb, cb))
  327. goto errout;
  328. next:
  329. num++;
  330. }
  331. errout:
  332. mutex_unlock(&dev_list->mutex);
  333. cb_ctx->pos[0] = num;
  334. }
  335. int smcd_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb)
  336. {
  337. smc_nl_prep_smcd_dev(&smcd_dev_list, skb, cb);
  338. return skb->len;
  339. }
  340. #if IS_ENABLED(CONFIG_ISM)
  341. struct smc_ism_event_work {
  342. struct work_struct work;
  343. struct smcd_dev *smcd;
  344. struct ism_event event;
  345. };
  346. #define ISM_EVENT_REQUEST 0x0001
  347. #define ISM_EVENT_RESPONSE 0x0002
  348. #define ISM_EVENT_REQUEST_IR 0x00000001
  349. #define ISM_EVENT_CODE_SHUTDOWN 0x80
  350. #define ISM_EVENT_CODE_TESTLINK 0x83
  351. union smcd_sw_event_info {
  352. u64 info;
  353. struct {
  354. u8 uid[SMC_LGR_ID_SIZE];
  355. unsigned short vlan_id;
  356. u16 code;
  357. };
  358. };
  359. static void smcd_handle_sw_event(struct smc_ism_event_work *wrk)
  360. {
  361. struct smcd_gid peer_gid = { .gid = wrk->event.tok,
  362. .gid_ext = 0 };
  363. union smcd_sw_event_info ev_info;
  364. ev_info.info = wrk->event.info;
  365. switch (wrk->event.code) {
  366. case ISM_EVENT_CODE_SHUTDOWN: /* Peer shut down DMBs */
  367. smc_smcd_terminate(wrk->smcd, &peer_gid, ev_info.vlan_id);
  368. break;
  369. case ISM_EVENT_CODE_TESTLINK: /* Activity timer */
  370. if (ev_info.code == ISM_EVENT_REQUEST &&
  371. wrk->smcd->ops->signal_event) {
  372. ev_info.code = ISM_EVENT_RESPONSE;
  373. wrk->smcd->ops->signal_event(wrk->smcd,
  374. &peer_gid,
  375. ISM_EVENT_REQUEST_IR,
  376. ISM_EVENT_CODE_TESTLINK,
  377. ev_info.info);
  378. }
  379. break;
  380. }
  381. }
  382. /* worker for SMC-D events */
  383. static void smc_ism_event_work(struct work_struct *work)
  384. {
  385. struct smc_ism_event_work *wrk =
  386. container_of(work, struct smc_ism_event_work, work);
  387. struct smcd_gid smcd_gid = { .gid = wrk->event.tok,
  388. .gid_ext = 0 };
  389. switch (wrk->event.type) {
  390. case ISM_EVENT_GID: /* GID event, token is peer GID */
  391. smc_smcd_terminate(wrk->smcd, &smcd_gid, VLAN_VID_MASK);
  392. break;
  393. case ISM_EVENT_DMB:
  394. break;
  395. case ISM_EVENT_SWR: /* Software defined event */
  396. smcd_handle_sw_event(wrk);
  397. break;
  398. }
  399. kfree(wrk);
  400. }
  401. static struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
  402. const struct smcd_ops *ops, int max_dmbs)
  403. {
  404. struct smcd_dev *smcd;
  405. smcd = devm_kzalloc(parent, sizeof(*smcd), GFP_KERNEL);
  406. if (!smcd)
  407. return NULL;
  408. smcd->conn = devm_kcalloc(parent, max_dmbs,
  409. sizeof(struct smc_connection *), GFP_KERNEL);
  410. if (!smcd->conn)
  411. return NULL;
  412. smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
  413. WQ_MEM_RECLAIM, name);
  414. if (!smcd->event_wq)
  415. return NULL;
  416. smcd->ops = ops;
  417. spin_lock_init(&smcd->lock);
  418. spin_lock_init(&smcd->lgr_lock);
  419. INIT_LIST_HEAD(&smcd->vlan);
  420. INIT_LIST_HEAD(&smcd->lgr_list);
  421. init_waitqueue_head(&smcd->lgrs_deleted);
  422. return smcd;
  423. }
  424. static void smcd_register_dev(struct ism_dev *ism)
  425. {
  426. const struct smcd_ops *ops = ism_get_smcd_ops();
  427. struct smcd_dev *smcd, *fentry;
  428. if (!ops)
  429. return;
  430. smcd = smcd_alloc_dev(&ism->pdev->dev, dev_name(&ism->pdev->dev), ops,
  431. ISM_NR_DMBS);
  432. if (!smcd)
  433. return;
  434. smcd->priv = ism;
  435. smcd->client = &smc_ism_client;
  436. ism_set_priv(ism, &smc_ism_client, smcd);
  437. if (smc_pnetid_by_dev_port(&ism->pdev->dev, 0, smcd->pnetid))
  438. smc_pnetid_by_table_smcd(smcd);
  439. if (smcd->ops->supports_v2())
  440. smc_ism_set_v2_capable();
  441. mutex_lock(&smcd_dev_list.mutex);
  442. /* sort list:
  443. * - devices without pnetid before devices with pnetid;
  444. * - loopback-ism always at the very beginning;
  445. */
  446. if (!smcd->pnetid[0]) {
  447. fentry = list_first_entry_or_null(&smcd_dev_list.list,
  448. struct smcd_dev, list);
  449. if (fentry && smc_ism_is_loopback(fentry))
  450. list_add(&smcd->list, &fentry->list);
  451. else
  452. list_add(&smcd->list, &smcd_dev_list.list);
  453. } else {
  454. list_add_tail(&smcd->list, &smcd_dev_list.list);
  455. }
  456. mutex_unlock(&smcd_dev_list.mutex);
  457. pr_warn_ratelimited("smc: adding smcd device %s with pnetid %.16s%s\n",
  458. dev_name(&ism->dev), smcd->pnetid,
  459. smcd->pnetid_by_user ? " (user defined)" : "");
  460. return;
  461. }
  462. static void smcd_unregister_dev(struct ism_dev *ism)
  463. {
  464. struct smcd_dev *smcd = ism_get_priv(ism, &smc_ism_client);
  465. pr_warn_ratelimited("smc: removing smcd device %s\n",
  466. dev_name(&ism->dev));
  467. smcd->going_away = 1;
  468. smc_smcd_terminate_all(smcd);
  469. mutex_lock(&smcd_dev_list.mutex);
  470. list_del_init(&smcd->list);
  471. mutex_unlock(&smcd_dev_list.mutex);
  472. destroy_workqueue(smcd->event_wq);
  473. }
  474. /* SMCD Device event handler. Called from ISM device interrupt handler.
  475. * Parameters are ism device pointer,
  476. * - event->type (0 --> DMB, 1 --> GID),
  477. * - event->code (event code),
  478. * - event->tok (either DMB token when event type 0, or GID when event type 1)
  479. * - event->time (time of day)
  480. * - event->info (debug info).
  481. *
  482. * Context:
  483. * - Function called in IRQ context from ISM device driver event handler.
  484. */
  485. static void smcd_handle_event(struct ism_dev *ism, struct ism_event *event)
  486. {
  487. struct smcd_dev *smcd = ism_get_priv(ism, &smc_ism_client);
  488. struct smc_ism_event_work *wrk;
  489. if (smcd->going_away)
  490. return;
  491. /* copy event to event work queue, and let it be handled there */
  492. wrk = kmalloc(sizeof(*wrk), GFP_ATOMIC);
  493. if (!wrk)
  494. return;
  495. INIT_WORK(&wrk->work, smc_ism_event_work);
  496. wrk->smcd = smcd;
  497. wrk->event = *event;
  498. queue_work(smcd->event_wq, &wrk->work);
  499. }
  500. /* SMCD Device interrupt handler. Called from ISM device interrupt handler.
  501. * Parameters are the ism device pointer, DMB number, and the DMBE bitmask.
  502. * Find the connection and schedule the tasklet for this connection.
  503. *
  504. * Context:
  505. * - Function called in IRQ context from ISM device driver IRQ handler.
  506. */
  507. static void smcd_handle_irq(struct ism_dev *ism, unsigned int dmbno,
  508. u16 dmbemask)
  509. {
  510. struct smcd_dev *smcd = ism_get_priv(ism, &smc_ism_client);
  511. struct smc_connection *conn = NULL;
  512. unsigned long flags;
  513. spin_lock_irqsave(&smcd->lock, flags);
  514. conn = smcd->conn[dmbno];
  515. if (conn && !conn->killed)
  516. tasklet_schedule(&conn->rx_tsklet);
  517. spin_unlock_irqrestore(&smcd->lock, flags);
  518. }
  519. #endif
  520. int smc_ism_signal_shutdown(struct smc_link_group *lgr)
  521. {
  522. int rc = 0;
  523. #if IS_ENABLED(CONFIG_ISM)
  524. union smcd_sw_event_info ev_info;
  525. if (lgr->peer_shutdown)
  526. return 0;
  527. if (!lgr->smcd->ops->signal_event)
  528. return 0;
  529. memcpy(ev_info.uid, lgr->id, SMC_LGR_ID_SIZE);
  530. ev_info.vlan_id = lgr->vlan_id;
  531. ev_info.code = ISM_EVENT_REQUEST;
  532. rc = lgr->smcd->ops->signal_event(lgr->smcd, &lgr->peer_gid,
  533. ISM_EVENT_REQUEST_IR,
  534. ISM_EVENT_CODE_SHUTDOWN,
  535. ev_info.info);
  536. #endif
  537. return rc;
  538. }
  539. int smc_ism_init(void)
  540. {
  541. int rc = 0;
  542. smc_ism_v2_capable = false;
  543. smc_ism_create_system_eid();
  544. #if IS_ENABLED(CONFIG_ISM)
  545. rc = ism_register_client(&smc_ism_client);
  546. #endif
  547. return rc;
  548. }
  549. void smc_ism_exit(void)
  550. {
  551. #if IS_ENABLED(CONFIG_ISM)
  552. ism_unregister_client(&smc_ism_client);
  553. #endif
  554. }