/* This is the first interrupt mode to try out of: *0=>MSI-X *1=>MSI *2=>legacy
*/ unsignedint efx_siena_interrupt_mode = EFX_INT_MODE_MSIX;
/* This is the requested number of CPUs to use for Receive-Side Scaling (RSS), *i.e.thenumberofCPUsamongwhichwemaydistributesimultaneous *interrupthandling. * *CardswithoutMSI-XwillonlytargetoneCPUvialegacyorMSIinterrupt. *Thedefault(0)meanstoassignaninterrupttoeachcore.
*/ unsignedint efx_siena_rss_cpus;
if (unlikely(!zalloc_cpumask_var(&filter_mask, GFP_KERNEL))) {
netif_warn(efx, probe, efx->net_dev, "RSS disabled due to allocation failure\n"); return1;
}
cpumask_copy(filter_mask, cpu_online_mask); if (local_node)
cpumask_and(filter_mask, filter_mask,
cpumask_of_pcibus(efx->pci_dev->bus));
/* If no online CPUs in local node, fallback to any online CPUs */ if (count == 0)
count = count_online_cores(efx, false);
}
if (count > EFX_MAX_RX_QUEUES) {
netif_cond_dbg(efx, probe, efx->net_dev, !efx_siena_rss_cpus,
warn, "Reducing number of rx queues from %u to %u.\n",
count, EFX_MAX_RX_QUEUES);
count = EFX_MAX_RX_QUEUES;
}
/* If RSS is requested for the PF *and* VFs then we can't write RSS *tableentriesthatareinaccessibletoVFs
*/ #ifdef CONFIG_SFC_SIENA_SRIOV if (efx->type->sriov_wanted) { if (efx->type->sriov_wanted(efx) && efx_vf_size(efx) > 1 &&
count > efx_vf_size(efx)) {
netif_warn(efx, probe, efx->net_dev, "Reducing number of RSS channels from %u to %u for " "VF support. Increase vf-msix-limit to use more " "channels on the PF.\n",
count, efx_vf_size(efx));
count = efx_vf_size(efx);
}
} #endif
return count;
}
staticint efx_allocate_msix_channels(struct efx_nic *efx, unsignedint max_channels, unsignedint extra_channels, unsignedint parallelism)
{ unsignedint n_channels = parallelism; int vec_count; int tx_per_ev; int n_xdp_tx; int n_xdp_ev;
if (efx_siena_separate_tx_channels)
n_channels *= 2;
n_channels += extra_channels;
/* To allow XDP transmit to happen from arbitrary NAPI contexts *weallocateaTXqueueperCPU.Weshareeventqueuesacross *multipletxqueues,assumingtxandevqueuesareboth *maximumsize.
*/
tx_per_ev = EFX_MAX_EVQ_SIZE / EFX_TXQ_MAX_ENT(efx);
tx_per_ev = min(tx_per_ev, EFX_MAX_TXQ_PER_CHANNEL);
n_xdp_tx = num_possible_cpus();
n_xdp_ev = DIV_ROUND_UP(n_xdp_tx, tx_per_ev);
vec_count = pci_msix_vec_count(efx->pci_dev); if (vec_count < 0) return vec_count;
/* Probe the number and type of interrupts we are able to obtain, and *theresultingnumbersofchannelsandRXqueues.
*/ int efx_siena_probe_interrupts(struct efx_nic *efx)
{ unsignedint extra_channels = 0; unsignedint rss_spread; unsignedint i, j; int rc;
for (i = 0; i < EFX_MAX_EXTRA_CHANNELS; i++) if (efx->extra_channel_type[i])
++extra_channels;
/* Assign extra channels if possible, before XDP channels */
efx->n_extra_tx_channels = 0;
j = efx->xdp_channel_offset; for (i = 0; i < EFX_MAX_EXTRA_CHANNELS; i++) { if (!efx->extra_channel_type[i]) continue; if (j <= efx->tx_channel_offset + efx->n_tx_channels) {
efx->extra_channel_type[i]->handle_no_channel(efx);
} else {
--j;
efx_get_channel(efx, j)->type =
efx->extra_channel_type[i]; if (efx_channel_has_tx_queues(efx_get_channel(efx, j)))
efx->n_extra_tx_channels++;
}
}
rss_spread = efx->n_rx_channels; /* RSS might be usable on VFs even if it is disabled on the PF */ #ifdef CONFIG_SFC_SIENA_SRIOV if (efx->type->sriov_wanted) {
efx->rss_spread = ((rss_spread > 1 ||
!efx->type->sriov_wanted(efx)) ?
rss_spread : efx_vf_size(efx)); return0;
} #endif
efx->rss_spread = rss_spread;
/* If no online CPUs in local node, fallback to any online CPU */ if (cpumask_first_and(cpu_online_mask, numa_mask) >= nr_cpu_ids)
numa_mask = cpu_online_mask;
cpu = -1;
efx_for_each_channel(channel, efx) {
cpu = cpumask_next_and(cpu, cpu_online_mask, numa_mask); if (cpu >= nr_cpu_ids)
cpu = cpumask_first_and(cpu_online_mask, numa_mask);
irq_set_affinity_hint(channel->irq, cpumask_of(cpu));
}
}
channel = container_of(dwork, struct efx_channel, filter_work);
time = jiffies - channel->rfs_last_expiry;
quota = channel->rfs_filter_count * time / (30 * HZ); if (quota >= 20 && __efx_siena_filter_rfs_expire(channel,
min(channel->rfs_filter_count, quota)))
channel->rfs_last_expiry += time; /* Ensure we do more work eventually even if NAPI poll is not happening */
schedule_delayed_work(dwork, 30 * HZ);
} #endif
/* Allocate and initialise a channel structure. */ staticstruct efx_channel *efx_alloc_channel(struct efx_nic *efx, int i)
{ struct efx_rx_queue *rx_queue; struct efx_tx_queue *tx_queue; struct efx_channel *channel; int j;
channel = kzalloc(sizeof(*channel), GFP_KERNEL); if (!channel) return NULL;
/* We need to mark which channels really have RX and TX *queues,andadjusttheTXqueuenumbersifwehaveseparate *RX-onlyandTX-onlychannels.
*/
efx_for_each_channel(channel, efx) { if (channel->channel < efx->tx_channel_offset) continue;
/* If XDP is borrowing queues from net stack, it must *usethequeuewithnocsumoffload,whichisthe *firstoneofthechannel *(note:tx_queue_by_typeisnotinitializedyet)
*/ if (efx->xdp_txq_queues_mode ==
EFX_XDP_TX_QUEUES_BORROWED) {
tx_queue = &channel->tx_queue[0];
rc = efx_set_xdp_tx_queue(efx, xdp_queue_number,
tx_queue); if (rc == 0)
xdp_queue_number++;
}
}
}
WARN_ON(efx->xdp_txq_queues_mode == EFX_XDP_TX_QUEUES_DEDICATED &&
xdp_queue_number != efx->xdp_tx_queue_count);
WARN_ON(efx->xdp_txq_queues_mode != EFX_XDP_TX_QUEUES_DEDICATED &&
xdp_queue_number > efx->xdp_tx_queue_count);
/* If we have more CPUs than assigned XDP TX queues, assign the already *existingqueuestotheexceedingCPUs
*/
next_queue = 0; while (xdp_queue_number < efx->xdp_tx_queue_count) {
tx_queue = efx->xdp_tx_queues[next_queue++];
rc = efx_set_xdp_tx_queue(efx, xdp_queue_number, tx_queue); if (rc == 0)
xdp_queue_number++;
}
}
int efx_siena_realloc_channels(struct efx_nic *efx, u32 rxq_entries,
u32 txq_entries)
{ struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel; unsignedint i, next_buffer_table = 0;
u32 old_rxq_entries, old_txq_entries; int rc, rc2;
rc = efx_check_disabled(efx); if (rc) return rc;
/* Not all channels should be reallocated. We must avoid *reallocatingtheirbuffertableentries.
*/
efx_for_each_channel(channel, efx) { struct efx_rx_queue *rx_queue; struct efx_tx_queue *tx_queue;
for (i = 0; i < efx->n_channels; i++) {
channel = efx->channel[i]; if (!channel->type->copy) continue;
rc = efx_probe_channel(channel); if (rc) goto rollback;
efx_init_napi_channel(efx->channel[i]);
}
efx_set_xdp_channels(efx);
out: /* Destroy unused channel structures */ for (i = 0; i < efx->n_channels; i++) {
channel = other_channel[i]; if (channel && channel->type->copy) {
efx_fini_napi_channel(channel);
efx_siena_remove_channel(channel);
kfree(channel);
}
}
efx_for_each_channel(channel, efx) { /* RX packet processing is pipelined, so wait for the *NAPIhandlertocomplete.Atleasteventqueue0 *mightbekeptactivebynon-dataevents,sodon't *usenapi_synchronize()butactuallydisableNAPI *temporarily.
*/ if (efx_channel_has_rx_queue(channel)) {
efx_siena_stop_eventq(channel);
efx_siena_start_eventq(channel);
}
}
if (efx->type->fini_dmaq)
rc = efx->type->fini_dmaq(efx);
if (rc) {
netif_err(efx, drv, efx->net_dev, "failed to flush queues\n");
} else {
netif_dbg(efx, drv, efx->net_dev, "successfully flushed all queues\n");
}
netif_vdbg(efx, intr, efx->net_dev, "channel %d NAPI poll executing on CPU %d\n",
channel->channel, raw_smp_processor_id());
spent = efx_process_channel(channel, budget);
if (budget)
xdp_do_flush();
if (spent < budget) { if (efx_channel_has_rx_queue(channel) &&
efx->irq_rx_adaptive &&
unlikely(++channel->irq_count == 1000)) {
efx_update_irq_mod(efx, channel);
}
#ifdef CONFIG_RFS_ACCEL /* Perhaps expire some ARFS filters */
time = jiffies - channel->rfs_last_expiry; /* Would our quota be >= 20? */ if (channel->rfs_filter_count * time >= 600 * HZ)
mod_delayed_work(system_wq, &channel->filter_work, 0); #endif
/* There is no race here; although napi_disable() will *onlywaitfornapi_complete(),thisisn'taproblem *sinceefx_nic_eventq_read_ack()willhavenoeffectif *interruptshavealreadybeendisabled.
*/ if (napi_complete_done(napi, spent))
efx_nic_eventq_read_ack(channel);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.24Bemerkung:
(vorverarbeitet am 2026-10-03)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.