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->pdev, nic->pcifunc) != in otx2_tc_parse_actions()
471 rvu_get_pf(nic->pdev, priv->pcifunc)) { in otx2_tc_parse_actions()
494 if (is_dev_otx2(nic->pdev)) { in otx2_tc_parse_actions()
527 nic->flags |= OTX2_FLAG_TC_MARK_ENABLED; in otx2_tc_parse_actions()
528 refcount_inc(&nic->flow_cfg->mark_flows); in otx2_tc_parse_actions()
553 err = otx2_tc_update_mcast(nic, req, extack, node, in otx2_tc_parse_actions()
567 return otx2_tc_act_set_police(nic, node, f, rate, burst, in otx2_tc_parse_actions()
573 static int otx2_tc_process_vlan(struct otx2_nic *nic, struct flow_msg *flow_spec, in otx2_tc_process_vlan() argument
586 netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n", in otx2_tc_process_vlan()
597 netdev_err(nic->netdev, in otx2_tc_process_vlan()
629 static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node, in otx2_tc_prepare_flow() argument
657 netdev_info(nic->netdev, "unsupported flow used key 0x%llx", in otx2_tc_prepare_flow()
680 netdev_info(nic->netdev, in otx2_tc_prepare_flow()
790 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, false); in otx2_tc_prepare_flow()
798 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, true); in otx2_tc_prepare_flow()
956 return otx2_tc_parse_actions(nic, &rule->action, req, f, node); in otx2_tc_prepare_flow()
1041 static int otx2_add_mcam_flow_entry(struct otx2_nic *nic, struct npc_install_flow_req *req) in otx2_add_mcam_flow_entry() argument
1046 mutex_lock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1047 tmp_req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_add_mcam_flow_entry()
1049 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1055 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_add_mcam_flow_entry()
1057 netdev_err(nic->netdev, "Failed to install MCAM flow entry %d\n", in otx2_add_mcam_flow_entry()
1059 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1063 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1067 static int otx2_del_mcam_flow_entry(struct otx2_nic *nic, u16 entry, u16 *cntr_val) in otx2_del_mcam_flow_entry() argument
1073 mutex_lock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1074 req = otx2_mbox_alloc_msg_npc_delete_flow(&nic->mbox); in otx2_del_mcam_flow_entry()
1076 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1083 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_del_mcam_flow_entry()
1085 netdev_err(nic->netdev, "Failed to delete MCAM flow entry %d\n", in otx2_del_mcam_flow_entry()
1087 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1092 rsp = (struct npc_delete_flow_rsp *)otx2_mbox_get_rsp(&nic->mbox.mbox, in otx2_del_mcam_flow_entry()
1095 netdev_err(nic->netdev, "Failed to get MCAM delete response for entry %d\n", in otx2_del_mcam_flow_entry()
1097 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1104 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1108 static int otx2_tc_update_mcam_table_del_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_del_req() argument
1128 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_del_req()
1140 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_del_req()
1147 static int otx2_tc_update_mcam_table_add_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_add_req() argument
1167 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_add_req()
1171 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_add_req()
1178 static int otx2_tc_update_mcam_table(struct otx2_nic *nic, in otx2_tc_update_mcam_table() argument
1184 return otx2_tc_update_mcam_table_add_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1186 return otx2_tc_update_mcam_table_del_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1189 static int otx2_tc_del_flow(struct otx2_nic *nic, in otx2_tc_del_flow() argument
1192 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_del_flow()
1199 netdev_err(nic->netdev, "tc flow not found for cookie 0x%lx\n", in otx2_tc_del_flow()
1207 nic->flags &= ~OTX2_FLAG_TC_MARK_ENABLED; in otx2_tc_del_flow()
1210 __clear_bit(flow_node->rq, &nic->rq_bmap); in otx2_tc_del_flow()
1212 if (nic->flags & OTX2_FLAG_INTF_DOWN) in otx2_tc_del_flow()
1215 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1217 err = cn10k_map_unmap_rq_policer(nic, flow_node->rq, in otx2_tc_del_flow()
1220 netdev_err(nic->netdev, in otx2_tc_del_flow()
1224 err = cn10k_free_leaf_profile(nic, flow_node->leaf_profile); in otx2_tc_del_flow()
1226 netdev_err(nic->netdev, in otx2_tc_del_flow()
1230 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1234 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1235 grp_destroy_req = otx2_mbox_alloc_msg_nix_mcast_grp_destroy(&nic->mbox); in otx2_tc_del_flow()
1237 otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_del_flow()
1238 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1243 otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL); in otx2_tc_del_flow()
1244 otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false); in otx2_tc_del_flow()
1250 static int otx2_tc_add_flow(struct otx2_nic *nic, in otx2_tc_add_flow() argument
1254 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_add_flow()
1259 if (!(nic->flags & OTX2_FLAG_TC_FLOWER_SUPPORT)) in otx2_tc_add_flow()
1262 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_add_flow()
1284 rc = otx2_tc_prepare_flow(nic, new_node, tc_flow_cmd, &dummy); in otx2_tc_add_flow()
1293 otx2_tc_del_flow(nic, tc_flow_cmd); in otx2_tc_add_flow()
1295 mcam_idx = otx2_tc_update_mcam_table(nic, flow_cfg, new_node, true); in otx2_tc_add_flow()
1296 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
1297 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_add_flow()
1299 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1306 req->channel = nic->hw.rx_chan_base; in otx2_tc_add_flow()
1309 req->vf = nic->pcifunc; in otx2_tc_add_flow()
1314 rc = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_add_flow()
1317 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1321 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()
1353 static int otx2_tc_get_flow_stats(struct otx2_nic *nic, in otx2_tc_get_flow_stats() argument
1362 flow_node = otx2_tc_get_entry_by_cookie(nic->flow_cfg, tc_flow_cmd->cookie); in otx2_tc_get_flow_stats()
1364 netdev_info(nic->netdev, "tc flow not found for cookie %lx", in otx2_tc_get_flow_stats()
1369 mutex_lock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1371 req = otx2_mbox_alloc_msg_npc_mcam_entry_stats(&nic->mbox); in otx2_tc_get_flow_stats()
1373 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1379 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_get_flow_stats()
1381 netdev_err(nic->netdev, "Failed to get stats for MCAM flow entry %d\n", in otx2_tc_get_flow_stats()
1383 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1388 (&nic->mbox.mbox, 0, &req->hdr); in otx2_tc_get_flow_stats()
1390 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1394 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1410 int otx2_setup_tc_cls_flower(struct otx2_nic *nic, in otx2_setup_tc_cls_flower() argument
1415 return otx2_tc_add_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1417 return otx2_tc_del_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1419 return otx2_tc_get_flow_stats(nic, cls_flower); in otx2_setup_tc_cls_flower()
1426 static int otx2_tc_ingress_matchall_install(struct otx2_nic *nic, in otx2_tc_ingress_matchall_install() argument
1435 err = otx2_tc_validate_flow(nic, actions, extack); in otx2_tc_ingress_matchall_install()
1439 if (nic->flags & OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED) { in otx2_tc_ingress_matchall_install()
1449 if (is_dev_otx2(nic->pdev)) { in otx2_tc_ingress_matchall_install()
1455 err = cn10k_alloc_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_install()
1461 err = cn10k_set_matchall_ipolicer_rate(nic, entry->police.burst, rate); in otx2_tc_ingress_matchall_install()
1464 nic->flags |= OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_install()
1475 static int otx2_tc_ingress_matchall_delete(struct otx2_nic *nic, in otx2_tc_ingress_matchall_delete() argument
1481 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_ingress_matchall_delete()
1486 err = cn10k_free_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_delete()
1487 nic->flags &= ~OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_delete()
1491 static int otx2_setup_tc_ingress_matchall(struct otx2_nic *nic, in otx2_setup_tc_ingress_matchall() argument
1496 return otx2_tc_ingress_matchall_install(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1498 return otx2_tc_ingress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1510 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_ingress_cb() local
1513 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_ingress_cb()
1516 ntuple = nic->netdev->features & NETIF_F_NTUPLE; in otx2_setup_tc_block_ingress_cb()
1520 netdev_warn(nic->netdev, in otx2_setup_tc_block_ingress_cb()
1525 return otx2_setup_tc_cls_flower(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1527 return otx2_setup_tc_ingress_matchall(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1535 static int otx2_setup_tc_egress_matchall(struct otx2_nic *nic, in otx2_setup_tc_egress_matchall() argument
1540 return otx2_tc_egress_matchall_install(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1542 return otx2_tc_egress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1554 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_egress_cb() local
1556 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_egress_cb()
1561 return otx2_setup_tc_egress_matchall(nic, type_data); in otx2_setup_tc_block_egress_cb()
1574 struct otx2_nic *nic = netdev_priv(netdev); in otx2_setup_tc_block() local
1592 nic, nic, ingress); in otx2_setup_tc_block()
1609 int otx2_init_tc(struct otx2_nic *nic) in otx2_init_tc() argument
1612 set_bit(0, &nic->rq_bmap); in otx2_init_tc()
1614 if (!nic->flow_cfg) { in otx2_init_tc()
1615 netdev_err(nic->netdev, in otx2_init_tc()
1616 "Can't init TC, nic->flow_cfg is not setup\n"); in otx2_init_tc()
1624 void otx2_shutdown_tc(struct otx2_nic *nic) in otx2_shutdown_tc() argument
1626 otx2_destroy_tc_flow_list(nic); in otx2_shutdown_tc()
1630 static void otx2_tc_config_ingress_rule(struct otx2_nic *nic, in otx2_tc_config_ingress_rule() argument
1635 if (otx2_tc_act_set_hw_police(nic, node)) in otx2_tc_config_ingress_rule()
1638 mutex_lock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1640 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_config_ingress_rule()
1646 if (otx2_sync_mbox_msg(&nic->mbox)) in otx2_tc_config_ingress_rule()
1647 netdev_err(nic->netdev, in otx2_tc_config_ingress_rule()
1650 mutex_unlock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1653 void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic) in otx2_tc_apply_ingress_police_rules() argument
1655 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_apply_ingress_police_rules()
1667 otx2_tc_config_ingress_rule(nic, node); in otx2_tc_apply_ingress_police_rules()