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()
521 nic->flags |= OTX2_FLAG_TC_MARK_ENABLED; in otx2_tc_parse_actions()
522 refcount_inc(&nic->flow_cfg->mark_flows); in otx2_tc_parse_actions()
547 err = otx2_tc_update_mcast(nic, req, extack, node, in otx2_tc_parse_actions()
561 return otx2_tc_act_set_police(nic, node, f, rate, burst, in otx2_tc_parse_actions()
567 static int otx2_tc_process_vlan(struct otx2_nic *nic, struct flow_msg *flow_spec, in otx2_tc_process_vlan() argument
580 netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n", in otx2_tc_process_vlan()
591 netdev_err(nic->netdev, in otx2_tc_process_vlan()
623 static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node, in otx2_tc_prepare_flow() argument
651 netdev_info(nic->netdev, "unsupported flow used key 0x%llx", in otx2_tc_prepare_flow()
674 netdev_info(nic->netdev, in otx2_tc_prepare_flow()
784 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, false); in otx2_tc_prepare_flow()
792 ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, true); in otx2_tc_prepare_flow()
950 return otx2_tc_parse_actions(nic, &rule->action, req, f, node); in otx2_tc_prepare_flow()
1035 static int otx2_add_mcam_flow_entry(struct otx2_nic *nic, struct npc_install_flow_req *req) in otx2_add_mcam_flow_entry() argument
1040 mutex_lock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1041 tmp_req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_add_mcam_flow_entry()
1043 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1049 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_add_mcam_flow_entry()
1051 netdev_err(nic->netdev, "Failed to install MCAM flow entry %d\n", in otx2_add_mcam_flow_entry()
1053 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1057 mutex_unlock(&nic->mbox.lock); in otx2_add_mcam_flow_entry()
1061 static int otx2_del_mcam_flow_entry(struct otx2_nic *nic, u16 entry, u16 *cntr_val) in otx2_del_mcam_flow_entry() argument
1067 mutex_lock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1068 req = otx2_mbox_alloc_msg_npc_delete_flow(&nic->mbox); in otx2_del_mcam_flow_entry()
1070 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1077 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_del_mcam_flow_entry()
1079 netdev_err(nic->netdev, "Failed to delete MCAM flow entry %d\n", in otx2_del_mcam_flow_entry()
1081 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1086 rsp = (struct npc_delete_flow_rsp *)otx2_mbox_get_rsp(&nic->mbox.mbox, in otx2_del_mcam_flow_entry()
1089 netdev_err(nic->netdev, "Failed to get MCAM delete response for entry %d\n", in otx2_del_mcam_flow_entry()
1091 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1098 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
1102 static int otx2_tc_update_mcam_table_del_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_del_req() argument
1122 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_del_req()
1134 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_del_req()
1141 static int otx2_tc_update_mcam_table_add_req(struct otx2_nic *nic, in otx2_tc_update_mcam_table_add_req() argument
1161 otx2_del_mcam_flow_entry(nic, tmp->entry, &cntr_val); in otx2_tc_update_mcam_table_add_req()
1165 otx2_add_mcam_flow_entry(nic, &tmp->req); in otx2_tc_update_mcam_table_add_req()
1172 static int otx2_tc_update_mcam_table(struct otx2_nic *nic, in otx2_tc_update_mcam_table() argument
1178 return otx2_tc_update_mcam_table_add_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1180 return otx2_tc_update_mcam_table_del_req(nic, flow_cfg, node); in otx2_tc_update_mcam_table()
1183 static int otx2_tc_del_flow(struct otx2_nic *nic, in otx2_tc_del_flow() argument
1186 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_del_flow()
1193 netdev_err(nic->netdev, "tc flow not found for cookie 0x%lx\n", in otx2_tc_del_flow()
1201 nic->flags &= ~OTX2_FLAG_TC_MARK_ENABLED; in otx2_tc_del_flow()
1204 __clear_bit(flow_node->rq, &nic->rq_bmap); in otx2_tc_del_flow()
1206 if (nic->flags & OTX2_FLAG_INTF_DOWN) in otx2_tc_del_flow()
1209 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1211 err = cn10k_map_unmap_rq_policer(nic, flow_node->rq, in otx2_tc_del_flow()
1214 netdev_err(nic->netdev, in otx2_tc_del_flow()
1218 err = cn10k_free_leaf_profile(nic, flow_node->leaf_profile); in otx2_tc_del_flow()
1220 netdev_err(nic->netdev, in otx2_tc_del_flow()
1224 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1228 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
1229 grp_destroy_req = otx2_mbox_alloc_msg_nix_mcast_grp_destroy(&nic->mbox); in otx2_tc_del_flow()
1231 otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_del_flow()
1232 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
1237 otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL); in otx2_tc_del_flow()
1238 otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false); in otx2_tc_del_flow()
1244 static int otx2_tc_add_flow(struct otx2_nic *nic, in otx2_tc_add_flow() argument
1248 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_add_flow()
1253 if (!(nic->flags & OTX2_FLAG_TC_FLOWER_SUPPORT)) in otx2_tc_add_flow()
1256 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_add_flow()
1278 rc = otx2_tc_prepare_flow(nic, new_node, tc_flow_cmd, &dummy); in otx2_tc_add_flow()
1287 otx2_tc_del_flow(nic, tc_flow_cmd); in otx2_tc_add_flow()
1289 mcam_idx = otx2_tc_update_mcam_table(nic, flow_cfg, new_node, true); in otx2_tc_add_flow()
1290 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
1291 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_add_flow()
1293 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1300 req->channel = nic->hw.rx_chan_base; in otx2_tc_add_flow()
1307 rc = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_add_flow()
1310 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1314 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1324 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
1326 err = cn10k_map_unmap_rq_policer(nic, new_node->rq, in otx2_tc_add_flow()
1329 netdev_err(nic->netdev, in otx2_tc_add_flow()
1332 err = cn10k_free_leaf_profile(nic, new_node->leaf_profile); in otx2_tc_add_flow()
1334 netdev_err(nic->netdev, in otx2_tc_add_flow()
1338 __clear_bit(new_node->rq, &nic->rq_bmap); in otx2_tc_add_flow()
1340 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
1346 static int otx2_tc_get_flow_stats(struct otx2_nic *nic, in otx2_tc_get_flow_stats() argument
1355 flow_node = otx2_tc_get_entry_by_cookie(nic->flow_cfg, tc_flow_cmd->cookie); in otx2_tc_get_flow_stats()
1357 netdev_info(nic->netdev, "tc flow not found for cookie %lx", in otx2_tc_get_flow_stats()
1362 mutex_lock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1364 req = otx2_mbox_alloc_msg_npc_mcam_entry_stats(&nic->mbox); in otx2_tc_get_flow_stats()
1366 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1372 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_get_flow_stats()
1374 netdev_err(nic->netdev, "Failed to get stats for MCAM flow entry %d\n", in otx2_tc_get_flow_stats()
1376 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1381 (&nic->mbox.mbox, 0, &req->hdr); in otx2_tc_get_flow_stats()
1383 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1387 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
1403 static int otx2_setup_tc_cls_flower(struct otx2_nic *nic, in otx2_setup_tc_cls_flower() argument
1408 return otx2_tc_add_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1410 return otx2_tc_del_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
1412 return otx2_tc_get_flow_stats(nic, cls_flower); in otx2_setup_tc_cls_flower()
1418 static int otx2_tc_ingress_matchall_install(struct otx2_nic *nic, in otx2_tc_ingress_matchall_install() argument
1427 err = otx2_tc_validate_flow(nic, actions, extack); in otx2_tc_ingress_matchall_install()
1431 if (nic->flags & OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED) { in otx2_tc_ingress_matchall_install()
1441 if (is_dev_otx2(nic->pdev)) { in otx2_tc_ingress_matchall_install()
1447 err = cn10k_alloc_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_install()
1453 err = cn10k_set_matchall_ipolicer_rate(nic, entry->police.burst, rate); in otx2_tc_ingress_matchall_install()
1456 nic->flags |= OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_install()
1467 static int otx2_tc_ingress_matchall_delete(struct otx2_nic *nic, in otx2_tc_ingress_matchall_delete() argument
1473 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_ingress_matchall_delete()
1478 err = cn10k_free_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_delete()
1479 nic->flags &= ~OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_delete()
1483 static int otx2_setup_tc_ingress_matchall(struct otx2_nic *nic, in otx2_setup_tc_ingress_matchall() argument
1488 return otx2_tc_ingress_matchall_install(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1490 return otx2_tc_ingress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1502 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_ingress_cb() local
1505 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_ingress_cb()
1508 ntuple = nic->netdev->features & NETIF_F_NTUPLE; in otx2_setup_tc_block_ingress_cb()
1512 netdev_warn(nic->netdev, in otx2_setup_tc_block_ingress_cb()
1517 return otx2_setup_tc_cls_flower(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1519 return otx2_setup_tc_ingress_matchall(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1527 static int otx2_setup_tc_egress_matchall(struct otx2_nic *nic, in otx2_setup_tc_egress_matchall() argument
1532 return otx2_tc_egress_matchall_install(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1534 return otx2_tc_egress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1546 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_egress_cb() local
1548 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_egress_cb()
1553 return otx2_setup_tc_egress_matchall(nic, type_data); in otx2_setup_tc_block_egress_cb()
1566 struct otx2_nic *nic = netdev_priv(netdev); in otx2_setup_tc_block() local
1584 nic, nic, ingress); in otx2_setup_tc_block()
1601 int otx2_init_tc(struct otx2_nic *nic) in otx2_init_tc() argument
1604 set_bit(0, &nic->rq_bmap); in otx2_init_tc()
1606 if (!nic->flow_cfg) { in otx2_init_tc()
1607 netdev_err(nic->netdev, in otx2_init_tc()
1608 "Can't init TC, nic->flow_cfg is not setup\n"); in otx2_init_tc()
1616 void otx2_shutdown_tc(struct otx2_nic *nic) in otx2_shutdown_tc() argument
1618 otx2_destroy_tc_flow_list(nic); in otx2_shutdown_tc()
1622 static void otx2_tc_config_ingress_rule(struct otx2_nic *nic, in otx2_tc_config_ingress_rule() argument
1627 if (otx2_tc_act_set_hw_police(nic, node)) in otx2_tc_config_ingress_rule()
1630 mutex_lock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1632 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_config_ingress_rule()
1638 if (otx2_sync_mbox_msg(&nic->mbox)) in otx2_tc_config_ingress_rule()
1639 netdev_err(nic->netdev, in otx2_tc_config_ingress_rule()
1642 mutex_unlock(&nic->mbox.lock); in otx2_tc_config_ingress_rule()
1645 void otx2_tc_apply_ingress_police_rules(struct otx2_nic *nic) in otx2_tc_apply_ingress_police_rules() argument
1647 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_apply_ingress_police_rules()
1659 otx2_tc_config_ingress_rule(nic, node); in otx2_tc_apply_ingress_police_rules()