diff mbox series

[v1,09/16] mt76: mt7921: make all event parser resuable between mt7921s and mt7921e

Message ID 764759a9a2befe09000863f04676287665675555.1631667941.git.objelf@gmail.com
State New
Headers show
Series [v1,01/16] mt76: mt7921: refactor mac.c to be bus independent | expand

Commit Message

Sean Wang Sept. 15, 2021, 1:14 a.m. UTC
From: Sean Wang <sean.wang@mediatek.com>

The longer event such as the event for mcu_get_nic_capability would hold
the data in paged fragment skb for the SDIO device so we turn the skb to
be linearized skb before accessing it to reuse the same event parser
betweem mt7921s and mt7921e.

Tested-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Lorenzo Bianconi Sept. 15, 2021, 1:24 p.m. UTC | #1
> From: Sean Wang <sean.wang@mediatek.com>
> 
> The longer event such as the event for mcu_get_nic_capability would hold
> the data in paged fragment skb for the SDIO device so we turn the skb to
> be linearized skb before accessing it to reuse the same event parser
> betweem mt7921s and mt7921e.
> 
> Tested-by: Deren Wu <deren.wu@mediatek.com>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> index f5a8f7fa4244..8e49df20a8cb 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> @@ -458,7 +458,14 @@ mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
>  
>  void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb)
>  {
> -	struct mt7921_mcu_rxd *rxd = (struct mt7921_mcu_rxd *)skb->data;
> +	struct mt7921_mcu_rxd *rxd;
> +	int ret;
> +
> +	ret = skb_linearize(skb);

is it true for sdio only? if so what about doing something like:

if (mt76_is_sdio() && skb_linearize(skb))
	return;

> +	if (ret)
> +		return;
> +
> +	rxd = (struct mt7921_mcu_rxd *)skb->data;
>  
>  	if (rxd->eid == 0x6) {
>  		mt76_mcu_rx_event(&dev->mt76, skb);
> -- 
> 2.25.1
>
Lorenzo Bianconi Sept. 15, 2021, 1:31 p.m. UTC | #2
> > From: Sean Wang <sean.wang@mediatek.com>
> > 
> > The longer event such as the event for mcu_get_nic_capability would hold
> > the data in paged fragment skb for the SDIO device so we turn the skb to
> > be linearized skb before accessing it to reuse the same event parser
> > betweem mt7921s and mt7921e.
> > 
> > Tested-by: Deren Wu <deren.wu@mediatek.com>
> > Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> > ---
> >  drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> > index f5a8f7fa4244..8e49df20a8cb 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> > @@ -458,7 +458,14 @@ mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
> >  
> >  void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb)
> >  {
> > -	struct mt7921_mcu_rxd *rxd = (struct mt7921_mcu_rxd *)skb->data;
> > +	struct mt7921_mcu_rxd *rxd;
> > +	int ret;
> > +
> > +	ret = skb_linearize(skb);
> 
> is it true for sdio only? if so what about doing something like:
> 
> if (mt76_is_sdio() && skb_linearize(skb))
> 	return;

please ignore this comment, it is already in skb_linearize()

> 
> > +	if (ret)
> > +		return;
> > +
> > +	rxd = (struct mt7921_mcu_rxd *)skb->data;
> >  
> >  	if (rxd->eid == 0x6) {
> >  		mt76_mcu_rx_event(&dev->mt76, skb);
> > -- 
> > 2.25.1
> >
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index f5a8f7fa4244..8e49df20a8cb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -458,7 +458,14 @@  mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
 
 void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb)
 {
-	struct mt7921_mcu_rxd *rxd = (struct mt7921_mcu_rxd *)skb->data;
+	struct mt7921_mcu_rxd *rxd;
+	int ret;
+
+	ret = skb_linearize(skb);
+	if (ret)
+		return;
+
+	rxd = (struct mt7921_mcu_rxd *)skb->data;
 
 	if (rxd->eid == 0x6) {
 		mt76_mcu_rx_event(&dev->mt76, skb);