Lines Matching full:eth

76 	struct airoha_eth *eth = port->qdma->eth;  in airoha_set_macaddr()  local
82 airoha_fe_wr(eth, reg, val); in airoha_set_macaddr()
85 airoha_fe_wr(eth, REG_FE_MAC_LMIN(reg), val); in airoha_set_macaddr()
86 airoha_fe_wr(eth, REG_FE_MAC_LMAX(reg), val); in airoha_set_macaddr()
91 static void airoha_set_gdm_port_fwd_cfg(struct airoha_eth *eth, u32 addr, in airoha_set_gdm_port_fwd_cfg() argument
94 airoha_fe_rmw(eth, addr, GDM_OCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
96 airoha_fe_rmw(eth, addr, GDM_MCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
98 airoha_fe_rmw(eth, addr, GDM_BCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
100 airoha_fe_rmw(eth, addr, GDM_UCFQ_MASK, in airoha_set_gdm_port_fwd_cfg()
107 struct airoha_eth *eth = port->qdma->eth; in airoha_set_vip_for_gdm_port() local
124 airoha_fe_set(eth, REG_FE_VIP_PORT_EN, vip_port); in airoha_set_vip_for_gdm_port()
125 airoha_fe_set(eth, REG_FE_IFC_PORT_EN, vip_port); in airoha_set_vip_for_gdm_port()
127 airoha_fe_clear(eth, REG_FE_VIP_PORT_EN, vip_port); in airoha_set_vip_for_gdm_port()
128 airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, vip_port); in airoha_set_vip_for_gdm_port()
134 static void airoha_fe_maccr_init(struct airoha_eth *eth) in airoha_fe_maccr_init() argument
138 for (p = 1; p <= ARRAY_SIZE(eth->ports); p++) in airoha_fe_maccr_init()
139 airoha_fe_set(eth, REG_GDM_FWD_CFG(p), in airoha_fe_maccr_init()
143 airoha_fe_rmw(eth, REG_CDM1_VLAN_CTRL, CDM1_VLAN_MASK, in airoha_fe_maccr_init()
146 airoha_fe_set(eth, REG_FE_CPORT_CFG, FE_CPORT_PAD); in airoha_fe_maccr_init()
149 static void airoha_fe_vip_setup(struct airoha_eth *eth) in airoha_fe_vip_setup() argument
151 airoha_fe_wr(eth, REG_FE_VIP_PATN(3), ETH_P_PPP_DISC); in airoha_fe_vip_setup()
152 airoha_fe_wr(eth, REG_FE_VIP_EN(3), PATN_FCPU_EN_MASK | PATN_EN_MASK); in airoha_fe_vip_setup()
154 airoha_fe_wr(eth, REG_FE_VIP_PATN(4), PPP_LCP); in airoha_fe_vip_setup()
155 airoha_fe_wr(eth, REG_FE_VIP_EN(4), in airoha_fe_vip_setup()
159 airoha_fe_wr(eth, REG_FE_VIP_PATN(6), PPP_IPCP); in airoha_fe_vip_setup()
160 airoha_fe_wr(eth, REG_FE_VIP_EN(6), in airoha_fe_vip_setup()
164 airoha_fe_wr(eth, REG_FE_VIP_PATN(7), PPP_CHAP); in airoha_fe_vip_setup()
165 airoha_fe_wr(eth, REG_FE_VIP_EN(7), in airoha_fe_vip_setup()
170 airoha_fe_wr(eth, REG_FE_VIP_PATN(8), 0x43); in airoha_fe_vip_setup()
171 airoha_fe_wr(eth, REG_FE_VIP_EN(8), in airoha_fe_vip_setup()
176 airoha_fe_wr(eth, REG_FE_VIP_PATN(9), 0x44); in airoha_fe_vip_setup()
177 airoha_fe_wr(eth, REG_FE_VIP_EN(9), in airoha_fe_vip_setup()
182 airoha_fe_wr(eth, REG_FE_VIP_PATN(10), 0x1f401f4); in airoha_fe_vip_setup()
183 airoha_fe_wr(eth, REG_FE_VIP_EN(10), in airoha_fe_vip_setup()
187 airoha_fe_wr(eth, REG_FE_VIP_PATN(11), PPP_IPV6CP); in airoha_fe_vip_setup()
188 airoha_fe_wr(eth, REG_FE_VIP_EN(11), in airoha_fe_vip_setup()
193 airoha_fe_wr(eth, REG_FE_VIP_PATN(12), 0x2220223); in airoha_fe_vip_setup()
194 airoha_fe_wr(eth, REG_FE_VIP_EN(12), in airoha_fe_vip_setup()
198 airoha_fe_wr(eth, REG_FE_VIP_PATN(19), PPP_PAP); in airoha_fe_vip_setup()
199 airoha_fe_wr(eth, REG_FE_VIP_EN(19), in airoha_fe_vip_setup()
203 /* ETH->ETH_P_1905 (0x893a) */ in airoha_fe_vip_setup()
204 airoha_fe_wr(eth, REG_FE_VIP_PATN(20), 0x893a); in airoha_fe_vip_setup()
205 airoha_fe_wr(eth, REG_FE_VIP_EN(20), in airoha_fe_vip_setup()
208 airoha_fe_wr(eth, REG_FE_VIP_PATN(21), ETH_P_LLDP); in airoha_fe_vip_setup()
209 airoha_fe_wr(eth, REG_FE_VIP_EN(21), in airoha_fe_vip_setup()
213 static u32 airoha_fe_get_pse_queue_rsv_pages(struct airoha_eth *eth, in airoha_fe_get_pse_queue_rsv_pages() argument
218 airoha_fe_rmw(eth, REG_FE_PSE_QUEUE_CFG_WR, in airoha_fe_get_pse_queue_rsv_pages()
222 val = airoha_fe_rr(eth, REG_FE_PSE_QUEUE_CFG_VAL); in airoha_fe_get_pse_queue_rsv_pages()
227 static void airoha_fe_set_pse_queue_rsv_pages(struct airoha_eth *eth, in airoha_fe_set_pse_queue_rsv_pages() argument
230 airoha_fe_rmw(eth, REG_FE_PSE_QUEUE_CFG_VAL, PSE_CFG_OQ_RSV_MASK, in airoha_fe_set_pse_queue_rsv_pages()
232 airoha_fe_rmw(eth, REG_FE_PSE_QUEUE_CFG_WR, in airoha_fe_set_pse_queue_rsv_pages()
240 static u32 airoha_fe_get_pse_all_rsv(struct airoha_eth *eth) in airoha_fe_get_pse_all_rsv() argument
242 u32 val = airoha_fe_rr(eth, REG_FE_PSE_BUF_SET); in airoha_fe_get_pse_all_rsv()
247 static int airoha_fe_set_pse_oq_rsv(struct airoha_eth *eth, in airoha_fe_set_pse_oq_rsv() argument
250 u32 orig_val = airoha_fe_get_pse_queue_rsv_pages(eth, port, queue); in airoha_fe_set_pse_oq_rsv()
253 airoha_fe_set_pse_queue_rsv_pages(eth, port, queue, val); in airoha_fe_set_pse_oq_rsv()
256 all_rsv = airoha_fe_get_pse_all_rsv(eth); in airoha_fe_set_pse_oq_rsv()
258 airoha_fe_rmw(eth, REG_FE_PSE_BUF_SET, PSE_ALLRSV_MASK, in airoha_fe_set_pse_oq_rsv()
262 tmp = airoha_fe_rr(eth, PSE_FQ_CFG); in airoha_fe_set_pse_oq_rsv()
265 airoha_fe_rmw(eth, REG_PSE_SHARE_USED_THD, in airoha_fe_set_pse_oq_rsv()
270 airoha_fe_rmw(eth, REG_PSE_SHARE_USED_THD, in airoha_fe_set_pse_oq_rsv()
274 airoha_fe_rmw(eth, REG_FE_PSE_BUF_SET, in airoha_fe_set_pse_oq_rsv()
281 static void airoha_fe_pse_ports_init(struct airoha_eth *eth) in airoha_fe_pse_ports_init() argument
299 all_rsv = airoha_fe_get_pse_all_rsv(eth); in airoha_fe_pse_ports_init()
302 airoha_fe_set(eth, REG_FE_PSE_BUF_SET, all_rsv); in airoha_fe_pse_ports_init()
306 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM1, q, in airoha_fe_pse_ports_init()
310 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM1, q, in airoha_fe_pse_ports_init()
314 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM2, q, 0); in airoha_fe_pse_ports_init()
317 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM3, q, in airoha_fe_pse_ports_init()
322 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE1, q, in airoha_fe_pse_ports_init()
325 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE1, q, 0); in airoha_fe_pse_ports_init()
329 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM2, q, in airoha_fe_pse_ports_init()
333 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM3, q, 0); in airoha_fe_pse_ports_init()
336 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM4, q, in airoha_fe_pse_ports_init()
341 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2, q, in airoha_fe_pse_ports_init()
344 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2, q, 0); in airoha_fe_pse_ports_init()
348 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_GDM4, q, in airoha_fe_pse_ports_init()
352 airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM5, q, in airoha_fe_pse_ports_init()
356 static int airoha_fe_mc_vlan_clear(struct airoha_eth *eth) in airoha_fe_mc_vlan_clear() argument
364 airoha_fe_wr(eth, REG_MC_VLAN_DATA, 0x0); in airoha_fe_mc_vlan_clear()
368 airoha_fe_wr(eth, REG_MC_VLAN_CFG, val); in airoha_fe_mc_vlan_clear()
372 false, eth, REG_MC_VLAN_CFG); in airoha_fe_mc_vlan_clear()
377 airoha_fe_wr(eth, REG_MC_VLAN_DATA, 0x0); in airoha_fe_mc_vlan_clear()
382 airoha_fe_wr(eth, REG_MC_VLAN_CFG, val); in airoha_fe_mc_vlan_clear()
386 5 * USEC_PER_MSEC, false, eth, in airoha_fe_mc_vlan_clear()
396 static void airoha_fe_crsn_qsel_init(struct airoha_eth *eth) in airoha_fe_crsn_qsel_init() argument
399 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_22 >> 2), in airoha_fe_crsn_qsel_init()
403 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_08 >> 2), in airoha_fe_crsn_qsel_init()
407 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_21 >> 2), in airoha_fe_crsn_qsel_init()
411 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_24 >> 2), in airoha_fe_crsn_qsel_init()
415 airoha_fe_rmw(eth, REG_CDM1_CRSN_QSEL(CRSN_25 >> 2), in airoha_fe_crsn_qsel_init()
420 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_08 >> 2), in airoha_fe_crsn_qsel_init()
424 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_21 >> 2), in airoha_fe_crsn_qsel_init()
428 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_22 >> 2), in airoha_fe_crsn_qsel_init()
432 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_24 >> 2), in airoha_fe_crsn_qsel_init()
436 airoha_fe_rmw(eth, REG_CDM2_CRSN_QSEL(CRSN_25 >> 2), in airoha_fe_crsn_qsel_init()
442 static int airoha_fe_init(struct airoha_eth *eth) in airoha_fe_init() argument
444 airoha_fe_maccr_init(eth); in airoha_fe_init()
447 airoha_fe_rmw(eth, REG_PSE_IQ_REV1, PSE_IQ_RES1_P2_MASK, in airoha_fe_init()
449 airoha_fe_rmw(eth, REG_PSE_IQ_REV2, in airoha_fe_init()
455 airoha_fe_wr(eth, REG_FE_PCE_CFG, in airoha_fe_init()
458 airoha_fe_rmw(eth, REG_CDM1_FWD_CFG, CDM1_VIP_QSEL_MASK, in airoha_fe_init()
460 airoha_fe_rmw(eth, REG_CDM2_FWD_CFG, CDM2_VIP_QSEL_MASK, in airoha_fe_init()
463 airoha_fe_rmw(eth, REG_GDM4_SRC_PORT_SET, in airoha_fe_init()
472 airoha_fe_rmw(eth, REG_FE_DMA_GLO_CFG, in airoha_fe_init()
476 airoha_fe_wr(eth, REG_FE_RST_GLO_CFG, in airoha_fe_init()
484 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP0, BIT(4)); in airoha_fe_init()
485 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP1, BIT(28)); in airoha_fe_init()
486 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP2, BIT(4)); in airoha_fe_init()
487 airoha_fe_wr(eth, REG_FE_CDM1_OQ_MAP3, BIT(28)); in airoha_fe_init()
489 airoha_fe_vip_setup(eth); in airoha_fe_init()
490 airoha_fe_pse_ports_init(eth); in airoha_fe_init()
492 airoha_fe_set(eth, REG_GDM_MISC_CFG, in airoha_fe_init()
495 airoha_fe_rmw(eth, REG_CDM2_FWD_CFG, CDM2_OAM_QSEL_MASK, in airoha_fe_init()
500 airoha_fe_rmw(eth, REG_IP_FRAG_FP, in airoha_fe_init()
505 airoha_fe_rmw(eth, REG_IP_FRAG_FP, in airoha_fe_init()
510 airoha_fe_set(eth, REG_GDM3_FWD_CFG, GDM3_PAD_EN_MASK); in airoha_fe_init()
511 airoha_fe_set(eth, REG_GDM4_FWD_CFG, GDM4_PAD_EN_MASK); in airoha_fe_init()
513 airoha_fe_crsn_qsel_init(eth); in airoha_fe_init()
515 airoha_fe_clear(eth, REG_FE_CPORT_CFG, FE_CPORT_QUEUE_XFC_MASK); in airoha_fe_init()
516 airoha_fe_set(eth, REG_FE_CPORT_CFG, FE_CPORT_PORT_XFC_MASK); in airoha_fe_init()
519 airoha_fe_rmw(eth, REG_GDM2_CHN_RLS, in airoha_fe_init()
525 airoha_fe_clear(eth, REG_FE_CSR_IFC_CFG, FE_IFC_EN_MASK); in airoha_fe_init()
527 airoha_fe_wr(eth, REG_PPE_DFT_CPORT0(0), in airoha_fe_init()
536 airoha_fe_wr(eth, REG_PPE_DFT_CPORT0(1), in airoha_fe_init()
547 airoha_fe_set(eth, REG_MC_VLAN_EN, MC_VLAN_EN_MASK); in airoha_fe_init()
549 return airoha_fe_mc_vlan_clear(eth); in airoha_fe_init()
596 static int airoha_qdma_get_gdm_port(struct airoha_eth *eth, in airoha_qdma_get_gdm_port() argument
613 return port >= ARRAY_SIZE(eth->ports) ? -EINVAL : port; in airoha_qdma_get_gdm_port()
620 struct airoha_eth *eth = qdma->eth; in airoha_qdma_rx_process() local
639 dma_sync_single_for_cpu(eth->dev, e->dma_addr, in airoha_qdma_rx_process()
648 p = airoha_qdma_get_gdm_port(eth, desc); in airoha_qdma_rx_process()
649 if (p < 0 || !eth->ports[p]) in airoha_qdma_rx_process()
652 port = eth->ports[p]; in airoha_qdma_rx_process()
701 airoha_ppe_check_skb(&eth->ppe->dev, q->skb, hash, in airoha_qdma_rx_process()
759 .dev = qdma->eth->dev, in airoha_qdma_init_rx_queue()
762 struct airoha_eth *eth = qdma->eth; in airoha_qdma_init_rx_queue() local
770 q->entry = devm_kzalloc(eth->dev, q->ndesc * sizeof(*q->entry), in airoha_qdma_init_rx_queue()
783 q->desc = dmam_alloc_coherent(eth->dev, q->ndesc * sizeof(*q->desc), in airoha_qdma_init_rx_queue()
788 netif_napi_add(eth->napi_dev, &q->napi, airoha_qdma_rx_napi_poll); in airoha_qdma_init_rx_queue()
809 struct airoha_eth *eth = q->qdma->eth; in airoha_qdma_cleanup_rx_queue() local
815 dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len, in airoha_qdma_cleanup_rx_queue()
849 struct airoha_eth *eth; in airoha_qdma_tx_napi_poll() local
855 eth = qdma->eth; in airoha_qdma_tx_napi_poll()
905 dma_unmap_single(eth->dev, e->dma_addr, e->dma_len, in airoha_qdma_tx_napi_poll()
956 struct airoha_eth *eth = qdma->eth; in airoha_qdma_init_tx_queue() local
965 q->entry = devm_kzalloc(eth->dev, q->ndesc * sizeof(*q->entry), in airoha_qdma_init_tx_queue()
970 q->desc = dmam_alloc_coherent(eth->dev, q->ndesc * sizeof(*q->desc), in airoha_qdma_init_tx_queue()
999 struct airoha_eth *eth = qdma->eth; in airoha_qdma_tx_irq_init() local
1002 netif_napi_add_tx(eth->napi_dev, &irq_q->napi, in airoha_qdma_tx_irq_init()
1004 irq_q->q = dmam_alloc_coherent(eth->dev, size * sizeof(u32), in airoha_qdma_tx_irq_init()
1045 struct airoha_eth *eth = q->qdma->eth; in airoha_qdma_cleanup_tx_queue() local
1051 dma_unmap_single(eth->dev, e->dma_addr, e->dma_len, in airoha_qdma_cleanup_tx_queue()
1065 struct airoha_eth *eth = qdma->eth; in airoha_qdma_init_hfwd_queues() local
1066 int id = qdma - &eth->qdma[0]; in airoha_qdma_init_hfwd_queues()
1071 name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id); in airoha_qdma_init_hfwd_queues()
1076 index = of_property_match_string(eth->dev->of_node, in airoha_qdma_init_hfwd_queues()
1085 np = of_parse_phandle(eth->dev->of_node, "memory-region", in airoha_qdma_init_hfwd_queues()
1099 if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, in airoha_qdma_init_hfwd_queues()
1107 if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL)) in airoha_qdma_init_hfwd_queues()
1278 if (!test_bit(DEV_STATE_INITIALIZED, &qdma->eth->state)) in airoha_irq_handler()
1318 struct airoha_eth *eth = qdma->eth; in airoha_qdma_init_irq_banks() local
1319 int i, id = qdma - &eth->qdma[0]; in airoha_qdma_init_irq_banks()
1333 name = devm_kasprintf(eth->dev, GFP_KERNEL, in airoha_qdma_init_irq_banks()
1338 err = devm_request_irq(eth->dev, irq_bank->irq, in airoha_qdma_init_irq_banks()
1349 struct airoha_eth *eth, in airoha_qdma_init() argument
1352 int err, id = qdma - &eth->qdma[0]; in airoha_qdma_init()
1355 qdma->eth = eth; in airoha_qdma_init()
1356 res = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d", id); in airoha_qdma_init()
1362 return dev_err_probe(eth->dev, PTR_ERR(qdma->regs), in airoha_qdma_init()
1385 struct airoha_eth *eth) in airoha_hw_init() argument
1390 err = reset_control_bulk_assert(ARRAY_SIZE(eth->xsi_rsts), in airoha_hw_init()
1391 eth->xsi_rsts); in airoha_hw_init()
1395 err = reset_control_bulk_assert(ARRAY_SIZE(eth->rsts), eth->rsts); in airoha_hw_init()
1400 err = reset_control_bulk_deassert(ARRAY_SIZE(eth->rsts), eth->rsts); in airoha_hw_init()
1405 err = airoha_fe_init(eth); in airoha_hw_init()
1409 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) { in airoha_hw_init()
1410 err = airoha_qdma_init(pdev, eth, &eth->qdma[i]); in airoha_hw_init()
1415 err = airoha_ppe_init(eth); in airoha_hw_init()
1419 set_bit(DEV_STATE_INITIALIZED, &eth->state); in airoha_hw_init()
1481 struct airoha_eth *eth = port->qdma->eth; in airoha_update_hw_stats() local
1488 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_PKT_CNT_H(port->id)); in airoha_update_hw_stats()
1490 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_PKT_CNT_L(port->id)); in airoha_update_hw_stats()
1493 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_BYTE_CNT_H(port->id)); in airoha_update_hw_stats()
1495 val = airoha_fe_rr(eth, REG_FE_GDM_TX_OK_BYTE_CNT_L(port->id)); in airoha_update_hw_stats()
1498 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_DROP_CNT(port->id)); in airoha_update_hw_stats()
1501 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_BC_CNT(port->id)); in airoha_update_hw_stats()
1504 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_MC_CNT(port->id)); in airoha_update_hw_stats()
1507 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_RUNT_CNT(port->id)); in airoha_update_hw_stats()
1510 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_E64_CNT_H(port->id)); in airoha_update_hw_stats()
1512 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_E64_CNT_L(port->id)); in airoha_update_hw_stats()
1515 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L64_CNT_H(port->id)); in airoha_update_hw_stats()
1517 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L64_CNT_L(port->id)); in airoha_update_hw_stats()
1520 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L127_CNT_H(port->id)); in airoha_update_hw_stats()
1522 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L127_CNT_L(port->id)); in airoha_update_hw_stats()
1525 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L255_CNT_H(port->id)); in airoha_update_hw_stats()
1527 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L255_CNT_L(port->id)); in airoha_update_hw_stats()
1530 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L511_CNT_H(port->id)); in airoha_update_hw_stats()
1532 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L511_CNT_L(port->id)); in airoha_update_hw_stats()
1535 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L1023_CNT_H(port->id)); in airoha_update_hw_stats()
1537 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_L1023_CNT_L(port->id)); in airoha_update_hw_stats()
1540 val = airoha_fe_rr(eth, REG_FE_GDM_TX_ETH_LONG_CNT(port->id)); in airoha_update_hw_stats()
1544 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_PKT_CNT_H(port->id)); in airoha_update_hw_stats()
1546 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_PKT_CNT_L(port->id)); in airoha_update_hw_stats()
1549 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_BYTE_CNT_H(port->id)); in airoha_update_hw_stats()
1551 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OK_BYTE_CNT_L(port->id)); in airoha_update_hw_stats()
1554 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_DROP_CNT(port->id)); in airoha_update_hw_stats()
1557 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_BC_CNT(port->id)); in airoha_update_hw_stats()
1560 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_MC_CNT(port->id)); in airoha_update_hw_stats()
1563 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ERROR_DROP_CNT(port->id)); in airoha_update_hw_stats()
1566 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_CRC_ERR_CNT(port->id)); in airoha_update_hw_stats()
1569 val = airoha_fe_rr(eth, REG_FE_GDM_RX_OVERFLOW_DROP_CNT(port->id)); in airoha_update_hw_stats()
1572 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_FRAG_CNT(port->id)); in airoha_update_hw_stats()
1575 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_JABBER_CNT(port->id)); in airoha_update_hw_stats()
1579 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_RUNT_CNT(port->id)); in airoha_update_hw_stats()
1582 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_E64_CNT_H(port->id)); in airoha_update_hw_stats()
1584 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_E64_CNT_L(port->id)); in airoha_update_hw_stats()
1587 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L64_CNT_H(port->id)); in airoha_update_hw_stats()
1589 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L64_CNT_L(port->id)); in airoha_update_hw_stats()
1592 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L127_CNT_H(port->id)); in airoha_update_hw_stats()
1594 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L127_CNT_L(port->id)); in airoha_update_hw_stats()
1597 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L255_CNT_H(port->id)); in airoha_update_hw_stats()
1599 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L255_CNT_L(port->id)); in airoha_update_hw_stats()
1602 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L511_CNT_H(port->id)); in airoha_update_hw_stats()
1604 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L511_CNT_L(port->id)); in airoha_update_hw_stats()
1607 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L1023_CNT_H(port->id)); in airoha_update_hw_stats()
1609 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_L1023_CNT_L(port->id)); in airoha_update_hw_stats()
1612 val = airoha_fe_rr(eth, REG_FE_GDM_RX_ETH_LONG_CNT(port->id)); in airoha_update_hw_stats()
1616 airoha_fe_set(eth, REG_FE_GDM_MIB_CLEAR(port->id), in airoha_update_hw_stats()
1635 airoha_fe_set(qdma->eth, REG_GDM_INGRESS_CFG(port->id), in airoha_dev_open()
1638 airoha_fe_clear(qdma->eth, REG_GDM_INGRESS_CFG(port->id), in airoha_dev_open()
1641 airoha_fe_rmw(qdma->eth, REG_GDM_LEN_CFG(port->id), in airoha_dev_open()
1701 struct airoha_eth *eth = port->qdma->eth; in airhoha_set_gdm2_loopback() local
1705 airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(2), pse_port); in airhoha_set_gdm2_loopback()
1706 airoha_fe_clear(eth, REG_GDM_FWD_CFG(2), GDM_STRIP_CRC); in airhoha_set_gdm2_loopback()
1709 airoha_fe_wr(eth, REG_GDM_TXCHN_EN(2), 0xffffffff); in airhoha_set_gdm2_loopback()
1710 airoha_fe_wr(eth, REG_GDM_RXCHN_EN(2), 0xffff); in airhoha_set_gdm2_loopback()
1711 airoha_fe_rmw(eth, REG_GDM_LPBK_CFG(2), in airhoha_set_gdm2_loopback()
1716 airoha_fe_rmw(eth, REG_GDM_LEN_CFG(2), in airhoha_set_gdm2_loopback()
1722 airoha_fe_clear(eth, REG_FE_VIP_PORT_EN, BIT(2)); in airhoha_set_gdm2_loopback()
1723 airoha_fe_clear(eth, REG_FE_IFC_PORT_EN, BIT(2)); in airhoha_set_gdm2_loopback()
1727 airoha_fe_rmw(eth, REG_FE_WAN_PORT, in airhoha_set_gdm2_loopback()
1730 airoha_fe_rmw(eth, in airhoha_set_gdm2_loopback()
1737 airoha_fe_rmw(eth, REG_SRC_PORT_FC_MAP6, in airhoha_set_gdm2_loopback()
1740 airoha_fe_rmw(eth, REG_FE_WAN_PORT, in airhoha_set_gdm2_loopback()
1743 airoha_fe_rmw(eth, in airhoha_set_gdm2_loopback()
1753 struct airoha_eth *eth = port->qdma->eth; in airoha_dev_init() local
1762 if (!eth->ports[1]) in airoha_dev_init()
1773 airoha_set_gdm_port_fwd_cfg(eth, REG_GDM_FWD_CFG(port->id), pse_port); in airoha_dev_init()
1803 struct airoha_eth *eth = port->qdma->eth; in airoha_dev_change_mtu() local
1806 airoha_fe_rmw(eth, REG_GDM_LEN_CFG(port->id), in airoha_dev_change_mtu()
2024 struct airoha_eth *eth = port->qdma->eth; in airoha_ethtool_get_drvinfo() local
2026 strscpy(info->driver, eth->dev->driver->name, sizeof(info->driver)); in airoha_ethtool_get_drvinfo()
2027 strscpy(info->bus_info, dev_name(eth->dev), sizeof(info->bus_info)); in airoha_ethtool_get_drvinfo()
2620 struct airoha_eth *eth = port->qdma->eth; in airoha_dev_setup_tc_block_cb() local
2627 return airoha_ppe_setup_tc_block_cb(&eth->ppe->dev, type_data); in airoha_dev_setup_tc_block_cb()
2816 bool airoha_is_valid_gdm_port(struct airoha_eth *eth, in airoha_is_valid_gdm_port() argument
2821 for (i = 0; i < ARRAY_SIZE(eth->ports); i++) { in airoha_is_valid_gdm_port()
2822 if (eth->ports[i] == port) in airoha_is_valid_gdm_port()
2829 static int airoha_alloc_gdm_port(struct airoha_eth *eth, in airoha_alloc_gdm_port() argument
2840 dev_err(eth->dev, "missing gdm port id\n"); in airoha_alloc_gdm_port()
2847 if (!id || id > ARRAY_SIZE(eth->ports)) { in airoha_alloc_gdm_port()
2848 dev_err(eth->dev, "invalid gdm port id: %d\n", id); in airoha_alloc_gdm_port()
2852 if (eth->ports[p]) { in airoha_alloc_gdm_port()
2853 dev_err(eth->dev, "duplicate gdm port id: %d\n", id); in airoha_alloc_gdm_port()
2857 dev = devm_alloc_etherdev_mqs(eth->dev, sizeof(*port), in airoha_alloc_gdm_port()
2861 dev_err(eth->dev, "alloc_etherdev failed\n"); in airoha_alloc_gdm_port()
2865 qdma = &eth->qdma[index % AIROHA_MAX_NUM_QDMA]; in airoha_alloc_gdm_port()
2878 SET_NETDEV_DEV(dev, eth->dev); in airoha_alloc_gdm_port()
2891 dev_info(eth->dev, "generated random MAC address %pM\n", in airoha_alloc_gdm_port()
2901 eth->ports[p] = port; in airoha_alloc_gdm_port()
2921 struct airoha_eth *eth; in airoha_probe() local
2924 eth = devm_kzalloc(&pdev->dev, sizeof(*eth), GFP_KERNEL); in airoha_probe()
2925 if (!eth) in airoha_probe()
2928 eth->dev = &pdev->dev; in airoha_probe()
2930 err = dma_set_mask_and_coherent(eth->dev, DMA_BIT_MASK(32)); in airoha_probe()
2932 dev_err(eth->dev, "failed configuring DMA mask\n"); in airoha_probe()
2936 eth->fe_regs = devm_platform_ioremap_resource_byname(pdev, "fe"); in airoha_probe()
2937 if (IS_ERR(eth->fe_regs)) in airoha_probe()
2938 return dev_err_probe(eth->dev, PTR_ERR(eth->fe_regs), in airoha_probe()
2941 eth->rsts[0].id = "fe"; in airoha_probe()
2942 eth->rsts[1].id = "pdma"; in airoha_probe()
2943 eth->rsts[2].id = "qdma"; in airoha_probe()
2944 err = devm_reset_control_bulk_get_exclusive(eth->dev, in airoha_probe()
2945 ARRAY_SIZE(eth->rsts), in airoha_probe()
2946 eth->rsts); in airoha_probe()
2948 dev_err(eth->dev, "failed to get bulk reset lines\n"); in airoha_probe()
2952 eth->xsi_rsts[0].id = "xsi-mac"; in airoha_probe()
2953 eth->xsi_rsts[1].id = "hsi0-mac"; in airoha_probe()
2954 eth->xsi_rsts[2].id = "hsi1-mac"; in airoha_probe()
2955 eth->xsi_rsts[3].id = "hsi-mac"; in airoha_probe()
2956 eth->xsi_rsts[4].id = "xfp-mac"; in airoha_probe()
2957 err = devm_reset_control_bulk_get_exclusive(eth->dev, in airoha_probe()
2958 ARRAY_SIZE(eth->xsi_rsts), in airoha_probe()
2959 eth->xsi_rsts); in airoha_probe()
2961 dev_err(eth->dev, "failed to get bulk xsi reset lines\n"); in airoha_probe()
2965 eth->napi_dev = alloc_netdev_dummy(0); in airoha_probe()
2966 if (!eth->napi_dev) in airoha_probe()
2970 eth->napi_dev->threaded = true; in airoha_probe()
2971 strscpy(eth->napi_dev->name, "qdma_eth", sizeof(eth->napi_dev->name)); in airoha_probe()
2972 platform_set_drvdata(pdev, eth); in airoha_probe()
2974 err = airoha_hw_init(pdev, eth); in airoha_probe()
2978 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) in airoha_probe()
2979 airoha_qdma_start_napi(&eth->qdma[i]); in airoha_probe()
2983 if (!of_device_is_compatible(np, "airoha,eth-mac")) in airoha_probe()
2989 err = airoha_alloc_gdm_port(eth, np, i++); in airoha_probe()
2999 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) in airoha_probe()
3000 airoha_qdma_stop_napi(&eth->qdma[i]); in airoha_probe()
3001 airoha_ppe_deinit(eth); in airoha_probe()
3003 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) in airoha_probe()
3004 airoha_hw_cleanup(&eth->qdma[i]); in airoha_probe()
3006 for (i = 0; i < ARRAY_SIZE(eth->ports); i++) { in airoha_probe()
3007 struct airoha_gdm_port *port = eth->ports[i]; in airoha_probe()
3014 free_netdev(eth->napi_dev); in airoha_probe()
3022 struct airoha_eth *eth = platform_get_drvdata(pdev); in airoha_remove() local
3025 for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) { in airoha_remove()
3026 airoha_qdma_stop_napi(&eth->qdma[i]); in airoha_remove()
3027 airoha_hw_cleanup(&eth->qdma[i]); in airoha_remove()
3030 for (i = 0; i < ARRAY_SIZE(eth->ports); i++) { in airoha_remove()
3031 struct airoha_gdm_port *port = eth->ports[i]; in airoha_remove()
3040 free_netdev(eth->napi_dev); in airoha_remove()
3042 airoha_ppe_deinit(eth); in airoha_remove()
3047 { .compatible = "airoha,en7581-eth" },