Re: [PATCH wireless-next v2 12/31] wifi: mm81x: add mac.c

From: Lachlan Hodges

Date: Fri Jun 05 2026 - 02:33:10 EST


Hi Johannes, just having a think about how to do this:

On Thu, Jun 04, 2026 at 01:46:32PM +0200, Johannes Berg wrote:
>
> > +static void mm81x_mac_ops_flush(struct ieee80211_hw *hw,
> > + struct ieee80211_vif *vif, u32 queues,
> > + bool drop)
> > +{
> > + struct mm81x *mors = hw->priv;
> > +
> > + /* We don't support IEEE80211_HW_QUEUE_CONTROL so flush all queues */
> > + if (drop) {
> > + /*
> > + * No need to call mm81x_skbq_stop_tx_queues as mac80211
> > + * has already cancelled each queue prior to calling .flush()
> > + */
> > + mm81x_skbq_data_traffic_pause(mors);
> > +
> > + flush_work(&mors->hif_work);
> > + flush_work(&mors->tx_stale_work);
> > +
> > + mm81x_hif_clear_events(mors);
> > + mm81x_hif_flush_tx_data(mors);
> > + mm81x_hif_flush_cmds(mors);
> > +
> > + /* Reenable data, not that there will be any */
> > + mm81x_skbq_data_traffic_resume(mors);
> > + }
> > +}
>
> Doing nothing in the !drop case seems questionable - mac80211 uses this
> sometimes to e.g. make sure a deauth frame really went out before
> shutting down the hardware.

What is the consensus (or I guess your opinion) on using
read_poll_timeout() with a function that isn't really doing any real
I/O but rather just reading software queue state? E.g.:

static void mm81x_mac_wait_queues(struct mm81x *mors)
{
int remaining;

if (read_poll_timeout(mm81x_hif_get_tx_outstanding_count, remaining,
!remaining, MM81X_FLUSH_DRAIN_POLL_US,
MM81X_FLUSH_DRAIN_TIMEOUT_US, false, mors))
dev_warn(mors->dev,
"Unable to empty queues before timeout. Remaining: %d",
remaining);
}

where mm81x_hif_get_tx_outstanding_count internally is:

int mm81x_yaps_get_tx_outstanding_count(struct mm81x *mors)
{
int i;
int count = 0;
struct mm81x_yaps *yaps = &mors->hif.u.yaps;

/* We only care about data + mgmt here */
count += mm81x_skbq_outstanding(&yaps->mgmt_q);

for (i = 0; i < ARRAY_SIZE(yaps->data_tx_qs); i++)
count += mm81x_skbq_outstanding(&yaps->data_tx_qs[i]);

return count;
}

It is fairly easy to opencode something similar, but this looks nice :)
though I can't see many examples of using it like this so I am
a bit cautious.

lachlan