Lines Matching full:channel
157 * We need a channel per event queue, plus a VI per tx queue. in efx_allocate_msix_channels()
274 /* Fall back to single channel MSI */ in efx_siena_probe_interrupts()
367 struct efx_channel *channel; in efx_siena_set_interrupt_affinity() local
375 efx_for_each_channel(channel, efx) { in efx_siena_set_interrupt_affinity()
379 irq_set_affinity_hint(channel->irq, cpumask_of(cpu)); in efx_siena_set_interrupt_affinity()
385 struct efx_channel *channel; in efx_siena_clear_interrupt_affinity() local
387 efx_for_each_channel(channel, efx) in efx_siena_clear_interrupt_affinity()
388 irq_set_affinity_hint(channel->irq, NULL); in efx_siena_clear_interrupt_affinity()
404 struct efx_channel *channel; in efx_siena_remove_interrupts() local
407 efx_for_each_channel(channel, efx) in efx_siena_remove_interrupts()
408 channel->irq = 0; in efx_siena_remove_interrupts()
421 * Event queue memory allocations are done only once. If the channel
423 * errors during channel reset and also simplifies interrupt handling.
425 static int efx_probe_eventq(struct efx_channel *channel) in efx_probe_eventq() argument
427 struct efx_nic *efx = channel->efx; in efx_probe_eventq()
431 "chan %d create event queue\n", channel->channel); in efx_probe_eventq()
438 channel->eventq_mask = max(entries, EFX_MIN_EVQ_SIZE) - 1; in efx_probe_eventq()
440 return efx_nic_probe_eventq(channel); in efx_probe_eventq()
443 /* Prepare channel's event queue */
444 static int efx_init_eventq(struct efx_channel *channel) in efx_init_eventq() argument
446 struct efx_nic *efx = channel->efx; in efx_init_eventq()
449 EFX_WARN_ON_PARANOID(channel->eventq_init); in efx_init_eventq()
452 "chan %d init event queue\n", channel->channel); in efx_init_eventq()
454 rc = efx_nic_init_eventq(channel); in efx_init_eventq()
456 efx->type->push_irq_moderation(channel); in efx_init_eventq()
457 channel->eventq_read_ptr = 0; in efx_init_eventq()
458 channel->eventq_init = true; in efx_init_eventq()
464 void efx_siena_start_eventq(struct efx_channel *channel) in efx_siena_start_eventq() argument
466 netif_dbg(channel->efx, ifup, channel->efx->net_dev, in efx_siena_start_eventq()
467 "chan %d start event queue\n", channel->channel); in efx_siena_start_eventq()
470 channel->enabled = true; in efx_siena_start_eventq()
473 napi_enable(&channel->napi_str); in efx_siena_start_eventq()
474 efx_nic_eventq_read_ack(channel); in efx_siena_start_eventq()
478 void efx_siena_stop_eventq(struct efx_channel *channel) in efx_siena_stop_eventq() argument
480 if (!channel->enabled) in efx_siena_stop_eventq()
483 napi_disable(&channel->napi_str); in efx_siena_stop_eventq()
484 channel->enabled = false; in efx_siena_stop_eventq()
487 static void efx_fini_eventq(struct efx_channel *channel) in efx_fini_eventq() argument
489 if (!channel->eventq_init) in efx_fini_eventq()
492 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_fini_eventq()
493 "chan %d fini event queue\n", channel->channel); in efx_fini_eventq()
495 efx_nic_fini_eventq(channel); in efx_fini_eventq()
496 channel->eventq_init = false; in efx_fini_eventq()
499 static void efx_remove_eventq(struct efx_channel *channel) in efx_remove_eventq() argument
501 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_remove_eventq()
502 "chan %d remove event queue\n", channel->channel); in efx_remove_eventq()
504 efx_nic_remove_eventq(channel); in efx_remove_eventq()
509 * Channel handling
517 struct efx_channel *channel; in efx_filter_rfs_expire() local
520 channel = container_of(dwork, struct efx_channel, filter_work); in efx_filter_rfs_expire()
521 time = jiffies - channel->rfs_last_expiry; in efx_filter_rfs_expire()
522 quota = channel->rfs_filter_count * time / (30 * HZ); in efx_filter_rfs_expire()
523 if (quota >= 20 && __efx_siena_filter_rfs_expire(channel, in efx_filter_rfs_expire()
524 min(channel->rfs_filter_count, quota))) in efx_filter_rfs_expire()
525 channel->rfs_last_expiry += time; in efx_filter_rfs_expire()
531 /* Allocate and initialise a channel structure. */
536 struct efx_channel *channel; in efx_alloc_channel() local
539 channel = kzalloc(sizeof(*channel), GFP_KERNEL); in efx_alloc_channel()
540 if (!channel) in efx_alloc_channel()
543 channel->efx = efx; in efx_alloc_channel()
544 channel->channel = i; in efx_alloc_channel()
545 channel->type = &efx_default_channel_type; in efx_alloc_channel()
548 tx_queue = &channel->tx_queue[j]; in efx_alloc_channel()
552 tx_queue->channel = channel; in efx_alloc_channel()
556 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_alloc_channel()
559 rx_queue = &channel->rx_queue; in efx_alloc_channel()
563 return channel; in efx_alloc_channel()
571 efx->channel[i] = efx_alloc_channel(efx, i); in efx_siena_init_channels()
572 if (!efx->channel[i]) in efx_siena_init_channels()
593 if (efx->channel[i]) { in efx_siena_fini_channels()
594 kfree(efx->channel[i]); in efx_siena_fini_channels()
595 efx->channel[i] = NULL; in efx_siena_fini_channels()
599 /* Allocate and initialise a channel structure, copying parameters
600 * (but not resources) from an old channel structure.
607 struct efx_channel *channel; in efx_copy_channel() local
610 channel = kmalloc(sizeof(*channel), GFP_KERNEL); in efx_copy_channel()
611 if (!channel) in efx_copy_channel()
614 *channel = *old_channel; in efx_copy_channel()
616 channel->napi_dev = NULL; in efx_copy_channel()
617 INIT_HLIST_NODE(&channel->napi_str.napi_hash_node); in efx_copy_channel()
618 channel->napi_str.napi_id = 0; in efx_copy_channel()
619 channel->napi_str.state = 0; in efx_copy_channel()
620 memset(&channel->eventq, 0, sizeof(channel->eventq)); in efx_copy_channel()
623 tx_queue = &channel->tx_queue[j]; in efx_copy_channel()
624 if (tx_queue->channel) in efx_copy_channel()
625 tx_queue->channel = channel; in efx_copy_channel()
631 rx_queue = &channel->rx_queue; in efx_copy_channel()
636 INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire); in efx_copy_channel()
639 return channel; in efx_copy_channel()
642 static int efx_probe_channel(struct efx_channel *channel) in efx_probe_channel() argument
648 netif_dbg(channel->efx, probe, channel->efx->net_dev, in efx_probe_channel()
649 "creating channel %d\n", channel->channel); in efx_probe_channel()
651 rc = channel->type->pre_probe(channel); in efx_probe_channel()
655 rc = efx_probe_eventq(channel); in efx_probe_channel()
659 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_probe_channel()
665 efx_for_each_channel_rx_queue(rx_queue, channel) { in efx_probe_channel()
671 channel->rx_list = NULL; in efx_probe_channel()
676 efx_siena_remove_channel(channel); in efx_probe_channel()
680 static void efx_get_channel_name(struct efx_channel *channel, char *buf, in efx_get_channel_name() argument
683 struct efx_nic *efx = channel->efx; in efx_get_channel_name()
687 number = channel->channel; in efx_get_channel_name()
706 struct efx_channel *channel; in efx_siena_set_channel_names() local
708 efx_for_each_channel(channel, efx) in efx_siena_set_channel_names()
709 channel->type->get_name(channel, in efx_siena_set_channel_names()
710 efx->msi_context[channel->channel].name, in efx_siena_set_channel_names()
716 struct efx_channel *channel; in efx_siena_probe_channels() local
727 efx_for_each_channel_rev(channel, efx) { in efx_siena_probe_channels()
728 rc = efx_probe_channel(channel); in efx_siena_probe_channels()
731 "failed to create channel %d\n", in efx_siena_probe_channels()
732 channel->channel); in efx_siena_probe_channels()
745 void efx_siena_remove_channel(struct efx_channel *channel) in efx_siena_remove_channel() argument
750 netif_dbg(channel->efx, drv, channel->efx->net_dev, in efx_siena_remove_channel()
751 "destroy chan %d\n", channel->channel); in efx_siena_remove_channel()
753 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_siena_remove_channel()
755 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_siena_remove_channel()
757 efx_remove_eventq(channel); in efx_siena_remove_channel()
758 channel->type->post_remove(channel); in efx_siena_remove_channel()
763 struct efx_channel *channel; in efx_siena_remove_channels() local
765 efx_for_each_channel(channel, efx) in efx_siena_remove_channels()
766 efx_siena_remove_channel(channel); in efx_siena_remove_channels()
778 "Channel %u TXQ %u is XDP %u, HW %u\n", in efx_set_xdp_tx_queue()
779 tx_queue->channel->channel, tx_queue->label, in efx_set_xdp_tx_queue()
788 struct efx_channel *channel; in efx_set_xdp_channels() local
797 efx_for_each_channel(channel, efx) { in efx_set_xdp_channels()
798 if (channel->channel < efx->tx_channel_offset) in efx_set_xdp_channels()
801 if (efx_channel_is_xdp_tx(channel)) { in efx_set_xdp_channels()
802 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_xdp_channels()
810 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_set_xdp_channels()
813 "Channel %u TXQ %u is HW %u\n", in efx_set_xdp_channels()
814 channel->channel, tx_queue->label, in efx_set_xdp_channels()
820 * first one of the channel in efx_set_xdp_channels()
825 tx_queue = &channel->tx_queue[0]; in efx_set_xdp_channels()
852 static void efx_init_napi_channel(struct efx_channel *channel);
853 static void efx_fini_napi_channel(struct efx_channel *channel);
858 struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel; in efx_siena_realloc_channels() local
870 efx_for_each_channel(channel, efx) { in efx_siena_realloc_channels()
874 if (channel->type->copy) in efx_siena_realloc_channels()
877 channel->eventq.index + in efx_siena_realloc_channels()
878 channel->eventq.entries); in efx_siena_realloc_channels()
879 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_siena_realloc_channels()
883 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_siena_realloc_channels()
896 channel = efx->channel[i]; in efx_siena_realloc_channels()
897 if (channel->type->copy) in efx_siena_realloc_channels()
898 channel = channel->type->copy(channel); in efx_siena_realloc_channels()
899 if (!channel) { in efx_siena_realloc_channels()
903 other_channel[i] = channel; in efx_siena_realloc_channels()
906 /* Swap entry counts and channel pointers */ in efx_siena_realloc_channels()
912 swap(efx->channel[i], other_channel[i]); in efx_siena_realloc_channels()
918 channel = efx->channel[i]; in efx_siena_realloc_channels()
919 if (!channel->type->copy) in efx_siena_realloc_channels()
921 rc = efx_probe_channel(channel); in efx_siena_realloc_channels()
924 efx_init_napi_channel(efx->channel[i]); in efx_siena_realloc_channels()
929 /* Destroy unused channel structures */ in efx_siena_realloc_channels()
931 channel = other_channel[i]; in efx_siena_realloc_channels()
932 if (channel && channel->type->copy) { in efx_siena_realloc_channels()
933 efx_fini_napi_channel(channel); in efx_siena_realloc_channels()
934 efx_siena_remove_channel(channel); in efx_siena_realloc_channels()
935 kfree(channel); in efx_siena_realloc_channels()
943 "unable to restart interrupts on channel reallocation\n"); in efx_siena_realloc_channels()
956 swap(efx->channel[i], other_channel[i]); in efx_siena_realloc_channels()
962 struct efx_channel *channel; in efx_siena_set_channels() local
976 efx_for_each_channel(channel, efx) { in efx_siena_set_channels()
977 if (channel->channel < efx->n_rx_channels) in efx_siena_set_channels()
978 channel->rx_queue.core_index = channel->channel; in efx_siena_set_channels()
980 channel->rx_queue.core_index = -1; in efx_siena_set_channels()
991 static bool efx_default_channel_want_txqs(struct efx_channel *channel) in efx_default_channel_want_txqs() argument
993 return channel->channel - channel->efx->tx_channel_offset < in efx_default_channel_want_txqs()
994 channel->efx->n_tx_channels; in efx_default_channel_want_txqs()
1003 struct efx_channel *channel, *end_channel; in efx_soft_enable_interrupts() local
1011 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
1012 if (!channel->type->keep_eventq) { in efx_soft_enable_interrupts()
1013 rc = efx_init_eventq(channel); in efx_soft_enable_interrupts()
1017 efx_siena_start_eventq(channel); in efx_soft_enable_interrupts()
1024 end_channel = channel; in efx_soft_enable_interrupts()
1025 efx_for_each_channel(channel, efx) { in efx_soft_enable_interrupts()
1026 if (channel == end_channel) in efx_soft_enable_interrupts()
1028 efx_siena_stop_eventq(channel); in efx_soft_enable_interrupts()
1029 if (!channel->type->keep_eventq) in efx_soft_enable_interrupts()
1030 efx_fini_eventq(channel); in efx_soft_enable_interrupts()
1038 struct efx_channel *channel; in efx_soft_disable_interrupts() local
1051 efx_for_each_channel(channel, efx) { in efx_soft_disable_interrupts()
1052 if (channel->irq) in efx_soft_disable_interrupts()
1053 synchronize_irq(channel->irq); in efx_soft_disable_interrupts()
1055 efx_siena_stop_eventq(channel); in efx_soft_disable_interrupts()
1056 if (!channel->type->keep_eventq) in efx_soft_disable_interrupts()
1057 efx_fini_eventq(channel); in efx_soft_disable_interrupts()
1066 struct efx_channel *channel, *end_channel; in efx_siena_enable_interrupts() local
1079 efx_for_each_channel(channel, efx) { in efx_siena_enable_interrupts()
1080 if (channel->type->keep_eventq) { in efx_siena_enable_interrupts()
1081 rc = efx_init_eventq(channel); in efx_siena_enable_interrupts()
1094 end_channel = channel; in efx_siena_enable_interrupts()
1095 efx_for_each_channel(channel, efx) { in efx_siena_enable_interrupts()
1096 if (channel == end_channel) in efx_siena_enable_interrupts()
1098 if (channel->type->keep_eventq) in efx_siena_enable_interrupts()
1099 efx_fini_eventq(channel); in efx_siena_enable_interrupts()
1109 struct efx_channel *channel; in efx_siena_disable_interrupts() local
1113 efx_for_each_channel(channel, efx) { in efx_siena_disable_interrupts()
1114 if (channel->type->keep_eventq) in efx_siena_disable_interrupts()
1115 efx_fini_eventq(channel); in efx_siena_disable_interrupts()
1125 struct efx_channel *channel; in efx_siena_start_channels() local
1127 efx_for_each_channel_rev(channel, efx) { in efx_siena_start_channels()
1128 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_siena_start_channels()
1133 efx_for_each_channel_rx_queue(rx_queue, channel) { in efx_siena_start_channels()
1136 efx_siena_stop_eventq(channel); in efx_siena_start_channels()
1138 efx_siena_start_eventq(channel); in efx_siena_start_channels()
1141 WARN_ON(channel->rx_pkt_n_frags); in efx_siena_start_channels()
1149 struct efx_channel *channel; in efx_siena_stop_channels() local
1153 efx_for_each_channel(channel, efx) { in efx_siena_stop_channels()
1154 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_siena_stop_channels()
1158 efx_for_each_channel(channel, efx) { in efx_siena_stop_channels()
1165 if (efx_channel_has_rx_queue(channel)) { in efx_siena_stop_channels()
1166 efx_siena_stop_eventq(channel); in efx_siena_stop_channels()
1167 efx_siena_start_eventq(channel); in efx_siena_stop_channels()
1181 efx_for_each_channel(channel, efx) { in efx_siena_stop_channels()
1182 efx_for_each_channel_rx_queue(rx_queue, channel) in efx_siena_stop_channels()
1184 efx_for_each_channel_tx_queue(tx_queue, channel) in efx_siena_stop_channels()
1195 /* Process channel's event queue
1198 * single channel. The caller must guarantee that this function will
1199 * never be concurrently called more than once on the same channel,
1202 static int efx_process_channel(struct efx_channel *channel, int budget) in efx_process_channel() argument
1208 if (unlikely(!channel->enabled)) in efx_process_channel()
1212 EFX_WARN_ON_PARANOID(channel->rx_list != NULL); in efx_process_channel()
1214 channel->rx_list = &rx_list; in efx_process_channel()
1216 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_process_channel()
1221 spent = efx_nic_process_eventq(channel, budget); in efx_process_channel()
1222 if (spent && efx_channel_has_rx_queue(channel)) { in efx_process_channel()
1224 efx_channel_get_rx_queue(channel); in efx_process_channel()
1226 efx_rx_flush_packet(channel); in efx_process_channel()
1231 efx_for_each_channel_tx_queue(tx_queue, channel) { in efx_process_channel()
1240 netif_receive_skb_list(channel->rx_list); in efx_process_channel()
1241 channel->rx_list = NULL; in efx_process_channel()
1246 static void efx_update_irq_mod(struct efx_nic *efx, struct efx_channel *channel) in efx_update_irq_mod() argument
1250 if (channel->irq_mod_score < irq_adapt_low_thresh) { in efx_update_irq_mod()
1251 if (channel->irq_moderation_us > step) { in efx_update_irq_mod()
1252 channel->irq_moderation_us -= step; in efx_update_irq_mod()
1253 efx->type->push_irq_moderation(channel); in efx_update_irq_mod()
1255 } else if (channel->irq_mod_score > irq_adapt_high_thresh) { in efx_update_irq_mod()
1256 if (channel->irq_moderation_us < in efx_update_irq_mod()
1258 channel->irq_moderation_us += step; in efx_update_irq_mod()
1259 efx->type->push_irq_moderation(channel); in efx_update_irq_mod()
1263 channel->irq_count = 0; in efx_update_irq_mod()
1264 channel->irq_mod_score = 0; in efx_update_irq_mod()
1274 struct efx_channel *channel = in efx_poll() local
1276 struct efx_nic *efx = channel->efx; in efx_poll()
1283 "channel %d NAPI poll executing on CPU %d\n", in efx_poll()
1284 channel->channel, raw_smp_processor_id()); in efx_poll()
1286 spent = efx_process_channel(channel, budget); in efx_poll()
1291 if (efx_channel_has_rx_queue(channel) && in efx_poll()
1293 unlikely(++channel->irq_count == 1000)) { in efx_poll()
1294 efx_update_irq_mod(efx, channel); in efx_poll()
1299 time = jiffies - channel->rfs_last_expiry; in efx_poll()
1301 if (channel->rfs_filter_count * time >= 600 * HZ) in efx_poll()
1302 mod_delayed_work(system_wq, &channel->filter_work, 0); in efx_poll()
1311 efx_nic_eventq_read_ack(channel); in efx_poll()
1317 static void efx_init_napi_channel(struct efx_channel *channel) in efx_init_napi_channel() argument
1319 struct efx_nic *efx = channel->efx; in efx_init_napi_channel()
1321 channel->napi_dev = efx->net_dev; in efx_init_napi_channel()
1322 netif_napi_add(channel->napi_dev, &channel->napi_str, efx_poll); in efx_init_napi_channel()
1327 struct efx_channel *channel; in efx_siena_init_napi() local
1329 efx_for_each_channel(channel, efx) in efx_siena_init_napi()
1330 efx_init_napi_channel(channel); in efx_siena_init_napi()
1333 static void efx_fini_napi_channel(struct efx_channel *channel) in efx_fini_napi_channel() argument
1335 if (channel->napi_dev) in efx_fini_napi_channel()
1336 netif_napi_del(&channel->napi_str); in efx_fini_napi_channel()
1338 channel->napi_dev = NULL; in efx_fini_napi_channel()
1343 struct efx_channel *channel; in efx_siena_fini_napi() local
1345 efx_for_each_channel(channel, efx) in efx_siena_fini_napi()
1346 efx_fini_napi_channel(channel); in efx_siena_fini_napi()
1353 static int efx_channel_dummy_op_int(struct efx_channel *channel) in efx_channel_dummy_op_int() argument
1358 void efx_siena_channel_dummy_op_void(struct efx_channel *channel) in efx_siena_channel_dummy_op_void() argument