Lines Matching full:eth
789 struct airoha_eth *eth; member
850 #define airoha_fe_rr(eth, offset) \ argument
851 airoha_rr((eth)->fe_regs, (offset))
852 #define airoha_fe_wr(eth, offset, val) \ argument
853 airoha_wr((eth)->fe_regs, (offset), (val))
854 #define airoha_fe_rmw(eth, offset, mask, val) \ argument
855 airoha_rmw((eth)->fe_regs, (offset), (mask), (val))
856 #define airoha_fe_set(eth, offset, val) \ argument
857 airoha_rmw((eth)->fe_regs, (offset), 0, (val))
858 #define airoha_fe_clear(eth, offset, val) \ argument
859 airoha_rmw((eth)->fe_regs, (offset), (val), 0)
916 struct airoha_eth *eth = port->qdma->eth; in airoha_set_macaddr() local
922 airoha_fe_wr(eth, reg, val); in airoha_set_macaddr()
925 airoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), val); in airoha_set_macaddr()
926 airoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), val); in airoha_set_macaddr()
929 static void airoha_set_gdm_port_fwd_cfg(struct airoha_eth *eth, u32 addr, in airoha_set_gdm_port_fwd_cfg() argument
932 airoha_fe_rmw(eth, addr, GDM_OCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
934 airoha_fe_rmw(eth, addr, GDM_MCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
936 airoha_fe_rmw(eth, addr, GDM_BCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
938 airoha_fe_rmw(eth, addr, GDM_UCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
942 static int airoha_set_gdm_port(struct airoha_eth *eth, int port, bool enable) in airoha_set_gdm_port() argument
969 airoha_fe_set(eth, REG_FE_VIP_PORT_EN, vip_port); in airoha_set_gdm_port()
970 airoha_fe_set(eth, REG_FE_IFC_PORT_EN, vip_port); in airoha_set_gdm_port()
972 airoha_fe_clear(eth, REG_FE_VIP_PORT_EN, vip_port); in airoha_set_gdm_port()
973 airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, vip_port); in airoha_set_gdm_port()
976 airoha_set_gdm_port_fwd_cfg(eth, cfg_addr, val); in airoha_set_gdm_port()
981 static int airoha_set_gdm_ports(struct airoha_eth *eth, bool enable) in airoha_set_gdm_ports() argument
992 err = airoha_set_gdm_port(eth, port_list[i], enable); in airoha_set_gdm_ports()
1001 airoha_set_gdm_port(eth, port_list[i], false); in airoha_set_gdm_ports()
1006 static void airoha_fe_maccr_init(struct airoha_eth *eth) in airoha_fe_maccr_init() argument
1010 for (p = 1; p <= ARRAY_SIZE(eth->ports); p++) { in airoha_fe_maccr_init()
1011 airoha_fe_set(eth, REG_GDM_FWD_CFG(p), in airoha_fe_maccr_init()
1014 airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(p), in airoha_fe_maccr_init()
1016 airoha_fe_rmw(eth, REG_GDM_LEN_CFG(p), in airoha_fe_maccr_init()
1022 airoha_fe_rmw(eth, REG_CDM1_VLAN_CTRL, CDM1_VLAN_MASK, in airoha_fe_maccr_init()
1025 airoha_fe_set(eth, REG_FE_CPORT_CFG, FE_CPORT_PAD); in airoha_fe_maccr_init()
1028 static void airoha_fe_vip_setup(struct airoha_eth *eth) in airoha_fe_vip_setup() argument
1030 airoha_fe_wr(eth, REG_FE_VIP_PATN(3), ETH_P_PPP_DISC); in airoha_fe_vip_setup()
1031 airoha_fe_wr(eth, REG_FE_VIP_EN(3), PATN_FCPU_EN_MASK | PATN_EN_MASK); in airoha_fe_vip_setup()
1033 airoha_fe_wr(eth, REG_FE_VIP_PATN(4), PPP_LCP); in airoha_fe_vip_setup()
1034 airoha_fe_wr(eth, REG_FE_VIP_EN(4), in airoha_fe_vip_setup()
1038 airoha_fe_wr(eth, REG_FE_VIP_PATN(6), PPP_IPCP); in airoha_fe_vip_setup()
1039 airoha_fe_wr(eth, REG_FE_VIP_EN(6), in airoha_fe_vip_setup()
1043 airoha_fe_wr(eth, REG_FE_VIP_PATN(7), PPP_CHAP); in airoha_fe_vip_setup()
1044 airoha_fe_wr(eth, REG_FE_VIP_EN(7), in airoha_fe_vip_setup()
1049 airoha_fe_wr(eth, REG_FE_VIP_PATN(8), 0x43); in airoha_fe_vip_setup()
1050 airoha_fe_wr(eth, REG_FE_VIP_EN(8), in airoha_fe_vip_setup()
1055 airoha_fe_wr(eth, REG_FE_VIP_PATN(9), 0x44); in airoha_fe_vip_setup()
1056 airoha_fe_wr(eth, REG_FE_VIP_EN(9), in airoha_fe_vip_setup()
1061 airoha_fe_wr(eth, REG_FE_VIP_PATN(10), 0x1f401f4); in airoha_fe_vip_setup()
1062 airoha_fe_wr(eth, REG_FE_VIP_EN(10), in airoha_fe_vip_setup()
1066 airoha_fe_wr(eth, REG_FE_VIP_PATN(11), PPP_IPV6CP); in airoha_fe_vip_setup()
1067 airoha_fe_wr(eth, REG_FE_VIP_EN(11), in airoha_fe_vip_setup()
1072 airoha_fe_wr(eth, REG_FE_VIP_PATN(12), 0x2220223); in airoha_fe_vip_setup()
1073 airoha_fe_wr(eth, REG_FE_VIP_EN(12), in airoha_fe_vip_setup()
1077 airoha_fe_wr(eth, REG_FE_VIP_PATN(19), PPP_PAP); in airoha_fe_vip_setup()
1078 airoha_fe_wr(eth, REG_FE_VIP_EN(19), in airoha_fe_vip_setup()
1082 /* ETH->ETH_P_1905 (0x893a) */ in airoha_fe_vip_setup()
1083 airoha_fe_wr(eth, REG_FE_VIP_PATN(20), 0x893a); in airoha_fe_vip_setup()
1084 airoha_fe_wr(eth, REG_FE_VIP_EN(20), in airoha_fe_vip_setup()
1087 airoha_fe_wr(eth, REG_FE_VIP_PATN(21), ETH_P_LLDP); in airoha_fe_vip_setup()
1088 airoha_fe_wr(eth, REG_FE_VIP_EN(21), in airoha_fe_vip_setup()
1092 static u32 airoha_fe_get_pse_queue_rsv_pages(struct airoha_eth *eth, in airoha_fe_get_pse_queue_rsv_pages() argument
1097 airoha_fe_rmw(eth, REG_FE_PSE_QUEUE_CFG_WR, in airoha_fe_get_pse_queue_rsv_pages()
1101 val = airoha_fe_rr(eth, REG_FE_PSE_QUEUE_CFG_VAL); in airoha_fe_get_pse_queue_rsv_pages()
1106 static void airoha_fe_set_pse_queue_rsv_pages(struct airoha_eth *eth, in airoha_fe_set_pse_queue_rsv_pages() argument
1109 airoha_fe_rmw(eth, REG_FE_PSE_QUEUE_CFG_VAL, PSE_CFG_OQ_RSV_MASK, in airoha_fe_set_pse_queue_rsv_pages()
1111 airoha_fe_rmw(eth, REG_FE_PSE_QUEUE_CFG_WR, in airoha_fe_set_pse_queue_rsv_pages()
1119 static int airoha_fe_set_pse_oq_rsv(struct airoha_eth *eth, in airoha_fe_set_pse_oq_rsv() argument
1124 airoha_fe_set_pse_queue_rsv_pages(eth, port, queue, val); in airoha_fe_set_pse_oq_rsv()
1127 orig_val = airoha_fe_get_pse_queue_rsv_pages(eth, port, queue); in airoha_fe_set_pse_oq_rsv()
1128 tmp = airoha_fe_rr(eth, REG_FE_PSE_BUF_SET); in airoha_fe_set_pse_oq_rsv()
1131 airoha_fe_rmw(eth, REG_FE_PSE_BUF_SET, PSE_ALLRSV_MASK, in airoha_fe_set_pse_oq_rsv()
1135 tmp = airoha_fe_rr(eth, PSE_FQ_CFG); in airoha_fe_set_pse_oq_rsv()
1138 airoha_fe_rmw(eth, REG_PSE_SHARE_USED_THD, in airoha_fe_set_pse_oq_rsv()
1143 airoha_fe_rmw(eth, REG_PSE_SHARE_USED_THD, in airoha_fe_set_pse_oq_rsv()
1147 airoha_fe_rmw(eth, REG_FE_PSE_BUF_SET, in airoha_fe_set_pse_oq_rsv()
1154 static void airoha_fe_pse_ports_init(struct airoha_eth *eth) in airoha_fe_pse_ports_init() argument
1172 airoha_fe_set(eth, REG_FE_PSE_BUF_SET, in airoha_fe_pse_ports_init()
1177 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM1, q, in airoha_fe_pse_ports_init()
1181 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM1, q, in airoha_fe_pse_ports_init()
1185 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM2, q, 0); in airoha_fe_pse_ports_init()
1188 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM3, q, in airoha_fe_pse_ports_init()
1193 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE1, q, in airoha_fe_pse_ports_init()
1196 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE1, q, 0); in airoha_fe_pse_ports_init()
1200 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM2, q, in airoha_fe_pse_ports_init()
1204 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM3, q, 0); in airoha_fe_pse_ports_init()
1207 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM4, q, in airoha_fe_pse_ports_init()
1212 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2, q, in airoha_fe_pse_ports_init()
1215 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2, q, 0); in airoha_fe_pse_ports_init()
1219 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM4, q, in airoha_fe_pse_ports_init()
1223 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM5, q, in airoha_fe_pse_ports_init()
1227 static int airoha_fe_mc_vlan_clear(struct airoha_eth *eth) in airoha_fe_mc_vlan_clear() argument
1235 airoha_fe_wr(eth, REG_MC_VLAN_DATA, 0x0); in airoha_fe_mc_vlan_clear()
1239 airoha_fe_wr(eth, REG_MC_VLAN_CFG, val); in airoha_fe_mc_vlan_clear()
1243 false, eth, REG_MC_VLAN_CFG); in airoha_fe_mc_vlan_clear()
1248 airoha_fe_wr(eth, REG_MC_VLAN_DATA, 0x0); in airoha_fe_mc_vlan_clear()
1253 airoha_fe_wr(eth, REG_MC_VLAN_CFG, val); in airoha_fe_mc_vlan_clear()
1257 5 * USEC_PER_MSEC, false, eth, in airoha_fe_mc_vlan_clear()
1267 static void airoha_fe_crsn_qsel_init(struct airoha_eth *eth) in airoha_fe_crsn_qsel_init() argument
1270 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_22 >> 2), in airoha_fe_crsn_qsel_init()
1274 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_08 >> 2), in airoha_fe_crsn_qsel_init()
1278 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_21 >> 2), in airoha_fe_crsn_qsel_init()
1282 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_24 >> 2), in airoha_fe_crsn_qsel_init()
1286 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_25 >> 2), in airoha_fe_crsn_qsel_init()
1291 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_08 >> 2), in airoha_fe_crsn_qsel_init()
1295 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_21 >> 2), in airoha_fe_crsn_qsel_init()
1299 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_22 >> 2), in airoha_fe_crsn_qsel_init()
1303 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_24 >> 2), in airoha_fe_crsn_qsel_init()
1307 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_25 >> 2), in airoha_fe_crsn_qsel_init()
1313 static int airoha_fe_init(struct airoha_eth *eth) in airoha_fe_init() argument
1315 airoha_fe_maccr_init(eth); in airoha_fe_init()
1318 airoha_fe_rmw(eth, REG_PSE_IQ_REV1, PSE_IQ_RES1_P2_MASK, in airoha_fe_init()
1320 airoha_fe_rmw(eth, REG_PSE_IQ_REV2, in airoha_fe_init()
1326 airoha_fe_wr(eth, REG_FE_PCE_CFG, in airoha_fe_init()
1329 airoha_fe_rmw(eth, REG_CDM1_FWD_CFG, CDM1_VIP_QSEL_MASK, in airoha_fe_init()
1331 airoha_fe_rmw(eth, REG_CDM2_FWD_CFG, CDM2_VIP_QSEL_MASK, in airoha_fe_init()
1334 airoha_fe_rmw(eth, REG_GDM4_SRC_PORT_SET, in airoha_fe_init()
1343 airoha_fe_rmw(eth, REG_FE_DMA_GLO_CFG, in airoha_fe_init()
1347 airoha_fe_wr(eth, REG_FE_RST_GLO_CFG, in airoha_fe_init()
1355 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP0, BIT(4)); in airoha_fe_init()
1356 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP1, BIT(28)); in airoha_fe_init()
1357 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP2, BIT(4)); in airoha_fe_init()
1358 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP3, BIT(28)); in airoha_fe_init()
1360 airoha_fe_vip_setup(eth); in airoha_fe_init()
1361 airoha_fe_pse_ports_init(eth); in airoha_fe_init()
1363 airoha_fe_set(eth, REG_GDM_MISC_CFG, in airoha_fe_init()
1366 airoha_fe_rmw(eth, REG_CDM2_FWD_CFG, CDM2_OAM_QSEL_MASK, 15); in airoha_fe_init()
1370 airoha_fe_rmw(eth, REG_IP_FRAG_FP, in airoha_fe_init()
1375 airoha_fe_rmw(eth, REG_IP_FRAG_FP, in airoha_fe_init()
1380 airoha_fe_set(eth, REG_GDM3_FWD_CFG, GDM3_PAD_EN_MASK); in airoha_fe_init()
1381 airoha_fe_set(eth, REG_GDM4_FWD_CFG, GDM4_PAD_EN_MASK); in airoha_fe_init()
1383 airoha_fe_crsn_qsel_init(eth); in airoha_fe_init()
1385 airoha_fe_clear(eth, REG_FE_CPORT_CFG, FE_CPORT_QUEUE_XFC_MASK); in airoha_fe_init()
1386 airoha_fe_set(eth, REG_FE_CPORT_CFG, FE_CPORT_PORT_XFC_MASK); in airoha_fe_init()
1389 airoha_fe_rmw(eth, REG_GDM2_CHN_RLS, in airoha_fe_init()
1395 airoha_fe_clear(eth, REG_FE_CSR_IFC_CFG, FE_IFC_EN_MASK); in airoha_fe_init()
1398 airoha_fe_set(eth, REG_MC_VLAN_EN, MC_VLAN_EN_MASK); in airoha_fe_init()
1400 return airoha_fe_mc_vlan_clear(eth); in airoha_fe_init()
1407 struct airoha_eth *eth = qdma->eth; in airoha_qdma_fill_rx_queue() local
1431 dma_sync_single_for_device(eth->dev, e->dma_addr, e->dma_len, in airoha_qdma_fill_rx_queue()
1452 static int airoha_qdma_get_gdm_port(struct airoha_eth *eth, in airoha_qdma_get_gdm_port() argument
1469 return port >= ARRAY_SIZE(eth->ports) ? -EINVAL : port; in airoha_qdma_get_gdm_port()
1476 struct airoha_eth *eth = qdma->eth; in airoha_qdma_rx_process() local
1501 dma_sync_single_for_cpu(eth->dev, dma_addr, in airoha_qdma_rx_process()
1504 p = airoha_qdma_get_gdm_port(eth, desc); in airoha_qdma_rx_process()
1505 if (p < 0 || !eth->ports[p]) { in airoha_qdma_rx_process()
1523 skb->dev = eth->ports[p]->dev; in airoha_qdma_rx_process()
1563 .dev = qdma->eth->dev, in airoha_qdma_init_rx_queue()
1566 struct airoha_eth *eth = qdma->eth; in airoha_qdma_init_rx_queue() local
1574 q->entry = devm_kzalloc(eth->dev, q->ndesc * sizeof(*q->entry), in airoha_qdma_init_rx_queue()
1587 q->desc = dmam_alloc_coherent(eth->dev, q->ndesc * sizeof(*q->desc), in airoha_qdma_init_rx_queue()
1592 netif_napi_add(eth->napi_dev, &q->napi, airoha_qdma_rx_napi_poll); in airoha_qdma_init_rx_queue()
1612 struct airoha_eth *eth = q->qdma->eth; in airoha_qdma_cleanup_rx_queue() local
1618 dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len, in airoha_qdma_cleanup_rx_queue()
1651 struct airoha_eth *eth; in airoha_qdma_tx_napi_poll() local
1657 eth = qdma->eth; in airoha_qdma_tx_napi_poll()
1697 dma_unmap_single(eth->dev, e->dma_addr, e->dma_len, in airoha_qdma_tx_napi_poll()
1742 struct airoha_eth *eth = qdma->eth; in airoha_qdma_init_tx_queue() local
1751 q->entry = devm_kzalloc(eth->dev, q->ndesc * sizeof(*q->entry), in airoha_qdma_init_tx_queue()
1756 q->desc = dmam_alloc_coherent(eth->dev, q->ndesc * sizeof(*q->desc), in airoha_qdma_init_tx_queue()
1781 struct airoha_eth *eth = qdma->eth; in airoha_qdma_tx_irq_init() local
1784 netif_napi_add_tx(eth->napi_dev, &irq_q->napi, in airoha_qdma_tx_irq_init()
1786 irq_q->q = dmam_alloc_coherent(eth->dev, size * sizeof(u32), in airoha_qdma_tx_irq_init()
1827 struct airoha_eth *eth = q->qdma->eth; in airoha_qdma_cleanup_tx_queue() local
1833 dma_unmap_single(eth->dev, e->dma_addr, e->dma_len, in airoha_qdma_cleanup_tx_queue()
1846 struct airoha_eth *eth = qdma->eth; in airoha_qdma_init_hfwd_queues() local
1852 qdma->hfwd.desc = dmam_alloc_coherent(eth->dev, size, &dma_addr, in airoha_qdma_init_hfwd_queues()
1860 qdma->hfwd.q = dmam_alloc_coherent(eth->dev, size, &dma_addr, in airoha_qdma_init_hfwd_queues()
2000 if (!test_bit(DEV_STATE_INITIALIZED, &qdma->eth->state)) in airoha_irq_handler()
2040 struct airoha_eth *eth, in airoha_qdma_init() argument
2043 int err, id = qdma - ð->qdma[0]; in airoha_qdma_init()
2047 qdma->eth = eth; in airoha_qdma_init()
2049 res = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d", id); in airoha_qdma_init()
2055 return dev_err_probe(eth->dev, PTR_ERR(qdma->regs), in airoha_qdma_init()
2062 err = devm_request_irq(eth->dev, qdma->irq, airoha_irq_handler, in airoha_qdma_init()
2083 struct airoha_eth *eth) in airoha_hw_init() argument
2088 err = reset_control_bulk_assert(ARRAY_SIZE(eth->xsi_rsts), in airoha_hw_init()
2089 eth->xsi_rsts); in airoha_hw_init()
2093 err = reset_control_bulk_assert(ARRAY_SIZE(eth->rsts), eth->rsts); in airoha_hw_init()
2098 err = reset_control_bulk_deassert(ARRAY_SIZE(eth->rsts), eth->rsts); in airoha_hw_init()
2103 err = airoha_fe_init(eth); in airoha_hw_init()
2107 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) { in airoha_hw_init()
2108 err = airoha_qdma_init(pdev, eth, ð->qdma[i]); in airoha_hw_init()
2113 set_bit(DEV_STATE_INITIALIZED, ð->state); in airoha_hw_init()
2163 struct airoha_eth *eth = port->qdma->eth; in airoha_update_hw_stats() local
2170 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_PKT_CNT_H(port->id)); in airoha_update_hw_stats()
2172 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_PKT_CNT_L(port->id)); in airoha_update_hw_stats()
2175 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_BYTE_CNT_H(port->id)); in airoha_update_hw_stats()
2177 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_BYTE_CNT_L(port->id)); in airoha_update_hw_stats()
2180 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_DROP_CNT(port->id)); in airoha_update_hw_stats()
2183 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_BC_CNT(port->id)); in airoha_update_hw_stats()
2186 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_MC_CNT(port->id)); in airoha_update_hw_stats()
2189 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_RUNT_CNT(port->id)); in airoha_update_hw_stats()
2192 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_E64_CNT_H(port->id)); in airoha_update_hw_stats()
2194 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_E64_CNT_L(port->id)); in airoha_update_hw_stats()
2197 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L64_CNT_H(port->id)); in airoha_update_hw_stats()
2199 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L64_CNT_L(port->id)); in airoha_update_hw_stats()
2202 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L127_CNT_H(port->id)); in airoha_update_hw_stats()
2204 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L127_CNT_L(port->id)); in airoha_update_hw_stats()
2207 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L255_CNT_H(port->id)); in airoha_update_hw_stats()
2209 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L255_CNT_L(port->id)); in airoha_update_hw_stats()
2212 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L511_CNT_H(port->id)); in airoha_update_hw_stats()
2214 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L511_CNT_L(port->id)); in airoha_update_hw_stats()
2217 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L1023_CNT_H(port->id)); in airoha_update_hw_stats()
2219 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L1023_CNT_L(port->id)); in airoha_update_hw_stats()
2222 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_LONG_CNT(port->id)); in airoha_update_hw_stats()
2226 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_PKT_CNT_H(port->id)); in airoha_update_hw_stats()
2228 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_PKT_CNT_L(port->id)); in airoha_update_hw_stats()
2231 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_BYTE_CNT_H(port->id)); in airoha_update_hw_stats()
2233 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_BYTE_CNT_L(port->id)); in airoha_update_hw_stats()
2236 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_DROP_CNT(port->id)); in airoha_update_hw_stats()
2239 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_BC_CNT(port->id)); in airoha_update_hw_stats()
2242 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_MC_CNT(port->id)); in airoha_update_hw_stats()
2245 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ERROR_DROP_CNT(port->id)); in airoha_update_hw_stats()
2248 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_CRC_ERR_CNT(port->id)); in airoha_update_hw_stats()
2251 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OVERFLOW_DROP_CNT(port->id)); in airoha_update_hw_stats()
2254 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_FRAG_CNT(port->id)); in airoha_update_hw_stats()
2257 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_JABBER_CNT(port->id)); in airoha_update_hw_stats()
2261 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_RUNT_CNT(port->id)); in airoha_update_hw_stats()
2264 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_E64_CNT_H(port->id)); in airoha_update_hw_stats()
2266 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_E64_CNT_L(port->id)); in airoha_update_hw_stats()
2269 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L64_CNT_H(port->id)); in airoha_update_hw_stats()
2271 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L64_CNT_L(port->id)); in airoha_update_hw_stats()
2274 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L127_CNT_H(port->id)); in airoha_update_hw_stats()
2276 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L127_CNT_L(port->id)); in airoha_update_hw_stats()
2279 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L255_CNT_H(port->id)); in airoha_update_hw_stats()
2281 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L255_CNT_L(port->id)); in airoha_update_hw_stats()
2284 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L511_CNT_H(port->id)); in airoha_update_hw_stats()
2286 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L511_CNT_L(port->id)); in airoha_update_hw_stats()
2289 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L1023_CNT_H(port->id)); in airoha_update_hw_stats()
2291 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L1023_CNT_L(port->id)); in airoha_update_hw_stats()
2294 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_LONG_CNT(port->id)); in airoha_update_hw_stats()
2298 airoha_fe_set(eth, REG_FE_GDM_MIB_CLEAR(port->id), in airoha_update_hw_stats()
2312 err = airoha_set_gdm_ports(qdma->eth, true); in airoha_dev_open()
2317 airoha_fe_set(qdma->eth, REG_GDM_INGRESS_CFG(port->id), in airoha_dev_open()
2320 airoha_fe_clear(qdma->eth, REG_GDM_INGRESS_CFG(port->id), in airoha_dev_open()
2337 err = airoha_set_gdm_ports(qdma->eth, false); in airoha_dev_stop()
2513 struct airoha_eth *eth = port->qdma->eth; in airoha_ethtool_get_drvinfo() local
2515 strscpy(info->driver, eth->dev->driver->name, sizeof(info->driver)); in airoha_ethtool_get_drvinfo()
2516 strscpy(info->bus_info, dev_name(eth->dev), sizeof(info->bus_info)); in airoha_ethtool_get_drvinfo()
2590 static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np) in airoha_alloc_gdm_port() argument
2600 dev_err(eth->dev, "missing gdm port id\n"); in airoha_alloc_gdm_port()
2607 if (!id || id > ARRAY_SIZE(eth->ports)) { in airoha_alloc_gdm_port()
2608 dev_err(eth->dev, "invalid gdm port id: %d\n", id); in airoha_alloc_gdm_port()
2612 if (eth->ports[index]) { in airoha_alloc_gdm_port()
2613 dev_err(eth->dev, "duplicate gdm port id: %d\n", id); in airoha_alloc_gdm_port()
2617 dev = devm_alloc_etherdev_mqs(eth->dev, sizeof(*port), in airoha_alloc_gdm_port()
2620 dev_err(eth->dev, "alloc_etherdev failed\n"); in airoha_alloc_gdm_port()
2624 qdma = ð->qdma[index % AIROHA_MAX_NUM_QDMA]; in airoha_alloc_gdm_port()
2635 SET_NETDEV_DEV(dev, eth->dev); in airoha_alloc_gdm_port()
2643 dev_info(eth->dev, "generated random MAC address %pM\n", in airoha_alloc_gdm_port()
2653 eth->ports[index] = port; in airoha_alloc_gdm_port()
2661 struct airoha_eth *eth; in airoha_probe() local
2664 eth = devm_kzalloc(&pdev->dev, sizeof(*eth), GFP_KERNEL); in airoha_probe()
2665 if (!eth) in airoha_probe()
2668 eth->dev = &pdev->dev; in airoha_probe()
2670 err = dma_set_mask_and_coherent(eth->dev, DMA_BIT_MASK(32)); in airoha_probe()
2672 dev_err(eth->dev, "failed configuring DMA mask\n"); in airoha_probe()
2676 eth->fe_regs = devm_platform_ioremap_resource_byname(pdev, "fe"); in airoha_probe()
2677 if (IS_ERR(eth->fe_regs)) in airoha_probe()
2678 return dev_err_probe(eth->dev, PTR_ERR(eth->fe_regs), in airoha_probe()
2681 eth->rsts[0].id = "fe"; in airoha_probe()
2682 eth->rsts[1].id = "pdma"; in airoha_probe()
2683 eth->rsts[2].id = "qdma"; in airoha_probe()
2684 err = devm_reset_control_bulk_get_exclusive(eth->dev, in airoha_probe()
2685 ARRAY_SIZE(eth->rsts), in airoha_probe()
2686 eth->rsts); in airoha_probe()
2688 dev_err(eth->dev, "failed to get bulk reset lines\n"); in airoha_probe()
2692 eth->xsi_rsts[0].id = "xsi-mac"; in airoha_probe()
2693 eth->xsi_rsts[1].id = "hsi0-mac"; in airoha_probe()
2694 eth->xsi_rsts[2].id = "hsi1-mac"; in airoha_probe()
2695 eth->xsi_rsts[3].id = "hsi-mac"; in airoha_probe()
2696 eth->xsi_rsts[4].id = "xfp-mac"; in airoha_probe()
2697 err = devm_reset_control_bulk_get_exclusive(eth->dev, in airoha_probe()
2698 ARRAY_SIZE(eth->xsi_rsts), in airoha_probe()
2699 eth->xsi_rsts); in airoha_probe()
2701 dev_err(eth->dev, "failed to get bulk xsi reset lines\n"); in airoha_probe()
2705 eth->napi_dev = alloc_netdev_dummy(0); in airoha_probe()
2706 if (!eth->napi_dev) in airoha_probe()
2710 eth->napi_dev->threaded = true; in airoha_probe()
2711 strscpy(eth->napi_dev->name, "qdma_eth", sizeof(eth->napi_dev->name)); in airoha_probe()
2712 platform_set_drvdata(pdev, eth); in airoha_probe()
2714 err = airoha_hw_init(pdev, eth); in airoha_probe()
2718 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) in airoha_probe()
2719 airoha_qdma_start_napi(ð->qdma[i]); in airoha_probe()
2722 if (!of_device_is_compatible(np, "airoha,eth-mac")) in airoha_probe()
2728 err = airoha_alloc_gdm_port(eth, np); in airoha_probe()
2738 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) in airoha_probe()
2739 airoha_hw_cleanup(ð->qdma[i]); in airoha_probe()
2741 for (i = 0; i < ARRAY_SIZE(eth->ports); i++) { in airoha_probe()
2742 struct airoha_gdm_port *port = eth->ports[i]; in airoha_probe()
2747 free_netdev(eth->napi_dev); in airoha_probe()
2755 struct airoha_eth *eth = platform_get_drvdata(pdev); in airoha_remove() local
2758 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) in airoha_remove()
2759 airoha_hw_cleanup(ð->qdma[i]); in airoha_remove()
2761 for (i = 0; i < ARRAY_SIZE(eth->ports); i++) { in airoha_remove()
2762 struct airoha_gdm_port *port = eth->ports[i]; in airoha_remove()
2770 free_netdev(eth->napi_dev); in airoha_remove()
2776 { .compatible = "airoha,en7581-eth" },