channel_mgmt.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. /*
  2. * Copyright (c) 2009, Microsoft Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  15. * Place - Suite 330, Boston, MA 02111-1307 USA.
  16. *
  17. * Authors:
  18. * Haiyang Zhang <haiyangz@microsoft.com>
  19. * Hank Janssen <hjanssen@microsoft.com>
  20. */
  21. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  22. #include <linux/kernel.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/sched.h>
  25. #include <linux/wait.h>
  26. #include <linux/mm.h>
  27. #include <linux/slab.h>
  28. #include <linux/list.h>
  29. #include <linux/module.h>
  30. #include <linux/completion.h>
  31. #include <linux/delay.h>
  32. #include <linux/hyperv.h>
  33. #include <asm/mshyperv.h>
  34. #include "hyperv_vmbus.h"
  35. static void init_vp_index(struct vmbus_channel *channel, u16 dev_type);
  36. static const struct vmbus_device vmbus_devs[] = {
  37. /* IDE */
  38. { .dev_type = HV_IDE,
  39. HV_IDE_GUID,
  40. .perf_device = true,
  41. },
  42. /* SCSI */
  43. { .dev_type = HV_SCSI,
  44. HV_SCSI_GUID,
  45. .perf_device = true,
  46. },
  47. /* Fibre Channel */
  48. { .dev_type = HV_FC,
  49. HV_SYNTHFC_GUID,
  50. .perf_device = true,
  51. },
  52. /* Synthetic NIC */
  53. { .dev_type = HV_NIC,
  54. HV_NIC_GUID,
  55. .perf_device = true,
  56. },
  57. /* Network Direct */
  58. { .dev_type = HV_ND,
  59. HV_ND_GUID,
  60. .perf_device = true,
  61. },
  62. /* PCIE */
  63. { .dev_type = HV_PCIE,
  64. HV_PCIE_GUID,
  65. .perf_device = false,
  66. },
  67. /* Synthetic Frame Buffer */
  68. { .dev_type = HV_FB,
  69. HV_SYNTHVID_GUID,
  70. .perf_device = false,
  71. },
  72. /* Synthetic Keyboard */
  73. { .dev_type = HV_KBD,
  74. HV_KBD_GUID,
  75. .perf_device = false,
  76. },
  77. /* Synthetic MOUSE */
  78. { .dev_type = HV_MOUSE,
  79. HV_MOUSE_GUID,
  80. .perf_device = false,
  81. },
  82. /* KVP */
  83. { .dev_type = HV_KVP,
  84. HV_KVP_GUID,
  85. .perf_device = false,
  86. },
  87. /* Time Synch */
  88. { .dev_type = HV_TS,
  89. HV_TS_GUID,
  90. .perf_device = false,
  91. },
  92. /* Heartbeat */
  93. { .dev_type = HV_HB,
  94. HV_HEART_BEAT_GUID,
  95. .perf_device = false,
  96. },
  97. /* Shutdown */
  98. { .dev_type = HV_SHUTDOWN,
  99. HV_SHUTDOWN_GUID,
  100. .perf_device = false,
  101. },
  102. /* File copy */
  103. { .dev_type = HV_FCOPY,
  104. HV_FCOPY_GUID,
  105. .perf_device = false,
  106. },
  107. /* Backup */
  108. { .dev_type = HV_BACKUP,
  109. HV_VSS_GUID,
  110. .perf_device = false,
  111. },
  112. /* Dynamic Memory */
  113. { .dev_type = HV_DM,
  114. HV_DM_GUID,
  115. .perf_device = false,
  116. },
  117. /* Unknown GUID */
  118. { .dev_type = HV_UNKNOWN,
  119. .perf_device = false,
  120. },
  121. };
  122. static const struct {
  123. uuid_le guid;
  124. } vmbus_unsupported_devs[] = {
  125. { HV_AVMA1_GUID },
  126. { HV_AVMA2_GUID },
  127. { HV_RDV_GUID },
  128. };
  129. /*
  130. * The rescinded channel may be blocked waiting for a response from the host;
  131. * take care of that.
  132. */
  133. static void vmbus_rescind_cleanup(struct vmbus_channel *channel)
  134. {
  135. struct vmbus_channel_msginfo *msginfo;
  136. unsigned long flags;
  137. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  138. channel->rescind = true;
  139. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  140. msglistentry) {
  141. if (msginfo->waiting_channel == channel) {
  142. complete(&msginfo->waitevent);
  143. break;
  144. }
  145. }
  146. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  147. }
  148. static bool is_unsupported_vmbus_devs(const uuid_le *guid)
  149. {
  150. int i;
  151. for (i = 0; i < ARRAY_SIZE(vmbus_unsupported_devs); i++)
  152. if (!uuid_le_cmp(*guid, vmbus_unsupported_devs[i].guid))
  153. return true;
  154. return false;
  155. }
  156. static u16 hv_get_dev_type(const struct vmbus_channel *channel)
  157. {
  158. const uuid_le *guid = &channel->offermsg.offer.if_type;
  159. u16 i;
  160. if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid))
  161. return HV_UNKNOWN;
  162. for (i = HV_IDE; i < HV_UNKNOWN; i++) {
  163. if (!uuid_le_cmp(*guid, vmbus_devs[i].guid))
  164. return i;
  165. }
  166. pr_info("Unknown GUID: %pUl\n", guid);
  167. return i;
  168. }
  169. /**
  170. * vmbus_prep_negotiate_resp() - Create default response for Hyper-V Negotiate message
  171. * @icmsghdrp: Pointer to msg header structure
  172. * @icmsg_negotiate: Pointer to negotiate message structure
  173. * @buf: Raw buffer channel data
  174. *
  175. * @icmsghdrp is of type &struct icmsg_hdr.
  176. * Set up and fill in default negotiate response message.
  177. *
  178. * The fw_version and fw_vercnt specifies the framework version that
  179. * we can support.
  180. *
  181. * The srv_version and srv_vercnt specifies the service
  182. * versions we can support.
  183. *
  184. * Versions are given in decreasing order.
  185. *
  186. * nego_fw_version and nego_srv_version store the selected protocol versions.
  187. *
  188. * Mainly used by Hyper-V drivers.
  189. */
  190. bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp,
  191. u8 *buf, const int *fw_version, int fw_vercnt,
  192. const int *srv_version, int srv_vercnt,
  193. int *nego_fw_version, int *nego_srv_version)
  194. {
  195. int icframe_major, icframe_minor;
  196. int icmsg_major, icmsg_minor;
  197. int fw_major, fw_minor;
  198. int srv_major, srv_minor;
  199. int i, j;
  200. bool found_match = false;
  201. struct icmsg_negotiate *negop;
  202. icmsghdrp->icmsgsize = 0x10;
  203. negop = (struct icmsg_negotiate *)&buf[
  204. sizeof(struct vmbuspipe_hdr) +
  205. sizeof(struct icmsg_hdr)];
  206. icframe_major = negop->icframe_vercnt;
  207. icframe_minor = 0;
  208. icmsg_major = negop->icmsg_vercnt;
  209. icmsg_minor = 0;
  210. /*
  211. * Select the framework version number we will
  212. * support.
  213. */
  214. for (i = 0; i < fw_vercnt; i++) {
  215. fw_major = (fw_version[i] >> 16);
  216. fw_minor = (fw_version[i] & 0xFFFF);
  217. for (j = 0; j < negop->icframe_vercnt; j++) {
  218. if ((negop->icversion_data[j].major == fw_major) &&
  219. (negop->icversion_data[j].minor == fw_minor)) {
  220. icframe_major = negop->icversion_data[j].major;
  221. icframe_minor = negop->icversion_data[j].minor;
  222. found_match = true;
  223. break;
  224. }
  225. }
  226. if (found_match)
  227. break;
  228. }
  229. if (!found_match)
  230. goto fw_error;
  231. found_match = false;
  232. for (i = 0; i < srv_vercnt; i++) {
  233. srv_major = (srv_version[i] >> 16);
  234. srv_minor = (srv_version[i] & 0xFFFF);
  235. for (j = negop->icframe_vercnt;
  236. (j < negop->icframe_vercnt + negop->icmsg_vercnt);
  237. j++) {
  238. if ((negop->icversion_data[j].major == srv_major) &&
  239. (negop->icversion_data[j].minor == srv_minor)) {
  240. icmsg_major = negop->icversion_data[j].major;
  241. icmsg_minor = negop->icversion_data[j].minor;
  242. found_match = true;
  243. break;
  244. }
  245. }
  246. if (found_match)
  247. break;
  248. }
  249. /*
  250. * Respond with the framework and service
  251. * version numbers we can support.
  252. */
  253. fw_error:
  254. if (!found_match) {
  255. negop->icframe_vercnt = 0;
  256. negop->icmsg_vercnt = 0;
  257. } else {
  258. negop->icframe_vercnt = 1;
  259. negop->icmsg_vercnt = 1;
  260. }
  261. if (nego_fw_version)
  262. *nego_fw_version = (icframe_major << 16) | icframe_minor;
  263. if (nego_srv_version)
  264. *nego_srv_version = (icmsg_major << 16) | icmsg_minor;
  265. negop->icversion_data[0].major = icframe_major;
  266. negop->icversion_data[0].minor = icframe_minor;
  267. negop->icversion_data[1].major = icmsg_major;
  268. negop->icversion_data[1].minor = icmsg_minor;
  269. return found_match;
  270. }
  271. EXPORT_SYMBOL_GPL(vmbus_prep_negotiate_resp);
  272. /*
  273. * alloc_channel - Allocate and initialize a vmbus channel object
  274. */
  275. static struct vmbus_channel *alloc_channel(void)
  276. {
  277. struct vmbus_channel *channel;
  278. channel = kzalloc(sizeof(*channel), GFP_ATOMIC);
  279. if (!channel)
  280. return NULL;
  281. spin_lock_init(&channel->lock);
  282. init_completion(&channel->rescind_event);
  283. INIT_LIST_HEAD(&channel->sc_list);
  284. INIT_LIST_HEAD(&channel->percpu_list);
  285. tasklet_init(&channel->callback_event,
  286. vmbus_on_event, (unsigned long)channel);
  287. return channel;
  288. }
  289. /*
  290. * free_channel - Release the resources used by the vmbus channel object
  291. */
  292. static void free_channel(struct vmbus_channel *channel)
  293. {
  294. tasklet_kill(&channel->callback_event);
  295. kobject_put(&channel->kobj);
  296. }
  297. static void percpu_channel_enq(void *arg)
  298. {
  299. struct vmbus_channel *channel = arg;
  300. struct hv_per_cpu_context *hv_cpu
  301. = this_cpu_ptr(hv_context.cpu_context);
  302. list_add_tail_rcu(&channel->percpu_list, &hv_cpu->chan_list);
  303. }
  304. static void percpu_channel_deq(void *arg)
  305. {
  306. struct vmbus_channel *channel = arg;
  307. list_del_rcu(&channel->percpu_list);
  308. }
  309. static void vmbus_release_relid(u32 relid)
  310. {
  311. struct vmbus_channel_relid_released msg;
  312. int ret;
  313. memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
  314. msg.child_relid = relid;
  315. msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
  316. ret = vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released),
  317. true);
  318. trace_vmbus_release_relid(&msg, ret);
  319. }
  320. void hv_process_channel_removal(u32 relid)
  321. {
  322. unsigned long flags;
  323. struct vmbus_channel *primary_channel, *channel;
  324. BUG_ON(!mutex_is_locked(&vmbus_connection.channel_mutex));
  325. /*
  326. * Make sure channel is valid as we may have raced.
  327. */
  328. channel = relid2channel(relid);
  329. if (!channel)
  330. return;
  331. BUG_ON(!channel->rescind);
  332. if (channel->target_cpu != get_cpu()) {
  333. put_cpu();
  334. smp_call_function_single(channel->target_cpu,
  335. percpu_channel_deq, channel, true);
  336. } else {
  337. percpu_channel_deq(channel);
  338. put_cpu();
  339. }
  340. if (channel->primary_channel == NULL) {
  341. list_del(&channel->listentry);
  342. primary_channel = channel;
  343. } else {
  344. primary_channel = channel->primary_channel;
  345. spin_lock_irqsave(&primary_channel->lock, flags);
  346. list_del(&channel->sc_list);
  347. primary_channel->num_sc--;
  348. spin_unlock_irqrestore(&primary_channel->lock, flags);
  349. }
  350. /*
  351. * We need to free the bit for init_vp_index() to work in the case
  352. * of sub-channel, when we reload drivers like hv_netvsc.
  353. */
  354. if (channel->affinity_policy == HV_LOCALIZED)
  355. cpumask_clear_cpu(channel->target_cpu,
  356. &primary_channel->alloced_cpus_in_node);
  357. vmbus_release_relid(relid);
  358. free_channel(channel);
  359. }
  360. void vmbus_free_channels(void)
  361. {
  362. struct vmbus_channel *channel, *tmp;
  363. list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
  364. listentry) {
  365. /* hv_process_channel_removal() needs this */
  366. channel->rescind = true;
  367. vmbus_device_unregister(channel->device_obj);
  368. }
  369. }
  370. /*
  371. * vmbus_process_offer - Process the offer by creating a channel/device
  372. * associated with this offer
  373. */
  374. static void vmbus_process_offer(struct vmbus_channel *newchannel)
  375. {
  376. struct vmbus_channel *channel;
  377. bool fnew = true;
  378. unsigned long flags;
  379. u16 dev_type;
  380. int ret;
  381. /* Make sure this is a new offer */
  382. mutex_lock(&vmbus_connection.channel_mutex);
  383. /*
  384. * Now that we have acquired the channel_mutex,
  385. * we can release the potentially racing rescind thread.
  386. */
  387. atomic_dec(&vmbus_connection.offer_in_progress);
  388. list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
  389. if (!uuid_le_cmp(channel->offermsg.offer.if_type,
  390. newchannel->offermsg.offer.if_type) &&
  391. !uuid_le_cmp(channel->offermsg.offer.if_instance,
  392. newchannel->offermsg.offer.if_instance)) {
  393. fnew = false;
  394. break;
  395. }
  396. }
  397. if (fnew)
  398. list_add_tail(&newchannel->listentry,
  399. &vmbus_connection.chn_list);
  400. mutex_unlock(&vmbus_connection.channel_mutex);
  401. if (!fnew) {
  402. /*
  403. * Check to see if this is a sub-channel.
  404. */
  405. if (newchannel->offermsg.offer.sub_channel_index != 0) {
  406. /*
  407. * Process the sub-channel.
  408. */
  409. newchannel->primary_channel = channel;
  410. spin_lock_irqsave(&channel->lock, flags);
  411. list_add_tail(&newchannel->sc_list, &channel->sc_list);
  412. channel->num_sc++;
  413. spin_unlock_irqrestore(&channel->lock, flags);
  414. } else {
  415. goto err_free_chan;
  416. }
  417. }
  418. dev_type = hv_get_dev_type(newchannel);
  419. init_vp_index(newchannel, dev_type);
  420. if (newchannel->target_cpu != get_cpu()) {
  421. put_cpu();
  422. smp_call_function_single(newchannel->target_cpu,
  423. percpu_channel_enq,
  424. newchannel, true);
  425. } else {
  426. percpu_channel_enq(newchannel);
  427. put_cpu();
  428. }
  429. /*
  430. * This state is used to indicate a successful open
  431. * so that when we do close the channel normally, we
  432. * can cleanup properly
  433. */
  434. newchannel->state = CHANNEL_OPEN_STATE;
  435. if (!fnew) {
  436. struct hv_device *dev
  437. = newchannel->primary_channel->device_obj;
  438. if (vmbus_add_channel_kobj(dev, newchannel)) {
  439. atomic_dec(&vmbus_connection.offer_in_progress);
  440. goto err_free_chan;
  441. }
  442. if (channel->sc_creation_callback != NULL)
  443. channel->sc_creation_callback(newchannel);
  444. newchannel->probe_done = true;
  445. return;
  446. }
  447. /*
  448. * Start the process of binding this offer to the driver
  449. * We need to set the DeviceObject field before calling
  450. * vmbus_child_dev_add()
  451. */
  452. newchannel->device_obj = vmbus_device_create(
  453. &newchannel->offermsg.offer.if_type,
  454. &newchannel->offermsg.offer.if_instance,
  455. newchannel);
  456. if (!newchannel->device_obj)
  457. goto err_deq_chan;
  458. newchannel->device_obj->device_id = dev_type;
  459. /*
  460. * Add the new device to the bus. This will kick off device-driver
  461. * binding which eventually invokes the device driver's AddDevice()
  462. * method.
  463. */
  464. ret = vmbus_device_register(newchannel->device_obj);
  465. if (ret != 0) {
  466. pr_err("unable to add child device object (relid %d)\n",
  467. newchannel->offermsg.child_relid);
  468. kfree(newchannel->device_obj);
  469. goto err_deq_chan;
  470. }
  471. newchannel->probe_done = true;
  472. return;
  473. err_deq_chan:
  474. mutex_lock(&vmbus_connection.channel_mutex);
  475. list_del(&newchannel->listentry);
  476. mutex_unlock(&vmbus_connection.channel_mutex);
  477. if (newchannel->target_cpu != get_cpu()) {
  478. put_cpu();
  479. smp_call_function_single(newchannel->target_cpu,
  480. percpu_channel_deq, newchannel, true);
  481. } else {
  482. percpu_channel_deq(newchannel);
  483. put_cpu();
  484. }
  485. vmbus_release_relid(newchannel->offermsg.child_relid);
  486. err_free_chan:
  487. free_channel(newchannel);
  488. }
  489. /*
  490. * We use this state to statically distribute the channel interrupt load.
  491. */
  492. static int next_numa_node_id;
  493. /*
  494. * Starting with Win8, we can statically distribute the incoming
  495. * channel interrupt load by binding a channel to VCPU.
  496. * We distribute the interrupt loads to one or more NUMA nodes based on
  497. * the channel's affinity_policy.
  498. *
  499. * For pre-win8 hosts or non-performance critical channels we assign the
  500. * first CPU in the first NUMA node.
  501. */
  502. static void init_vp_index(struct vmbus_channel *channel, u16 dev_type)
  503. {
  504. u32 cur_cpu;
  505. bool perf_chn = vmbus_devs[dev_type].perf_device;
  506. struct vmbus_channel *primary = channel->primary_channel;
  507. int next_node;
  508. struct cpumask available_mask;
  509. struct cpumask *alloced_mask;
  510. if ((vmbus_proto_version == VERSION_WS2008) ||
  511. (vmbus_proto_version == VERSION_WIN7) || (!perf_chn)) {
  512. /*
  513. * Prior to win8, all channel interrupts are
  514. * delivered on cpu 0.
  515. * Also if the channel is not a performance critical
  516. * channel, bind it to cpu 0.
  517. */
  518. channel->numa_node = 0;
  519. channel->target_cpu = 0;
  520. channel->target_vp = hv_cpu_number_to_vp_number(0);
  521. return;
  522. }
  523. /*
  524. * Based on the channel affinity policy, we will assign the NUMA
  525. * nodes.
  526. */
  527. if ((channel->affinity_policy == HV_BALANCED) || (!primary)) {
  528. while (true) {
  529. next_node = next_numa_node_id++;
  530. if (next_node == nr_node_ids) {
  531. next_node = next_numa_node_id = 0;
  532. continue;
  533. }
  534. if (cpumask_empty(cpumask_of_node(next_node)))
  535. continue;
  536. break;
  537. }
  538. channel->numa_node = next_node;
  539. primary = channel;
  540. }
  541. alloced_mask = &hv_context.hv_numa_map[primary->numa_node];
  542. if (cpumask_weight(alloced_mask) ==
  543. cpumask_weight(cpumask_of_node(primary->numa_node))) {
  544. /*
  545. * We have cycled through all the CPUs in the node;
  546. * reset the alloced map.
  547. */
  548. cpumask_clear(alloced_mask);
  549. }
  550. cpumask_xor(&available_mask, alloced_mask,
  551. cpumask_of_node(primary->numa_node));
  552. cur_cpu = -1;
  553. if (primary->affinity_policy == HV_LOCALIZED) {
  554. /*
  555. * Normally Hyper-V host doesn't create more subchannels
  556. * than there are VCPUs on the node but it is possible when not
  557. * all present VCPUs on the node are initialized by guest.
  558. * Clear the alloced_cpus_in_node to start over.
  559. */
  560. if (cpumask_equal(&primary->alloced_cpus_in_node,
  561. cpumask_of_node(primary->numa_node)))
  562. cpumask_clear(&primary->alloced_cpus_in_node);
  563. }
  564. while (true) {
  565. cur_cpu = cpumask_next(cur_cpu, &available_mask);
  566. if (cur_cpu >= nr_cpu_ids) {
  567. cur_cpu = -1;
  568. cpumask_copy(&available_mask,
  569. cpumask_of_node(primary->numa_node));
  570. continue;
  571. }
  572. if (primary->affinity_policy == HV_LOCALIZED) {
  573. /*
  574. * NOTE: in the case of sub-channel, we clear the
  575. * sub-channel related bit(s) in
  576. * primary->alloced_cpus_in_node in
  577. * hv_process_channel_removal(), so when we
  578. * reload drivers like hv_netvsc in SMP guest, here
  579. * we're able to re-allocate
  580. * bit from primary->alloced_cpus_in_node.
  581. */
  582. if (!cpumask_test_cpu(cur_cpu,
  583. &primary->alloced_cpus_in_node)) {
  584. cpumask_set_cpu(cur_cpu,
  585. &primary->alloced_cpus_in_node);
  586. cpumask_set_cpu(cur_cpu, alloced_mask);
  587. break;
  588. }
  589. } else {
  590. cpumask_set_cpu(cur_cpu, alloced_mask);
  591. break;
  592. }
  593. }
  594. channel->target_cpu = cur_cpu;
  595. channel->target_vp = hv_cpu_number_to_vp_number(cur_cpu);
  596. }
  597. static void vmbus_wait_for_unload(void)
  598. {
  599. int cpu;
  600. void *page_addr;
  601. struct hv_message *msg;
  602. struct vmbus_channel_message_header *hdr;
  603. u32 message_type;
  604. /*
  605. * CHANNELMSG_UNLOAD_RESPONSE is always delivered to the CPU which was
  606. * used for initial contact or to CPU0 depending on host version. When
  607. * we're crashing on a different CPU let's hope that IRQ handler on
  608. * the cpu which receives CHANNELMSG_UNLOAD_RESPONSE is still
  609. * functional and vmbus_unload_response() will complete
  610. * vmbus_connection.unload_event. If not, the last thing we can do is
  611. * read message pages for all CPUs directly.
  612. */
  613. while (1) {
  614. if (completion_done(&vmbus_connection.unload_event))
  615. break;
  616. for_each_online_cpu(cpu) {
  617. struct hv_per_cpu_context *hv_cpu
  618. = per_cpu_ptr(hv_context.cpu_context, cpu);
  619. page_addr = hv_cpu->synic_message_page;
  620. msg = (struct hv_message *)page_addr
  621. + VMBUS_MESSAGE_SINT;
  622. message_type = READ_ONCE(msg->header.message_type);
  623. if (message_type == HVMSG_NONE)
  624. continue;
  625. hdr = (struct vmbus_channel_message_header *)
  626. msg->u.payload;
  627. if (hdr->msgtype == CHANNELMSG_UNLOAD_RESPONSE)
  628. complete(&vmbus_connection.unload_event);
  629. vmbus_signal_eom(msg, message_type);
  630. }
  631. mdelay(10);
  632. }
  633. /*
  634. * We're crashing and already got the UNLOAD_RESPONSE, cleanup all
  635. * maybe-pending messages on all CPUs to be able to receive new
  636. * messages after we reconnect.
  637. */
  638. for_each_online_cpu(cpu) {
  639. struct hv_per_cpu_context *hv_cpu
  640. = per_cpu_ptr(hv_context.cpu_context, cpu);
  641. page_addr = hv_cpu->synic_message_page;
  642. msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
  643. msg->header.message_type = HVMSG_NONE;
  644. }
  645. }
  646. /*
  647. * vmbus_unload_response - Handler for the unload response.
  648. */
  649. static void vmbus_unload_response(struct vmbus_channel_message_header *hdr)
  650. {
  651. /*
  652. * This is a global event; just wakeup the waiting thread.
  653. * Once we successfully unload, we can cleanup the monitor state.
  654. */
  655. complete(&vmbus_connection.unload_event);
  656. }
  657. void vmbus_initiate_unload(bool crash)
  658. {
  659. struct vmbus_channel_message_header hdr;
  660. /* Pre-Win2012R2 hosts don't support reconnect */
  661. if (vmbus_proto_version < VERSION_WIN8_1)
  662. return;
  663. init_completion(&vmbus_connection.unload_event);
  664. memset(&hdr, 0, sizeof(struct vmbus_channel_message_header));
  665. hdr.msgtype = CHANNELMSG_UNLOAD;
  666. vmbus_post_msg(&hdr, sizeof(struct vmbus_channel_message_header),
  667. !crash);
  668. /*
  669. * vmbus_initiate_unload() is also called on crash and the crash can be
  670. * happening in an interrupt context, where scheduling is impossible.
  671. */
  672. if (!crash)
  673. wait_for_completion(&vmbus_connection.unload_event);
  674. else
  675. vmbus_wait_for_unload();
  676. }
  677. /*
  678. * vmbus_onoffer - Handler for channel offers from vmbus in parent partition.
  679. *
  680. */
  681. static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
  682. {
  683. struct vmbus_channel_offer_channel *offer;
  684. struct vmbus_channel *newchannel;
  685. offer = (struct vmbus_channel_offer_channel *)hdr;
  686. trace_vmbus_onoffer(offer);
  687. /* Allocate the channel object and save this offer. */
  688. newchannel = alloc_channel();
  689. if (!newchannel) {
  690. vmbus_release_relid(offer->child_relid);
  691. atomic_dec(&vmbus_connection.offer_in_progress);
  692. pr_err("Unable to allocate channel object\n");
  693. return;
  694. }
  695. /*
  696. * Setup state for signalling the host.
  697. */
  698. newchannel->sig_event = VMBUS_EVENT_CONNECTION_ID;
  699. if (vmbus_proto_version != VERSION_WS2008) {
  700. newchannel->is_dedicated_interrupt =
  701. (offer->is_dedicated_interrupt != 0);
  702. newchannel->sig_event = offer->connection_id;
  703. }
  704. memcpy(&newchannel->offermsg, offer,
  705. sizeof(struct vmbus_channel_offer_channel));
  706. newchannel->monitor_grp = (u8)offer->monitorid / 32;
  707. newchannel->monitor_bit = (u8)offer->monitorid % 32;
  708. vmbus_process_offer(newchannel);
  709. }
  710. /*
  711. * vmbus_onoffer_rescind - Rescind offer handler.
  712. *
  713. * We queue a work item to process this offer synchronously
  714. */
  715. static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
  716. {
  717. struct vmbus_channel_rescind_offer *rescind;
  718. struct vmbus_channel *channel;
  719. struct device *dev;
  720. rescind = (struct vmbus_channel_rescind_offer *)hdr;
  721. trace_vmbus_onoffer_rescind(rescind);
  722. /*
  723. * The offer msg and the corresponding rescind msg
  724. * from the host are guranteed to be ordered -
  725. * offer comes in first and then the rescind.
  726. * Since we process these events in work elements,
  727. * and with preemption, we may end up processing
  728. * the events out of order. Given that we handle these
  729. * work elements on the same CPU, this is possible only
  730. * in the case of preemption. In any case wait here
  731. * until the offer processing has moved beyond the
  732. * point where the channel is discoverable.
  733. */
  734. while (atomic_read(&vmbus_connection.offer_in_progress) != 0) {
  735. /*
  736. * We wait here until any channel offer is currently
  737. * being processed.
  738. */
  739. msleep(1);
  740. }
  741. mutex_lock(&vmbus_connection.channel_mutex);
  742. channel = relid2channel(rescind->child_relid);
  743. mutex_unlock(&vmbus_connection.channel_mutex);
  744. if (channel == NULL) {
  745. /*
  746. * We failed in processing the offer message;
  747. * we would have cleaned up the relid in that
  748. * failure path.
  749. */
  750. return;
  751. }
  752. /*
  753. * Now wait for offer handling to complete.
  754. */
  755. vmbus_rescind_cleanup(channel);
  756. while (READ_ONCE(channel->probe_done) == false) {
  757. /*
  758. * We wait here until any channel offer is currently
  759. * being processed.
  760. */
  761. msleep(1);
  762. }
  763. /*
  764. * At this point, the rescind handling can proceed safely.
  765. */
  766. if (channel->device_obj) {
  767. if (channel->chn_rescind_callback) {
  768. channel->chn_rescind_callback(channel);
  769. return;
  770. }
  771. /*
  772. * We will have to unregister this device from the
  773. * driver core.
  774. */
  775. dev = get_device(&channel->device_obj->device);
  776. if (dev) {
  777. vmbus_device_unregister(channel->device_obj);
  778. put_device(dev);
  779. }
  780. }
  781. if (channel->primary_channel != NULL) {
  782. /*
  783. * Sub-channel is being rescinded. Following is the channel
  784. * close sequence when initiated from the driveri (refer to
  785. * vmbus_close() for details):
  786. * 1. Close all sub-channels first
  787. * 2. Then close the primary channel.
  788. */
  789. mutex_lock(&vmbus_connection.channel_mutex);
  790. if (channel->state == CHANNEL_OPEN_STATE) {
  791. /*
  792. * The channel is currently not open;
  793. * it is safe for us to cleanup the channel.
  794. */
  795. hv_process_channel_removal(rescind->child_relid);
  796. } else {
  797. complete(&channel->rescind_event);
  798. }
  799. mutex_unlock(&vmbus_connection.channel_mutex);
  800. }
  801. }
  802. void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
  803. {
  804. BUG_ON(!is_hvsock_channel(channel));
  805. /* We always get a rescind msg when a connection is closed. */
  806. while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind))
  807. msleep(1);
  808. vmbus_device_unregister(channel->device_obj);
  809. }
  810. EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister);
  811. /*
  812. * vmbus_onoffers_delivered -
  813. * This is invoked when all offers have been delivered.
  814. *
  815. * Nothing to do here.
  816. */
  817. static void vmbus_onoffers_delivered(
  818. struct vmbus_channel_message_header *hdr)
  819. {
  820. }
  821. /*
  822. * vmbus_onopen_result - Open result handler.
  823. *
  824. * This is invoked when we received a response to our channel open request.
  825. * Find the matching request, copy the response and signal the requesting
  826. * thread.
  827. */
  828. static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
  829. {
  830. struct vmbus_channel_open_result *result;
  831. struct vmbus_channel_msginfo *msginfo;
  832. struct vmbus_channel_message_header *requestheader;
  833. struct vmbus_channel_open_channel *openmsg;
  834. unsigned long flags;
  835. result = (struct vmbus_channel_open_result *)hdr;
  836. trace_vmbus_onopen_result(result);
  837. /*
  838. * Find the open msg, copy the result and signal/unblock the wait event
  839. */
  840. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  841. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  842. msglistentry) {
  843. requestheader =
  844. (struct vmbus_channel_message_header *)msginfo->msg;
  845. if (requestheader->msgtype == CHANNELMSG_OPENCHANNEL) {
  846. openmsg =
  847. (struct vmbus_channel_open_channel *)msginfo->msg;
  848. if (openmsg->child_relid == result->child_relid &&
  849. openmsg->openid == result->openid) {
  850. memcpy(&msginfo->response.open_result,
  851. result,
  852. sizeof(
  853. struct vmbus_channel_open_result));
  854. complete(&msginfo->waitevent);
  855. break;
  856. }
  857. }
  858. }
  859. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  860. }
  861. /*
  862. * vmbus_ongpadl_created - GPADL created handler.
  863. *
  864. * This is invoked when we received a response to our gpadl create request.
  865. * Find the matching request, copy the response and signal the requesting
  866. * thread.
  867. */
  868. static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
  869. {
  870. struct vmbus_channel_gpadl_created *gpadlcreated;
  871. struct vmbus_channel_msginfo *msginfo;
  872. struct vmbus_channel_message_header *requestheader;
  873. struct vmbus_channel_gpadl_header *gpadlheader;
  874. unsigned long flags;
  875. gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr;
  876. trace_vmbus_ongpadl_created(gpadlcreated);
  877. /*
  878. * Find the establish msg, copy the result and signal/unblock the wait
  879. * event
  880. */
  881. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  882. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  883. msglistentry) {
  884. requestheader =
  885. (struct vmbus_channel_message_header *)msginfo->msg;
  886. if (requestheader->msgtype == CHANNELMSG_GPADL_HEADER) {
  887. gpadlheader =
  888. (struct vmbus_channel_gpadl_header *)requestheader;
  889. if ((gpadlcreated->child_relid ==
  890. gpadlheader->child_relid) &&
  891. (gpadlcreated->gpadl == gpadlheader->gpadl)) {
  892. memcpy(&msginfo->response.gpadl_created,
  893. gpadlcreated,
  894. sizeof(
  895. struct vmbus_channel_gpadl_created));
  896. complete(&msginfo->waitevent);
  897. break;
  898. }
  899. }
  900. }
  901. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  902. }
  903. /*
  904. * vmbus_ongpadl_torndown - GPADL torndown handler.
  905. *
  906. * This is invoked when we received a response to our gpadl teardown request.
  907. * Find the matching request, copy the response and signal the requesting
  908. * thread.
  909. */
  910. static void vmbus_ongpadl_torndown(
  911. struct vmbus_channel_message_header *hdr)
  912. {
  913. struct vmbus_channel_gpadl_torndown *gpadl_torndown;
  914. struct vmbus_channel_msginfo *msginfo;
  915. struct vmbus_channel_message_header *requestheader;
  916. struct vmbus_channel_gpadl_teardown *gpadl_teardown;
  917. unsigned long flags;
  918. gpadl_torndown = (struct vmbus_channel_gpadl_torndown *)hdr;
  919. trace_vmbus_ongpadl_torndown(gpadl_torndown);
  920. /*
  921. * Find the open msg, copy the result and signal/unblock the wait event
  922. */
  923. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  924. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  925. msglistentry) {
  926. requestheader =
  927. (struct vmbus_channel_message_header *)msginfo->msg;
  928. if (requestheader->msgtype == CHANNELMSG_GPADL_TEARDOWN) {
  929. gpadl_teardown =
  930. (struct vmbus_channel_gpadl_teardown *)requestheader;
  931. if (gpadl_torndown->gpadl == gpadl_teardown->gpadl) {
  932. memcpy(&msginfo->response.gpadl_torndown,
  933. gpadl_torndown,
  934. sizeof(
  935. struct vmbus_channel_gpadl_torndown));
  936. complete(&msginfo->waitevent);
  937. break;
  938. }
  939. }
  940. }
  941. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  942. }
  943. /*
  944. * vmbus_onversion_response - Version response handler
  945. *
  946. * This is invoked when we received a response to our initiate contact request.
  947. * Find the matching request, copy the response and signal the requesting
  948. * thread.
  949. */
  950. static void vmbus_onversion_response(
  951. struct vmbus_channel_message_header *hdr)
  952. {
  953. struct vmbus_channel_msginfo *msginfo;
  954. struct vmbus_channel_message_header *requestheader;
  955. struct vmbus_channel_version_response *version_response;
  956. unsigned long flags;
  957. version_response = (struct vmbus_channel_version_response *)hdr;
  958. trace_vmbus_onversion_response(version_response);
  959. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  960. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  961. msglistentry) {
  962. requestheader =
  963. (struct vmbus_channel_message_header *)msginfo->msg;
  964. if (requestheader->msgtype ==
  965. CHANNELMSG_INITIATE_CONTACT) {
  966. memcpy(&msginfo->response.version_response,
  967. version_response,
  968. sizeof(struct vmbus_channel_version_response));
  969. complete(&msginfo->waitevent);
  970. }
  971. }
  972. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  973. }
  974. /* Channel message dispatch table */
  975. const struct vmbus_channel_message_table_entry
  976. channel_message_table[CHANNELMSG_COUNT] = {
  977. { CHANNELMSG_INVALID, 0, NULL },
  978. { CHANNELMSG_OFFERCHANNEL, 0, vmbus_onoffer },
  979. { CHANNELMSG_RESCIND_CHANNELOFFER, 0, vmbus_onoffer_rescind },
  980. { CHANNELMSG_REQUESTOFFERS, 0, NULL },
  981. { CHANNELMSG_ALLOFFERS_DELIVERED, 1, vmbus_onoffers_delivered },
  982. { CHANNELMSG_OPENCHANNEL, 0, NULL },
  983. { CHANNELMSG_OPENCHANNEL_RESULT, 1, vmbus_onopen_result },
  984. { CHANNELMSG_CLOSECHANNEL, 0, NULL },
  985. { CHANNELMSG_GPADL_HEADER, 0, NULL },
  986. { CHANNELMSG_GPADL_BODY, 0, NULL },
  987. { CHANNELMSG_GPADL_CREATED, 1, vmbus_ongpadl_created },
  988. { CHANNELMSG_GPADL_TEARDOWN, 0, NULL },
  989. { CHANNELMSG_GPADL_TORNDOWN, 1, vmbus_ongpadl_torndown },
  990. { CHANNELMSG_RELID_RELEASED, 0, NULL },
  991. { CHANNELMSG_INITIATE_CONTACT, 0, NULL },
  992. { CHANNELMSG_VERSION_RESPONSE, 1, vmbus_onversion_response },
  993. { CHANNELMSG_UNLOAD, 0, NULL },
  994. { CHANNELMSG_UNLOAD_RESPONSE, 1, vmbus_unload_response },
  995. { CHANNELMSG_18, 0, NULL },
  996. { CHANNELMSG_19, 0, NULL },
  997. { CHANNELMSG_20, 0, NULL },
  998. { CHANNELMSG_TL_CONNECT_REQUEST, 0, NULL },
  999. };
  1000. /*
  1001. * vmbus_onmessage - Handler for channel protocol messages.
  1002. *
  1003. * This is invoked in the vmbus worker thread context.
  1004. */
  1005. void vmbus_onmessage(void *context)
  1006. {
  1007. struct hv_message *msg = context;
  1008. struct vmbus_channel_message_header *hdr;
  1009. int size;
  1010. hdr = (struct vmbus_channel_message_header *)msg->u.payload;
  1011. size = msg->header.payload_size;
  1012. trace_vmbus_on_message(hdr);
  1013. if (hdr->msgtype >= CHANNELMSG_COUNT) {
  1014. pr_err("Received invalid channel message type %d size %d\n",
  1015. hdr->msgtype, size);
  1016. print_hex_dump_bytes("", DUMP_PREFIX_NONE,
  1017. (unsigned char *)msg->u.payload, size);
  1018. return;
  1019. }
  1020. if (channel_message_table[hdr->msgtype].message_handler)
  1021. channel_message_table[hdr->msgtype].message_handler(hdr);
  1022. else
  1023. pr_err("Unhandled channel message type %d\n", hdr->msgtype);
  1024. }
  1025. /*
  1026. * vmbus_request_offers - Send a request to get all our pending offers.
  1027. */
  1028. int vmbus_request_offers(void)
  1029. {
  1030. struct vmbus_channel_message_header *msg;
  1031. struct vmbus_channel_msginfo *msginfo;
  1032. int ret;
  1033. msginfo = kmalloc(sizeof(*msginfo) +
  1034. sizeof(struct vmbus_channel_message_header),
  1035. GFP_KERNEL);
  1036. if (!msginfo)
  1037. return -ENOMEM;
  1038. msg = (struct vmbus_channel_message_header *)msginfo->msg;
  1039. msg->msgtype = CHANNELMSG_REQUESTOFFERS;
  1040. ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_message_header),
  1041. true);
  1042. trace_vmbus_request_offers(ret);
  1043. if (ret != 0) {
  1044. pr_err("Unable to request offers - %d\n", ret);
  1045. goto cleanup;
  1046. }
  1047. cleanup:
  1048. kfree(msginfo);
  1049. return ret;
  1050. }
  1051. /*
  1052. * Retrieve the (sub) channel on which to send an outgoing request.
  1053. * When a primary channel has multiple sub-channels, we try to
  1054. * distribute the load equally amongst all available channels.
  1055. */
  1056. struct vmbus_channel *vmbus_get_outgoing_channel(struct vmbus_channel *primary)
  1057. {
  1058. struct list_head *cur, *tmp;
  1059. int cur_cpu;
  1060. struct vmbus_channel *cur_channel;
  1061. struct vmbus_channel *outgoing_channel = primary;
  1062. int next_channel;
  1063. int i = 1;
  1064. if (list_empty(&primary->sc_list))
  1065. return outgoing_channel;
  1066. next_channel = primary->next_oc++;
  1067. if (next_channel > (primary->num_sc)) {
  1068. primary->next_oc = 0;
  1069. return outgoing_channel;
  1070. }
  1071. cur_cpu = hv_cpu_number_to_vp_number(smp_processor_id());
  1072. list_for_each_safe(cur, tmp, &primary->sc_list) {
  1073. cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
  1074. if (cur_channel->state != CHANNEL_OPENED_STATE)
  1075. continue;
  1076. if (cur_channel->target_vp == cur_cpu)
  1077. return cur_channel;
  1078. if (i == next_channel)
  1079. return cur_channel;
  1080. i++;
  1081. }
  1082. return outgoing_channel;
  1083. }
  1084. EXPORT_SYMBOL_GPL(vmbus_get_outgoing_channel);
  1085. static void invoke_sc_cb(struct vmbus_channel *primary_channel)
  1086. {
  1087. struct list_head *cur, *tmp;
  1088. struct vmbus_channel *cur_channel;
  1089. if (primary_channel->sc_creation_callback == NULL)
  1090. return;
  1091. list_for_each_safe(cur, tmp, &primary_channel->sc_list) {
  1092. cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
  1093. primary_channel->sc_creation_callback(cur_channel);
  1094. }
  1095. }
  1096. void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
  1097. void (*sc_cr_cb)(struct vmbus_channel *new_sc))
  1098. {
  1099. primary_channel->sc_creation_callback = sc_cr_cb;
  1100. }
  1101. EXPORT_SYMBOL_GPL(vmbus_set_sc_create_callback);
  1102. bool vmbus_are_subchannels_present(struct vmbus_channel *primary)
  1103. {
  1104. bool ret;
  1105. ret = !list_empty(&primary->sc_list);
  1106. if (ret) {
  1107. /*
  1108. * Invoke the callback on sub-channel creation.
  1109. * This will present a uniform interface to the
  1110. * clients.
  1111. */
  1112. invoke_sc_cb(primary);
  1113. }
  1114. return ret;
  1115. }
  1116. EXPORT_SYMBOL_GPL(vmbus_are_subchannels_present);
  1117. void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel,
  1118. void (*chn_rescind_cb)(struct vmbus_channel *))
  1119. {
  1120. channel->chn_rescind_callback = chn_rescind_cb;
  1121. }
  1122. EXPORT_SYMBOL_GPL(vmbus_set_chn_rescind_callback);