Commit 79968444 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by David S. Miller

net: ethernet: mtk_wed: introduce wed wo support

Introduce WO chip support to mtk wed driver. MTK WED WO is used to
implement RX Wireless Ethernet Dispatch and offload traffic received by
wlan nic to the wired interface.
Tested-by: default avatarDaniel Golle <daniel@makrotopia.org>
Co-developed-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: default avatarSujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cc514101
......@@ -5,7 +5,7 @@
obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o
mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o
mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o
mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o mtk_wed_wo.o
ifdef CONFIG_DEBUG_FS
mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o
endif
......
......@@ -16,6 +16,7 @@
#include "mtk_wed_regs.h"
#include "mtk_wed.h"
#include "mtk_ppe.h"
#include "mtk_wed_wo.h"
#define MTK_PCIE_BASE(n) (0x1a143000 + (n) * 0x2000)
......@@ -355,6 +356,8 @@ mtk_wed_detach(struct mtk_wed_device *dev)
mtk_wed_free_buffer(dev);
mtk_wed_free_tx_rings(dev);
if (hw->version != 1)
mtk_wed_wo_deinit(hw);
if (dev->wlan.bus_type == MTK_WED_BUS_PCIE) {
struct device_node *wlan_node;
......@@ -878,9 +881,11 @@ mtk_wed_attach(struct mtk_wed_device *dev)
}
mtk_wed_hw_init_early(dev);
if (hw->hifsys)
if (hw->version == 1)
regmap_update_bits(hw->hifsys, HIFSYS_DMA_AG_MAP,
BIT(hw->index), 0);
else
ret = mtk_wed_wo_init(hw);
out:
mutex_unlock(&hw_lock);
......
......@@ -10,6 +10,7 @@
#include <linux/netdevice.h>
struct mtk_eth;
struct mtk_wed_wo;
struct mtk_wed_hw {
struct device_node *node;
......@@ -22,6 +23,7 @@ struct mtk_wed_hw {
struct regmap *mirror;
struct dentry *debugfs_dir;
struct mtk_wed_device *wed_dev;
struct mtk_wed_wo *wed_wo;
u32 debugfs_reg;
u32 num_flows;
u8 version;
......
......@@ -122,8 +122,7 @@ mtk_wed_mcu_skb_send_msg(struct mtk_wed_wo *wo, struct sk_buff *skb,
if (id == MTK_WED_MODULE_ID_WO)
hdr->flag |= cpu_to_le16(MTK_WED_WARP_CMD_FLAG_FROM_TO_WO);
dev_kfree_skb(skb);
return 0;
return mtk_wed_wo_queue_tx_skb(wo, &wo->q_tx, skb);
}
static int
......
This diff is collapsed.
......@@ -80,6 +80,54 @@ enum mtk_wed_dummy_cr_idx {
#define MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK BIT(5)
#define MTK_WO_MCU_CFG_LS_WF_WM_WA_WA_CPU_RSTB_MASK BIT(0)
#define MTK_WED_WO_RING_SIZE 256
#define MTK_WED_WO_CMD_LEN 1504
#define MTK_WED_WO_TXCH_NUM 0
#define MTK_WED_WO_RXCH_NUM 1
#define MTK_WED_WO_RXCH_WO_EXCEPTION 7
#define MTK_WED_WO_TXCH_INT_MASK BIT(0)
#define MTK_WED_WO_RXCH_INT_MASK BIT(1)
#define MTK_WED_WO_EXCEPTION_INT_MASK BIT(7)
#define MTK_WED_WO_ALL_INT_MASK (MTK_WED_WO_RXCH_INT_MASK | \
MTK_WED_WO_EXCEPTION_INT_MASK)
#define MTK_WED_WO_CCIF_BUSY 0x004
#define MTK_WED_WO_CCIF_START 0x008
#define MTK_WED_WO_CCIF_TCHNUM 0x00c
#define MTK_WED_WO_CCIF_RCHNUM 0x010
#define MTK_WED_WO_CCIF_RCHNUM_MASK GENMASK(7, 0)
#define MTK_WED_WO_CCIF_ACK 0x014
#define MTK_WED_WO_CCIF_IRQ0_MASK 0x018
#define MTK_WED_WO_CCIF_IRQ1_MASK 0x01c
#define MTK_WED_WO_CCIF_DUMMY1 0x020
#define MTK_WED_WO_CCIF_DUMMY2 0x024
#define MTK_WED_WO_CCIF_DUMMY3 0x028
#define MTK_WED_WO_CCIF_DUMMY4 0x02c
#define MTK_WED_WO_CCIF_SHADOW1 0x030
#define MTK_WED_WO_CCIF_SHADOW2 0x034
#define MTK_WED_WO_CCIF_SHADOW3 0x038
#define MTK_WED_WO_CCIF_SHADOW4 0x03c
#define MTK_WED_WO_CCIF_DUMMY5 0x050
#define MTK_WED_WO_CCIF_DUMMY6 0x054
#define MTK_WED_WO_CCIF_DUMMY7 0x058
#define MTK_WED_WO_CCIF_DUMMY8 0x05c
#define MTK_WED_WO_CCIF_SHADOW5 0x060
#define MTK_WED_WO_CCIF_SHADOW6 0x064
#define MTK_WED_WO_CCIF_SHADOW7 0x068
#define MTK_WED_WO_CCIF_SHADOW8 0x06c
#define MTK_WED_WO_CTL_SD_LEN1 GENMASK(13, 0)
#define MTK_WED_WO_CTL_LAST_SEC1 BIT(14)
#define MTK_WED_WO_CTL_BURST BIT(15)
#define MTK_WED_WO_CTL_SD_LEN0_SHIFT 16
#define MTK_WED_WO_CTL_SD_LEN0 GENMASK(29, 16)
#define MTK_WED_WO_CTL_LAST_SEC0 BIT(30)
#define MTK_WED_WO_CTL_DMA_DONE BIT(31)
#define MTK_WED_WO_INFO_WINFO GENMASK(15, 0)
struct mtk_wed_wo_memory_region {
const char *name;
void __iomem *addr;
......@@ -112,10 +160,53 @@ struct mtk_wed_fw_trailer {
u32 crc;
};
struct mtk_wed_wo_queue_regs {
u32 desc_base;
u32 ring_size;
u32 cpu_idx;
u32 dma_idx;
};
struct mtk_wed_wo_queue_desc {
__le32 buf0;
__le32 ctrl;
__le32 buf1;
__le32 info;
__le32 reserved[4];
} __packed __aligned(32);
struct mtk_wed_wo_queue_entry {
dma_addr_t addr;
void *buf;
u32 len;
};
struct mtk_wed_wo_queue {
struct mtk_wed_wo_queue_regs regs;
struct page_frag_cache cache;
spinlock_t lock;
struct mtk_wed_wo_queue_desc *desc;
dma_addr_t desc_dma;
struct mtk_wed_wo_queue_entry *entry;
u16 head;
u16 tail;
int n_desc;
int queued;
int buf_size;
};
struct mtk_wed_wo {
struct mtk_wed_hw *hw;
struct mtk_wed_wo_memory_region boot;
struct mtk_wed_wo_queue q_tx;
struct mtk_wed_wo_queue q_rx;
struct {
struct mutex mutex;
int timeout;
......@@ -124,6 +215,15 @@ struct mtk_wed_wo {
struct sk_buff_head res_q;
wait_queue_head_t wait;
} mcu;
struct {
struct regmap *regs;
spinlock_t lock;
struct tasklet_struct irq_tasklet;
int irq;
u32 irq_mask;
} mmio;
};
static inline int
......@@ -146,5 +246,9 @@ void mtk_wed_mcu_rx_unsolicited_event(struct mtk_wed_wo *wo,
int mtk_wed_mcu_send_msg(struct mtk_wed_wo *wo, int id, int cmd,
const void *data, int len, bool wait_resp);
int mtk_wed_mcu_init(struct mtk_wed_wo *wo);
int mtk_wed_wo_init(struct mtk_wed_hw *hw);
void mtk_wed_wo_deinit(struct mtk_wed_hw *hw);
int mtk_wed_wo_queue_tx_skb(struct mtk_wed_wo *dev, struct mtk_wed_wo_queue *q,
struct sk_buff *skb);
#endif /* __MTK_WED_WO_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment