Lines Matching defs:channel
115 /* This is the weight assigned to each of the (per-channel) virtual
196 static void ef4_remove_channel(struct ef4_channel *channel);
200 static void ef4_init_napi_channel(struct ef4_channel *channel);
202 static void ef4_fini_napi_channel(struct ef4_channel *channel);
231 /* Process channel's event queue
234 * single channel. The caller must guarantee that this function will
235 * never be concurrently called more than once on the same channel,
238 static int ef4_process_channel(struct ef4_channel *channel, int budget)
243 if (unlikely(!channel->enabled))
246 ef4_for_each_channel_tx_queue(tx_queue, channel) {
251 spent = ef4_nic_process_eventq(channel, budget);
252 if (spent && ef4_channel_has_rx_queue(channel)) {
254 ef4_channel_get_rx_queue(channel);
256 ef4_rx_flush_packet(channel);
261 ef4_for_each_channel_tx_queue(tx_queue, channel) {
276 static void ef4_update_irq_mod(struct ef4_nic *efx, struct ef4_channel *channel)
280 if (channel->irq_mod_score < irq_adapt_low_thresh) {
281 if (channel->irq_moderation_us > step) {
282 channel->irq_moderation_us -= step;
283 efx->type->push_irq_moderation(channel);
285 } else if (channel->irq_mod_score > irq_adapt_high_thresh) {
286 if (channel->irq_moderation_us <
288 channel->irq_moderation_us += step;
289 efx->type->push_irq_moderation(channel);
293 channel->irq_count = 0;
294 channel->irq_mod_score = 0;
299 struct ef4_channel *channel =
301 struct ef4_nic *efx = channel->efx;
305 "channel %d NAPI poll executing on CPU %d\n",
306 channel->channel, raw_smp_processor_id());
308 spent = ef4_process_channel(channel, budget);
311 if (ef4_channel_has_rx_queue(channel) &&
313 unlikely(++channel->irq_count == 1000)) {
314 ef4_update_irq_mod(efx, channel);
317 ef4_filter_rfs_expire(channel);
325 ef4_nic_eventq_read_ack(channel);
332 * Event queue memory allocations are done only once. If the channel
334 * errors during channel reset and also simplifies interrupt handling.
336 static int ef4_probe_eventq(struct ef4_channel *channel)
338 struct ef4_nic *efx = channel->efx;
342 "chan %d create event queue\n", channel->channel);
348 channel->eventq_mask = max(entries, EF4_MIN_EVQ_SIZE) - 1;
350 return ef4_nic_probe_eventq(channel);
353 /* Prepare channel's event queue */
354 static int ef4_init_eventq(struct ef4_channel *channel)
356 struct ef4_nic *efx = channel->efx;
359 EF4_WARN_ON_PARANOID(channel->eventq_init);
362 "chan %d init event queue\n", channel->channel);
364 rc = ef4_nic_init_eventq(channel);
366 efx->type->push_irq_moderation(channel);
367 channel->eventq_read_ptr = 0;
368 channel->eventq_init = true;
374 void ef4_start_eventq(struct ef4_channel *channel)
376 netif_dbg(channel->efx, ifup, channel->efx->net_dev,
377 "chan %d start event queue\n", channel->channel);
380 channel->enabled = true;
383 napi_enable(&channel->napi_str);
384 ef4_nic_eventq_read_ack(channel);
388 void ef4_stop_eventq(struct ef4_channel *channel)
390 if (!channel->enabled)
393 napi_disable(&channel->napi_str);
394 channel->enabled = false;
397 static void ef4_fini_eventq(struct ef4_channel *channel)
399 if (!channel->eventq_init)
402 netif_dbg(channel->efx, drv, channel->efx->net_dev,
403 "chan %d fini event queue\n", channel->channel);
405 ef4_nic_fini_eventq(channel);
406 channel->eventq_init = false;
409 static void ef4_remove_eventq(struct ef4_channel *channel)
411 netif_dbg(channel->efx, drv, channel->efx->net_dev,
412 "chan %d remove event queue\n", channel->channel);
414 ef4_nic_remove_eventq(channel);
423 /* Allocate and initialise a channel structure. */
427 struct ef4_channel *channel;
432 channel = kzalloc(sizeof(*channel), GFP_KERNEL);
433 if (!channel)
436 channel->efx = efx;
437 channel->channel = i;
438 channel->type = &ef4_default_channel_type;
441 tx_queue = &channel->tx_queue[j];
444 tx_queue->channel = channel;
447 rx_queue = &channel->rx_queue;
451 return channel;
454 /* Allocate and initialise a channel structure, copying parameters
455 * (but not resources) from an old channel structure.
460 struct ef4_channel *channel;
465 channel = kmalloc(sizeof(*channel), GFP_KERNEL);
466 if (!channel)
469 *channel = *old_channel;
471 channel->napi_dev = NULL;
472 INIT_HLIST_NODE(&channel->napi_str.napi_hash_node);
473 channel->napi_str.napi_id = 0;
474 channel->napi_str.state = 0;
475 memset(&channel->eventq, 0, sizeof(channel->eventq));
478 tx_queue = &channel->tx_queue[j];
479 if (tx_queue->channel)
480 tx_queue->channel = channel;
485 rx_queue = &channel->rx_queue;
490 return channel;
493 static int ef4_probe_channel(struct ef4_channel *channel)
499 netif_dbg(channel->efx, probe, channel->efx->net_dev,
500 "creating channel %d\n", channel->channel);
502 rc = channel->type->pre_probe(channel);
506 rc = ef4_probe_eventq(channel);
510 ef4_for_each_channel_tx_queue(tx_queue, channel) {
516 ef4_for_each_channel_rx_queue(rx_queue, channel) {
525 ef4_remove_channel(channel);
530 ef4_get_channel_name(struct ef4_channel *channel, char *buf, size_t len)
532 struct ef4_nic *efx = channel->efx;
536 number = channel->channel;
539 } else if (channel->channel < efx->tx_channel_offset) {
550 struct ef4_channel *channel;
552 ef4_for_each_channel(channel, efx)
553 channel->type->get_name(channel,
554 efx->msi_context[channel->channel].name,
560 struct ef4_channel *channel;
571 ef4_for_each_channel_rev(channel, efx) {
572 rc = ef4_probe_channel(channel);
575 "failed to create channel %d\n",
576 channel->channel);
599 struct ef4_channel *channel;
664 ef4_for_each_channel(channel, efx) {
665 ef4_for_each_channel_tx_queue(tx_queue, channel) {
670 ef4_for_each_channel_rx_queue(rx_queue, channel) {
673 ef4_stop_eventq(channel);
675 ef4_start_eventq(channel);
678 WARN_ON(channel->rx_pkt_n_frags);
687 struct ef4_channel *channel;
696 ef4_for_each_channel(channel, efx) {
697 ef4_for_each_channel_rx_queue(rx_queue, channel)
701 ef4_for_each_channel(channel, efx) {
708 if (ef4_channel_has_rx_queue(channel)) {
709 ef4_stop_eventq(channel);
710 ef4_start_eventq(channel);
731 ef4_for_each_channel(channel, efx) {
732 ef4_for_each_channel_rx_queue(rx_queue, channel)
734 ef4_for_each_possible_channel_tx_queue(tx_queue, channel)
739 static void ef4_remove_channel(struct ef4_channel *channel)
744 netif_dbg(channel->efx, drv, channel->efx->net_dev,
745 "destroy chan %d\n", channel->channel);
747 ef4_for_each_channel_rx_queue(rx_queue, channel)
749 ef4_for_each_possible_channel_tx_queue(tx_queue, channel)
751 ef4_remove_eventq(channel);
752 channel->type->post_remove(channel);
757 struct ef4_channel *channel;
759 ef4_for_each_channel(channel, efx)
760 ef4_remove_channel(channel);
766 struct ef4_channel *other_channel[EF4_MAX_CHANNELS], *channel;
778 ef4_for_each_channel(channel, efx) {
782 if (channel->type->copy)
785 channel->eventq.index +
786 channel->eventq.entries);
787 ef4_for_each_channel_rx_queue(rx_queue, channel)
791 ef4_for_each_channel_tx_queue(tx_queue, channel)
804 channel = efx->channel[i];
805 if (channel->type->copy)
806 channel = channel->type->copy(channel);
807 if (!channel) {
811 other_channel[i] = channel;
814 /* Swap entry counts and channel pointers */
820 channel = efx->channel[i];
821 efx->channel[i] = other_channel[i];
822 other_channel[i] = channel;
829 channel = efx->channel[i];
830 if (!channel->type->copy)
832 rc = ef4_probe_channel(channel);
835 ef4_init_napi_channel(efx->channel[i]);
839 /* Destroy unused channel structures */
841 channel = other_channel[i];
842 if (channel && channel->type->copy) {
843 ef4_fini_napi_channel(channel);
844 ef4_remove_channel(channel);
845 kfree(channel);
853 "unable to restart interrupts on channel reallocation\n");
866 channel = efx->channel[i];
867 efx->channel[i] = other_channel[i];
868 other_channel[i] = channel;
886 int ef4_channel_dummy_op_int(struct ef4_channel *channel)
891 void ef4_channel_dummy_op_void(struct ef4_channel *channel)
1389 /* Fall back to single channel MSI */
1469 struct ef4_channel *channel, *end_channel;
1477 ef4_for_each_channel(channel, efx) {
1478 if (!channel->type->keep_eventq) {
1479 rc = ef4_init_eventq(channel);
1483 ef4_start_eventq(channel);
1488 end_channel = channel;
1489 ef4_for_each_channel(channel, efx) {
1490 if (channel == end_channel)
1492 ef4_stop_eventq(channel);
1493 if (!channel->type->keep_eventq)
1494 ef4_fini_eventq(channel);
1502 struct ef4_channel *channel;
1513 ef4_for_each_channel(channel, efx) {
1514 if (channel->irq)
1515 synchronize_irq(channel->irq);
1517 ef4_stop_eventq(channel);
1518 if (!channel->type->keep_eventq)
1519 ef4_fini_eventq(channel);
1525 struct ef4_channel *channel, *end_channel;
1537 ef4_for_each_channel(channel, efx) {
1538 if (channel->type->keep_eventq) {
1539 rc = ef4_init_eventq(channel);
1552 end_channel = channel;
1553 ef4_for_each_channel(channel, efx) {
1554 if (channel == end_channel)
1556 if (channel->type->keep_eventq)
1557 ef4_fini_eventq(channel);
1567 struct ef4_channel *channel;
1571 ef4_for_each_channel(channel, efx) {
1572 if (channel->type->keep_eventq)
1573 ef4_fini_eventq(channel);
1581 struct ef4_channel *channel;
1584 ef4_for_each_channel(channel, efx)
1585 channel->irq = 0;
1595 struct ef4_channel *channel;
1606 ef4_for_each_channel(channel, efx) {
1607 if (channel->channel < efx->n_rx_channels)
1608 channel->rx_queue.core_index = channel->channel;
1610 channel->rx_queue.core_index = -1;
1612 ef4_for_each_channel_tx_queue(tx_queue, channel)
1702 struct ef4_channel *channel;
1705 ef4_for_each_channel(channel, efx) {
1706 channel->rps_flow_id =
1708 sizeof(*channel->rps_flow_id),
1710 if (!channel->rps_flow_id)
1716 channel->rps_flow_id[i] =
1721 ef4_for_each_channel(channel, efx)
1722 kfree(channel->rps_flow_id);
1740 struct ef4_channel *channel;
1742 ef4_for_each_channel(channel, efx)
1743 kfree(channel->rps_flow_id);
1912 struct ef4_channel *channel;
1931 ef4_for_each_channel(channel, efx) {
1932 if (ef4_channel_has_rx_queue(channel))
1933 channel->irq_moderation_us = rx_usecs;
1934 else if (ef4_channel_has_tx_queues(channel))
1935 channel->irq_moderation_us = tx_usecs;
1956 tx_channel = efx->channel[efx->tx_channel_offset];
2019 static void ef4_init_napi_channel(struct ef4_channel *channel)
2021 struct ef4_nic *efx = channel->efx;
2023 channel->napi_dev = efx->net_dev;
2024 netif_napi_add(channel->napi_dev, &channel->napi_str,
2030 struct ef4_channel *channel;
2032 ef4_for_each_channel(channel, efx)
2033 ef4_init_napi_channel(channel);
2036 static void ef4_fini_napi_channel(struct ef4_channel *channel)
2038 if (channel->napi_dev)
2039 netif_napi_del(&channel->napi_str);
2041 channel->napi_dev = NULL;
2046 struct ef4_channel *channel;
2048 ef4_for_each_channel(channel, efx)
2049 ef4_fini_napi_channel(channel);
2267 struct ef4_channel *channel;
2305 ef4_for_each_channel(channel, efx) {
2307 ef4_for_each_channel_tx_queue(tx_queue, channel)
2671 efx->channel[i] = ef4_alloc_channel(efx, i, NULL);
2672 if (!efx->channel[i])
2701 kfree(efx->channel[i]);
2714 struct ef4_channel *channel;
2716 ef4_for_each_channel(channel, efx)
2717 n_rx_nodesc_trunc += channel->n_rx_nodesc_trunc;