Lines Matching full:channel

156 	 * We need a channel per event queue, plus a VI per tx queue.  in efx_allocate_msix_channels()
273 /* Fall back to single channel MSI */ in efx_probe_interrupts()
366 struct efx_channel *channel; in efx_set_interrupt_affinity() local
374 efx_for_each_channel(channel, efx) { in efx_set_interrupt_affinity()
378 irq_set_affinity_hint(channel->irq, cpumask_of(cpu)); in efx_set_interrupt_affinity()
384 struct efx_channel *channel; in efx_clear_interrupt_affinity() local
386 efx_for_each_channel(channel, efx) in efx_clear_interrupt_affinity()
387 irq_set_affinity_hint(channel->irq, NULL); in efx_clear_interrupt_affinity()
403 struct efx_channel *channel; in efx_remove_interrupts() local
406 efx_for_each_channel(channel, efx) in efx_remove_interrupts()
407 channel->irq = 0; in efx_remove_interrupts()
420 * Event queue memory allocations are done only once. If the channel
422 * errors during channel reset and also simplifies interrupt handling.
424 int efx_probe_eventq(struct efx_channel *channel) in efx_probe_eventq() argument
426 struct efx_nic *efx = channel->efx; in efx_probe_eventq()
430 "chan %d create event queue\n", channel->channel); in efx_probe_eventq()
437 channel->eventq_mask = max(entries, EFX_MIN_EVQ_SIZE) - 1; in efx_probe_eventq()
439 return efx_nic_probe_eventq(channel); in efx_probe_eventq()
442 /* Prepare channel's event queue */
443 int efx_init_eventq(struct efx_channel *channel) in efx_init_eventq() argument
445 struct efx_nic *efx = channel->efx; in efx_init_eventq()
448 EFX_WARN_ON_PARANOID(channel->eventq_init); in efx_init_eventq()
451 "chan %d init event queue\n", channel->channel); in efx_init_eventq()
453 rc = efx_nic_init_eventq(channel); in efx_init_eventq()
455 efx->type->push_irq_moderation(channel); in efx_init_eventq()
456 channel->eventq_read_ptr = 0; in efx_init_eventq()
457 channel->eventq_init = true; in efx_init_eventq()
463 void efx_start_eventq(struct efx_channel *channel) in efx_start_eventq() argument
465 netif_dbg(channel->efx, ifup, channel->efx->net_dev, in efx_start_eventq()
466 "chan %d start event queue\n", channel->channel); in efx_start_eventq()
469 channel->enabled = true; in efx_start_eventq()
472 napi_enable(&channel->napi_str); in efx_start_eventq()
473 efx_nic_eventq_read_ack(channel); in efx_start_eventq()
477 void efx_stop_eventq(struct efx_channel *channel) in efx_stop_eventq() argument
479 if (!channel->enabled) in efx_stop_eventq()
482 napi_disable(&channel->napi_str); in efx_stop_eventq()
483 channel->enabled = false; in efx_stop_eventq()
486 void efx_fini_eventq(struct efx_channel *channel) in efx_fini_eventq() argument
488 if (!channel->eventq_init) in efx_fini_eventq()
491 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_fini_eventq()
492 "chan %d fini event queue\n", channel->channel); in efx_fini_eventq()
494 efx_nic_fini_eventq(channel); in efx_fini_eventq()
495 channel->eventq_init = false; in efx_fini_eventq()
498 void efx_remove_eventq(struct efx_channel *channel) in efx_remove_eventq() argument
500 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_eventq()
501 "chan %d remove event queue\n", channel->channel); in efx_remove_eventq()
503 efx_nic_remove_eventq(channel); in efx_remove_eventq()
508 * Channel handling
516 struct efx_channel *channel; in efx_filter_rfs_expire() local
519 channel = container_of(dwork, struct efx_channel, filter_work); in efx_filter_rfs_expire()
520 time = jiffies - channel->rfs_last_expiry; in efx_filter_rfs_expire()
521 quota = channel->rfs_filter_count * time / (30 * HZ); in efx_filter_rfs_expire()
522 if (quota >= 20 && __efx_filter_rfs_expire(channel, min(channel->rfs_filter_count, quota))) in efx_filter_rfs_expire()
523 channel->rfs_last_expiry += time; in efx_filter_rfs_expire()
529 /* Allocate and initialise a channel structure. */
534 struct efx_channel *channel; in efx_alloc_channel() local
537 channel = kzalloc(sizeof(*channel), GFP_KERNEL); in efx_alloc_channel()
538 if (!channel) in efx_alloc_channel()
541 channel->efx = efx; in efx_alloc_channel()
542 channel->channel = i; in efx_alloc_channel()
543 channel->type = &efx_default_channel_type; in efx_alloc_channel()
546 tx_queue = &channel->tx_queue[j]; in efx_alloc_channel()
550 tx_queue->channel = channel; in efx_alloc_channel()
554 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_alloc_channel()
557 rx_queue = &channel->rx_queue; in efx_alloc_channel()
561 return channel; in efx_alloc_channel()
569 efx->channel[i] = efx_alloc_channel(efx, i); in efx_init_channels()
570 if (!efx->channel[i]) in efx_init_channels()
591 if (efx->channel[i]) { in efx_fini_channels()
592 kfree(efx->channel[i]); in efx_fini_channels()
593 efx->channel[i] = NULL; in efx_fini_channels()
597 /* Allocate and initialise a channel structure, copying parameters
598 * (but not resources) from an old channel structure.
604 struct efx_channel *channel; in efx_copy_channel() local
607 channel = kmalloc(sizeof(*channel), GFP_KERNEL); in efx_copy_channel()
608 if (!channel) in efx_copy_channel()
611 *channel = *old_channel; in efx_copy_channel()
613 channel->napi_dev = NULL; in efx_copy_channel()
614 INIT_HLIST_NODE(&channel->napi_str.napi_hash_node); in efx_copy_channel()
615 channel->napi_str.napi_id = 0; in efx_copy_channel()
616 channel->napi_str.state = 0; in efx_copy_channel()
617 memset(&channel->eventq, 0, sizeof(channel->eventq)); in efx_copy_channel()
620 tx_queue = &channel->tx_queue[j]; in efx_copy_channel()
621 if (tx_queue->channel) in efx_copy_channel()
622 tx_queue->channel = channel; in efx_copy_channel()
628 rx_queue = &channel->rx_queue; in efx_copy_channel()
633 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_copy_channel()
636 return channel; in efx_copy_channel()
639 static int efx_probe_channel(struct efx_channel *channel) in efx_probe_channel() argument
645 netif_dbg(channel->efx, probe, channel->efx->net_dev, in efx_probe_channel()
646 "creating channel %d\n", channel->channel); in efx_probe_channel()
648 rc = channel->type->pre_probe(channel); in efx_probe_channel()
652 rc = efx_probe_eventq(channel); in efx_probe_channel()
656 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_probe_channel()
662 efx_for_each_channel_rx_queue(rx_queue, channel) { in efx_probe_channel()
668 channel->rx_list = NULL; in efx_probe_channel()
673 efx_remove_channel(channel); in efx_probe_channel()
677 static void efx_get_channel_name(struct efx_channel *channel, char *buf, in efx_get_channel_name() argument
680 struct efx_nic *efx = channel->efx; in efx_get_channel_name()
684 number = channel->channel; in efx_get_channel_name()
703 struct efx_channel *channel; in efx_set_channel_names() local
705 efx_for_each_channel(channel, efx) in efx_set_channel_names()
706 channel->type->get_name(channel, in efx_set_channel_names()
707 efx->msi_context[channel->channel].name, in efx_set_channel_names()
713 struct efx_channel *channel; in efx_probe_channels() local
721 efx_for_each_channel_rev(channel, efx) { in efx_probe_channels()
722 rc = efx_probe_channel(channel); in efx_probe_channels()
725 "failed to create channel %d\n", in efx_probe_channels()
726 channel->channel); in efx_probe_channels()
739 void efx_remove_channel(struct efx_channel *channel) in efx_remove_channel() argument
744 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_channel()
745 "destroy chan %d\n", channel->channel); in efx_remove_channel()
747 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_remove_channel()
749 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_remove_channel()
751 efx_remove_eventq(channel); in efx_remove_channel()
752 channel->type->post_remove(channel); in efx_remove_channel()
757 struct efx_channel *channel; in efx_remove_channels() local
759 efx_for_each_channel(channel, efx) in efx_remove_channels()
760 efx_remove_channel(channel); in efx_remove_channels()
772 "Channel %u TXQ %u is XDP %u, HW %u\n", in efx_set_xdp_tx_queue()
773 tx_queue->channel->channel, tx_queue->label, in efx_set_xdp_tx_queue()
782 struct efx_channel *channel; in efx_set_xdp_channels() local
791 efx_for_each_channel(channel, efx) { in efx_set_xdp_channels()
792 if (channel->channel < efx->tx_channel_offset) in efx_set_xdp_channels()
795 if (efx_channel_is_xdp_tx(channel)) { in efx_set_xdp_channels()
796 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_xdp_channels()
804 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_xdp_channels()
807 "Channel %u TXQ %u is HW %u\n", in efx_set_xdp_channels()
808 channel->channel, tx_queue->label, in efx_set_xdp_channels()
814 * first one of the channel in efx_set_xdp_channels()
819 tx_queue = &channel->tx_queue[0]; in efx_set_xdp_channels()
846 struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel, in efx_realloc_channels() local
864 channel = efx->channel[i]; in efx_realloc_channels()
865 if (channel->type->copy) in efx_realloc_channels()
866 channel = channel->type->copy(channel); in efx_realloc_channels()
867 if (!channel) { in efx_realloc_channels()
871 other_channel[i] = channel; in efx_realloc_channels()
874 /* Swap entry counts and channel pointers */ in efx_realloc_channels()
880 swap(efx->channel[i], other_channel[i]); in efx_realloc_channels()
883 channel = efx->channel[i]; in efx_realloc_channels()
884 if (!channel->type->copy) in efx_realloc_channels()
886 rc = efx_probe_channel(channel); in efx_realloc_channels()
889 efx_init_napi_channel(efx->channel[i]); in efx_realloc_channels()
895 /* Destroy unused channel structures */ in efx_realloc_channels()
897 channel = other_channel[i]; in efx_realloc_channels()
898 if (channel && channel->type->copy) { in efx_realloc_channels()
899 efx_fini_napi_channel(channel); in efx_realloc_channels()
900 efx_remove_channel(channel); in efx_realloc_channels()
901 kfree(channel); in efx_realloc_channels()
910 "unable to restart interrupts on channel reallocation\n"); in efx_realloc_channels()
923 swap(efx->channel[i], other_channel[i]); in efx_realloc_channels()
930 struct efx_channel *channel; in efx_set_channels() local
944 efx_for_each_channel(channel, efx) { in efx_set_channels()
945 if (channel->channel < efx->n_rx_channels) in efx_set_channels()
946 channel->rx_queue.core_index = channel->channel; in efx_set_channels()
948 channel->rx_queue.core_index = -1; in efx_set_channels()
959 static bool efx_default_channel_want_txqs(struct efx_channel *channel) in efx_default_channel_want_txqs() argument
961 return channel->channel - channel->efx->tx_channel_offset < in efx_default_channel_want_txqs()
962 channel->efx->n_tx_channels; in efx_default_channel_want_txqs()
971 struct efx_channel *channel, *end_channel; in efx_soft_enable_interrupts() local
979 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
980 if (!channel->type->keep_eventq) { in efx_soft_enable_interrupts()
981 rc = efx_init_eventq(channel); in efx_soft_enable_interrupts()
985 efx_start_eventq(channel); in efx_soft_enable_interrupts()
992 end_channel = channel; in efx_soft_enable_interrupts()
993 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
994 if (channel == end_channel) in efx_soft_enable_interrupts()
996 efx_stop_eventq(channel); in efx_soft_enable_interrupts()
997 if (!channel->type->keep_eventq) in efx_soft_enable_interrupts()
998 efx_fini_eventq(channel); in efx_soft_enable_interrupts()
1006 struct efx_channel *channel; in efx_soft_disable_interrupts() local
1019 efx_for_each_channel(channel, efx) { in efx_soft_disable_interrupts()
1020 if (channel->irq) in efx_soft_disable_interrupts()
1021 synchronize_irq(channel->irq); in efx_soft_disable_interrupts()
1023 efx_stop_eventq(channel); in efx_soft_disable_interrupts()
1024 if (!channel->type->keep_eventq) in efx_soft_disable_interrupts()
1025 efx_fini_eventq(channel); in efx_soft_disable_interrupts()
1034 struct efx_channel *channel, *end_channel; in efx_enable_interrupts() local
1047 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1048 if (channel->type->keep_eventq) { in efx_enable_interrupts()
1049 rc = efx_init_eventq(channel); in efx_enable_interrupts()
1062 end_channel = channel; in efx_enable_interrupts()
1063 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1064 if (channel == end_channel) in efx_enable_interrupts()
1066 if (channel->type->keep_eventq) in efx_enable_interrupts()
1067 efx_fini_eventq(channel); in efx_enable_interrupts()
1077 struct efx_channel *channel; in efx_disable_interrupts() local
1081 efx_for_each_channel(channel, efx) { in efx_disable_interrupts()
1082 if (channel->type->keep_eventq) in efx_disable_interrupts()
1083 efx_fini_eventq(channel); in efx_disable_interrupts()
1093 struct efx_channel *channel; in efx_start_channels() local
1095 efx_for_each_channel_rev(channel, efx) { in efx_start_channels()
1096 if (channel->type->start) in efx_start_channels()
1097 channel->type->start(channel); in efx_start_channels()
1098 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_start_channels()
1103 efx_for_each_channel_rx_queue(rx_queue, channel) { in efx_start_channels()
1106 efx_stop_eventq(channel); in efx_start_channels()
1108 efx_start_eventq(channel); in efx_start_channels()
1111 WARN_ON(channel->rx_pkt_n_frags); in efx_start_channels()
1119 struct efx_channel *channel; in efx_stop_channels() local
1123 * The channel's stop has to be called first, since it might wait in efx_stop_channels()
1124 * for a sentinel RX to indicate the channel has fully drained. in efx_stop_channels()
1126 efx_for_each_channel(channel, efx) { in efx_stop_channels()
1127 if (channel->type->stop) in efx_stop_channels()
1128 channel->type->stop(channel); in efx_stop_channels()
1129 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_stop_channels()
1133 efx_for_each_channel(channel, efx) { in efx_stop_channels()
1140 if (efx_channel_has_rx_queue(channel)) { in efx_stop_channels()
1141 efx_stop_eventq(channel); in efx_stop_channels()
1142 efx_start_eventq(channel); in efx_stop_channels()
1156 efx_for_each_channel(channel, efx) { in efx_stop_channels()
1157 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_stop_channels()
1159 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_stop_channels()
1170 /* Process channel's event queue
1173 * single channel. The caller must guarantee that this function will
1174 * never be concurrently called more than once on the same channel,
1177 static int efx_process_channel(struct efx_channel *channel, int budget) in efx_process_channel() argument
1183 if (unlikely(!channel->enabled)) in efx_process_channel()
1187 EFX_WARN_ON_PARANOID(channel->rx_list != NULL); in efx_process_channel()
1189 channel->rx_list = &rx_list; in efx_process_channel()
1191 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_process_channel()
1196 spent = efx_nic_process_eventq(channel, budget); in efx_process_channel()
1197 if (spent && efx_channel_has_rx_queue(channel)) { in efx_process_channel()
1199 efx_channel_get_rx_queue(channel); in efx_process_channel()
1201 efx_rx_flush_packet(channel); in efx_process_channel()
1206 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_process_channel()
1215 netif_receive_skb_list(channel->rx_list); in efx_process_channel()
1216 channel->rx_list = NULL; in efx_process_channel()
1221 static void efx_update_irq_mod(struct efx_nic *efx, struct efx_channel *channel) in efx_update_irq_mod() argument
1225 if (channel->irq_mod_score < irq_adapt_low_thresh) { in efx_update_irq_mod()
1226 if (channel->irq_moderation_us > step) { in efx_update_irq_mod()
1227 channel->irq_moderation_us -= step; in efx_update_irq_mod()
1228 efx->type->push_irq_moderation(channel); in efx_update_irq_mod()
1230 } else if (channel->irq_mod_score > irq_adapt_high_thresh) { in efx_update_irq_mod()
1231 if (channel->irq_moderation_us < in efx_update_irq_mod()
1233 channel->irq_moderation_us += step; in efx_update_irq_mod()
1234 efx->type->push_irq_moderation(channel); in efx_update_irq_mod()
1238 channel->irq_count = 0; in efx_update_irq_mod()
1239 channel->irq_mod_score = 0; in efx_update_irq_mod()
1249 struct efx_channel *channel = in efx_poll() local
1251 struct efx_nic *efx = channel->efx; in efx_poll()
1258 "channel %d NAPI poll executing on CPU %d\n", in efx_poll()
1259 channel->channel, raw_smp_processor_id()); in efx_poll()
1261 spent = efx_process_channel(channel, budget); in efx_poll()
1266 if (efx_channel_has_rx_queue(channel) && in efx_poll()
1268 unlikely(++channel->irq_count == 1000)) { in efx_poll()
1269 efx_update_irq_mod(efx, channel); in efx_poll()
1274 time = jiffies - channel->rfs_last_expiry; in efx_poll()
1276 if (channel->rfs_filter_count * time >= 600 * HZ) in efx_poll()
1277 mod_delayed_work(system_wq, &channel->filter_work, 0); in efx_poll()
1286 efx_nic_eventq_read_ack(channel); in efx_poll()
1292 void efx_init_napi_channel(struct efx_channel *channel) in efx_init_napi_channel() argument
1294 struct efx_nic *efx = channel->efx; in efx_init_napi_channel()
1296 channel->napi_dev = efx->net_dev; in efx_init_napi_channel()
1297 netif_napi_add(channel->napi_dev, &channel->napi_str, efx_poll); in efx_init_napi_channel()
1302 struct efx_channel *channel; in efx_init_napi() local
1304 efx_for_each_channel(channel, efx) in efx_init_napi()
1305 efx_init_napi_channel(channel); in efx_init_napi()
1308 void efx_fini_napi_channel(struct efx_channel *channel) in efx_fini_napi_channel() argument
1310 if (channel->napi_dev) in efx_fini_napi_channel()
1311 netif_napi_del(&channel->napi_str); in efx_fini_napi_channel()
1313 channel->napi_dev = NULL; in efx_fini_napi_channel()
1318 struct efx_channel *channel; in efx_fini_napi() local
1320 efx_for_each_channel(channel, efx) in efx_fini_napi()
1321 efx_fini_napi_channel(channel); in efx_fini_napi()
1328 static int efx_channel_dummy_op_int(struct efx_channel *channel) in efx_channel_dummy_op_int() argument
1333 void efx_channel_dummy_op_void(struct efx_channel *channel) in efx_channel_dummy_op_void() argument