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()
352 struct efx_channel *channel; in efx_set_interrupt_affinity() local
355 efx_for_each_channel(channel, efx) { in efx_set_interrupt_affinity()
356 cpu = cpumask_local_spread(channel->channel, in efx_set_interrupt_affinity()
358 irq_set_affinity_hint(channel->irq, cpumask_of(cpu)); in efx_set_interrupt_affinity()
364 struct efx_channel *channel; in efx_clear_interrupt_affinity() local
366 efx_for_each_channel(channel, efx) in efx_clear_interrupt_affinity()
367 irq_set_affinity_hint(channel->irq, NULL); in efx_clear_interrupt_affinity()
383 struct efx_channel *channel; in efx_remove_interrupts() local
386 efx_for_each_channel(channel, efx) in efx_remove_interrupts()
387 channel->irq = 0; in efx_remove_interrupts()
400 * Event queue memory allocations are done only once. If the channel
402 * errors during channel reset and also simplifies interrupt handling.
404 int efx_probe_eventq(struct efx_channel *channel) in efx_probe_eventq() argument
406 struct efx_nic *efx = channel->efx; in efx_probe_eventq()
410 "chan %d create event queue\n", channel->channel); in efx_probe_eventq()
417 channel->eventq_mask = max(entries, EFX_MIN_EVQ_SIZE) - 1; in efx_probe_eventq()
419 return efx_nic_probe_eventq(channel); in efx_probe_eventq()
422 /* Prepare channel's event queue */
423 int efx_init_eventq(struct efx_channel *channel) in efx_init_eventq() argument
425 struct efx_nic *efx = channel->efx; in efx_init_eventq()
428 EFX_WARN_ON_PARANOID(channel->eventq_init); in efx_init_eventq()
431 "chan %d init event queue\n", channel->channel); in efx_init_eventq()
433 rc = efx_nic_init_eventq(channel); in efx_init_eventq()
435 efx->type->push_irq_moderation(channel); in efx_init_eventq()
436 channel->eventq_read_ptr = 0; in efx_init_eventq()
437 channel->eventq_init = true; in efx_init_eventq()
443 void efx_start_eventq(struct efx_channel *channel) in efx_start_eventq() argument
445 netif_dbg(channel->efx, ifup, channel->efx->net_dev, in efx_start_eventq()
446 "chan %d start event queue\n", channel->channel); in efx_start_eventq()
449 channel->enabled = true; in efx_start_eventq()
452 napi_enable(&channel->napi_str); in efx_start_eventq()
453 efx_nic_eventq_read_ack(channel); in efx_start_eventq()
457 void efx_stop_eventq(struct efx_channel *channel) in efx_stop_eventq() argument
459 if (!channel->enabled) in efx_stop_eventq()
462 napi_disable(&channel->napi_str); in efx_stop_eventq()
463 channel->enabled = false; in efx_stop_eventq()
466 void efx_fini_eventq(struct efx_channel *channel) in efx_fini_eventq() argument
468 if (!channel->eventq_init) in efx_fini_eventq()
471 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_fini_eventq()
472 "chan %d fini event queue\n", channel->channel); in efx_fini_eventq()
474 efx_nic_fini_eventq(channel); in efx_fini_eventq()
475 channel->eventq_init = false; in efx_fini_eventq()
478 void efx_remove_eventq(struct efx_channel *channel) in efx_remove_eventq() argument
480 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_eventq()
481 "chan %d remove event queue\n", channel->channel); in efx_remove_eventq()
483 efx_nic_remove_eventq(channel); in efx_remove_eventq()
488 * Channel handling
496 struct efx_channel *channel; in efx_filter_rfs_expire() local
499 channel = container_of(dwork, struct efx_channel, filter_work); in efx_filter_rfs_expire()
500 time = jiffies - channel->rfs_last_expiry; in efx_filter_rfs_expire()
501 quota = channel->rfs_filter_count * time / (30 * HZ); in efx_filter_rfs_expire()
502 if (quota >= 20 && __efx_filter_rfs_expire(channel, min(channel->rfs_filter_count, quota))) in efx_filter_rfs_expire()
503 channel->rfs_last_expiry += time; in efx_filter_rfs_expire()
509 /* Allocate and initialise a channel structure. */
514 struct efx_channel *channel; in efx_alloc_channel() local
517 channel = kzalloc(sizeof(*channel), GFP_KERNEL); in efx_alloc_channel()
518 if (!channel) in efx_alloc_channel()
521 channel->efx = efx; in efx_alloc_channel()
522 channel->channel = i; in efx_alloc_channel()
523 channel->type = &efx_default_channel_type; in efx_alloc_channel()
526 tx_queue = &channel->tx_queue[j]; in efx_alloc_channel()
530 tx_queue->channel = channel; in efx_alloc_channel()
534 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_alloc_channel()
537 rx_queue = &channel->rx_queue; in efx_alloc_channel()
541 return channel; in efx_alloc_channel()
549 efx->channel[i] = efx_alloc_channel(efx, i); in efx_init_channels()
550 if (!efx->channel[i]) in efx_init_channels()
571 if (efx->channel[i]) { in efx_fini_channels()
572 kfree(efx->channel[i]); in efx_fini_channels()
573 efx->channel[i] = NULL; in efx_fini_channels()
577 /* Allocate and initialise a channel structure, copying parameters
578 * (but not resources) from an old channel structure.
584 struct efx_channel *channel; in efx_copy_channel() local
587 channel = kmalloc(sizeof(*channel), GFP_KERNEL); in efx_copy_channel()
588 if (!channel) in efx_copy_channel()
591 *channel = *old_channel; in efx_copy_channel()
593 channel->napi_dev = NULL; in efx_copy_channel()
594 INIT_HLIST_NODE(&channel->napi_str.napi_hash_node); in efx_copy_channel()
595 channel->napi_str.napi_id = 0; in efx_copy_channel()
596 channel->napi_str.state = 0; in efx_copy_channel()
597 memset(&channel->eventq, 0, sizeof(channel->eventq)); in efx_copy_channel()
600 tx_queue = &channel->tx_queue[j]; in efx_copy_channel()
601 if (tx_queue->channel) in efx_copy_channel()
602 tx_queue->channel = channel; in efx_copy_channel()
608 rx_queue = &channel->rx_queue; in efx_copy_channel()
613 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_copy_channel()
616 return channel; in efx_copy_channel()
619 static int efx_probe_channel(struct efx_channel *channel) in efx_probe_channel() argument
625 netif_dbg(channel->efx, probe, channel->efx->net_dev, in efx_probe_channel()
626 "creating channel %d\n", channel->channel); in efx_probe_channel()
628 rc = channel->type->pre_probe(channel); in efx_probe_channel()
632 rc = efx_probe_eventq(channel); in efx_probe_channel()
636 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_probe_channel()
642 efx_for_each_channel_rx_queue(rx_queue, channel) { in efx_probe_channel()
648 channel->rx_list = NULL; in efx_probe_channel()
653 efx_remove_channel(channel); in efx_probe_channel()
657 void efx_get_channel_name(struct efx_channel *channel, char *buf, size_t len) in efx_get_channel_name() argument
659 struct efx_nic *efx = channel->efx; in efx_get_channel_name()
663 number = channel->channel; in efx_get_channel_name()
682 struct efx_channel *channel; in efx_set_channel_names() local
684 efx_for_each_channel(channel, efx) in efx_set_channel_names()
685 channel->type->get_name(channel, in efx_set_channel_names()
686 efx->msi_context[channel->channel].name, in efx_set_channel_names()
692 struct efx_channel *channel; in efx_probe_channels() local
703 efx_for_each_channel_rev(channel, efx) { in efx_probe_channels()
704 rc = efx_probe_channel(channel); in efx_probe_channels()
707 "failed to create channel %d\n", in efx_probe_channels()
708 channel->channel); in efx_probe_channels()
721 void efx_remove_channel(struct efx_channel *channel) in efx_remove_channel() argument
726 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_channel()
727 "destroy chan %d\n", channel->channel); in efx_remove_channel()
729 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_remove_channel()
731 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_remove_channel()
733 efx_remove_eventq(channel); in efx_remove_channel()
734 channel->type->post_remove(channel); in efx_remove_channel()
739 struct efx_channel *channel; in efx_remove_channels() local
741 efx_for_each_channel(channel, efx) in efx_remove_channels()
742 efx_remove_channel(channel); in efx_remove_channels()
749 struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel, in efx_realloc_channels() local
763 efx_for_each_channel(channel, efx) { in efx_realloc_channels()
767 if (channel->type->copy) in efx_realloc_channels()
770 channel->eventq.index + in efx_realloc_channels()
771 channel->eventq.entries); in efx_realloc_channels()
772 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_realloc_channels()
776 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_realloc_channels()
789 channel = efx->channel[i]; in efx_realloc_channels()
790 if (channel->type->copy) in efx_realloc_channels()
791 channel = channel->type->copy(channel); in efx_realloc_channels()
792 if (!channel) { in efx_realloc_channels()
796 other_channel[i] = channel; in efx_realloc_channels()
799 /* Swap entry counts and channel pointers */ in efx_realloc_channels()
805 swap(efx->channel[i], other_channel[i]); in efx_realloc_channels()
811 channel = efx->channel[i]; in efx_realloc_channels()
812 if (!channel->type->copy) in efx_realloc_channels()
814 rc = efx_probe_channel(channel); in efx_realloc_channels()
817 efx_init_napi_channel(efx->channel[i]); in efx_realloc_channels()
822 /* Destroy unused channel structures */ in efx_realloc_channels()
824 channel = other_channel[i]; in efx_realloc_channels()
825 if (channel && channel->type->copy) { in efx_realloc_channels()
826 efx_fini_napi_channel(channel); in efx_realloc_channels()
827 efx_remove_channel(channel); in efx_realloc_channels()
828 kfree(channel); in efx_realloc_channels()
837 "unable to restart interrupts on channel reallocation\n"); in efx_realloc_channels()
850 swap(efx->channel[i], other_channel[i]); in efx_realloc_channels()
858 struct efx_channel *channel; in efx_set_channels() local
879 efx_for_each_channel(channel, efx) { in efx_set_channels()
880 if (channel->channel < efx->n_rx_channels) in efx_set_channels()
881 channel->rx_queue.core_index = channel->channel; in efx_set_channels()
883 channel->rx_queue.core_index = -1; in efx_set_channels()
885 if (channel->channel >= efx->tx_channel_offset) { in efx_set_channels()
886 if (efx_channel_is_xdp_tx(channel)) { in efx_set_channels()
887 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_channels()
897 netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n", in efx_set_channels()
898 channel->channel, tx_queue->label, in efx_set_channels()
905 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_channels()
907 netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is HW %u\n", in efx_set_channels()
908 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()