Lines Matching +full:sub +full:- +full:message
1 // SPDX-License-Identifier: GPL-2.0-only
170 channel->rescind = true; in vmbus_rescind_cleanup()
174 if (msginfo->waiting_channel == channel) { in vmbus_rescind_cleanup()
175 complete(&msginfo->waitevent); in vmbus_rescind_cleanup()
194 const guid_t *guid = &channel->offermsg.offer.if_type; in hv_get_dev_type()
209 * vmbus_prep_negotiate_resp() - Create default response for Negotiate message
222 * Set up and fill in default negotiate response message.
223 * Mainly used by Hyper-V drivers.
244 icmsghdrp->icmsgsize = 0x10; in vmbus_prep_negotiate_resp()
247 icframe_major = negop->icframe_vercnt; in vmbus_prep_negotiate_resp()
250 icmsg_major = negop->icmsg_vercnt; in vmbus_prep_negotiate_resp()
257 pr_err_ratelimited("Invalid icmsg negotiate - icframe_major: %u, icmsg_major: %u\n", in vmbus_prep_negotiate_resp()
271 for (j = 0; j < negop->icframe_vercnt; j++) { in vmbus_prep_negotiate_resp()
272 if ((negop->icversion_data[j].major == fw_major) && in vmbus_prep_negotiate_resp()
273 (negop->icversion_data[j].minor == fw_minor)) { in vmbus_prep_negotiate_resp()
274 icframe_major = negop->icversion_data[j].major; in vmbus_prep_negotiate_resp()
275 icframe_minor = negop->icversion_data[j].minor; in vmbus_prep_negotiate_resp()
294 for (j = negop->icframe_vercnt; in vmbus_prep_negotiate_resp()
295 (j < negop->icframe_vercnt + negop->icmsg_vercnt); in vmbus_prep_negotiate_resp()
298 if ((negop->icversion_data[j].major == srv_major) && in vmbus_prep_negotiate_resp()
299 (negop->icversion_data[j].minor == srv_minor)) { in vmbus_prep_negotiate_resp()
301 icmsg_major = negop->icversion_data[j].major; in vmbus_prep_negotiate_resp()
302 icmsg_minor = negop->icversion_data[j].minor; in vmbus_prep_negotiate_resp()
319 negop->icframe_vercnt = 0; in vmbus_prep_negotiate_resp()
320 negop->icmsg_vercnt = 0; in vmbus_prep_negotiate_resp()
322 negop->icframe_vercnt = 1; in vmbus_prep_negotiate_resp()
323 negop->icmsg_vercnt = 1; in vmbus_prep_negotiate_resp()
332 negop->icversion_data[0].major = icframe_major; in vmbus_prep_negotiate_resp()
333 negop->icversion_data[0].minor = icframe_minor; in vmbus_prep_negotiate_resp()
334 negop->icversion_data[1].major = icmsg_major; in vmbus_prep_negotiate_resp()
335 negop->icversion_data[1].minor = icmsg_minor; in vmbus_prep_negotiate_resp()
341 * alloc_channel - Allocate and initialize a vmbus channel object
351 spin_lock_init(&channel->sched_lock); in alloc_channel()
352 init_completion(&channel->rescind_event); in alloc_channel()
354 INIT_LIST_HEAD(&channel->sc_list); in alloc_channel()
356 tasklet_init(&channel->callback_event, in alloc_channel()
365 * free_channel - Release the resources used by the vmbus channel object
369 tasklet_kill(&channel->callback_event); in free_channel()
372 kobject_put(&channel->kobj); in free_channel()
377 if (WARN_ON(channel->offermsg.child_relid >= MAX_CHANNEL_RELIDS)) in vmbus_channel_map_relid()
389 * OPENCHANNEL message for the channel is sent in vmbus_open(). in vmbus_channel_map_relid()
390 * Hyper-V won't start sending the interrupts for the channel in vmbus_channel_map_relid()
391 * before the OPENCHANNEL message is acked. The memory barrier in vmbus_channel_map_relid()
392 * in vmbus_chan_sched() -> sync_test_and_clear_bit() ensures in vmbus_channel_map_relid()
405 vmbus_connection.channels[channel->offermsg.child_relid], in vmbus_channel_map_relid()
411 if (WARN_ON(channel->offermsg.child_relid >= MAX_CHANNEL_RELIDS)) in vmbus_channel_unmap_relid()
414 vmbus_connection.channels[channel->offermsg.child_relid], in vmbus_channel_unmap_relid()
435 BUG_ON(!channel->rescind); in hv_process_channel_removal()
441 WARN_ON(channel->offermsg.child_relid == INVALID_RELID && in hv_process_channel_removal()
445 * Upon suspend, an in-use hv_sock channel is removed from the array of in hv_process_channel_removal()
447 * user-space application destroys the channel, it's unnecessary and in hv_process_channel_removal()
451 if (channel->offermsg.child_relid != INVALID_RELID) in hv_process_channel_removal()
454 if (channel->primary_channel == NULL) in hv_process_channel_removal()
455 list_del(&channel->listentry); in hv_process_channel_removal()
457 list_del(&channel->sc_list); in hv_process_channel_removal()
461 * init_vp_index() can (re-)use the CPU. in hv_process_channel_removal()
464 hv_clear_allocated_cpu(channel->target_cpu); in hv_process_channel_removal()
467 * Upon suspend, an in-use hv_sock channel is marked as "rescinded" and in hv_process_channel_removal()
468 * the relid is invalidated; after hibernation, when the user-space app in hv_process_channel_removal()
473 if (channel->offermsg.child_relid != INVALID_RELID) in hv_process_channel_removal()
474 vmbus_release_relid(channel->offermsg.child_relid); in hv_process_channel_removal()
486 channel->rescind = true; in vmbus_free_channels()
488 vmbus_device_unregister(channel->device_obj); in vmbus_free_channels()
492 /* Note: the function can run concurrently for primary/sub channels. */
497 struct vmbus_channel *primary_channel = newchannel->primary_channel; in vmbus_add_channel_work()
505 newchannel->state = CHANNEL_OPEN_STATE; in vmbus_add_channel_work()
508 /* newchannel is a sub-channel. */ in vmbus_add_channel_work()
509 struct hv_device *dev = primary_channel->device_obj; in vmbus_add_channel_work()
514 if (primary_channel->sc_creation_callback != NULL) in vmbus_add_channel_work()
515 primary_channel->sc_creation_callback(newchannel); in vmbus_add_channel_work()
517 newchannel->probe_done = true; in vmbus_add_channel_work()
524 newchannel->device_obj = vmbus_device_create( in vmbus_add_channel_work()
525 &newchannel->offermsg.offer.if_type, in vmbus_add_channel_work()
526 &newchannel->offermsg.offer.if_instance, in vmbus_add_channel_work()
528 if (!newchannel->device_obj) in vmbus_add_channel_work()
531 newchannel->device_obj->device_id = newchannel->device_id; in vmbus_add_channel_work()
533 * Add the new device to the bus. This will kick off device-driver in vmbus_add_channel_work()
542 ret = vmbus_device_register(newchannel->device_obj); in vmbus_add_channel_work()
546 newchannel->offermsg.child_relid); in vmbus_add_channel_work()
550 newchannel->probe_done = true; in vmbus_add_channel_work()
560 newchannel->probe_done = true; in vmbus_add_channel_work()
563 list_del(&newchannel->listentry); in vmbus_add_channel_work()
565 list_del(&newchannel->sc_list); in vmbus_add_channel_work()
572 vmbus_release_relid(newchannel->offermsg.child_relid); in vmbus_add_channel_work()
578 * vmbus_process_offer - Process the offer by creating a channel/device
615 if (guid_equal(&channel->offermsg.offer.if_type, in vmbus_process_offer()
616 &newchannel->offermsg.offer.if_type) && in vmbus_process_offer()
617 guid_equal(&channel->offermsg.offer.if_instance, in vmbus_process_offer()
618 &newchannel->offermsg.offer.if_instance)) { in vmbus_process_offer()
620 newchannel->primary_channel = channel; in vmbus_process_offer()
638 list_add_tail(&newchannel->listentry, in vmbus_process_offer()
642 * Check to see if this is a valid sub-channel. in vmbus_process_offer()
644 if (newchannel->offermsg.offer.sub_channel_index == 0) { in vmbus_process_offer()
648 * Don't call free_channel(), because newchannel->kobj in vmbus_process_offer()
656 * Process the sub-channel. in vmbus_process_offer()
658 list_add_tail(&newchannel->sc_list, &channel->sc_list); in vmbus_process_offer()
667 * vmbus_process_offer() mustn't call channel->sc_creation_callback() in vmbus_process_offer()
668 * directly for sub-channels, because sc_creation_callback() -> in vmbus_process_offer()
670 * OPEN_CHANNEL message (the host may rescind a channel at any time, in vmbus_process_offer()
672 * may not wake up the vmbus_open() as it's blocked due to a non-zero in vmbus_process_offer()
678 * And, usually the handling of primary channels and sub-channels can in vmbus_process_offer()
680 * workqueues to avoid possible deadlock, e.g. in sync-probing mode, in vmbus_process_offer()
681 * NIC1's netvsc_subchan_work() can race with NIC2's netvsc_probe() -> in vmbus_process_offer()
683 * and waits for all the sub-channels to appear, but the latter in vmbus_process_offer()
685 * sub-channels. in vmbus_process_offer()
687 INIT_WORK(&newchannel->add_channel_work, vmbus_add_channel_work); in vmbus_process_offer()
690 queue_work(wq, &newchannel->add_channel_work); in vmbus_process_offer()
699 struct vmbus_channel *primary = chn->primary_channel; in hv_cpuself_used()
707 if (primary->target_cpu == cpu) in hv_cpuself_used()
710 list_for_each_entry(sc, &primary->sc_list, sc_list) in hv_cpuself_used()
711 if (sc != chn && sc->target_cpu == cpu) in hv_cpuself_used()
726 * For non-performance critical channels we assign the VMBUS_CONNECT_CPU.
752 channel->target_cpu = VMBUS_CONNECT_CPU; in init_vp_index()
787 if (channel->offermsg.offer.sub_channel_index >= ncpu || in init_vp_index()
792 channel->target_cpu = target_cpu; in init_vp_index()
818 * read message pages for all CPUs directly. in vmbus_wait_for_unload()
826 * message isn't seen. in vmbus_wait_for_unload()
841 * not all present CPUs are online, the message page in vmbus_wait_for_unload()
844 page_addr = hv_cpu->synic_message_page; in vmbus_wait_for_unload()
851 message_type = READ_ONCE(msg->header.message_type); in vmbus_wait_for_unload()
856 msg->u.payload; in vmbus_wait_for_unload()
858 if (hdr->msgtype == CHANNELMSG_UNLOAD_RESPONSE) in vmbus_wait_for_unload()
878 * maybe-pending messages on all CPUs to be able to receive new in vmbus_wait_for_unload()
885 page_addr = hv_cpu->synic_message_page; in vmbus_wait_for_unload()
890 msg->header.message_type = HVMSG_NONE; in vmbus_wait_for_unload()
895 * vmbus_unload_response - Handler for the unload response.
903 * NB. A malicious or compromised Hyper-V could send a spurious in vmbus_unload_response()
904 * message of type CHANNELMSG_UNLOAD_RESPONSE, and trigger a call in vmbus_unload_response()
918 /* Pre-Win2012R2 hosts don't support reconnect */ in vmbus_initiate_unload()
954 channel->sig_event = VMBUS_EVENT_CONNECTION_ID; in vmbus_setup_channel_state()
956 channel->is_dedicated_interrupt = in vmbus_setup_channel_state()
957 (offer->is_dedicated_interrupt != 0); in vmbus_setup_channel_state()
958 channel->sig_event = offer->connection_id; in vmbus_setup_channel_state()
960 memcpy(&channel->offermsg, offer, in vmbus_setup_channel_state()
962 channel->monitor_grp = (u8)offer->monitorid / 32; in vmbus_setup_channel_state()
963 channel->monitor_bit = (u8)offer->monitorid % 32; in vmbus_setup_channel_state()
964 channel->device_id = hv_get_dev_type(channel); in vmbus_setup_channel_state()
968 * find_primary_channel_by_offer - Get the channel object given the new offer.
977 /* Ignore sub-channel offers. */ in find_primary_channel_by_offer()
978 if (offer->offer.sub_channel_index != 0) in find_primary_channel_by_offer()
984 inst1 = &iter->offermsg.offer.if_instance; in find_primary_channel_by_offer()
985 inst2 = &offer->offer.if_instance; in find_primary_channel_by_offer()
1000 const guid_t *guid = &offer->offer.if_type; in vmbus_is_valid_offer()
1017 * vmbus_onoffer - Handler for channel offers from vmbus in parent partition.
1032 offer->child_relid); in vmbus_onoffer()
1041 * We're resuming from hibernation: all the sub-channel and in vmbus_onoffer()
1043 * been cleaned up, and now we must be seeing a re-offered in vmbus_onoffer()
1066 * suspend are re-offered upon the resume. See the WARN_ON() in vmbus_onoffer()
1073 WARN_ON(oldchannel->offermsg.child_relid != INVALID_RELID); in vmbus_onoffer()
1075 oldchannel->offermsg.child_relid = offer->child_relid; in vmbus_onoffer()
1078 if (memcmp(offer, &oldchannel->offermsg, offer_sz) != 0) { in vmbus_onoffer()
1082 * (Build 17763), the offer->connection_id of the in vmbus_onoffer()
1087 offer->child_relid); in vmbus_onoffer()
1091 &oldchannel->offermsg, offer_sz, in vmbus_onoffer()
1112 vmbus_release_relid(offer->child_relid); in vmbus_onoffer()
1126 * If all the sub-channels or hv_sock channels have been cleaned up, in check_ready_for_suspend_event()
1134 * vmbus_onoffer_rescind - Rescind offer handler.
1151 * from the host are guranteed to be ordered - in vmbus_onoffer_rescind()
1182 channel = relid2channel(rescind->child_relid); in vmbus_onoffer_rescind()
1189 if (channel->rescind_ref) { in vmbus_onoffer_rescind()
1193 channel->rescind_ref = true; in vmbus_onoffer_rescind()
1199 * We failed in processing the offer message; in vmbus_onoffer_rescind()
1209 * Before setting channel->rescind in vmbus_rescind_cleanup(), we in vmbus_onoffer_rescind()
1218 while (READ_ONCE(channel->probe_done) == false) { in vmbus_onoffer_rescind()
1230 if (channel->device_obj) { in vmbus_onoffer_rescind()
1231 if (channel->chn_rescind_callback) { in vmbus_onoffer_rescind()
1232 channel->chn_rescind_callback(channel); in vmbus_onoffer_rescind()
1243 dev = get_device(&channel->device_obj->device); in vmbus_onoffer_rescind()
1245 vmbus_device_unregister(channel->device_obj); in vmbus_onoffer_rescind()
1248 } else if (channel->primary_channel != NULL) { in vmbus_onoffer_rescind()
1250 * Sub-channel is being rescinded. Following is the channel in vmbus_onoffer_rescind()
1253 * 1. Close all sub-channels first in vmbus_onoffer_rescind()
1257 if (channel->state == CHANNEL_OPEN_STATE) { in vmbus_onoffer_rescind()
1264 complete(&channel->rescind_event); in vmbus_onoffer_rescind()
1280 while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind)) in vmbus_hvsock_device_unregister()
1283 vmbus_device_unregister(channel->device_obj); in vmbus_hvsock_device_unregister()
1289 * vmbus_onoffers_delivered -
1300 * vmbus_onopen_result - Open result handler.
1326 (struct vmbus_channel_message_header *)msginfo->msg; in vmbus_onopen_result()
1328 if (requestheader->msgtype == CHANNELMSG_OPENCHANNEL) { in vmbus_onopen_result()
1330 (struct vmbus_channel_open_channel *)msginfo->msg; in vmbus_onopen_result()
1331 if (openmsg->child_relid == result->child_relid && in vmbus_onopen_result()
1332 openmsg->openid == result->openid) { in vmbus_onopen_result()
1333 memcpy(&msginfo->response.open_result, in vmbus_onopen_result()
1337 complete(&msginfo->waitevent); in vmbus_onopen_result()
1346 * vmbus_ongpadl_created - GPADL created handler.
1373 (struct vmbus_channel_message_header *)msginfo->msg; in vmbus_ongpadl_created()
1375 if (requestheader->msgtype == CHANNELMSG_GPADL_HEADER) { in vmbus_ongpadl_created()
1379 if ((gpadlcreated->child_relid == in vmbus_ongpadl_created()
1380 gpadlheader->child_relid) && in vmbus_ongpadl_created()
1381 (gpadlcreated->gpadl == gpadlheader->gpadl)) { in vmbus_ongpadl_created()
1382 memcpy(&msginfo->response.gpadl_created, in vmbus_ongpadl_created()
1386 complete(&msginfo->waitevent); in vmbus_ongpadl_created()
1395 * vmbus_onmodifychannel_response - Modify Channel response handler.
1417 (struct vmbus_channel_message_header *)msginfo->msg; in vmbus_onmodifychannel_response()
1419 if (responseheader->msgtype == CHANNELMSG_MODIFYCHANNEL) { in vmbus_onmodifychannel_response()
1422 modifymsg = (struct vmbus_channel_modifychannel *)msginfo->msg; in vmbus_onmodifychannel_response()
1423 if (modifymsg->child_relid == response->child_relid) { in vmbus_onmodifychannel_response()
1424 memcpy(&msginfo->response.modify_response, response, in vmbus_onmodifychannel_response()
1426 complete(&msginfo->waitevent); in vmbus_onmodifychannel_response()
1435 * vmbus_ongpadl_torndown - GPADL torndown handler.
1462 (struct vmbus_channel_message_header *)msginfo->msg; in vmbus_ongpadl_torndown()
1464 if (requestheader->msgtype == CHANNELMSG_GPADL_TEARDOWN) { in vmbus_ongpadl_torndown()
1468 if (gpadl_torndown->gpadl == gpadl_teardown->gpadl) { in vmbus_ongpadl_torndown()
1469 memcpy(&msginfo->response.gpadl_torndown, in vmbus_ongpadl_torndown()
1473 complete(&msginfo->waitevent); in vmbus_ongpadl_torndown()
1482 * vmbus_onversion_response - Version response handler
1505 (struct vmbus_channel_message_header *)msginfo->msg; in vmbus_onversion_response()
1507 if (requestheader->msgtype == in vmbus_onversion_response()
1509 memcpy(&msginfo->response.version_response, in vmbus_onversion_response()
1512 complete(&msginfo->waitevent); in vmbus_onversion_response()
1518 /* Channel message dispatch table */
1556 * vmbus_onmessage - Handler for channel protocol messages.
1565 * vmbus_on_msg_dpc() makes sure the hdr->msgtype here can not go in vmbus_onmessage()
1568 channel_message_table[hdr->msgtype].message_handler(hdr); in vmbus_onmessage()
1572 * vmbus_request_offers - Send a request to get all our pending offers.
1584 return -ENOMEM; in vmbus_request_offers()
1586 msg = (struct vmbus_channel_message_header *)msginfo->msg; in vmbus_request_offers()
1588 msg->msgtype = CHANNELMSG_REQUESTOFFERS; in vmbus_request_offers()
1596 pr_err("Unable to request offers - %d\n", ret); in vmbus_request_offers()
1610 primary_channel->sc_creation_callback = sc_cr_cb; in vmbus_set_sc_create_callback()
1617 channel->chn_rescind_callback = chn_rescind_cb; in vmbus_set_chn_rescind_callback()