Re: [PATCH net-next v3 2/3] net: dpaa2-mac: retrieve MAC statistics in one firmware command

From: Ioana Ciornei

Date: Wed Mar 18 2026 - 07:18:30 EST


On Wed, Mar 18, 2026 at 12:10:04PM +0200, Ioana Ciornei wrote:
> The latest MC firmware version added a new command to retrieve all DPMAC
> counters in a single firmware call. Use this new command, when possible,
> in dpaa2-mac as well.
>
> In order to use the dpmac_get_statistics() API, two DMA memory areas are
> used: one to transmit what counters the driver is requesting and one to
> receive the values of those counters. These memory areas are allocated
> and DMA mapped at probe time so that we don't waste time at runtime.
>
> And since we are planning to add rmon, eth-ctrl and other standard
> statistics using the same infrastructure, make the setup and cleanup
> processes as generic as possibile through the dpaa2_mac_setup_stats()
> and dpaa2_mac_clear_stats() functions.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@xxxxxxx>
> ---

(...)

> +static void dpaa2_mac_setup_stats(struct dpaa2_mac *mac,
> + struct dpaa2_mac_stats *stats,
> + size_t num_stats,
> + const struct dpmac_counter *counters)
> +{
> + struct device *dev = mac->net_dev->dev.parent;
> + size_t size_idx, size_values;
> + __le32 *cnt_idx;
> +
> + size_idx = num_stats * sizeof(__le32);
> + stats->idx_dma_mem = dma_alloc_noncoherent(dev, size_idx,
> + &stats->idx_iova,
> + DMA_TO_DEVICE,
> + GFP_KERNEL);
> + if (!stats->idx_dma_mem)
> + goto out;
> +
> + size_values = num_stats * sizeof(__le64);
> + stats->values_dma_mem = dma_alloc_noncoherent(dev, size_values,
> + &stats->values_iova,
> + DMA_FROM_DEVICE,
> + GFP_KERNEL);
> + if (!stats->values_dma_mem)
> + goto err_alloc_values;
> +
> + cnt_idx = stats->idx_dma_mem;
> + for (size_t i = 0; i < num_stats; i++)
> + *cnt_idx++ = cpu_to_le32((u32)(counters[i].id));
> +
> + dma_sync_single_for_cpu(dev, stats->idx_iova,
> + num_stats * sizeof(__le32),
> + DMA_TO_DEVICE);

This should have been dma_sync_single_for_device(). Sorry, I missed
this before submitting it.