Lines Matching refs:pf

45 static int	ixl_vf_alloc_vsi(struct ixl_pf *pf, struct ixl_vf *vf);
46 static int ixl_vf_setup_vsi(struct ixl_pf *pf, struct ixl_vf *vf);
47 static void ixl_vf_map_queues(struct ixl_pf *pf, struct ixl_vf *vf);
48 static void ixl_vf_vsi_release(struct ixl_pf *pf, struct ixl_vsi *vsi);
49 static void ixl_vf_release_resources(struct ixl_pf *pf, struct ixl_vf *vf);
50 static int ixl_flush_pcie(struct ixl_pf *pf, struct ixl_vf *vf);
51 static void ixl_reset_vf(struct ixl_pf *pf, struct ixl_vf *vf);
52 static void ixl_reinit_vf(struct ixl_pf *pf, struct ixl_vf *vf);
53 static void ixl_send_vf_msg(struct ixl_pf *pf, struct ixl_vf *vf, uint16_t op, enum i40e_status_code status, void *msg, uint16_t len);
54 static void ixl_send_vf_ack(struct ixl_pf *pf, struct ixl_vf *vf, uint16_t op);
55 static void ixl_send_vf_nack_msg(struct ixl_pf *pf, struct ixl_vf *vf, uint16_t op, enum i40e_status_code status, const char *file, int line);
56 static void ixl_vf_version_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
57 static void ixl_vf_reset_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
58 static void ixl_vf_get_resources_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
59 static int ixl_vf_config_tx_queue(struct ixl_pf *pf, struct ixl_vf *vf, struct virtchnl_txq_info *info);
60 static int ixl_vf_config_rx_queue(struct ixl_pf *pf, struct ixl_vf *vf, struct virtchnl_rxq_info *info);
61 static void ixl_vf_config_vsi_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
62 static void ixl_vf_set_qctl(struct ixl_pf *pf, const struct virtchnl_vector_map *vector, enum i40e_queue_type cur_type, uint16_t cur_queue,
64 static void ixl_vf_config_vector(struct ixl_pf *pf, struct ixl_vf *vf, const struct virtchnl_vector_map *vector);
65 static void ixl_vf_config_irq_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
66 static void ixl_vf_enable_queues_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
67 static void ixl_vf_disable_queues_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
68 static void ixl_vf_add_mac_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
69 static void ixl_vf_del_mac_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
70 static enum i40e_status_code ixl_vf_enable_vlan_strip(struct ixl_pf *pf, struct ixl_vf *vf);
71 static void ixl_vf_add_vlan_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
72 static void ixl_vf_del_vlan_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
73 static void ixl_vf_config_promisc_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
74 static void ixl_vf_get_stats_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg, uint16_t msg_size);
75 static int ixl_vf_reserve_queues(struct ixl_pf *pf, struct ixl_vf *vf, int num_queues);
76 static int ixl_config_pf_vsi_loopback(struct ixl_pf *pf, bool enable);
89 ixl_initialize_sriov(struct ixl_pf *pf)
91 device_t dev = pf->dev;
92 struct i40e_hw *hw = &pf->hw;
117 pf->vc_debug_lvl = 1;
124 ixl_vf_alloc_vsi(struct ixl_pf *pf, struct ixl_vf *vf)
132 hw = &pf->hw;
133 dev = pf->dev;
136 vsi_ctx.uplink_seid = pf->veb_seid;
144 if (pf->enable_vf_loopback)
195 ixl_vf_setup_vsi(struct ixl_pf *pf, struct ixl_vf *vf)
200 hw = &pf->hw;
203 error = ixl_vf_alloc_vsi(pf, vf);
207 vf->vsi.dev = pf->dev;
213 device_printf(pf->dev, "Error configuring VF VSI for broadcast promiscuous\n");
242 ixl_vf_map_queues(struct ixl_pf *pf, struct ixl_vf *vf)
248 hw = &pf->hw;
289 ixl_vf_vsi_release(struct ixl_pf *pf, struct ixl_vsi *vsi)
293 hw = &pf->hw;
319 ixl_vf_release_resources(struct ixl_pf *pf, struct ixl_vf *vf)
325 hw = &pf->hw;
327 ixl_vf_vsi_release(pf, &vf->vsi);
350 ixl_flush_pcie(struct ixl_pf *pf, struct ixl_vf *vf)
357 hw = &pf->hw;
373 ixl_reset_vf(struct ixl_pf *pf, struct ixl_vf *vf)
378 hw = &pf->hw;
380 ixl_dbg_iov(pf, "Resetting VF-%d\n", vf->vf_num);
387 ixl_reinit_vf(pf, vf);
389 ixl_dbg_iov(pf, "Resetting VF-%d done.\n", vf->vf_num);
393 ixl_reinit_vf(struct ixl_pf *pf, struct ixl_vf *vf)
399 hw = &pf->hw;
401 error = ixl_flush_pcie(pf, vf);
403 device_printf(pf->dev,
416 device_printf(pf->dev, "VF %d failed to reset\n", vf->vf_num);
425 ixl_disable_rings(pf, &vf->vsi, &vf->qtag);
428 ixl_vf_release_resources(pf, vf);
429 ixl_vf_setup_vsi(pf, vf);
430 ixl_vf_map_queues(pf, vf);
448 ixl_send_vf_msg(struct ixl_pf *pf, struct ixl_vf *vf, uint16_t op,
454 hw = &pf->hw;
457 I40E_VC_DEBUG(pf, ixl_vc_opcode_level(op),
465 ixl_send_vf_ack(struct ixl_pf *pf, struct ixl_vf *vf, uint16_t op)
468 ixl_send_vf_msg(pf, vf, op, I40E_SUCCESS, NULL, 0);
472 ixl_send_vf_nack_msg(struct ixl_pf *pf, struct ixl_vf *vf, uint16_t op,
476 I40E_VC_DEBUG(pf, 1,
478 ixl_vc_opcode_str(op), op, i40e_stat_str(&pf->hw, status),
480 ixl_send_vf_msg(pf, vf, op, status, NULL, 0);
484 ixl_vf_version_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
488 device_t dev = pf->dev;
509 ixl_send_vf_msg(pf, vf, VIRTCHNL_OP_VERSION, I40E_SUCCESS,
514 ixl_vf_reset_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
517 ixl_reset_vf(pf, vf);
523 ixl_vf_get_resources_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
543 reply.max_vectors = pf->hw.func_caps.num_msix_vectors_vf;
551 ixl_send_vf_msg(pf, vf, VIRTCHNL_OP_GET_VF_RESOURCES,
556 ixl_vf_config_tx_queue(struct ixl_pf *pf, struct ixl_vf *vf,
565 hw = &pf->hw;
570 DDPRINTF(pf->dev, "VF %d: PF TX queue %d / VF TX queue %d (Global VF %d)\n",
601 ixl_vf_config_rx_queue(struct ixl_pf *pf, struct ixl_vf *vf,
609 hw = &pf->hw;
613 DDPRINTF(pf->dev, "VF %d: PF RX queue %d / VF RX queue %d\n",
668 ixl_vf_config_vsi_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
677 device_printf(pf->dev, "VF %d: invalid # of qpairs (msg has %d, VSI has %d)\n",
679 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
685 device_printf(pf->dev, "VF %d: VSI id in recvd message (%d) does not match expected id (%d)\n",
687 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
700 i40e_send_vf_nack(pf, vf,
705 if (ixl_vf_config_tx_queue(pf, vf, &pair->txq) != 0) {
706 i40e_send_vf_nack(pf, vf,
711 if (ixl_vf_config_rx_queue(pf, vf, &pair->rxq) != 0) {
712 i40e_send_vf_nack(pf, vf,
718 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_CONFIG_VSI_QUEUES);
722 ixl_vf_set_qctl(struct ixl_pf *pf,
744 wr32(&pf->hw, offset, qctl);
751 ixl_vf_config_vector(struct ixl_pf *pf, struct ixl_vf *vf,
760 hw = &pf->hw;
778 ixl_vf_set_qctl(pf, vector, type, cur_queue,
787 ixl_vf_set_qctl(pf, vector, type, cur_queue,
806 ixl_vf_config_irq_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
814 hw = &pf->hw;
822 i40e_send_vf_nack(pf, vf,
830 i40e_send_vf_nack(pf, vf,
840 i40e_send_vf_nack(pf, vf,
849 i40e_send_vf_nack(pf, vf,
855 ixl_vf_config_vector(pf, vf, vector);
858 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_CONFIG_IRQ_MAP);
862 ixl_vf_enable_queues_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
872 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ENABLE_QUEUES,
882 device_printf(pf->dev, "VF %d: TX ring %d is outside of VF VSI allocation!\n",
891 ixl_dbg_iov(pf, "VF %d: TX ring %d is already enabled!\n",
894 error = ixl_enable_tx_ring(pf, &vf->qtag, i);
907 device_printf(pf->dev, "VF %d: RX ring %d is outside of VF VSI allocation!\n",
916 ixl_dbg_iov(pf, "VF %d: RX ring %d is already enabled!\n",
918 error = ixl_enable_rx_ring(pf, &vf->qtag, i);
927 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ENABLE_QUEUES,
932 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_ENABLE_QUEUES);
936 ixl_vf_disable_queues_msg(struct ixl_pf *pf, struct ixl_vf *vf,
946 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_DISABLE_QUEUES,
956 device_printf(pf->dev, "VF %d: TX ring %d is outside of VF VSI allocation!\n",
965 ixl_dbg_iov(pf, "VF %d: TX ring %d is already disabled!\n",
969 error = ixl_disable_tx_ring(pf, &vf->qtag, i);
982 device_printf(pf->dev, "VF %d: RX ring %d is outside of VF VSI allocation!\n",
991 ixl_dbg_iov(pf, "VF %d: RX ring %d is already disabled!\n",
995 error = ixl_disable_rx_ring(pf, &vf->qtag, i);
1004 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_DISABLE_QUEUES,
1009 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_DISABLE_QUEUES);
1032 ixl_vf_add_mac_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1044 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ADD_ETH_ADDR,
1051 i40e_send_vf_nack(pf, vf,
1062 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_ADD_ETH_ADDR);
1066 ixl_vf_del_mac_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1078 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_DEL_ETH_ADDR,
1086 i40e_send_vf_nack(pf, vf,
1097 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_DEL_ETH_ADDR);
1101 ixl_vf_enable_vlan_strip(struct ixl_pf *pf, struct ixl_vf *vf)
1111 return (i40e_aq_update_vsi_params(&pf->hw, &vsi_ctx, NULL));
1115 ixl_vf_add_vlan_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1125 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ADD_VLAN,
1131 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ADD_VLAN,
1138 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ADD_VLAN,
1144 code = ixl_vf_enable_vlan_strip(pf, vf);
1146 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ADD_VLAN,
1153 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_ADD_VLAN);
1157 ixl_vf_del_vlan_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1166 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_DEL_VLAN,
1173 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ADD_VLAN,
1180 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_ADD_VLAN,
1188 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_DEL_VLAN);
1192 ixl_vf_config_promisc_msg(struct ixl_pf *pf, struct ixl_vf *vf,
1196 struct i40e_hw *hw = &pf->hw;
1203 ixl_send_vf_ack(pf, vf,
1210 i40e_send_vf_nack(pf, vf,
1218 device_printf(pf->dev, "i40e_aq_set_vsi_unicast_promiscuous (seid %d) failed: status %s,"
1221 i40e_send_vf_nack(pf, vf,
1229 device_printf(pf->dev, "i40e_aq_set_vsi_multicast_promiscuous (seid %d) failed: status %s,"
1232 i40e_send_vf_nack(pf, vf,
1237 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE);
1241 ixl_vf_get_stats_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1248 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_GET_STATS,
1255 ixl_send_vf_msg(pf, vf, VIRTCHNL_OP_GET_STATS,
1260 ixl_vf_config_rss_key_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1268 hw = &pf->hw;
1273 device_printf(pf->dev, "VF %d: Key size in msg (%d) is greater than max key size (%d)\n",
1275 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_KEY,
1281 device_printf(pf->dev, "VF %d: VSI id in recvd message (%d) does not match expected id (%d)\n",
1283 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_KEY,
1299 device_printf(pf->dev, "i40e_aq_set_rss_key status %s, error %s\n",
1301 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_KEY,
1310 DDPRINTF(pf->dev, "VF %d: Programmed key starting with 0x%x ok!",
1313 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_KEY);
1317 ixl_vf_config_rss_lut_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1324 hw = &pf->hw;
1329 device_printf(pf->dev, "VF %d: # of LUT entries in msg (%d) is greater than max (%d)\n",
1331 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_LUT,
1337 device_printf(pf->dev, "VF %d: VSI id in recvd message (%d) does not match expected id (%d)\n",
1339 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_LUT,
1348 device_printf(pf->dev, "i40e_aq_set_rss_lut status %s, error %s\n",
1350 i40e_send_vf_nack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_LUT,
1359 DDPRINTF(pf->dev, "VF %d: Programmed LUT starting with 0x%x and length %d ok!",
1362 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_CONFIG_RSS_LUT);
1366 ixl_vf_set_rss_hena_msg(struct ixl_pf *pf, struct ixl_vf *vf, void *msg,
1372 hw = &pf->hw;
1379 DDPRINTF(pf->dev, "VF %d: Programmed HENA with 0x%016lx",
1382 ixl_send_vf_ack(pf, vf, VIRTCHNL_OP_SET_RSS_HENA);
1386 ixl_notify_vf_link_state(struct ixl_pf *pf, struct ixl_vf *vf)
1391 hw = &pf->hw;
1394 event.event_data.link_event.link_status = pf->vsi.link_active;
1398 ixl_send_vf_msg(pf, vf, VIRTCHNL_OP_EVENT, I40E_SUCCESS, &event,
1403 ixl_broadcast_link_state(struct ixl_pf *pf)
1407 for (i = 0; i < pf->num_vfs; i++)
1408 ixl_notify_vf_link_state(pf, &pf->vfs[i]);
1412 ixl_handle_vf_msg(struct ixl_pf *pf, struct i40e_arq_event_info *event)
1414 device_t dev = pf->dev;
1421 vf_num = le16toh(event->desc.retval) - pf->hw.func_caps.vf_base_id;
1424 if (vf_num >= pf->num_vfs) {
1425 device_printf(pf->dev, "Got msg from illegal VF: %d\n", vf_num);
1429 vf = &pf->vfs[vf_num];
1433 I40E_VC_DEBUG(pf, ixl_vc_opcode_level(opcode),
1444 i40e_send_vf_nack(pf, vf, opcode, I40E_ERR_PARAM);
1454 ixl_vf_version_msg(pf, vf, msg, msg_size);
1457 ixl_vf_reset_msg(pf, vf, msg, msg_size);
1460 ixl_vf_get_resources_msg(pf, vf, msg, msg_size);
1464 ixl_notify_vf_link_state(pf, vf);
1467 ixl_vf_config_vsi_msg(pf, vf, msg, msg_size);
1470 ixl_vf_config_irq_msg(pf, vf, msg, msg_size);
1473 ixl_vf_enable_queues_msg(pf, vf, msg, msg_size);
1477 ixl_notify_vf_link_state(pf, vf);
1480 ixl_vf_disable_queues_msg(pf, vf, msg, msg_size);
1483 ixl_vf_add_mac_msg(pf, vf, msg, msg_size);
1486 ixl_vf_del_mac_msg(pf, vf, msg, msg_size);
1489 ixl_vf_add_vlan_msg(pf, vf, msg, msg_size);
1492 ixl_vf_del_vlan_msg(pf, vf, msg, msg_size);
1495 ixl_vf_config_promisc_msg(pf, vf, msg, msg_size);
1498 ixl_vf_get_stats_msg(pf, vf, msg, msg_size);
1501 ixl_vf_config_rss_key_msg(pf, vf, msg, msg_size);
1504 ixl_vf_config_rss_lut_msg(pf, vf, msg, msg_size);
1507 ixl_vf_set_rss_hena_msg(pf, vf, msg, msg_size);
1514 i40e_send_vf_nack(pf, vf, opcode, I40E_ERR_NOT_IMPLEMENTED);
1521 ixl_handle_vflr(struct ixl_pf *pf)
1529 hw = &pf->hw;
1531 ixl_dbg_iov(pf, "%s: begin\n", __func__);
1540 for (i = 0; i < pf->num_vfs; i++) {
1543 vf = &pf->vfs[i];
1554 ixl_dbg_iov(pf, "Reinitializing VF-%d\n", i);
1555 ixl_reinit_vf(pf, vf);
1556 ixl_dbg_iov(pf, "Reinitializing VF-%d done\n", i);
1617 ixl_config_pf_vsi_loopback(struct ixl_pf *pf, bool enable)
1619 struct i40e_hw *hw = &pf->hw;
1620 device_t dev = pf->dev;
1621 struct ixl_vsi *vsi = &pf->vsi;
1628 if (pf->veb_seid != 0)
1629 ctxt.uplink_seid = pf->veb_seid;
1650 struct ixl_pf *pf = iflib_get_softc(ctx);
1657 hw = &pf->hw;
1658 pf_vsi = &pf->vsi;
1660 pf->vfs = malloc(sizeof(struct ixl_vf) * num_vfs, M_IXL, M_NOWAIT |
1662 if (pf->vfs == NULL) {
1673 1, FALSE, &pf->veb_seid, FALSE, NULL);
1680 if (pf->enable_vf_loopback)
1681 ixl_config_pf_vsi_loopback(pf, true);
1690 pf->num_vfs = num_vfs;
1694 free(pf->vfs, M_IXL);
1695 pf->vfs = NULL;
1702 struct ixl_pf *pf = iflib_get_softc(ctx);
1707 hw = &pf->hw;
1709 for (i = 0; i < pf->num_vfs; i++) {
1710 if (pf->vfs[i].vsi.seid != 0)
1711 i40e_aq_delete_element(hw, pf->vfs[i].vsi.seid, NULL);
1712 ixl_pf_qmgr_release(&pf->qmgr, &pf->vfs[i].qtag);
1713 ixl_free_filters(&pf->vfs[i].vsi.ftl);
1714 ixl_dbg_iov(pf, "VF %d: %d released\n",
1715 i, pf->vfs[i].qtag.num_allocated);
1716 ixl_dbg_iov(pf, "Unallocated total: %d\n", ixl_pf_qmgr_get_num_free(&pf->qmgr));
1719 if (pf->veb_seid != 0) {
1720 i40e_aq_delete_element(hw, pf->veb_seid, NULL);
1721 pf->veb_seid = 0;
1724 if (pf->enable_vf_loopback)
1725 ixl_config_pf_vsi_loopback(pf, false);
1727 vfs = pf->vfs;
1728 num_vfs = pf->num_vfs;
1730 pf->vfs = NULL;
1731 pf->num_vfs = 0;
1740 ixl_vf_reserve_queues(struct ixl_pf *pf, struct ixl_vf *vf, int num_queues)
1742 device_t dev = pf->dev;
1756 error = ixl_pf_qmgr_alloc_scattered(&pf->qmgr, num_queues, &vf->qtag);
1763 ixl_dbg_iov(pf, "VF %d: %d allocated, %d active\n",
1765 ixl_dbg_iov(pf, "Unallocated total: %d\n", ixl_pf_qmgr_get_num_free(&pf->qmgr));
1773 struct ixl_pf *pf = iflib_get_softc(ctx);
1781 vf = &pf->vfs[vfnum];
1783 vf->vsi.back = pf;
1788 error = ixl_vf_reserve_queues(pf, vf, vf_num_queues);
1792 error = ixl_vf_setup_vsi(pf, vf);
1818 ixl_reset_vf(pf, vf);