Lines Matching full:nic
80 #include "nic.h"
83 #define VNIC_VF_DEVSTR "Cavium Thunder NIC Virtual Function Driver"
88 #define NICVF_CORE_LOCK_INIT(nic) \ argument
89 sx_init(&(nic)->core_sx, device_get_nameunit((nic)->dev))
91 #define NICVF_CORE_LOCK_DESTROY(nic) \ argument
92 sx_destroy(&(nic)->core_sx)
94 #define NICVF_CORE_LOCK(nic) sx_xlock(&(nic)->core_sx) argument
95 #define NICVF_CORE_UNLOCK(nic) sx_xunlock(&(nic)->core_sx) argument
97 #define NICVF_CORE_LOCK_ASSERT(nic) sx_assert(&(nic)->core_sx, SA_XLOCKED) argument
184 struct nicvf *nic; in nicvf_attach() local
190 nic = device_get_softc(dev); in nicvf_attach()
191 nic->dev = dev; in nicvf_attach()
192 nic->pnicvf = nic; in nicvf_attach()
194 NICVF_CORE_LOCK_INIT(nic); in nicvf_attach()
197 nic->hw_tso = TRUE; in nicvf_attach()
200 nic->reg_base = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in nicvf_attach()
202 if (nic->reg_base == NULL) { in nicvf_attach()
208 nic->max_queues = qcount; in nicvf_attach()
210 err = nicvf_set_qset_resources(nic); in nicvf_attach()
215 err = nicvf_allocate_misc_interrupt(nic); in nicvf_attach()
219 NICVF_CORE_LOCK(nic); in nicvf_attach()
220 err = nicvf_enable_misc_interrupt(nic); in nicvf_attach()
221 NICVF_CORE_UNLOCK(nic); in nicvf_attach()
225 err = nicvf_allocate_net_interrupts(nic); in nicvf_attach()
233 if (memcmp(nic->hwaddr, zeromac, ETHER_ADDR_LEN) == 0) { in nicvf_attach()
235 memcpy(nic->hwaddr, hwaddr, ETHER_ADDR_LEN); in nicvf_attach()
236 NICVF_CORE_LOCK(nic); in nicvf_attach()
237 nicvf_hw_set_mac_addr(nic, hwaddr); in nicvf_attach()
238 NICVF_CORE_UNLOCK(nic); in nicvf_attach()
242 nic->cpi_alg = CPI_ALG_NONE; in nicvf_attach()
243 NICVF_CORE_LOCK(nic); in nicvf_attach()
244 nicvf_config_cpi(nic); in nicvf_attach()
246 if (nic->qs->rq_cnt > 1) in nicvf_attach()
247 nicvf_rss_init(nic); in nicvf_attach()
248 NICVF_CORE_UNLOCK(nic); in nicvf_attach()
250 nicvf_setup_ifnet(nic); in nicvf_attach()
252 err = nicvf_setup_ifmedia(nic); in nicvf_attach()
258 mtx_init(&nic->stats_mtx, "VNIC stats", NULL, MTX_DEF); in nicvf_attach()
259 callout_init_mtx(&nic->stats_callout, &nic->stats_mtx, 0); in nicvf_attach()
261 ether_ifattach(nic->ifp, nic->hwaddr); in nicvf_attach()
266 if_free(nic->ifp); in nicvf_attach()
268 nicvf_release_all_interrupts(nic); in nicvf_attach()
270 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(nic->reg_base), in nicvf_attach()
271 nic->reg_base); in nicvf_attach()
279 struct nicvf *nic; in nicvf_detach() local
281 nic = device_get_softc(dev); in nicvf_detach()
283 NICVF_CORE_LOCK(nic); in nicvf_detach()
285 nicvf_stop_locked(nic); in nicvf_detach()
287 mtx_destroy(&nic->stats_mtx); in nicvf_detach()
289 nicvf_release_all_interrupts(nic); in nicvf_detach()
291 if (nic->reg_base != NULL) { in nicvf_detach()
293 rman_get_rid(nic->reg_base), nic->reg_base); in nicvf_detach()
297 ifmedia_removeall(&nic->if_media); in nicvf_detach()
299 if_free(nic->ifp); in nicvf_detach()
300 NICVF_CORE_UNLOCK(nic); in nicvf_detach()
302 NICVF_CORE_LOCK_DESTROY(nic); in nicvf_detach()
329 nicvf_setup_ifnet(struct nicvf *nic) in nicvf_setup_ifnet() argument
334 nic->ifp = ifp; in nicvf_setup_ifnet()
336 if_setsoftc(ifp, nic); in nicvf_setup_ifnet()
337 if_initname(ifp, device_get_name(nic->dev), device_get_unit(nic->dev)); in nicvf_setup_ifnet()
354 if (nic->hw_tso) { in nicvf_setup_ifnet()
370 if (nic->hw_tso) in nicvf_setup_ifnet()
376 nicvf_setup_ifmedia(struct nicvf *nic) in nicvf_setup_ifmedia() argument
379 ifmedia_init(&nic->if_media, IFM_IMASK, nicvf_media_change, in nicvf_setup_ifmedia()
387 ifmedia_add(&nic->if_media, (IFM_ETHER | IFM_10_T | IFM_FDX), in nicvf_setup_ifmedia()
389 ifmedia_add(&nic->if_media, (IFM_ETHER | IFM_100_TX | IFM_FDX), in nicvf_setup_ifmedia()
391 ifmedia_add(&nic->if_media, (IFM_ETHER | IFM_1000_T | IFM_FDX), in nicvf_setup_ifmedia()
393 ifmedia_add(&nic->if_media, (IFM_ETHER | IFM_10G_SR | IFM_FDX), in nicvf_setup_ifmedia()
395 ifmedia_add(&nic->if_media, (IFM_ETHER | IFM_40G_CR4 | IFM_FDX), in nicvf_setup_ifmedia()
397 ifmedia_add(&nic->if_media, (IFM_ETHER | IFM_AUTO | IFM_FDX), in nicvf_setup_ifmedia()
400 ifmedia_set(&nic->if_media, (IFM_ETHER | IFM_AUTO | IFM_FDX)); in nicvf_setup_ifmedia()
408 struct nicvf *nic; in nicvf_if_ioctl() local
419 nic = if_getsoftc(ifp); in nicvf_if_ioctl()
441 nicvf_if_init(nic); in nicvf_if_ioctl()
457 NICVF_CORE_LOCK(nic); in nicvf_if_ioctl()
458 err = nicvf_update_hw_max_frs(nic, ifr->ifr_mtu); in nicvf_if_ioctl()
461 NICVF_CORE_UNLOCK(nic); in nicvf_if_ioctl()
465 NICVF_CORE_LOCK(nic); in nicvf_if_ioctl()
469 if ((flags ^ nic->if_flags) & IFF_PROMISC) { in nicvf_if_ioctl()
472 nicvf_set_promiscous(nic); in nicvf_if_ioctl()
476 if ((flags ^ nic->if_flags) & IFF_ALLMULTI) { in nicvf_if_ioctl()
479 nicvf_set_multicast(nic); in nicvf_if_ioctl()
483 nicvf_if_init_locked(nic); in nicvf_if_ioctl()
486 nicvf_stop_locked(nic); in nicvf_if_ioctl()
488 nic->if_flags = flags; in nicvf_if_ioctl()
489 NICVF_CORE_UNLOCK(nic); in nicvf_if_ioctl()
496 NICVF_CORE_LOCK(nic); in nicvf_if_ioctl()
498 nicvf_set_multicast(nic); in nicvf_if_ioctl()
499 NICVF_CORE_UNLOCK(nic); in nicvf_if_ioctl()
506 err = ifmedia_ioctl(ifp, ifr, &nic->if_media, cmd); in nicvf_if_ioctl()
519 if ((mask & IFCAP_TSO4) && nic->hw_tso) in nicvf_if_ioctl()
526 NICVF_CORE_LOCK(nic); in nicvf_if_ioctl()
528 if ((if_getdrvflags(nic->ifp) & IFF_DRV_RUNNING) != 0) { in nicvf_if_ioctl()
537 rq_idx < nic->qs->rq_cnt; rq_idx++) { in nicvf_if_ioctl()
538 rq = &nic->qs->rq[rq_idx]; in nicvf_if_ioctl()
542 NICVF_CORE_UNLOCK(nic); in nicvf_if_ioctl()
556 nicvf_if_init_locked(struct nicvf *nic) in nicvf_if_init_locked() argument
558 struct queue_set *qs = nic->qs; in nicvf_if_init_locked()
564 NICVF_CORE_LOCK_ASSERT(nic); in nicvf_if_init_locked()
565 ifp = nic->ifp; in nicvf_if_init_locked()
568 nicvf_stop_locked(nic); in nicvf_if_init_locked()
570 err = nicvf_enable_misc_interrupt(nic); in nicvf_if_init_locked()
579 if (memcmp(nic->hwaddr, if_addr, ETHER_ADDR_LEN) != 0) { in nicvf_if_init_locked()
580 memcpy(nic->hwaddr, if_addr, ETHER_ADDR_LEN); in nicvf_if_init_locked()
581 nicvf_hw_set_mac_addr(nic, if_addr); in nicvf_if_init_locked()
585 err = nicvf_init_resources(nic); in nicvf_if_init_locked()
592 nicvf_reg_write(nic, NIC_VF_INT, ~0UL); in nicvf_if_init_locked()
594 nicvf_enable_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_if_init_locked()
598 nicvf_enable_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_if_init_locked()
602 nicvf_enable_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_if_init_locked()
604 nic->drv_stats.txq_stop = 0; in nicvf_if_init_locked()
605 nic->drv_stats.txq_wake = 0; in nicvf_if_init_locked()
611 callout_reset(&nic->stats_callout, hz, nicvf_tick_stats, nic); in nicvf_if_init_locked()
623 struct nicvf *nic = if_softc; in nicvf_if_init() local
625 NICVF_CORE_LOCK(nic); in nicvf_if_init()
626 nicvf_if_init_locked(nic); in nicvf_if_init()
627 NICVF_CORE_UNLOCK(nic); in nicvf_if_init()
633 struct nicvf *nic = if_getsoftc(ifp); in nicvf_if_transmit() local
634 struct queue_set *qs = nic->qs; in nicvf_if_transmit()
642 device_get_nameunit(nic->dev)); in nicvf_if_transmit()
667 IFF_DRV_RUNNING) || !nic->link_up || (err != 0)) { in nicvf_if_transmit()
689 struct nicvf *nic; in nicvf_if_qflush() local
695 nic = if_getsoftc(ifp); in nicvf_if_qflush()
696 qs = nic->qs; in nicvf_if_qflush()
711 struct nicvf *nic; in nicvf_if_getcounter() local
715 nic = if_getsoftc(ifp); in nicvf_if_getcounter()
716 hw_stats = &nic->hw_stats; in nicvf_if_getcounter()
717 drv_stats = &nic->drv_stats; in nicvf_if_getcounter()
745 struct nicvf *nic = if_getsoftc(ifp); in nicvf_media_status() local
747 NICVF_CORE_LOCK(nic); in nicvf_media_status()
752 if (nic->link_up) { in nicvf_media_status()
757 switch (nic->speed) { in nicvf_media_status()
778 if (nic->duplex) in nicvf_media_status()
783 NICVF_CORE_UNLOCK(nic); in nicvf_media_status()
795 nicvf_reg_write(struct nicvf *nic, bus_space_handle_t offset, uint64_t val) in nicvf_reg_write() argument
798 bus_write_8(nic->reg_base, offset, val); in nicvf_reg_write()
802 nicvf_reg_read(struct nicvf *nic, uint64_t offset) in nicvf_reg_read() argument
805 return (bus_read_8(nic->reg_base, offset)); in nicvf_reg_read()
809 nicvf_queue_reg_write(struct nicvf *nic, bus_space_handle_t offset, in nicvf_queue_reg_write() argument
813 bus_write_8(nic->reg_base, offset + (qidx << NIC_Q_NUM_SHIFT), val); in nicvf_queue_reg_write()
817 nicvf_queue_reg_read(struct nicvf *nic, bus_space_handle_t offset, in nicvf_queue_reg_read() argument
821 return (bus_read_8(nic->reg_base, offset + (qidx << NIC_Q_NUM_SHIFT))); in nicvf_queue_reg_read()
826 nicvf_write_to_mbx(struct nicvf *nic, union nic_mbx *mbx) in nicvf_write_to_mbx() argument
830 nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]); in nicvf_write_to_mbx()
831 nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]); in nicvf_write_to_mbx()
835 nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx) in nicvf_send_msg_to_pf() argument
840 NICVF_CORE_LOCK_ASSERT(nic); in nicvf_send_msg_to_pf()
842 nic->pf_acked = FALSE; in nicvf_send_msg_to_pf()
843 nic->pf_nacked = FALSE; in nicvf_send_msg_to_pf()
845 nicvf_write_to_mbx(nic, mbx); in nicvf_send_msg_to_pf()
848 while (!nic->pf_acked) { in nicvf_send_msg_to_pf()
849 if (nic->pf_nacked) in nicvf_send_msg_to_pf()
854 if (nic->pf_acked) in nicvf_send_msg_to_pf()
858 device_printf(nic->dev, in nicvf_send_msg_to_pf()
860 (mbx->msg.msg & 0xFF), nic->vf_id); in nicvf_send_msg_to_pf()
873 nicvf_check_pf_ready(struct nicvf *nic) in nicvf_check_pf_ready() argument
878 if (nicvf_send_msg_to_pf(nic, &mbx)) { in nicvf_check_pf_ready()
879 device_printf(nic->dev, in nicvf_check_pf_ready()
888 nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx) in nicvf_read_bgx_stats() argument
892 nic->bgx_stats.rx_stats[bgx->idx] = bgx->stats; in nicvf_read_bgx_stats()
894 nic->bgx_stats.tx_stats[bgx->idx] = bgx->stats; in nicvf_read_bgx_stats()
898 nicvf_handle_mbx_intr(struct nicvf *nic) in nicvf_handle_mbx_intr() argument
909 *mbx_data = nicvf_reg_read(nic, mbx_addr); in nicvf_handle_mbx_intr()
916 nic->pf_acked = TRUE; in nicvf_handle_mbx_intr()
917 nic->vf_id = mbx.nic_cfg.vf_id & 0x7F; in nicvf_handle_mbx_intr()
918 nic->tns_mode = mbx.nic_cfg.tns_mode & 0x7F; in nicvf_handle_mbx_intr()
919 nic->node = mbx.nic_cfg.node_id; in nicvf_handle_mbx_intr()
920 memcpy(nic->hwaddr, mbx.nic_cfg.mac_addr, ETHER_ADDR_LEN); in nicvf_handle_mbx_intr()
921 nic->loopback_supported = mbx.nic_cfg.loopback_supported; in nicvf_handle_mbx_intr()
922 nic->link_up = FALSE; in nicvf_handle_mbx_intr()
923 nic->duplex = 0; in nicvf_handle_mbx_intr()
924 nic->speed = 0; in nicvf_handle_mbx_intr()
927 nic->pf_acked = TRUE; in nicvf_handle_mbx_intr()
930 nic->pf_nacked = TRUE; in nicvf_handle_mbx_intr()
933 nic->rss_info.rss_size = mbx.rss_size.ind_tbl_size; in nicvf_handle_mbx_intr()
934 nic->pf_acked = TRUE; in nicvf_handle_mbx_intr()
937 nicvf_read_bgx_stats(nic, &mbx.bgx_stats); in nicvf_handle_mbx_intr()
938 nic->pf_acked = TRUE; in nicvf_handle_mbx_intr()
941 nic->pf_acked = TRUE; in nicvf_handle_mbx_intr()
942 nic->link_up = mbx.link_status.link_up; in nicvf_handle_mbx_intr()
943 nic->duplex = mbx.link_status.duplex; in nicvf_handle_mbx_intr()
944 nic->speed = mbx.link_status.speed; in nicvf_handle_mbx_intr()
945 if (nic->link_up) { in nicvf_handle_mbx_intr()
946 if_setbaudrate(nic->ifp, nic->speed * 1000000); in nicvf_handle_mbx_intr()
947 if_link_state_change(nic->ifp, LINK_STATE_UP); in nicvf_handle_mbx_intr()
949 if_setbaudrate(nic->ifp, 0); in nicvf_handle_mbx_intr()
950 if_link_state_change(nic->ifp, LINK_STATE_DOWN); in nicvf_handle_mbx_intr()
954 device_printf(nic->dev, in nicvf_handle_mbx_intr()
958 nicvf_clear_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_handle_mbx_intr()
962 nicvf_update_hw_max_frs(struct nicvf *nic, int mtu) in nicvf_update_hw_max_frs() argument
968 mbx.frs.vf_id = nic->vf_id; in nicvf_update_hw_max_frs()
970 return nicvf_send_msg_to_pf(nic, &mbx); in nicvf_update_hw_max_frs()
974 nicvf_hw_set_mac_addr(struct nicvf *nic, uint8_t *hwaddr) in nicvf_hw_set_mac_addr() argument
979 mbx.mac.vf_id = nic->vf_id; in nicvf_hw_set_mac_addr()
982 return (nicvf_send_msg_to_pf(nic, &mbx)); in nicvf_hw_set_mac_addr()
986 nicvf_config_cpi(struct nicvf *nic) in nicvf_config_cpi() argument
991 mbx.cpi_cfg.vf_id = nic->vf_id; in nicvf_config_cpi()
992 mbx.cpi_cfg.cpi_alg = nic->cpi_alg; in nicvf_config_cpi()
993 mbx.cpi_cfg.rq_cnt = nic->qs->rq_cnt; in nicvf_config_cpi()
995 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_config_cpi()
999 nicvf_get_rss_size(struct nicvf *nic) in nicvf_get_rss_size() argument
1004 mbx.rss_size.vf_id = nic->vf_id; in nicvf_get_rss_size()
1005 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_get_rss_size()
1009 nicvf_config_rss(struct nicvf *nic) in nicvf_config_rss() argument
1016 rss = &nic->rss_info; in nicvf_config_rss()
1020 mbx.rss_cfg.vf_id = nic->vf_id; in nicvf_config_rss()
1032 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_config_rss()
1039 nicvf_set_rss_key(struct nicvf *nic) in nicvf_set_rss_key() argument
1045 rss = &nic->rss_info; in nicvf_set_rss_key()
1049 nicvf_reg_write(nic, key_addr, rss->key[idx]); in nicvf_set_rss_key()
1055 nicvf_rss_init(struct nicvf *nic) in nicvf_rss_init() argument
1060 nicvf_get_rss_size(nic); in nicvf_rss_init()
1062 rss = &nic->rss_info; in nicvf_rss_init()
1063 if (nic->cpi_alg != CPI_ALG_NONE) { in nicvf_rss_init()
1078 nicvf_set_rss_key(nic); in nicvf_rss_init()
1081 nicvf_reg_write(nic, NIC_VNIC_RSS_CFG, rss->cfg); in nicvf_rss_init()
1085 rss->ind_tbl[idx] = idx % nic->rx_queues; in nicvf_rss_init()
1087 nicvf_config_rss(nic); in nicvf_rss_init()
1093 nicvf_init_resources(struct nicvf *nic) in nicvf_init_resources() argument
1101 nicvf_qset_config(nic, TRUE); in nicvf_init_resources()
1104 err = nicvf_config_data_transfer(nic, TRUE); in nicvf_init_resources()
1106 device_printf(nic->dev, in nicvf_init_resources()
1112 nicvf_write_to_mbx(nic, &mbx); in nicvf_init_resources()
1120 struct nicvf *nic = (struct nicvf *)arg; in nicvf_misc_intr_handler() local
1123 intr = nicvf_reg_read(nic, NIC_VF_INT); in nicvf_misc_intr_handler()
1128 nicvf_handle_mbx_intr(nic); in nicvf_misc_intr_handler()
1134 struct nicvf *nic; in nicvf_intr_handler() local
1139 nic = cq->nic; in nicvf_intr_handler()
1143 nicvf_disable_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_intr_handler()
1148 nicvf_clear_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_intr_handler()
1156 struct nicvf *nic; in nicvf_rbdr_intr_handler() local
1161 nic = (struct nicvf *)arg; in nicvf_rbdr_intr_handler()
1164 for (qidx = 0; qidx < nic->qs->rbdr_cnt; qidx++) { in nicvf_rbdr_intr_handler()
1165 if (!nicvf_is_intr_enabled(nic, NICVF_INTR_RBDR, qidx)) in nicvf_rbdr_intr_handler()
1167 nicvf_disable_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_rbdr_intr_handler()
1169 qs = nic->qs; in nicvf_rbdr_intr_handler()
1173 nicvf_clear_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_rbdr_intr_handler()
1180 struct nicvf *nic = (struct nicvf *)arg; in nicvf_qs_err_intr_handler() local
1181 struct queue_set *qs = nic->qs; in nicvf_qs_err_intr_handler()
1184 nicvf_disable_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_qs_err_intr_handler()
1186 nicvf_clear_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_qs_err_intr_handler()
1191 nicvf_enable_msix(struct nicvf *nic) in nicvf_enable_msix() argument
1197 dinfo = device_get_ivars(nic->dev); in nicvf_enable_msix()
1199 nic->msix_table_res = in nicvf_enable_msix()
1200 bus_alloc_resource_any(nic->dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); in nicvf_enable_msix()
1201 if (nic->msix_table_res == NULL) { in nicvf_enable_msix()
1202 device_printf(nic->dev, in nicvf_enable_msix()
1207 count = nic->num_vec = NIC_VF_MSIX_VECTORS; in nicvf_enable_msix()
1209 ret = pci_alloc_msix(nic->dev, &count); in nicvf_enable_msix()
1210 if ((ret != 0) || (count != nic->num_vec)) { in nicvf_enable_msix()
1211 device_printf(nic->dev, in nicvf_enable_msix()
1213 nic->num_vec, ret); in nicvf_enable_msix()
1217 nic->msix_enabled = 1; in nicvf_enable_msix()
1222 nicvf_disable_msix(struct nicvf *nic) in nicvf_disable_msix() argument
1225 if (nic->msix_enabled) { in nicvf_disable_msix()
1226 pci_release_msi(nic->dev); in nicvf_disable_msix()
1227 nic->msix_enabled = 0; in nicvf_disable_msix()
1228 nic->num_vec = 0; in nicvf_disable_msix()
1233 nicvf_release_all_interrupts(struct nicvf *nic) in nicvf_release_all_interrupts() argument
1240 for (irq = 0; irq < nic->num_vec; irq++) { in nicvf_release_all_interrupts()
1241 res = nic->msix_entries[irq].irq_res; in nicvf_release_all_interrupts()
1245 if (nic->msix_entries[irq].handle != NULL) { in nicvf_release_all_interrupts()
1246 err = bus_teardown_intr(nic->dev, in nicvf_release_all_interrupts()
1247 nic->msix_entries[irq].irq_res, in nicvf_release_all_interrupts()
1248 nic->msix_entries[irq].handle); in nicvf_release_all_interrupts()
1251 nic->msix_entries[irq].handle = NULL; in nicvf_release_all_interrupts()
1254 bus_release_resource(nic->dev, SYS_RES_IRQ, in nicvf_release_all_interrupts()
1255 rman_get_rid(res), nic->msix_entries[irq].irq_res); in nicvf_release_all_interrupts()
1256 nic->msix_entries[irq].irq_res = NULL; in nicvf_release_all_interrupts()
1259 nicvf_disable_msix(nic); in nicvf_release_all_interrupts()
1267 nicvf_allocate_misc_interrupt(struct nicvf *nic) in nicvf_allocate_misc_interrupt() argument
1274 if (nic->msix_enabled) in nicvf_allocate_misc_interrupt()
1278 if (nicvf_enable_msix(nic) != 0) in nicvf_allocate_misc_interrupt()
1283 nic->msix_entries[irq].irq_res = bus_alloc_resource_any(nic->dev, in nicvf_allocate_misc_interrupt()
1285 if (nic->msix_entries[irq].irq_res == NULL) { in nicvf_allocate_misc_interrupt()
1286 device_printf(nic->dev, in nicvf_allocate_misc_interrupt()
1288 device_get_unit(nic->dev)); in nicvf_allocate_misc_interrupt()
1292 ret = bus_setup_intr(nic->dev, nic->msix_entries[irq].irq_res, in nicvf_allocate_misc_interrupt()
1293 (INTR_MPSAFE | INTR_TYPE_MISC), NULL, nicvf_misc_intr_handler, nic, in nicvf_allocate_misc_interrupt()
1294 &nic->msix_entries[irq].handle); in nicvf_allocate_misc_interrupt()
1296 res = nic->msix_entries[irq].irq_res; in nicvf_allocate_misc_interrupt()
1297 bus_release_resource(nic->dev, SYS_RES_IRQ, in nicvf_allocate_misc_interrupt()
1299 nic->msix_entries[irq].irq_res = NULL; in nicvf_allocate_misc_interrupt()
1307 nicvf_enable_misc_interrupt(struct nicvf *nic) in nicvf_enable_misc_interrupt() argument
1311 nicvf_enable_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_enable_misc_interrupt()
1314 if (!nicvf_check_pf_ready(nic)) { in nicvf_enable_misc_interrupt()
1315 nicvf_disable_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_enable_misc_interrupt()
1323 nicvf_release_net_interrupts(struct nicvf *nic) in nicvf_release_net_interrupts() argument
1330 res = nic->msix_entries[irq].irq_res; in nicvf_release_net_interrupts()
1334 if (nic->msix_entries[irq].handle != NULL) { in nicvf_release_net_interrupts()
1335 err = bus_teardown_intr(nic->dev, in nicvf_release_net_interrupts()
1336 nic->msix_entries[irq].irq_res, in nicvf_release_net_interrupts()
1337 nic->msix_entries[irq].handle); in nicvf_release_net_interrupts()
1346 bus_release_resource(nic->dev, SYS_RES_IRQ, rman_get_rid(res), in nicvf_release_net_interrupts()
1348 nic->msix_entries[irq].irq_res = NULL; in nicvf_release_net_interrupts()
1352 res = nic->msix_entries[irq].irq_res; in nicvf_release_net_interrupts()
1356 if (nic->msix_entries[irq].handle != NULL) { in nicvf_release_net_interrupts()
1357 err = bus_teardown_intr(nic->dev, in nicvf_release_net_interrupts()
1358 nic->msix_entries[irq].irq_res, in nicvf_release_net_interrupts()
1359 nic->msix_entries[irq].handle); in nicvf_release_net_interrupts()
1368 bus_release_resource(nic->dev, SYS_RES_IRQ, rman_get_rid(res), in nicvf_release_net_interrupts()
1370 nic->msix_entries[irq].irq_res = NULL; in nicvf_release_net_interrupts()
1374 res = nic->msix_entries[irq].irq_res; in nicvf_release_net_interrupts()
1377 if (nic->msix_entries[irq].handle != NULL) { in nicvf_release_net_interrupts()
1378 err = bus_teardown_intr(nic->dev, in nicvf_release_net_interrupts()
1379 nic->msix_entries[irq].irq_res, in nicvf_release_net_interrupts()
1380 nic->msix_entries[irq].handle); in nicvf_release_net_interrupts()
1389 bus_release_resource(nic->dev, SYS_RES_IRQ, rman_get_rid(res), in nicvf_release_net_interrupts()
1391 nic->msix_entries[irq].irq_res = NULL; in nicvf_release_net_interrupts()
1396 nicvf_allocate_net_interrupts(struct nicvf *nic) in nicvf_allocate_net_interrupts() argument
1404 if (!nic->msix_enabled) { in nicvf_allocate_net_interrupts()
1405 device_printf(nic->dev, "Cannot alloacte queue interrups. " in nicvf_allocate_net_interrupts()
1412 if (irq >= (NICVF_INTR_ID_CQ + nic->qs->cq_cnt)) in nicvf_allocate_net_interrupts()
1417 nic->msix_entries[irq].irq_res = bus_alloc_resource_any(nic->dev, in nicvf_allocate_net_interrupts()
1419 if (nic->msix_entries[irq].irq_res == NULL) { in nicvf_allocate_net_interrupts()
1420 device_printf(nic->dev, in nicvf_allocate_net_interrupts()
1422 (irq - NICVF_INTR_ID_CQ), device_get_unit(nic->dev)); in nicvf_allocate_net_interrupts()
1426 ret = bus_setup_intr(nic->dev, nic->msix_entries[irq].irq_res, in nicvf_allocate_net_interrupts()
1428 NULL, &nic->qs->cq[qidx], &nic->msix_entries[irq].handle); in nicvf_allocate_net_interrupts()
1430 device_printf(nic->dev, in nicvf_allocate_net_interrupts()
1432 (irq - NICVF_INTR_ID_CQ), device_get_unit(nic->dev)); in nicvf_allocate_net_interrupts()
1435 cpuid = (device_get_unit(nic->dev) * CMP_QUEUE_CNT) + qidx; in nicvf_allocate_net_interrupts()
1442 nic->qs->cq[qidx].cmp_cpuid = cpuid; in nicvf_allocate_net_interrupts()
1444 device_printf(nic->dev, "bind CQ%d IRQ to CPU%d\n", in nicvf_allocate_net_interrupts()
1448 bus_bind_intr(nic->dev, nic->msix_entries[irq].irq_res, cpuid); in nicvf_allocate_net_interrupts()
1453 if (irq >= (NICVF_INTR_ID_RBDR + nic->qs->rbdr_cnt)) in nicvf_allocate_net_interrupts()
1457 nic->msix_entries[irq].irq_res = bus_alloc_resource_any(nic->dev, in nicvf_allocate_net_interrupts()
1459 if (nic->msix_entries[irq].irq_res == NULL) { in nicvf_allocate_net_interrupts()
1460 device_printf(nic->dev, in nicvf_allocate_net_interrupts()
1463 device_get_unit(nic->dev)); in nicvf_allocate_net_interrupts()
1467 ret = bus_setup_intr(nic->dev, nic->msix_entries[irq].irq_res, in nicvf_allocate_net_interrupts()
1469 nicvf_rbdr_intr_handler, nic, in nicvf_allocate_net_interrupts()
1470 &nic->msix_entries[irq].handle); in nicvf_allocate_net_interrupts()
1472 device_printf(nic->dev, in nicvf_allocate_net_interrupts()
1475 device_get_unit(nic->dev)); in nicvf_allocate_net_interrupts()
1483 nic->msix_entries[irq].irq_res = bus_alloc_resource_any(nic->dev, in nicvf_allocate_net_interrupts()
1485 if (nic->msix_entries[irq].irq_res == NULL) { in nicvf_allocate_net_interrupts()
1486 device_printf(nic->dev, in nicvf_allocate_net_interrupts()
1488 device_get_unit(nic->dev)); in nicvf_allocate_net_interrupts()
1492 ret = bus_setup_intr(nic->dev, nic->msix_entries[irq].irq_res, in nicvf_allocate_net_interrupts()
1494 nic, &nic->msix_entries[irq].handle); in nicvf_allocate_net_interrupts()
1496 device_printf(nic->dev, in nicvf_allocate_net_interrupts()
1498 device_get_unit(nic->dev)); in nicvf_allocate_net_interrupts()
1504 nicvf_release_net_interrupts(nic); in nicvf_allocate_net_interrupts()
1509 nicvf_stop_locked(struct nicvf *nic) in nicvf_stop_locked() argument
1513 struct queue_set *qs = nic->qs; in nicvf_stop_locked()
1516 NICVF_CORE_LOCK_ASSERT(nic); in nicvf_stop_locked()
1518 callout_drain(&nic->stats_callout); in nicvf_stop_locked()
1520 ifp = nic->ifp; in nicvf_stop_locked()
1523 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_stop_locked()
1527 nicvf_disable_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_stop_locked()
1528 nicvf_clear_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_stop_locked()
1530 nicvf_disable_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_stop_locked()
1531 nicvf_clear_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_stop_locked()
1537 nicvf_config_data_transfer(nic, FALSE); in nicvf_stop_locked()
1540 nicvf_qset_config(nic, FALSE); in nicvf_stop_locked()
1543 nicvf_disable_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_stop_locked()
1549 nicvf_update_stats(struct nicvf *nic) in nicvf_update_stats() argument
1552 struct nicvf_hw_stats *stats = &nic->hw_stats; in nicvf_update_stats()
1553 struct nicvf_drv_stats *drv_stats = &nic->drv_stats; in nicvf_update_stats()
1554 struct queue_set *qs = nic->qs; in nicvf_update_stats()
1557 nicvf_reg_read(nic, NIC_VNIC_RX_STAT_0_13 | ((reg) << 3)) in nicvf_update_stats()
1559 nicvf_reg_read(nic, NIC_VNIC_TX_STAT_0_4 | ((reg) << 3)) in nicvf_update_stats()
1589 nicvf_update_rq_stats(nic, qidx); in nicvf_update_stats()
1591 nicvf_update_sq_stats(nic, qidx); in nicvf_update_stats()
1597 struct nicvf *nic; in nicvf_tick_stats() local
1599 nic = (struct nicvf *)arg; in nicvf_tick_stats()
1602 nicvf_update_stats(nic); in nicvf_tick_stats()
1604 callout_reset(&nic->stats_callout, hz, nicvf_tick_stats, nic); in nicvf_tick_stats()