Lines Matching refs:pfvf
15 static int otx2_mcam_entry_init(struct otx2_nic *pfvf);
35 static void otx2_clear_ntuple_flow_info(struct otx2_nic *pfvf, struct otx2_flow_config *flow_cfg) in otx2_clear_ntuple_flow_info() argument
37 devm_kfree(pfvf->dev, flow_cfg->flow_ent); in otx2_clear_ntuple_flow_info()
42 static int otx2_free_ntuple_mcam_entries(struct otx2_nic *pfvf) in otx2_free_ntuple_mcam_entries() argument
44 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_free_ntuple_mcam_entries()
51 mutex_lock(&pfvf->mbox.lock); in otx2_free_ntuple_mcam_entries()
53 req = otx2_mbox_alloc_msg_npc_mcam_free_entry(&pfvf->mbox); in otx2_free_ntuple_mcam_entries()
60 err = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_free_ntuple_mcam_entries()
64 mutex_unlock(&pfvf->mbox.lock); in otx2_free_ntuple_mcam_entries()
65 otx2_clear_ntuple_flow_info(pfvf, flow_cfg); in otx2_free_ntuple_mcam_entries()
74 int otx2_alloc_mcam_entries(struct otx2_nic *pfvf, u16 count) in otx2_alloc_mcam_entries() argument
76 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_alloc_mcam_entries()
82 otx2_free_ntuple_mcam_entries(pfvf); in otx2_alloc_mcam_entries()
87 flow_cfg->flow_ent = devm_kmalloc_array(pfvf->dev, count, in otx2_alloc_mcam_entries()
90 netdev_err(pfvf->netdev, in otx2_alloc_mcam_entries()
96 mutex_lock(&pfvf->mbox.lock); in otx2_alloc_mcam_entries()
102 req = otx2_mbox_alloc_msg_npc_mcam_alloc_entry(&pfvf->mbox); in otx2_alloc_mcam_entries()
113 if (!is_otx2_vf(pfvf->pcifunc)) { in otx2_alloc_mcam_entries()
119 if (otx2_sync_mbox_msg(&pfvf->mbox)) in otx2_alloc_mcam_entries()
123 (&pfvf->mbox.mbox, 0, &req->hdr); in otx2_alloc_mcam_entries()
147 mutex_unlock(&pfvf->mbox.lock); in otx2_alloc_mcam_entries()
152 pfvf->flags |= OTX2_FLAG_MCAM_ENTRIES_ALLOC; in otx2_alloc_mcam_entries()
153 pfvf->flags |= OTX2_FLAG_NTUPLE_SUPPORT; in otx2_alloc_mcam_entries()
157 netdev_info(pfvf->netdev, in otx2_alloc_mcam_entries()
164 static int otx2_mcam_entry_init(struct otx2_nic *pfvf) in otx2_mcam_entry_init() argument
166 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_mcam_entry_init()
174 vf_vlan_max_flows = pfvf->total_vfs * OTX2_PER_VF_VLAN_FLOWS; in otx2_mcam_entry_init()
178 flow_cfg->def_ent = devm_kmalloc_array(pfvf->dev, count, in otx2_mcam_entry_init()
183 mutex_lock(&pfvf->mbox.lock); in otx2_mcam_entry_init()
185 req = otx2_mbox_alloc_msg_npc_mcam_alloc_entry(&pfvf->mbox); in otx2_mcam_entry_init()
187 mutex_unlock(&pfvf->mbox.lock); in otx2_mcam_entry_init()
195 if (otx2_sync_mbox_msg(&pfvf->mbox)) { in otx2_mcam_entry_init()
196 mutex_unlock(&pfvf->mbox.lock); in otx2_mcam_entry_init()
201 (&pfvf->mbox.mbox, 0, &req->hdr); in otx2_mcam_entry_init()
204 netdev_info(pfvf->netdev, in otx2_mcam_entry_init()
206 mutex_unlock(&pfvf->mbox.lock); in otx2_mcam_entry_init()
207 devm_kfree(pfvf->dev, flow_cfg->def_ent); in otx2_mcam_entry_init()
218 pfvf->flags |= OTX2_FLAG_UCAST_FLTR_SUPPORT; in otx2_mcam_entry_init()
223 freq = otx2_mbox_alloc_msg_npc_get_field_status(&pfvf->mbox); in otx2_mcam_entry_init()
225 mutex_unlock(&pfvf->mbox.lock); in otx2_mcam_entry_init()
230 if (otx2_sync_mbox_msg(&pfvf->mbox)) { in otx2_mcam_entry_init()
231 mutex_unlock(&pfvf->mbox.lock); in otx2_mcam_entry_init()
236 (&pfvf->mbox.mbox, 0, &freq->hdr); in otx2_mcam_entry_init()
239 pfvf->flags |= OTX2_FLAG_RX_VLAN_SUPPORT; in otx2_mcam_entry_init()
240 pfvf->flags |= OTX2_FLAG_VF_VLAN_SUPPORT; in otx2_mcam_entry_init()
243 pfvf->flags |= OTX2_FLAG_MCAM_ENTRIES_ALLOC; in otx2_mcam_entry_init()
244 mutex_unlock(&pfvf->mbox.lock); in otx2_mcam_entry_init()
247 count = otx2_alloc_mcam_entries(pfvf, OTX2_DEFAULT_FLOWCOUNT); in otx2_mcam_entry_init()
249 otx2_clear_ntuple_flow_info(pfvf, flow_cfg); in otx2_mcam_entry_init()
253 pfvf->flags |= OTX2_FLAG_TC_FLOWER_SUPPORT; in otx2_mcam_entry_init()
261 int otx2vf_mcam_flow_init(struct otx2_nic *pfvf) in otx2vf_mcam_flow_init() argument
265 pfvf->flow_cfg = devm_kzalloc(pfvf->dev, in otx2vf_mcam_flow_init()
268 if (!pfvf->flow_cfg) in otx2vf_mcam_flow_init()
271 pfvf->flow_cfg->dmacflt_bmap = devm_kcalloc(pfvf->dev, in otx2vf_mcam_flow_init()
274 if (!pfvf->flow_cfg->dmacflt_bmap) in otx2vf_mcam_flow_init()
277 flow_cfg = pfvf->flow_cfg; in otx2vf_mcam_flow_init()
449 static struct otx2_flow *otx2_find_flow(struct otx2_nic *pfvf, u32 location) in otx2_find_flow() argument
453 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) { in otx2_find_flow()
461 static void otx2_add_flow_to_list(struct otx2_nic *pfvf, struct otx2_flow *flow) in otx2_add_flow_to_list() argument
463 struct list_head *head = &pfvf->flow_cfg->flow_list; in otx2_add_flow_to_list()
466 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) { in otx2_add_flow_to_list()
489 int otx2_get_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc, in otx2_get_flow() argument
494 if (location >= otx2_get_maxflows(pfvf->flow_cfg)) in otx2_get_flow()
497 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) { in otx2_get_flow()
508 int otx2_get_all_flows(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc, in otx2_get_all_flows() argument
516 nfc->data = otx2_get_maxflows(pfvf->flow_cfg); in otx2_get_all_flows()
518 err = otx2_get_flow(pfvf, nfc, location); in otx2_get_all_flows()
940 static int otx2_is_flow_rule_dmacfilter(struct otx2_nic *pfvf, in otx2_is_flow_rule_dmacfilter() argument
948 if (!(pfvf->flags & OTX2_FLAG_DMACFLTR_SUPPORT)) in otx2_is_flow_rule_dmacfilter()
966 static int otx2_add_flow_msg(struct otx2_nic *pfvf, struct otx2_flow *flow) in otx2_add_flow_msg() argument
975 mutex_lock(&pfvf->mbox.lock); in otx2_add_flow_msg()
976 req = otx2_mbox_alloc_msg_npc_install_flow(&pfvf->mbox); in otx2_add_flow_msg()
978 mutex_unlock(&pfvf->mbox.lock); in otx2_add_flow_msg()
985 otx2_mbox_reset(&pfvf->mbox.mbox, 0); in otx2_add_flow_msg()
986 mutex_unlock(&pfvf->mbox.lock); in otx2_add_flow_msg()
993 req->channel = pfvf->hw.rx_chan_base; in otx2_add_flow_msg()
1003 req->flow_key_alg = pfvf->hw.flowkey_alg_idx; in otx2_add_flow_msg()
1009 if (vf > pci_num_vf(pfvf->pdev)) { in otx2_add_flow_msg()
1010 mutex_unlock(&pfvf->mbox.lock); in otx2_add_flow_msg()
1017 pfvf->pfc_en && req->op != NIX_RX_ACTIONOP_RSS) { in otx2_add_flow_msg()
1025 if (pfvf->pfc_en & BIT(vlan_prio)) { in otx2_add_flow_msg()
1041 err = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_add_flow_msg()
1045 otx2_update_bpid_in_rqctx(pfvf, vlan_prio, qidx, true); in otx2_add_flow_msg()
1048 mutex_unlock(&pfvf->mbox.lock); in otx2_add_flow_msg()
1052 static int otx2_add_flow_with_pfmac(struct otx2_nic *pfvf, in otx2_add_flow_with_pfmac() argument
1064 pf_mac->location = pfvf->flow_cfg->max_flows; in otx2_add_flow_with_pfmac()
1071 ether_addr_copy(eth_hdr->h_dest, pfvf->netdev->dev_addr); in otx2_add_flow_with_pfmac()
1074 otx2_dmacflt_add(pfvf, eth_hdr->h_dest, 0); in otx2_add_flow_with_pfmac()
1076 otx2_add_flow_to_list(pfvf, pf_mac); in otx2_add_flow_with_pfmac()
1077 pfvf->flow_cfg->nr_flows++; in otx2_add_flow_with_pfmac()
1078 set_bit(0, pfvf->flow_cfg->dmacflt_bmap); in otx2_add_flow_with_pfmac()
1083 int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc) in otx2_add_flow() argument
1085 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_add_flow()
1095 netdev_err(pfvf->netdev, in otx2_add_flow()
1101 if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT)) in otx2_add_flow()
1117 if (!is_otx2_vf(pfvf->pcifunc) && !vf_num && in otx2_add_flow()
1118 ring >= pfvf->hw.rx_queues && fsp->ring_cookie != RX_CLS_FLOW_DISC) in otx2_add_flow()
1124 flow = otx2_find_flow(pfvf, fsp->location); in otx2_add_flow()
1139 if (otx2_is_flow_rule_dmacfilter(pfvf, &flow->flow_spec)) { in otx2_add_flow()
1144 return otx2_dmacflt_update(pfvf, eth_hdr->h_dest, in otx2_add_flow()
1149 netdev_warn(pfvf->netdev, in otx2_add_flow()
1162 otx2_add_flow_with_pfmac(pfvf, flow); in otx2_add_flow()
1172 otx2_dmacflt_add(pfvf, eth_hdr->h_dest, flow->entry); in otx2_add_flow()
1175 if (flow->location >= pfvf->flow_cfg->max_flows) { in otx2_add_flow()
1176 netdev_warn(pfvf->netdev, in otx2_add_flow()
1182 err = otx2_add_flow_msg(pfvf, flow); in otx2_add_flow()
1196 otx2_add_flow_to_list(pfvf, flow); in otx2_add_flow()
1201 netdev_info(pfvf->netdev, in otx2_add_flow()
1206 static int otx2_remove_flow_msg(struct otx2_nic *pfvf, u16 entry, bool all) in otx2_remove_flow_msg() argument
1211 mutex_lock(&pfvf->mbox.lock); in otx2_remove_flow_msg()
1212 req = otx2_mbox_alloc_msg_npc_delete_flow(&pfvf->mbox); in otx2_remove_flow_msg()
1214 mutex_unlock(&pfvf->mbox.lock); in otx2_remove_flow_msg()
1223 err = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_remove_flow_msg()
1224 mutex_unlock(&pfvf->mbox.lock); in otx2_remove_flow_msg()
1228 static void otx2_update_rem_pfmac(struct otx2_nic *pfvf, int req) in otx2_update_rem_pfmac() argument
1234 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) { in otx2_update_rem_pfmac()
1238 otx2_dmacflt_remove(pfvf, eth_hdr->h_dest, in otx2_update_rem_pfmac()
1240 clear_bit(0, pfvf->flow_cfg->dmacflt_bmap); in otx2_update_rem_pfmac()
1244 pfvf->netdev->dev_addr); in otx2_update_rem_pfmac()
1246 otx2_dmacflt_update(pfvf, eth_hdr->h_dest, 0); in otx2_update_rem_pfmac()
1255 pfvf->flow_cfg->nr_flows--; in otx2_update_rem_pfmac()
1259 int otx2_remove_flow(struct otx2_nic *pfvf, u32 location) in otx2_remove_flow() argument
1261 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_remove_flow()
1268 flow = otx2_find_flow(pfvf, location); in otx2_remove_flow()
1276 if (ether_addr_equal(pfvf->netdev->dev_addr, eth_hdr->h_dest)) in otx2_remove_flow()
1279 err = otx2_dmacflt_remove(pfvf, eth_hdr->h_dest, in otx2_remove_flow()
1288 otx2_update_rem_pfmac(pfvf, DMAC_ADDR_DEL); in otx2_remove_flow()
1292 otx2_update_bpid_in_rqctx(pfvf, 0, in otx2_remove_flow()
1297 err = otx2_remove_flow_msg(pfvf, flow->entry, false); in otx2_remove_flow()
1310 void otx2_rss_ctx_flow_del(struct otx2_nic *pfvf, int ctx_id) in otx2_rss_ctx_flow_del() argument
1315 list_for_each_entry_safe(flow, tmp, &pfvf->flow_cfg->flow_list, list) { in otx2_rss_ctx_flow_del()
1318 err = otx2_remove_flow(pfvf, flow->location); in otx2_rss_ctx_flow_del()
1320 netdev_warn(pfvf->netdev, in otx2_rss_ctx_flow_del()
1326 int otx2_destroy_ntuple_flows(struct otx2_nic *pfvf) in otx2_destroy_ntuple_flows() argument
1328 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_destroy_ntuple_flows()
1333 if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT)) in otx2_destroy_ntuple_flows()
1339 mutex_lock(&pfvf->mbox.lock); in otx2_destroy_ntuple_flows()
1340 req = otx2_mbox_alloc_msg_npc_delete_flow(&pfvf->mbox); in otx2_destroy_ntuple_flows()
1342 mutex_unlock(&pfvf->mbox.lock); in otx2_destroy_ntuple_flows()
1348 err = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_destroy_ntuple_flows()
1349 mutex_unlock(&pfvf->mbox.lock); in otx2_destroy_ntuple_flows()
1359 int otx2_destroy_mcam_flows(struct otx2_nic *pfvf) in otx2_destroy_mcam_flows() argument
1361 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_destroy_mcam_flows()
1366 if (!(pfvf->flags & OTX2_FLAG_MCAM_ENTRIES_ALLOC)) in otx2_destroy_mcam_flows()
1370 err = otx2_remove_flow_msg(pfvf, 0, true); in otx2_destroy_mcam_flows()
1380 mutex_lock(&pfvf->mbox.lock); in otx2_destroy_mcam_flows()
1381 req = otx2_mbox_alloc_msg_npc_mcam_free_entry(&pfvf->mbox); in otx2_destroy_mcam_flows()
1383 mutex_unlock(&pfvf->mbox.lock); in otx2_destroy_mcam_flows()
1389 err = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_destroy_mcam_flows()
1391 mutex_unlock(&pfvf->mbox.lock); in otx2_destroy_mcam_flows()
1395 pfvf->flags &= ~OTX2_FLAG_MCAM_ENTRIES_ALLOC; in otx2_destroy_mcam_flows()
1396 mutex_unlock(&pfvf->mbox.lock); in otx2_destroy_mcam_flows()
1401 int otx2_install_rxvlan_offload_flow(struct otx2_nic *pfvf) in otx2_install_rxvlan_offload_flow() argument
1403 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_install_rxvlan_offload_flow()
1407 mutex_lock(&pfvf->mbox.lock); in otx2_install_rxvlan_offload_flow()
1408 req = otx2_mbox_alloc_msg_npc_install_flow(&pfvf->mbox); in otx2_install_rxvlan_offload_flow()
1410 mutex_unlock(&pfvf->mbox.lock); in otx2_install_rxvlan_offload_flow()
1416 ether_addr_copy(req->packet.dmac, pfvf->netdev->dev_addr); in otx2_install_rxvlan_offload_flow()
1418 req->channel = pfvf->hw.rx_chan_base; in otx2_install_rxvlan_offload_flow()
1425 err = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_install_rxvlan_offload_flow()
1426 mutex_unlock(&pfvf->mbox.lock); in otx2_install_rxvlan_offload_flow()
1430 static int otx2_delete_rxvlan_offload_flow(struct otx2_nic *pfvf) in otx2_delete_rxvlan_offload_flow() argument
1432 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; in otx2_delete_rxvlan_offload_flow()
1436 mutex_lock(&pfvf->mbox.lock); in otx2_delete_rxvlan_offload_flow()
1437 req = otx2_mbox_alloc_msg_npc_delete_flow(&pfvf->mbox); in otx2_delete_rxvlan_offload_flow()
1439 mutex_unlock(&pfvf->mbox.lock); in otx2_delete_rxvlan_offload_flow()
1445 err = otx2_sync_mbox_msg(&pfvf->mbox); in otx2_delete_rxvlan_offload_flow()
1446 mutex_unlock(&pfvf->mbox.lock); in otx2_delete_rxvlan_offload_flow()
1514 void otx2_dmacflt_update_pfmac_flow(struct otx2_nic *pfvf) in otx2_dmacflt_update_pfmac_flow() argument
1516 otx2_update_rem_pfmac(pfvf, DMAC_ADDR_UPDATE); in otx2_dmacflt_update_pfmac_flow()