Lines Matching refs:tp
104 static void rtase_w8(const struct rtase_private *tp, u16 reg, u8 val8) in rtase_w8() argument
106 writeb(val8, tp->mmio_addr + reg); in rtase_w8()
109 static void rtase_w16(const struct rtase_private *tp, u16 reg, u16 val16) in rtase_w16() argument
111 writew(val16, tp->mmio_addr + reg); in rtase_w16()
114 static void rtase_w32(const struct rtase_private *tp, u16 reg, u32 val32) in rtase_w32() argument
116 writel(val32, tp->mmio_addr + reg); in rtase_w32()
119 static u8 rtase_r8(const struct rtase_private *tp, u16 reg) in rtase_r8() argument
121 return readb(tp->mmio_addr + reg); in rtase_r8()
124 static u16 rtase_r16(const struct rtase_private *tp, u16 reg) in rtase_r16() argument
126 return readw(tp->mmio_addr + reg); in rtase_r16()
129 static u32 rtase_r32(const struct rtase_private *tp, u16 reg) in rtase_r32() argument
131 return readl(tp->mmio_addr + reg); in rtase_r32()
134 static void rtase_free_desc(struct rtase_private *tp) in rtase_free_desc() argument
136 struct pci_dev *pdev = tp->pdev; in rtase_free_desc()
139 for (i = 0; i < tp->func_tx_queue_num; i++) { in rtase_free_desc()
140 if (!tp->tx_ring[i].desc) in rtase_free_desc()
144 tp->tx_ring[i].desc, in rtase_free_desc()
145 tp->tx_ring[i].phy_addr); in rtase_free_desc()
146 tp->tx_ring[i].desc = NULL; in rtase_free_desc()
149 for (i = 0; i < tp->func_rx_queue_num; i++) { in rtase_free_desc()
150 if (!tp->rx_ring[i].desc) in rtase_free_desc()
154 tp->rx_ring[i].desc, in rtase_free_desc()
155 tp->rx_ring[i].phy_addr); in rtase_free_desc()
156 tp->rx_ring[i].desc = NULL; in rtase_free_desc()
160 static int rtase_alloc_desc(struct rtase_private *tp) in rtase_alloc_desc() argument
162 struct pci_dev *pdev = tp->pdev; in rtase_alloc_desc()
168 for (i = 0; i < tp->func_tx_queue_num; i++) { in rtase_alloc_desc()
169 tp->tx_ring[i].desc = in rtase_alloc_desc()
172 &tp->tx_ring[i].phy_addr, in rtase_alloc_desc()
174 if (!tp->tx_ring[i].desc) in rtase_alloc_desc()
178 for (i = 0; i < tp->func_rx_queue_num; i++) { in rtase_alloc_desc()
179 tp->rx_ring[i].desc = in rtase_alloc_desc()
182 &tp->rx_ring[i].phy_addr, in rtase_alloc_desc()
184 if (!tp->rx_ring[i].desc) in rtase_alloc_desc()
191 rtase_free_desc(tp); in rtase_alloc_desc()
208 struct rtase_private *tp = ring->ivec->tp; in rtase_tx_clear_range() local
220 rtase_unmap_tx_skb(tp->pdev, len, desc); in rtase_tx_clear_range()
226 tp->stats.tx_dropped++; in rtase_tx_clear_range()
232 static void rtase_tx_clear(struct rtase_private *tp) in rtase_tx_clear() argument
237 for (i = 0; i < tp->func_tx_queue_num; i++) { in rtase_tx_clear()
238 ring = &tp->tx_ring[i]; in rtase_tx_clear()
264 const struct rtase_private *tp = ring->ivec->tp; in tx_handler() local
265 struct net_device *dev = tp->dev; in tx_handler()
285 rtase_unmap_tx_skb(tp->pdev, ring->mis.len[entry], desc); in tx_handler()
312 rtase_w8(tp, RTASE_TPPOLL, BIT(ring->index)); in tx_handler()
318 static void rtase_tx_desc_init(struct rtase_private *tp, u16 idx) in rtase_tx_desc_init() argument
320 struct rtase_ring *ring = &tp->tx_ring[idx]; in rtase_tx_desc_init()
341 ring->ivec = &tp->int_vector[idx]; in rtase_tx_desc_init()
343 &tp->int_vector[idx].ring_list); in rtase_tx_desc_init()
345 ring->ivec = &tp->int_vector[0]; in rtase_tx_desc_init()
346 list_add_tail(&ring->ring_entry, &tp->int_vector[0].ring_list); in rtase_tx_desc_init()
370 const struct rtase_private *tp = ivec->tp; in rtase_alloc_rx_data_buf() local
374 page = page_pool_dev_alloc_pages(tp->page_pool); in rtase_alloc_rx_data_buf()
383 rtase_map_to_asic(desc, mapping, tp->rx_buf_sz); in rtase_alloc_rx_data_buf()
445 static void rtase_rx_csum(const struct rtase_private *tp, struct sk_buff *skb, in rtase_rx_csum() argument
485 struct rtase_private *tp = ring->ivec->tp; in rx_handler() local
486 struct net_device *dev = tp->dev; in rx_handler()
512 tp->stats.rx_errors++; in rx_handler()
515 tp->stats.rx_length_errors++; in rx_handler()
518 tp->stats.rx_crc_errors++; in rx_handler()
523 rtase_mark_to_asic(desc, tp->rx_buf_sz); in rx_handler()
536 tp->stats.rx_dropped++; in rx_handler()
537 tp->stats.rx_length_errors++; in rx_handler()
538 rtase_mark_to_asic(desc, tp->rx_buf_sz); in rx_handler()
542 dma_sync_single_for_cpu(&tp->pdev->dev, in rx_handler()
544 tp->rx_buf_sz, DMA_FROM_DEVICE); in rx_handler()
548 tp->stats.rx_dropped++; in rx_handler()
549 rtase_mark_to_asic(desc, tp->rx_buf_sz); in rx_handler()
555 rtase_rx_csum(tp, skb, desc); in rx_handler()
562 tp->stats.multicast++; in rx_handler()
583 static void rtase_rx_desc_init(struct rtase_private *tp, u16 idx) in rtase_rx_desc_init() argument
585 struct rtase_ring *ring = &tp->rx_ring[idx]; in rtase_rx_desc_init()
599 ring->ivec = &tp->int_vector[idx]; in rtase_rx_desc_init()
600 list_add_tail(&ring->ring_entry, &tp->int_vector[idx].ring_list); in rtase_rx_desc_init()
603 static void rtase_rx_clear(struct rtase_private *tp) in rtase_rx_clear() argument
607 for (i = 0; i < tp->func_rx_queue_num; i++) in rtase_rx_clear()
608 rtase_rx_ring_clear(tp->page_pool, &tp->rx_ring[i]); in rtase_rx_clear()
610 page_pool_destroy(tp->page_pool); in rtase_rx_clear()
611 tp->page_pool = NULL; in rtase_rx_clear()
616 struct rtase_private *tp = netdev_priv(dev); in rtase_init_ring() local
624 pp_params.pool_size = RTASE_NUM_DESC * tp->func_rx_queue_num; in rtase_init_ring()
625 pp_params.nid = dev_to_node(&tp->pdev->dev); in rtase_init_ring()
626 pp_params.dev = &tp->pdev->dev; in rtase_init_ring()
633 netdev_err(tp->dev, "failed to create page pool\n"); in rtase_init_ring()
637 tp->page_pool = page_pool; in rtase_init_ring()
639 for (i = 0; i < tp->func_tx_queue_num; i++) in rtase_init_ring()
640 rtase_tx_desc_init(tp, i); in rtase_init_ring()
642 for (i = 0; i < tp->func_rx_queue_num; i++) { in rtase_init_ring()
643 rtase_rx_desc_init(tp, i); in rtase_init_ring()
645 num = rtase_rx_ring_fill(&tp->rx_ring[i], 0, RTASE_NUM_DESC); in rtase_init_ring()
649 rtase_mark_as_last_descriptor(tp->rx_ring[i].desc + in rtase_init_ring()
657 rtase_rx_clear(tp); in rtase_init_ring()
661 static void rtase_interrupt_mitigation(const struct rtase_private *tp) in rtase_interrupt_mitigation() argument
665 for (i = 0; i < tp->func_tx_queue_num; i++) in rtase_interrupt_mitigation()
666 rtase_w16(tp, RTASE_INT_MITI_TX + i * 2, tp->tx_int_mit); in rtase_interrupt_mitigation()
668 for (i = 0; i < tp->func_rx_queue_num; i++) in rtase_interrupt_mitigation()
669 rtase_w16(tp, RTASE_INT_MITI_RX + i * 2, tp->rx_int_mit); in rtase_interrupt_mitigation()
672 static void rtase_tally_counter_addr_fill(const struct rtase_private *tp) in rtase_tally_counter_addr_fill() argument
674 rtase_w32(tp, RTASE_DTCCR4, upper_32_bits(tp->tally_paddr)); in rtase_tally_counter_addr_fill()
675 rtase_w32(tp, RTASE_DTCCR0, lower_32_bits(tp->tally_paddr)); in rtase_tally_counter_addr_fill()
678 static void rtase_tally_counter_clear(const struct rtase_private *tp) in rtase_tally_counter_clear() argument
680 u32 cmd = lower_32_bits(tp->tally_paddr); in rtase_tally_counter_clear()
682 rtase_w32(tp, RTASE_DTCCR4, upper_32_bits(tp->tally_paddr)); in rtase_tally_counter_clear()
683 rtase_w32(tp, RTASE_DTCCR0, cmd | RTASE_COUNTER_RESET); in rtase_tally_counter_clear()
686 static void rtase_desc_addr_fill(const struct rtase_private *tp) in rtase_desc_addr_fill() argument
692 for (i = 0; i < tp->func_tx_queue_num; i++) { in rtase_desc_addr_fill()
693 ring = &tp->tx_ring[i]; in rtase_desc_addr_fill()
695 rtase_w32(tp, RTASE_TX_DESC_ADDR0, in rtase_desc_addr_fill()
697 rtase_w32(tp, RTASE_TX_DESC_ADDR4, in rtase_desc_addr_fill()
701 rtase_w16(tp, RTASE_TX_DESC_COMMAND, cmd); in rtase_desc_addr_fill()
705 1000, false, tp, in rtase_desc_addr_fill()
709 netdev_err(tp->dev, in rtase_desc_addr_fill()
713 for (i = 0; i < tp->func_rx_queue_num; i++) { in rtase_desc_addr_fill()
714 ring = &tp->rx_ring[i]; in rtase_desc_addr_fill()
717 rtase_w32(tp, RTASE_Q0_RX_DESC_ADDR0, in rtase_desc_addr_fill()
719 rtase_w32(tp, RTASE_Q0_RX_DESC_ADDR4, in rtase_desc_addr_fill()
722 rtase_w32(tp, (RTASE_Q1_RX_DESC_ADDR0 + ((i - 1) * 8)), in rtase_desc_addr_fill()
724 rtase_w32(tp, (RTASE_Q1_RX_DESC_ADDR4 + ((i - 1) * 8)), in rtase_desc_addr_fill()
733 const struct rtase_private *tp = netdev_priv(dev); in rtase_hw_set_features() local
736 rx_config = rtase_r16(tp, RTASE_RX_CONFIG_0); in rtase_hw_set_features()
742 rtase_w16(tp, RTASE_RX_CONFIG_0, rx_config); in rtase_hw_set_features()
744 val = rtase_r16(tp, RTASE_CPLUS_CMD); in rtase_hw_set_features()
746 rtase_w16(tp, RTASE_CPLUS_CMD, val | RTASE_RX_CHKSUM); in rtase_hw_set_features()
748 rtase_w16(tp, RTASE_CPLUS_CMD, val & ~RTASE_RX_CHKSUM); in rtase_hw_set_features()
750 rx_config = rtase_r16(tp, RTASE_RX_CONFIG_1); in rtase_hw_set_features()
758 rtase_w16(tp, RTASE_RX_CONFIG_1, rx_config); in rtase_hw_set_features()
764 struct rtase_private *tp = netdev_priv(dev); in rtase_hw_set_rx_packet_filter() local
767 rx_mode = rtase_r16(tp, RTASE_RX_CONFIG_0) & ~RTASE_ACCEPT_MASK; in rtase_hw_set_rx_packet_filter()
794 rtase_w32(tp, RTASE_MAR0, swab32(mc_filter[1])); in rtase_hw_set_rx_packet_filter()
795 rtase_w32(tp, RTASE_MAR1, swab32(mc_filter[0])); in rtase_hw_set_rx_packet_filter()
796 rtase_w16(tp, RTASE_RX_CONFIG_0, rx_mode); in rtase_hw_set_rx_packet_filter()
799 static void rtase_irq_dis_and_clear(const struct rtase_private *tp) in rtase_irq_dis_and_clear() argument
801 const struct rtase_int_vector *ivec = &tp->int_vector[0]; in rtase_irq_dis_and_clear()
806 rtase_w32(tp, ivec->imr_addr, 0); in rtase_irq_dis_and_clear()
807 val1 = rtase_r32(tp, ivec->isr_addr); in rtase_irq_dis_and_clear()
808 rtase_w32(tp, ivec->isr_addr, val1); in rtase_irq_dis_and_clear()
810 for (i = 1; i < tp->int_nums; i++) { in rtase_irq_dis_and_clear()
811 ivec = &tp->int_vector[i]; in rtase_irq_dis_and_clear()
812 rtase_w16(tp, ivec->imr_addr, 0); in rtase_irq_dis_and_clear()
813 val2 = rtase_r16(tp, ivec->isr_addr); in rtase_irq_dis_and_clear()
814 rtase_w16(tp, ivec->isr_addr, val2); in rtase_irq_dis_and_clear()
818 static void rtase_poll_timeout(const struct rtase_private *tp, u32 cond, in rtase_poll_timeout() argument
825 timeout_us, false, tp, reg); in rtase_poll_timeout()
828 netdev_err(tp->dev, "poll reg 0x00%x timeout\n", reg); in rtase_poll_timeout()
833 const struct rtase_private *tp = netdev_priv(dev); in rtase_nic_reset() local
837 rx_config = rtase_r16(tp, RTASE_RX_CONFIG_0); in rtase_nic_reset()
838 rtase_w16(tp, RTASE_RX_CONFIG_0, rx_config & ~RTASE_ACCEPT_MASK); in rtase_nic_reset()
840 val = rtase_r8(tp, RTASE_MISC); in rtase_nic_reset()
841 rtase_w8(tp, RTASE_MISC, val | RTASE_RX_DV_GATE_EN); in rtase_nic_reset()
843 val = rtase_r8(tp, RTASE_CHIP_CMD); in rtase_nic_reset()
844 rtase_w8(tp, RTASE_CHIP_CMD, val | RTASE_STOP_REQ); in rtase_nic_reset()
847 rtase_poll_timeout(tp, RTASE_STOP_REQ_DONE, 100, 150000, in rtase_nic_reset()
850 rtase_poll_timeout(tp, RTASE_TX_FIFO_EMPTY, 100, 100000, in rtase_nic_reset()
853 rtase_poll_timeout(tp, RTASE_RX_FIFO_EMPTY, 100, 100000, in rtase_nic_reset()
856 val = rtase_r8(tp, RTASE_CHIP_CMD); in rtase_nic_reset()
857 rtase_w8(tp, RTASE_CHIP_CMD, val & ~(RTASE_TE | RTASE_RE)); in rtase_nic_reset()
858 val = rtase_r8(tp, RTASE_CHIP_CMD); in rtase_nic_reset()
859 rtase_w8(tp, RTASE_CHIP_CMD, val & ~RTASE_STOP_REQ); in rtase_nic_reset()
861 rtase_w16(tp, RTASE_RX_CONFIG_0, rx_config); in rtase_nic_reset()
866 const struct rtase_private *tp = netdev_priv(dev); in rtase_hw_reset() local
868 rtase_irq_dis_and_clear(tp); in rtase_hw_reset()
873 static void rtase_set_rx_queue(const struct rtase_private *tp) in rtase_set_rx_queue() argument
877 reg_data = rtase_r16(tp, RTASE_FCR); in rtase_set_rx_queue()
878 switch (tp->func_rx_queue_num) { in rtase_set_rx_queue()
889 rtase_w16(tp, RTASE_FCR, reg_data); in rtase_set_rx_queue()
892 static void rtase_set_tx_queue(const struct rtase_private *tp) in rtase_set_tx_queue() argument
896 reg_data = rtase_r16(tp, RTASE_TX_CONFIG_1); in rtase_set_tx_queue()
897 switch (tp->tx_queue_ctrl) { in rtase_set_tx_queue()
912 rtase_w16(tp, RTASE_TX_CONFIG_1, reg_data); in rtase_set_tx_queue()
917 const struct rtase_private *tp = netdev_priv(dev); in rtase_hw_config() local
924 reg_data16 = rtase_r16(tp, RTASE_RX_CONFIG_0); in rtase_hw_config()
928 rtase_w16(tp, RTASE_RX_CONFIG_0, reg_data16); in rtase_hw_config()
931 reg_data16 = rtase_r16(tp, RTASE_RX_CONFIG_1); in rtase_hw_config()
934 rtase_w16(tp, RTASE_RX_CONFIG_1, reg_data16); in rtase_hw_config()
936 rtase_set_rx_queue(tp); in rtase_hw_config()
938 rtase_interrupt_mitigation(tp); in rtase_hw_config()
941 reg_data32 = rtase_r32(tp, RTASE_TX_CONFIG_0); in rtase_hw_config()
946 rtase_w32(tp, RTASE_TX_CONFIG_0, reg_data32); in rtase_hw_config()
949 reg_data16 = rtase_r16(tp, RTASE_TFUN_CTRL); in rtase_hw_config()
950 rtase_w16(tp, RTASE_TFUN_CTRL, reg_data16 | in rtase_hw_config()
954 rtase_w8(tp, RTASE_TDFNR, 0x10); in rtase_hw_config()
957 reg_data16 = rtase_r16(tp, RTASE_MTPS); in rtase_hw_config()
959 rtase_w16(tp, RTASE_MTPS, reg_data16); in rtase_hw_config()
961 rtase_set_tx_queue(tp); in rtase_hw_config()
963 rtase_w16(tp, RTASE_TOKSEL, 0x5555); in rtase_hw_config()
965 rtase_tally_counter_addr_fill(tp); in rtase_hw_config()
966 rtase_desc_addr_fill(tp); in rtase_hw_config()
970 reg_data16 = rtase_r16(tp, RTASE_CPLUS_CMD); in rtase_hw_config()
972 rtase_w16(tp, RTASE_CPLUS_CMD, reg_data16); in rtase_hw_config()
974 rtase_w16(tp, RTASE_RFIFONFULL, 0x190); in rtase_hw_config()
976 rtase_w16(tp, RTASE_RMS, tp->rx_buf_sz); in rtase_hw_config()
983 const struct rtase_private *tp = netdev_priv(dev); in rtase_nic_enable() local
984 u16 rcr = rtase_r16(tp, RTASE_RX_CONFIG_1); in rtase_nic_enable()
987 rtase_w16(tp, RTASE_RX_CONFIG_1, rcr & ~RTASE_PCIE_RELOAD_EN); in rtase_nic_enable()
988 rtase_w16(tp, RTASE_RX_CONFIG_1, rcr | RTASE_PCIE_RELOAD_EN); in rtase_nic_enable()
990 val = rtase_r8(tp, RTASE_CHIP_CMD); in rtase_nic_enable()
991 rtase_w8(tp, RTASE_CHIP_CMD, val | RTASE_TE | RTASE_RE); in rtase_nic_enable()
993 val = rtase_r8(tp, RTASE_MISC); in rtase_nic_enable()
994 rtase_w8(tp, RTASE_MISC, val & ~RTASE_RX_DV_GATE_EN); in rtase_nic_enable()
997 static void rtase_enable_hw_interrupt(const struct rtase_private *tp) in rtase_enable_hw_interrupt() argument
999 const struct rtase_int_vector *ivec = &tp->int_vector[0]; in rtase_enable_hw_interrupt()
1002 rtase_w32(tp, ivec->imr_addr, ivec->imr); in rtase_enable_hw_interrupt()
1004 for (i = 1; i < tp->int_nums; i++) { in rtase_enable_hw_interrupt()
1005 ivec = &tp->int_vector[i]; in rtase_enable_hw_interrupt()
1006 rtase_w16(tp, ivec->imr_addr, ivec->imr); in rtase_enable_hw_interrupt()
1012 const struct rtase_private *tp = netdev_priv(dev); in rtase_hw_start() local
1015 rtase_enable_hw_interrupt(tp); in rtase_hw_start()
1022 const struct rtase_private *tp; in rtase_interrupt() local
1027 tp = ivec->tp; in rtase_interrupt()
1028 status = rtase_r32(tp, ivec->isr_addr); in rtase_interrupt()
1030 rtase_w32(tp, ivec->imr_addr, 0x0); in rtase_interrupt()
1031 rtase_w32(tp, ivec->isr_addr, status & ~RTASE_FOVW); in rtase_interrupt()
1044 const struct rtase_private *tp; in rtase_q_interrupt() local
1049 tp = ivec->tp; in rtase_q_interrupt()
1050 status = rtase_r16(tp, ivec->isr_addr); in rtase_q_interrupt()
1052 rtase_w16(tp, ivec->imr_addr, 0x0); in rtase_q_interrupt()
1053 rtase_w16(tp, ivec->isr_addr, status); in rtase_q_interrupt()
1064 const struct rtase_private *tp; in rtase_poll() local
1069 tp = ivec->tp; in rtase_poll()
1079 rtase_w32(tp, ivec->imr_addr, ivec->imr); in rtase_poll()
1081 rtase_w16(tp, ivec->imr_addr, ivec->imr); in rtase_poll()
1089 struct rtase_private *tp = netdev_priv(dev); in rtase_open() local
1090 const struct pci_dev *pdev = tp->pdev; in rtase_open()
1095 ivec = &tp->int_vector[0]; in rtase_open()
1096 tp->rx_buf_sz = RTASE_RX_BUF_SIZE; in rtase_open()
1098 ret = rtase_alloc_desc(tp); in rtase_open()
1108 if (tp->sw_flag & RTASE_SWF_MSIX_ENABLED) { in rtase_open()
1115 for (i = 1; i < tp->int_nums; i++) { in rtase_open()
1116 ivec = &tp->int_vector[i]; in rtase_open()
1118 tp->dev->name, i); in rtase_open()
1133 for (i = 0; i < tp->int_nums; i++) { in rtase_open()
1134 ivec = &tp->int_vector[i]; in rtase_open()
1145 free_irq(tp->int_vector[j].irq, &tp->int_vector[j]); in rtase_open()
1148 rtase_free_desc(tp); in rtase_open()
1155 struct rtase_private *tp = netdev_priv(dev); in rtase_down() local
1160 for (i = 0; i < tp->int_nums; i++) { in rtase_down()
1161 ivec = &tp->int_vector[i]; in rtase_down()
1174 rtase_tx_clear(tp); in rtase_down()
1176 rtase_rx_clear(tp); in rtase_down()
1181 struct rtase_private *tp = netdev_priv(dev); in rtase_close() local
1182 const struct pci_dev *pdev = tp->pdev; in rtase_close()
1187 if (tp->sw_flag & RTASE_SWF_MSIX_ENABLED) { in rtase_close()
1188 for (i = 0; i < tp->int_nums; i++) in rtase_close()
1189 free_irq(tp->int_vector[i].irq, &tp->int_vector[i]); in rtase_close()
1192 free_irq(pdev->irq, &tp->int_vector[0]); in rtase_close()
1195 rtase_free_desc(tp); in rtase_close()
1200 static u32 rtase_tx_vlan_tag(const struct rtase_private *tp, in rtase_tx_vlan_tag() argument
1243 const struct rtase_private *tp = ring->ivec->tp; in rtase_xmit_frags() local
1260 mapping = dma_map_single(&tp->pdev->dev, addr, len, in rtase_xmit_frags()
1263 if (unlikely(dma_mapping_error(&tp->pdev->dev, mapping))) { in rtase_xmit_frags()
1265 netdev_err(tp->dev, in rtase_xmit_frags()
1301 struct rtase_private *tp = netdev_priv(dev); in rtase_start_xmit() local
1313 ring = &tp->tx_ring[q_idx]; in rtase_start_xmit()
1329 opts2 = rtase_tx_vlan_tag(tp, skb); in rtase_start_xmit()
1370 mapping = dma_map_single(&tp->pdev->dev, skb->data, len, in rtase_start_xmit()
1373 if (unlikely(dma_mapping_error(&tp->pdev->dev, mapping))) { in rtase_start_xmit()
1406 rtase_w8(tp, RTASE_TPPOLL, BIT(ring->index)); in rtase_start_xmit()
1415 tp->stats.tx_dropped++; in rtase_start_xmit()
1425 static void rtase_enable_eem_write(const struct rtase_private *tp) in rtase_enable_eem_write() argument
1429 val = rtase_r8(tp, RTASE_EEM); in rtase_enable_eem_write()
1430 rtase_w8(tp, RTASE_EEM, val | RTASE_EEM_UNLOCK); in rtase_enable_eem_write()
1433 static void rtase_disable_eem_write(const struct rtase_private *tp) in rtase_disable_eem_write() argument
1437 val = rtase_r8(tp, RTASE_EEM); in rtase_disable_eem_write()
1438 rtase_w8(tp, RTASE_EEM, val & ~RTASE_EEM_UNLOCK); in rtase_disable_eem_write()
1441 static void rtase_rar_set(const struct rtase_private *tp, const u8 *addr) in rtase_rar_set() argument
1450 rtase_enable_eem_write(tp); in rtase_rar_set()
1451 rtase_w32(tp, RTASE_MAC0, rar_low); in rtase_rar_set()
1452 rtase_w32(tp, RTASE_MAC4, rar_high); in rtase_rar_set()
1453 rtase_disable_eem_write(tp); in rtase_rar_set()
1454 rtase_w16(tp, RTASE_LBK_CTRL, RTASE_LBK_ATLD | RTASE_LBK_CLR); in rtase_rar_set()
1459 struct rtase_private *tp = netdev_priv(dev); in rtase_set_mac_address() local
1466 rtase_rar_set(tp, dev->dev_addr); in rtase_set_mac_address()
1482 struct rtase_private *tp = netdev_priv(dev); in rtase_wait_for_quiescence() local
1486 for (i = 0; i < tp->int_nums; i++) { in rtase_wait_for_quiescence()
1487 ivec = &tp->int_vector[i]; in rtase_wait_for_quiescence()
1493 rtase_irq_dis_and_clear(tp); in rtase_wait_for_quiescence()
1495 for (i = 0; i < tp->int_nums; i++) { in rtase_wait_for_quiescence()
1496 ivec = &tp->int_vector[i]; in rtase_wait_for_quiescence()
1503 struct rtase_private *tp = netdev_priv(dev); in rtase_sw_reset() local
1512 rtase_tx_clear(tp); in rtase_sw_reset()
1513 rtase_rx_clear(tp); in rtase_sw_reset()
1518 rtase_free_desc(tp); in rtase_sw_reset()
1530 static void rtase_dump_tally_counter(const struct rtase_private *tp) in rtase_dump_tally_counter() argument
1532 dma_addr_t paddr = tp->tally_paddr; in rtase_dump_tally_counter()
1537 rtase_w32(tp, RTASE_DTCCR4, upper_32_bits(paddr)); in rtase_dump_tally_counter()
1538 rtase_w32(tp, RTASE_DTCCR0, cmd); in rtase_dump_tally_counter()
1539 rtase_w32(tp, RTASE_DTCCR0, cmd | RTASE_COUNTER_DUMP); in rtase_dump_tally_counter()
1542 10, 250, false, tp, RTASE_DTCCR0); in rtase_dump_tally_counter()
1545 netdev_err(tp->dev, "error occurred in dump tally counter\n"); in rtase_dump_tally_counter()
1550 const struct rtase_private *tp = netdev_priv(dev); in rtase_dump_state() local
1557 ring = &tp->tx_ring[0]; in rtase_dump_state()
1563 ring = &tp->rx_ring[0]; in rtase_dump_state()
1571 rtase_r8(tp, RTASE_CHIP_CMD)); in rtase_dump_state()
1572 netdev_err(dev, "IMR = %08x\n", rtase_r32(tp, RTASE_IMR0)); in rtase_dump_state()
1573 netdev_err(dev, "ISR = %08x\n", rtase_r32(tp, RTASE_ISR0)); in rtase_dump_state()
1575 rtase_r16(tp, RTASE_BOOT_CTL)); in rtase_dump_state()
1577 rtase_r16(tp, RTASE_EPHY_ISR)); in rtase_dump_state()
1579 rtase_r16(tp, RTASE_EPHY_IMR)); in rtase_dump_state()
1581 rtase_r16(tp, RTASE_CLKSW_SET)); in rtase_dump_state()
1587 netdev_err(tp->dev, "0x%03x:\n", n); in rtase_dump_state()
1589 pci_read_config_dword(tp->pdev, n, &dword_rd); in rtase_dump_state()
1590 netdev_err(tp->dev, "%08x\n", dword_rd); in rtase_dump_state()
1595 counters = tp->tally_vaddr; in rtase_dump_state()
1596 rtase_dump_tally_counter(tp); in rtase_dump_state()
1635 const struct rtase_private *tp = netdev_priv(dev); in rtase_get_stats64() local
1638 counters = tp->tally_vaddr; in rtase_get_stats64()
1645 rtase_dump_tally_counter(tp); in rtase_get_stats64()
1646 stats->rx_errors = tp->stats.rx_errors; in rtase_get_stats64()
1648 stats->rx_dropped = tp->stats.rx_dropped; in rtase_get_stats64()
1649 stats->tx_dropped = tp->stats.tx_dropped; in rtase_get_stats64()
1650 stats->multicast = tp->stats.multicast; in rtase_get_stats64()
1651 stats->rx_length_errors = tp->stats.rx_length_errors; in rtase_get_stats64()
1695 struct rtase_private *tp = netdev_priv(dev); in rtase_get_mac_address() local
1700 mac_addr[i] = rtase_r8(tp, RTASE_MAC0 + i); in rtase_get_mac_address()
1710 rtase_rar_set(tp, dev->dev_addr); in rtase_get_mac_address()
1731 const struct rtase_private *tp = netdev_priv(dev); in rtase_get_pauseparam() local
1732 u16 value = rtase_r16(tp, RTASE_CPLUS_CMD); in rtase_get_pauseparam()
1742 const struct rtase_private *tp = netdev_priv(dev); in rtase_set_pauseparam() local
1743 u16 value = rtase_r16(tp, RTASE_CPLUS_CMD); in rtase_set_pauseparam()
1756 rtase_w16(tp, RTASE_CPLUS_CMD, value); in rtase_set_pauseparam()
1763 struct rtase_private *tp = netdev_priv(dev); in rtase_get_eth_mac_stats() local
1766 counters = tp->tally_vaddr; in rtase_get_eth_mac_stats()
1768 rtase_dump_tally_counter(tp); in rtase_get_eth_mac_stats()
1793 const struct rtase_private *tp) in rtase_reset_interrupt() argument
1795 if (tp->sw_flag & RTASE_SWF_MSIX_ENABLED) in rtase_reset_interrupt()
1801 static int rtase_alloc_msix(struct pci_dev *pdev, struct rtase_private *tp) in rtase_alloc_msix() argument
1806 memset(tp->msix_entry, 0x0, RTASE_NUM_MSIX * in rtase_alloc_msix()
1810 tp->msix_entry[i].entry = i; in rtase_alloc_msix()
1812 ret = pci_enable_msix_exact(pdev, tp->msix_entry, tp->int_nums); in rtase_alloc_msix()
1817 for (i = 0; i < tp->int_nums; i++) { in rtase_alloc_msix()
1824 tp->int_vector[i].irq = irq; in rtase_alloc_msix()
1831 struct rtase_private *tp) in rtase_alloc_interrupt() argument
1835 ret = rtase_alloc_msix(pdev, tp); in rtase_alloc_interrupt()
1844 tp->sw_flag |= RTASE_SWF_MSI_ENABLED; in rtase_alloc_interrupt()
1846 tp->sw_flag |= RTASE_SWF_MSIX_ENABLED; in rtase_alloc_interrupt()
1852 static void rtase_init_hardware(const struct rtase_private *tp) in rtase_init_hardware() argument
1857 rtase_w32(tp, RTASE_VLAN_ENTRY_0 + i * 4, 0); in rtase_init_hardware()
1860 static void rtase_init_int_vector(struct rtase_private *tp) in rtase_init_int_vector() argument
1865 tp->int_vector[0].tp = tp; in rtase_init_int_vector()
1866 tp->int_vector[0].index = 0; in rtase_init_int_vector()
1867 tp->int_vector[0].imr_addr = RTASE_IMR0; in rtase_init_int_vector()
1868 tp->int_vector[0].isr_addr = RTASE_ISR0; in rtase_init_int_vector()
1869 tp->int_vector[0].imr = RTASE_ROK | RTASE_RDU | RTASE_TOK | in rtase_init_int_vector()
1872 tp->int_vector[0].poll = rtase_poll; in rtase_init_int_vector()
1874 memset(tp->int_vector[0].name, 0x0, sizeof(tp->int_vector[0].name)); in rtase_init_int_vector()
1875 INIT_LIST_HEAD(&tp->int_vector[0].ring_list); in rtase_init_int_vector()
1877 netif_napi_add(tp->dev, &tp->int_vector[0].napi, in rtase_init_int_vector()
1878 tp->int_vector[0].poll); in rtase_init_int_vector()
1881 for (i = 1; i < tp->int_nums; i++) { in rtase_init_int_vector()
1882 tp->int_vector[i].tp = tp; in rtase_init_int_vector()
1883 tp->int_vector[i].index = i; in rtase_init_int_vector()
1884 tp->int_vector[i].imr_addr = RTASE_IMR1 + (i - 1) * 4; in rtase_init_int_vector()
1885 tp->int_vector[i].isr_addr = RTASE_ISR1 + (i - 1) * 4; in rtase_init_int_vector()
1886 tp->int_vector[i].imr = RTASE_Q_ROK | RTASE_Q_RDU | in rtase_init_int_vector()
1888 tp->int_vector[i].poll = rtase_poll; in rtase_init_int_vector()
1890 memset(tp->int_vector[i].name, 0x0, in rtase_init_int_vector()
1891 sizeof(tp->int_vector[0].name)); in rtase_init_int_vector()
1892 INIT_LIST_HEAD(&tp->int_vector[i].ring_list); in rtase_init_int_vector()
1894 netif_napi_add(tp->dev, &tp->int_vector[i].napi, in rtase_init_int_vector()
1895 tp->int_vector[i].poll); in rtase_init_int_vector()
1952 struct rtase_private *tp) in rtase_init_software_variable() argument
1956 tp->tx_queue_ctrl = RTASE_TXQ_CTRL; in rtase_init_software_variable()
1957 tp->func_tx_queue_num = RTASE_FUNC_TXQ_NUM; in rtase_init_software_variable()
1958 tp->func_rx_queue_num = RTASE_FUNC_RXQ_NUM; in rtase_init_software_variable()
1959 tp->int_nums = RTASE_INTERRUPT_NUM; in rtase_init_software_variable()
1963 tp->tx_int_mit = int_miti; in rtase_init_software_variable()
1964 tp->rx_int_mit = int_miti; in rtase_init_software_variable()
1966 tp->sw_flag = 0; in rtase_init_software_variable()
1968 rtase_init_int_vector(tp); in rtase_init_software_variable()
1971 tp->dev->min_mtu = ETH_ZLEN; in rtase_init_software_variable()
1972 tp->dev->max_mtu = RTASE_MAX_JUMBO_SIZE; in rtase_init_software_variable()
1975 static bool rtase_check_mac_version_valid(struct rtase_private *tp) in rtase_check_mac_version_valid() argument
1977 u32 hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK; in rtase_check_mac_version_valid()
2066 const struct rtase_private *tp = netdev_priv(dev); in rtase_release_board() local
2068 rtase_rar_set(tp, tp->dev->perm_addr); in rtase_release_board()
2071 if (tp->sw_flag & RTASE_SWF_MSIX_ENABLED) in rtase_release_board()
2087 struct rtase_private *tp; in rtase_init_one() local
2102 tp = netdev_priv(dev); in rtase_init_one()
2103 tp->mmio_addr = ioaddr; in rtase_init_one()
2104 tp->dev = dev; in rtase_init_one()
2105 tp->pdev = pdev; in rtase_init_one()
2108 if (!rtase_check_mac_version_valid(tp)) in rtase_init_one()
2112 rtase_init_software_variable(pdev, tp); in rtase_init_one()
2113 rtase_init_hardware(tp); in rtase_init_one()
2115 ret = rtase_alloc_interrupt(pdev, tp); in rtase_init_one()
2145 tp->tally_vaddr = dma_alloc_coherent(&pdev->dev, in rtase_init_one()
2146 sizeof(*tp->tally_vaddr), in rtase_init_one()
2147 &tp->tally_paddr, in rtase_init_one()
2149 if (!tp->tally_vaddr) { in rtase_init_one()
2154 rtase_tally_counter_clear(tp); in rtase_init_one()
2169 if (tp->tally_vaddr) { in rtase_init_one()
2171 sizeof(*tp->tally_vaddr), in rtase_init_one()
2172 tp->tally_vaddr, in rtase_init_one()
2173 tp->tally_paddr); in rtase_init_one()
2175 tp->tally_vaddr = NULL; in rtase_init_one()
2179 for (i = 0; i < tp->int_nums; i++) { in rtase_init_one()
2180 ivec = &tp->int_vector[i]; in rtase_init_one()
2192 struct rtase_private *tp = netdev_priv(dev); in rtase_remove_one() local
2198 for (i = 0; i < tp->int_nums; i++) { in rtase_remove_one()
2199 ivec = &tp->int_vector[i]; in rtase_remove_one()
2203 rtase_reset_interrupt(pdev, tp); in rtase_remove_one()
2204 if (tp->tally_vaddr) { in rtase_remove_one()
2206 sizeof(*tp->tally_vaddr), in rtase_remove_one()
2207 tp->tally_vaddr, in rtase_remove_one()
2208 tp->tally_paddr); in rtase_remove_one()
2209 tp->tally_vaddr = NULL; in rtase_remove_one()
2212 rtase_release_board(pdev, dev, tp->mmio_addr); in rtase_remove_one()
2219 const struct rtase_private *tp; in rtase_shutdown() local
2221 tp = netdev_priv(dev); in rtase_shutdown()
2226 rtase_reset_interrupt(pdev, tp); in rtase_shutdown()
2244 struct rtase_private *tp = netdev_priv(dev); in rtase_resume() local
2248 rtase_rar_set(tp, dev->dev_addr); in rtase_resume()
2255 rtase_tx_clear(tp); in rtase_resume()
2256 rtase_rx_clear(tp); in rtase_resume()
2261 rtase_free_desc(tp); in rtase_resume()