[PATCH net-next v5 3/7] net: airoha: npu: Add wlan_{send,get}_msg NPU callbacks

Lorenzo Bianconi lorenzo at kernel.org
Sun Jul 27 01:42:25 PDT 2025


> On 23/07/2025 18:19, Lorenzo Bianconi wrote:
> > Introduce wlan_send_msg() and wlan_get_msg() NPU wlan callbacks used
> > by the wlan driver (MT76) to initialize NPU module registers in order to
> > offload wireless-wired traffic.
> > This is a preliminary patch to enable wlan flowtable offload for EN7581
> > SoC with MT76 driver.
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
> > ---
> >   drivers/net/ethernet/airoha/airoha_npu.c | 58 ++++++++++++++++++++++++++++++++
> >   drivers/net/ethernet/airoha/airoha_npu.h | 21 ++++++++++++
> >   2 files changed, 79 insertions(+)
> > 
> 
> [...]
> 
> > @@ -131,6 +147,12 @@ struct wlan_mbox_data {
> >   	u32 func_id;
> >   	union {
> >   		u32 data;
> > +		struct {
> > +			u32 dir;
> > +			u32 in_counter_addr;
> > +			u32 out_status_addr;
> > +			u32 out_counter_addr;
> > +		} txrx_addr;
> >   		u8 stats[WLAN_MAX_STATS_SIZE];
> >   	};
> >   };
> > @@ -424,6 +446,30 @@ static int airoha_npu_wlan_msg_send(struct airoha_npu *npu, int ifindex,
> >   	return err;
> >   }
> > +static int airoha_npu_wlan_msg_get(struct airoha_npu *npu, int ifindex,
> > +				   enum airoha_npu_wlan_get_cmd func_id,
> > +				   u32 *data, gfp_t gfp)
> > +{
> > +	struct wlan_mbox_data *wlan_data;
> > +	int err;
> > +
> > +	wlan_data = kzalloc(sizeof(*wlan_data), gfp);
> > +	if (!wlan_data)
> > +		return -ENOMEM;
> > +
> > +	wlan_data->ifindex = ifindex;
> > +	wlan_data->func_type = NPU_OP_GET;
> > +	wlan_data->func_id = func_id;
> > +
> > +	err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data,
> > +				  sizeof(*wlan_data));
> > +	if (!err)
> > +		*data = wlan_data->data;
> > +	kfree(wlan_data);
> > +
> > +	return err;
> > +}
> 
> Am I reading it correct, that on message_get you allocate 4408 + 8 byte,
> setting it 0, then reallocate the same size in airoha_npu_send_msg() and
> copy the data, and then free both buffers, and this is all done just to
> get u32 value back?

ack, right. This is was the original approach in the vendor sdk.
I will fix in v6.

Regards,
Lorenzo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20250727/4b2d49f6/attachment.sig>


More information about the linux-arm-kernel mailing list