Lines Matching full:channel
47 /* This is the weight assigned to each of the (per-channel) virtual
56 int efx_channel_dummy_op_int(struct efx_channel *channel) in efx_channel_dummy_op_int() argument
61 void efx_channel_dummy_op_void(struct efx_channel *channel) in efx_channel_dummy_op_void() argument
163 * We need a channel per event queue, plus a VI per tx queue. in efx_allocate_msix_channels()
262 /* Fall back to single channel MSI */ in efx_probe_interrupts()
350 struct efx_channel *channel; in efx_set_interrupt_affinity() local
353 efx_for_each_channel(channel, efx) { in efx_set_interrupt_affinity()
354 cpu = cpumask_local_spread(channel->channel, in efx_set_interrupt_affinity()
356 irq_set_affinity_hint(channel->irq, cpumask_of(cpu)); in efx_set_interrupt_affinity()
362 struct efx_channel *channel; in efx_clear_interrupt_affinity() local
364 efx_for_each_channel(channel, efx) in efx_clear_interrupt_affinity()
365 irq_set_affinity_hint(channel->irq, NULL); in efx_clear_interrupt_affinity()
381 struct efx_channel *channel; in efx_remove_interrupts() local
384 efx_for_each_channel(channel, efx) in efx_remove_interrupts()
385 channel->irq = 0; in efx_remove_interrupts()
398 * Event queue memory allocations are done only once. If the channel
400 * errors during channel reset and also simplifies interrupt handling.
402 int efx_probe_eventq(struct efx_channel *channel) in efx_probe_eventq() argument
404 struct efx_nic *efx = channel->efx; in efx_probe_eventq()
408 "chan %d create event queue\n", channel->channel); in efx_probe_eventq()
415 channel->eventq_mask = max(entries, EFX_MIN_EVQ_SIZE) - 1; in efx_probe_eventq()
417 return efx_nic_probe_eventq(channel); in efx_probe_eventq()
420 /* Prepare channel's event queue */
421 int efx_init_eventq(struct efx_channel *channel) in efx_init_eventq() argument
423 struct efx_nic *efx = channel->efx; in efx_init_eventq()
426 EFX_WARN_ON_PARANOID(channel->eventq_init); in efx_init_eventq()
429 "chan %d init event queue\n", channel->channel); in efx_init_eventq()
431 rc = efx_nic_init_eventq(channel); in efx_init_eventq()
433 efx->type->push_irq_moderation(channel); in efx_init_eventq()
434 channel->eventq_read_ptr = 0; in efx_init_eventq()
435 channel->eventq_init = true; in efx_init_eventq()
441 void efx_start_eventq(struct efx_channel *channel) in efx_start_eventq() argument
443 netif_dbg(channel->efx, ifup, channel->efx->net_dev, in efx_start_eventq()
444 "chan %d start event queue\n", channel->channel); in efx_start_eventq()
447 channel->enabled = true; in efx_start_eventq()
450 napi_enable(&channel->napi_str); in efx_start_eventq()
451 efx_nic_eventq_read_ack(channel); in efx_start_eventq()
455 void efx_stop_eventq(struct efx_channel *channel) in efx_stop_eventq() argument
457 if (!channel->enabled) in efx_stop_eventq()
460 napi_disable(&channel->napi_str); in efx_stop_eventq()
461 channel->enabled = false; in efx_stop_eventq()
464 void efx_fini_eventq(struct efx_channel *channel) in efx_fini_eventq() argument
466 if (!channel->eventq_init) in efx_fini_eventq()
469 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_fini_eventq()
470 "chan %d fini event queue\n", channel->channel); in efx_fini_eventq()
472 efx_nic_fini_eventq(channel); in efx_fini_eventq()
473 channel->eventq_init = false; in efx_fini_eventq()
476 void efx_remove_eventq(struct efx_channel *channel) in efx_remove_eventq() argument
478 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_eventq()
479 "chan %d remove event queue\n", channel->channel); in efx_remove_eventq()
481 efx_nic_remove_eventq(channel); in efx_remove_eventq()
486 * Channel handling
494 struct efx_channel *channel; in efx_filter_rfs_expire() local
497 channel = container_of(dwork, struct efx_channel, filter_work); in efx_filter_rfs_expire()
498 time = jiffies - channel->rfs_last_expiry; in efx_filter_rfs_expire()
499 quota = channel->rfs_filter_count * time / (30 * HZ); in efx_filter_rfs_expire()
500 if (quota >= 20 && __efx_filter_rfs_expire(channel, min(channel->rfs_filter_count, quota))) in efx_filter_rfs_expire()
501 channel->rfs_last_expiry += time; in efx_filter_rfs_expire()
507 /* Allocate and initialise a channel structure. */
512 struct efx_channel *channel; in efx_alloc_channel() local
515 channel = kzalloc(sizeof(*channel), GFP_KERNEL); in efx_alloc_channel()
516 if (!channel) in efx_alloc_channel()
519 channel->efx = efx; in efx_alloc_channel()
520 channel->channel = i; in efx_alloc_channel()
521 channel->type = &efx_default_channel_type; in efx_alloc_channel()
524 tx_queue = &channel->tx_queue[j]; in efx_alloc_channel()
528 tx_queue->channel = channel; in efx_alloc_channel()
532 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_alloc_channel()
535 rx_queue = &channel->rx_queue; in efx_alloc_channel()
539 return channel; in efx_alloc_channel()
547 efx->channel[i] = efx_alloc_channel(efx, i); in efx_init_channels()
548 if (!efx->channel[i]) in efx_init_channels()
569 if (efx->channel[i]) { in efx_fini_channels()
570 kfree(efx->channel[i]); in efx_fini_channels()
571 efx->channel[i] = NULL; in efx_fini_channels()
575 /* Allocate and initialise a channel structure, copying parameters
576 * (but not resources) from an old channel structure.
582 struct efx_channel *channel; in efx_copy_channel() local
585 channel = kmalloc(sizeof(*channel), GFP_KERNEL); in efx_copy_channel()
586 if (!channel) in efx_copy_channel()
589 *channel = *old_channel; in efx_copy_channel()
591 channel->napi_dev = NULL; in efx_copy_channel()
592 INIT_HLIST_NODE(&channel->napi_str.napi_hash_node); in efx_copy_channel()
593 channel->napi_str.napi_id = 0; in efx_copy_channel()
594 channel->napi_str.state = 0; in efx_copy_channel()
595 memset(&channel->eventq, 0, sizeof(channel->eventq)); in efx_copy_channel()
598 tx_queue = &channel->tx_queue[j]; in efx_copy_channel()
599 if (tx_queue->channel) in efx_copy_channel()
600 tx_queue->channel = channel; in efx_copy_channel()
606 rx_queue = &channel->rx_queue; in efx_copy_channel()
611 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_copy_channel()
614 return channel; in efx_copy_channel()
617 static int efx_probe_channel(struct efx_channel *channel) in efx_probe_channel() argument
623 netif_dbg(channel->efx, probe, channel->efx->net_dev, in efx_probe_channel()
624 "creating channel %d\n", channel->channel); in efx_probe_channel()
626 rc = channel->type->pre_probe(channel); in efx_probe_channel()
630 rc = efx_probe_eventq(channel); in efx_probe_channel()
634 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_probe_channel()
640 efx_for_each_channel_rx_queue(rx_queue, channel) { in efx_probe_channel()
646 channel->rx_list = NULL; in efx_probe_channel()
651 efx_remove_channel(channel); in efx_probe_channel()
655 void efx_get_channel_name(struct efx_channel *channel, char *buf, size_t len) in efx_get_channel_name() argument
657 struct efx_nic *efx = channel->efx; in efx_get_channel_name()
661 number = channel->channel; in efx_get_channel_name()
680 struct efx_channel *channel; in efx_set_channel_names() local
682 efx_for_each_channel(channel, efx) in efx_set_channel_names()
683 channel->type->get_name(channel, in efx_set_channel_names()
684 efx->msi_context[channel->channel].name, in efx_set_channel_names()
690 struct efx_channel *channel; in efx_probe_channels() local
701 efx_for_each_channel_rev(channel, efx) { in efx_probe_channels()
702 rc = efx_probe_channel(channel); in efx_probe_channels()
705 "failed to create channel %d\n", in efx_probe_channels()
706 channel->channel); in efx_probe_channels()
719 void efx_remove_channel(struct efx_channel *channel) in efx_remove_channel() argument
724 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_channel()
725 "destroy chan %d\n", channel->channel); in efx_remove_channel()
727 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_remove_channel()
729 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_remove_channel()
731 efx_remove_eventq(channel); in efx_remove_channel()
732 channel->type->post_remove(channel); in efx_remove_channel()
737 struct efx_channel *channel; in efx_remove_channels() local
739 efx_for_each_channel(channel, efx) in efx_remove_channels()
740 efx_remove_channel(channel); in efx_remove_channels()
747 struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel; in efx_realloc_channels() local
759 efx_for_each_channel(channel, efx) { in efx_realloc_channels()
763 if (channel->type->copy) in efx_realloc_channels()
766 channel->eventq.index + in efx_realloc_channels()
767 channel->eventq.entries); in efx_realloc_channels()
768 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_realloc_channels()
772 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_realloc_channels()
785 channel = efx->channel[i]; in efx_realloc_channels()
786 if (channel->type->copy) in efx_realloc_channels()
787 channel = channel->type->copy(channel); in efx_realloc_channels()
788 if (!channel) { in efx_realloc_channels()
792 other_channel[i] = channel; in efx_realloc_channels()
795 /* Swap entry counts and channel pointers */ in efx_realloc_channels()
801 channel = efx->channel[i]; in efx_realloc_channels()
802 efx->channel[i] = other_channel[i]; in efx_realloc_channels()
803 other_channel[i] = channel; in efx_realloc_channels()
810 channel = efx->channel[i]; in efx_realloc_channels()
811 if (!channel->type->copy) in efx_realloc_channels()
813 rc = efx_probe_channel(channel); in efx_realloc_channels()
816 efx_init_napi_channel(efx->channel[i]); in efx_realloc_channels()
820 /* Destroy unused channel structures */ in efx_realloc_channels()
822 channel = other_channel[i]; in efx_realloc_channels()
823 if (channel && channel->type->copy) { in efx_realloc_channels()
824 efx_fini_napi_channel(channel); in efx_realloc_channels()
825 efx_remove_channel(channel); in efx_realloc_channels()
826 kfree(channel); in efx_realloc_channels()
834 "unable to restart interrupts on channel reallocation\n"); in efx_realloc_channels()
847 channel = efx->channel[i]; in efx_realloc_channels()
848 efx->channel[i] = other_channel[i]; in efx_realloc_channels()
849 other_channel[i] = channel; in efx_realloc_channels()
857 struct efx_channel *channel; in efx_set_channels() local
882 efx_for_each_channel(channel, efx) { in efx_set_channels()
883 if (channel->channel < efx->n_rx_channels) in efx_set_channels()
884 channel->rx_queue.core_index = channel->channel; in efx_set_channels()
886 channel->rx_queue.core_index = -1; in efx_set_channels()
888 if (channel->channel >= efx->tx_channel_offset) { in efx_set_channels()
889 if (efx_channel_is_xdp_tx(channel)) { in efx_set_channels()
890 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_channels()
892 netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n", in efx_set_channels()
893 channel->channel, tx_queue->label, in efx_set_channels()
906 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_channels()
908 netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is HW %u\n", in efx_set_channels()
909 channel->channel, tx_queue->label, in efx_set_channels()
922 bool efx_default_channel_want_txqs(struct efx_channel *channel) in efx_default_channel_want_txqs() argument
924 return channel->channel - channel->efx->tx_channel_offset < in efx_default_channel_want_txqs()
925 channel->efx->n_tx_channels; in efx_default_channel_want_txqs()
934 struct efx_channel *channel, *end_channel; in efx_soft_enable_interrupts() local
942 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
943 if (!channel->type->keep_eventq) { in efx_soft_enable_interrupts()
944 rc = efx_init_eventq(channel); in efx_soft_enable_interrupts()
948 efx_start_eventq(channel); in efx_soft_enable_interrupts()
955 end_channel = channel; in efx_soft_enable_interrupts()
956 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
957 if (channel == end_channel) in efx_soft_enable_interrupts()
959 efx_stop_eventq(channel); in efx_soft_enable_interrupts()
960 if (!channel->type->keep_eventq) in efx_soft_enable_interrupts()
961 efx_fini_eventq(channel); in efx_soft_enable_interrupts()
969 struct efx_channel *channel; in efx_soft_disable_interrupts() local
982 efx_for_each_channel(channel, efx) { in efx_soft_disable_interrupts()
983 if (channel->irq) in efx_soft_disable_interrupts()
984 synchronize_irq(channel->irq); in efx_soft_disable_interrupts()
986 efx_stop_eventq(channel); in efx_soft_disable_interrupts()
987 if (!channel->type->keep_eventq) in efx_soft_disable_interrupts()
988 efx_fini_eventq(channel); in efx_soft_disable_interrupts()
997 struct efx_channel *channel, *end_channel; in efx_enable_interrupts() local
1010 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1011 if (channel->type->keep_eventq) { in efx_enable_interrupts()
1012 rc = efx_init_eventq(channel); in efx_enable_interrupts()
1025 end_channel = channel; in efx_enable_interrupts()
1026 efx_for_each_channel(channel, efx) { in efx_enable_interrupts()
1027 if (channel == end_channel) in efx_enable_interrupts()
1029 if (channel->type->keep_eventq) in efx_enable_interrupts()
1030 efx_fini_eventq(channel); in efx_enable_interrupts()
1040 struct efx_channel *channel; in efx_disable_interrupts() local
1044 efx_for_each_channel(channel, efx) { in efx_disable_interrupts()
1045 if (channel->type->keep_eventq) in efx_disable_interrupts()
1046 efx_fini_eventq(channel); in efx_disable_interrupts()
1056 struct efx_channel *channel; in efx_start_channels() local
1058 efx_for_each_channel(channel, efx) { in efx_start_channels()
1059 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_start_channels()
1064 efx_for_each_channel_rx_queue(rx_queue, channel) { in efx_start_channels()
1067 efx_stop_eventq(channel); in efx_start_channels()
1069 efx_start_eventq(channel); in efx_start_channels()
1072 WARN_ON(channel->rx_pkt_n_frags); in efx_start_channels()
1080 struct efx_channel *channel; in efx_stop_channels() local
1084 efx_for_each_channel(channel, efx) { in efx_stop_channels()
1085 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_stop_channels()
1089 efx_for_each_channel(channel, efx) { in efx_stop_channels()
1096 if (efx_channel_has_rx_queue(channel)) { in efx_stop_channels()
1097 efx_stop_eventq(channel); in efx_stop_channels()
1098 efx_start_eventq(channel); in efx_stop_channels()
1112 efx_for_each_channel(channel, efx) { in efx_stop_channels()
1113 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_stop_channels()
1115 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_stop_channels()
1126 /* Process channel's event queue
1129 * single channel. The caller must guarantee that this function will
1130 * never be concurrently called more than once on the same channel,
1133 static int efx_process_channel(struct efx_channel *channel, int budget) in efx_process_channel() argument
1139 if (unlikely(!channel->enabled)) in efx_process_channel()
1143 EFX_WARN_ON_PARANOID(channel->rx_list != NULL); in efx_process_channel()
1145 channel->rx_list = &rx_list; in efx_process_channel()
1147 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_process_channel()
1152 spent = efx_nic_process_eventq(channel, budget); in efx_process_channel()
1153 if (spent && efx_channel_has_rx_queue(channel)) { in efx_process_channel()
1155 efx_channel_get_rx_queue(channel); in efx_process_channel()
1157 efx_rx_flush_packet(channel); in efx_process_channel()
1162 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_process_channel()
1171 netif_receive_skb_list(channel->rx_list); in efx_process_channel()
1172 channel->rx_list = NULL; in efx_process_channel()
1177 static void efx_update_irq_mod(struct efx_nic *efx, struct efx_channel *channel) in efx_update_irq_mod() argument
1181 if (channel->irq_mod_score < irq_adapt_low_thresh) { in efx_update_irq_mod()
1182 if (channel->irq_moderation_us > step) { in efx_update_irq_mod()
1183 channel->irq_moderation_us -= step; in efx_update_irq_mod()
1184 efx->type->push_irq_moderation(channel); in efx_update_irq_mod()
1186 } else if (channel->irq_mod_score > irq_adapt_high_thresh) { in efx_update_irq_mod()
1187 if (channel->irq_moderation_us < in efx_update_irq_mod()
1189 channel->irq_moderation_us += step; in efx_update_irq_mod()
1190 efx->type->push_irq_moderation(channel); in efx_update_irq_mod()
1194 channel->irq_count = 0; in efx_update_irq_mod()
1195 channel->irq_mod_score = 0; in efx_update_irq_mod()
1205 struct efx_channel *channel = in efx_poll() local
1207 struct efx_nic *efx = channel->efx; in efx_poll()
1214 "channel %d NAPI poll executing on CPU %d\n", in efx_poll()
1215 channel->channel, raw_smp_processor_id()); in efx_poll()
1217 spent = efx_process_channel(channel, budget); in efx_poll()
1222 if (efx_channel_has_rx_queue(channel) && in efx_poll()
1224 unlikely(++channel->irq_count == 1000)) { in efx_poll()
1225 efx_update_irq_mod(efx, channel); in efx_poll()
1230 time = jiffies - channel->rfs_last_expiry; in efx_poll()
1232 if (channel->rfs_filter_count * time >= 600 * HZ) in efx_poll()
1233 mod_delayed_work(system_wq, &channel->filter_work, 0); in efx_poll()
1242 efx_nic_eventq_read_ack(channel); in efx_poll()
1248 void efx_init_napi_channel(struct efx_channel *channel) in efx_init_napi_channel() argument
1250 struct efx_nic *efx = channel->efx; in efx_init_napi_channel()
1252 channel->napi_dev = efx->net_dev; in efx_init_napi_channel()
1253 netif_napi_add(channel->napi_dev, &channel->napi_str, in efx_init_napi_channel()
1259 struct efx_channel *channel; in efx_init_napi() local
1261 efx_for_each_channel(channel, efx) in efx_init_napi()
1262 efx_init_napi_channel(channel); in efx_init_napi()
1265 void efx_fini_napi_channel(struct efx_channel *channel) in efx_fini_napi_channel() argument
1267 if (channel->napi_dev) in efx_fini_napi_channel()
1268 netif_napi_del(&channel->napi_str); in efx_fini_napi_channel()
1270 channel->napi_dev = NULL; in efx_fini_napi_channel()
1275 struct efx_channel *channel; in efx_fini_napi() local
1277 efx_for_each_channel(channel, efx) in efx_fini_napi()
1278 efx_fini_napi_channel(channel); in efx_fini_napi()