Lines Matching defs:channel

190 static void ef4_remove_channel(struct ef4_channel *channel);
194 static void ef4_init_napi_channel(struct ef4_channel *channel);
196 static void ef4_fini_napi_channel(struct ef4_channel *channel);
225 /* Process channel's event queue
228 * single channel. The caller must guarantee that this function will
229 * never be concurrently called more than once on the same channel,
232 static int ef4_process_channel(struct ef4_channel *channel, int budget)
237 if (unlikely(!channel->enabled))
240 ef4_for_each_channel_tx_queue(tx_queue, channel) {
245 spent = ef4_nic_process_eventq(channel, budget);
246 if (spent && ef4_channel_has_rx_queue(channel)) {
248 ef4_channel_get_rx_queue(channel);
250 ef4_rx_flush_packet(channel);
255 ef4_for_each_channel_tx_queue(tx_queue, channel) {
270 static void ef4_update_irq_mod(struct ef4_nic *efx, struct ef4_channel *channel)
274 if (channel->irq_mod_score < irq_adapt_low_thresh) {
275 if (channel->irq_moderation_us > step) {
276 channel->irq_moderation_us -= step;
277 efx->type->push_irq_moderation(channel);
279 } else if (channel->irq_mod_score > irq_adapt_high_thresh) {
280 if (channel->irq_moderation_us <
282 channel->irq_moderation_us += step;
283 efx->type->push_irq_moderation(channel);
287 channel->irq_count = 0;
288 channel->irq_mod_score = 0;
293 struct ef4_channel *channel =
295 struct ef4_nic *efx = channel->efx;
299 "channel %d NAPI poll executing on CPU %d\n",
300 channel->channel, raw_smp_processor_id());
302 spent = ef4_process_channel(channel, budget);
305 if (ef4_channel_has_rx_queue(channel) &&
307 unlikely(++channel->irq_count == 1000)) {
308 ef4_update_irq_mod(efx, channel);
311 ef4_filter_rfs_expire(channel);
319 ef4_nic_eventq_read_ack(channel);
326 * Event queue memory allocations are done only once. If the channel
328 * errors during channel reset and also simplifies interrupt handling.
330 static int ef4_probe_eventq(struct ef4_channel *channel)
332 struct ef4_nic *efx = channel->efx;
336 "chan %d create event queue\n", channel->channel);
342 channel->eventq_mask = max(entries, EF4_MIN_EVQ_SIZE) - 1;
344 return ef4_nic_probe_eventq(channel);
347 /* Prepare channel's event queue */
348 static int ef4_init_eventq(struct ef4_channel *channel)
350 struct ef4_nic *efx = channel->efx;
353 EF4_WARN_ON_PARANOID(channel->eventq_init);
356 "chan %d init event queue\n", channel->channel);
358 rc = ef4_nic_init_eventq(channel);
360 efx->type->push_irq_moderation(channel);
361 channel->eventq_read_ptr = 0;
362 channel->eventq_init = true;
368 void ef4_start_eventq(struct ef4_channel *channel)
370 netif_dbg(channel->efx, ifup, channel->efx->net_dev,
371 "chan %d start event queue\n", channel->channel);
374 channel->enabled = true;
377 napi_enable(&channel->napi_str);
378 ef4_nic_eventq_read_ack(channel);
382 void ef4_stop_eventq(struct ef4_channel *channel)
384 if (!channel->enabled)
387 napi_disable(&channel->napi_str);
388 channel->enabled = false;
391 static void ef4_fini_eventq(struct ef4_channel *channel)
393 if (!channel->eventq_init)
396 netif_dbg(channel->efx, drv, channel->efx->net_dev,
397 "chan %d fini event queue\n", channel->channel);
399 ef4_nic_fini_eventq(channel);
400 channel->eventq_init = false;
403 static void ef4_remove_eventq(struct ef4_channel *channel)
405 netif_dbg(channel->efx, drv, channel->efx->net_dev,
406 "chan %d remove event queue\n", channel->channel);
408 ef4_nic_remove_eventq(channel);
417 /* Allocate and initialise a channel structure. */
421 struct ef4_channel *channel;
426 channel = kzalloc(sizeof(*channel), GFP_KERNEL);
427 if (!channel)
430 channel->efx = efx;
431 channel->channel = i;
432 channel->type = &ef4_default_channel_type;
435 tx_queue = &channel->tx_queue[j];
438 tx_queue->channel = channel;
441 rx_queue = &channel->rx_queue;
445 return channel;
448 /* Allocate and initialise a channel structure, copying parameters
449 * (but not resources) from an old channel structure.
454 struct ef4_channel *channel;
459 channel = kmalloc(sizeof(*channel), GFP_KERNEL);
460 if (!channel)
463 *channel = *old_channel;
465 channel->napi_dev = NULL;
466 INIT_HLIST_NODE(&channel->napi_str.napi_hash_node);
467 channel->napi_str.napi_id = 0;
468 channel->napi_str.state = 0;
469 memset(&channel->eventq, 0, sizeof(channel->eventq));
472 tx_queue = &channel->tx_queue[j];
473 if (tx_queue->channel)
474 tx_queue->channel = channel;
479 rx_queue = &channel->rx_queue;
484 return channel;
487 static int ef4_probe_channel(struct ef4_channel *channel)
493 netif_dbg(channel->efx, probe, channel->efx->net_dev,
494 "creating channel %d\n", channel->channel);
496 rc = channel->type->pre_probe(channel);
500 rc = ef4_probe_eventq(channel);
504 ef4_for_each_channel_tx_queue(tx_queue, channel) {
510 ef4_for_each_channel_rx_queue(rx_queue, channel) {
519 ef4_remove_channel(channel);
524 ef4_get_channel_name(struct ef4_channel *channel, char *buf, size_t len)
526 struct ef4_nic *efx = channel->efx;
530 number = channel->channel;
533 } else if (channel->channel < efx->tx_channel_offset) {
544 struct ef4_channel *channel;
546 ef4_for_each_channel(channel, efx)
547 channel->type->get_name(channel,
548 efx->msi_context[channel->channel].name,
554 struct ef4_channel *channel;
565 ef4_for_each_channel_rev(channel, efx) {
566 rc = ef4_probe_channel(channel);
569 "failed to create channel %d\n",
570 channel->channel);
593 struct ef4_channel *channel;
658 ef4_for_each_channel(channel, efx) {
659 ef4_for_each_channel_tx_queue(tx_queue, channel) {
664 ef4_for_each_channel_rx_queue(rx_queue, channel) {
667 ef4_stop_eventq(channel);
669 ef4_start_eventq(channel);
672 WARN_ON(channel->rx_pkt_n_frags);
681 struct ef4_channel *channel;
690 ef4_for_each_channel(channel, efx) {
691 ef4_for_each_channel_rx_queue(rx_queue, channel)
695 ef4_for_each_channel(channel, efx) {
702 if (ef4_channel_has_rx_queue(channel)) {
703 ef4_stop_eventq(channel);
704 ef4_start_eventq(channel);
725 ef4_for_each_channel(channel, efx) {
726 ef4_for_each_channel_rx_queue(rx_queue, channel)
728 ef4_for_each_possible_channel_tx_queue(tx_queue, channel)
733 static void ef4_remove_channel(struct ef4_channel *channel)
738 netif_dbg(channel->efx, drv, channel->efx->net_dev,
739 "destroy chan %d\n", channel->channel);
741 ef4_for_each_channel_rx_queue(rx_queue, channel)
743 ef4_for_each_possible_channel_tx_queue(tx_queue, channel)
745 ef4_remove_eventq(channel);
746 channel->type->post_remove(channel);
751 struct ef4_channel *channel;
753 ef4_for_each_channel(channel, efx)
754 ef4_remove_channel(channel);
760 struct ef4_channel *other_channel[EF4_MAX_CHANNELS], *channel;
772 ef4_for_each_channel(channel, efx) {
776 if (channel->type->copy)
779 channel->eventq.index +
780 channel->eventq.entries);
781 ef4_for_each_channel_rx_queue(rx_queue, channel)
785 ef4_for_each_channel_tx_queue(tx_queue, channel)
798 channel = efx->channel[i];
799 if (channel->type->copy)
800 channel = channel->type->copy(channel);
801 if (!channel) {
805 other_channel[i] = channel;
808 /* Swap entry counts and channel pointers */
814 swap(efx->channel[i], other_channel[i]);
821 channel = efx->channel[i];
822 if (!channel->type->copy)
824 rc = ef4_probe_channel(channel);
827 ef4_init_napi_channel(efx->channel[i]);
831 /* Destroy unused channel structures */
833 channel = other_channel[i];
834 if (channel && channel->type->copy) {
835 ef4_fini_napi_channel(channel);
836 ef4_remove_channel(channel);
837 kfree(channel);
845 "unable to restart interrupts on channel reallocation\n");
858 swap(efx->channel[i], other_channel[i]);
876 int ef4_channel_dummy_op_int(struct ef4_channel *channel)
881 void ef4_channel_dummy_op_void(struct ef4_channel *channel)
1379 /* Fall back to single channel MSI */
1459 struct ef4_channel *channel, *end_channel;
1467 ef4_for_each_channel(channel, efx) {
1468 if (!channel->type->keep_eventq) {
1469 rc = ef4_init_eventq(channel);
1473 ef4_start_eventq(channel);
1478 end_channel = channel;
1479 ef4_for_each_channel(channel, efx) {
1480 if (channel == end_channel)
1482 ef4_stop_eventq(channel);
1483 if (!channel->type->keep_eventq)
1484 ef4_fini_eventq(channel);
1492 struct ef4_channel *channel;
1503 ef4_for_each_channel(channel, efx) {
1504 if (channel->irq)
1505 synchronize_irq(channel->irq);
1507 ef4_stop_eventq(channel);
1508 if (!channel->type->keep_eventq)
1509 ef4_fini_eventq(channel);
1515 struct ef4_channel *channel, *end_channel;
1527 ef4_for_each_channel(channel, efx) {
1528 if (channel->type->keep_eventq) {
1529 rc = ef4_init_eventq(channel);
1542 end_channel = channel;
1543 ef4_for_each_channel(channel, efx) {
1544 if (channel == end_channel)
1546 if (channel->type->keep_eventq)
1547 ef4_fini_eventq(channel);
1557 struct ef4_channel *channel;
1561 ef4_for_each_channel(channel, efx) {
1562 if (channel->type->keep_eventq)
1563 ef4_fini_eventq(channel);
1571 struct ef4_channel *channel;
1574 ef4_for_each_channel(channel, efx)
1575 channel->irq = 0;
1585 struct ef4_channel *channel;
1596 ef4_for_each_channel(channel, efx) {
1597 if (channel->channel < efx->n_rx_channels)
1598 channel->rx_queue.core_index = channel->channel;
1600 channel->rx_queue.core_index = -1;
1602 ef4_for_each_channel_tx_queue(tx_queue, channel)
1692 struct ef4_channel *channel;
1695 ef4_for_each_channel(channel, efx) {
1696 channel->rps_flow_id =
1698 sizeof(*channel->rps_flow_id),
1700 if (!channel->rps_flow_id)
1706 channel->rps_flow_id[i] =
1711 ef4_for_each_channel(channel, efx)
1712 kfree(channel->rps_flow_id);
1730 struct ef4_channel *channel;
1732 ef4_for_each_channel(channel, efx)
1733 kfree(channel->rps_flow_id);
1902 struct ef4_channel *channel;
1921 ef4_for_each_channel(channel, efx) {
1922 if (ef4_channel_has_rx_queue(channel))
1923 channel->irq_moderation_us = rx_usecs;
1924 else if (ef4_channel_has_tx_queues(channel))
1925 channel->irq_moderation_us = tx_usecs;
1946 tx_channel = efx->channel[efx->tx_channel_offset];
2009 static void ef4_init_napi_channel(struct ef4_channel *channel)
2011 struct ef4_nic *efx = channel->efx;
2013 channel->napi_dev = efx->net_dev;
2014 netif_napi_add(channel->napi_dev, &channel->napi_str, ef4_poll);
2019 struct ef4_channel *channel;
2021 ef4_for_each_channel(channel, efx)
2022 ef4_init_napi_channel(channel);
2025 static void ef4_fini_napi_channel(struct ef4_channel *channel)
2027 if (channel->napi_dev)
2028 netif_napi_del(&channel->napi_str);
2030 channel->napi_dev = NULL;
2035 struct ef4_channel *channel;
2037 ef4_for_each_channel(channel, efx)
2038 ef4_fini_napi_channel(channel);
2256 struct ef4_channel *channel;
2294 ef4_for_each_channel(channel, efx) {
2296 ef4_for_each_channel_tx_queue(tx_queue, channel)
2660 efx->channel[i] = ef4_alloc_channel(efx, i, NULL);
2661 if (!efx->channel[i])
2690 kfree(efx->channel[i]);
2703 struct ef4_channel *channel;
2705 ef4_for_each_channel(channel, efx)
2706 n_rx_nodesc_trunc += channel->n_rx_nodesc_trunc;