Lines Matching full:nic
58 static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst, in otx2_get_egress_burst_cfg() argument
64 if (is_dev_otx2(nic->pdev)) { in otx2_get_egress_burst_cfg()
122 u64 otx2_get_txschq_rate_regval(struct otx2_nic *nic, in otx2_get_txschq_rate_regval() argument
130 otx2_get_egress_burst_cfg(nic, burst, &burst_exp, &burst_mantissa); in otx2_get_txschq_rate_regval()
133 if (is_dev_otx2(nic->pdev)) { in otx2_get_txschq_rate_regval()
150 static int otx2_set_matchall_egress_rate(struct otx2_nic *nic, in otx2_set_matchall_egress_rate() argument
153 struct otx2_hw *hw = &nic->hw; in otx2_set_matchall_egress_rate()
160 mutex_lock(&nic->mbox.lock); in otx2_set_matchall_egress_rate()
161 req = otx2_mbox_alloc_msg_nix_txschq_cfg(&nic->mbox); in otx2_set_matchall_egress_rate()
163 mutex_unlock(&nic->mbox.lock); in otx2_set_matchall_egress_rate()
170 req->regval[0] = otx2_get_txschq_rate_regval(nic, maxrate, burst); in otx2_set_matchall_egress_rate()
172 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_set_matchall_egress_rate()
173 mutex_unlock(&nic->mbox.lock); in otx2_set_matchall_egress_rate()
177 static int otx2_tc_validate_flow(struct otx2_nic *nic, in otx2_tc_validate_flow() argument
181 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_validate_flow()
233 static int otx2_tc_egress_matchall_install(struct otx2_nic *nic, in otx2_tc_egress_matchall_install() argument
241 err = otx2_tc_validate_flow(nic, actions, extack); in otx2_tc_egress_matchall_install()
245 if (nic->flags & OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED) { in otx2_tc_egress_matchall_install()
262 err = otx2_set_matchall_egress_rate(nic, entry->police.burst, in otx2_tc_egress_matchall_install()
266 nic->flags |= OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED; in otx2_tc_egress_matchall_install()
277 static int otx2_tc_egress_matchall_delete(struct otx2_nic *nic, in otx2_tc_egress_matchall_delete() argument
283 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_egress_matchall_delete()
288 err = otx2_set_matchall_egress_rate(nic, 0, 0); in otx2_tc_egress_matchall_delete()
289 nic->flags &= ~OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED; in otx2_tc_egress_matchall_delete()
293 static int otx2_tc_act_set_hw_police(struct otx2_nic *nic, in otx2_tc_act_set_hw_police() argument
298 mutex_lock(&nic->mbox.lock); in otx2_tc_act_set_hw_police()
300 rc = cn10k_alloc_leaf_profile(nic, &node->leaf_profile); in otx2_tc_act_set_hw_police()
302 mutex_unlock(&nic->mbox.lock); in otx2_tc_act_set_hw_police()
306 rc = cn10k_set_ipolicer_rate(nic, node->leaf_profile, in otx2_tc_act_set_hw_police()
311 rc = cn10k_map_unmap_rq_policer(nic, node->rq, node->leaf_profile, true); in otx2_tc_act_set_hw_police()
315 mutex_unlock(&nic->mbox.lock); in otx2_tc_act_set_hw_police()
320 if (cn10k_free_leaf_profile(nic, node->leaf_profile)) in otx2_tc_act_set_hw_police()
321 netdev_err(nic->netdev, in otx2_tc_act_set_hw_police()
324 mutex_unlock(&nic->mbox.lock); in otx2_tc_act_set_hw_police()
328 static int otx2_tc_act_set_police(struct otx2_nic *nic, in otx2_tc_act_set_police() argument
335 struct otx2_hw *hw = &nic->hw; in otx2_tc_act_set_police()
338 rq_idx = find_first_zero_bit(&nic->rq_bmap, hw->rx_queues); in otx2_tc_act_set_police()
354 rc = otx2_tc_act_set_hw_police(nic, node); in otx2_tc_act_set_police()
356 set_bit(rq_idx, &nic->rq_bmap); in otx2_tc_act_set_police()
361 static int otx2_tc_update_mcast(struct otx2_nic *nic, in otx2_tc_update_mcast() argument
374 mutex_lock(&nic->mbox.lock); in otx2_tc_update_mcast()
375 creq = otx2_mbox_alloc_msg_nix_mcast_grp_create(&nic->mbox); in otx2_tc_update_mcast()
383 rc = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_update_mcast()
389 crsp = (struct nix_mcast_grp_create_rsp *)otx2_mbox_get_rsp(&nic->mbox.mbox, in otx2_tc_update_mcast()
398 grp_update_req = otx2_mbox_alloc_msg_nix_mcast_grp_update(&nic->mbox); in otx2_tc_update_mcast()
408 ureq->pcifunc[0] = nic->pcifunc; in otx2_tc_update_mcast()
409 ureq->channel[0] = nic->hw.tx_chan_base; in otx2_tc_update_mcast()
417 rc = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_update_mcast()
423 mutex_unlock(&nic->mbox.lock); in otx2_tc_update_mcast()
430 mutex_unlock(&nic->mbox.lock); in otx2_tc_update_mcast()
434 static int otx2_tc_parse_actions(struct otx2_nic *nic, in otx2_tc_parse_actions() argument
470 if (rvu_get_pf(nic->pcifunc) != rvu_get_pf(priv->pcifunc)) { in otx2_tc_parse_actions()
493 if (is_dev_otx2(nic->pdev)) { in otx2_tc_parse_actions()
526 nic->flags |= OTX2_FLAG_TC_MARK_ENABLED; in otx2_tc_parse_actions()
527 refcount_inc(&nic->flow_cfg->mark_flows); in otx2_tc_parse_actions()
552 err = otx2_tc_update_mcast(nic, req, extack, node, in otx2_tc_parse_actions()
566 return otx2_tc_act_set_police(nic, node, f, rate, burst, in otx2_tc_parse_actions()
572 static int otx2_tc_process_vlan(struct otx2_nic *nic, struct flow_msg *flow_spec, in otx2_tc_process_vlan() argument
585 netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n", in otx2_tc_process_vlan()
596 netdev_err(nic->netdev, in otx2_tc_process_vlan()
628 static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node, in otx2_tc_prepare_flow() argument
656 netdev_info(nic->netdev, "unsupported flow used key 0x%llx", in otx2_tc_prepare_flow()
679 netdev_info(nic->netdev, in otx2_tc_prepare_flow()
789 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, false); in otx2_tc_prepare_flow()
797 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, true); in otx2_tc_prepare_flow()
955 return otx2_tc_parse_actions(nic, &rule->action, req, f, node); in otx2_tc_prepare_flow()
1040 static int otx2_add_mcam_flow_entry(struct otx2_nic *nic, struct npc_install_flow_req *req) in otx2_add_mcam_flow_entry() argument
1045 mutex_lock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1046 tmp_req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_add_mcam_flow_entry()
1048 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1054 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_add_mcam_flow_entry()
1056 netdev_err(nic->netdev, "Failed to install MCAM flow entry %d\n", in otx2_add_mcam_flow_entry()
1058 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1062 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1066 static int otx2_del_mcam_flow_entry(struct otx2_nic *nic, u16 entry, u16 *cntr_val) in otx2_del_mcam_flow_entry() argument
1072 mutex_lock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1073 req = otx2_mbox_alloc_msg_npc_delete_flow(&nic->mbox); in otx2_del_mcam_flow_entry()
1075 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1082 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_del_mcam_flow_entry()
1084 netdev_err(nic->netdev, "Failed to delete MCAM flow entry %d\n", in otx2_del_mcam_flow_entry()
1086 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1091 rsp = (struct npc_delete_flow_rsp *)otx2_mbox_get_rsp(&nic->mbox.mbox, in otx2_del_mcam_flow_entry()
1094 netdev_err(nic->netdev, "Failed to get MCAM delete response for entry %d\n", in otx2_del_mcam_flow_entry()
1096 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1103 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1107 static int otx2_tc_update_mcam_table_del_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_del_req() argument
1127 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_del_req()
1139 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_del_req()
1146 static int otx2_tc_update_mcam_table_add_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_add_req() argument
1166 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_add_req()
1170 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_add_req()
1177 static int otx2_tc_update_mcam_table(struct otx2_nic *nic, in otx2_tc_update_mcam_table() argument
1183 return otx2_tc_update_mcam_table_add_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1185 return otx2_tc_update_mcam_table_del_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1188 static int otx2_tc_del_flow(struct otx2_nic *nic, in otx2_tc_del_flow() argument
1191 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_del_flow()
1198 netdev_err(nic->netdev, "tc flow not found for cookie 0x%lx\n", in otx2_tc_del_flow()
1206 nic->flags &= ~OTX2_FLAG_TC_MARK_ENABLED; in otx2_tc_del_flow()
1209 __clear_bit(flow_node->rq, &nic->rq_bmap); in otx2_tc_del_flow()
1211 if (nic->flags & OTX2_FLAG_INTF_DOWN) in otx2_tc_del_flow()
1214 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1216 err = cn10k_map_unmap_rq_policer(nic, flow_node->rq, in otx2_tc_del_flow()
1219 netdev_err(nic->netdev, in otx2_tc_del_flow()
1223 err = cn10k_free_leaf_profile(nic, flow_node->leaf_profile); in otx2_tc_del_flow()
1225 netdev_err(nic->netdev, in otx2_tc_del_flow()
1229 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1233 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1234 grp_destroy_req = otx2_mbox_alloc_msg_nix_mcast_grp_destroy(&nic->mbox); in otx2_tc_del_flow()
1236 otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_del_flow()
1237 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1242 otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL); in otx2_tc_del_flow()
1243 otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false); in otx2_tc_del_flow()
1249 static int otx2_tc_add_flow(struct otx2_nic *nic, in otx2_tc_add_flow() argument
1253 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_add_flow()
1258 if (!(nic->flags & OTX2_FLAG_TC_FLOWER_SUPPORT)) in otx2_tc_add_flow()
1261 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_add_flow()
1283 rc = otx2_tc_prepare_flow(nic, new_node, tc_flow_cmd, &dummy); in otx2_tc_add_flow()
1292 otx2_tc_del_flow(nic, tc_flow_cmd); in otx2_tc_add_flow()
1294 mcam_idx = otx2_tc_update_mcam_table(nic, flow_cfg, new_node, true); in otx2_tc_add_flow()
1295 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
1296 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_add_flow()
1298 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1305 req->channel = nic->hw.rx_chan_base; in otx2_tc_add_flow()
1308 req->vf = nic->pcifunc; in otx2_tc_add_flow()
1313 rc = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_add_flow()
1316 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1320 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1330 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
1332 err = cn10k_map_unmap_rq_policer(nic, new_node->rq, in otx2_tc_add_flow()
1335 netdev_err(nic->netdev, in otx2_tc_add_flow()
1338 err = cn10k_free_leaf_profile(nic, new_node->leaf_profile); in otx2_tc_add_flow()
1340 netdev_err(nic->netdev, in otx2_tc_add_flow()
1344 __clear_bit(new_node->rq, &nic->rq_bmap); in otx2_tc_add_flow()
1346 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1352 static int otx2_tc_get_flow_stats(struct otx2_nic *nic, in otx2_tc_get_flow_stats() argument
1361 flow_node = otx2_tc_get_entry_by_cookie(nic->flow_cfg, tc_flow_cmd->cookie); in otx2_tc_get_flow_stats()
1363 netdev_info(nic->netdev, "tc flow not found for cookie %lx", in otx2_tc_get_flow_stats()
1368 mutex_lock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1370 req = otx2_mbox_alloc_msg_npc_mcam_entry_stats(&nic->mbox); in otx2_tc_get_flow_stats()
1372 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1378 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_get_flow_stats()
1380 netdev_err(nic->netdev, "Failed to get stats for MCAM flow entry %d\n", in otx2_tc_get_flow_stats()
1382 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1387 (&nic->mbox.mbox, 0, &req->hdr); in otx2_tc_get_flow_stats()
1389 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1393 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1409 int otx2_setup_tc_cls_flower(struct otx2_nic *nic, in otx2_setup_tc_cls_flower() argument
1414 return otx2_tc_add_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1416 return otx2_tc_del_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1418 return otx2_tc_get_flow_stats(nic, cls_flower); in otx2_setup_tc_cls_flower()
1425 static int otx2_tc_ingress_matchall_install(struct otx2_nic *nic, in otx2_tc_ingress_matchall_install() argument
1434 err = otx2_tc_validate_flow(nic, actions, extack); in otx2_tc_ingress_matchall_install()
1438 if (nic->flags & OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED) { in otx2_tc_ingress_matchall_install()
1448 if (is_dev_otx2(nic->pdev)) { in otx2_tc_ingress_matchall_install()
1454 err = cn10k_alloc_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_install()
1460 err = cn10k_set_matchall_ipolicer_rate(nic, entry->police.burst, rate); in otx2_tc_ingress_matchall_install()
1463 nic->flags |= OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_install()
1474 static int otx2_tc_ingress_matchall_delete(struct otx2_nic *nic, in otx2_tc_ingress_matchall_delete() argument
1480 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_ingress_matchall_delete()
1485 err = cn10k_free_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_delete()
1486 nic->flags &= ~OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_delete()
1490 static int otx2_setup_tc_ingress_matchall(struct otx2_nic *nic, in otx2_setup_tc_ingress_matchall() argument
1495 return otx2_tc_ingress_matchall_install(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1497 return otx2_tc_ingress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1509 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_ingress_cb() local
1512 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_ingress_cb()
1515 ntuple = nic->netdev->features & NETIF_F_NTUPLE; in otx2_setup_tc_block_ingress_cb()
1519 netdev_warn(nic->netdev, in otx2_setup_tc_block_ingress_cb()
1524 return otx2_setup_tc_cls_flower(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1526 return otx2_setup_tc_ingress_matchall(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1534 static int otx2_setup_tc_egress_matchall(struct otx2_nic *nic, in otx2_setup_tc_egress_matchall() argument
1539 return otx2_tc_egress_matchall_install(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1541 return otx2_tc_egress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1553 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_egress_cb() local
1555 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_egress_cb()
1560 return otx2_setup_tc_egress_matchall(nic, type_data); in otx2_setup_tc_block_egress_cb()
1573 struct otx2_nic *nic = netdev_priv(netdev); in otx2_setup_tc_block() local
1591 nic, nic, ingress); in otx2_setup_tc_block()
1608 int otx2_init_tc(struct otx2_nic *nic) in otx2_init_tc() argument
1611 set_bit(0, &nic->rq_bmap); in otx2_init_tc()
1613 if (!nic->flow_cfg) { in otx2_init_tc()
1614 netdev_err(nic->netdev, in otx2_init_tc()
1615 "Can't init TC, nic->flow_cfg is not setup\n"); in otx2_init_tc()
1623 void otx2_shutdown_tc(struct otx2_nic *nic) in otx2_shutdown_tc() argument
1625 otx2_destroy_tc_flow_list(nic); in otx2_shutdown_tc()
1629 static void otx2_tc_config_ingress_rule(struct otx2_nic *nic, in otx2_tc_config_ingress_rule() argument
1634 if (otx2_tc_act_set_hw_police(nic, node)) in otx2_tc_config_ingress_rule()
1637 mutex_lock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1639 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_config_ingress_rule()
1645 if (otx2_sync_mbox_msg(&nic->mbox)) in otx2_tc_config_ingress_rule()
1646 netdev_err(nic->netdev, in otx2_tc_config_ingress_rule()
1649 mutex_unlock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1652 void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic) in otx2_tc_apply_ingress_police_rules() argument
1654 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_apply_ingress_police_rules()
1666 otx2_tc_config_ingress_rule(nic, node); in otx2_tc_apply_ingress_police_rules()