Re: [PATCH net-next 4/4] eth: mpnic: add a NAPI depletion check
From: Daniel Zahka
Date: Mon Oct 05 2026 - 07:42:50 EST
On Fri Oct 2, 2026 at 8:53 PM EDT, Harshitha Ramamurthy wrote:
> On Thu, Oct 1, 2026 at 9:41 AM Daniel Zahka <daniel.zahka@xxxxxxxxx> wrote:
[...]
> +void mpnic_napi_depletion_check(struct mpnic_net *mpn)
>> +{
>> + int i, j, t;
>> +
>> + for (i = 0; i < mpn->num_napi; i++) {
>> + struct mpnic_napi_vector *nv = mpn->napi[i];
>> +
>> + for (t = nv->txt_count, j = 0; j < nv->rxt_count; j++, t++) {
>> + /* Check if BDs posted covers a max sized frame
>> + * + 1 BD held by RDE as a spare
>> + * + 1 BD of extra safety margin
>> + */
>
> Curious how the "+ 1 BD of extra safety margin" was decided. I
> understand the "+ 1 BD held by RDE as a spare" is because of HW
> behaviour but wondering about the extra buffer descriptor - if it came
> from testing or guarding against something specific.
>
The extra +1 isn't strictly necessary. The real lower bound is
MPNIC_RX_HPQ_DROP_THRS + 1, which was derived from the design of the
device and our napi poll implementation. I added an extra BD count
because the actual bound doesn't matter as long as its conservative.
Perhaps that's a bit superstitious.
>> + if (mpnic_desc_used(&nv->qt[t].sub0) <
>> + MPNIC_RX_HPQ_DROP_THRS + 2 ||
>> + mpnic_desc_used(&nv->qt[t].sub1) <
>> + MPNIC_RX_PPQ_DROP_THRS + 2) {
>> + mpnic_nv_irq_trigger(nv);
>> + break;
>> + }
>> + }
>> + }
>> +
>> + mpnic_wrfl(mpn->mpd);
>> +}
>> diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
>> index 9397010557eb..767d87a36c35 100644
>> --- a/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
>> +++ b/drivers/net/ethernet/meta/mpnic/mpnic_txrx.h
>> @@ -148,6 +148,7 @@ int mpnic_set_netif_queues(struct mpnic_net *mpn);
>> void mpnic_reset_netif_queues(struct mpnic_net *mpn);
>> void mpnic_napi_enable(struct mpnic_net *mpn);
>> void mpnic_napi_disable(struct mpnic_net *mpn);
>> +void mpnic_napi_depletion_check(struct mpnic_net *mpn);
>> void mpnic_enable(struct mpnic_net *mpn);
>> void mpnic_disable(struct mpnic_net *mpn);
>> void mpnic_wait_all_queues_idle(struct mpnic_dev *mpd);
>>
>> --
>> 2.52.0
>>
>>