Lines Matching full:channel

29 static void init_vp_index(struct vmbus_channel *channel);
46 /* Fibre Channel */
170 * The rescinded channel may be blocked waiting for a response from the host;
173 static void vmbus_rescind_cleanup(struct vmbus_channel *channel) in vmbus_rescind_cleanup() argument
180 channel->rescind = true; in vmbus_rescind_cleanup()
184 if (msginfo->waiting_channel == channel) { in vmbus_rescind_cleanup()
202 static u16 hv_get_dev_type(const struct vmbus_channel *channel) in hv_get_dev_type() argument
204 const guid_t *guid = &channel->offermsg.offer.if_type; in hv_get_dev_type()
207 if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid)) in hv_get_dev_type()
221 * @buf: Raw buffer channel data
222 * @buflen: Length of the raw buffer channel data.
351 * alloc_channel - Allocate and initialize a vmbus channel object
355 struct vmbus_channel *channel; in alloc_channel() local
357 channel = kzalloc(sizeof(*channel), GFP_ATOMIC); in alloc_channel()
358 if (!channel) in alloc_channel()
361 spin_lock_init(&channel->sched_lock); in alloc_channel()
362 init_completion(&channel->rescind_event); in alloc_channel()
364 INIT_LIST_HEAD(&channel->sc_list); in alloc_channel()
366 tasklet_init(&channel->callback_event, in alloc_channel()
367 vmbus_on_event, (unsigned long)channel); in alloc_channel()
369 hv_ringbuffer_pre_init(channel); in alloc_channel()
371 return channel; in alloc_channel()
375 * free_channel - Release the resources used by the vmbus channel object
377 static void free_channel(struct vmbus_channel *channel) in free_channel() argument
379 tasklet_kill(&channel->callback_event); in free_channel()
380 vmbus_remove_channel_attr_group(channel); in free_channel()
382 kobject_put(&channel->kobj); in free_channel()
385 void vmbus_channel_map_relid(struct vmbus_channel *channel) in vmbus_channel_map_relid() argument
387 if (WARN_ON(channel->offermsg.child_relid >= MAX_CHANNEL_RELIDS)) in vmbus_channel_map_relid()
390 * The mapping of the channel's relid is visible from the CPUs that in vmbus_channel_map_relid()
398 * channel's ring buffer is allocated/initialized and the in vmbus_channel_map_relid()
399 * OPENCHANNEL message for the channel is sent in vmbus_open(). in vmbus_channel_map_relid()
400 * Hyper-V won't start sending the interrupts for the channel in vmbus_channel_map_relid()
403 * that vmbus_chan_sched() must find the channel's relid in in vmbus_channel_map_relid()
404 * recv_int_page before retrieving the channel pointer from the in vmbus_channel_map_relid()
415 vmbus_connection.channels[channel->offermsg.child_relid], in vmbus_channel_map_relid()
416 channel); in vmbus_channel_map_relid()
419 void vmbus_channel_unmap_relid(struct vmbus_channel *channel) in vmbus_channel_unmap_relid() argument
421 if (WARN_ON(channel->offermsg.child_relid >= MAX_CHANNEL_RELIDS)) in vmbus_channel_unmap_relid()
424 vmbus_connection.channels[channel->offermsg.child_relid], in vmbus_channel_unmap_relid()
442 void hv_process_channel_removal(struct vmbus_channel *channel) in hv_process_channel_removal() argument
445 BUG_ON(!channel->rescind); in hv_process_channel_removal()
451 WARN_ON(channel->offermsg.child_relid == INVALID_RELID && in hv_process_channel_removal()
452 !is_hvsock_channel(channel)); in hv_process_channel_removal()
455 * Upon suspend, an in-use hv_sock channel is removed from the array of in hv_process_channel_removal()
457 * user-space application destroys the channel, it's unnecessary and in hv_process_channel_removal()
458 * unsafe to remove the channel from the array of channels. See also in hv_process_channel_removal()
461 if (channel->offermsg.child_relid != INVALID_RELID) in hv_process_channel_removal()
462 vmbus_channel_unmap_relid(channel); in hv_process_channel_removal()
464 if (channel->primary_channel == NULL) in hv_process_channel_removal()
465 list_del(&channel->listentry); in hv_process_channel_removal()
467 list_del(&channel->sc_list); in hv_process_channel_removal()
470 * If this is a "perf" channel, updates the hv_numa_map[] masks so that in hv_process_channel_removal()
473 if (hv_is_perf_channel(channel)) in hv_process_channel_removal()
474 hv_clear_allocated_cpu(channel->target_cpu); in hv_process_channel_removal()
477 * Upon suspend, an in-use hv_sock channel is marked as "rescinded" and in hv_process_channel_removal()
479 * destroys the channel, the relid is INVALID_RELID, and in this case in hv_process_channel_removal()
481 * relid can refer to a completely different channel now. in hv_process_channel_removal()
483 if (channel->offermsg.child_relid != INVALID_RELID) in hv_process_channel_removal()
484 vmbus_release_relid(channel->offermsg.child_relid); in hv_process_channel_removal()
486 free_channel(channel); in hv_process_channel_removal()
491 struct vmbus_channel *channel, *tmp; in vmbus_free_channels() local
493 list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list, in vmbus_free_channels()
496 channel->rescind = true; in vmbus_free_channels()
498 vmbus_device_unregister(channel->device_obj); in vmbus_free_channels()
512 * so that when we do close the channel normally, we in vmbus_add_channel_work()
518 /* newchannel is a sub-channel. */ in vmbus_add_channel_work()
532 * Start the process of binding the primary channel to the driver in vmbus_add_channel_work()
577 /* vmbus_process_offer() has mapped the channel. */ in vmbus_add_channel_work()
588 * vmbus_process_offer - Process the offer by creating a channel/device
593 struct vmbus_channel *channel; in vmbus_process_offer() local
624 list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) { in vmbus_process_offer()
625 if (guid_equal(&channel->offermsg.offer.if_type, in vmbus_process_offer()
627 guid_equal(&channel->offermsg.offer.if_instance, in vmbus_process_offer()
630 newchannel->primary_channel = channel; in vmbus_process_offer()
652 * Check to see if this is a valid sub-channel. in vmbus_process_offer()
666 * Process the sub-channel. in vmbus_process_offer()
668 list_add_tail(&newchannel->sc_list, &channel->sc_list); in vmbus_process_offer()
677 * vmbus_process_offer() mustn't call channel->sc_creation_callback() in vmbus_process_offer()
680 * OPEN_CHANNEL message (the host may rescind a channel at any time, in vmbus_process_offer()
728 * We use this state to statically distribute the channel interrupt load.
733 * We can statically distribute the incoming channel interrupt load
734 * by binding a channel to VCPU.
741 static void init_vp_index(struct vmbus_channel *channel) in init_vp_index() argument
743 bool perf_chn = hv_is_perf_channel(channel); in init_vp_index()
755 * If the channel is not a performance critical in init_vp_index()
756 * channel, bind it to VMBUS_CONNECT_CPU. in init_vp_index()
762 channel->target_cpu = VMBUS_CONNECT_CPU; in init_vp_index()
797 if (channel->offermsg.offer.sub_channel_index >= ncpu || in init_vp_index()
798 i > ncpu || !hv_cpuself_used(target_cpu, channel)) in init_vp_index()
802 channel->target_cpu = target_cpu; in init_vp_index()
948 static void vmbus_setup_channel_state(struct vmbus_channel *channel, in vmbus_setup_channel_state() argument
954 channel->sig_event = VMBUS_EVENT_CONNECTION_ID; in vmbus_setup_channel_state()
956 channel->is_dedicated_interrupt = 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.
974 struct vmbus_channel *channel = NULL, *iter; in find_primary_channel_by_offer() local
977 /* Ignore sub-channel offers. */ in find_primary_channel_by_offer()
988 channel = iter; in find_primary_channel_by_offer()
995 return channel; in find_primary_channel_by_offer()
1017 * vmbus_onoffer - Handler for channel offers from vmbus in parent partition.
1041 * We're resuming from hibernation: all the sub-channel and in vmbus_onoffer()
1044 * primary channel that we had before the hibernation. in vmbus_onoffer()
1048 * { Initially: channel relid = INVALID_RELID, in vmbus_onoffer()
1056 * STORE channel relid = valid_relid LOAD r1 = channel relid in vmbus_onoffer()
1057 * MAP_RELID channel if (r1 != INVALID_RELID) in vmbus_onoffer()
1058 * UNLOCK channel_mutex UNMAP_RELID channel in vmbus_onoffer()
1062 * channels[valid_relid] == channel in vmbus_onoffer()
1064 * Note. r1 can be INVALID_RELID only for an hv_sock channel. in vmbus_onoffer()
1097 /* Fix up the old channel. */ in vmbus_onoffer()
1101 /* Add the channel back to the array of channels. */ in vmbus_onoffer()
1107 /* Allocate the channel object and save this offer. */ in vmbus_onoffer()
1112 pr_err("Unable to allocate channel object\n"); in vmbus_onoffer()
1139 struct vmbus_channel *channel; in vmbus_onoffer_rescind() local
1173 * We wait here until any channel offer is currently in vmbus_onoffer_rescind()
1180 channel = relid2channel(rescind->child_relid); in vmbus_onoffer_rescind()
1181 if (channel != NULL) { in vmbus_onoffer_rescind()
1184 * has got a reference to the channel object. Synchronize on in vmbus_onoffer_rescind()
1187 if (channel->rescind_ref) { in vmbus_onoffer_rescind()
1191 channel->rescind_ref = true; in vmbus_onoffer_rescind()
1195 if (channel == NULL) { in vmbus_onoffer_rescind()
1204 clean_up_chan_for_suspend = is_hvsock_channel(channel) || in vmbus_onoffer_rescind()
1205 is_sub_channel(channel); in vmbus_onoffer_rescind()
1207 * Before setting channel->rescind in vmbus_rescind_cleanup(), we in vmbus_onoffer_rescind()
1208 * should make sure the channel callback is not running any more. in vmbus_onoffer_rescind()
1210 vmbus_reset_channel_cb(channel); in vmbus_onoffer_rescind()
1215 vmbus_rescind_cleanup(channel); in vmbus_onoffer_rescind()
1216 while (READ_ONCE(channel->probe_done) == false) { in vmbus_onoffer_rescind()
1218 * We wait here until any channel offer is currently in vmbus_onoffer_rescind()
1228 if (channel->device_obj) { in vmbus_onoffer_rescind()
1229 if (channel->chn_rescind_callback) { in vmbus_onoffer_rescind()
1230 channel->chn_rescind_callback(channel); in vmbus_onoffer_rescind()
1241 dev = get_device(&channel->device_obj->device); in vmbus_onoffer_rescind()
1243 vmbus_device_unregister(channel->device_obj); in vmbus_onoffer_rescind()
1246 } else if (channel->primary_channel != NULL) { in vmbus_onoffer_rescind()
1248 * Sub-channel is being rescinded. Following is the channel in vmbus_onoffer_rescind()
1252 * 2. Then close the primary channel. in vmbus_onoffer_rescind()
1255 if (channel->state == CHANNEL_OPEN_STATE) { in vmbus_onoffer_rescind()
1257 * The channel is currently not open; in vmbus_onoffer_rescind()
1258 * it is safe for us to cleanup the channel. in vmbus_onoffer_rescind()
1260 hv_process_channel_removal(channel); in vmbus_onoffer_rescind()
1262 complete(&channel->rescind_event); in vmbus_onoffer_rescind()
1267 /* The "channel" may have been freed. Do not access it any longer. */ in vmbus_onoffer_rescind()
1273 void vmbus_hvsock_device_unregister(struct vmbus_channel *channel) in vmbus_hvsock_device_unregister() argument
1275 BUG_ON(!is_hvsock_channel(channel)); in vmbus_hvsock_device_unregister()
1278 while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind)) in vmbus_hvsock_device_unregister()
1281 vmbus_device_unregister(channel->device_obj); in vmbus_hvsock_device_unregister()
1290 * channel for any virtual hardware configured in the VM at the time it boots.
1295 * devices can be hot-added to the VM after it is booted, additional channel
1303 * NIC channel is opened (once it knows the guest can support it, via the
1315 * This is invoked when we received a response to our channel open request.
1408 * vmbus_onmodifychannel_response - Modify Channel response handler.
1410 * This is invoked when we received a response to our channel modify request.
1531 /* Channel message dispatch table */
1569 * vmbus_onmessage - Handler for channel protocol messages.
1655 void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel, in vmbus_set_chn_rescind_callback() argument
1658 channel->chn_rescind_callback = chn_rescind_cb; in vmbus_set_chn_rescind_callback()