[PATCH net-next 10/15] net: ethernet: mtk_wed: introduce WED support for MT7988
Rob Herring
robh at kernel.org
Fri Sep 15 07:55:48 PDT 2023
On Thu, Sep 14, 2023 at 04:38:15PM +0200, Lorenzo Bianconi wrote:
> From: Sujuan Chen <sujuan.chen at mediatek.com>
>
> Similar to MT7986 and MT7622, enable Wireless Ethernet Ditpatcher for
> MT7988 in order to offload traffic forwarded from LAN/WLAN to WLAN/LAN
>
> Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
> Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
> Signed-off-by: Sujuan Chen <sujuan.chen at mediatek.com>
> ---
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 +
> drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +-
> .../net/ethernet/mediatek/mtk_ppe_offload.c | 3 +
> drivers/net/ethernet/mediatek/mtk_wed.c | 458 +++++++++++++-----
> drivers/net/ethernet/mediatek/mtk_wed.h | 28 ++
> drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 33 +-
> drivers/net/ethernet/mediatek/mtk_wed_regs.h | 228 ++++++++-
> drivers/net/ethernet/mediatek/mtk_wed_wo.h | 2 +
> include/linux/soc/mediatek/mtk_wed.h | 9 +-
> 9 files changed, 618 insertions(+), 146 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 3cffd1bd3067..697620c6354b 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -197,6 +197,7 @@ static const struct mtk_reg_map mt7988_reg_map = {
> .wdma_base = {
> [0] = 0x4800,
> [1] = 0x4c00,
> + [2] = 0x5000,
> },
> .pse_iq_sta = 0x0180,
> .pse_oq_sta = 0x01a0,
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
> index 403219d987ef..9ae3b8a71d0e 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
> @@ -1132,7 +1132,7 @@ struct mtk_reg_map {
> u32 gdm1_cnt;
> u32 gdma_to_ppe;
> u32 ppe_base;
> - u32 wdma_base[2];
> + u32 wdma_base[3];
> u32 pse_iq_sta;
> u32 pse_oq_sta;
> };
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
> index ef3980840695..95f76975f258 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
> @@ -201,6 +201,9 @@ mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe,
> case 1:
> pse_port = PSE_WDMA1_PORT;
> break;
> + case 2:
> + pse_port = PSE_WDMA2_PORT;
> + break;
> default:
> return -EINVAL;
> }
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
> index 58d97be98029..0d8e10df9da2 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed.c
> +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
> @@ -17,17 +17,19 @@
> #include <net/flow_offload.h>
> #include <net/pkt_cls.h>
> #include "mtk_eth_soc.h"
> -#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)
>
> -#define MTK_WED_PKT_SIZE 1900
> +#define MTK_WED_PKT_SIZE 1920
> #define MTK_WED_BUF_SIZE 2048
> +#define MTK_WED_PAGE_BUF_SIZE 128
> #define MTK_WED_BUF_PER_PAGE (PAGE_SIZE / 2048)
> +#define MTK_WED_RX_PAGE_BUF_PER_PAGE (PAGE_SIZE / 128)
> #define MTK_WED_RX_RING_SIZE 1536
> +#define MTK_WED_RX_PG_BM_CNT 8192
>
> #define MTK_WED_TX_RING_SIZE 2048
> #define MTK_WED_WDMA_RING_SIZE 1024
> @@ -41,7 +43,10 @@
> #define MTK_WED_RRO_QUE_CNT 8192
> #define MTK_WED_MIOD_ENTRY_CNT 128
>
> -static struct mtk_wed_hw *hw_list[2];
> +#define MTK_WED_TX_BM_DMA_SIZE 65536
> +#define MTK_WED_TX_BM_PKT_CNT 32768
> +
> +static struct mtk_wed_hw *hw_list[3];
> static DEFINE_MUTEX(hw_lock);
>
> struct mtk_wed_flow_block_priv {
> @@ -300,33 +305,39 @@ mtk_wed_assign(struct mtk_wed_device *dev)
> static int
> mtk_wed_tx_buffer_alloc(struct mtk_wed_device *dev)
> {
> + int i, page_idx = 0, n_pages, ring_size;
> + int token = dev->wlan.token_start;
> struct mtk_wed_buf *page_list;
> - struct mtk_wdma_desc *desc;
> dma_addr_t desc_phys;
> - int token = dev->wlan.token_start;
> - int ring_size;
> - int n_pages;
> - int i, page_idx;
> + void *desc_ptr;
>
> - ring_size = dev->wlan.nbuf & ~(MTK_WED_BUF_PER_PAGE - 1);
> - n_pages = ring_size / MTK_WED_BUF_PER_PAGE;
> + if (!mtk_wed_is_v3_or_greater(dev->hw)) {
> + dev->tx_buf_ring.desc_size = sizeof(struct mtk_wdma_desc);
Instead of checking the version or using of_device_is_compatible() in
other places why don't you define driver match data for all this static
data.
Rob
More information about the Linux-mediatek
mailing list