diff mbox series

mt76: sdio: add rx_check callback for sdio devices

Message ID 2902205ffea3f07349db8c1466e81a8a5f24dc86.1658474979.git.lorenzo@kernel.org (mailing list archive)
State Accepted
Delegated to: Felix Fietkau
Headers show
Series mt76: sdio: add rx_check callback for sdio devices | expand

Commit Message

Lorenzo Bianconi July 22, 2022, 7:32 a.m. UTC
Introduce rx_check callback support for mt7921s driver.

Tested-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
This patch is based on: "mt76: add rx_check callback for usb devices"
https://patchwork.kernel.org/project/linux-wireless/patch/1ce2555483783c2f62bb8fecc575ceca1aad8583.1658335993.git.lorenzo@kernel.org/
---
 .../net/wireless/mediatek/mt76/mt7921/sdio.c  |  1 +
 .../net/wireless/mediatek/mt76/sdio_txrx.c    | 23 +++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

Comments

kernel test robot July 24, 2022, 9:16 p.m. UTC | #1
Hi Lorenzo,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-next/main]
[also build test ERROR on linus/master v5.19-rc7 next-20220722]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Bianconi/mt76-sdio-add-rx_check-callback-for-sdio-devices/20220722-153400
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
config: ia64-allmodconfig (https://download.01.org/0day-ci/archive/20220725/202207250528.8cxL1kpm-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/202e740929b81d6752f7f4586d5383c252ed8057
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Lorenzo-Bianconi/mt76-sdio-add-rx_check-callback-for-sdio-devices/20220722-153400
        git checkout 202e740929b81d6752f7f4586d5383c252ed8057
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/gpu/drm/amd/display/amdgpu_dm/ drivers/net/wireless/mediatek/mt76/mt7921/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/wireless/mediatek/mt76/mt7921/sdio.c: In function 'mt7921s_probe':
>> drivers/net/wireless/mediatek/mt76/mt7921/sdio.c:99:29: error: 'mt7921_rx_check' undeclared (first use in this function); did you mean 'mt7921e_rx_check'?
      99 |                 .rx_check = mt7921_rx_check,
         |                             ^~~~~~~~~~~~~~~
         |                             mt7921e_rx_check
   drivers/net/wireless/mediatek/mt76/mt7921/sdio.c:99:29: note: each undeclared identifier is reported only once for each function it appears in


vim +99 drivers/net/wireless/mediatek/mt76/mt7921/sdio.c

    86	
    87	static int mt7921s_probe(struct sdio_func *func,
    88				 const struct sdio_device_id *id)
    89	{
    90		static const struct mt76_driver_ops drv_ops = {
    91			.txwi_size = MT_SDIO_TXD_SIZE,
    92			.survey_flags = SURVEY_INFO_TIME_TX |
    93					SURVEY_INFO_TIME_RX |
    94					SURVEY_INFO_TIME_BSS_RX,
    95			.tx_prepare_skb = mt7921_usb_sdio_tx_prepare_skb,
    96			.tx_complete_skb = mt7921_usb_sdio_tx_complete_skb,
    97			.tx_status_data = mt7921_usb_sdio_tx_status_data,
    98			.rx_skb = mt7921_queue_rx_skb,
  > 99			.rx_check = mt7921_rx_check,
   100			.sta_ps = mt7921_sta_ps,
   101			.sta_add = mt7921_mac_sta_add,
   102			.sta_assoc = mt7921_mac_sta_assoc,
   103			.sta_remove = mt7921_mac_sta_remove,
   104			.update_survey = mt7921_update_channel,
   105		};
   106		static const struct mt76_bus_ops mt7921s_ops = {
   107			.rr = mt76s_rr,
   108			.rmw = mt76s_rmw,
   109			.wr = mt76s_wr,
   110			.write_copy = mt76s_write_copy,
   111			.read_copy = mt76s_read_copy,
   112			.wr_rp = mt76s_wr_rp,
   113			.rd_rp = mt76s_rd_rp,
   114			.type = MT76_BUS_SDIO,
   115		};
   116		static const struct mt7921_hif_ops mt7921_sdio_ops = {
   117			.init_reset = mt7921s_init_reset,
   118			.reset = mt7921s_mac_reset,
   119			.mcu_init = mt7921s_mcu_init,
   120			.drv_own = mt7921s_mcu_drv_pmctrl,
   121			.fw_own = mt7921s_mcu_fw_pmctrl,
   122		};
   123	
   124		struct mt7921_dev *dev;
   125		struct mt76_dev *mdev;
   126		int ret;
   127	
   128		mdev = mt76_alloc_device(&func->dev, sizeof(*dev), &mt7921_ops,
   129					 &drv_ops);
   130		if (!mdev)
   131			return -ENOMEM;
   132	
   133		dev = container_of(mdev, struct mt7921_dev, mt76);
   134		dev->hif_ops = &mt7921_sdio_ops;
   135	
   136		sdio_set_drvdata(func, dev);
   137	
   138		ret = mt76s_init(mdev, func, &mt7921s_ops);
   139		if (ret < 0)
   140			goto error;
   141	
   142		ret = mt76s_hw_init(mdev, func, MT76_CONNAC2_SDIO);
   143		if (ret)
   144			goto error;
   145	
   146		mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
   147			    (mt76_rr(dev, MT_HW_REV) & 0xff);
   148		dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
   149	
   150		mdev->sdio.parse_irq = mt7921s_parse_intr;
   151		mdev->sdio.intr_data = devm_kmalloc(mdev->dev,
   152						    sizeof(struct mt7921_sdio_intr),
   153						    GFP_KERNEL);
   154		if (!mdev->sdio.intr_data) {
   155			ret = -ENOMEM;
   156			goto error;
   157		}
   158	
   159		ret = mt76s_alloc_rx_queue(mdev, MT_RXQ_MAIN);
   160		if (ret)
   161			goto error;
   162	
   163		ret = mt76s_alloc_rx_queue(mdev, MT_RXQ_MCU);
   164		if (ret)
   165			goto error;
   166	
   167		ret = mt76s_alloc_tx(mdev);
   168		if (ret)
   169			goto error;
   170	
   171		ret = mt76_worker_setup(mt76_hw(dev), &mdev->sdio.txrx_worker,
   172					mt7921s_txrx_worker, "sdio-txrx");
   173		if (ret)
   174			goto error;
   175	
   176		sched_set_fifo_low(mdev->sdio.txrx_worker.task);
   177	
   178		ret = mt7921_register_device(dev);
   179		if (ret)
   180			goto error;
   181	
   182		return 0;
   183	
   184	error:
   185		mt76s_deinit(&dev->mt76);
   186		mt76_free_device(&dev->mt76);
   187	
   188		return ret;
   189	}
   190
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c b/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c
index 487acd6e2be8..0c1b6e70e756 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/sdio.c
@@ -96,6 +96,7 @@  static int mt7921s_probe(struct sdio_func *func,
 		.tx_complete_skb = mt7921_usb_sdio_tx_complete_skb,
 		.tx_status_data = mt7921_usb_sdio_tx_status_data,
 		.rx_skb = mt7921_queue_rx_skb,
+		.rx_check = mt7921_rx_check,
 		.sta_ps = mt7921_sta_ps,
 		.sta_add = mt7921_mac_sta_add,
 		.sta_assoc = mt7921_mac_sta_assoc,
diff --git a/drivers/net/wireless/mediatek/mt76/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
index a2601aa9e7b1..bfc4de50a4d2 100644
--- a/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
+++ b/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
@@ -85,7 +85,7 @@  mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
 	struct mt76_sdio *sdio = &dev->sdio;
 	int len = 0, err, i;
 	struct page *page;
-	u8 *buf;
+	u8 *buf, *end;
 
 	for (i = 0; i < intr->rx.num[qid]; i++)
 		len += round_up(intr->rx.len[qid][i] + 4, 4);
@@ -112,20 +112,29 @@  mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
 		return err;
 	}
 
-	for (i = 0; i < intr->rx.num[qid]; i++) {
+	end = buf + len;
+	i = 0;
+
+	while (i < intr->rx.num[qid] && buf < end) {
 		int index = (q->head + i) % q->ndesc;
 		struct mt76_queue_entry *e = &q->entry[index];
 		__le32 *rxd = (__le32 *)buf;
 
 		/* parse rxd to get the actual packet length */
 		len = le32_get_bits(rxd[0], GENMASK(15, 0));
-		e->skb = mt76s_build_rx_skb(buf, len, round_up(len + 4, 4));
-		if (!e->skb)
-			break;
 
+		/* Optimized path for TXS */
+		if (!dev->drv->rx_check || dev->drv->rx_check(dev, buf, len)) {
+			e->skb = mt76s_build_rx_skb(buf, len,
+						    round_up(len + 4, 4));
+			if (!e->skb)
+				break;
+
+			if (q->queued + i + 1 == q->ndesc)
+				break;
+			i++;
+		}
 		buf += round_up(len + 4, 4);
-		if (q->queued + i + 1 == q->ndesc)
-			break;
 	}
 	put_page(page);