Lines Matching refs:bp
184 static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev);
185 static int bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev);
186 static void bnxt_cancel_fw_health_check(struct bnxt *bp);
187 static int bnxt_restore_vlan_filters(struct bnxt *bp);
189 static void bnxt_free_error_recovery_info(struct bnxt *bp);
190 static void bnxt_free_rep_info(struct bnxt *bp);
192 int is_bnxt_in_error(struct bnxt *bp) in is_bnxt_in_error() argument
194 if (bp->flags & BNXT_FLAG_FATAL_ERROR) in is_bnxt_in_error()
196 if (bp->flags & BNXT_FLAG_FW_RESET) in is_bnxt_in_error()
208 static uint16_t bnxt_rss_ctxts(const struct bnxt *bp) in bnxt_rss_ctxts() argument
210 if (!BNXT_CHIP_THOR(bp)) in bnxt_rss_ctxts()
213 return RTE_ALIGN_MUL_CEIL(bp->rx_nr_rings, in bnxt_rss_ctxts()
218 uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp) in bnxt_rss_hash_tbl_size() argument
220 if (!BNXT_CHIP_THOR(bp)) in bnxt_rss_hash_tbl_size()
223 return bnxt_rss_ctxts(bp) * BNXT_RSS_ENTRIES_PER_CTX_THOR; in bnxt_rss_hash_tbl_size()
226 static void bnxt_free_parent_info(struct bnxt *bp) in bnxt_free_parent_info() argument
228 rte_free(bp->parent); in bnxt_free_parent_info()
231 static void bnxt_free_pf_info(struct bnxt *bp) in bnxt_free_pf_info() argument
233 rte_free(bp->pf); in bnxt_free_pf_info()
236 static void bnxt_free_link_info(struct bnxt *bp) in bnxt_free_link_info() argument
238 rte_free(bp->link_info); in bnxt_free_link_info()
241 static void bnxt_free_leds_info(struct bnxt *bp) in bnxt_free_leds_info() argument
243 if (BNXT_VF(bp)) in bnxt_free_leds_info()
246 rte_free(bp->leds); in bnxt_free_leds_info()
247 bp->leds = NULL; in bnxt_free_leds_info()
250 static void bnxt_free_flow_stats_info(struct bnxt *bp) in bnxt_free_flow_stats_info() argument
252 rte_free(bp->flow_stat); in bnxt_free_flow_stats_info()
253 bp->flow_stat = NULL; in bnxt_free_flow_stats_info()
256 static void bnxt_free_cos_queues(struct bnxt *bp) in bnxt_free_cos_queues() argument
258 rte_free(bp->rx_cos_queue); in bnxt_free_cos_queues()
259 rte_free(bp->tx_cos_queue); in bnxt_free_cos_queues()
262 static void bnxt_free_mem(struct bnxt *bp, bool reconfig) in bnxt_free_mem() argument
264 bnxt_free_filter_mem(bp); in bnxt_free_mem()
265 bnxt_free_vnic_attributes(bp); in bnxt_free_mem()
266 bnxt_free_vnic_mem(bp); in bnxt_free_mem()
273 bnxt_free_stats(bp); in bnxt_free_mem()
274 bnxt_free_tx_rings(bp); in bnxt_free_mem()
275 bnxt_free_rx_rings(bp); in bnxt_free_mem()
277 bnxt_free_async_cp_ring(bp); in bnxt_free_mem()
278 bnxt_free_rxtx_nq_ring(bp); in bnxt_free_mem()
280 rte_free(bp->grp_info); in bnxt_free_mem()
281 bp->grp_info = NULL; in bnxt_free_mem()
284 static int bnxt_alloc_parent_info(struct bnxt *bp) in bnxt_alloc_parent_info() argument
286 bp->parent = rte_zmalloc("bnxt_parent_info", in bnxt_alloc_parent_info()
288 if (bp->parent == NULL) in bnxt_alloc_parent_info()
294 static int bnxt_alloc_pf_info(struct bnxt *bp) in bnxt_alloc_pf_info() argument
296 bp->pf = rte_zmalloc("bnxt_pf_info", sizeof(struct bnxt_pf_info), 0); in bnxt_alloc_pf_info()
297 if (bp->pf == NULL) in bnxt_alloc_pf_info()
303 static int bnxt_alloc_link_info(struct bnxt *bp) in bnxt_alloc_link_info() argument
305 bp->link_info = in bnxt_alloc_link_info()
307 if (bp->link_info == NULL) in bnxt_alloc_link_info()
313 static int bnxt_alloc_leds_info(struct bnxt *bp) in bnxt_alloc_leds_info() argument
315 if (BNXT_VF(bp)) in bnxt_alloc_leds_info()
318 bp->leds = rte_zmalloc("bnxt_leds", in bnxt_alloc_leds_info()
321 if (bp->leds == NULL) in bnxt_alloc_leds_info()
327 static int bnxt_alloc_cos_queues(struct bnxt *bp) in bnxt_alloc_cos_queues() argument
329 bp->rx_cos_queue = in bnxt_alloc_cos_queues()
334 if (bp->rx_cos_queue == NULL) in bnxt_alloc_cos_queues()
337 bp->tx_cos_queue = in bnxt_alloc_cos_queues()
342 if (bp->tx_cos_queue == NULL) in bnxt_alloc_cos_queues()
348 static int bnxt_alloc_flow_stats_info(struct bnxt *bp) in bnxt_alloc_flow_stats_info() argument
350 bp->flow_stat = rte_zmalloc("bnxt_flow_xstat", in bnxt_alloc_flow_stats_info()
352 if (bp->flow_stat == NULL) in bnxt_alloc_flow_stats_info()
358 static int bnxt_alloc_mem(struct bnxt *bp, bool reconfig) in bnxt_alloc_mem() argument
362 rc = bnxt_alloc_ring_grps(bp); in bnxt_alloc_mem()
366 rc = bnxt_alloc_async_ring_struct(bp); in bnxt_alloc_mem()
370 rc = bnxt_alloc_vnic_mem(bp); in bnxt_alloc_mem()
374 rc = bnxt_alloc_vnic_attributes(bp); in bnxt_alloc_mem()
378 rc = bnxt_alloc_filter_mem(bp); in bnxt_alloc_mem()
382 rc = bnxt_alloc_async_cp_ring(bp); in bnxt_alloc_mem()
386 rc = bnxt_alloc_rxtx_nq_ring(bp); in bnxt_alloc_mem()
390 if (BNXT_FLOW_XSTATS_EN(bp)) { in bnxt_alloc_mem()
391 rc = bnxt_alloc_flow_stats_info(bp); in bnxt_alloc_mem()
399 bnxt_free_mem(bp, reconfig); in bnxt_alloc_mem()
403 static int bnxt_setup_one_vnic(struct bnxt *bp, uint16_t vnic_id) in bnxt_setup_one_vnic() argument
405 struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; in bnxt_setup_one_vnic()
406 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_setup_one_vnic()
412 rc = bnxt_vnic_grp_alloc(bp, vnic); in bnxt_setup_one_vnic()
419 rc = bnxt_hwrm_vnic_alloc(bp, vnic); in bnxt_setup_one_vnic()
425 int j, nr_ctxs = bnxt_rss_ctxts(bp); in bnxt_setup_one_vnic()
429 rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic, j); in bnxt_setup_one_vnic()
452 rc = bnxt_hwrm_vnic_cfg(bp, vnic); in bnxt_setup_one_vnic()
456 rc = bnxt_set_hwrm_vnic_filters(bp, vnic); in bnxt_setup_one_vnic()
460 for (j = 0; j < bp->rx_num_qs_per_vnic; j++) { in bnxt_setup_one_vnic()
461 rxq = bp->eth_dev->data->rx_queues[j]; in bnxt_setup_one_vnic()
467 if (BNXT_HAS_RING_GRPS(bp) && rxq->rx_deferred_start) in bnxt_setup_one_vnic()
475 rc = bnxt_vnic_rss_configure(bp, vnic); in bnxt_setup_one_vnic()
479 bnxt_hwrm_vnic_plcmode_cfg(bp, vnic); in bnxt_setup_one_vnic()
482 bnxt_hwrm_vnic_tpa_cfg(bp, vnic, 1); in bnxt_setup_one_vnic()
484 bnxt_hwrm_vnic_tpa_cfg(bp, vnic, 0); in bnxt_setup_one_vnic()
493 static int bnxt_register_fc_ctx_mem(struct bnxt *bp) in bnxt_register_fc_ctx_mem() argument
497 rc = bnxt_hwrm_ctx_rgtr(bp, bp->flow_stat->rx_fc_in_tbl.dma, in bnxt_register_fc_ctx_mem()
498 &bp->flow_stat->rx_fc_in_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
505 bp->flow_stat->rx_fc_in_tbl.va, in bnxt_register_fc_ctx_mem()
506 (void *)((uintptr_t)bp->flow_stat->rx_fc_in_tbl.dma), in bnxt_register_fc_ctx_mem()
507 bp->flow_stat->rx_fc_in_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
509 rc = bnxt_hwrm_ctx_rgtr(bp, bp->flow_stat->rx_fc_out_tbl.dma, in bnxt_register_fc_ctx_mem()
510 &bp->flow_stat->rx_fc_out_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
517 bp->flow_stat->rx_fc_out_tbl.va, in bnxt_register_fc_ctx_mem()
518 (void *)((uintptr_t)bp->flow_stat->rx_fc_out_tbl.dma), in bnxt_register_fc_ctx_mem()
519 bp->flow_stat->rx_fc_out_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
521 rc = bnxt_hwrm_ctx_rgtr(bp, bp->flow_stat->tx_fc_in_tbl.dma, in bnxt_register_fc_ctx_mem()
522 &bp->flow_stat->tx_fc_in_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
529 bp->flow_stat->tx_fc_in_tbl.va, in bnxt_register_fc_ctx_mem()
530 (void *)((uintptr_t)bp->flow_stat->tx_fc_in_tbl.dma), in bnxt_register_fc_ctx_mem()
531 bp->flow_stat->tx_fc_in_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
533 rc = bnxt_hwrm_ctx_rgtr(bp, bp->flow_stat->tx_fc_out_tbl.dma, in bnxt_register_fc_ctx_mem()
534 &bp->flow_stat->tx_fc_out_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
541 bp->flow_stat->tx_fc_out_tbl.va, in bnxt_register_fc_ctx_mem()
542 (void *)((uintptr_t)bp->flow_stat->tx_fc_out_tbl.dma), in bnxt_register_fc_ctx_mem()
543 bp->flow_stat->tx_fc_out_tbl.ctx_id); in bnxt_register_fc_ctx_mem()
545 memset(bp->flow_stat->rx_fc_out_tbl.va, in bnxt_register_fc_ctx_mem()
547 bp->flow_stat->rx_fc_out_tbl.size); in bnxt_register_fc_ctx_mem()
548 rc = bnxt_hwrm_cfa_counter_cfg(bp, BNXT_DIR_RX, in bnxt_register_fc_ctx_mem()
550 bp->flow_stat->rx_fc_out_tbl.ctx_id, in bnxt_register_fc_ctx_mem()
551 bp->flow_stat->max_fc, in bnxt_register_fc_ctx_mem()
556 memset(bp->flow_stat->tx_fc_out_tbl.va, in bnxt_register_fc_ctx_mem()
558 bp->flow_stat->tx_fc_out_tbl.size); in bnxt_register_fc_ctx_mem()
559 rc = bnxt_hwrm_cfa_counter_cfg(bp, BNXT_DIR_TX, in bnxt_register_fc_ctx_mem()
561 bp->flow_stat->tx_fc_out_tbl.ctx_id, in bnxt_register_fc_ctx_mem()
562 bp->flow_stat->max_fc, in bnxt_register_fc_ctx_mem()
586 static int bnxt_init_fc_ctx_mem(struct bnxt *bp) in bnxt_init_fc_ctx_mem() argument
588 struct rte_pci_device *pdev = bp->pdev; in bnxt_init_fc_ctx_mem()
593 max_fc = bp->flow_stat->max_fc; in bnxt_init_fc_ctx_mem()
600 &bp->flow_stat->rx_fc_in_tbl); in bnxt_init_fc_ctx_mem()
609 &bp->flow_stat->rx_fc_out_tbl); in bnxt_init_fc_ctx_mem()
618 &bp->flow_stat->tx_fc_in_tbl); in bnxt_init_fc_ctx_mem()
627 &bp->flow_stat->tx_fc_out_tbl); in bnxt_init_fc_ctx_mem()
631 rc = bnxt_register_fc_ctx_mem(bp); in bnxt_init_fc_ctx_mem()
636 static int bnxt_init_ctx_mem(struct bnxt *bp) in bnxt_init_ctx_mem() argument
640 if (!(bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS) || in bnxt_init_ctx_mem()
641 !(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) || in bnxt_init_ctx_mem()
642 !BNXT_FLOW_XSTATS_EN(bp)) in bnxt_init_ctx_mem()
645 rc = bnxt_hwrm_cfa_counter_qcaps(bp, &bp->flow_stat->max_fc); in bnxt_init_ctx_mem()
649 rc = bnxt_init_fc_ctx_mem(bp); in bnxt_init_ctx_mem()
654 static int bnxt_update_phy_setting(struct bnxt *bp) in bnxt_update_phy_setting() argument
659 rc = bnxt_get_hwrm_link_config(bp, &new); in bnxt_update_phy_setting()
670 if (!new.link_status || IS_BNXT_DEV_957508_N2100(bp)) { in bnxt_update_phy_setting()
671 rc = bnxt_set_hwrm_link_config(bp, true); in bnxt_update_phy_setting()
681 static int bnxt_init_chip(struct bnxt *bp) in bnxt_init_chip() argument
683 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(bp->eth_dev); in bnxt_init_chip()
691 if (bp->eth_dev->data->mtu > RTE_ETHER_MTU) { in bnxt_init_chip()
692 bp->eth_dev->data->dev_conf.rxmode.offloads |= in bnxt_init_chip()
694 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_init_chip()
696 bp->eth_dev->data->dev_conf.rxmode.offloads &= in bnxt_init_chip()
698 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_init_chip()
704 if (BNXT_CHIP_THOR(bp)) in bnxt_init_chip()
705 bp->max_ring_grps = BNXT_MAX_RSS_CTXTS_THOR; in bnxt_init_chip()
707 rc = bnxt_alloc_all_hwrm_stat_ctxs(bp); in bnxt_init_chip()
713 rc = bnxt_alloc_hwrm_rings(bp); in bnxt_init_chip()
719 rc = bnxt_alloc_all_hwrm_ring_grps(bp); in bnxt_init_chip()
725 if (!(bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY)) in bnxt_init_chip()
729 if (bp->rx_cos_queue[i].id != 0xff) { in bnxt_init_chip()
730 struct bnxt_vnic_info *vnic = &bp->vnic_info[j++]; in bnxt_init_chip()
738 vnic->cos_queue_id = bp->rx_cos_queue[i].id; in bnxt_init_chip()
739 bp->rx_cosq_cnt++; in bnxt_init_chip()
744 rc = bnxt_mq_rx_configure(bp); in bnxt_init_chip()
751 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_init_chip()
752 rc = bnxt_setup_one_vnic(bp, i); in bnxt_init_chip()
757 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, &bp->vnic_info[0], 0, NULL); in bnxt_init_chip()
766 !RTE_ETH_DEV_SRIOV(bp->eth_dev).active) && in bnxt_init_chip()
767 bp->eth_dev->data->dev_conf.intr_conf.rxq != 0) { in bnxt_init_chip()
768 intr_vector = bp->eth_dev->data->nb_rx_queues; in bnxt_init_chip()
770 if (intr_vector > bp->rx_cp_nr_rings) { in bnxt_init_chip()
772 bp->rx_cp_nr_rings); in bnxt_init_chip()
783 bp->eth_dev->data->nb_rx_queues * in bnxt_init_chip()
787 " intr_vec", bp->eth_dev->data->nb_rx_queues); in bnxt_init_chip()
795 for (queue_id = 0; queue_id < bp->eth_dev->data->nb_rx_queues; in bnxt_init_chip()
812 rc = bnxt_update_phy_setting(bp); in bnxt_init_chip()
816 bp->mark_table = rte_zmalloc("bnxt_mark_table", BNXT_MARK_TABLE_SZ, 0); in bnxt_init_chip()
817 if (!bp->mark_table) in bnxt_init_chip()
834 static int bnxt_shutdown_nic(struct bnxt *bp) in bnxt_shutdown_nic() argument
836 bnxt_free_all_hwrm_resources(bp); in bnxt_shutdown_nic()
837 bnxt_free_all_filters(bp); in bnxt_shutdown_nic()
838 bnxt_free_all_vnics(bp); in bnxt_shutdown_nic()
846 uint32_t bnxt_get_speed_capabilities(struct bnxt *bp) in bnxt_get_speed_capabilities() argument
848 uint32_t link_speed = bp->link_info->support_speeds; in bnxt_get_speed_capabilities()
852 if (link_speed == 0 && bp->link_info->support_pam4_speeds > 0) in bnxt_get_speed_capabilities()
853 link_speed = bp->link_info->support_pam4_speeds; in bnxt_get_speed_capabilities()
882 if (bp->link_info->auto_mode == in bnxt_get_speed_capabilities()
895 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_info_get_op() local
900 rc = is_bnxt_in_error(bp); in bnxt_dev_info_get_op()
905 dev_info->max_mac_addrs = bp->max_l2_ctx; in bnxt_dev_info_get_op()
909 if (BNXT_PF(bp)) in bnxt_dev_info_get_op()
912 max_rx_rings = BNXT_MAX_RINGS(bp); in bnxt_dev_info_get_op()
916 dev_info->reta_size = bnxt_rss_hash_tbl_size(bp); in bnxt_dev_info_get_op()
918 max_vnics = bp->max_vnics; in bnxt_dev_info_get_op()
929 if (bp->flags & BNXT_FLAG_PTP_SUPPORTED) in bnxt_dev_info_get_op()
936 dev_info->speed_capa = bnxt_get_speed_capabilities(bp); in bnxt_dev_info_get_op()
966 if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) { in bnxt_dev_info_get_op()
968 dev_info->switch_info.domain_id = bp->switch_domain_id; in bnxt_dev_info_get_op()
970 BNXT_PF(bp) ? BNXT_SWITCH_PORT_ID_PF : in bnxt_dev_info_get_op()
1013 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_configure_op() local
1017 bp->rx_queues = (void *)eth_dev->data->rx_queues; in bnxt_dev_configure_op()
1018 bp->tx_queues = (void *)eth_dev->data->tx_queues; in bnxt_dev_configure_op()
1019 bp->tx_nr_rings = eth_dev->data->nb_tx_queues; in bnxt_dev_configure_op()
1020 bp->rx_nr_rings = eth_dev->data->nb_rx_queues; in bnxt_dev_configure_op()
1022 rc = is_bnxt_in_error(bp); in bnxt_dev_configure_op()
1026 if (BNXT_VF(bp) && (bp->flags & BNXT_FLAG_NEW_RM)) { in bnxt_dev_configure_op()
1027 rc = bnxt_hwrm_check_vf_rings(bp); in bnxt_dev_configure_op()
1039 pthread_mutex_lock(&bp->def_cp_lock); in bnxt_dev_configure_op()
1041 if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) { in bnxt_dev_configure_op()
1042 bnxt_disable_int(bp); in bnxt_dev_configure_op()
1043 bnxt_free_cp_ring(bp, bp->async_cp_ring); in bnxt_dev_configure_op()
1046 rc = bnxt_hwrm_func_reserve_vf_resc(bp, false); in bnxt_dev_configure_op()
1049 pthread_mutex_unlock(&bp->def_cp_lock); in bnxt_dev_configure_op()
1053 if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) { in bnxt_dev_configure_op()
1054 rc = bnxt_alloc_async_cp_ring(bp); in bnxt_dev_configure_op()
1056 pthread_mutex_unlock(&bp->def_cp_lock); in bnxt_dev_configure_op()
1059 bnxt_enable_int(bp); in bnxt_dev_configure_op()
1062 pthread_mutex_unlock(&bp->def_cp_lock); in bnxt_dev_configure_op()
1065 rc = bnxt_hwrm_func_qcaps(bp); in bnxt_dev_configure_op()
1073 if (eth_dev->data->nb_rx_queues > bp->max_rx_rings || in bnxt_dev_configure_op()
1074 eth_dev->data->nb_tx_queues > bp->max_tx_rings || in bnxt_dev_configure_op()
1076 + BNXT_NUM_ASYNC_CPR(bp) > bp->max_cp_rings || in bnxt_dev_configure_op()
1078 bp->max_stat_ctx) in bnxt_dev_configure_op()
1081 if (BNXT_HAS_RING_GRPS(bp) && in bnxt_dev_configure_op()
1082 (uint32_t)(eth_dev->data->nb_rx_queues) > bp->max_ring_grps) in bnxt_dev_configure_op()
1086 bp->max_vnics < eth_dev->data->nb_rx_queues) in bnxt_dev_configure_op()
1089 bp->rx_cp_nr_rings = bp->rx_nr_rings; in bnxt_dev_configure_op()
1090 bp->tx_cp_nr_rings = bp->tx_nr_rings; in bnxt_dev_configure_op()
1114 bp->max_tx_rings, bp->max_rx_rings, bp->max_cp_rings, in bnxt_dev_configure_op()
1115 bp->max_stat_ctx, bp->max_ring_grps, bp->max_vnics); in bnxt_dev_configure_op()
1160 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_receive_function() local
1180 !BNXT_TRUFLOW_EN(bp) && BNXT_NUM_ASYNC_CPR(bp) && in bnxt_receive_function()
1184 bp->flags |= BNXT_FLAG_RX_VECTOR_PKT_MODE; in bnxt_receive_function()
1196 bp->flags &= ~BNXT_FLAG_RX_VECTOR_PKT_MODE; in bnxt_receive_function()
1206 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_transmit_function() local
1214 !BNXT_TRUFLOW_EN(bp) && in bnxt_transmit_function()
1232 static int bnxt_handle_if_change_status(struct bnxt *bp) in bnxt_handle_if_change_status() argument
1239 bp->flags |= BNXT_FLAG_FATAL_ERROR; in bnxt_handle_if_change_status()
1240 bnxt_uninit_resources(bp, true); in bnxt_handle_if_change_status()
1243 bp->flags &= ~BNXT_FLAG_FATAL_ERROR; in bnxt_handle_if_change_status()
1244 rc = bnxt_init_resources(bp, true); in bnxt_handle_if_change_status()
1246 bp->flags &= ~BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE; in bnxt_handle_if_change_status()
1253 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_start_op() local
1263 if (bp->rx_cp_nr_rings > RTE_ETHDEV_QUEUE_STAT_CNTRS) { in bnxt_dev_start_op()
1266 bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS); in bnxt_dev_start_op()
1270 rc = bnxt_hwrm_if_change(bp, true); in bnxt_dev_start_op()
1280 if (bp->flags & BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE) { in bnxt_dev_start_op()
1281 rc = bnxt_handle_if_change_status(bp); in bnxt_dev_start_op()
1286 bnxt_enable_int(bp); in bnxt_dev_start_op()
1288 rc = bnxt_init_chip(bp); in bnxt_dev_start_op()
1306 rc = bnxt_ulp_port_init(bp); in bnxt_dev_start_op()
1313 bnxt_schedule_fw_health_check(bp); in bnxt_dev_start_op()
1318 bnxt_shutdown_nic(bp); in bnxt_dev_start_op()
1319 bnxt_free_tx_mbufs(bp); in bnxt_dev_start_op()
1320 bnxt_free_rx_mbufs(bp); in bnxt_dev_start_op()
1321 bnxt_hwrm_if_change(bp, false); in bnxt_dev_start_op()
1328 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_set_link_up_op() local
1331 if (!bp->link_info->link_up) in bnxt_dev_set_link_up_op()
1332 rc = bnxt_set_hwrm_link_config(bp, true); in bnxt_dev_set_link_up_op()
1342 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_set_link_down_op() local
1345 bnxt_set_hwrm_link_config(bp, false); in bnxt_dev_set_link_down_op()
1346 bp->link_info->link_up = 0; in bnxt_dev_set_link_down_op()
1351 static void bnxt_free_switch_domain(struct bnxt *bp) in bnxt_free_switch_domain() argument
1355 if (bp->switch_domain_id) { in bnxt_free_switch_domain()
1356 rc = rte_eth_switch_domain_free(bp->switch_domain_id); in bnxt_free_switch_domain()
1359 bp->switch_domain_id, rc); in bnxt_free_switch_domain()
1366 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_stop_op() local
1379 bnxt_disable_int(bp); in bnxt_dev_stop_op()
1385 ret = bnxt_rep_stop_all(bp); in bnxt_dev_stop_op()
1390 bnxt_ulp_port_deinit(bp); in bnxt_dev_stop_op()
1392 bnxt_cancel_fw_health_check(bp); in bnxt_dev_stop_op()
1395 if (!is_bnxt_in_error(bp)) { in bnxt_dev_stop_op()
1398 if (BNXT_SINGLE_PF(bp)) in bnxt_dev_stop_op()
1412 bnxt_hwrm_port_clr_stats(bp); in bnxt_dev_stop_op()
1413 bnxt_free_tx_mbufs(bp); in bnxt_dev_stop_op()
1414 bnxt_free_rx_mbufs(bp); in bnxt_dev_stop_op()
1417 bnxt_shutdown_nic(bp); in bnxt_dev_stop_op()
1418 bnxt_hwrm_if_change(bp, false); in bnxt_dev_stop_op()
1420 rte_free(bp->mark_table); in bnxt_dev_stop_op()
1421 bp->mark_table = NULL; in bnxt_dev_stop_op()
1423 bp->flags &= ~BNXT_FLAG_RX_VECTOR_PKT_MODE; in bnxt_dev_stop_op()
1424 bp->rx_cosq_cnt = 0; in bnxt_dev_stop_op()
1426 if (BNXT_FLOW_XSTATS_EN(bp)) in bnxt_dev_stop_op()
1427 bp->flow_stat->flow_count = 0; in bnxt_dev_stop_op()
1434 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_close_op() local
1441 rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp); in bnxt_dev_close_op()
1442 rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp); in bnxt_dev_close_op()
1443 bnxt_cancel_fc_thread(bp); in bnxt_dev_close_op()
1448 bnxt_free_switch_domain(bp); in bnxt_dev_close_op()
1450 bnxt_uninit_resources(bp, false); in bnxt_dev_close_op()
1452 bnxt_free_leds_info(bp); in bnxt_dev_close_op()
1453 bnxt_free_cos_queues(bp); in bnxt_dev_close_op()
1454 bnxt_free_link_info(bp); in bnxt_dev_close_op()
1455 bnxt_free_pf_info(bp); in bnxt_dev_close_op()
1456 bnxt_free_parent_info(bp); in bnxt_dev_close_op()
1458 rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone); in bnxt_dev_close_op()
1459 bp->tx_mem_zone = NULL; in bnxt_dev_close_op()
1460 rte_memzone_free((const struct rte_memzone *)bp->rx_mem_zone); in bnxt_dev_close_op()
1461 bp->rx_mem_zone = NULL; in bnxt_dev_close_op()
1463 bnxt_hwrm_free_vf_info(bp); in bnxt_dev_close_op()
1465 rte_free(bp->grp_info); in bnxt_dev_close_op()
1466 bp->grp_info = NULL; in bnxt_dev_close_op()
1474 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_mac_addr_remove_op() local
1480 if (is_bnxt_in_error(bp)) in bnxt_mac_addr_remove_op()
1487 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_mac_addr_remove_op()
1491 vnic = &bp->vnic_info[i]; in bnxt_mac_addr_remove_op()
1498 bnxt_hwrm_clear_l2_filter(bp, filter); in bnxt_mac_addr_remove_op()
1499 bnxt_free_filter(bp, filter); in bnxt_mac_addr_remove_op()
1506 static int bnxt_add_mac_filter(struct bnxt *bp, struct bnxt_vnic_info *vnic, in bnxt_add_mac_filter() argument
1523 filter = bnxt_alloc_filter(bp); in bnxt_add_mac_filter()
1537 rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter); in bnxt_add_mac_filter()
1545 bnxt_free_filter(bp, filter); in bnxt_add_mac_filter()
1555 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_mac_addr_add_op() local
1556 struct bnxt_vnic_info *vnic = &bp->vnic_info[pool]; in bnxt_mac_addr_add_op()
1559 rc = is_bnxt_in_error(bp); in bnxt_mac_addr_add_op()
1563 if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp)) { in bnxt_mac_addr_add_op()
1577 rc = bnxt_add_mac_filter(bp, vnic, mac_addr, index, pool); in bnxt_mac_addr_add_op()
1585 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_link_update_op() local
1590 rc = is_bnxt_in_error(bp); in bnxt_link_update_op()
1597 rc = bnxt_get_hwrm_link_config(bp, &new); in bnxt_link_update_op()
1615 if (!BNXT_SINGLE_PF(bp) && !eth_dev->data->dev_started) in bnxt_link_update_op()
1636 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_promiscuous_enable_op() local
1641 rc = is_bnxt_in_error(bp); in bnxt_promiscuous_enable_op()
1649 if (bp->vnic_info == NULL) in bnxt_promiscuous_enable_op()
1652 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_promiscuous_enable_op()
1656 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL); in bnxt_promiscuous_enable_op()
1665 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_promiscuous_disable_op() local
1670 rc = is_bnxt_in_error(bp); in bnxt_promiscuous_disable_op()
1678 if (bp->vnic_info == NULL) in bnxt_promiscuous_disable_op()
1681 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_promiscuous_disable_op()
1685 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL); in bnxt_promiscuous_disable_op()
1694 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_allmulticast_enable_op() local
1699 rc = is_bnxt_in_error(bp); in bnxt_allmulticast_enable_op()
1707 if (bp->vnic_info == NULL) in bnxt_allmulticast_enable_op()
1710 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_allmulticast_enable_op()
1714 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL); in bnxt_allmulticast_enable_op()
1723 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_allmulticast_disable_op() local
1728 rc = is_bnxt_in_error(bp); in bnxt_allmulticast_disable_op()
1736 if (bp->vnic_info == NULL) in bnxt_allmulticast_disable_op()
1739 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_allmulticast_disable_op()
1743 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL); in bnxt_allmulticast_disable_op()
1751 static struct bnxt_rx_queue *bnxt_qid_to_rxq(struct bnxt *bp, uint16_t qid) in bnxt_qid_to_rxq() argument
1753 if (qid >= bp->rx_nr_rings) in bnxt_qid_to_rxq()
1756 return bp->eth_dev->data->rx_queues[qid]; in bnxt_qid_to_rxq()
1760 static uint16_t bnxt_rss_to_qid(struct bnxt *bp, uint16_t fwr) in bnxt_rss_to_qid() argument
1765 if (!BNXT_HAS_RING_GRPS(bp)) { in bnxt_rss_to_qid()
1766 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rss_to_qid()
1767 rxq = bp->eth_dev->data->rx_queues[i]; in bnxt_rss_to_qid()
1772 for (i = 0; i < bp->rx_nr_rings; i++) { in bnxt_rss_to_qid()
1773 if (bp->grp_info[i].fw_grp_id == fwr) in bnxt_rss_to_qid()
1785 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_reta_update_op() local
1786 struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; in bnxt_reta_update_op()
1787 struct bnxt_vnic_info *vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_reta_update_op()
1788 uint16_t tbl_size = bnxt_rss_hash_tbl_size(bp); in bnxt_reta_update_op()
1792 rc = is_bnxt_in_error(bp); in bnxt_reta_update_op()
1818 rxq = bnxt_qid_to_rxq(bp, reta_conf[idx].reta[sft]); in bnxt_reta_update_op()
1824 if (BNXT_CHIP_THOR(bp)) { in bnxt_reta_update_op()
1835 bnxt_hwrm_vnic_rss_cfg(bp, vnic); in bnxt_reta_update_op()
1843 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_reta_query_op() local
1844 struct bnxt_vnic_info *vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_reta_query_op()
1845 uint16_t tbl_size = bnxt_rss_hash_tbl_size(bp); in bnxt_reta_query_op()
1849 rc = is_bnxt_in_error(bp); in bnxt_reta_query_op()
1873 if (BNXT_CHIP_THOR(bp)) in bnxt_reta_query_op()
1874 qid = bnxt_rss_to_qid(bp, in bnxt_reta_query_op()
1877 qid = bnxt_rss_to_qid(bp, vnic->rss_table[i]); in bnxt_reta_query_op()
1893 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_rss_hash_update_op() local
1894 struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; in bnxt_rss_hash_update_op()
1898 rc = is_bnxt_in_error(bp); in bnxt_rss_hash_update_op()
1914 bp->flags |= BNXT_FLAG_UPDATE_HASH; in bnxt_rss_hash_update_op()
1920 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_rss_hash_update_op()
1923 bnxt_rte_to_hwrm_hash_level(bp, rss_conf->rss_hf, in bnxt_rss_hash_update_op()
1941 bnxt_hwrm_vnic_rss_cfg(bp, vnic); in bnxt_rss_hash_update_op()
1948 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_rss_hash_conf_get_op() local
1949 struct bnxt_vnic_info *vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_rss_hash_conf_get_op()
1953 rc = is_bnxt_in_error(bp); in bnxt_rss_hash_conf_get_op()
1997 bnxt_hwrm_to_rte_rss_level(bp, vnic->hash_mode); in bnxt_rss_hash_conf_get_op()
2014 struct bnxt *bp = dev->data->dev_private; in bnxt_flow_ctrl_get_op() local
2018 rc = is_bnxt_in_error(bp); in bnxt_flow_ctrl_get_op()
2022 rc = bnxt_get_hwrm_link_config(bp, &link_info); in bnxt_flow_ctrl_get_op()
2027 if (bp->link_info->auto_pause) in bnxt_flow_ctrl_get_op()
2029 switch (bp->link_info->pause) { in bnxt_flow_ctrl_get_op()
2050 struct bnxt *bp = dev->data->dev_private; in bnxt_flow_ctrl_set_op() local
2053 rc = is_bnxt_in_error(bp); in bnxt_flow_ctrl_set_op()
2057 if (!BNXT_SINGLE_PF(bp) || BNXT_VF(bp)) { in bnxt_flow_ctrl_set_op()
2064 bp->link_info->auto_pause = 0; in bnxt_flow_ctrl_set_op()
2065 bp->link_info->force_pause = 0; in bnxt_flow_ctrl_set_op()
2069 bp->link_info->auto_pause = in bnxt_flow_ctrl_set_op()
2071 bp->link_info->force_pause = 0; in bnxt_flow_ctrl_set_op()
2073 bp->link_info->auto_pause = 0; in bnxt_flow_ctrl_set_op()
2074 bp->link_info->force_pause = in bnxt_flow_ctrl_set_op()
2080 bp->link_info->auto_pause = in bnxt_flow_ctrl_set_op()
2082 bp->link_info->force_pause = 0; in bnxt_flow_ctrl_set_op()
2084 bp->link_info->auto_pause = 0; in bnxt_flow_ctrl_set_op()
2085 bp->link_info->force_pause = in bnxt_flow_ctrl_set_op()
2091 bp->link_info->auto_pause = in bnxt_flow_ctrl_set_op()
2094 bp->link_info->force_pause = 0; in bnxt_flow_ctrl_set_op()
2096 bp->link_info->auto_pause = 0; in bnxt_flow_ctrl_set_op()
2097 bp->link_info->force_pause = in bnxt_flow_ctrl_set_op()
2103 return bnxt_set_hwrm_link_config(bp, true); in bnxt_flow_ctrl_set_op()
2111 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_udp_tunnel_port_add_op() local
2115 rc = is_bnxt_in_error(bp); in bnxt_udp_tunnel_port_add_op()
2121 if (bp->vxlan_port_cnt) { in bnxt_udp_tunnel_port_add_op()
2124 if (bp->vxlan_port != udp_tunnel->udp_port) { in bnxt_udp_tunnel_port_add_op()
2128 bp->vxlan_port_cnt++; in bnxt_udp_tunnel_port_add_op()
2133 bp->vxlan_port_cnt++; in bnxt_udp_tunnel_port_add_op()
2136 if (bp->geneve_port_cnt) { in bnxt_udp_tunnel_port_add_op()
2139 if (bp->geneve_port != udp_tunnel->udp_port) { in bnxt_udp_tunnel_port_add_op()
2143 bp->geneve_port_cnt++; in bnxt_udp_tunnel_port_add_op()
2148 bp->geneve_port_cnt++; in bnxt_udp_tunnel_port_add_op()
2154 rc = bnxt_hwrm_tunnel_dst_port_alloc(bp, udp_tunnel->udp_port, in bnxt_udp_tunnel_port_add_op()
2163 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_udp_tunnel_port_del_op() local
2168 rc = is_bnxt_in_error(bp); in bnxt_udp_tunnel_port_del_op()
2174 if (!bp->vxlan_port_cnt) { in bnxt_udp_tunnel_port_del_op()
2178 if (bp->vxlan_port != udp_tunnel->udp_port) { in bnxt_udp_tunnel_port_del_op()
2180 udp_tunnel->udp_port, bp->vxlan_port); in bnxt_udp_tunnel_port_del_op()
2183 if (--bp->vxlan_port_cnt) in bnxt_udp_tunnel_port_del_op()
2188 port = bp->vxlan_fw_dst_port_id; in bnxt_udp_tunnel_port_del_op()
2191 if (!bp->geneve_port_cnt) { in bnxt_udp_tunnel_port_del_op()
2195 if (bp->geneve_port != udp_tunnel->udp_port) { in bnxt_udp_tunnel_port_del_op()
2197 udp_tunnel->udp_port, bp->geneve_port); in bnxt_udp_tunnel_port_del_op()
2200 if (--bp->geneve_port_cnt) in bnxt_udp_tunnel_port_del_op()
2205 port = bp->geneve_fw_dst_port_id; in bnxt_udp_tunnel_port_del_op()
2212 rc = bnxt_hwrm_tunnel_dst_port_free(bp, port, tunnel_type); in bnxt_udp_tunnel_port_del_op()
2216 static int bnxt_del_vlan_filter(struct bnxt *bp, uint16_t vlan_id) in bnxt_del_vlan_filter() argument
2223 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_del_vlan_filter()
2227 if (bnxt_vlan_filter_exists(bp, filter, chk, vlan_id)) { in bnxt_del_vlan_filter()
2229 rc = bnxt_hwrm_clear_l2_filter(bp, filter); in bnxt_del_vlan_filter()
2234 bnxt_free_filter(bp, filter); in bnxt_del_vlan_filter()
2245 static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id) in bnxt_add_vlan_filter() argument
2262 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_add_vlan_filter()
2266 if (bnxt_vlan_filter_exists(bp, filter, chk, vlan_id)) in bnxt_add_vlan_filter()
2275 filter = bnxt_alloc_filter(bp); in bnxt_add_vlan_filter()
2293 rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter); in bnxt_add_vlan_filter()
2298 bnxt_free_filter(bp, filter); in bnxt_add_vlan_filter()
2317 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_vlan_filter_set_op() local
2320 rc = is_bnxt_in_error(bp); in bnxt_vlan_filter_set_op()
2331 return bnxt_add_vlan_filter(bp, vlan_id); in bnxt_vlan_filter_set_op()
2333 return bnxt_del_vlan_filter(bp, vlan_id); in bnxt_vlan_filter_set_op()
2336 static int bnxt_del_dflt_mac_filter(struct bnxt *bp, in bnxt_del_dflt_mac_filter() argument
2345 !memcmp(filter->l2_addr, bp->mac_addr, in bnxt_del_dflt_mac_filter()
2347 rc = bnxt_hwrm_clear_l2_filter(bp, filter); in bnxt_del_dflt_mac_filter()
2351 bnxt_free_filter(bp, filter); in bnxt_del_dflt_mac_filter()
2361 bnxt_config_vlan_hw_filter(struct bnxt *bp, uint64_t rx_offloads) in bnxt_config_vlan_hw_filter() argument
2367 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_config_vlan_hw_filter()
2371 bnxt_del_vlan_filter(bp, i); in bnxt_config_vlan_hw_filter()
2373 rc = bnxt_add_mac_filter(bp, vnic, NULL, 0, 0); in bnxt_config_vlan_hw_filter()
2383 bnxt_del_dflt_mac_filter(bp, vnic); in bnxt_config_vlan_hw_filter()
2385 bnxt_add_vlan_filter(bp, 0); in bnxt_config_vlan_hw_filter()
2393 static int bnxt_free_one_vnic(struct bnxt *bp, uint16_t vnic_id) in bnxt_free_one_vnic() argument
2395 struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; in bnxt_free_one_vnic()
2400 if (bp->eth_dev->data->dev_conf.rxmode.offloads & in bnxt_free_one_vnic()
2403 bnxt_del_vlan_filter(bp, i); in bnxt_free_one_vnic()
2405 bnxt_del_dflt_mac_filter(bp, vnic); in bnxt_free_one_vnic()
2407 rc = bnxt_hwrm_vnic_free(bp, vnic); in bnxt_free_one_vnic()
2420 bnxt_config_vlan_hw_stripping(struct bnxt *bp, uint64_t rx_offloads) in bnxt_config_vlan_hw_stripping() argument
2422 struct bnxt_vnic_info *vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_config_vlan_hw_stripping()
2426 rc = bnxt_free_one_vnic(bp, 0); in bnxt_config_vlan_hw_stripping()
2431 rc = bnxt_setup_one_vnic(bp, 0); in bnxt_config_vlan_hw_stripping()
2435 if (bp->eth_dev->data->dev_conf.rxmode.offloads & in bnxt_config_vlan_hw_stripping()
2437 rc = bnxt_add_vlan_filter(bp, 0); in bnxt_config_vlan_hw_stripping()
2440 rc = bnxt_restore_vlan_filters(bp); in bnxt_config_vlan_hw_stripping()
2444 rc = bnxt_add_mac_filter(bp, vnic, NULL, 0, 0); in bnxt_config_vlan_hw_stripping()
2449 rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL); in bnxt_config_vlan_hw_stripping()
2463 struct bnxt *bp = dev->data->dev_private; in bnxt_vlan_offload_set_op() local
2466 rc = is_bnxt_in_error(bp); in bnxt_vlan_offload_set_op()
2476 rc = bnxt_config_vlan_hw_filter(bp, rx_offloads); in bnxt_vlan_offload_set_op()
2483 rc = bnxt_config_vlan_hw_stripping(bp, rx_offloads); in bnxt_vlan_offload_set_op()
2502 struct bnxt *bp = dev->data->dev_private; in bnxt_vlan_tpid_set_op() local
2522 bp->outer_tpid_bd = in bnxt_vlan_tpid_set_op()
2526 bp->outer_tpid_bd = in bnxt_vlan_tpid_set_op()
2530 bp->outer_tpid_bd = in bnxt_vlan_tpid_set_op()
2534 bp->outer_tpid_bd = in bnxt_vlan_tpid_set_op()
2538 bp->outer_tpid_bd = in bnxt_vlan_tpid_set_op()
2545 bp->outer_tpid_bd |= tpid; in bnxt_vlan_tpid_set_op()
2546 PMD_DRV_LOG(INFO, "outer_tpid_bd = %x\n", bp->outer_tpid_bd); in bnxt_vlan_tpid_set_op()
2560 struct bnxt *bp = dev->data->dev_private; in bnxt_set_default_mac_addr_op() local
2562 struct bnxt_vnic_info *vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_set_default_mac_addr_op()
2565 rc = is_bnxt_in_error(bp); in bnxt_set_default_mac_addr_op()
2569 if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp)) in bnxt_set_default_mac_addr_op()
2580 if (memcmp(addr, bp->mac_addr, RTE_ETHER_ADDR_LEN) == 0) in bnxt_set_default_mac_addr_op()
2584 bnxt_del_dflt_mac_filter(bp, vnic); in bnxt_set_default_mac_addr_op()
2586 memcpy(bp->mac_addr, addr, RTE_ETHER_ADDR_LEN); in bnxt_set_default_mac_addr_op()
2589 rc = bnxt_add_vlan_filter(bp, 0); in bnxt_set_default_mac_addr_op()
2591 rc = bnxt_add_mac_filter(bp, vnic, addr, 0, 0); in bnxt_set_default_mac_addr_op()
2603 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_dev_set_mc_addr_list_op() local
2609 rc = is_bnxt_in_error(bp); in bnxt_dev_set_mc_addr_list_op()
2613 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_dev_set_mc_addr_list_op()
2635 return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL); in bnxt_dev_set_mc_addr_list_op()
2641 struct bnxt *bp = dev->data->dev_private; in bnxt_fw_version_get() local
2642 uint8_t fw_major = (bp->fw_ver >> 24) & 0xff; in bnxt_fw_version_get()
2643 uint8_t fw_minor = (bp->fw_ver >> 16) & 0xff; in bnxt_fw_version_get()
2644 uint8_t fw_updt = (bp->fw_ver >> 8) & 0xff; in bnxt_fw_version_get()
2645 uint8_t fw_rsvd = bp->fw_ver & 0xff; in bnxt_fw_version_get()
2662 struct bnxt *bp = dev->data->dev_private; in bnxt_rxq_info_get_op() local
2665 if (is_bnxt_in_error(bp)) in bnxt_rxq_info_get_op()
2684 struct bnxt *bp = dev->data->dev_private; in bnxt_txq_info_get_op() local
2687 if (is_bnxt_in_error(bp)) in bnxt_txq_info_get_op()
2766 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_mtu_set_op() local
2771 rc = is_bnxt_in_error(bp); in bnxt_mtu_set_op()
2797 bp->flags |= BNXT_FLAG_JUMBO; in bnxt_mtu_set_op()
2798 bp->eth_dev->data->dev_conf.rxmode.offloads |= in bnxt_mtu_set_op()
2801 bp->eth_dev->data->dev_conf.rxmode.offloads &= in bnxt_mtu_set_op()
2803 bp->flags &= ~BNXT_FLAG_JUMBO; in bnxt_mtu_set_op()
2810 for (i = 0; i < bp->nr_vnics; i++) { in bnxt_mtu_set_op()
2811 struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; in bnxt_mtu_set_op()
2815 rc = bnxt_hwrm_vnic_cfg(bp, vnic); in bnxt_mtu_set_op()
2819 size = rte_pktmbuf_data_room_size(bp->rx_queues[0]->mb_pool); in bnxt_mtu_set_op()
2823 rc = bnxt_hwrm_vnic_plcmode_cfg(bp, vnic); in bnxt_mtu_set_op()
2840 struct bnxt *bp = dev->data->dev_private; in bnxt_vlan_pvid_set_op() local
2841 uint16_t vlan = bp->vlan; in bnxt_vlan_pvid_set_op()
2844 rc = is_bnxt_in_error(bp); in bnxt_vlan_pvid_set_op()
2848 if (!BNXT_SINGLE_PF(bp) || BNXT_VF(bp)) { in bnxt_vlan_pvid_set_op()
2853 bp->vlan = on ? pvid : 0; in bnxt_vlan_pvid_set_op()
2855 rc = bnxt_hwrm_set_default_vlan(bp, 0, 0); in bnxt_vlan_pvid_set_op()
2857 bp->vlan = vlan; in bnxt_vlan_pvid_set_op()
2864 struct bnxt *bp = dev->data->dev_private; in bnxt_dev_led_on_op() local
2867 rc = is_bnxt_in_error(bp); in bnxt_dev_led_on_op()
2871 return bnxt_hwrm_port_led_cfg(bp, true); in bnxt_dev_led_on_op()
2877 struct bnxt *bp = dev->data->dev_private; in bnxt_dev_led_off_op() local
2880 rc = is_bnxt_in_error(bp); in bnxt_dev_led_off_op()
2884 return bnxt_hwrm_port_led_cfg(bp, false); in bnxt_dev_led_off_op()
2890 struct bnxt *bp = (struct bnxt *)dev->data->dev_private; in bnxt_rx_queue_count_op() local
2897 rc = is_bnxt_in_error(bp); in bnxt_rx_queue_count_op()
2935 rc = is_bnxt_in_error(rxq->bp); in bnxt_rx_descriptor_status_op()
2978 rc = is_bnxt_in_error(txq->bp); in bnxt_tx_descriptor_status_op()
3011 struct bnxt *bp = dev->data->dev_private; in bnxt_filter_ctrl_op() local
3014 if (!bp) in bnxt_filter_ctrl_op()
3019 bp = vfr->parent_dev->data->dev_private; in bnxt_filter_ctrl_op()
3021 if (!bp) { in bnxt_filter_ctrl_op()
3030 ret = is_bnxt_in_error(bp); in bnxt_filter_ctrl_op()
3044 if (BNXT_TRUFLOW_EN(bp)) in bnxt_filter_ctrl_op()
3082 static int bnxt_map_regs(struct bnxt *bp, uint32_t *reg_arr, int count, in bnxt_map_regs() argument
3094 rte_write32(reg_base, (uint8_t *)bp->bar0 + win_off); in bnxt_map_regs()
3098 static int bnxt_map_ptp_regs(struct bnxt *bp) in bnxt_map_ptp_regs() argument
3100 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_map_ptp_regs()
3105 rc = bnxt_map_regs(bp, reg_arr, BNXT_PTP_RX_REGS, 5); in bnxt_map_ptp_regs()
3110 rc = bnxt_map_regs(bp, reg_arr, BNXT_PTP_TX_REGS, 6); in bnxt_map_ptp_regs()
3123 static void bnxt_unmap_ptp_regs(struct bnxt *bp) in bnxt_unmap_ptp_regs() argument
3125 rte_write32(0, (uint8_t *)bp->bar0 + in bnxt_unmap_ptp_regs()
3127 rte_write32(0, (uint8_t *)bp->bar0 + in bnxt_unmap_ptp_regs()
3131 static uint64_t bnxt_cc_read(struct bnxt *bp) in bnxt_cc_read() argument
3135 ns = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_cc_read()
3137 ns |= (uint64_t)(rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_cc_read()
3142 static int bnxt_get_tx_ts(struct bnxt *bp, uint64_t *ts) in bnxt_get_tx_ts() argument
3144 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_tx_ts()
3147 fifo = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_tx_ts()
3152 fifo = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_tx_ts()
3154 *ts = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_tx_ts()
3156 *ts |= (uint64_t)rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_tx_ts()
3162 static int bnxt_get_rx_ts(struct bnxt *bp, uint64_t *ts) in bnxt_get_rx_ts() argument
3164 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_rx_ts()
3165 struct bnxt_pf_info *pf = bp->pf; in bnxt_get_rx_ts()
3172 fifo = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_rx_ts()
3178 rte_write32(1 << port_id, (uint8_t *)bp->bar0 + in bnxt_get_rx_ts()
3181 fifo = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_rx_ts()
3188 *ts = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_rx_ts()
3190 *ts |= (uint64_t)rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_get_rx_ts()
3200 struct bnxt *bp = dev->data->dev_private; in bnxt_timesync_write_time() local
3201 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_timesync_write_time()
3216 struct bnxt *bp = dev->data->dev_private; in bnxt_timesync_read_time() local
3217 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_timesync_read_time()
3224 if (BNXT_CHIP_THOR(bp)) in bnxt_timesync_read_time()
3225 rc = bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_CURRENT_TIME, in bnxt_timesync_read_time()
3228 systime_cycles = bnxt_cc_read(bp); in bnxt_timesync_read_time()
3238 struct bnxt *bp = dev->data->dev_private; in bnxt_timesync_enable() local
3239 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_timesync_enable()
3250 rc = bnxt_hwrm_ptp_cfg(bp); in bnxt_timesync_enable()
3270 if (!BNXT_CHIP_THOR(bp)) in bnxt_timesync_enable()
3271 bnxt_map_ptp_regs(bp); in bnxt_timesync_enable()
3279 struct bnxt *bp = dev->data->dev_private; in bnxt_timesync_disable() local
3280 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_timesync_disable()
3289 bnxt_hwrm_ptp_cfg(bp); in bnxt_timesync_disable()
3291 if (!BNXT_CHIP_THOR(bp)) in bnxt_timesync_disable()
3292 bnxt_unmap_ptp_regs(bp); in bnxt_timesync_disable()
3302 struct bnxt *bp = dev->data->dev_private; in bnxt_timesync_read_rx_timestamp() local
3303 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_timesync_read_rx_timestamp()
3310 if (BNXT_CHIP_THOR(bp)) in bnxt_timesync_read_rx_timestamp()
3313 bnxt_get_rx_ts(bp, &rx_tstamp_cycles); in bnxt_timesync_read_rx_timestamp()
3324 struct bnxt *bp = dev->data->dev_private; in bnxt_timesync_read_tx_timestamp() local
3325 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_timesync_read_tx_timestamp()
3333 if (BNXT_CHIP_THOR(bp)) in bnxt_timesync_read_tx_timestamp()
3334 rc = bnxt_hwrm_port_ts_query(bp, BNXT_PTP_FLAGS_PATH_TX, in bnxt_timesync_read_tx_timestamp()
3337 rc = bnxt_get_tx_ts(bp, &tx_tstamp_cycles); in bnxt_timesync_read_tx_timestamp()
3348 struct bnxt *bp = dev->data->dev_private; in bnxt_timesync_adjust_time() local
3349 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_timesync_adjust_time()
3362 struct bnxt *bp = dev->data->dev_private; in bnxt_get_eeprom_length_op() local
3367 rc = is_bnxt_in_error(bp); in bnxt_get_eeprom_length_op()
3372 bp->pdev->addr.domain, bp->pdev->addr.bus, in bnxt_get_eeprom_length_op()
3373 bp->pdev->addr.devid, bp->pdev->addr.function); in bnxt_get_eeprom_length_op()
3375 rc = bnxt_hwrm_nvm_get_dir_info(bp, &dir_entries, &entry_length); in bnxt_get_eeprom_length_op()
3386 struct bnxt *bp = dev->data->dev_private; in bnxt_get_eeprom_op() local
3391 rc = is_bnxt_in_error(bp); in bnxt_get_eeprom_op()
3396 bp->pdev->addr.domain, bp->pdev->addr.bus, in bnxt_get_eeprom_op()
3397 bp->pdev->addr.devid, bp->pdev->addr.function, in bnxt_get_eeprom_op()
3401 return bnxt_get_nvram_directory(bp, in_eeprom->length, in bnxt_get_eeprom_op()
3408 return bnxt_hwrm_get_nvram_item(bp, index - 1, offset, in bnxt_get_eeprom_op()
3462 struct bnxt *bp = dev->data->dev_private; in bnxt_set_eeprom_op() local
3467 rc = is_bnxt_in_error(bp); in bnxt_set_eeprom_op()
3472 bp->pdev->addr.domain, bp->pdev->addr.bus, in bnxt_set_eeprom_op()
3473 bp->pdev->addr.devid, bp->pdev->addr.function, in bnxt_set_eeprom_op()
3476 if (!BNXT_PF(bp)) { in bnxt_set_eeprom_op()
3492 return bnxt_hwrm_erase_nvram_directory(bp, index - 1); in bnxt_set_eeprom_op()
3505 return bnxt_hwrm_flash_nvram(bp, type, ordinal, ext, attr, in bnxt_set_eeprom_op()
3579 static uint32_t bnxt_map_reset_regs(struct bnxt *bp, uint32_t reg) in bnxt_map_reset_regs() argument
3584 rte_write32(reg & 0xfffff000, (uint8_t *)bp->bar0 + in bnxt_map_reset_regs()
3592 int bnxt_map_fw_health_status_regs(struct bnxt *bp) in bnxt_map_fw_health_status_regs() argument
3594 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_map_fw_health_status_regs()
3620 rte_write32(reg_base, (uint8_t *)bp->bar0 + in bnxt_map_fw_health_status_regs()
3626 static void bnxt_write_fw_reset_reg(struct bnxt *bp, uint32_t index) in bnxt_write_fw_reset_reg() argument
3628 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_write_fw_reset_reg()
3639 rte_pci_write_config(bp->pdev, &val, sizeof(val), offset); in bnxt_write_fw_reset_reg()
3642 offset = bnxt_map_reset_regs(bp, offset); in bnxt_write_fw_reset_reg()
3643 rte_write32(val, (uint8_t *)bp->bar0 + offset); in bnxt_write_fw_reset_reg()
3646 rte_write32(val, (uint8_t *)bp->bar0 + offset); in bnxt_write_fw_reset_reg()
3654 static void bnxt_dev_cleanup(struct bnxt *bp) in bnxt_dev_cleanup() argument
3656 bp->eth_dev->data->dev_link.link_status = 0; in bnxt_dev_cleanup()
3657 bp->link_info->link_up = 0; in bnxt_dev_cleanup()
3658 if (bp->eth_dev->data->dev_started) in bnxt_dev_cleanup()
3659 bnxt_dev_stop_op(bp->eth_dev); in bnxt_dev_cleanup()
3661 bnxt_uninit_resources(bp, true); in bnxt_dev_cleanup()
3664 static int bnxt_restore_vlan_filters(struct bnxt *bp) in bnxt_restore_vlan_filters() argument
3666 struct rte_eth_dev *dev = bp->eth_dev; in bnxt_restore_vlan_filters()
3678 rc = bnxt_add_vlan_filter(bp, vlan_id); in bnxt_restore_vlan_filters()
3687 static int bnxt_restore_mac_filters(struct bnxt *bp) in bnxt_restore_mac_filters() argument
3689 struct rte_eth_dev *dev = bp->eth_dev; in bnxt_restore_mac_filters()
3697 if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp)) in bnxt_restore_mac_filters()
3729 static int bnxt_restore_filters(struct bnxt *bp) in bnxt_restore_filters() argument
3731 struct rte_eth_dev *dev = bp->eth_dev; in bnxt_restore_filters()
3745 ret = bnxt_restore_mac_filters(bp); in bnxt_restore_filters()
3749 ret = bnxt_restore_vlan_filters(bp); in bnxt_restore_filters()
3756 struct bnxt *bp = arg; in bnxt_dev_recover() local
3757 int timeout = bp->fw_reset_max_msecs; in bnxt_dev_recover()
3761 bp->flags &= ~BNXT_FLAG_FATAL_ERROR; in bnxt_dev_recover()
3764 rc = bnxt_hwrm_ver_get(bp, SHORT_HWRM_CMD_TIMEOUT); in bnxt_dev_recover()
3776 rc = bnxt_init_resources(bp, true); in bnxt_dev_recover()
3783 bp->flags &= ~BNXT_FLAG_FW_RESET; in bnxt_dev_recover()
3785 rc = bnxt_dev_start_op(bp->eth_dev); in bnxt_dev_recover()
3791 rc = bnxt_restore_filters(bp); in bnxt_dev_recover()
3798 bnxt_dev_stop_op(bp->eth_dev); in bnxt_dev_recover()
3800 bp->flags |= BNXT_FLAG_FATAL_ERROR; in bnxt_dev_recover()
3801 bnxt_uninit_resources(bp, false); in bnxt_dev_recover()
3807 struct bnxt *bp = arg; in bnxt_dev_reset_and_resume() local
3810 bnxt_dev_cleanup(bp); in bnxt_dev_reset_and_resume()
3812 bnxt_wait_for_device_shutdown(bp); in bnxt_dev_reset_and_resume()
3814 rc = rte_eal_alarm_set(US_PER_MS * bp->fw_reset_min_msecs, in bnxt_dev_reset_and_resume()
3815 bnxt_dev_recover, (void *)bp); in bnxt_dev_reset_and_resume()
3820 uint32_t bnxt_read_fw_status_reg(struct bnxt *bp, uint32_t index) in bnxt_read_fw_status_reg() argument
3822 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_read_fw_status_reg()
3831 rte_pci_read_config(bp->pdev, &val, sizeof(val), offset); in bnxt_read_fw_status_reg()
3837 val = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_read_fw_status_reg()
3845 static int bnxt_fw_reset_all(struct bnxt *bp) in bnxt_fw_reset_all() argument
3847 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_fw_reset_all()
3854 bnxt_write_fw_reset_reg(bp, i); in bnxt_fw_reset_all()
3859 rc = bnxt_hwrm_fw_reset(bp); in bnxt_fw_reset_all()
3869 struct bnxt *bp = arg; in bnxt_fw_reset_cb() local
3870 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_fw_reset_cb()
3874 if (bnxt_is_master_func(bp) && in bnxt_fw_reset_cb()
3875 bnxt_is_recovery_enabled(bp)) { in bnxt_fw_reset_cb()
3876 rc = bnxt_fw_reset_all(bp); in bnxt_fw_reset_cb()
3889 bp->fw_reset_min_msecs = BNXT_MIN_FW_READY_TIMEOUT; in bnxt_fw_reset_cb()
3890 bp->fw_reset_max_msecs = BNXT_MAX_FW_RESET_TIMEOUT; in bnxt_fw_reset_cb()
3894 (void *)bp); in bnxt_fw_reset_cb()
3908 struct bnxt *bp = arg; in bnxt_check_fw_health() local
3909 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_check_fw_health()
3912 if (!info || !bnxt_is_recovery_enabled(bp) || in bnxt_check_fw_health()
3913 is_bnxt_in_error(bp)) in bnxt_check_fw_health()
3916 val = bnxt_read_fw_status_reg(bp, BNXT_FW_HEARTBEAT_CNT_REG); in bnxt_check_fw_health()
3922 val = bnxt_read_fw_status_reg(bp, BNXT_FW_RECOVERY_CNT_REG); in bnxt_check_fw_health()
3929 bnxt_check_fw_health, (void *)bp); in bnxt_check_fw_health()
3934 bp->flags |= BNXT_FLAG_FATAL_ERROR; in bnxt_check_fw_health()
3935 bp->flags |= BNXT_FLAG_FW_RESET; in bnxt_check_fw_health()
3939 if (bnxt_is_master_func(bp)) in bnxt_check_fw_health()
3945 bnxt_fw_reset_cb, (void *)bp); in bnxt_check_fw_health()
3948 void bnxt_schedule_fw_health_check(struct bnxt *bp) in bnxt_schedule_fw_health_check() argument
3952 pthread_mutex_lock(&bp->health_check_lock); in bnxt_schedule_fw_health_check()
3954 if (!bnxt_is_recovery_enabled(bp)) in bnxt_schedule_fw_health_check()
3957 if (bp->flags & BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED) in bnxt_schedule_fw_health_check()
3960 polling_freq = bp->recovery_info->driver_polling_freq; in bnxt_schedule_fw_health_check()
3963 bnxt_check_fw_health, (void *)bp); in bnxt_schedule_fw_health_check()
3964 bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED; in bnxt_schedule_fw_health_check()
3967 pthread_mutex_unlock(&bp->health_check_lock); in bnxt_schedule_fw_health_check()
3970 static void bnxt_cancel_fw_health_check(struct bnxt *bp) in bnxt_cancel_fw_health_check() argument
3972 if (!bnxt_is_recovery_enabled(bp)) in bnxt_cancel_fw_health_check()
3975 rte_eal_alarm_cancel(bnxt_check_fw_health, (void *)bp); in bnxt_cancel_fw_health_check()
3976 bp->flags &= ~BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED; in bnxt_cancel_fw_health_check()
4020 bool bnxt_stratus_device(struct bnxt *bp) in bnxt_stratus_device() argument
4022 uint16_t device_id = bp->pdev->id.device_id; in bnxt_stratus_device()
4038 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_init_board() local
4041 bp->bar0 = (void *)pci_dev->mem_resource[0].addr; in bnxt_init_board()
4042 bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr; in bnxt_init_board()
4043 if (!bp->bar0 || !bp->doorbell_base) { in bnxt_init_board()
4048 bp->eth_dev = eth_dev; in bnxt_init_board()
4049 bp->pdev = pci_dev; in bnxt_init_board()
4054 static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, in bnxt_alloc_ctx_mem_blk() argument
4083 suffix, idx, bp->eth_dev->data->port_id); in bnxt_alloc_ctx_mem_blk()
4107 suffix, idx, bp->eth_dev->data->port_id); in bnxt_alloc_ctx_mem_blk()
4148 static void bnxt_free_ctx_mem(struct bnxt *bp) in bnxt_free_ctx_mem() argument
4152 if (!bp->ctx || !(bp->ctx->flags & BNXT_CTX_FLAG_INITED)) in bnxt_free_ctx_mem()
4155 bp->ctx->flags &= ~BNXT_CTX_FLAG_INITED; in bnxt_free_ctx_mem()
4156 rte_memzone_free(bp->ctx->qp_mem.ring_mem.mz); in bnxt_free_ctx_mem()
4157 rte_memzone_free(bp->ctx->srq_mem.ring_mem.mz); in bnxt_free_ctx_mem()
4158 rte_memzone_free(bp->ctx->cq_mem.ring_mem.mz); in bnxt_free_ctx_mem()
4159 rte_memzone_free(bp->ctx->vnic_mem.ring_mem.mz); in bnxt_free_ctx_mem()
4160 rte_memzone_free(bp->ctx->stat_mem.ring_mem.mz); in bnxt_free_ctx_mem()
4161 rte_memzone_free(bp->ctx->qp_mem.ring_mem.pg_tbl_mz); in bnxt_free_ctx_mem()
4162 rte_memzone_free(bp->ctx->srq_mem.ring_mem.pg_tbl_mz); in bnxt_free_ctx_mem()
4163 rte_memzone_free(bp->ctx->cq_mem.ring_mem.pg_tbl_mz); in bnxt_free_ctx_mem()
4164 rte_memzone_free(bp->ctx->vnic_mem.ring_mem.pg_tbl_mz); in bnxt_free_ctx_mem()
4165 rte_memzone_free(bp->ctx->stat_mem.ring_mem.pg_tbl_mz); in bnxt_free_ctx_mem()
4167 for (i = 0; i < bp->ctx->tqm_fp_rings_count + 1; i++) { in bnxt_free_ctx_mem()
4168 if (bp->ctx->tqm_mem[i]) in bnxt_free_ctx_mem()
4169 rte_memzone_free(bp->ctx->tqm_mem[i]->ring_mem.mz); in bnxt_free_ctx_mem()
4172 rte_free(bp->ctx); in bnxt_free_ctx_mem()
4173 bp->ctx = NULL; in bnxt_free_ctx_mem()
4190 int bnxt_alloc_ctx_mem(struct bnxt *bp) in bnxt_alloc_ctx_mem() argument
4198 rc = bnxt_hwrm_func_backing_store_qcaps(bp); in bnxt_alloc_ctx_mem()
4203 ctx = bp->ctx; in bnxt_alloc_ctx_mem()
4210 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg, mem_size, "qp_mem", 0); in bnxt_alloc_ctx_mem()
4217 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg, mem_size, "srq_mem", 0); in bnxt_alloc_ctx_mem()
4224 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg, mem_size, "cq_mem", 0); in bnxt_alloc_ctx_mem()
4232 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg, mem_size, "vnic_mem", 0); in bnxt_alloc_ctx_mem()
4239 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg, mem_size, "stat_mem", 0); in bnxt_alloc_ctx_mem()
4258 rc = bnxt_alloc_ctx_mem_blk(bp, ctx_pg, mem_size, "tqm_mem", i); in bnxt_alloc_ctx_mem()
4265 rc = bnxt_hwrm_func_backing_store_cfg(bp, ena); in bnxt_alloc_ctx_mem()
4275 static int bnxt_alloc_stats_mem(struct bnxt *bp) in bnxt_alloc_stats_mem() argument
4277 struct rte_pci_device *pci_dev = bp->pdev; in bnxt_alloc_stats_mem()
4307 bp->rx_mem_zone = (const void *)mz; in bnxt_alloc_stats_mem()
4308 bp->hw_rx_port_stats = mz->addr; in bnxt_alloc_stats_mem()
4309 bp->hw_rx_port_stats_map = mz_phys_addr; in bnxt_alloc_stats_mem()
4333 bp->tx_mem_zone = (const void *)mz; in bnxt_alloc_stats_mem()
4334 bp->hw_tx_port_stats = mz->addr; in bnxt_alloc_stats_mem()
4335 bp->hw_tx_port_stats_map = mz_phys_addr; in bnxt_alloc_stats_mem()
4336 bp->flags |= BNXT_FLAG_PORT_STATS; in bnxt_alloc_stats_mem()
4339 if (bp->hwrm_spec_code < HWRM_SPEC_CODE_1_8_4 || in bnxt_alloc_stats_mem()
4340 bp->hwrm_spec_code == HWRM_SPEC_CODE_1_9_0 || in bnxt_alloc_stats_mem()
4341 !(bp->flags & BNXT_FLAG_EXT_STATS_SUPPORTED)) in bnxt_alloc_stats_mem()
4344 bp->hw_rx_port_stats_ext = (void *) in bnxt_alloc_stats_mem()
4345 ((uint8_t *)bp->hw_rx_port_stats + in bnxt_alloc_stats_mem()
4347 bp->hw_rx_port_stats_ext_map = bp->hw_rx_port_stats_map + in bnxt_alloc_stats_mem()
4349 bp->flags |= BNXT_FLAG_EXT_RX_PORT_STATS; in bnxt_alloc_stats_mem()
4351 if (bp->hwrm_spec_code < HWRM_SPEC_CODE_1_9_2 || in bnxt_alloc_stats_mem()
4352 bp->flags & BNXT_FLAG_EXT_STATS_SUPPORTED) { in bnxt_alloc_stats_mem()
4353 bp->hw_tx_port_stats_ext = (void *) in bnxt_alloc_stats_mem()
4354 ((uint8_t *)bp->hw_tx_port_stats + in bnxt_alloc_stats_mem()
4356 bp->hw_tx_port_stats_ext_map = in bnxt_alloc_stats_mem()
4357 bp->hw_tx_port_stats_map + in bnxt_alloc_stats_mem()
4359 bp->flags |= BNXT_FLAG_EXT_TX_PORT_STATS; in bnxt_alloc_stats_mem()
4367 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_setup_mac_addr() local
4372 bp->max_l2_ctx, in bnxt_setup_mac_addr()
4379 if (!BNXT_HAS_DFLT_MAC_SET(bp)) { in bnxt_setup_mac_addr()
4380 if (BNXT_PF(bp)) in bnxt_setup_mac_addr()
4385 bnxt_eth_hw_addr_random(bp->mac_addr); in bnxt_setup_mac_addr()
4388 bp->mac_addr[0], bp->mac_addr[1], bp->mac_addr[2], in bnxt_setup_mac_addr()
4389 bp->mac_addr[3], bp->mac_addr[4], bp->mac_addr[5]); in bnxt_setup_mac_addr()
4391 rc = bnxt_hwrm_set_mac(bp); in bnxt_setup_mac_addr()
4397 memcpy(ð_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN); in bnxt_setup_mac_addr()
4402 static int bnxt_restore_dflt_mac(struct bnxt *bp) in bnxt_restore_dflt_mac() argument
4407 if (BNXT_HAS_DFLT_MAC_SET(bp)) in bnxt_restore_dflt_mac()
4411 rc = bnxt_hwrm_set_mac(bp); in bnxt_restore_dflt_mac()
4418 static void bnxt_config_vf_req_fwd(struct bnxt *bp) in bnxt_config_vf_req_fwd() argument
4420 if (!BNXT_PF(bp)) in bnxt_config_vf_req_fwd()
4423 memset(bp->pf->vf_req_fwd, 0, sizeof(bp->pf->vf_req_fwd)); in bnxt_config_vf_req_fwd()
4425 if (!(bp->fw_cap & BNXT_FW_CAP_LINK_ADMIN)) in bnxt_config_vf_req_fwd()
4438 struct bnxt *bp; in bnxt_get_svif() local
4452 bp = eth_dev->data->dev_private; in bnxt_get_svif()
4454 return func_svif ? bp->func_svif : bp->port_svif; in bnxt_get_svif()
4462 struct bnxt *bp; in bnxt_get_vnic_id() local
4476 bp = eth_dev->data->dev_private; in bnxt_get_vnic_id()
4478 vnic = BNXT_GET_DEFAULT_VNIC(bp); in bnxt_get_vnic_id()
4487 struct bnxt *bp; in bnxt_get_fw_func_id() local
4501 bp = eth_dev->data->dev_private; in bnxt_get_fw_func_id()
4503 return bp->fw_fid; in bnxt_get_fw_func_id()
4510 struct bnxt *bp; in bnxt_get_interface_type() local
4516 bp = eth_dev->data->dev_private; in bnxt_get_interface_type()
4517 if (BNXT_PF(bp)) in bnxt_get_interface_type()
4519 else if (BNXT_VF_IS_TRUSTED(bp)) in bnxt_get_interface_type()
4521 else if (BNXT_VF(bp)) in bnxt_get_interface_type()
4532 struct bnxt *bp; in bnxt_get_phy_port_id() local
4543 bp = eth_dev->data->dev_private; in bnxt_get_phy_port_id()
4545 return BNXT_PF(bp) ? bp->pf->port_id : bp->parent->port_id; in bnxt_get_phy_port_id()
4552 struct bnxt *bp; in bnxt_get_parif() local
4566 bp = eth_dev->data->dev_private; in bnxt_get_parif()
4568 return BNXT_PF(bp) ? bp->fw_fid - 1 : bp->parent->fid - 1; in bnxt_get_parif()
4577 static void bnxt_alloc_error_recovery_info(struct bnxt *bp) in bnxt_alloc_error_recovery_info() argument
4579 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_alloc_error_recovery_info()
4582 if (!(bp->fw_cap & BNXT_FW_CAP_HCOMM_FW_STATUS)) in bnxt_alloc_error_recovery_info()
4587 if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY)) in bnxt_alloc_error_recovery_info()
4593 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_alloc_error_recovery_info()
4595 bp->recovery_info = info; in bnxt_alloc_error_recovery_info()
4598 static void bnxt_check_fw_status(struct bnxt *bp) in bnxt_check_fw_status() argument
4602 if (!(bp->recovery_info && in bnxt_check_fw_status()
4603 (bp->fw_cap & BNXT_FW_CAP_HCOMM_FW_STATUS))) in bnxt_check_fw_status()
4606 fw_status = bnxt_read_fw_status_reg(bp, BNXT_FW_STATUS_REG); in bnxt_check_fw_status()
4612 static int bnxt_map_hcomm_fw_status_reg(struct bnxt *bp) in bnxt_map_hcomm_fw_status_reg() argument
4614 struct bnxt_error_recovery_info *info = bp->recovery_info; in bnxt_map_hcomm_fw_status_reg()
4618 rte_write32(HCOMM_STATUS_STRUCT_LOC, (uint8_t *)bp->bar0 + in bnxt_map_hcomm_fw_status_reg()
4620 sig_ver = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_map_hcomm_fw_status_reg()
4634 bp->recovery_info = info; in bnxt_map_hcomm_fw_status_reg()
4639 status_loc = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 + in bnxt_map_hcomm_fw_status_reg()
4652 rte_write32((status_loc & BNXT_GRCP_BASE_MASK), (uint8_t *)bp->bar0 + in bnxt_map_hcomm_fw_status_reg()
4655 bp->fw_cap |= BNXT_FW_CAP_HCOMM_FW_STATUS; in bnxt_map_hcomm_fw_status_reg()
4660 static int bnxt_init_fw(struct bnxt *bp) in bnxt_init_fw() argument
4665 bp->fw_cap = 0; in bnxt_init_fw()
4667 rc = bnxt_map_hcomm_fw_status_reg(bp); in bnxt_init_fw()
4671 rc = bnxt_hwrm_ver_get(bp, DFLT_HWRM_CMD_TIMEOUT); in bnxt_init_fw()
4673 bnxt_check_fw_status(bp); in bnxt_init_fw()
4677 rc = bnxt_hwrm_func_reset(bp); in bnxt_init_fw()
4681 rc = bnxt_hwrm_vnic_qcaps(bp); in bnxt_init_fw()
4685 rc = bnxt_hwrm_queue_qportcfg(bp); in bnxt_init_fw()
4693 rc = bnxt_hwrm_func_qcaps(bp); in bnxt_init_fw()
4697 rc = bnxt_hwrm_func_qcfg(bp, &mtu); in bnxt_init_fw()
4701 bnxt_hwrm_port_mac_qcfg(bp); in bnxt_init_fw()
4703 bnxt_hwrm_parent_pf_qcfg(bp); in bnxt_init_fw()
4705 bnxt_hwrm_port_phy_qcaps(bp); in bnxt_init_fw()
4707 bnxt_alloc_error_recovery_info(bp); in bnxt_init_fw()
4709 rc = bnxt_hwrm_error_recovery_qcfg(bp); in bnxt_init_fw()
4711 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_init_fw()
4713 bnxt_hwrm_port_led_qcaps(bp); in bnxt_init_fw()
4719 bnxt_init_locks(struct bnxt *bp) in bnxt_init_locks() argument
4723 err = pthread_mutex_init(&bp->flow_lock, NULL); in bnxt_init_locks()
4729 err = pthread_mutex_init(&bp->def_cp_lock, NULL); in bnxt_init_locks()
4733 err = pthread_mutex_init(&bp->health_check_lock, NULL); in bnxt_init_locks()
4739 static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) in bnxt_init_resources() argument
4743 rc = bnxt_init_fw(bp); in bnxt_init_resources()
4748 rc = bnxt_setup_mac_addr(bp->eth_dev); in bnxt_init_resources()
4752 rc = bnxt_restore_dflt_mac(bp); in bnxt_init_resources()
4757 bnxt_config_vf_req_fwd(bp); in bnxt_init_resources()
4759 rc = bnxt_hwrm_func_driver_register(bp); in bnxt_init_resources()
4765 if (BNXT_PF(bp)) { in bnxt_init_resources()
4766 if (bp->pdev->max_vfs) { in bnxt_init_resources()
4767 rc = bnxt_hwrm_allocate_vfs(bp, bp->pdev->max_vfs); in bnxt_init_resources()
4773 rc = bnxt_hwrm_allocate_pf_only(bp); in bnxt_init_resources()
4782 rc = bnxt_alloc_mem(bp, reconfig_dev); in bnxt_init_resources()
4786 rc = bnxt_setup_int(bp); in bnxt_init_resources()
4790 rc = bnxt_request_int(bp); in bnxt_init_resources()
4794 rc = bnxt_init_ctx_mem(bp); in bnxt_init_resources()
4800 rc = bnxt_init_locks(bp); in bnxt_init_resources()
4811 struct bnxt *bp = opaque_arg; in bnxt_parse_devarg_truflow() local
4836 bp->flags |= BNXT_FLAG_TRUFLOW_EN; in bnxt_parse_devarg_truflow()
4839 bp->flags &= ~BNXT_FLAG_TRUFLOW_EN; in bnxt_parse_devarg_truflow()
4850 struct bnxt *bp = opaque_arg; in bnxt_parse_devarg_flow_xstat() local
4874 bp->flags |= BNXT_FLAG_FLOW_XSTATS_EN; in bnxt_parse_devarg_flow_xstat()
4875 if (BNXT_FLOW_XSTATS_EN(bp)) in bnxt_parse_devarg_flow_xstat()
4885 struct bnxt *bp = opaque_arg; in bnxt_parse_devarg_max_num_kflows() local
4909 bp->max_num_kflows = max_num_kflows; in bnxt_parse_devarg_max_num_kflows()
4910 if (bp->max_num_kflows) in bnxt_parse_devarg_max_num_kflows()
5141 bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs) in bnxt_parse_dev_args() argument
5157 bnxt_parse_devarg_truflow, bp); in bnxt_parse_dev_args()
5164 bnxt_parse_devarg_flow_xstat, bp); in bnxt_parse_dev_args()
5171 bnxt_parse_devarg_max_num_kflows, bp); in bnxt_parse_dev_args()
5176 static int bnxt_alloc_switch_domain(struct bnxt *bp) in bnxt_alloc_switch_domain() argument
5180 if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) { in bnxt_alloc_switch_domain()
5181 rc = rte_eth_switch_domain_alloc(&bp->switch_domain_id); in bnxt_alloc_switch_domain()
5188 bp->switch_domain_id); in bnxt_alloc_switch_domain()
5199 struct bnxt *bp; in bnxt_dev_init() local
5222 bp = eth_dev->data->dev_private; in bnxt_dev_init()
5225 bnxt_parse_dev_args(bp, pci_dev->device.devargs); in bnxt_dev_init()
5227 bp->flags &= ~BNXT_FLAG_RX_VECTOR_PKT_MODE; in bnxt_dev_init()
5230 bp->flags |= BNXT_FLAG_VF; in bnxt_dev_init()
5233 bp->flags |= BNXT_FLAG_THOR_CHIP; in bnxt_dev_init()
5239 bp->flags |= BNXT_FLAG_STINGRAY; in bnxt_dev_init()
5241 if (BNXT_TRUFLOW_EN(bp)) { in bnxt_dev_init()
5264 rc = bnxt_alloc_pf_info(bp); in bnxt_dev_init()
5268 rc = bnxt_alloc_link_info(bp); in bnxt_dev_init()
5272 rc = bnxt_alloc_parent_info(bp); in bnxt_dev_init()
5276 rc = bnxt_alloc_hwrm_resources(bp); in bnxt_dev_init()
5282 rc = bnxt_alloc_leds_info(bp); in bnxt_dev_init()
5286 rc = bnxt_alloc_cos_queues(bp); in bnxt_dev_init()
5290 rc = bnxt_init_resources(bp, false); in bnxt_dev_init()
5294 rc = bnxt_alloc_stats_mem(bp); in bnxt_dev_init()
5298 bnxt_alloc_switch_domain(bp); in bnxt_dev_init()
5326 static void bnxt_unregister_fc_ctx_mem(struct bnxt *bp) in bnxt_unregister_fc_ctx_mem() argument
5328 bnxt_hwrm_cfa_counter_cfg(bp, BNXT_DIR_RX, in bnxt_unregister_fc_ctx_mem()
5330 bp->flow_stat->rx_fc_out_tbl.ctx_id, in bnxt_unregister_fc_ctx_mem()
5331 bp->flow_stat->max_fc, in bnxt_unregister_fc_ctx_mem()
5334 bnxt_hwrm_cfa_counter_cfg(bp, BNXT_DIR_TX, in bnxt_unregister_fc_ctx_mem()
5336 bp->flow_stat->tx_fc_out_tbl.ctx_id, in bnxt_unregister_fc_ctx_mem()
5337 bp->flow_stat->max_fc, in bnxt_unregister_fc_ctx_mem()
5340 if (bp->flow_stat->rx_fc_in_tbl.ctx_id != BNXT_CTX_VAL_INVAL) in bnxt_unregister_fc_ctx_mem()
5341 bnxt_hwrm_ctx_unrgtr(bp, bp->flow_stat->rx_fc_in_tbl.ctx_id); in bnxt_unregister_fc_ctx_mem()
5342 bp->flow_stat->rx_fc_in_tbl.ctx_id = BNXT_CTX_VAL_INVAL; in bnxt_unregister_fc_ctx_mem()
5344 if (bp->flow_stat->rx_fc_out_tbl.ctx_id != BNXT_CTX_VAL_INVAL) in bnxt_unregister_fc_ctx_mem()
5345 bnxt_hwrm_ctx_unrgtr(bp, bp->flow_stat->rx_fc_out_tbl.ctx_id); in bnxt_unregister_fc_ctx_mem()
5346 bp->flow_stat->rx_fc_out_tbl.ctx_id = BNXT_CTX_VAL_INVAL; in bnxt_unregister_fc_ctx_mem()
5348 if (bp->flow_stat->tx_fc_in_tbl.ctx_id != BNXT_CTX_VAL_INVAL) in bnxt_unregister_fc_ctx_mem()
5349 bnxt_hwrm_ctx_unrgtr(bp, bp->flow_stat->tx_fc_in_tbl.ctx_id); in bnxt_unregister_fc_ctx_mem()
5350 bp->flow_stat->tx_fc_in_tbl.ctx_id = BNXT_CTX_VAL_INVAL; in bnxt_unregister_fc_ctx_mem()
5352 if (bp->flow_stat->tx_fc_out_tbl.ctx_id != BNXT_CTX_VAL_INVAL) in bnxt_unregister_fc_ctx_mem()
5353 bnxt_hwrm_ctx_unrgtr(bp, bp->flow_stat->tx_fc_out_tbl.ctx_id); in bnxt_unregister_fc_ctx_mem()
5354 bp->flow_stat->tx_fc_out_tbl.ctx_id = BNXT_CTX_VAL_INVAL; in bnxt_unregister_fc_ctx_mem()
5357 static void bnxt_uninit_fc_ctx_mem(struct bnxt *bp) in bnxt_uninit_fc_ctx_mem() argument
5359 bnxt_unregister_fc_ctx_mem(bp); in bnxt_uninit_fc_ctx_mem()
5361 bnxt_free_ctx_mem_buf(&bp->flow_stat->rx_fc_in_tbl); in bnxt_uninit_fc_ctx_mem()
5362 bnxt_free_ctx_mem_buf(&bp->flow_stat->rx_fc_out_tbl); in bnxt_uninit_fc_ctx_mem()
5363 bnxt_free_ctx_mem_buf(&bp->flow_stat->tx_fc_in_tbl); in bnxt_uninit_fc_ctx_mem()
5364 bnxt_free_ctx_mem_buf(&bp->flow_stat->tx_fc_out_tbl); in bnxt_uninit_fc_ctx_mem()
5367 static void bnxt_uninit_ctx_mem(struct bnxt *bp) in bnxt_uninit_ctx_mem() argument
5369 if (BNXT_FLOW_XSTATS_EN(bp)) in bnxt_uninit_ctx_mem()
5370 bnxt_uninit_fc_ctx_mem(bp); in bnxt_uninit_ctx_mem()
5374 bnxt_free_error_recovery_info(struct bnxt *bp) in bnxt_free_error_recovery_info() argument
5376 rte_free(bp->recovery_info); in bnxt_free_error_recovery_info()
5377 bp->recovery_info = NULL; in bnxt_free_error_recovery_info()
5378 bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY; in bnxt_free_error_recovery_info()
5382 bnxt_uninit_locks(struct bnxt *bp) in bnxt_uninit_locks() argument
5384 pthread_mutex_destroy(&bp->flow_lock); in bnxt_uninit_locks()
5385 pthread_mutex_destroy(&bp->def_cp_lock); in bnxt_uninit_locks()
5386 pthread_mutex_destroy(&bp->health_check_lock); in bnxt_uninit_locks()
5387 if (bp->rep_info) { in bnxt_uninit_locks()
5388 pthread_mutex_destroy(&bp->rep_info->vfr_lock); in bnxt_uninit_locks()
5389 pthread_mutex_destroy(&bp->rep_info->vfr_start_lock); in bnxt_uninit_locks()
5394 bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) in bnxt_uninit_resources() argument
5398 bnxt_free_int(bp); in bnxt_uninit_resources()
5399 bnxt_free_mem(bp, reconfig_dev); in bnxt_uninit_resources()
5401 bnxt_hwrm_func_buf_unrgtr(bp); in bnxt_uninit_resources()
5402 rte_free(bp->pf->vf_req_buf); in bnxt_uninit_resources()
5404 rc = bnxt_hwrm_func_driver_unregister(bp, 0); in bnxt_uninit_resources()
5405 bp->flags &= ~BNXT_FLAG_REGISTERED; in bnxt_uninit_resources()
5406 bnxt_free_ctx_mem(bp); in bnxt_uninit_resources()
5408 bnxt_free_hwrm_resources(bp); in bnxt_uninit_resources()
5409 bnxt_free_error_recovery_info(bp); in bnxt_uninit_resources()
5412 bnxt_uninit_ctx_mem(bp); in bnxt_uninit_resources()
5414 bnxt_uninit_locks(bp); in bnxt_uninit_resources()
5415 bnxt_free_flow_stats_info(bp); in bnxt_uninit_resources()
5416 bnxt_free_rep_info(bp); in bnxt_uninit_resources()
5417 rte_free(bp->ptp_cfg); in bnxt_uninit_resources()
5418 bp->ptp_cfg = NULL; in bnxt_uninit_resources()
5438 struct bnxt *bp = eth_dev->data->dev_private; in bnxt_pci_remove_dev_with_reps() local
5442 if (!bp) in bnxt_pci_remove_dev_with_reps()
5445 for (i = 0; i < bp->num_reps; i++) { in bnxt_pci_remove_dev_with_reps()
5446 vf_rep_eth_dev = bp->rep_info[i].vfr_eth_dev; in bnxt_pci_remove_dev_with_reps()
5460 static void bnxt_free_rep_info(struct bnxt *bp) in bnxt_free_rep_info() argument
5462 rte_free(bp->rep_info); in bnxt_free_rep_info()
5463 bp->rep_info = NULL; in bnxt_free_rep_info()
5464 rte_free(bp->cfa_code_map); in bnxt_free_rep_info()
5465 bp->cfa_code_map = NULL; in bnxt_free_rep_info()
5468 static int bnxt_init_rep_info(struct bnxt *bp) in bnxt_init_rep_info() argument
5472 if (bp->rep_info) in bnxt_init_rep_info()
5475 bp->rep_info = rte_zmalloc("bnxt_rep_info", in bnxt_init_rep_info()
5476 sizeof(bp->rep_info[0]) * BNXT_MAX_VF_REPS, in bnxt_init_rep_info()
5478 if (!bp->rep_info) { in bnxt_init_rep_info()
5482 bp->cfa_code_map = rte_zmalloc("bnxt_cfa_code_map", in bnxt_init_rep_info()
5483 sizeof(*bp->cfa_code_map) * in bnxt_init_rep_info()
5485 if (!bp->cfa_code_map) { in bnxt_init_rep_info()
5487 bnxt_free_rep_info(bp); in bnxt_init_rep_info()
5492 bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID; in bnxt_init_rep_info()
5494 rc = pthread_mutex_init(&bp->rep_info->vfr_lock, NULL); in bnxt_init_rep_info()
5497 bnxt_free_rep_info(bp); in bnxt_init_rep_info()
5501 rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL); in bnxt_init_rep_info()
5504 bnxt_free_rep_info(bp); in bnxt_init_rep_info()