Lines Matching +full:num +full:- +full:macs
3 * Copyright 2009-2013 Broadcom Corporation
10 * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL").
82 /* acking a VF sb through the PF - use the GRC */ in bnx2x_vf_igu_ack_sb()
86 u32 func_encode = vf->abs_vfid; in bnx2x_vf_igu_ack_sb()
132 "VF[%d] Q_SETUP: txq[%d]-- vfsb=%d, sb-index=%d, hc-rate=%d, flags=0x%lx, traffic-type=%d", in bnx2x_vfop_qctor_dump_tx()
133 vf->abs_vfid, in bnx2x_vfop_qctor_dump_tx()
136 init_params->tx.sb_cq_index, in bnx2x_vfop_qctor_dump_tx()
137 init_params->tx.hc_rate, in bnx2x_vfop_qctor_dump_tx()
138 setup_params->flags, in bnx2x_vfop_qctor_dump_tx()
139 setup_params->txq_params.traffic_type); in bnx2x_vfop_qctor_dump_tx()
147 struct bnx2x_rxq_setup_params *rxq_params = &setup_params->rxq_params; in bnx2x_vfop_qctor_dump_rx()
149 …DP(BNX2X_MSG_IOV, "VF[%d] Q_SETUP: rxq[%d]-- vfsb=%d, sb-index=%d, hc-rate=%d, mtu=%d, buf-size=%d… in bnx2x_vfop_qctor_dump_rx()
150 "sge-size=%d, max_sge_pkt=%d, tpa-agg-size=%d, flags=0x%lx, drop-flags=0x%x, cache-log=%d\n", in bnx2x_vfop_qctor_dump_rx()
151 vf->abs_vfid, in bnx2x_vfop_qctor_dump_rx()
154 init_params->rx.sb_cq_index, in bnx2x_vfop_qctor_dump_rx()
155 init_params->rx.hc_rate, in bnx2x_vfop_qctor_dump_rx()
156 setup_params->gen_params.mtu, in bnx2x_vfop_qctor_dump_rx()
157 rxq_params->buf_sz, in bnx2x_vfop_qctor_dump_rx()
158 rxq_params->sge_buf_sz, in bnx2x_vfop_qctor_dump_rx()
159 rxq_params->max_sges_pkt, in bnx2x_vfop_qctor_dump_rx()
160 rxq_params->tpa_agg_sz, in bnx2x_vfop_qctor_dump_rx()
161 setup_params->flags, in bnx2x_vfop_qctor_dump_rx()
162 rxq_params->drop_flags, in bnx2x_vfop_qctor_dump_rx()
163 rxq_params->cache_line_log); in bnx2x_vfop_qctor_dump_rx()
172 struct bnx2x_queue_init_params *init_p = &p->qstate.params.init; in bnx2x_vfop_qctor_prep()
173 struct bnx2x_queue_setup_params *setup_p = &p->prep_qsetup; in bnx2x_vfop_qctor_prep()
178 if (test_bit(BNX2X_Q_FLG_HC, &init_p->rx.flags)) in bnx2x_vfop_qctor_prep()
179 __set_bit(BNX2X_Q_FLG_HC_EN, &init_p->rx.flags); in bnx2x_vfop_qctor_prep()
181 if (test_bit(BNX2X_Q_FLG_HC, &init_p->tx.flags)) in bnx2x_vfop_qctor_prep()
182 __set_bit(BNX2X_Q_FLG_HC_EN, &init_p->tx.flags); in bnx2x_vfop_qctor_prep()
185 init_p->rx.fw_sb_id = vf_igu_sb(vf, q->sb_idx); in bnx2x_vfop_qctor_prep()
186 init_p->tx.fw_sb_id = vf_igu_sb(vf, q->sb_idx); in bnx2x_vfop_qctor_prep()
189 init_p->cxts[0] = q->cxt; in bnx2x_vfop_qctor_prep()
193 /* Setup-op general parameters */ in bnx2x_vfop_qctor_prep()
194 setup_p->gen_params.spcl_id = vf->sp_cl_id; in bnx2x_vfop_qctor_prep()
195 setup_p->gen_params.stat_id = vfq_stat_id(vf, q); in bnx2x_vfop_qctor_prep()
196 setup_p->gen_params.fp_hsi = vf->fp_hsi; in bnx2x_vfop_qctor_prep()
198 /* Setup-op flags: in bnx2x_vfop_qctor_prep()
199 * collect statistics, zero statistics, local-switching, security, in bnx2x_vfop_qctor_prep()
202 if (test_bit(BNX2X_Q_FLG_STATS, &setup_p->flags)) in bnx2x_vfop_qctor_prep()
203 __set_bit(BNX2X_Q_FLG_ZERO_STATS, &setup_p->flags); in bnx2x_vfop_qctor_prep()
206 * anti-spoofing in bnx2x_vfop_qctor_prep()
208 __set_bit(BNX2X_Q_FLG_TX_SWITCH, &setup_p->flags); in bnx2x_vfop_qctor_prep()
209 __set_bit(BNX2X_Q_FLG_TX_SEC, &setup_p->flags); in bnx2x_vfop_qctor_prep()
210 if (vf->spoofchk) in bnx2x_vfop_qctor_prep()
211 __set_bit(BNX2X_Q_FLG_ANTI_SPOOF, &setup_p->flags); in bnx2x_vfop_qctor_prep()
213 __clear_bit(BNX2X_Q_FLG_ANTI_SPOOF, &setup_p->flags); in bnx2x_vfop_qctor_prep()
215 /* Setup-op rx parameters */ in bnx2x_vfop_qctor_prep()
217 struct bnx2x_rxq_setup_params *rxq_p = &setup_p->rxq_params; in bnx2x_vfop_qctor_prep()
219 rxq_p->cl_qzone_id = vfq_qzone_id(vf, q); in bnx2x_vfop_qctor_prep()
220 rxq_p->fw_sb_id = vf_igu_sb(vf, q->sb_idx); in bnx2x_vfop_qctor_prep()
221 rxq_p->rss_engine_id = FW_VF_HANDLE(vf->abs_vfid); in bnx2x_vfop_qctor_prep()
223 if (test_bit(BNX2X_Q_FLG_TPA, &setup_p->flags)) in bnx2x_vfop_qctor_prep()
224 rxq_p->max_tpa_queues = BNX2X_VF_MAX_TPA_AGG_QUEUES; in bnx2x_vfop_qctor_prep()
227 /* Setup-op tx parameters */ in bnx2x_vfop_qctor_prep()
229 setup_p->txq_params.tss_leading_cl_id = vf->leading_rss; in bnx2x_vfop_qctor_prep()
230 setup_p->txq_params.fw_sb_id = vf_igu_sb(vf, q->sb_idx); in bnx2x_vfop_qctor_prep()
241 DP(BNX2X_MSG_IOV, "vf[%d:%d]\n", vf->abs_vfid, qid); in bnx2x_vf_queue_create()
244 q_params = &qctor->qstate; in bnx2x_vf_queue_create()
245 q_params->q_obj = &bnx2x_vfq(vf, qid, sp_obj); in bnx2x_vf_queue_create()
246 set_bit(RAMROD_COMP_WAIT, &q_params->ramrod_flags); in bnx2x_vf_queue_create()
248 if (bnx2x_get_q_logical_state(bp, q_params->q_obj) == in bnx2x_vf_queue_create()
255 q_params->cmd = BNX2X_Q_CMD_INIT; in bnx2x_vf_queue_create()
260 memcpy(&q_params->params.setup, &qctor->prep_qsetup, in bnx2x_vf_queue_create()
262 q_params->cmd = BNX2X_Q_CMD_SETUP; in bnx2x_vf_queue_create()
283 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_queue_destroy()
308 bnx2x_vfq(vf, qid, cxt)->ustorm_ag_context.cdu_usage = 0; in bnx2x_vf_queue_destroy()
309 bnx2x_vfq(vf, qid, cxt)->xstorm_ag_context.cdu_reserved = 0; in bnx2x_vf_queue_destroy()
321 if (!BP_VFDB(bp)->first_vf_igu_entry) in bnx2x_vf_set_igu_info()
322 BP_VFDB(bp)->first_vf_igu_entry = igu_sb_id; in bnx2x_vf_set_igu_info()
326 vf->igu_base_id = igu_sb_id; in bnx2x_vf_set_igu_info()
329 ++vf->sb_count; in bnx2x_vf_set_igu_info()
331 BP_VFDB(bp)->vf_sbs_pool++; in bnx2x_vf_set_igu_info()
340 DP(BNX2X_MSG_IOV, "vf[%d] - deleting all %s\n", vf->abs_vfid, in bnx2x_vf_vlan_mac_clear()
341 (type == BNX2X_VF_FILTER_VLAN_MAC) ? "VLAN-MACs" : in bnx2x_vf_vlan_mac_clear()
342 (type == BNX2X_VF_FILTER_MAC) ? "MACs" : "VLANs"); in bnx2x_vf_vlan_mac_clear()
364 rc = ramrod.vlan_mac_obj->delete_all(bp, in bnx2x_vf_vlan_mac_clear()
370 (type == BNX2X_VF_FILTER_VLAN_MAC) ? "VLAN-MACs" : in bnx2x_vf_vlan_mac_clear()
371 (type == BNX2X_VF_FILTER_MAC) ? "MACs" : "VLANs"); in bnx2x_vf_vlan_mac_clear()
386 DP(BNX2X_MSG_IOV, "vf[%d] - %s a %s filter\n", in bnx2x_vf_mac_vlan_config()
387 vf->abs_vfid, filter->add ? "Adding" : "Deleting", in bnx2x_vf_mac_vlan_config()
388 (filter->type == BNX2X_VF_FILTER_VLAN_MAC) ? "VLAN-MAC" : in bnx2x_vf_mac_vlan_config()
389 (filter->type == BNX2X_VF_FILTER_MAC) ? "MAC" : "VLAN"); in bnx2x_vf_mac_vlan_config()
393 if (filter->type == BNX2X_VF_FILTER_VLAN_MAC) { in bnx2x_vf_mac_vlan_config()
395 ramrod.user_req.u.vlan.vlan = filter->vid; in bnx2x_vf_mac_vlan_config()
396 memcpy(&ramrod.user_req.u.mac.mac, filter->mac, ETH_ALEN); in bnx2x_vf_mac_vlan_config()
398 } else if (filter->type == BNX2X_VF_FILTER_VLAN) { in bnx2x_vf_mac_vlan_config()
400 ramrod.user_req.u.vlan.vlan = filter->vid; in bnx2x_vf_mac_vlan_config()
404 memcpy(&ramrod.user_req.u.mac.mac, filter->mac, ETH_ALEN); in bnx2x_vf_mac_vlan_config()
406 ramrod.user_req.cmd = filter->add ? BNX2X_VLAN_MAC_ADD : in bnx2x_vf_mac_vlan_config()
417 if (rc == -EEXIST) in bnx2x_vf_mac_vlan_config()
421 filter->add ? "add" : "delete", in bnx2x_vf_mac_vlan_config()
422 (filter->type == BNX2X_VF_FILTER_VLAN_MAC) ? in bnx2x_vf_mac_vlan_config()
423 "VLAN-MAC" : in bnx2x_vf_mac_vlan_config()
424 (filter->type == BNX2X_VF_FILTER_MAC) ? in bnx2x_vf_mac_vlan_config()
429 filter->applied = true; in bnx2x_vf_mac_vlan_config()
440 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_mac_vlan_config_list()
443 return -EINVAL; in bnx2x_vf_mac_vlan_config_list()
446 for (i = 0; i < filters->count; i++) { in bnx2x_vf_mac_vlan_config_list()
448 &filters->filters[i], drv_only); in bnx2x_vf_mac_vlan_config_list()
454 if (i != filters->count) { in bnx2x_vf_mac_vlan_config_list()
455 BNX2X_ERR("Managed only %d/%d filters - rolling back\n", in bnx2x_vf_mac_vlan_config_list()
456 i, filters->count); in bnx2x_vf_mac_vlan_config_list()
457 while (--i >= 0) { in bnx2x_vf_mac_vlan_config_list()
458 if (!filters->filters[i].applied) in bnx2x_vf_mac_vlan_config_list()
460 filters->filters[i].add = !filters->filters[i].add; in bnx2x_vf_mac_vlan_config_list()
462 &filters->filters[i], in bnx2x_vf_mac_vlan_config_list()
478 DP(BNX2X_MSG_IOV, "vf[%d:%d]\n", vf->abs_vfid, qid); in bnx2x_vf_queue_setup()
489 BNX2X_ERR("QSETUP[%d:%d] error: rc %d\n", vf->abs_vfid, qid, rc); in bnx2x_vf_queue_setup()
498 DP(BNX2X_MSG_IOV, "vf[%d:%d]\n", vf->abs_vfid, qid); in bnx2x_vf_queue_flr()
523 qstate.q_obj->state = BNX2X_Q_STATE_STOPPED; in bnx2x_vf_queue_flr()
533 BNX2X_ERR("vf[%d:%d] error: rc %d\n", vf->abs_vfid, qid, rc); in bnx2x_vf_queue_flr()
544 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_mcast()
548 mcast.mcast_obj = &vf->mcast_obj; in bnx2x_vf_mcast()
558 return -ENOMEM; in bnx2x_vf_mcast()
595 ramrod->cid = vfq->cid; in bnx2x_vf_prep_rx_mode()
596 ramrod->cl_id = vfq_cl_id(vf, vfq); in bnx2x_vf_prep_rx_mode()
597 ramrod->rx_mode_obj = &bp->rx_mode_obj; in bnx2x_vf_prep_rx_mode()
598 ramrod->func_id = FW_VF_HANDLE(vf->abs_vfid); in bnx2x_vf_prep_rx_mode()
599 ramrod->rx_accept_flags = accept_flags; in bnx2x_vf_prep_rx_mode()
600 ramrod->tx_accept_flags = accept_flags; in bnx2x_vf_prep_rx_mode()
601 ramrod->pstate = &vf->filter_state; in bnx2x_vf_prep_rx_mode()
602 ramrod->state = BNX2X_FILTER_RX_MODE_PENDING; in bnx2x_vf_prep_rx_mode()
604 set_bit(BNX2X_FILTER_RX_MODE_PENDING, &vf->filter_state); in bnx2x_vf_prep_rx_mode()
605 set_bit(RAMROD_RX, &ramrod->ramrod_flags); in bnx2x_vf_prep_rx_mode()
606 set_bit(RAMROD_TX, &ramrod->ramrod_flags); in bnx2x_vf_prep_rx_mode()
608 ramrod->rdata = bnx2x_vf_sp(bp, vf, rx_mode_rdata.e2); in bnx2x_vf_prep_rx_mode()
609 ramrod->rdata_mapping = bnx2x_vf_sp_map(bp, vf, rx_mode_rdata.e2); in bnx2x_vf_prep_rx_mode()
617 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_rxmode()
621 vfq_get(vf, qid)->accept_flags = ramrod.rx_accept_flags; in bnx2x_vf_rxmode()
629 DP(BNX2X_MSG_IOV, "vf[%d:%d]\n", vf->abs_vfid, qid); in bnx2x_vf_queue_teardown()
667 vf->abs_vfid, qid, rc); in bnx2x_vf_queue_teardown()
676 /* internal vf enable - until vf is enabled internally all transactions
720 /* Set VF masks and configuration - pretend */ in bnx2x_vf_igu_reset()
721 bnx2x_pretend_func(bp, HW_VF_HANDLE(bp, vf->abs_vfid)); in bnx2x_vf_igu_reset()
738 vf->abs_vfid, val); in bnx2x_vf_igu_reset()
750 bnx2x_igu_clear_sb_gen(bp, vf->abs_vfid, igu_sb_id, in bnx2x_vf_igu_reset()
765 /* set the VF-PF association in the FW */ in bnx2x_vf_enable_access()
770 if (bp->fw_cap & FW_CAP_INVALIDATE_VF_FP_HSI) in bnx2x_vf_enable_access()
778 /* internal vf-enable - pretend */ in bnx2x_vf_enable_access()
791 bnx2x_pretend_func(bp, HW_VF_HANDLE(bp, vf->abs_vfid)); in bnx2x_vf_enable_traffic()
805 dev = pci_get_domain_bus_and_slot(vf->domain, vf->bus, vf->devfn); in bnx2x_vf_is_pcie_pending()
829 struct vf_pf_resc_request *resc = &vf->alloc_resc; in bnx2x_iov_static_resc()
831 /* will be set only during VF-ACQUIRE */ in bnx2x_iov_static_resc()
832 resc->num_rxqs = 0; in bnx2x_iov_static_resc()
833 resc->num_txqs = 0; in bnx2x_iov_static_resc()
835 resc->num_mac_filters = VF_MAC_CREDIT_CNT; in bnx2x_iov_static_resc()
836 resc->num_vlan_filters = VF_VLAN_CREDIT_CNT; in bnx2x_iov_static_resc()
839 resc->num_mc_filters = 0; in bnx2x_iov_static_resc()
842 resc->num_sbs = vf->sb_count; in bnx2x_iov_static_resc()
850 vf->state = VF_FREE; in bnx2x_vf_free_resc()
858 bnx2x_pretend_func(bp, HW_VF_HANDLE(bp, vf->abs_vfid)); in bnx2x_vf_flr_clnup_hw()
864 /* FW cleanup command - poll for the results */ in bnx2x_vf_flr_clnup_hw()
865 if (bnx2x_send_final_clnup(bp, (u8)FW_VF_HANDLE(vf->abs_vfid), in bnx2x_vf_flr_clnup_hw()
867 BNX2X_ERR("VF[%d] Final cleanup timed-out\n", vf->abs_vfid); in bnx2x_vf_flr_clnup_hw()
877 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_flr()
897 vf->malicious = false; in bnx2x_vf_flr()
899 /* re-open the mailbox */ in bnx2x_vf_flr()
900 bnx2x_vf_enable_mbx(bp, vf->abs_vfid); in bnx2x_vf_flr()
904 vf->abs_vfid, i, rc); in bnx2x_vf_flr()
918 DP(BNX2X_MSG_IOV, "next vf to cleanup: %d. Num of vfs: %d\n", in bnx2x_vf_flr_clnup()
930 vf->flr_clnup_stage = false; in bnx2x_vf_flr_clnup()
942 bp->vfdb->flrd_vfs[0], bp->vfdb->flrd_vfs[1]); in bnx2x_vf_flr_clnup()
945 bp->vfdb->flrd_vfs[i]); in bnx2x_vf_flr_clnup()
949 /* clear the acked bits - better yet if the MCP implemented in bnx2x_vf_flr_clnup()
962 bp->vfdb->flrd_vfs[i] = SHMEM2_RD(bp, mcp_vf_disabled[i]); in bnx2x_vf_handle_flr_event()
966 bp->vfdb->flrd_vfs[0], bp->vfdb->flrd_vfs[1]); in bnx2x_vf_handle_flr_event()
972 if (vf->abs_vfid < 32) in bnx2x_vf_handle_flr_event()
973 reset = bp->vfdb->flrd_vfs[0] & (1 << vf->abs_vfid); in bnx2x_vf_handle_flr_event()
975 reset = bp->vfdb->flrd_vfs[1] & in bnx2x_vf_handle_flr_event()
976 (1 << (vf->abs_vfid - 32)); in bnx2x_vf_handle_flr_event()
980 vf->state = VF_RESET; in bnx2x_vf_handle_flr_event()
981 vf->flr_clnup_stage = true; in bnx2x_vf_handle_flr_event()
985 vf->abs_vfid); in bnx2x_vf_handle_flr_event()
1011 /* The VF doorbell size 0 - *B, 4 - 128B. We set it here to match in bnx2x_iov_init_dq()
1016 /* No security checks for now - in bnx2x_iov_init_dq()
1018 * CID range 0 - 0x1ffff in bnx2x_iov_init_dq()
1033 if (pci_find_ext_capability(bp->pdev, PCI_EXT_CAP_ID_SRIOV)) in bnx2x_iov_init_dmae()
1039 struct pci_dev *dev = bp->pdev; in bnx2x_vf_domain()
1041 return pci_domain_nr(dev->bus); in bnx2x_vf_domain()
1046 struct pci_dev *dev = bp->pdev; in bnx2x_vf_bus()
1047 struct bnx2x_sriov *iov = &bp->vfdb->sriov; in bnx2x_vf_bus()
1049 return dev->bus->number + ((dev->devfn + iov->offset + in bnx2x_vf_bus()
1050 iov->stride * vfid) >> 8); in bnx2x_vf_bus()
1055 struct pci_dev *dev = bp->pdev; in bnx2x_vf_devfn()
1056 struct bnx2x_sriov *iov = &bp->vfdb->sriov; in bnx2x_vf_devfn()
1058 return (dev->devfn + iov->offset + iov->stride * vfid) & 0xff; in bnx2x_vf_devfn()
1064 struct pci_dev *dev = bp->pdev; in bnx2x_vf_set_bars()
1065 struct bnx2x_sriov *iov = &bp->vfdb->sriov; in bnx2x_vf_set_bars()
1071 size /= iov->total; in bnx2x_vf_set_bars()
1072 vf->bars[n].bar = start + size * vf->abs_vfid; in bnx2x_vf_set_bars()
1073 vf->bars[n].size = size; in bnx2x_vf_set_bars()
1084 /* IGU in normal mode - read CAM */ in bnx2x_get_vf_igu_cam_info()
1101 DP(BNX2X_MSG_IOV, "vf_sbs_pool is %d\n", BP_VFDB(bp)->vf_sbs_pool); in bnx2x_get_vf_igu_cam_info()
1102 return BP_VFDB(bp)->vf_sbs_pool; in bnx2x_get_vf_igu_cam_info()
1107 if (bp->vfdb) { in __bnx2x_iov_free_vfdb()
1108 kfree(bp->vfdb->vfqs); in __bnx2x_iov_free_vfdb()
1109 kfree(bp->vfdb->vfs); in __bnx2x_iov_free_vfdb()
1110 kfree(bp->vfdb); in __bnx2x_iov_free_vfdb()
1112 bp->vfdb = NULL; in __bnx2x_iov_free_vfdb()
1118 struct pci_dev *dev = bp->pdev; in bnx2x_sriov_pci_cfg_info()
1123 return -ENODEV; in bnx2x_sriov_pci_cfg_info()
1126 iov->pos = pos; in bnx2x_sriov_pci_cfg_info()
1128 pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &iov->ctrl); in bnx2x_sriov_pci_cfg_info()
1129 pci_read_config_word(dev, pos + PCI_SRIOV_TOTAL_VF, &iov->total); in bnx2x_sriov_pci_cfg_info()
1130 pci_read_config_word(dev, pos + PCI_SRIOV_INITIAL_VF, &iov->initial); in bnx2x_sriov_pci_cfg_info()
1131 pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &iov->offset); in bnx2x_sriov_pci_cfg_info()
1132 pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &iov->stride); in bnx2x_sriov_pci_cfg_info()
1133 pci_read_config_dword(dev, pos + PCI_SRIOV_SUP_PGSIZE, &iov->pgsz); in bnx2x_sriov_pci_cfg_info()
1134 pci_read_config_dword(dev, pos + PCI_SRIOV_CAP, &iov->cap); in bnx2x_sriov_pci_cfg_info()
1135 pci_read_config_byte(dev, pos + PCI_SRIOV_FUNC_LINK, &iov->link); in bnx2x_sriov_pci_cfg_info()
1149 return -ENODEV; in bnx2x_sriov_info()
1152 iov->nres = 0; in bnx2x_sriov_info()
1156 iov->first_vf_in_pf = ((val & GRC_CR_PF_INIT_VF_PF_FIRST_VF_NUM_MASK) in bnx2x_sriov_info()
1157 * 8) - (BNX2X_MAX_NUM_OF_VFS * BP_PATH(bp)); in bnx2x_sriov_info()
1160 …"IOV info[%d]: first vf %d, nres %d, cap 0x%x, ctrl 0x%x, total %d, initial %d, num vfs %d, offset… in bnx2x_sriov_info()
1162 iov->first_vf_in_pf, iov->nres, iov->cap, iov->ctrl, iov->total, in bnx2x_sriov_info()
1163 iov->initial, iov->nr_virtfn, iov->offset, iov->stride, iov->pgsz); in bnx2x_sriov_info()
1174 struct pci_dev *dev = bp->pdev; in bnx2x_iov_init_one()
1176 bp->vfdb = NULL; in bnx2x_iov_init_one()
1194 /* SRIOV assumes that num of PF CIDs < BNX2X_FIRST_VF_CID */ in bnx2x_iov_init_one()
1209 if (!pci_ari_enabled(bp->pdev->bus)) { in bnx2x_iov_init_one()
1221 bp->vfdb = kzalloc(sizeof(*(bp->vfdb)), GFP_KERNEL); in bnx2x_iov_init_one()
1222 if (!bp->vfdb) { in bnx2x_iov_init_one()
1224 err = -ENOMEM; in bnx2x_iov_init_one()
1228 /* get the sriov info - Linux already collected all the pertinent in bnx2x_iov_init_one()
1231 * of the hyper-visor. in bnx2x_iov_init_one()
1233 iov = &(bp->vfdb->sriov); in bnx2x_iov_init_one()
1238 /* SR-IOV capability was enabled but there are no VFs*/ in bnx2x_iov_init_one()
1239 if (iov->total == 0) { in bnx2x_iov_init_one()
1244 iov->nr_virtfn = min_t(u16, iov->total, num_vfs_param); in bnx2x_iov_init_one()
1247 num_vfs_param, iov->nr_virtfn); in bnx2x_iov_init_one()
1250 bp->vfdb->vfs = kcalloc(BNX2X_NR_VIRTFN(bp), in bnx2x_iov_init_one()
1253 if (!bp->vfdb->vfs) { in bnx2x_iov_init_one()
1255 err = -ENOMEM; in bnx2x_iov_init_one()
1259 /* Initial VF init - index and abs_vfid - nr_virtfn must be set */ in bnx2x_iov_init_one()
1262 bnx2x_vf(bp, i, abs_vfid) = iov->first_vf_in_pf + i; in bnx2x_iov_init_one()
1270 /* re-read the IGU CAM for VFs - index and abs_vfid must be set */ in bnx2x_iov_init_one()
1273 err = -EINVAL; in bnx2x_iov_init_one()
1278 bp->vfdb->vfqs = kcalloc(BNX2X_MAX_NUM_VF_QUEUES, in bnx2x_iov_init_one()
1282 if (!bp->vfdb->vfqs) { in bnx2x_iov_init_one()
1284 err = -ENOMEM; in bnx2x_iov_init_one()
1289 mutex_init(&bp->vfdb->event_mutex); in bnx2x_iov_init_one()
1291 mutex_init(&bp->vfdb->bulletin_mutex); in bnx2x_iov_init_one()
1314 for (vf_idx = 0; vf_idx < bp->vfdb->sriov.total; vf_idx++) { in bnx2x_iov_remove_one()
1317 bp->vfdb->sriov.first_vf_in_pf + in bnx2x_iov_remove_one()
1320 bp->vfdb->sriov.first_vf_in_pf + vf_idx); in bnx2x_iov_remove_one()
1338 struct hw_dma *cxt = &bp->vfdb->context[i]; in bnx2x_iov_free_mem()
1339 BNX2X_PCI_FREE(cxt->addr, cxt->mapping, cxt->size); in bnx2x_iov_free_mem()
1342 BNX2X_PCI_FREE(BP_VFDB(bp)->sp_dma.addr, in bnx2x_iov_free_mem()
1343 BP_VFDB(bp)->sp_dma.mapping, in bnx2x_iov_free_mem()
1344 BP_VFDB(bp)->sp_dma.size); in bnx2x_iov_free_mem()
1346 BNX2X_PCI_FREE(BP_VF_MBX_DMA(bp)->addr, in bnx2x_iov_free_mem()
1347 BP_VF_MBX_DMA(bp)->mapping, in bnx2x_iov_free_mem()
1348 BP_VF_MBX_DMA(bp)->size); in bnx2x_iov_free_mem()
1350 BNX2X_PCI_FREE(BP_VF_BULLETIN_DMA(bp)->addr, in bnx2x_iov_free_mem()
1351 BP_VF_BULLETIN_DMA(bp)->mapping, in bnx2x_iov_free_mem()
1352 BP_VF_BULLETIN_DMA(bp)->size); in bnx2x_iov_free_mem()
1364 tot_size = (BP_VFDB(bp)->sriov.first_vf_in_pf + BNX2X_NR_VIRTFN(bp)) * in bnx2x_iov_alloc_mem()
1369 cxt->size = min_t(size_t, tot_size, CDU_ILT_PAGE_SZ); in bnx2x_iov_alloc_mem()
1371 if (cxt->size) { in bnx2x_iov_alloc_mem()
1372 cxt->addr = BNX2X_PCI_ALLOC(&cxt->mapping, cxt->size); in bnx2x_iov_alloc_mem()
1373 if (!cxt->addr) in bnx2x_iov_alloc_mem()
1376 cxt->addr = NULL; in bnx2x_iov_alloc_mem()
1377 cxt->mapping = 0; in bnx2x_iov_alloc_mem()
1379 tot_size -= cxt->size; in bnx2x_iov_alloc_mem()
1382 /* allocate vfs ramrods dma memory - client_init and set_mac */ in bnx2x_iov_alloc_mem()
1384 BP_VFDB(bp)->sp_dma.addr = BNX2X_PCI_ALLOC(&BP_VFDB(bp)->sp_dma.mapping, in bnx2x_iov_alloc_mem()
1386 if (!BP_VFDB(bp)->sp_dma.addr) in bnx2x_iov_alloc_mem()
1388 BP_VFDB(bp)->sp_dma.size = tot_size; in bnx2x_iov_alloc_mem()
1392 BP_VF_MBX_DMA(bp)->addr = BNX2X_PCI_ALLOC(&BP_VF_MBX_DMA(bp)->mapping, in bnx2x_iov_alloc_mem()
1394 if (!BP_VF_MBX_DMA(bp)->addr) in bnx2x_iov_alloc_mem()
1397 BP_VF_MBX_DMA(bp)->size = tot_size; in bnx2x_iov_alloc_mem()
1401 BP_VF_BULLETIN_DMA(bp)->addr = BNX2X_PCI_ALLOC(&BP_VF_BULLETIN_DMA(bp)->mapping, in bnx2x_iov_alloc_mem()
1403 if (!BP_VF_BULLETIN_DMA(bp)->addr) in bnx2x_iov_alloc_mem()
1406 BP_VF_BULLETIN_DMA(bp)->size = tot_size; in bnx2x_iov_alloc_mem()
1411 return -ENOMEM; in bnx2x_iov_alloc_mem()
1418 u8 func_id = FW_VF_HANDLE(vf->abs_vfid); in bnx2x_vfq_init()
1425 bnx2x_init_queue_obj(bp, &q->sp_obj, in bnx2x_vfq_init()
1426 cl_id, &q->cid, 1, func_id, in bnx2x_vfq_init()
1432 q->sp_initialized = false; in bnx2x_vfq_init()
1436 vf->abs_vfid, q->sp_obj.func_id, q->cid); in bnx2x_vfq_init()
1441 u32 supported = bp->port.supported[bnx2x_get_link_cfg_idx(bp)]; in bnx2x_max_speed_cap()
1452 struct bnx2x_link_report_data *state = &bp->last_reported_link; in bnx2x_iov_link_update_vf()
1463 mutex_lock(&bp->vfdb->bulletin_mutex); in bnx2x_iov_link_update_vf()
1465 if (vf->link_cfg == IFLA_VF_LINK_STATE_AUTO) { in bnx2x_iov_link_update_vf()
1466 bulletin->valid_bitmap |= 1 << LINK_VALID; in bnx2x_iov_link_update_vf()
1468 bulletin->link_speed = state->line_speed; in bnx2x_iov_link_update_vf()
1469 bulletin->link_flags = 0; in bnx2x_iov_link_update_vf()
1471 &state->link_report_flags)) in bnx2x_iov_link_update_vf()
1472 bulletin->link_flags |= VFPF_LINK_REPORT_LINK_DOWN; in bnx2x_iov_link_update_vf()
1474 &state->link_report_flags)) in bnx2x_iov_link_update_vf()
1475 bulletin->link_flags |= VFPF_LINK_REPORT_FULL_DUPLEX; in bnx2x_iov_link_update_vf()
1477 &state->link_report_flags)) in bnx2x_iov_link_update_vf()
1478 bulletin->link_flags |= VFPF_LINK_REPORT_RX_FC_ON; in bnx2x_iov_link_update_vf()
1480 &state->link_report_flags)) in bnx2x_iov_link_update_vf()
1481 bulletin->link_flags |= VFPF_LINK_REPORT_TX_FC_ON; in bnx2x_iov_link_update_vf()
1482 } else if (vf->link_cfg == IFLA_VF_LINK_STATE_DISABLE && in bnx2x_iov_link_update_vf()
1483 !(bulletin->link_flags & VFPF_LINK_REPORT_LINK_DOWN)) { in bnx2x_iov_link_update_vf()
1484 bulletin->valid_bitmap |= 1 << LINK_VALID; in bnx2x_iov_link_update_vf()
1485 bulletin->link_flags |= VFPF_LINK_REPORT_LINK_DOWN; in bnx2x_iov_link_update_vf()
1486 } else if (vf->link_cfg == IFLA_VF_LINK_STATE_ENABLE && in bnx2x_iov_link_update_vf()
1487 (bulletin->link_flags & VFPF_LINK_REPORT_LINK_DOWN)) { in bnx2x_iov_link_update_vf()
1488 bulletin->valid_bitmap |= 1 << LINK_VALID; in bnx2x_iov_link_update_vf()
1489 bulletin->link_speed = bnx2x_max_speed_cap(bp); in bnx2x_iov_link_update_vf()
1490 bulletin->link_flags &= ~VFPF_LINK_REPORT_LINK_DOWN; in bnx2x_iov_link_update_vf()
1498 vf->link_cfg, bulletin->link_speed, bulletin->link_flags); in bnx2x_iov_link_update_vf()
1509 mutex_unlock(&bp->vfdb->bulletin_mutex); in bnx2x_iov_link_update_vf()
1519 return -EINVAL; in bnx2x_set_vf_link_state()
1521 if (vf->link_cfg == link_state) in bnx2x_set_vf_link_state()
1524 vf->link_cfg = link_state; in bnx2x_set_vf_link_state()
1550 DP(BNX2X_MSG_IOV, "num of vfs: %d\n", (bp)->vfdb->sriov.nr_virtfn); in bnx2x_iov_nic_init()
1559 int base_vf_cid = (BP_VFDB(bp)->sriov.first_vf_in_pf + vfid) * in bnx2x_iov_nic_init()
1563 BP_VF_CXT_PAGE(bp, base_vf_cid/ILT_PAGE_CIDS)->addr + in bnx2x_iov_nic_init()
1564 (base_vf_cid & (ILT_PAGE_CIDS-1)); in bnx2x_iov_nic_init()
1568 vf->abs_vfid, vf_sb_count(vf), base_vf_cid, in bnx2x_iov_nic_init()
1574 /* queues are initialized during VF-ACQUIRE */ in bnx2x_iov_nic_init()
1575 vf->filter_state = 0; in bnx2x_iov_nic_init()
1576 vf->sp_cl_id = bnx2x_fp(bp, 0, cl_id); in bnx2x_iov_nic_init()
1578 bnx2x_init_credit_pool(&vf->vf_vlans_pool, 0, in bnx2x_iov_nic_init()
1580 bnx2x_init_credit_pool(&vf->vf_macs_pool, 0, in bnx2x_iov_nic_init()
1583 /* init mcast object - This object will be re-initialized in bnx2x_iov_nic_init()
1584 * during VF-ACQUIRE with the proper cl_id and cid. in bnx2x_iov_nic_init()
1588 bnx2x_init_mcast_obj(bp, &vf->mcast_obj, 0xFF, in bnx2x_iov_nic_init()
1593 &vf->filter_state, in bnx2x_iov_nic_init()
1597 BP_VF_MBX(bp, vfid)->msg = (struct bnx2x_vf_mbx_msg *) in bnx2x_iov_nic_init()
1598 (((u8 *)BP_VF_MBX_DMA(bp)->addr) + vfid * in bnx2x_iov_nic_init()
1601 BP_VF_MBX(bp, vfid)->msg_mapping = BP_VF_MBX_DMA(bp)->mapping + in bnx2x_iov_nic_init()
1605 bnx2x_vf_enable_mbx(bp, vf->abs_vfid); in bnx2x_iov_nic_init()
1613 vf->domain = bnx2x_vf_domain(bp, vfid); in bnx2x_iov_nic_init()
1614 vf->bus = bnx2x_vf_bus(bp, vfid); in bnx2x_iov_nic_init()
1615 vf->devfn = bnx2x_vf_devfn(bp, vfid); in bnx2x_iov_nic_init()
1620 vf->abs_vfid, vf->bus, vf->devfn, in bnx2x_iov_nic_init()
1621 (unsigned)vf->bars[0].bar, vf->bars[0].size, in bnx2x_iov_nic_init()
1622 (unsigned)vf->bars[1].bar, vf->bars[1].size, in bnx2x_iov_nic_init()
1623 (unsigned)vf->bars[2].bar, vf->bars[2].size); in bnx2x_iov_nic_init()
1657 ilt->lines[line+i].page = hw_cxt->addr; in bnx2x_iov_init_ilt()
1658 ilt->lines[line+i].page_mapping = hw_cxt->mapping; in bnx2x_iov_init_ilt()
1659 ilt->lines[line+i].size = hw_cxt->size; /* doesn't matter */ in bnx2x_iov_init_ilt()
1667 ((cid - BNX2X_FIRST_VF_CID) < BNX2X_VF_CIDS)); in bnx2x_iov_is_vf_cid()
1677 u32 echo = le32_to_cpu(elem->message.data.eth_event.echo); in bnx2x_vf_handle_classification_eqe()
1684 rc = vfq->mac_obj.complete(bp, &vfq->mac_obj, elem, in bnx2x_vf_handle_classification_eqe()
1688 rc = vfq->vlan_obj.complete(bp, &vfq->vlan_obj, elem, in bnx2x_vf_handle_classification_eqe()
1708 rparam.mcast_obj = &vf->mcast_obj; in bnx2x_vf_handle_mcast_eqe()
1709 vf->mcast_obj.raw.clear_pending(&vf->mcast_obj.raw); in bnx2x_vf_handle_mcast_eqe()
1711 /* If there are pending mcast commands - send them */ in bnx2x_vf_handle_mcast_eqe()
1712 if (vf->mcast_obj.check_pending(&vf->mcast_obj)) { in bnx2x_vf_handle_mcast_eqe()
1725 clear_bit(BNX2X_FILTER_RX_MODE_PENDING, &vf->filter_state); in bnx2x_vf_handle_filters_eqe()
1732 vf->rss_conf_obj.raw.clear_pending(&vf->rss_conf_obj.raw); in bnx2x_vf_handle_rss_update_eqe()
1745 /* first get the cid - the only events we handle here are cfc-delete in bnx2x_iov_eq_sp_event()
1746 * and set-mac completion in bnx2x_iov_eq_sp_event()
1748 opcode = elem->message.opcode; in bnx2x_iov_eq_sp_event()
1752 cid = SW_CID(elem->message.data.cfc_del_event.cid); in bnx2x_iov_eq_sp_event()
1753 DP(BNX2X_MSG_IOV, "checking cfc-del comp cid=%d\n", cid); in bnx2x_iov_eq_sp_event()
1759 cid = SW_CID(elem->message.data.eth_event.echo); in bnx2x_iov_eq_sp_event()
1763 abs_vfid = elem->message.data.vf_flr_event.vf_id; in bnx2x_iov_eq_sp_event()
1768 abs_vfid = elem->message.data.malicious_vf_event.vf_id; in bnx2x_iov_eq_sp_event()
1771 elem->message.data.malicious_vf_event.err_id); in bnx2x_iov_eq_sp_event()
1783 /* extract vf and rxq index from vf_cid - relies on the following: in bnx2x_iov_eq_sp_event()
1787 qidx = cid & ((1 << BNX2X_VF_CID_WND)-1); in bnx2x_iov_eq_sp_event()
1788 abs_vfid = (cid >> BNX2X_VF_CID_WND) & (BNX2X_MAX_NUM_OF_VFS-1); in bnx2x_iov_eq_sp_event()
1801 vf->abs_vfid, qidx); in bnx2x_iov_eq_sp_event()
1802 vfq_get(vf, qidx)->sp_obj.complete_cmd(bp, in bnx2x_iov_eq_sp_event()
1804 qidx)->sp_obj, in bnx2x_iov_eq_sp_event()
1809 vf->abs_vfid, qidx); in bnx2x_iov_eq_sp_event()
1814 vf->abs_vfid, qidx); in bnx2x_iov_eq_sp_event()
1818 DP(BNX2X_MSG_IOV, "got VF [%d:%d] set rx-mode ramrod\n", in bnx2x_iov_eq_sp_event()
1819 vf->abs_vfid, qidx); in bnx2x_iov_eq_sp_event()
1824 vf->abs_vfid, qidx); in bnx2x_iov_eq_sp_event()
1831 vf->malicious = true; in bnx2x_iov_eq_sp_event()
1840 /* extract the vf from vf_cid - relies on the following: in bnx2x_vf_by_cid()
1844 int abs_vfid = (vf_cid >> BNX2X_VF_CID_WND) & (BNX2X_MAX_NUM_OF_VFS-1); in bnx2x_vf_by_cid()
1859 /* extract queue index from vf_cid - relies on the following: in bnx2x_iov_set_queue_sp_obj()
1863 int q_index = vf_cid & ((1 << BNX2X_VF_CID_WND)-1); in bnx2x_iov_set_queue_sp_obj()
1886 first_queue_query_index = BNX2X_FIRST_QUEUE_QUERY_IDX - in bnx2x_iov_adjust_stats_req()
1894 cur_query_entry = &bp->fw_stats_req-> in bnx2x_iov_adjust_stats_req()
1901 if (vf->state != VF_ENABLED) { in bnx2x_iov_adjust_stats_req()
1904 vf->abs_vfid); in bnx2x_iov_adjust_stats_req()
1908 if (vf->malicious) { in bnx2x_iov_adjust_stats_req()
1911 vf->abs_vfid); in bnx2x_iov_adjust_stats_req()
1916 "add addresses for vf %d\n", vf->abs_vfid); in bnx2x_iov_adjust_stats_req()
1921 vf->fw_stat_map + j * vf->stats_stride; in bnx2x_iov_adjust_stats_req()
1924 if (bnx2x_get_q_logical_state(bp, &rxq->sp_obj) == in bnx2x_iov_adjust_stats_req()
1929 cur_query_entry->kind = STATS_TYPE_QUEUE; in bnx2x_iov_adjust_stats_req()
1930 cur_query_entry->index = vfq_stat_id(vf, rxq); in bnx2x_iov_adjust_stats_req()
1931 cur_query_entry->funcID = in bnx2x_iov_adjust_stats_req()
1932 cpu_to_le16(FW_VF_HANDLE(vf->abs_vfid)); in bnx2x_iov_adjust_stats_req()
1933 cur_query_entry->address.hi = in bnx2x_iov_adjust_stats_req()
1935 cur_query_entry->address.lo = in bnx2x_iov_adjust_stats_req()
1939 cur_query_entry->address.hi, in bnx2x_iov_adjust_stats_req()
1940 cur_query_entry->address.lo, in bnx2x_iov_adjust_stats_req()
1941 cur_query_entry->funcID, in bnx2x_iov_adjust_stats_req()
1942 j, cur_query_entry->index); in bnx2x_iov_adjust_stats_req()
1947 if (vf->cfg_flags & VF_CFG_STATS_COALESCE) in bnx2x_iov_adjust_stats_req()
1951 bp->fw_stats_req->hdr.cmd_num = bp->fw_stats_num + stats_count; in bnx2x_iov_adjust_stats_req()
1969 bnx2x_vf_qtbl_set_q(bp, vf->abs_vfid, in bnx2x_vf_clr_qtbl()
1977 /* clear the VF configuration - pretend */ in bnx2x_vf_igu_disable()
1978 bnx2x_pretend_func(bp, HW_VF_HANDLE(bp, vf->abs_vfid)); in bnx2x_vf_igu_disable()
1999 return ((req_resc->num_rxqs <= rxq_cnt) && in bnx2x_vf_chk_avail_resc()
2000 (req_resc->num_txqs <= txq_cnt) && in bnx2x_vf_chk_avail_resc()
2001 (req_resc->num_sbs <= vf_sb_count(vf)) && in bnx2x_vf_chk_avail_resc()
2002 (req_resc->num_mac_filters <= vf_mac_rules_cnt(vf)) && in bnx2x_vf_chk_avail_resc()
2003 (req_resc->num_vlan_filters <= vf_vlan_rules_cnt(vf))); in bnx2x_vf_chk_avail_resc()
2010 int base_vf_cid = (BP_VFDB(bp)->sriov.first_vf_in_pf + vf->index) * in bnx2x_vf_acquire()
2014 BP_VF_CXT_PAGE(bp, base_vf_cid/ILT_PAGE_CIDS)->addr + in bnx2x_vf_acquire()
2015 (base_vf_cid & (ILT_PAGE_CIDS-1)); in bnx2x_vf_acquire()
2023 if (vf->state == VF_ACQUIRED) { in bnx2x_vf_acquire()
2024 DP(BNX2X_MSG_IOV, "VF[%d] Trying to re-acquire resources (VF was not released or FLR'd)\n", in bnx2x_vf_acquire()
2025 vf->abs_vfid); in bnx2x_vf_acquire()
2028 …BNX2X_ERR("VF[%d] When re-acquiring resources, requested numbers must be <= then previously acquir… in bnx2x_vf_acquire()
2029 vf->abs_vfid); in bnx2x_vf_acquire()
2030 return -EINVAL; in bnx2x_vf_acquire()
2036 if (vf->state != VF_FREE && vf->state != VF_RESET) { in bnx2x_vf_acquire()
2038 vf->abs_vfid, vf->state); in bnx2x_vf_acquire()
2039 return -EINVAL; in bnx2x_vf_acquire()
2050 return -ENOMEM; in bnx2x_vf_acquire()
2053 /* Set resources counters - 0 request means max available */ in bnx2x_vf_acquire()
2054 vf_sb_count(vf) = resc->num_sbs; in bnx2x_vf_acquire()
2055 vf_rxq_count(vf) = resc->num_rxqs ? : bnx2x_vf_max_queue_cnt(bp, vf); in bnx2x_vf_acquire()
2056 vf_txq_count(vf) = resc->num_txqs ? : bnx2x_vf_max_queue_cnt(bp, vf); in bnx2x_vf_acquire()
2065 if (!vf->vfqs) { in bnx2x_vf_acquire()
2066 DP(BNX2X_MSG_IOV, "vf->vfqs was not allocated\n"); in bnx2x_vf_acquire()
2067 return -EINVAL; in bnx2x_vf_acquire()
2075 return -EINVAL; in bnx2x_vf_acquire()
2078 q->index = i; in bnx2x_vf_acquire()
2079 q->cxt = &((base_cxt + i)->eth); in bnx2x_vf_acquire()
2080 q->cid = BNX2X_FIRST_VF_CID + base_vf_cid + i; in bnx2x_vf_acquire()
2083 vf->abs_vfid, i, q->index, q->cid, q->cxt); in bnx2x_vf_acquire()
2088 vf->state = VF_ACQUIRED; in bnx2x_vf_acquire()
2101 bnx2x_init_sb(bp, (dma_addr_t)sb_map[i], vf->abs_vfid, true, in bnx2x_vf_init()
2105 if (vf->state != VF_ACQUIRED) { in bnx2x_vf_init()
2107 vf->abs_vfid, vf->state); in bnx2x_vf_init()
2108 return -EINVAL; in bnx2x_vf_init()
2115 if (bnx2x_vf_flr_clnup_epilog(bp, vf->abs_vfid)) in bnx2x_vf_init()
2116 return -EBUSY; in bnx2x_vf_init()
2119 REG_WR(bp, IGU_REG_STATISTIC_NUM_MESSAGE_SENT + vf->abs_vfid * 4 , 0); in bnx2x_vf_init()
2123 func_init.func_id = FW_VF_HANDLE(vf->abs_vfid); in bnx2x_vf_init()
2127 bnx2x_vf_enable_access(bp, vf->abs_vfid); in bnx2x_vf_init()
2132 bnx2x_vf_qtbl_set_q(bp, vf->abs_vfid, in bnx2x_vf_init()
2135 vf->state = VF_ENABLED; in bnx2x_vf_init()
2138 bnx2x_post_vf_bulletin(bp, vf->index); in bnx2x_vf_init()
2152 p->vf->state = p->state; in bnx2x_set_vf_state()
2159 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_close()
2194 BNX2X_ERR("vf[%d] CLOSE error: rc %d\n", vf->abs_vfid, rc); in bnx2x_vf_close()
2206 DP(BNX2X_MSG_IOV, "VF[%d] STATE: %s\n", vf->abs_vfid, in bnx2x_vf_free()
2207 vf->state == VF_FREE ? "Free" : in bnx2x_vf_free()
2208 vf->state == VF_ACQUIRED ? "Acquired" : in bnx2x_vf_free()
2209 vf->state == VF_ENABLED ? "Enabled" : in bnx2x_vf_free()
2210 vf->state == VF_RESET ? "Reset" : in bnx2x_vf_free()
2213 switch (vf->state) { in bnx2x_vf_free()
2231 BNX2X_ERR("VF[%d] RELEASE error: rc %d\n", vf->abs_vfid, rc); in bnx2x_vf_free()
2238 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_rss_update()
2239 set_bit(RAMROD_COMP_WAIT, &rss->ramrod_flags); in bnx2x_vf_rss_update()
2247 aligned_u64 *sge_addr = tlv->tpa_client_info.sge_addr; in bnx2x_vf_tpa_update()
2251 DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid); in bnx2x_vf_tpa_update()
2264 vf->abs_vfid, qid, U64_HI(sge_addr[qid]), in bnx2x_vf_tpa_update()
2270 vf->abs_vfid, qid); in bnx2x_vf_tpa_update()
2278 /* VF release ~ VF close + VF release-resources
2286 DP(BNX2X_MSG_IOV, "PF releasing vf %d\n", vf->abs_vfid); in bnx2x_vf_release()
2292 "VF[%d] Failed to allocate resources for release op- rc=%d\n", in bnx2x_vf_release()
2293 vf->abs_vfid, rc); in bnx2x_vf_release()
2308 mutex_lock(&vf->op_mutex); in bnx2x_lock_vf_pf_channel()
2311 vf->op_current = tlv; in bnx2x_lock_vf_pf_channel()
2315 vf->abs_vfid, tlv); in bnx2x_lock_vf_pf_channel()
2328 current_tlv = vf->op_current; in bnx2x_unlock_vf_pf_channel()
2334 WARN(expected_tlv != vf->op_current, in bnx2x_unlock_vf_pf_channel()
2336 vf->op_current); in bnx2x_unlock_vf_pf_channel()
2339 vf->op_current = CHANNEL_TLV_NONE; in bnx2x_unlock_vf_pf_channel()
2342 mutex_unlock(&vf->op_mutex); in bnx2x_unlock_vf_pf_channel()
2346 vf->abs_vfid, current_tlv); in bnx2x_unlock_vf_pf_channel()
2356 prev_flags = bp->flags; in bnx2x_set_pf_tx_switching()
2358 bp->flags |= TX_SWITCHING; in bnx2x_set_pf_tx_switching()
2360 bp->flags &= ~TX_SWITCHING; in bnx2x_set_pf_tx_switching()
2361 if (prev_flags == bp->flags) in bnx2x_set_pf_tx_switching()
2365 if ((bp->state != BNX2X_STATE_OPEN) || in bnx2x_set_pf_tx_switching()
2367 &bnx2x_sp_obj(bp, &bp->fp[0]).q_obj) != in bnx2x_set_pf_tx_switching()
2386 struct bnx2x_fastpath *fp = &bp->fp[i]; in bnx2x_set_pf_tx_switching()
2393 tx_idx < fp->max_cos; tx_idx++) { in bnx2x_set_pf_tx_switching()
2414 …BNX2X_ERR("failed to configure SR-IOV since vfdb was not allocated. Check dmesg for errors in prob… in bnx2x_sriov_configure()
2415 return -EINVAL; in bnx2x_sriov_configure()
2422 if (bp->state != BNX2X_STATE_OPEN) { in bnx2x_sriov_configure()
2423 BNX2X_ERR("VF num configuration via sysfs not supported while PF is down\n"); in bnx2x_sriov_configure()
2424 return -EINVAL; in bnx2x_sriov_configure()
2434 bp->requested_nr_virtfn = num_vfs_param; in bnx2x_sriov_configure()
2448 int rc = 0, req_vfs = bp->requested_nr_virtfn; in bnx2x_enable_sriov()
2456 first_vf = bp->vfdb->sriov.first_vf_in_pf; in bnx2x_enable_sriov()
2460 BP_VFDB(bp)->vf_sbs_pool / req_vfs); in bnx2x_enable_sriov()
2466 vf->sb_count = 0; in bnx2x_enable_sriov()
2469 bp->vfdb->vf_sbs_pool = 0; in bnx2x_enable_sriov()
2472 sb_idx = BP_VFDB(bp)->first_vf_igu_entry; in bnx2x_enable_sriov()
2491 BP_VFDB(bp)->vf_sbs_pool, num_vf_queues); in bnx2x_enable_sriov()
2498 vf->vfqs = &bp->vfdb->vfqs[qcount]; in bnx2x_enable_sriov()
2503 /* prepare msix vectors in VF configuration space - the value in the in bnx2x_enable_sriov()
2510 num_vf_queues - 1); in bnx2x_enable_sriov()
2511 DP(BNX2X_MSG_IOV, "set msix vec num in VF %d cfg space to %d\n", in bnx2x_enable_sriov()
2512 vf_idx, num_vf_queues - 1); in bnx2x_enable_sriov()
2526 rc = pci_enable_sriov(bp->pdev, req_vfs); in bnx2x_enable_sriov()
2540 DP(BNX2X_MSG_IOV, "configuring vlan for VFs from sp-task\n"); in bnx2x_pf_set_vfs_vlan()
2543 if (bulletin->valid_bitmap & (1 << VLAN_VALID)) in bnx2x_pf_set_vfs_vlan()
2544 bnx2x_set_vf_vlan(bp->dev, vfidx, bulletin->vlan, 0, in bnx2x_pf_set_vfs_vlan()
2551 if (pci_vfs_assigned(bp->pdev)) { in bnx2x_disable_sriov()
2553 "Unloading driver while VFs are assigned - VFs will not be deallocated\n"); in bnx2x_disable_sriov()
2557 pci_disable_sriov(bp->pdev); in bnx2x_disable_sriov()
2565 if (bp->state != BNX2X_STATE_OPEN) { in bnx2x_vf_op_prep()
2566 BNX2X_ERR("PF is down - can't utilize iov-related functionality\n"); in bnx2x_vf_op_prep()
2567 return -EINVAL; in bnx2x_vf_op_prep()
2571 BNX2X_ERR("sriov is disabled - can't utilize iov-related functionality\n"); in bnx2x_vf_op_prep()
2572 return -EINVAL; in bnx2x_vf_op_prep()
2576 …BNX2X_ERR("VF is uninitialized - can't utilize iov-related functionality. vfidx was %d BNX2X_NR_VI… in bnx2x_vf_op_prep()
2578 return -EINVAL; in bnx2x_vf_op_prep()
2587 return -EINVAL; in bnx2x_vf_op_prep()
2590 if (test_queue && !(*vf)->vfqs) { in bnx2x_vf_op_prep()
2591 …BNX2X_ERR("vfqs struct is null. Was this invoked before dynamically enabling SR-IOV? vfidx was %d\… in bnx2x_vf_op_prep()
2593 return -EINVAL; in bnx2x_vf_op_prep()
2599 return -EINVAL; in bnx2x_vf_op_prep()
2624 return -EINVAL; in bnx2x_get_vf_config()
2627 ivi->vf = vfidx; in bnx2x_get_vf_config()
2628 ivi->qos = 0; in bnx2x_get_vf_config()
2629 ivi->max_tx_rate = 10000; /* always 10G. TBA take from link struct */ in bnx2x_get_vf_config()
2630 ivi->min_tx_rate = 0; in bnx2x_get_vf_config()
2631 ivi->spoofchk = vf->spoofchk ? 1 : 0; in bnx2x_get_vf_config()
2632 ivi->linkstate = vf->link_cfg; in bnx2x_get_vf_config()
2633 if (vf->state == VF_ENABLED) { in bnx2x_get_vf_config()
2636 mac_obj->get_n_elements(bp, mac_obj, 1, (u8 *)&ivi->mac, in bnx2x_get_vf_config()
2638 vlan_obj->get_n_elements(bp, vlan_obj, 1, in bnx2x_get_vf_config()
2639 (u8 *)&ivi->vlan, 0, in bnx2x_get_vf_config()
2643 mutex_lock(&bp->vfdb->bulletin_mutex); in bnx2x_get_vf_config()
2645 if (bulletin->valid_bitmap & (1 << MAC_ADDR_VALID)) in bnx2x_get_vf_config()
2647 memcpy(&ivi->mac, bulletin->mac, ETH_ALEN); in bnx2x_get_vf_config()
2650 eth_zero_addr(ivi->mac); in bnx2x_get_vf_config()
2653 if (bulletin->valid_bitmap & (1 << VLAN_VALID)) in bnx2x_get_vf_config()
2655 ivi->vlan = bulletin->vlan; in bnx2x_get_vf_config()
2658 ivi->vlan = 0; in bnx2x_get_vf_config()
2660 mutex_unlock(&bp->vfdb->bulletin_mutex); in bnx2x_get_vf_config()
2667 * 1. VF hasn't been acquired yet - save the mac in local bulletin board and
2669 * 2. VF has already been acquired but has not yet initialized - store in local
2672 * 3. VF has already initialized but has not yet setup a queue - post the new
2675 * 4. VF has already set a queue - delete any macs already configured for this
2692 return -EINVAL; in bnx2x_set_vf_mac()
2700 mutex_lock(&bp->vfdb->bulletin_mutex); in bnx2x_set_vf_mac()
2705 bulletin->valid_bitmap |= 1 << MAC_ADDR_VALID; in bnx2x_set_vf_mac()
2706 memcpy(bulletin->mac, mac, ETH_ALEN); in bnx2x_set_vf_mac()
2712 mutex_unlock(&bp->vfdb->bulletin_mutex); in bnx2x_set_vf_mac()
2721 if (vf->state == VF_ENABLED && in bnx2x_set_vf_mac()
2729 return -EINVAL; in bnx2x_set_vf_mac()
2734 /* remove existing eth macs */ in bnx2x_set_vf_mac()
2738 BNX2X_ERR("failed to delete eth macs\n"); in bnx2x_set_vf_mac()
2739 rc = -EINVAL; in bnx2x_set_vf_mac()
2743 /* remove existing uc list macs */ in bnx2x_set_vf_mac()
2746 BNX2X_ERR("failed to delete uc_list macs\n"); in bnx2x_set_vf_mac()
2747 rc = -EINVAL; in bnx2x_set_vf_mac()
2753 bnx2x_set_mac_one(bp, (u8 *)&bulletin->mac, mac_obj, true, in bnx2x_set_vf_mac()
2800 return -EINVAL; in bnx2x_set_vf_vlan_filter()
2819 return -EINVAL; in bnx2x_set_vf_vlan()
2823 return -EPROTONOSUPPORT; in bnx2x_set_vf_vlan()
2839 mutex_lock(&bp->vfdb->bulletin_mutex); in bnx2x_set_vf_vlan()
2842 bulletin->valid_bitmap |= 1 << VLAN_VALID; in bnx2x_set_vf_vlan()
2844 bulletin->valid_bitmap &= ~(1 << VLAN_VALID); in bnx2x_set_vf_vlan()
2845 bulletin->vlan = vlan; in bnx2x_set_vf_vlan()
2851 mutex_unlock(&bp->vfdb->bulletin_mutex); in bnx2x_set_vf_vlan()
2854 if (vf->state != VF_ENABLED || in bnx2x_set_vf_vlan()
2861 return -EINVAL; in bnx2x_set_vf_vlan()
2869 rc = vlan_obj->delete_all(bp, vlan_obj, &vlan_mac_flags, in bnx2x_set_vf_vlan()
2873 rc = -EINVAL; in bnx2x_set_vf_vlan()
2880 if (vlan || !(vf->cfg_flags & VF_CFG_VLAN_FILTER)) in bnx2x_set_vf_vlan()
2905 &update_params->update_flags); in bnx2x_set_vf_vlan()
2907 &update_params->update_flags); in bnx2x_set_vf_vlan()
2914 &update_params->update_flags); in bnx2x_set_vf_vlan()
2916 &update_params->update_flags); in bnx2x_set_vf_vlan()
2922 &update_params->update_flags); in bnx2x_set_vf_vlan()
2924 &update_params->update_flags); in bnx2x_set_vf_vlan()
2925 update_params->def_vlan = vlan; in bnx2x_set_vf_vlan()
2926 update_params->silent_removal_value = in bnx2x_set_vf_vlan()
2928 update_params->silent_removal_mask = VLAN_VID_MASK; in bnx2x_set_vf_vlan()
2958 return -EINVAL; in bnx2x_set_vf_spoofchk()
2961 if (vf->spoofchk == val) in bnx2x_set_vf_spoofchk()
2964 vf->spoofchk = val ? 1 : 0; in bnx2x_set_vf_spoofchk()
2970 if (vf->state != VF_ENABLED || in bnx2x_set_vf_spoofchk()
2977 return -EINVAL; in bnx2x_set_vf_spoofchk()
2995 &update_params->update_flags); in bnx2x_set_vf_spoofchk()
2998 &update_params->update_flags); in bnx2x_set_vf_spoofchk()
3001 &update_params->update_flags); in bnx2x_set_vf_spoofchk()
3007 BNX2X_ERR("Failed to %s spoofchk on VF %d - vfq %d\n", in bnx2x_set_vf_spoofchk()
3030 ((u8 *)bulletin) + sizeof(bulletin->crc), in bnx2x_crc_vf_bulletin()
3031 bulletin->length - sizeof(bulletin->crc)); in bnx2x_crc_vf_bulletin()
3047 memcpy(&bp->shadow_bulletin, bp->pf2vf_bulletin, in bnx2x_sample_bulletin()
3050 crc = bnx2x_crc_vf_bulletin(&bp->shadow_bulletin.content); in bnx2x_sample_bulletin()
3052 if (bp->shadow_bulletin.content.crc == crc) in bnx2x_sample_bulletin()
3056 bp->shadow_bulletin.content.crc, crc); in bnx2x_sample_bulletin()
3064 bulletin = &bp->shadow_bulletin.content; in bnx2x_sample_bulletin()
3067 if (bp->old_bulletin.version == bulletin->version) in bnx2x_sample_bulletin()
3071 if (bulletin->valid_bitmap & 1 << MAC_ADDR_VALID && in bnx2x_sample_bulletin()
3072 !ether_addr_equal(bulletin->mac, bp->old_bulletin.mac)) { in bnx2x_sample_bulletin()
3074 eth_hw_addr_set(bp->dev, bulletin->mac); in bnx2x_sample_bulletin()
3077 if (bulletin->valid_bitmap & (1 << LINK_VALID)) { in bnx2x_sample_bulletin()
3079 bulletin->link_speed, bulletin->link_flags); in bnx2x_sample_bulletin()
3081 bp->vf_link_vars.line_speed = bulletin->link_speed; in bnx2x_sample_bulletin()
3082 bp->vf_link_vars.link_report_flags = 0; in bnx2x_sample_bulletin()
3084 if (bulletin->link_flags & VFPF_LINK_REPORT_LINK_DOWN) in bnx2x_sample_bulletin()
3086 &bp->vf_link_vars.link_report_flags); in bnx2x_sample_bulletin()
3088 if (bulletin->link_flags & VFPF_LINK_REPORT_FULL_DUPLEX) in bnx2x_sample_bulletin()
3090 &bp->vf_link_vars.link_report_flags); in bnx2x_sample_bulletin()
3092 if (bulletin->link_flags & VFPF_LINK_REPORT_RX_FC_ON) in bnx2x_sample_bulletin()
3094 &bp->vf_link_vars.link_report_flags); in bnx2x_sample_bulletin()
3096 if (bulletin->link_flags & VFPF_LINK_REPORT_TX_FC_ON) in bnx2x_sample_bulletin()
3098 &bp->vf_link_vars.link_report_flags); in bnx2x_sample_bulletin()
3103 memcpy(&bp->old_bulletin, bulletin, in bnx2x_sample_bulletin()
3114 if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) in bnx2x_timer_sriov()
3122 return bp->regview + PXP_VF_ADDR_DB_START; in bnx2x_vf_doorbells()
3127 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping, in bnx2x_vf_pci_dealloc()
3129 BNX2X_PCI_FREE(bp->pf2vf_bulletin, bp->pf2vf_bulletin_mapping, in bnx2x_vf_pci_dealloc()
3135 mutex_init(&bp->vf2pf_mutex); in bnx2x_vf_pci_alloc()
3138 bp->vf2pf_mbox = BNX2X_PCI_ALLOC(&bp->vf2pf_mbox_mapping, in bnx2x_vf_pci_alloc()
3140 if (!bp->vf2pf_mbox) in bnx2x_vf_pci_alloc()
3144 bp->pf2vf_bulletin = BNX2X_PCI_ALLOC(&bp->pf2vf_bulletin_mapping, in bnx2x_vf_pci_alloc()
3146 if (!bp->pf2vf_bulletin) in bnx2x_vf_pci_alloc()
3149 bnx2x_vf_bulletin_finalize(&bp->pf2vf_bulletin->content, true); in bnx2x_vf_pci_alloc()
3155 return -ENOMEM; in bnx2x_vf_pci_alloc()
3171 bulletin->valid_bitmap |= 1 << CHANNEL_DOWN; in bnx2x_iov_channel_down()
3182 if (!netif_running(bp->dev)) in bnx2x_iov_task()
3186 &bp->iov_task_state)) in bnx2x_iov_task()
3190 &bp->iov_task_state)) in bnx2x_iov_task()
3197 set_bit(flag, &bp->iov_task_state); in bnx2x_schedule_iov_task()
3200 queue_delayed_work(bnx2x_iov_wq, &bp->iov_task, 0); in bnx2x_schedule_iov_task()