Lines Matching full:adapter
270 struct al_eth_adapter *adapter; in al_attach() local
293 adapter = device_get_softc(dev); in al_attach()
294 adapter->dev = dev; in al_attach()
295 adapter->board_type = ALPINE_INTEGRATED; in al_attach()
296 snprintf(adapter->name, AL_ETH_NAME_MAX_LEN, "%s", in al_attach()
298 AL_RX_LOCK_INIT(adapter); in al_attach()
300 g_adapters[g_adapters_count] = adapter; in al_attach()
303 adapter->udma_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in al_attach()
305 if (adapter->udma_res == NULL) { in al_attach()
306 device_printf(adapter->dev, in al_attach()
311 adapter->udma_base = al_bus_dma_to_va(rman_get_bustag(adapter->udma_res), in al_attach()
312 rman_get_bushandle(adapter->udma_res)); in al_attach()
314 adapter->mac_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in al_attach()
316 if (adapter->mac_res == NULL) { in al_attach()
317 device_printf(adapter->dev, in al_attach()
322 adapter->mac_base = al_bus_dma_to_va(rman_get_bustag(adapter->mac_res), in al_attach()
323 rman_get_bushandle(adapter->mac_res)); in al_attach()
326 adapter->ec_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &bar_ec, in al_attach()
328 if (adapter->ec_res == NULL) { in al_attach()
329 device_printf(adapter->dev, in al_attach()
334 adapter->ec_base = al_bus_dma_to_va(rman_get_bustag(adapter->ec_res), in al_attach()
335 rman_get_bushandle(adapter->ec_res)); in al_attach()
337 adapter->netdev = ifp = if_alloc(IFT_ETHER); in al_attach()
339 if_setsoftc(ifp, adapter); in al_attach()
351 adapter->if_flags = if_getflags(ifp); in al_attach()
361 adapter->id_number = g_adapters_count; in al_attach()
363 if (adapter->board_type == ALPINE_INTEGRATED) { in al_attach()
364 dev_id = pci_get_device(adapter->dev); in al_attach()
365 rev_id = pci_get_revid(adapter->dev); in al_attach()
367 al_eth_fpga_read_pci_config(adapter->internal_pcie_base, in al_attach()
369 al_eth_fpga_read_pci_config(adapter->internal_pcie_base, in al_attach()
373 adapter->dev_id = dev_id; in al_attach()
374 adapter->rev_id = rev_id; in al_attach()
377 adapter->tx_ring_count = AL_ETH_DEFAULT_TX_SW_DESCS; in al_attach()
378 adapter->tx_descs_count = AL_ETH_DEFAULT_TX_HW_DESCS; in al_attach()
379 adapter->rx_ring_count = AL_ETH_DEFAULT_RX_DESCS; in al_attach()
380 adapter->rx_descs_count = AL_ETH_DEFAULT_RX_DESCS; in al_attach()
382 adapter->num_tx_queues = AL_ETH_NUM_QUEUES; in al_attach()
383 adapter->num_rx_queues = AL_ETH_NUM_QUEUES; in al_attach()
385 adapter->small_copy_len = AL_ETH_DEFAULT_SMALL_PACKET_LEN; in al_attach()
386 adapter->link_poll_interval = AL_ETH_DEFAULT_LINK_POLL_INTERVAL; in al_attach()
387 adapter->max_rx_buff_alloc_size = AL_ETH_DEFAULT_MAX_RX_BUFF_ALLOC_SIZE; in al_attach()
389 al_eth_req_rx_buff_size(adapter, if_getmtu(adapter->netdev)); in al_attach()
391 adapter->link_config.force_1000_base_x = AL_ETH_DEFAULT_FORCE_1000_BASEX; in al_attach()
393 err = al_eth_board_params_init(adapter); in al_attach()
397 if (adapter->mac_mode == AL_ETH_MAC_MODE_10GbE_Serial) { in al_attach()
398 ifmedia_init(&adapter->media, IFM_IMASK, in al_attach()
400 ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_LX, 0, NULL); in al_attach()
401 ifmedia_add(&adapter->media, IFM_ETHER | IFM_10G_LR, 0, NULL); in al_attach()
402 ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); in al_attach()
403 ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); in al_attach()
406 al_eth_function_reset(adapter); in al_attach()
408 err = al_eth_hw_init_adapter(adapter); in al_attach()
412 al_eth_init_rings(adapter); in al_attach()
415 al_eth_lm_config(adapter); in al_attach()
416 mtx_init(&adapter->stats_mtx, "AlStatsMtx", NULL, MTX_DEF); in al_attach()
417 mtx_init(&adapter->wd_mtx, "AlWdMtx", NULL, MTX_DEF); in al_attach()
418 callout_init_mtx(&adapter->stats_callout, &adapter->stats_mtx, 0); in al_attach()
419 callout_init_mtx(&adapter->wd_callout, &adapter->wd_mtx, 0); in al_attach()
421 ether_ifattach(ifp, adapter->mac_addr); in al_attach()
424 if (adapter->mac_mode == AL_ETH_MAC_MODE_RGMII) { in al_attach()
425 al_eth_hw_init(adapter); in al_attach()
428 err = mii_attach(adapter->dev, &adapter->miibus, adapter->netdev, in al_attach()
432 device_printf(adapter->dev, "attaching PHYs failed\n"); in al_attach()
436 adapter->mii = device_get_softc(adapter->miibus); in al_attach()
442 bus_release_resource(dev, SYS_RES_MEMORY, bar_ec, adapter->ec_res); in al_attach()
444 bus_release_resource(dev, SYS_RES_MEMORY, bar_mac, adapter->mac_res); in al_attach()
446 bus_release_resource(dev, SYS_RES_MEMORY, bar_udma, adapter->udma_res); in al_attach()
454 struct al_eth_adapter *adapter; in al_detach() local
456 adapter = device_get_softc(dev); in al_detach()
457 ether_ifdetach(adapter->netdev); in al_detach()
459 mtx_destroy(&adapter->stats_mtx); in al_detach()
460 mtx_destroy(&adapter->wd_mtx); in al_detach()
462 al_eth_down(adapter); in al_detach()
464 bus_release_resource(dev, SYS_RES_IRQ, 0, adapter->irq_res); in al_detach()
465 bus_release_resource(dev, SYS_RES_MEMORY, 0, adapter->ec_res); in al_detach()
466 bus_release_resource(dev, SYS_RES_MEMORY, 0, adapter->mac_res); in al_detach()
467 bus_release_resource(dev, SYS_RES_MEMORY, 0, adapter->udma_res); in al_detach()
476 /* handle is the base address of the adapter */ in al_eth_fpga_read_pci_config()
486 /* handle is the base address of the adapter */ in al_eth_fpga_write_pci_config()
524 al_eth_serdes_init(struct al_eth_adapter *adapter) in al_eth_serdes_init() argument
528 adapter->serdes_init = false; in al_eth_serdes_init()
530 serdes_base = alpine_serdes_resource_get(adapter->serdes_grp); in al_eth_serdes_init()
532 device_printf(adapter->dev, "serdes_base get failed!\n"); in al_eth_serdes_init()
538 al_serdes_handle_grp_init(serdes_base, adapter->serdes_grp, in al_eth_serdes_init()
539 &adapter->serdes_obj); in al_eth_serdes_init()
541 adapter->serdes_init = true; in al_eth_serdes_init()
598 al_eth_mac_table_unicast_add(struct al_eth_adapter *adapter, in al_eth_mac_table_unicast_add() argument
603 memcpy(entry.addr, adapter->mac_addr, sizeof(adapter->mac_addr)); in al_eth_mac_table_unicast_add()
611 device_printf_dbg(adapter->dev, in al_eth_mac_table_unicast_add()
615 al_eth_fwd_mac_table_set(&adapter->hal_adapter, idx, &entry); in al_eth_mac_table_unicast_add()
619 al_eth_mac_table_all_multicast_add(struct al_eth_adapter *adapter, uint8_t idx, in al_eth_mac_table_all_multicast_add() argument
634 device_printf_dbg(adapter->dev, in al_eth_mac_table_all_multicast_add()
638 al_eth_fwd_mac_table_set(&adapter->hal_adapter, idx, &entry); in al_eth_mac_table_all_multicast_add()
642 al_eth_mac_table_broadcast_add(struct al_eth_adapter *adapter, in al_eth_mac_table_broadcast_add() argument
655 device_printf_dbg(adapter->dev, in al_eth_mac_table_broadcast_add()
659 al_eth_fwd_mac_table_set(&adapter->hal_adapter, idx, &entry); in al_eth_mac_table_broadcast_add()
663 al_eth_mac_table_promiscuous_set(struct al_eth_adapter *adapter, in al_eth_mac_table_promiscuous_set() argument
676 device_printf_dbg(adapter->dev, "%s: %s promiscuous mode\n", in al_eth_mac_table_promiscuous_set()
679 al_eth_fwd_mac_table_set(&adapter->hal_adapter, in al_eth_mac_table_promiscuous_set()
684 al_eth_set_thash_table_entry(struct al_eth_adapter *adapter, uint8_t idx, in al_eth_set_thash_table_entry() argument
694 al_eth_thash_table_set(&adapter->hal_adapter, idx, udma, queue); in al_eth_set_thash_table_entry()
699 al_eth_fsm_table_init(struct al_eth_adapter *adapter) in al_eth_fsm_table_init() argument
723 al_eth_fsm_table_set(&adapter->hal_adapter, i, val); in al_eth_fsm_table_init()
728 al_eth_mac_table_entry_clear(struct al_eth_adapter *adapter, in al_eth_mac_table_entry_clear() argument
733 device_printf_dbg(adapter->dev, "%s: clear entry %d\n", __func__, idx); in al_eth_mac_table_entry_clear()
735 al_eth_fwd_mac_table_set(&adapter->hal_adapter, idx, &entry); in al_eth_mac_table_entry_clear()
739 al_eth_hw_init_adapter(struct al_eth_adapter *adapter) in al_eth_hw_init_adapter() argument
741 struct al_eth_adapter_params *params = &adapter->eth_hal_params; in al_eth_hw_init_adapter()
744 /* params->dev_id = adapter->dev_id; */ in al_eth_hw_init_adapter()
745 params->rev_id = adapter->rev_id; in al_eth_hw_init_adapter()
748 params->udma_regs_base = adapter->udma_base; /* UDMA register base address */ in al_eth_hw_init_adapter()
749 params->ec_regs_base = adapter->ec_base; /* Ethernet controller registers base address */ in al_eth_hw_init_adapter()
750 params->mac_regs_base = adapter->mac_base; /* Ethernet MAC registers base address */ in al_eth_hw_init_adapter()
751 params->name = adapter->name; in al_eth_hw_init_adapter()
752 params->serdes_lane = adapter->serdes_lane; in al_eth_hw_init_adapter()
754 rc = al_eth_adapter_init(&adapter->hal_adapter, params); in al_eth_hw_init_adapter()
756 device_printf(adapter->dev, "%s failed at hal init!\n", in al_eth_hw_init_adapter()
759 if ((adapter->board_type == ALPINE_NIC) || in al_eth_hw_init_adapter()
760 (adapter->board_type == ALPINE_FPGA_NIC)) { in al_eth_hw_init_adapter()
772 al_udma_gen_tgtid_conf_set(adapter->udma_base, &conf); in al_eth_hw_init_adapter()
779 al_eth_lm_config(struct al_eth_adapter *adapter) in al_eth_lm_config() argument
783 params.adapter = &adapter->hal_adapter; in al_eth_lm_config()
784 params.serdes_obj = &adapter->serdes_obj; in al_eth_lm_config()
785 params.lane = adapter->serdes_lane; in al_eth_lm_config()
786 params.sfp_detection = adapter->sfp_detection_needed; in al_eth_lm_config()
787 if (adapter->sfp_detection_needed == true) { in al_eth_lm_config()
788 params.sfp_bus_id = adapter->i2c_adapter_id; in al_eth_lm_config()
792 if (adapter->sfp_detection_needed == false) { in al_eth_lm_config()
793 switch (adapter->mac_mode) { in al_eth_lm_config()
795 if ((adapter->lt_en != 0) && (adapter->an_en != 0)) in al_eth_lm_config()
809 params.link_training = adapter->lt_en; in al_eth_lm_config()
811 params.static_values = !adapter->dont_override_serdes; in al_eth_lm_config()
812 params.i2c_context = adapter; in al_eth_lm_config()
815 params.retimer_exist = adapter->retimer.exist; in al_eth_lm_config()
816 params.retimer_bus_id = adapter->retimer.bus_id; in al_eth_lm_config()
817 params.retimer_i2c_addr = adapter->retimer.i2c_addr; in al_eth_lm_config()
818 params.retimer_channel = adapter->retimer.channel; in al_eth_lm_config()
820 al_eth_lm_init(&adapter->lm_context, ¶ms); in al_eth_lm_config()
824 al_eth_board_params_init(struct al_eth_adapter *adapter) in al_eth_board_params_init() argument
827 if (adapter->board_type == ALPINE_NIC) { in al_eth_board_params_init()
828 adapter->mac_mode = AL_ETH_MAC_MODE_10GbE_Serial; in al_eth_board_params_init()
829 adapter->sfp_detection_needed = false; in al_eth_board_params_init()
830 adapter->phy_exist = false; in al_eth_board_params_init()
831 adapter->an_en = false; in al_eth_board_params_init()
832 adapter->lt_en = false; in al_eth_board_params_init()
833 adapter->ref_clk_freq = AL_ETH_REF_FREQ_375_MHZ; in al_eth_board_params_init()
834 adapter->mdio_freq = AL_ETH_DEFAULT_MDIO_FREQ_KHZ; in al_eth_board_params_init()
835 } else if (adapter->board_type == ALPINE_FPGA_NIC) { in al_eth_board_params_init()
836 adapter->mac_mode = AL_ETH_MAC_MODE_SGMII; in al_eth_board_params_init()
837 adapter->sfp_detection_needed = false; in al_eth_board_params_init()
838 adapter->phy_exist = false; in al_eth_board_params_init()
839 adapter->an_en = false; in al_eth_board_params_init()
840 adapter->lt_en = false; in al_eth_board_params_init()
841 adapter->ref_clk_freq = AL_ETH_REF_FREQ_375_MHZ; in al_eth_board_params_init()
842 adapter->mdio_freq = AL_ETH_DEFAULT_MDIO_FREQ_KHZ; in al_eth_board_params_init()
847 adapter->auto_speed = false; in al_eth_board_params_init()
849 rc = al_eth_board_params_get(adapter->mac_base, ¶ms); in al_eth_board_params_init()
851 device_printf(adapter->dev, in al_eth_board_params_init()
856 adapter->phy_exist = params.phy_exist == true; in al_eth_board_params_init()
857 adapter->phy_addr = params.phy_mdio_addr; in al_eth_board_params_init()
858 adapter->an_en = params.autoneg_enable; in al_eth_board_params_init()
859 adapter->lt_en = params.kr_lt_enable; in al_eth_board_params_init()
860 adapter->serdes_grp = params.serdes_grp; in al_eth_board_params_init()
861 adapter->serdes_lane = params.serdes_lane; in al_eth_board_params_init()
862 adapter->sfp_detection_needed = params.sfp_plus_module_exist; in al_eth_board_params_init()
863 adapter->i2c_adapter_id = params.i2c_adapter_id; in al_eth_board_params_init()
864 adapter->ref_clk_freq = params.ref_clk_freq; in al_eth_board_params_init()
865 adapter->dont_override_serdes = params.dont_override_serdes; in al_eth_board_params_init()
866 adapter->link_config.active_duplex = !params.half_duplex; in al_eth_board_params_init()
867 adapter->link_config.autoneg = !params.an_disable; in al_eth_board_params_init()
868 adapter->link_config.force_1000_base_x = params.force_1000_base_x; in al_eth_board_params_init()
869 adapter->retimer.exist = params.retimer_exist; in al_eth_board_params_init()
870 adapter->retimer.bus_id = params.retimer_bus_id; in al_eth_board_params_init()
871 adapter->retimer.i2c_addr = params.retimer_i2c_addr; in al_eth_board_params_init()
872 adapter->retimer.channel = params.retimer_channel; in al_eth_board_params_init()
876 device_printf(adapter->dev, in al_eth_board_params_init()
879 adapter->link_config.active_speed = 1000; in al_eth_board_params_init()
882 adapter->link_config.active_speed = 100; in al_eth_board_params_init()
885 adapter->link_config.active_speed = 10; in al_eth_board_params_init()
891 device_printf(adapter->dev, in al_eth_board_params_init()
895 adapter->mdio_freq = AL_ETH_DEFAULT_MDIO_FREQ_KHZ; in al_eth_board_params_init()
898 adapter->mdio_freq = AL_ETH_MDIO_FREQ_1000_KHZ; in al_eth_board_params_init()
906 adapter->mac_mode = AL_ETH_MAC_MODE_SGMII; in al_eth_board_params_init()
908 adapter->mac_mode = AL_ETH_MAC_MODE_RGMII; in al_eth_board_params_init()
910 adapter->use_lm = false; in al_eth_board_params_init()
913 adapter->mac_mode = AL_ETH_MAC_MODE_SGMII; in al_eth_board_params_init()
914 adapter->use_lm = true; in al_eth_board_params_init()
917 adapter->mac_mode = AL_ETH_MAC_MODE_10GbE_Serial; in al_eth_board_params_init()
918 adapter->use_lm = true; in al_eth_board_params_init()
921 adapter->sfp_detection_needed = true; in al_eth_board_params_init()
922 adapter->auto_speed = false; in al_eth_board_params_init()
923 adapter->use_lm = true; in al_eth_board_params_init()
926 adapter->sfp_detection_needed = true; in al_eth_board_params_init()
927 adapter->auto_speed = true; in al_eth_board_params_init()
928 adapter->mac_mode_set = false; in al_eth_board_params_init()
929 adapter->use_lm = true; in al_eth_board_params_init()
931 adapter->mac_mode = AL_ETH_MAC_MODE_10GbE_Serial; in al_eth_board_params_init()
934 device_printf(adapter->dev, in al_eth_board_params_init()
940 device_printf(adapter->dev, in al_eth_board_params_init()
944 params.phy_mdio_addr, adapter->mdio_freq, in al_eth_board_params_init()
949 al_eth_mac_addr_read(adapter->ec_base, 0, adapter->mac_addr); in al_eth_board_params_init()
955 al_eth_function_reset(struct al_eth_adapter *adapter) in al_eth_function_reset() argument
961 al_eth_board_params_get(adapter->mac_base, ¶ms); in al_eth_function_reset()
962 al_eth_mac_addr_read(adapter->ec_base, 0, adapter->mac_addr); in al_eth_function_reset()
963 if (adapter->board_type == ALPINE_INTEGRATED) in al_eth_function_reset()
966 adapter->dev, adapter->mac_base); in al_eth_function_reset()
970 adapter->internal_pcie_base, adapter->mac_base); in al_eth_function_reset()
973 al_eth_board_params_set(adapter->mac_base, ¶ms); in al_eth_function_reset()
974 al_eth_mac_addr_store(adapter->ec_base, 0, adapter->mac_addr); in al_eth_function_reset()
980 al_eth_init_rings(struct al_eth_adapter *adapter) in al_eth_init_rings() argument
984 for (i = 0; i < adapter->num_tx_queues; i++) { in al_eth_init_rings()
985 struct al_eth_ring *ring = &adapter->tx_ring[i]; in al_eth_init_rings()
988 ring->dev = adapter->dev; in al_eth_init_rings()
989 ring->adapter = adapter; in al_eth_init_rings()
990 ring->netdev = adapter->netdev; in al_eth_init_rings()
991 al_udma_q_handle_get(&adapter->hal_adapter.tx_udma, i, in al_eth_init_rings()
993 ring->sw_count = adapter->tx_ring_count; in al_eth_init_rings()
994 ring->hw_count = adapter->tx_descs_count; in al_eth_init_rings()
995 …ring->unmask_reg_offset = al_udma_iofic_unmask_offset_get((struct unit_regs *)adapter->udma_base, … in al_eth_init_rings()
999 for (i = 0; i < adapter->num_rx_queues; i++) { in al_eth_init_rings()
1000 struct al_eth_ring *ring = &adapter->rx_ring[i]; in al_eth_init_rings()
1003 ring->dev = adapter->dev; in al_eth_init_rings()
1004 ring->adapter = adapter; in al_eth_init_rings()
1005 ring->netdev = adapter->netdev; in al_eth_init_rings()
1006 al_udma_q_handle_get(&adapter->hal_adapter.rx_udma, i, &ring->dma_q); in al_eth_init_rings()
1007 ring->sw_count = adapter->rx_ring_count; in al_eth_init_rings()
1008 ring->hw_count = adapter->rx_descs_count; in al_eth_init_rings()
1010 (struct unit_regs *)adapter->udma_base, in al_eth_init_rings()
1019 struct al_eth_adapter *adapter = arg; in al_init_locked() local
1020 if_t ifp = adapter->netdev; in al_init_locked()
1023 al_eth_down(adapter); in al_init_locked()
1024 rc = al_eth_up(adapter); in al_init_locked()
1034 struct al_eth_adapter *adapter = arg; in al_init() local
1036 al_init_locked(adapter); in al_init()
1040 al_eth_alloc_rx_buf(struct al_eth_adapter *adapter, in al_eth_alloc_rx_buf() argument
1052 rx_info->data_size = adapter->rx_mbuf_sz; in al_eth_alloc_rx_buf()
1054 AL_RX_LOCK(adapter); in al_eth_alloc_rx_buf()
1059 AL_RX_UNLOCK(adapter); in al_eth_alloc_rx_buf()
1064 rx_info->m->m_pkthdr.len = rx_info->m->m_len = adapter->rx_mbuf_sz; in al_eth_alloc_rx_buf()
1085 al_eth_refill_rx_bufs(struct al_eth_adapter *adapter, unsigned int qid, in al_eth_refill_rx_bufs() argument
1088 struct al_eth_ring *rx_ring = &adapter->rx_ring[qid]; in al_eth_refill_rx_bufs()
1099 if (__predict_false(al_eth_alloc_rx_buf(adapter, in al_eth_refill_rx_bufs()
1101 device_printf(adapter->dev, in al_eth_refill_rx_bufs()
1109 device_printf(adapter->dev, in al_eth_refill_rx_bufs()
1118 device_printf(adapter->dev, in al_eth_refill_rx_bufs()
1132 * @adapter: board private structure
1135 al_eth_refill_all_rx_bufs(struct al_eth_adapter *adapter) in al_eth_refill_all_rx_bufs() argument
1139 for (i = 0; i < adapter->num_rx_queues; i++) in al_eth_refill_all_rx_bufs()
1140 al_eth_refill_rx_bufs(adapter, i, AL_ETH_DEFAULT_RX_DESCS - 1); in al_eth_refill_all_rx_bufs()
1471 * @adapter: structure containing adapter specific data
1476 al_eth_rx_checksum(struct al_eth_adapter *adapter, in al_eth_rx_checksum() argument
1481 if (unlikely((if_getcapenable(adapter->netdev) & IFCAP_RXCSUM) && in al_eth_rx_checksum()
1484 device_printf(adapter->dev,"rx ipv4 header checksum error\n"); in al_eth_rx_checksum()
1489 if (unlikely((if_getcapenable(adapter->netdev) & IFCAP_RXCSUM_IPV6) && in al_eth_rx_checksum()
1492 device_printf(adapter->dev,"rx ipv6 header checksum error\n"); in al_eth_rx_checksum()
1500 device_printf_dbg(adapter->dev, "rx L4 checksum error\n"); in al_eth_rx_checksum()
1505 device_printf_dbg(adapter->dev, "rx checksum correct\n"); in al_eth_rx_checksum()
1515 al_eth_rx_mbuf(struct al_eth_adapter *adapter, in al_eth_rx_mbuf() argument
1525 device_printf_dbg(adapter->dev, "rx_info %p data %p\n", rx_info, in al_eth_rx_mbuf()
1540 if (len <= adapter->small_copy_len) { in al_eth_rx_mbuf()
1542 device_printf_dbg(adapter->dev, "rx small packet. len %d\n", len); in al_eth_rx_mbuf()
1544 AL_RX_LOCK(adapter); in al_eth_rx_mbuf()
1546 AL_RX_UNLOCK(adapter); in al_eth_rx_mbuf()
1548 device_printf(adapter->dev, "smbuf is NULL\n"); in al_eth_rx_mbuf()
1619 mbuf = al_eth_rx_mbuf(rx_ring->adapter, rx_ring, hal_pkt, descs, in al_eth_rx_recv_work()
1631 al_eth_rx_checksum(rx_ring->adapter, hal_pkt, mbuf); in al_eth_rx_recv_work()
1665 refill_actual = al_eth_refill_rx_bufs(rx_ring->adapter, qid, in al_eth_rx_recv_work()
1722 struct al_eth_adapter *adapter = if_getsoftc(ifp); in al_mq_start() local
1729 i = m->m_pkthdr.flowid % adapter->num_tx_queues; in al_mq_start()
1731 i = curcpu % adapter->num_tx_queues; in al_mq_start()
1738 tx_ring = &adapter->tx_ring[i]; in al_mq_start()
1740 device_printf_dbg(adapter->dev, "dgb start() - assuming link is active, " in al_mq_start()
1763 al_eth_flow_ctrl_init(struct al_eth_adapter *adapter) in al_eth_flow_ctrl_init() argument
1770 adapter->link_config.flow_ctrl_supported = default_flow_ctrl; in al_eth_flow_ctrl_init()
1774 al_eth_flow_ctrl_config(struct al_eth_adapter *adapter) in al_eth_flow_ctrl_config() argument
1777 uint8_t active = adapter->link_config.flow_ctrl_active; in al_eth_flow_ctrl_config()
1780 flow_ctrl_params = &adapter->flow_ctrl_params; in al_eth_flow_ctrl_config()
1797 al_eth_flow_control_config(&adapter->hal_adapter, flow_ctrl_params); in al_eth_flow_ctrl_config()
1803 al_eth_flow_ctrl_enable(struct al_eth_adapter *adapter) in al_eth_flow_ctrl_enable() argument
1810 adapter->link_config.flow_ctrl_active = in al_eth_flow_ctrl_enable()
1811 adapter->link_config.flow_ctrl_supported; in al_eth_flow_ctrl_enable()
1813 al_eth_flow_ctrl_config(adapter); in al_eth_flow_ctrl_enable()
1817 al_eth_flow_ctrl_disable(struct al_eth_adapter *adapter) in al_eth_flow_ctrl_disable() argument
1820 adapter->link_config.flow_ctrl_active = 0; in al_eth_flow_ctrl_disable()
1821 al_eth_flow_ctrl_config(adapter); in al_eth_flow_ctrl_disable()
1825 al_eth_hw_init(struct al_eth_adapter *adapter) in al_eth_hw_init() argument
1829 rc = al_eth_hw_init_adapter(adapter); in al_eth_hw_init()
1833 rc = al_eth_mac_config(&adapter->hal_adapter, adapter->mac_mode); in al_eth_hw_init()
1835 device_printf(adapter->dev, "%s failed to configure mac!\n", in al_eth_hw_init()
1840 if ((adapter->mac_mode == AL_ETH_MAC_MODE_SGMII) || in al_eth_hw_init()
1841 (adapter->mac_mode == AL_ETH_MAC_MODE_RGMII && in al_eth_hw_init()
1842 adapter->phy_exist == false)) { in al_eth_hw_init()
1843 rc = al_eth_mac_link_config(&adapter->hal_adapter, in al_eth_hw_init()
1844 adapter->link_config.force_1000_base_x, in al_eth_hw_init()
1845 adapter->link_config.autoneg, in al_eth_hw_init()
1846 adapter->link_config.active_speed, in al_eth_hw_init()
1847 adapter->link_config.active_duplex); in al_eth_hw_init()
1849 device_printf(adapter->dev, in al_eth_hw_init()
1856 rc = al_eth_mdio_config(&adapter->hal_adapter, in al_eth_hw_init()
1858 adapter->ref_clk_freq, adapter->mdio_freq); in al_eth_hw_init()
1860 device_printf(adapter->dev, "%s failed at mdio config!\n", in al_eth_hw_init()
1865 al_eth_flow_ctrl_init(adapter); in al_eth_hw_init()
1871 al_eth_hw_stop(struct al_eth_adapter *adapter) in al_eth_hw_stop() argument
1874 al_eth_mac_stop(&adapter->hal_adapter); in al_eth_hw_stop()
1883 al_eth_adapter_stop(&adapter->hal_adapter); in al_eth_hw_stop()
1885 adapter->flags |= AL_ETH_FLAG_RESET_REQUESTED; in al_eth_hw_stop()
1888 al_eth_flow_ctrl_disable(adapter); in al_eth_hw_stop()
1901 struct al_eth_adapter *adapter = data; in al_eth_intr_intx_all() local
1904 (struct unit_regs __iomem *)adapter->udma_base; in al_eth_intr_intx_all()
1910 device_printf_dbg(adapter->dev, "%s group A cause %x\n", in al_eth_intr_intx_all()
1921 device_printf_dbg(adapter->dev, in al_eth_intr_intx_all()
1926 device_printf(adapter->dev, in al_eth_intr_intx_all()
1932 device_printf_dbg(adapter->dev, in al_eth_intr_intx_all()
1940 device_printf_dbg(adapter->dev, "secondary B cause %x\n", in al_eth_intr_intx_all()
1942 for (qid = 0; qid < adapter->num_rx_queues; qid++) { in al_eth_intr_intx_all()
1946 (struct unit_regs __iomem *)adapter->udma_base, in al_eth_intr_intx_all()
1956 device_printf_dbg(adapter->dev, "secondary C cause %x\n", cause_c); in al_eth_intr_intx_all()
1957 for (qid = 0; qid < adapter->num_tx_queues; qid++) { in al_eth_intr_intx_all()
1960 (struct unit_regs __iomem *)adapter->udma_base, in al_eth_intr_intx_all()
1967 al_eth_tx_cmlp_irq_filter(adapter->tx_ring); in al_eth_intr_intx_all()
1975 struct al_eth_adapter *adapter = data; in al_eth_intr_msix_all() local
1977 device_printf_dbg(adapter->dev, "%s\n", __func__); in al_eth_intr_msix_all()
1984 struct al_eth_adapter *adapter = data; in al_eth_intr_msix_mgmt() local
1986 device_printf_dbg(adapter->dev, "%s\n", __func__); in al_eth_intr_msix_mgmt()
1991 al_eth_enable_msix(struct al_eth_adapter *adapter) in al_eth_enable_msix() argument
1995 device_printf_dbg(adapter->dev, "%s\n", __func__); in al_eth_enable_msix()
1996 msix_vecs = 1 + adapter->num_rx_queues + adapter->num_tx_queues; in al_eth_enable_msix()
1998 device_printf_dbg(adapter->dev, in al_eth_enable_msix()
2001 adapter->msix_entries = malloc(msix_vecs*sizeof(*adapter->msix_entries), in al_eth_enable_msix()
2004 adapter->msix_entries[AL_ETH_MGMT_IRQ_IDX].entry = 2; in al_eth_enable_msix()
2005 adapter->msix_entries[AL_ETH_MGMT_IRQ_IDX].vector = 0; in al_eth_enable_msix()
2008 for (i = 0; i < adapter->num_rx_queues; i++) { in al_eth_enable_msix()
2009 int irq_idx = AL_ETH_RXQ_IRQ_IDX(adapter, i); in al_eth_enable_msix()
2011 adapter->msix_entries[irq_idx].entry = 3 + i; in al_eth_enable_msix()
2012 adapter->msix_entries[irq_idx].vector = 0; in al_eth_enable_msix()
2015 for (i = 0; i < adapter->num_tx_queues; i++) { in al_eth_enable_msix()
2016 int irq_idx = AL_ETH_TXQ_IRQ_IDX(adapter, i); in al_eth_enable_msix()
2018 adapter->msix_entries[irq_idx].entry = 3 + in al_eth_enable_msix()
2020 adapter->msix_entries[irq_idx].vector = 0; in al_eth_enable_msix()
2024 rc = pci_alloc_msix(adapter->dev, &count); in al_eth_enable_msix()
2027 device_printf_dbg(adapter->dev, "failed to allocate MSIX " in al_eth_enable_msix()
2029 device_printf_dbg(adapter->dev, "ret = %d\n", rc); in al_eth_enable_msix()
2034 device_printf_dbg(adapter->dev, "failed to allocate all MSIX " in al_eth_enable_msix()
2041 adapter->msix_entries[i].vector = 2 + 1 + i; in al_eth_enable_msix()
2043 device_printf_dbg(adapter->dev, "successfully enabled MSIX," in al_eth_enable_msix()
2046 adapter->msix_vecs = msix_vecs; in al_eth_enable_msix()
2047 adapter->flags |= AL_ETH_FLAG_MSIX_ENABLED; in al_eth_enable_msix()
2051 adapter->msix_vecs = 0; in al_eth_enable_msix()
2052 free(adapter->msix_entries, M_IFAL); in al_eth_enable_msix()
2053 adapter->msix_entries = NULL; in al_eth_enable_msix()
2060 al_eth_setup_int_mode(struct al_eth_adapter *adapter) in al_eth_setup_int_mode() argument
2064 rc = al_eth_enable_msix(adapter); in al_eth_setup_int_mode()
2066 device_printf(adapter->dev, "Failed to enable MSIX mode.\n"); in al_eth_setup_int_mode()
2070 adapter->irq_vecs = max(1, adapter->msix_vecs); in al_eth_setup_int_mode()
2072 if (adapter->msix_vecs == 0) { in al_eth_setup_int_mode()
2073 snprintf(adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].name, in al_eth_setup_int_mode()
2075 device_get_name(adapter->dev)); in al_eth_setup_int_mode()
2076 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].handler = in al_eth_setup_int_mode()
2079 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].vector = 0; in al_eth_setup_int_mode()
2080 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].data = adapter; in al_eth_setup_int_mode()
2082 device_printf(adapter->dev, "%s and vector %d \n", __func__, in al_eth_setup_int_mode()
2083 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].vector); in al_eth_setup_int_mode()
2088 if (adapter->msix_vecs == 1) { in al_eth_setup_int_mode()
2089 snprintf(adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].name, in al_eth_setup_int_mode()
2091 device_get_name(adapter->dev)); in al_eth_setup_int_mode()
2092 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].handler = in al_eth_setup_int_mode()
2094 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].vector = in al_eth_setup_int_mode()
2095 adapter->msix_entries[AL_ETH_MGMT_IRQ_IDX].vector; in al_eth_setup_int_mode()
2096 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].data = adapter; in al_eth_setup_int_mode()
2101 snprintf(adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].name, AL_ETH_IRQNAME_SIZE, in al_eth_setup_int_mode()
2102 "al-eth-msix-mgmt@pci:%s", device_get_name(adapter->dev)); in al_eth_setup_int_mode()
2103 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].handler = al_eth_intr_msix_mgmt; in al_eth_setup_int_mode()
2105 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].data = adapter; in al_eth_setup_int_mode()
2106 adapter->irq_tbl[AL_ETH_MGMT_IRQ_IDX].vector = in al_eth_setup_int_mode()
2107 adapter->msix_entries[AL_ETH_MGMT_IRQ_IDX].vector; in al_eth_setup_int_mode()
2109 for (i = 0; i < adapter->num_rx_queues; i++) { in al_eth_setup_int_mode()
2110 int irq_idx = AL_ETH_RXQ_IRQ_IDX(adapter, i); in al_eth_setup_int_mode()
2112 snprintf(adapter->irq_tbl[irq_idx].name, AL_ETH_IRQNAME_SIZE, in al_eth_setup_int_mode()
2114 device_get_name(adapter->dev)); in al_eth_setup_int_mode()
2115 adapter->irq_tbl[irq_idx].handler = al_eth_rx_recv_irq_filter; in al_eth_setup_int_mode()
2116 adapter->irq_tbl[irq_idx].data = &adapter->rx_ring[i]; in al_eth_setup_int_mode()
2117 adapter->irq_tbl[irq_idx].vector = in al_eth_setup_int_mode()
2118 adapter->msix_entries[irq_idx].vector; in al_eth_setup_int_mode()
2121 for (i = 0; i < adapter->num_tx_queues; i++) { in al_eth_setup_int_mode()
2122 int irq_idx = AL_ETH_TXQ_IRQ_IDX(adapter, i); in al_eth_setup_int_mode()
2124 snprintf(adapter->irq_tbl[irq_idx].name, in al_eth_setup_int_mode()
2126 device_get_name(adapter->dev)); in al_eth_setup_int_mode()
2127 adapter->irq_tbl[irq_idx].handler = al_eth_tx_cmlp_irq_filter; in al_eth_setup_int_mode()
2128 adapter->irq_tbl[irq_idx].data = &adapter->tx_ring[i]; in al_eth_setup_int_mode()
2129 adapter->irq_tbl[irq_idx].vector = in al_eth_setup_int_mode()
2130 adapter->msix_entries[irq_idx].vector; in al_eth_setup_int_mode()
2137 __al_eth_free_irq(struct al_eth_adapter *adapter) in __al_eth_free_irq() argument
2142 for (i = 0; i < adapter->irq_vecs; i++) { in __al_eth_free_irq()
2143 irq = &adapter->irq_tbl[i]; in __al_eth_free_irq()
2145 device_printf_dbg(adapter->dev, "tear down irq: %d\n", in __al_eth_free_irq()
2147 rc = bus_teardown_intr(adapter->dev, irq->res, in __al_eth_free_irq()
2150 device_printf(adapter->dev, "failed to tear " in __al_eth_free_irq()
2158 al_eth_free_irq(struct al_eth_adapter *adapter) in al_eth_free_irq() argument
2163 if (adapter->msix_vecs >= 1) { in al_eth_free_irq()
2164 free_irq_cpu_rmap(adapter->netdev->rx_cpu_rmap); in al_eth_free_irq()
2165 adapter->netdev->rx_cpu_rmap = NULL; in al_eth_free_irq()
2169 __al_eth_free_irq(adapter); in al_eth_free_irq()
2171 for (i = 0; i < adapter->irq_vecs; i++) { in al_eth_free_irq()
2172 irq = &adapter->irq_tbl[i]; in al_eth_free_irq()
2175 device_printf_dbg(adapter->dev, "release resource irq: %d\n", in al_eth_free_irq()
2177 rc = bus_release_resource(adapter->dev, SYS_RES_IRQ, irq->vector, in al_eth_free_irq()
2181 device_printf(adapter->dev, "dev has no parent while " in al_eth_free_irq()
2185 pci_release_msi(adapter->dev); in al_eth_free_irq()
2187 adapter->flags &= ~AL_ETH_FLAG_MSIX_ENABLED; in al_eth_free_irq()
2189 adapter->msix_vecs = 0; in al_eth_free_irq()
2190 free(adapter->msix_entries, M_IFAL); in al_eth_free_irq()
2191 adapter->msix_entries = NULL; in al_eth_free_irq()
2195 al_eth_request_irq(struct al_eth_adapter *adapter) in al_eth_request_irq() argument
2201 if ((adapter->flags & AL_ETH_FLAG_MSIX_ENABLED) != 0) in al_eth_request_irq()
2206 for (i = 0; i < adapter->irq_vecs; i++) { in al_eth_request_irq()
2207 irq = &adapter->irq_tbl[i]; in al_eth_request_irq()
2212 irq->res = bus_alloc_resource_any(adapter->dev, SYS_RES_IRQ, in al_eth_request_irq()
2215 device_printf(adapter->dev, "could not allocate " in al_eth_request_irq()
2221 if ((rc = bus_setup_intr(adapter->dev, irq->res, in al_eth_request_irq()
2224 device_printf(adapter->dev, "failed to register " in al_eth_request_irq()
2237 irq = &adapter->irq_tbl[v]; in al_eth_request_irq()
2238 bti = bus_teardown_intr(adapter->dev, irq->res, irq->cookie); in al_eth_request_irq()
2240 device_printf(adapter->dev, "failed to tear " in al_eth_request_irq()
2245 device_printf_dbg(adapter->dev, "exit_intr: releasing irq %d\n", in al_eth_request_irq()
2253 irq = &adapter->irq_tbl[v]; in al_eth_request_irq()
2254 device_printf_dbg(adapter->dev, "exit_res: releasing resource" in al_eth_request_irq()
2256 brr = bus_release_resource(adapter->dev, SYS_RES_IRQ, in al_eth_request_irq()
2259 device_printf(adapter->dev, "dev has no parent while " in al_eth_request_irq()
2270 * @adapter: network interface device structure
2276 al_eth_setup_tx_resources(struct al_eth_adapter *adapter, int qid) in al_eth_setup_tx_resources() argument
2278 struct al_eth_ring *tx_ring = &adapter->tx_ring[qid]; in al_eth_setup_tx_resources()
2284 if (adapter->up) in al_eth_setup_tx_resources()
2318 device_get_nameunit(adapter->dev)); in al_eth_setup_tx_resources()
2323 device_get_nameunit(adapter->dev)); in al_eth_setup_tx_resources()
2367 * @adapter: network interface device structure
2373 al_eth_free_tx_resources(struct al_eth_adapter *adapter, int qid) in al_eth_free_tx_resources() argument
2375 struct al_eth_ring *tx_ring = &adapter->tx_ring[qid]; in al_eth_free_tx_resources()
2392 drbr_flush(adapter->netdev, tx_ring->br); in al_eth_free_tx_resources()
2424 * @adapter: board private structure
2429 al_eth_free_all_tx_resources(struct al_eth_adapter *adapter) in al_eth_free_all_tx_resources() argument
2433 for (i = 0; i < adapter->num_tx_queues; i++) in al_eth_free_all_tx_resources()
2434 if (adapter->tx_ring[i].q_params.desc_base) in al_eth_free_all_tx_resources()
2435 al_eth_free_tx_resources(adapter, i); in al_eth_free_all_tx_resources()
2440 * @adapter: network interface device structure
2446 al_eth_setup_rx_resources(struct al_eth_adapter *adapter, unsigned int qid) in al_eth_setup_rx_resources() argument
2448 struct al_eth_ring *rx_ring = &adapter->rx_ring[qid]; in al_eth_setup_rx_resources()
2487 device_get_nameunit(adapter->dev)); in al_eth_setup_rx_resources()
2521 if ((if_getcapenable(adapter->netdev) & IFCAP_LRO) != 0) { in al_eth_setup_rx_resources()
2524 device_printf(adapter->dev, in al_eth_setup_rx_resources()
2527 device_printf_dbg(adapter->dev, in al_eth_setup_rx_resources()
2530 rx_ring->lro.ifp = adapter->netdev; in al_eth_setup_rx_resources()
2542 * @adapter: network interface device structure
2548 al_eth_free_rx_resources(struct al_eth_adapter *adapter, unsigned int qid) in al_eth_free_rx_resources() argument
2550 struct al_eth_ring *rx_ring = &adapter->rx_ring[qid]; in al_eth_free_rx_resources()
2599 * @adapter: board private structure
2604 al_eth_free_all_rx_resources(struct al_eth_adapter *adapter) in al_eth_free_all_rx_resources() argument
2608 for (i = 0; i < adapter->num_rx_queues; i++) in al_eth_free_all_rx_resources()
2609 if (adapter->rx_ring[i].q_params.desc_base != 0) in al_eth_free_all_rx_resources()
2610 al_eth_free_rx_resources(adapter, i); in al_eth_free_all_rx_resources()
2615 * @adapter: board private structure
2620 al_eth_setup_all_rx_resources(struct al_eth_adapter *adapter) in al_eth_setup_all_rx_resources() argument
2624 for (i = 0; i < adapter->num_rx_queues; i++) { in al_eth_setup_all_rx_resources()
2625 rc = al_eth_setup_rx_resources(adapter, i); in al_eth_setup_all_rx_resources()
2629 device_printf(adapter->dev, "Allocation for Rx Queue %u failed\n", i); in al_eth_setup_all_rx_resources()
2637 al_eth_free_rx_resources(adapter, i); in al_eth_setup_all_rx_resources()
2643 * @adapter: private structure
2648 al_eth_setup_all_tx_resources(struct al_eth_adapter *adapter) in al_eth_setup_all_tx_resources() argument
2652 for (i = 0; i < adapter->num_tx_queues; i++) { in al_eth_setup_all_tx_resources()
2653 rc = al_eth_setup_tx_resources(adapter, i); in al_eth_setup_all_tx_resources()
2657 device_printf(adapter->dev, in al_eth_setup_all_tx_resources()
2667 al_eth_free_tx_resources(adapter, i); in al_eth_setup_all_tx_resources()
2673 al_eth_disable_int_sync(struct al_eth_adapter *adapter) in al_eth_disable_int_sync() argument
2677 if ((adapter->board_type == ALPINE_FPGA_NIC) || in al_eth_disable_int_sync()
2678 (adapter->board_type == ALPINE_NIC)) { in al_eth_disable_int_sync()
2679 al_eth_forward_int_config((uint32_t*)adapter->internal_pcie_base + in al_eth_disable_int_sync()
2684 al_eth_interrupts_mask(adapter); in al_eth_disable_int_sync()
2688 al_eth_interrupts_unmask(struct al_eth_adapter *adapter) in al_eth_interrupts_unmask() argument
2691 uint32_t group_b_mask = (1 << adapter->num_rx_queues) - 1;/* bit per Rx q*/ in al_eth_interrupts_unmask()
2692 uint32_t group_c_mask = (1 << adapter->num_tx_queues) - 1;/* bit per Tx q*/ in al_eth_interrupts_unmask()
2695 (struct unit_regs __iomem *)adapter->udma_base; in al_eth_interrupts_unmask()
2697 if (adapter->int_mode == AL_IOFIC_MODE_LEGACY) in al_eth_interrupts_unmask()
2713 al_eth_interrupts_mask(struct al_eth_adapter *adapter) in al_eth_interrupts_mask() argument
2716 (struct unit_regs __iomem *)adapter->udma_base; in al_eth_interrupts_mask()
2730 al_eth_configure_int_mode(struct al_eth_adapter *adapter) in al_eth_configure_int_mode() argument
2739 if (adapter->msix_vecs == 0) in al_eth_configure_int_mode()
2741 else if (adapter->msix_vecs > 1) in al_eth_configure_int_mode()
2744 device_printf(adapter->dev, in al_eth_configure_int_mode()
2749 if (adapter->board_type != ALPINE_INTEGRATED) { in al_eth_configure_int_mode()
2756 if (al_udma_iofic_config((struct unit_regs __iomem *)adapter->udma_base, in al_eth_configure_int_mode()
2759 device_printf(adapter->dev, in al_eth_configure_int_mode()
2763 adapter->int_mode = int_mode; in al_eth_configure_int_mode()
2764 device_printf_dbg(adapter->dev, "using %s interrupt mode\n", in al_eth_configure_int_mode()
2768 …al_iofic_moder_res_config(&((struct unit_regs *)(adapter->udma_base))->gen.interrupt_regs.main_iof… in al_eth_configure_int_mode()
2769 …al_iofic_moder_res_config(&((struct unit_regs *)(adapter->udma_base))->gen.interrupt_regs.main_iof… in al_eth_configure_int_mode()
2771 adapter->tx_usecs = 0; in al_eth_configure_int_mode()
2772 adapter->rx_usecs = 0; in al_eth_configure_int_mode()
2792 al_eth_update_stats(struct al_eth_adapter *adapter) in al_eth_update_stats() argument
2794 struct al_eth_mac_stats *mac_stats = &adapter->mac_stats; in al_eth_update_stats()
2796 if (adapter->up == 0) in al_eth_update_stats()
2799 al_eth_mac_stats_get(&adapter->hal_adapter, mac_stats); in al_eth_update_stats()
2807 struct al_eth_adapter *adapter; in al_get_counter() local
2811 adapter = if_getsoftc(ifp); in al_get_counter()
2812 mac_stats = &adapter->mac_stats; in al_get_counter()
2863 struct al_eth_adapter *adapter = arg; in al_program_addr() local
2865 al_eth_mac_table_unicast_add(adapter, in al_program_addr()
2880 al_eth_set_rx_mode(struct al_eth_adapter *adapter) in al_eth_set_rx_mode() argument
2882 if_t ifp = adapter->netdev; in al_eth_set_rx_mode()
2891 al_eth_mac_table_promiscuous_set(adapter, true); in al_eth_set_rx_mode()
2895 al_eth_mac_table_all_multicast_add(adapter, in al_eth_set_rx_mode()
2899 al_eth_mac_table_entry_clear(adapter, in al_eth_set_rx_mode()
2902 al_eth_mac_table_all_multicast_add(adapter, in al_eth_set_rx_mode()
2913 al_eth_mac_table_promiscuous_set(adapter, true); in al_eth_set_rx_mode()
2920 al_eth_mac_table_entry_clear(adapter, i); in al_eth_set_rx_mode()
2925 if_foreach_lladdr(ifp, al_program_addr, adapter); in al_eth_set_rx_mode()
2927 al_eth_mac_table_promiscuous_set(adapter, false); in al_eth_set_rx_mode()
2932 al_eth_config_rx_fwd(struct al_eth_adapter *adapter) in al_eth_config_rx_fwd() argument
2939 al_eth_fwd_pbits_table_set(&adapter->hal_adapter, i, i); in al_eth_config_rx_fwd()
2943 al_eth_fwd_priority_table_set(&adapter->hal_adapter, i, i >> 1); in al_eth_config_rx_fwd()
2951 al_eth_ctrl_table_def_set(&adapter->hal_adapter, AL_FALSE, &entry); in al_eth_config_rx_fwd()
2957 al_eth_mac_table_unicast_add(adapter, AL_ETH_MAC_TABLE_UNICAST_IDX_BASE, in al_eth_config_rx_fwd()
2959 al_eth_mac_table_broadcast_add(adapter, AL_ETH_MAC_TABLE_BROADCAST_IDX, 1); in al_eth_config_rx_fwd()
2960 al_eth_mac_table_promiscuous_set(adapter, false); in al_eth_config_rx_fwd()
2963 for (i = 0; i < sizeof(adapter->toeplitz_hash_key); i++) in al_eth_config_rx_fwd()
2964 *((uint8_t*)adapter->toeplitz_hash_key + i) = (uint8_t)random(); in al_eth_config_rx_fwd()
2967 al_eth_hash_key_set(&adapter->hal_adapter, i, in al_eth_config_rx_fwd()
2968 htonl(adapter->toeplitz_hash_key[i])); in al_eth_config_rx_fwd()
2971 adapter->rss_ind_tbl[i] = ethtool_rxfh_indir_default(i, in al_eth_config_rx_fwd()
2973 al_eth_set_thash_table_entry(adapter, i, 0, in al_eth_config_rx_fwd()
2974 adapter->rss_ind_tbl[i]); in al_eth_config_rx_fwd()
2977 al_eth_fsm_table_init(adapter); in al_eth_config_rx_fwd()
2981 al_eth_req_rx_buff_size(struct al_eth_adapter *adapter, int size) in al_eth_req_rx_buff_size() argument
2989 adapter->rx_mbuf_sz = MCLBYTES; in al_eth_req_rx_buff_size()
2991 if (adapter->max_rx_buff_alloc_size > 2048) in al_eth_req_rx_buff_size()
2992 adapter->rx_mbuf_sz = MJUMPAGESIZE; in al_eth_req_rx_buff_size()
2997 if (adapter->max_rx_buff_alloc_size > 4096) in al_eth_req_rx_buff_size()
2998 adapter->rx_mbuf_sz = MJUM9BYTES; in al_eth_req_rx_buff_size()
3003 if (adapter->max_rx_buff_alloc_size > 9216) in al_eth_req_rx_buff_size()
3004 adapter->rx_mbuf_sz = MJUM16BYTES; in al_eth_req_rx_buff_size()
3011 al_eth_change_mtu(struct al_eth_adapter *adapter, int new_mtu) in al_eth_change_mtu() argument
3016 al_eth_req_rx_buff_size(adapter, new_mtu); in al_eth_change_mtu()
3018 device_printf_dbg(adapter->dev, "set MTU to %d\n", new_mtu); in al_eth_change_mtu()
3019 al_eth_rx_pkt_limit_config(&adapter->hal_adapter, in al_eth_change_mtu()
3022 al_eth_tso_mss_config(&adapter->hal_adapter, 0, new_mtu - 100); in al_eth_change_mtu()
3028 al_eth_check_mtu(struct al_eth_adapter *adapter, int new_mtu) in al_eth_check_mtu() argument
3041 al_eth_udma_queue_enable(struct al_eth_adapter *adapter, enum al_udma_type type, in al_eth_udma_queue_enable() argument
3049 q_params = &adapter->tx_ring[qid].q_params; in al_eth_udma_queue_enable()
3051 q_params = &adapter->rx_ring[qid].q_params; in al_eth_udma_queue_enable()
3053 rc = al_eth_queue_config(&adapter->hal_adapter, type, qid, q_params); in al_eth_udma_queue_enable()
3055 device_printf(adapter->dev, "config %s queue %u failed\n", name, in al_eth_udma_queue_enable()
3063 al_eth_udma_queues_enable_all(struct al_eth_adapter *adapter) in al_eth_udma_queues_enable_all() argument
3067 for (i = 0; i < adapter->num_tx_queues; i++) in al_eth_udma_queues_enable_all()
3068 al_eth_udma_queue_enable(adapter, UDMA_TX, i); in al_eth_udma_queues_enable_all()
3070 for (i = 0; i < adapter->num_rx_queues; i++) in al_eth_udma_queues_enable_all()
3071 al_eth_udma_queue_enable(adapter, UDMA_RX, i); in al_eth_udma_queues_enable_all()
3077 al_eth_up_complete(struct al_eth_adapter *adapter) in al_eth_up_complete() argument
3080 al_eth_configure_int_mode(adapter); in al_eth_up_complete()
3081 al_eth_config_rx_fwd(adapter); in al_eth_up_complete()
3082 al_eth_change_mtu(adapter, if_getmtu(adapter->netdev)); in al_eth_up_complete()
3083 al_eth_udma_queues_enable_all(adapter); in al_eth_up_complete()
3084 al_eth_refill_all_rx_bufs(adapter); in al_eth_up_complete()
3085 al_eth_interrupts_unmask(adapter); in al_eth_up_complete()
3088 if ((adapter->board_type == ALPINE_FPGA_NIC) || in al_eth_up_complete()
3089 (adapter->board_type == ALPINE_NIC)) { in al_eth_up_complete()
3090 al_eth_forward_int_config((uint32_t*)adapter->internal_pcie_base + in al_eth_up_complete()
3094 al_eth_flow_ctrl_enable(adapter); in al_eth_up_complete()
3096 mtx_lock(&adapter->stats_mtx); in al_eth_up_complete()
3097 callout_reset(&adapter->stats_callout, hz, al_tick_stats, (void*)adapter); in al_eth_up_complete()
3098 mtx_unlock(&adapter->stats_mtx); in al_eth_up_complete()
3100 al_eth_mac_start(&adapter->hal_adapter); in al_eth_up_complete()
3106 struct al_eth_adapter *adapter = if_getsoftc(ifp); in al_media_update() local
3109 mii_mediachg(adapter->mii); in al_media_update()
3137 struct al_eth_adapter *adapter = arg; in al_tick() local
3139 mii_tick(adapter->mii); in al_tick()
3142 callout_schedule(&adapter->wd_callout, hz); in al_tick()
3148 struct al_eth_adapter *adapter = arg; in al_tick_stats() local
3150 al_eth_update_stats(adapter); in al_tick_stats()
3152 callout_schedule(&adapter->stats_callout, hz); in al_tick_stats()
3156 al_eth_up(struct al_eth_adapter *adapter) in al_eth_up() argument
3158 if_t ifp = adapter->netdev; in al_eth_up()
3161 if (adapter->up) in al_eth_up()
3164 if ((adapter->flags & AL_ETH_FLAG_RESET_REQUESTED) != 0) { in al_eth_up()
3165 al_eth_function_reset(adapter); in al_eth_up()
3166 adapter->flags &= ~AL_ETH_FLAG_RESET_REQUESTED; in al_eth_up()
3177 al_eth_serdes_init(adapter); in al_eth_up()
3179 rc = al_eth_hw_init(adapter); in al_eth_up()
3183 rc = al_eth_setup_int_mode(adapter); in al_eth_up()
3185 device_printf(adapter->dev, in al_eth_up()
3191 rc = al_eth_setup_all_tx_resources(adapter); in al_eth_up()
3196 rc = al_eth_setup_all_rx_resources(adapter); in al_eth_up()
3200 rc = al_eth_request_irq(adapter); in al_eth_up()
3204 al_eth_up_complete(adapter); in al_eth_up()
3206 adapter->up = true; in al_eth_up()
3208 if (adapter->mac_mode == AL_ETH_MAC_MODE_10GbE_Serial) in al_eth_up()
3209 if_link_state_change(adapter->netdev, LINK_STATE_UP); in al_eth_up()
3211 if (adapter->mac_mode == AL_ETH_MAC_MODE_RGMII) { in al_eth_up()
3212 mii_mediachg(adapter->mii); in al_eth_up()
3215 mtx_lock(&adapter->wd_mtx); in al_eth_up()
3216 callout_reset(&adapter->wd_callout, hz, al_tick, adapter); in al_eth_up()
3217 mtx_unlock(&adapter->wd_mtx); in al_eth_up()
3219 mii_pollstat(adapter->mii); in al_eth_up()
3225 al_eth_free_all_rx_resources(adapter); in al_eth_up()
3227 al_eth_free_all_tx_resources(adapter); in al_eth_up()
3229 al_eth_free_irq(adapter); in al_eth_up()
3231 al_eth_hw_stop(adapter); in al_eth_up()
3233 al_eth_function_reset(adapter); in al_eth_up()
3241 struct al_eth_adapter *adapter = device_get_softc(dev); in al_shutdown() local
3243 al_eth_down(adapter); in al_shutdown()
3249 al_eth_down(struct al_eth_adapter *adapter) in al_eth_down() argument
3252 device_printf_dbg(adapter->dev, "al_eth_down: begin\n"); in al_eth_down()
3254 adapter->up = false; in al_eth_down()
3256 mtx_lock(&adapter->wd_mtx); in al_eth_down()
3257 callout_stop(&adapter->wd_callout); in al_eth_down()
3258 mtx_unlock(&adapter->wd_mtx); in al_eth_down()
3260 al_eth_disable_int_sync(adapter); in al_eth_down()
3262 mtx_lock(&adapter->stats_mtx); in al_eth_down()
3263 callout_stop(&adapter->stats_callout); in al_eth_down()
3264 mtx_unlock(&adapter->stats_mtx); in al_eth_down()
3266 al_eth_free_irq(adapter); in al_eth_down()
3267 al_eth_hw_stop(adapter); in al_eth_down()
3269 al_eth_free_all_tx_resources(adapter); in al_eth_down()
3270 al_eth_free_all_rx_resources(adapter); in al_eth_down()
3276 struct al_eth_adapter *adapter = if_getsoftc(ifp); in al_ioctl() local
3283 error = al_eth_check_mtu(adapter, ifr->ifr_mtu); in al_ioctl()
3285 device_printf(adapter->dev, "ioctl wrong mtu %u\n", in al_ioctl()
3286 if_getmtu(adapter->netdev)); in al_ioctl()
3291 if_setmtu(adapter->netdev, ifr->ifr_mtu); in al_ioctl()
3292 al_init(adapter); in al_ioctl()
3298 if (((if_getflags(ifp) ^ adapter->if_flags) & in al_ioctl()
3300 device_printf_dbg(adapter->dev, in al_ioctl()
3302 al_eth_set_rx_mode(adapter); in al_ioctl()
3305 error = al_eth_up(adapter); in al_ioctl()
3311 al_eth_down(adapter); in al_ioctl()
3316 adapter->if_flags = if_getflags(ifp); in al_ioctl()
3322 device_printf_dbg(adapter->dev, in al_ioctl()
3324 al_eth_set_rx_mode(adapter); in al_ioctl()
3332 if (adapter->mii != NULL) in al_ioctl()
3334 &adapter->mii->mii_media, command); in al_ioctl()
3337 &adapter->media, command); in al_ioctl()
3389 al_init(adapter); in al_ioctl()
3422 struct al_eth_adapter *adapter = device_get_softc(dev); in al_miibus_readreg() local
3428 rc = al_eth_mdio_read(&adapter->hal_adapter, adapter->phy_addr, in al_miibus_readreg()
3434 device_printf_dbg(adapter->dev, in al_miibus_readreg()
3442 device_printf(adapter->dev, "MDIO read failed on timeout\n"); in al_miibus_readreg()
3450 struct al_eth_adapter *adapter = device_get_softc(dev); in al_miibus_writereg() local
3455 rc = al_eth_mdio_write(&adapter->hal_adapter, adapter->phy_addr, in al_miibus_writereg()
3461 device_printf(adapter->dev, in al_miibus_writereg()
3469 device_printf(adapter->dev, "MDIO write failed on timeout\n"); in al_miibus_writereg()
3477 struct al_eth_adapter *adapter = device_get_softc(dev); in al_miibus_statchg() local
3479 device_printf_dbg(adapter->dev, in al_miibus_statchg()
3481 device_printf_dbg(adapter->dev, in al_miibus_statchg()
3483 adapter->mii->mii_media_active, adapter->mii->mii_media_status); in al_miibus_statchg()
3485 if (adapter->up == 0) in al_miibus_statchg()
3488 if ((adapter->mii->mii_media_status & IFM_AVALID) != 0) { in al_miibus_statchg()
3489 if (adapter->mii->mii_media_status & IFM_ACTIVE) { in al_miibus_statchg()
3490 device_printf(adapter->dev, "link is UP\n"); in al_miibus_statchg()
3491 if_link_state_change(adapter->netdev, LINK_STATE_UP); in al_miibus_statchg()
3493 device_printf(adapter->dev, "link is DOWN\n"); in al_miibus_statchg()
3494 if_link_state_change(adapter->netdev, LINK_STATE_DOWN); in al_miibus_statchg()
3502 struct al_eth_adapter *adapter = device_get_softc(dev); in al_miibus_linkchg() local
3506 if (adapter->mii == NULL) in al_miibus_linkchg()
3509 if ((if_getflags(adapter->netdev) & IFF_UP) == 0) in al_miibus_linkchg()
3513 if ((adapter->mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) != in al_miibus_linkchg()
3518 if ((adapter->mii->mii_media_active & IFM_FDX) != 0) in al_miibus_linkchg()
3521 speed = IFM_SUBTYPE(adapter->mii->mii_media_active); in al_miibus_linkchg()
3524 al_eth_mac_link_config(&adapter->hal_adapter, 0, 1, in al_miibus_linkchg()
3530 al_eth_mac_link_config(&adapter->hal_adapter, 0, 1, in al_miibus_linkchg()
3536 al_eth_mac_link_config(&adapter->hal_adapter, 0, 1, in al_miibus_linkchg()
3541 device_printf(adapter->dev, "ERROR: unknown MII media active 0x%08x\n", in al_miibus_linkchg()
3542 adapter->mii->mii_media_active); in al_miibus_linkchg()