On 2020-10-12 05:25, Shayne Chen wrote: > Support testmode rx and display rx statistic by parsing RXV packet > type, which is currently only enabled in testmode. > > Reviewed-by: Ryder Lee <ryder.lee@xxxxxxxxxxxx> > Signed-off-by: Shayne Chen <shayne.chen@xxxxxxxxxxxx> > --- > v2: change last_snr to u8 > > .../net/wireless/mediatek/mt76/mt7915/dma.c | 3 + > .../net/wireless/mediatek/mt76/mt7915/mac.c | 37 +++++++ > .../net/wireless/mediatek/mt76/mt7915/mac.h | 5 + > .../net/wireless/mediatek/mt76/mt7915/mcu.h | 1 + > .../wireless/mediatek/mt76/mt7915/mt7915.h | 7 ++ > .../wireless/mediatek/mt76/mt7915/testmode.c | 97 +++++++++++++++++++ > .../wireless/mediatek/mt76/mt7915/testmode.h | 30 ++++++ > 7 files changed, 180 insertions(+) > > --- a/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c > @@ -169,12 +209,69 @@ mt7915_tm_set_state(struct mt76_dev *mdev, enum mt76_testmode_state state) > mt7915_tm_set_tx_frames(dev, false); > else if (state == MT76_TM_STATE_TX_FRAMES) > mt7915_tm_set_tx_frames(dev, true); > + else if (prev_state == MT76_TM_STATE_RX_FRAMES) > + mt7915_tm_set_rx_frames(dev, false); > + else if (state == MT76_TM_STATE_RX_FRAMES) > + mt7915_tm_set_rx_frames(dev, true); > else if (prev_state == MT76_TM_STATE_OFF || state == MT76_TM_STATE_OFF) > mt7915_tm_init(dev); > > return 0; > } > > +static int > +mt7915_tm_dump_stats(struct mt76_dev *mdev, struct sk_buff *msg) > +{ > + struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76); > + void *rx, *rssi; > + int i; > + > + rx = nla_nest_start(msg, MT76_TM_STATS_ATTR_LAST_RX); > + if (!rx) > + return -ENOMEM; > + > + if (nla_put_s32(msg, MT76_TM_RX_ATTR_FREQ_OFFSET, dev->test.last_freq_offset)) > + return -ENOMEM; > + > + rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_RCPI); > + if (!rssi) > + return -ENOMEM; > + > + for (i = 0; i < ARRAY_SIZE(dev->test.last_rcpi); i++) > + if (nla_put_u8(msg, i, dev->test.last_rcpi[i])) > + return -ENOMEM; > + > + nla_nest_end(msg, rssi); > + > + rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_IB_RSSI); > + if (!rssi) > + return -ENOMEM; > + > + for (i = 0; i < ARRAY_SIZE(dev->test.last_ib_rssi); i++) > + if (nla_put_s8(msg, i, dev->test.last_ib_rssi[i])) > + return -ENOMEM; > + > + nla_nest_end(msg, rssi); > + > + rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_WB_RSSI); > + if (!rssi) > + return -ENOMEM; > + > + for (i = 0; i < ARRAY_SIZE(dev->test.last_wb_rssi); i++) > + if (nla_put_s8(msg, i, dev->test.last_wb_rssi[i])) > + return -ENOMEM; > + > + nla_nest_end(msg, rssi); > + > + if (nla_put_s32(msg, MT76_TM_RX_ATTR_SNR, dev->test.last_snr)) > + return -ENOMEM; You updated the comment in the header file, but not this part which actually generates the attribute. - Felix