Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-airoha-introduce-npu-callbacks-for-wlan-offloading'

Lorenzo Bianconi says:

====================
net: airoha: Introduce NPU callbacks for wlan offloading

Similar to wired traffic, EN7581 SoC allows to offload traffic to/from
the MT76 wireless NIC configuring the NPU module via the Netfilter
flowtable. This series introduces the necessary NPU callback used by
the MT7996 driver in order to enable the offloading.
MT76 support has been posted as RFC in [0] in order to show how the
APIs are consumed.
====================

Link: https://patch.msgid.link/20250811-airoha-en7581-wlan-offlaod-v7-0-58823603bb4e@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+451 -44
+18 -4
Documentation/devicetree/bindings/net/airoha,en7581-npu.yaml
··· 41 41 - description: wlan irq line5 42 42 43 43 memory-region: 44 - maxItems: 1 45 - description: 46 - Memory used to store NPU firmware binary. 44 + oneOf: 45 + - items: 46 + - description: NPU firmware binary region 47 + - items: 48 + - description: NPU firmware binary region 49 + - description: NPU wlan offload RX buffers region 50 + - description: NPU wlan offload TX buffers region 51 + - description: NPU wlan offload TX packet identifiers region 52 + 53 + memory-region-names: 54 + items: 55 + - const: firmware 56 + - const: pkt 57 + - const: tx-pkt 58 + - const: tx-bufid 47 59 48 60 required: 49 61 - compatible ··· 91 79 <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>, 92 80 <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>, 93 81 <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>; 94 - memory-region = <&npu_binary>; 82 + memory-region = <&npu_firmware>, <&npu_pkt>, <&npu_txpkt>, 83 + <&npu_txbufid>; 84 + memory-region-names = "firmware", "pkt", "tx-pkt", "tx-bufid"; 95 85 }; 96 86 };
+172 -3
drivers/net/ethernet/airoha/airoha_npu.c
··· 11 11 #include <linux/of_platform.h> 12 12 #include <linux/of_reserved_mem.h> 13 13 #include <linux/regmap.h> 14 + #include <linux/soc/airoha/airoha_offload.h> 14 15 15 16 #include "airoha_eth.h" 16 - #include "airoha_npu.h" 17 17 18 18 #define NPU_EN7581_FIRMWARE_DATA "airoha/en7581_npu_data.bin" 19 19 #define NPU_EN7581_FIRMWARE_RV32 "airoha/en7581_npu_rv32.bin" ··· 41 41 #define REG_CR_MBQ0_CTRL(_n) (NPU_MBOX_BASE_ADDR + 0x030 + ((_n) << 2)) 42 42 #define REG_CR_MBQ8_CTRL(_n) (NPU_MBOX_BASE_ADDR + 0x0b0 + ((_n) << 2)) 43 43 #define REG_CR_NPU_MIB(_n) (NPU_MBOX_BASE_ADDR + 0x140 + ((_n) << 2)) 44 + 45 + #define NPU_WLAN_BASE_ADDR 0x30d000 46 + 47 + #define REG_IRQ_STATUS (NPU_WLAN_BASE_ADDR + 0x030) 48 + #define REG_IRQ_RXDONE(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 2) + 0x034) 49 + #define NPU_IRQ_RX_MASK(_n) ((_n) == 1 ? BIT(17) : BIT(16)) 50 + 51 + #define REG_TX_BASE(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x080) 52 + #define REG_TX_DSCP_NUM(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x084) 53 + #define REG_TX_CPU_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x088) 54 + #define REG_TX_DMA_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x08c) 55 + 56 + #define REG_RX_BASE(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x180) 57 + #define REG_RX_DSCP_NUM(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x184) 58 + #define REG_RX_CPU_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x188) 59 + #define REG_RX_DMA_IDX(_n) (NPU_WLAN_BASE_ADDR + ((_n) << 4) + 0x18c) 44 60 45 61 #define NPU_TIMER_BASE_ADDR 0x310100 46 62 #define REG_WDT_TIMER_CTRL(_n) (NPU_TIMER_BASE_ADDR + ((_n) * 0x100)) ··· 138 122 u32 foe_stats_addr; 139 123 } stats_info; 140 124 }; 125 + }; 126 + 127 + struct wlan_mbox_data { 128 + u32 ifindex:4; 129 + u32 func_type:4; 130 + u32 func_id; 131 + DECLARE_FLEX_ARRAY(u8, d); 141 132 }; 142 133 143 134 static int airoha_npu_send_msg(struct airoha_npu *npu, int func_id, ··· 413 390 return err; 414 391 } 415 392 393 + static int airoha_npu_wlan_msg_send(struct airoha_npu *npu, int ifindex, 394 + enum airoha_npu_wlan_set_cmd func_id, 395 + void *data, int data_len, gfp_t gfp) 396 + { 397 + struct wlan_mbox_data *wlan_data; 398 + int err, len; 399 + 400 + len = sizeof(*wlan_data) + data_len; 401 + wlan_data = kzalloc(len, gfp); 402 + if (!wlan_data) 403 + return -ENOMEM; 404 + 405 + wlan_data->ifindex = ifindex; 406 + wlan_data->func_type = NPU_OP_SET; 407 + wlan_data->func_id = func_id; 408 + memcpy(wlan_data->d, data, data_len); 409 + 410 + err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data, len); 411 + kfree(wlan_data); 412 + 413 + return err; 414 + } 415 + 416 + static int airoha_npu_wlan_msg_get(struct airoha_npu *npu, int ifindex, 417 + enum airoha_npu_wlan_get_cmd func_id, 418 + void *data, int data_len, gfp_t gfp) 419 + { 420 + struct wlan_mbox_data *wlan_data; 421 + int err, len; 422 + 423 + len = sizeof(*wlan_data) + data_len; 424 + wlan_data = kzalloc(len, gfp); 425 + if (!wlan_data) 426 + return -ENOMEM; 427 + 428 + wlan_data->ifindex = ifindex; 429 + wlan_data->func_type = NPU_OP_GET; 430 + wlan_data->func_id = func_id; 431 + 432 + err = airoha_npu_send_msg(npu, NPU_FUNC_WIFI, wlan_data, len); 433 + if (!err) 434 + memcpy(data, wlan_data->d, data_len); 435 + kfree(wlan_data); 436 + 437 + return err; 438 + } 439 + 440 + static int 441 + airoha_npu_wlan_set_reserved_memory(struct airoha_npu *npu, 442 + int ifindex, const char *name, 443 + enum airoha_npu_wlan_set_cmd func_id) 444 + { 445 + struct device *dev = npu->dev; 446 + struct resource res; 447 + int err; 448 + u32 val; 449 + 450 + err = of_reserved_mem_region_to_resource_byname(dev->of_node, name, 451 + &res); 452 + if (err) 453 + return err; 454 + 455 + val = res.start; 456 + return airoha_npu_wlan_msg_send(npu, ifindex, func_id, &val, 457 + sizeof(val), GFP_KERNEL); 458 + } 459 + 460 + static int airoha_npu_wlan_init_memory(struct airoha_npu *npu) 461 + { 462 + enum airoha_npu_wlan_set_cmd cmd = WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU; 463 + u32 val = 0; 464 + int err; 465 + 466 + err = airoha_npu_wlan_msg_send(npu, 1, cmd, &val, sizeof(val), 467 + GFP_KERNEL); 468 + if (err) 469 + return err; 470 + 471 + cmd = WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR; 472 + err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-bufid", cmd); 473 + if (err) 474 + return err; 475 + 476 + cmd = WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR; 477 + err = airoha_npu_wlan_set_reserved_memory(npu, 0, "pkt", cmd); 478 + if (err) 479 + return err; 480 + 481 + cmd = WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR; 482 + err = airoha_npu_wlan_set_reserved_memory(npu, 0, "tx-pkt", cmd); 483 + if (err) 484 + return err; 485 + 486 + cmd = WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU; 487 + return airoha_npu_wlan_msg_send(npu, 0, cmd, &val, sizeof(val), 488 + GFP_KERNEL); 489 + } 490 + 491 + static u32 airoha_npu_wlan_queue_addr_get(struct airoha_npu *npu, int qid, 492 + bool xmit) 493 + { 494 + if (xmit) 495 + return REG_TX_BASE(qid + 2); 496 + 497 + return REG_RX_BASE(qid); 498 + } 499 + 500 + static void airoha_npu_wlan_irq_status_set(struct airoha_npu *npu, u32 val) 501 + { 502 + regmap_write(npu->regmap, REG_IRQ_STATUS, val); 503 + } 504 + 505 + static u32 airoha_npu_wlan_irq_status_get(struct airoha_npu *npu, int q) 506 + { 507 + u32 val; 508 + 509 + regmap_read(npu->regmap, REG_IRQ_STATUS, &val); 510 + return val; 511 + } 512 + 513 + static void airoha_npu_wlan_irq_enable(struct airoha_npu *npu, int q) 514 + { 515 + regmap_set_bits(npu->regmap, REG_IRQ_RXDONE(q), NPU_IRQ_RX_MASK(q)); 516 + } 517 + 518 + static void airoha_npu_wlan_irq_disable(struct airoha_npu *npu, int q) 519 + { 520 + regmap_clear_bits(npu->regmap, REG_IRQ_RXDONE(q), NPU_IRQ_RX_MASK(q)); 521 + } 522 + 416 523 struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr) 417 524 { 418 525 struct platform_device *pdev; ··· 646 493 npu->ops.ppe_deinit = airoha_npu_ppe_deinit; 647 494 npu->ops.ppe_flush_sram_entries = airoha_npu_ppe_flush_sram_entries; 648 495 npu->ops.ppe_foe_commit_entry = airoha_npu_foe_commit_entry; 496 + npu->ops.wlan_init_reserved_memory = airoha_npu_wlan_init_memory; 497 + npu->ops.wlan_send_msg = airoha_npu_wlan_msg_send; 498 + npu->ops.wlan_get_msg = airoha_npu_wlan_msg_get; 499 + npu->ops.wlan_get_queue_addr = airoha_npu_wlan_queue_addr_get; 500 + npu->ops.wlan_set_irq_status = airoha_npu_wlan_irq_status_set; 501 + npu->ops.wlan_get_irq_status = airoha_npu_wlan_irq_status_get; 502 + npu->ops.wlan_enable_irq = airoha_npu_wlan_irq_enable; 503 + npu->ops.wlan_disable_irq = airoha_npu_wlan_irq_disable; 649 504 650 505 npu->regmap = devm_regmap_init_mmio(dev, base, &regmap_config); 651 506 if (IS_ERR(npu->regmap)) ··· 690 529 INIT_WORK(&core->wdt_work, airoha_npu_wdt_work); 691 530 } 692 531 532 + /* wlan IRQ lines */ 533 + for (i = 0; i < ARRAY_SIZE(npu->irqs); i++) { 534 + irq = platform_get_irq(pdev, i + ARRAY_SIZE(npu->cores) + 1); 535 + if (irq < 0) 536 + return irq; 537 + 538 + npu->irqs[i] = irq; 539 + } 540 + 693 541 err = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); 694 542 if (err) 695 543 return err; ··· 720 550 usleep_range(1000, 2000); 721 551 722 552 /* enable NPU cores */ 723 - /* do not start core3 since it is used for WiFi offloading */ 724 - regmap_write(npu->regmap, REG_CR_BOOT_CONFIG, 0xf7); 553 + regmap_write(npu->regmap, REG_CR_BOOT_CONFIG, 0xff); 725 554 regmap_write(npu->regmap, REG_CR_BOOT_TRIGGER, 0x1); 726 555 msleep(100); 727 556
-36
drivers/net/ethernet/airoha/airoha_npu.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright (c) 2025 AIROHA Inc 4 - * Author: Lorenzo Bianconi <lorenzo@kernel.org> 5 - */ 6 - 7 - #define NPU_NUM_CORES 8 8 - 9 - struct airoha_npu { 10 - struct device *dev; 11 - struct regmap *regmap; 12 - 13 - struct airoha_npu_core { 14 - struct airoha_npu *npu; 15 - /* protect concurrent npu memory accesses */ 16 - spinlock_t lock; 17 - struct work_struct wdt_work; 18 - } cores[NPU_NUM_CORES]; 19 - 20 - struct airoha_foe_stats __iomem *stats; 21 - 22 - struct { 23 - int (*ppe_init)(struct airoha_npu *npu); 24 - int (*ppe_deinit)(struct airoha_npu *npu); 25 - int (*ppe_flush_sram_entries)(struct airoha_npu *npu, 26 - dma_addr_t foe_addr, 27 - int sram_num_entries); 28 - int (*ppe_foe_commit_entry)(struct airoha_npu *npu, 29 - dma_addr_t foe_addr, 30 - u32 entry_size, u32 hash, 31 - bool ppe2); 32 - } ops; 33 - }; 34 - 35 - struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr); 36 - void airoha_npu_put(struct airoha_npu *npu);
+1 -1
drivers/net/ethernet/airoha/airoha_ppe.c
··· 7 7 #include <linux/ip.h> 8 8 #include <linux/ipv6.h> 9 9 #include <linux/rhashtable.h> 10 + #include <linux/soc/airoha/airoha_offload.h> 10 11 #include <net/ipv6.h> 11 12 #include <net/pkt_cls.h> 12 13 13 - #include "airoha_npu.h" 14 14 #include "airoha_regs.h" 15 15 #include "airoha_eth.h" 16 16
+260
include/linux/soc/airoha/airoha_offload.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (c) 2025 AIROHA Inc 4 + * Author: Lorenzo Bianconi <lorenzo@kernel.org> 5 + */ 6 + #ifndef AIROHA_OFFLOAD_H 7 + #define AIROHA_OFFLOAD_H 8 + 9 + #include <linux/spinlock.h> 10 + #include <linux/workqueue.h> 11 + 12 + #define NPU_NUM_CORES 8 13 + #define NPU_NUM_IRQ 6 14 + #define NPU_RX0_DESC_NUM 512 15 + #define NPU_RX1_DESC_NUM 512 16 + 17 + /* CTRL */ 18 + #define NPU_RX_DMA_DESC_LAST_MASK BIT(29) 19 + #define NPU_RX_DMA_DESC_LEN_MASK GENMASK(28, 15) 20 + #define NPU_RX_DMA_DESC_CUR_LEN_MASK GENMASK(14, 1) 21 + #define NPU_RX_DMA_DESC_DONE_MASK BIT(0) 22 + /* INFO */ 23 + #define NPU_RX_DMA_PKT_COUNT_MASK GENMASK(31, 28) 24 + #define NPU_RX_DMA_PKT_ID_MASK GENMASK(28, 26) 25 + #define NPU_RX_DMA_SRC_PORT_MASK GENMASK(25, 21) 26 + #define NPU_RX_DMA_CRSN_MASK GENMASK(20, 16) 27 + #define NPU_RX_DMA_FOE_ID_MASK GENMASK(15, 0) 28 + /* DATA */ 29 + #define NPU_RX_DMA_SID_MASK GENMASK(31, 16) 30 + #define NPU_RX_DMA_FRAG_TYPE_MASK GENMASK(15, 14) 31 + #define NPU_RX_DMA_PRIORITY_MASK GENMASK(13, 10) 32 + #define NPU_RX_DMA_RADIO_ID_MASK GENMASK(9, 6) 33 + #define NPU_RX_DMA_VAP_ID_MASK GENMASK(5, 2) 34 + #define NPU_RX_DMA_FRAME_TYPE_MASK GENMASK(1, 0) 35 + 36 + struct airoha_npu_rx_dma_desc { 37 + u32 ctrl; 38 + u32 info; 39 + u32 data; 40 + u32 addr; 41 + u64 rsv; 42 + } __packed; 43 + 44 + /* CTRL */ 45 + #define NPU_TX_DMA_DESC_SCHED_MASK BIT(31) 46 + #define NPU_TX_DMA_DESC_LEN_MASK GENMASK(30, 18) 47 + #define NPU_TX_DMA_DESC_VEND_LEN_MASK GENMASK(17, 1) 48 + #define NPU_TX_DMA_DESC_DONE_MASK BIT(0) 49 + 50 + #define NPU_TXWI_LEN 192 51 + 52 + struct airoha_npu_tx_dma_desc { 53 + u32 ctrl; 54 + u32 addr; 55 + u64 rsv; 56 + u8 txwi[NPU_TXWI_LEN]; 57 + } __packed; 58 + 59 + enum airoha_npu_wlan_set_cmd { 60 + WLAN_FUNC_SET_WAIT_PCIE_ADDR, 61 + WLAN_FUNC_SET_WAIT_DESC, 62 + WLAN_FUNC_SET_WAIT_NPU_INIT_DONE, 63 + WLAN_FUNC_SET_WAIT_TRAN_TO_CPU, 64 + WLAN_FUNC_SET_WAIT_BA_WIN_SIZE, 65 + WLAN_FUNC_SET_WAIT_DRIVER_MODEL, 66 + WLAN_FUNC_SET_WAIT_DEL_STA, 67 + WLAN_FUNC_SET_WAIT_DRAM_BA_NODE_ADDR, 68 + WLAN_FUNC_SET_WAIT_PKT_BUF_ADDR, 69 + WLAN_FUNC_SET_WAIT_IS_TEST_NOBA, 70 + WLAN_FUNC_SET_WAIT_FLUSHONE_TIMEOUT, 71 + WLAN_FUNC_SET_WAIT_FLUSHALL_TIMEOUT, 72 + WLAN_FUNC_SET_WAIT_IS_FORCE_TO_CPU, 73 + WLAN_FUNC_SET_WAIT_PCIE_STATE, 74 + WLAN_FUNC_SET_WAIT_PCIE_PORT_TYPE, 75 + WLAN_FUNC_SET_WAIT_ERROR_RETRY_TIMES, 76 + WLAN_FUNC_SET_WAIT_BAR_INFO, 77 + WLAN_FUNC_SET_WAIT_FAST_FLAG, 78 + WLAN_FUNC_SET_WAIT_NPU_BAND0_ONCPU, 79 + WLAN_FUNC_SET_WAIT_TX_RING_PCIE_ADDR, 80 + WLAN_FUNC_SET_WAIT_TX_DESC_HW_BASE, 81 + WLAN_FUNC_SET_WAIT_TX_BUF_SPACE_HW_BASE, 82 + WLAN_FUNC_SET_WAIT_RX_RING_FOR_TXDONE_HW_BASE, 83 + WLAN_FUNC_SET_WAIT_TX_PKT_BUF_ADDR, 84 + WLAN_FUNC_SET_WAIT_INODE_TXRX_REG_ADDR, 85 + WLAN_FUNC_SET_WAIT_INODE_DEBUG_FLAG, 86 + WLAN_FUNC_SET_WAIT_INODE_HW_CFG_INFO, 87 + WLAN_FUNC_SET_WAIT_INODE_STOP_ACTION, 88 + WLAN_FUNC_SET_WAIT_INODE_PCIE_SWAP, 89 + WLAN_FUNC_SET_WAIT_RATELIMIT_CTRL, 90 + WLAN_FUNC_SET_WAIT_HWNAT_INIT, 91 + WLAN_FUNC_SET_WAIT_ARHT_CHIP_INFO, 92 + WLAN_FUNC_SET_WAIT_TX_BUF_CHECK_ADDR, 93 + WLAN_FUNC_SET_WAIT_TOKEN_ID_SIZE, 94 + }; 95 + 96 + enum airoha_npu_wlan_get_cmd { 97 + WLAN_FUNC_GET_WAIT_NPU_INFO, 98 + WLAN_FUNC_GET_WAIT_LAST_RATE, 99 + WLAN_FUNC_GET_WAIT_COUNTER, 100 + WLAN_FUNC_GET_WAIT_DBG_COUNTER, 101 + WLAN_FUNC_GET_WAIT_RXDESC_BASE, 102 + WLAN_FUNC_GET_WAIT_WCID_DBG_COUNTER, 103 + WLAN_FUNC_GET_WAIT_DMA_ADDR, 104 + WLAN_FUNC_GET_WAIT_RING_SIZE, 105 + WLAN_FUNC_GET_WAIT_NPU_SUPPORT_MAP, 106 + WLAN_FUNC_GET_WAIT_MDC_LOCK_ADDRESS, 107 + WLAN_FUNC_GET_WAIT_NPU_VERSION, 108 + }; 109 + 110 + struct airoha_npu { 111 + #if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU)) 112 + struct device *dev; 113 + struct regmap *regmap; 114 + 115 + struct airoha_npu_core { 116 + struct airoha_npu *npu; 117 + /* protect concurrent npu memory accesses */ 118 + spinlock_t lock; 119 + struct work_struct wdt_work; 120 + } cores[NPU_NUM_CORES]; 121 + 122 + int irqs[NPU_NUM_IRQ]; 123 + 124 + struct airoha_foe_stats __iomem *stats; 125 + 126 + struct { 127 + int (*ppe_init)(struct airoha_npu *npu); 128 + int (*ppe_deinit)(struct airoha_npu *npu); 129 + int (*ppe_flush_sram_entries)(struct airoha_npu *npu, 130 + dma_addr_t foe_addr, 131 + int sram_num_entries); 132 + int (*ppe_foe_commit_entry)(struct airoha_npu *npu, 133 + dma_addr_t foe_addr, 134 + u32 entry_size, u32 hash, 135 + bool ppe2); 136 + int (*wlan_init_reserved_memory)(struct airoha_npu *npu); 137 + int (*wlan_send_msg)(struct airoha_npu *npu, int ifindex, 138 + enum airoha_npu_wlan_set_cmd func_id, 139 + void *data, int data_len, gfp_t gfp); 140 + int (*wlan_get_msg)(struct airoha_npu *npu, int ifindex, 141 + enum airoha_npu_wlan_get_cmd func_id, 142 + void *data, int data_len, gfp_t gfp); 143 + u32 (*wlan_get_queue_addr)(struct airoha_npu *npu, int qid, 144 + bool xmit); 145 + void (*wlan_set_irq_status)(struct airoha_npu *npu, u32 val); 146 + u32 (*wlan_get_irq_status)(struct airoha_npu *npu, int q); 147 + void (*wlan_enable_irq)(struct airoha_npu *npu, int q); 148 + void (*wlan_disable_irq)(struct airoha_npu *npu, int q); 149 + } ops; 150 + #endif 151 + }; 152 + 153 + #if (IS_BUILTIN(CONFIG_NET_AIROHA_NPU) || IS_MODULE(CONFIG_NET_AIROHA_NPU)) 154 + struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr); 155 + void airoha_npu_put(struct airoha_npu *npu); 156 + 157 + static inline int airoha_npu_wlan_init_reserved_memory(struct airoha_npu *npu) 158 + { 159 + return npu->ops.wlan_init_reserved_memory(npu); 160 + } 161 + 162 + static inline int airoha_npu_wlan_send_msg(struct airoha_npu *npu, 163 + int ifindex, 164 + enum airoha_npu_wlan_set_cmd cmd, 165 + void *data, int data_len, gfp_t gfp) 166 + { 167 + return npu->ops.wlan_send_msg(npu, ifindex, cmd, data, data_len, gfp); 168 + } 169 + 170 + static inline int airoha_npu_wlan_get_msg(struct airoha_npu *npu, int ifindex, 171 + enum airoha_npu_wlan_get_cmd cmd, 172 + void *data, int data_len, gfp_t gfp) 173 + { 174 + return npu->ops.wlan_get_msg(npu, ifindex, cmd, data, data_len, gfp); 175 + } 176 + 177 + static inline u32 airoha_npu_wlan_get_queue_addr(struct airoha_npu *npu, 178 + int qid, bool xmit) 179 + { 180 + return npu->ops.wlan_get_queue_addr(npu, qid, xmit); 181 + } 182 + 183 + static inline void airoha_npu_wlan_set_irq_status(struct airoha_npu *npu, 184 + u32 val) 185 + { 186 + npu->ops.wlan_set_irq_status(npu, val); 187 + } 188 + 189 + static inline u32 airoha_npu_wlan_get_irq_status(struct airoha_npu *npu, int q) 190 + { 191 + return npu->ops.wlan_get_irq_status(npu, q); 192 + } 193 + 194 + static inline void airoha_npu_wlan_enable_irq(struct airoha_npu *npu, int q) 195 + { 196 + npu->ops.wlan_enable_irq(npu, q); 197 + } 198 + 199 + static inline void airoha_npu_wlan_disable_irq(struct airoha_npu *npu, int q) 200 + { 201 + npu->ops.wlan_disable_irq(npu, q); 202 + } 203 + #else 204 + static inline struct airoha_npu *airoha_npu_get(struct device *dev, 205 + dma_addr_t *foe_stats_addr) 206 + { 207 + return NULL; 208 + } 209 + 210 + static inline void airoha_npu_put(struct airoha_npu *npu) 211 + { 212 + } 213 + 214 + static inline int airoha_npu_wlan_init_reserved_memory(struct airoha_npu *npu) 215 + { 216 + return -EOPNOTSUPP; 217 + } 218 + 219 + static inline int airoha_npu_wlan_send_msg(struct airoha_npu *npu, 220 + int ifindex, 221 + enum airoha_npu_wlan_set_cmd cmd, 222 + void *data, int data_len, gfp_t gfp) 223 + { 224 + return -EOPNOTSUPP; 225 + } 226 + 227 + static inline int airoha_npu_wlan_get_msg(struct airoha_npu *npu, int ifindex, 228 + enum airoha_npu_wlan_get_cmd cmd, 229 + void *data, int data_len, gfp_t gfp) 230 + { 231 + return -EOPNOTSUPP; 232 + } 233 + 234 + static inline u32 airoha_npu_wlan_get_queue_addr(struct airoha_npu *npu, 235 + int qid, bool xmit) 236 + { 237 + return 0; 238 + } 239 + 240 + static inline void airoha_npu_wlan_set_irq_status(struct airoha_npu *npu, 241 + u32 val) 242 + { 243 + } 244 + 245 + static inline u32 airoha_npu_wlan_get_irq_status(struct airoha_npu *npu, 246 + int q) 247 + { 248 + return 0; 249 + } 250 + 251 + static inline void airoha_npu_wlan_enable_irq(struct airoha_npu *npu, int q) 252 + { 253 + } 254 + 255 + static inline void airoha_npu_wlan_disable_irq(struct airoha_npu *npu, int q) 256 + { 257 + } 258 + #endif 259 + 260 + #endif /* AIROHA_OFFLOAD_H */