Lines Matching full:channel
26 static void init_vp_index(struct vmbus_channel *channel, u16 dev_type);
41 /* Fibre Channel */
140 * The rescinded channel may be blocked waiting for a response from the host;
143 static void vmbus_rescind_cleanup(struct vmbus_channel *channel) in vmbus_rescind_cleanup() argument
150 channel->rescind = true; in vmbus_rescind_cleanup()
154 if (msginfo->waiting_channel == channel) { in vmbus_rescind_cleanup()
172 static u16 hv_get_dev_type(const struct vmbus_channel *channel) in hv_get_dev_type() argument
174 const guid_t *guid = &channel->offermsg.offer.if_type; in hv_get_dev_type()
177 if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid)) in hv_get_dev_type()
191 * @buf: Raw buffer channel data
308 * alloc_channel - Allocate and initialize a vmbus channel object
312 struct vmbus_channel *channel; in alloc_channel() local
314 channel = kzalloc(sizeof(*channel), GFP_ATOMIC); in alloc_channel()
315 if (!channel) in alloc_channel()
318 spin_lock_init(&channel->lock); in alloc_channel()
319 init_completion(&channel->rescind_event); in alloc_channel()
321 INIT_LIST_HEAD(&channel->sc_list); in alloc_channel()
322 INIT_LIST_HEAD(&channel->percpu_list); in alloc_channel()
324 tasklet_init(&channel->callback_event, in alloc_channel()
325 vmbus_on_event, (unsigned long)channel); in alloc_channel()
327 hv_ringbuffer_pre_init(channel); in alloc_channel()
329 return channel; in alloc_channel()
333 * free_channel - Release the resources used by the vmbus channel object
335 static void free_channel(struct vmbus_channel *channel) in free_channel() argument
337 tasklet_kill(&channel->callback_event); in free_channel()
338 vmbus_remove_channel_attr_group(channel); in free_channel()
340 kobject_put(&channel->kobj); in free_channel()
345 struct vmbus_channel *channel = arg; in percpu_channel_enq() local
349 list_add_tail_rcu(&channel->percpu_list, &hv_cpu->chan_list); in percpu_channel_enq()
354 struct vmbus_channel *channel = arg; in percpu_channel_deq() local
356 list_del_rcu(&channel->percpu_list); in percpu_channel_deq()
374 void hv_process_channel_removal(struct vmbus_channel *channel) in hv_process_channel_removal() argument
380 BUG_ON(!channel->rescind); in hv_process_channel_removal()
382 if (channel->target_cpu != get_cpu()) { in hv_process_channel_removal()
384 smp_call_function_single(channel->target_cpu, in hv_process_channel_removal()
385 percpu_channel_deq, channel, true); in hv_process_channel_removal()
387 percpu_channel_deq(channel); in hv_process_channel_removal()
391 if (channel->primary_channel == NULL) { in hv_process_channel_removal()
392 list_del(&channel->listentry); in hv_process_channel_removal()
394 primary_channel = channel; in hv_process_channel_removal()
396 primary_channel = channel->primary_channel; in hv_process_channel_removal()
398 list_del(&channel->sc_list); in hv_process_channel_removal()
404 * of sub-channel, when we reload drivers like hv_netvsc. in hv_process_channel_removal()
406 if (channel->affinity_policy == HV_LOCALIZED) in hv_process_channel_removal()
407 cpumask_clear_cpu(channel->target_cpu, in hv_process_channel_removal()
411 * Upon suspend, an in-use hv_sock channel is marked as "rescinded" and in hv_process_channel_removal()
413 * destroys the channel, the relid is INVALID_RELID, and in this case in hv_process_channel_removal()
415 * relid can refer to a completely different channel now. in hv_process_channel_removal()
417 if (channel->offermsg.child_relid != INVALID_RELID) in hv_process_channel_removal()
418 vmbus_release_relid(channel->offermsg.child_relid); in hv_process_channel_removal()
420 free_channel(channel); in hv_process_channel_removal()
425 struct vmbus_channel *channel, *tmp; in vmbus_free_channels() local
427 list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list, in vmbus_free_channels()
430 channel->rescind = true; in vmbus_free_channels()
432 vmbus_device_unregister(channel->device_obj); in vmbus_free_channels()
462 * so that when we do close the channel normally, we in vmbus_add_channel_work()
468 /* newchannel is a sub-channel. */ in vmbus_add_channel_work()
482 * Start the process of binding the primary channel to the driver in vmbus_add_channel_work()
544 * vmbus_process_offer - Process the offer by creating a channel/device
549 struct vmbus_channel *channel; in vmbus_process_offer() local
566 list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) { in vmbus_process_offer()
567 if (guid_equal(&channel->offermsg.offer.if_type, in vmbus_process_offer()
569 guid_equal(&channel->offermsg.offer.if_instance, in vmbus_process_offer()
581 * Check to see if this is a valid sub-channel. in vmbus_process_offer()
594 * Process the sub-channel. in vmbus_process_offer()
596 newchannel->primary_channel = channel; in vmbus_process_offer()
597 spin_lock_irqsave(&channel->lock, flags); in vmbus_process_offer()
598 list_add_tail(&newchannel->sc_list, &channel->sc_list); in vmbus_process_offer()
599 spin_unlock_irqrestore(&channel->lock, flags); in vmbus_process_offer()
605 * vmbus_process_offer() mustn't call channel->sc_creation_callback() in vmbus_process_offer()
608 * OPEN_CHANNEL message (the host may rescind a channel at any time, in vmbus_process_offer()
632 * We use this state to statically distribute the channel interrupt load.
645 * channel interrupt load by binding a channel to VCPU.
647 * the channel's affinity_policy.
652 static void init_vp_index(struct vmbus_channel *channel, u16 dev_type) in init_vp_index() argument
656 struct vmbus_channel *primary = channel->primary_channel; in init_vp_index()
665 * Prior to win8, all channel interrupts are in init_vp_index()
667 * Also if the channel is not a performance critical in init_vp_index()
668 * channel, bind it to cpu 0. in init_vp_index()
671 channel->numa_node = 0; in init_vp_index()
672 channel->target_cpu = 0; in init_vp_index()
673 channel->target_vp = hv_cpu_number_to_vp_number(0); in init_vp_index()
680 * Based on the channel affinity policy, we will assign the NUMA in init_vp_index()
684 if ((channel->affinity_policy == HV_BALANCED) || (!primary)) { in init_vp_index()
695 channel->numa_node = next_node; in init_vp_index()
696 primary = channel; in init_vp_index()
737 * NOTE: in the case of sub-channel, we clear the in init_vp_index()
738 * sub-channel related bit(s) in in init_vp_index()
758 channel->target_cpu = cur_cpu; in init_vp_index()
759 channel->target_vp = hv_cpu_number_to_vp_number(cur_cpu); in init_vp_index()
872 static void vmbus_setup_channel_state(struct vmbus_channel *channel, in vmbus_setup_channel_state() argument
878 channel->sig_event = VMBUS_EVENT_CONNECTION_ID; in vmbus_setup_channel_state()
881 channel->is_dedicated_interrupt = in vmbus_setup_channel_state()
883 channel->sig_event = offer->connection_id; in vmbus_setup_channel_state()
886 memcpy(&channel->offermsg, offer, in vmbus_setup_channel_state()
888 channel->monitor_grp = (u8)offer->monitorid / 32; in vmbus_setup_channel_state()
889 channel->monitor_bit = (u8)offer->monitorid % 32; in vmbus_setup_channel_state()
893 * find_primary_channel_by_offer - Get the channel object given the new offer.
899 struct vmbus_channel *channel = NULL, *iter; in find_primary_channel_by_offer() local
902 /* Ignore sub-channel offers. */ in find_primary_channel_by_offer()
913 channel = iter; in find_primary_channel_by_offer()
920 return channel; in find_primary_channel_by_offer()
924 * vmbus_onoffer - Handler for channel offers from vmbus in parent partition.
943 * We're resuming from hibernation: all the sub-channel and in vmbus_onoffer()
946 * primary channel that we had before the hibernation. in vmbus_onoffer()
974 /* Fix up the old channel. */ in vmbus_onoffer()
982 /* Allocate the channel object and save this offer. */ in vmbus_onoffer()
987 pr_err("Unable to allocate channel object\n"); in vmbus_onoffer()
1014 struct vmbus_channel *channel; in vmbus_onoffer_rescind() local
1032 * point where the channel is discoverable. in vmbus_onoffer_rescind()
1037 * We wait here until any channel offer is currently in vmbus_onoffer_rescind()
1044 channel = relid2channel(rescind->child_relid); in vmbus_onoffer_rescind()
1047 if (channel == NULL) { in vmbus_onoffer_rescind()
1056 clean_up_chan_for_suspend = is_hvsock_channel(channel) || in vmbus_onoffer_rescind()
1057 is_sub_channel(channel); in vmbus_onoffer_rescind()
1059 * Before setting channel->rescind in vmbus_rescind_cleanup(), we in vmbus_onoffer_rescind()
1060 * should make sure the channel callback is not running any more. in vmbus_onoffer_rescind()
1062 vmbus_reset_channel_cb(channel); in vmbus_onoffer_rescind()
1067 vmbus_rescind_cleanup(channel); in vmbus_onoffer_rescind()
1068 while (READ_ONCE(channel->probe_done) == false) { in vmbus_onoffer_rescind()
1070 * We wait here until any channel offer is currently in vmbus_onoffer_rescind()
1080 if (channel->device_obj) { in vmbus_onoffer_rescind()
1081 if (channel->chn_rescind_callback) { in vmbus_onoffer_rescind()
1082 channel->chn_rescind_callback(channel); in vmbus_onoffer_rescind()
1093 dev = get_device(&channel->device_obj->device); in vmbus_onoffer_rescind()
1095 vmbus_device_unregister(channel->device_obj); in vmbus_onoffer_rescind()
1099 if (channel->primary_channel != NULL) { in vmbus_onoffer_rescind()
1101 * Sub-channel is being rescinded. Following is the channel in vmbus_onoffer_rescind()
1105 * 2. Then close the primary channel. in vmbus_onoffer_rescind()
1108 if (channel->state == CHANNEL_OPEN_STATE) { in vmbus_onoffer_rescind()
1110 * The channel is currently not open; in vmbus_onoffer_rescind()
1111 * it is safe for us to cleanup the channel. in vmbus_onoffer_rescind()
1113 hv_process_channel_removal(channel); in vmbus_onoffer_rescind()
1115 complete(&channel->rescind_event); in vmbus_onoffer_rescind()
1120 /* The "channel" may have been freed. Do not access it any longer. */ in vmbus_onoffer_rescind()
1126 void vmbus_hvsock_device_unregister(struct vmbus_channel *channel) in vmbus_hvsock_device_unregister() argument
1128 BUG_ON(!is_hvsock_channel(channel)); in vmbus_hvsock_device_unregister()
1131 while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind)) in vmbus_hvsock_device_unregister()
1134 vmbus_device_unregister(channel->device_obj); in vmbus_hvsock_device_unregister()
1153 * This is invoked when we received a response to our channel open request.
1329 /* Channel message dispatch table */
1357 * vmbus_onmessage - Handler for channel protocol messages.
1373 pr_err("Received invalid channel message type %d size %d\n", in vmbus_onmessage()
1383 pr_err("Unhandled channel message type %d\n", hdr->msgtype); in vmbus_onmessage()
1452 * Invoke the callback on sub-channel creation. in vmbus_are_subchannels_present()
1463 void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel, in vmbus_set_chn_rescind_callback() argument
1466 channel->chn_rescind_callback = chn_rescind_cb; in vmbus_set_chn_rescind_callback()