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
469 if (rvu_get_pf(nic->pcifunc) != rvu_get_pf(priv->pcifunc)) { in otx2_tc_parse_actions()
488 if (is_dev_otx2(nic->pdev)) { in otx2_tc_parse_actions()
539 err = otx2_tc_update_mcast(nic, req, extack, node, in otx2_tc_parse_actions()
553 return otx2_tc_act_set_police(nic, node, f, rate, burst, in otx2_tc_parse_actions()
559 static int otx2_tc_process_vlan(struct otx2_nic *nic, struct flow_msg *flow_spec, in otx2_tc_process_vlan() argument
572 netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n", in otx2_tc_process_vlan()
583 netdev_err(nic->netdev, in otx2_tc_process_vlan()
615 static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node, in otx2_tc_prepare_flow() argument
642 netdev_info(nic->netdev, "unsupported flow used key 0x%llx", in otx2_tc_prepare_flow()
665 netdev_info(nic->netdev, in otx2_tc_prepare_flow()
772 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, false); in otx2_tc_prepare_flow()
780 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, true); in otx2_tc_prepare_flow()
928 return otx2_tc_parse_actions(nic, &rule->action, req, f, node); in otx2_tc_prepare_flow()
1013 static int otx2_add_mcam_flow_entry(struct otx2_nic *nic, struct npc_install_flow_req *req) in otx2_add_mcam_flow_entry() argument
1018 mutex_lock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1019 tmp_req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_add_mcam_flow_entry()
1021 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1027 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_add_mcam_flow_entry()
1029 netdev_err(nic->netdev, "Failed to install MCAM flow entry %d\n", in otx2_add_mcam_flow_entry()
1031 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1035 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1039 static int otx2_del_mcam_flow_entry(struct otx2_nic *nic, u16 entry, u16 *cntr_val) in otx2_del_mcam_flow_entry() argument
1045 mutex_lock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1046 req = otx2_mbox_alloc_msg_npc_delete_flow(&nic->mbox); in otx2_del_mcam_flow_entry()
1048 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1055 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_del_mcam_flow_entry()
1057 netdev_err(nic->netdev, "Failed to delete MCAM flow entry %d\n", in otx2_del_mcam_flow_entry()
1059 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1064 rsp = (struct npc_delete_flow_rsp *)otx2_mbox_get_rsp(&nic->mbox.mbox, in otx2_del_mcam_flow_entry()
1067 netdev_err(nic->netdev, "Failed to get MCAM delete response for entry %d\n", in otx2_del_mcam_flow_entry()
1069 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1076 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1080 static int otx2_tc_update_mcam_table_del_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_del_req() argument
1100 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_del_req()
1112 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_del_req()
1119 static int otx2_tc_update_mcam_table_add_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_add_req() argument
1139 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_add_req()
1143 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_add_req()
1150 static int otx2_tc_update_mcam_table(struct otx2_nic *nic, in otx2_tc_update_mcam_table() argument
1156 return otx2_tc_update_mcam_table_add_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1158 return otx2_tc_update_mcam_table_del_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1161 static int otx2_tc_del_flow(struct otx2_nic *nic, in otx2_tc_del_flow() argument
1164 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_del_flow()
1171 netdev_err(nic->netdev, "tc flow not found for cookie 0x%lx\n", in otx2_tc_del_flow()
1177 __clear_bit(flow_node->rq, &nic->rq_bmap); in otx2_tc_del_flow()
1179 if (nic->flags & OTX2_FLAG_INTF_DOWN) in otx2_tc_del_flow()
1182 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1184 err = cn10k_map_unmap_rq_policer(nic, flow_node->rq, in otx2_tc_del_flow()
1187 netdev_err(nic->netdev, in otx2_tc_del_flow()
1191 err = cn10k_free_leaf_profile(nic, flow_node->leaf_profile); in otx2_tc_del_flow()
1193 netdev_err(nic->netdev, in otx2_tc_del_flow()
1197 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1201 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1202 grp_destroy_req = otx2_mbox_alloc_msg_nix_mcast_grp_destroy(&nic->mbox); in otx2_tc_del_flow()
1204 otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_del_flow()
1205 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1210 otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL); in otx2_tc_del_flow()
1211 otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false); in otx2_tc_del_flow()
1217 static int otx2_tc_add_flow(struct otx2_nic *nic, in otx2_tc_add_flow() argument
1221 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_add_flow()
1226 if (!(nic->flags & OTX2_FLAG_TC_FLOWER_SUPPORT)) in otx2_tc_add_flow()
1229 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_add_flow()
1251 rc = otx2_tc_prepare_flow(nic, new_node, tc_flow_cmd, &dummy); in otx2_tc_add_flow()
1260 otx2_tc_del_flow(nic, tc_flow_cmd); in otx2_tc_add_flow()
1262 mcam_idx = otx2_tc_update_mcam_table(nic, flow_cfg, new_node, true); in otx2_tc_add_flow()
1263 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
1264 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_add_flow()
1266 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1273 req->channel = nic->hw.rx_chan_base; in otx2_tc_add_flow()
1280 rc = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_add_flow()
1283 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1287 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1297 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
1299 err = cn10k_map_unmap_rq_policer(nic, new_node->rq, in otx2_tc_add_flow()
1302 netdev_err(nic->netdev, in otx2_tc_add_flow()
1305 err = cn10k_free_leaf_profile(nic, new_node->leaf_profile); in otx2_tc_add_flow()
1307 netdev_err(nic->netdev, in otx2_tc_add_flow()
1311 __clear_bit(new_node->rq, &nic->rq_bmap); in otx2_tc_add_flow()
1313 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1319 static int otx2_tc_get_flow_stats(struct otx2_nic *nic, in otx2_tc_get_flow_stats() argument
1328 flow_node = otx2_tc_get_entry_by_cookie(nic->flow_cfg, tc_flow_cmd->cookie); in otx2_tc_get_flow_stats()
1330 netdev_info(nic->netdev, "tc flow not found for cookie %lx", in otx2_tc_get_flow_stats()
1335 mutex_lock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1337 req = otx2_mbox_alloc_msg_npc_mcam_entry_stats(&nic->mbox); in otx2_tc_get_flow_stats()
1339 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1345 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_get_flow_stats()
1347 netdev_err(nic->netdev, "Failed to get stats for MCAM flow entry %d\n", in otx2_tc_get_flow_stats()
1349 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1354 (&nic->mbox.mbox, 0, &req->hdr); in otx2_tc_get_flow_stats()
1356 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1360 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1376 static int otx2_setup_tc_cls_flower(struct otx2_nic *nic, in otx2_setup_tc_cls_flower() argument
1381 return otx2_tc_add_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1383 return otx2_tc_del_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1385 return otx2_tc_get_flow_stats(nic, cls_flower); in otx2_setup_tc_cls_flower()
1391 static int otx2_tc_ingress_matchall_install(struct otx2_nic *nic, in otx2_tc_ingress_matchall_install() argument
1400 err = otx2_tc_validate_flow(nic, actions, extack); in otx2_tc_ingress_matchall_install()
1404 if (nic->flags & OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED) { in otx2_tc_ingress_matchall_install()
1414 if (is_dev_otx2(nic->pdev)) { in otx2_tc_ingress_matchall_install()
1420 err = cn10k_alloc_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_install()
1426 err = cn10k_set_matchall_ipolicer_rate(nic, entry->police.burst, rate); in otx2_tc_ingress_matchall_install()
1429 nic->flags |= OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_install()
1440 static int otx2_tc_ingress_matchall_delete(struct otx2_nic *nic, in otx2_tc_ingress_matchall_delete() argument
1446 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_ingress_matchall_delete()
1451 err = cn10k_free_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_delete()
1452 nic->flags &= ~OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_delete()
1456 static int otx2_setup_tc_ingress_matchall(struct otx2_nic *nic, in otx2_setup_tc_ingress_matchall() argument
1461 return otx2_tc_ingress_matchall_install(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1463 return otx2_tc_ingress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1475 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_ingress_cb() local
1478 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_ingress_cb()
1481 ntuple = nic->netdev->features & NETIF_F_NTUPLE; in otx2_setup_tc_block_ingress_cb()
1485 netdev_warn(nic->netdev, in otx2_setup_tc_block_ingress_cb()
1490 return otx2_setup_tc_cls_flower(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1492 return otx2_setup_tc_ingress_matchall(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1500 static int otx2_setup_tc_egress_matchall(struct otx2_nic *nic, in otx2_setup_tc_egress_matchall() argument
1505 return otx2_tc_egress_matchall_install(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1507 return otx2_tc_egress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1519 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_egress_cb() local
1521 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_egress_cb()
1526 return otx2_setup_tc_egress_matchall(nic, type_data); in otx2_setup_tc_block_egress_cb()
1539 struct otx2_nic *nic = netdev_priv(netdev); in otx2_setup_tc_block() local
1557 nic, nic, ingress); in otx2_setup_tc_block()
1574 int otx2_init_tc(struct otx2_nic *nic) in otx2_init_tc() argument
1577 set_bit(0, &nic->rq_bmap); in otx2_init_tc()
1579 if (!nic->flow_cfg) { in otx2_init_tc()
1580 netdev_err(nic->netdev, in otx2_init_tc()
1581 "Can't init TC, nic->flow_cfg is not setup\n"); in otx2_init_tc()
1589 void otx2_shutdown_tc(struct otx2_nic *nic) in otx2_shutdown_tc() argument
1591 otx2_destroy_tc_flow_list(nic); in otx2_shutdown_tc()
1595 static void otx2_tc_config_ingress_rule(struct otx2_nic *nic, in otx2_tc_config_ingress_rule() argument
1600 if (otx2_tc_act_set_hw_police(nic, node)) in otx2_tc_config_ingress_rule()
1603 mutex_lock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1605 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_config_ingress_rule()
1611 if (otx2_sync_mbox_msg(&nic->mbox)) in otx2_tc_config_ingress_rule()
1612 netdev_err(nic->netdev, in otx2_tc_config_ingress_rule()
1615 mutex_unlock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1618 void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic) in otx2_tc_apply_ingress_police_rules() argument
1620 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_apply_ingress_police_rules()
1632 otx2_tc_config_ingress_rule(nic, node); in otx2_tc_apply_ingress_police_rules()