Lines Matching refs:nic

63 int otx2_tc_alloc_ent_bitmap(struct otx2_nic *nic)  in otx2_tc_alloc_ent_bitmap()  argument
65 struct otx2_tc_info *tc = &nic->tc_info; in otx2_tc_alloc_ent_bitmap()
67 if (!nic->flow_cfg->max_flows) in otx2_tc_alloc_ent_bitmap()
74 kcalloc(BITS_TO_LONGS(nic->flow_cfg->max_flows), in otx2_tc_alloc_ent_bitmap()
77 netdev_err(nic->netdev, in otx2_tc_alloc_ent_bitmap()
86 static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst, in otx2_get_egress_burst_cfg() argument
92 if (is_dev_otx2(nic->pdev)) { in otx2_get_egress_burst_cfg()
150 static u64 otx2_get_txschq_rate_regval(struct otx2_nic *nic, in otx2_get_txschq_rate_regval() argument
158 otx2_get_egress_burst_cfg(nic, burst, &burst_exp, &burst_mantissa); in otx2_get_txschq_rate_regval()
161 if (is_dev_otx2(nic->pdev)) { in otx2_get_txschq_rate_regval()
178 static int otx2_set_matchall_egress_rate(struct otx2_nic *nic, in otx2_set_matchall_egress_rate() argument
181 struct otx2_hw *hw = &nic->hw; in otx2_set_matchall_egress_rate()
188 mutex_lock(&nic->mbox.lock); in otx2_set_matchall_egress_rate()
189 req = otx2_mbox_alloc_msg_nix_txschq_cfg(&nic->mbox); in otx2_set_matchall_egress_rate()
191 mutex_unlock(&nic->mbox.lock); in otx2_set_matchall_egress_rate()
198 req->regval[0] = otx2_get_txschq_rate_regval(nic, maxrate, burst); in otx2_set_matchall_egress_rate()
200 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_set_matchall_egress_rate()
201 mutex_unlock(&nic->mbox.lock); in otx2_set_matchall_egress_rate()
205 static int otx2_tc_validate_flow(struct otx2_nic *nic, in otx2_tc_validate_flow() argument
209 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_validate_flow()
261 static int otx2_tc_egress_matchall_install(struct otx2_nic *nic, in otx2_tc_egress_matchall_install() argument
270 err = otx2_tc_validate_flow(nic, actions, extack); in otx2_tc_egress_matchall_install()
274 if (nic->flags & OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED) { in otx2_tc_egress_matchall_install()
294 err = otx2_set_matchall_egress_rate(nic, entry->police.burst, rate); in otx2_tc_egress_matchall_install()
297 nic->flags |= OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED; in otx2_tc_egress_matchall_install()
308 static int otx2_tc_egress_matchall_delete(struct otx2_nic *nic, in otx2_tc_egress_matchall_delete() argument
314 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_egress_matchall_delete()
319 err = otx2_set_matchall_egress_rate(nic, 0, 0); in otx2_tc_egress_matchall_delete()
320 nic->flags &= ~OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED; in otx2_tc_egress_matchall_delete()
324 static int otx2_tc_act_set_police(struct otx2_nic *nic, in otx2_tc_act_set_police() argument
331 struct otx2_hw *hw = &nic->hw; in otx2_tc_act_set_police()
334 rq_idx = find_first_zero_bit(&nic->rq_bmap, hw->rx_queues); in otx2_tc_act_set_police()
340 mutex_lock(&nic->mbox.lock); in otx2_tc_act_set_police()
342 rc = cn10k_alloc_leaf_profile(nic, &node->leaf_profile); in otx2_tc_act_set_police()
344 mutex_unlock(&nic->mbox.lock); in otx2_tc_act_set_police()
348 rc = cn10k_set_ipolicer_rate(nic, node->leaf_profile, burst, rate, pps); in otx2_tc_act_set_police()
352 rc = cn10k_map_unmap_rq_policer(nic, rq_idx, node->leaf_profile, true); in otx2_tc_act_set_police()
356 mutex_unlock(&nic->mbox.lock); in otx2_tc_act_set_police()
361 set_bit(rq_idx, &nic->rq_bmap); in otx2_tc_act_set_police()
368 if (cn10k_free_leaf_profile(nic, node->leaf_profile)) in otx2_tc_act_set_police()
369 netdev_err(nic->netdev, in otx2_tc_act_set_police()
372 mutex_unlock(&nic->mbox.lock); in otx2_tc_act_set_police()
376 static int otx2_tc_parse_actions(struct otx2_nic *nic, in otx2_tc_parse_actions() argument
410 if (rvu_get_pf(nic->pcifunc) != rvu_get_pf(priv->pcifunc)) { in otx2_tc_parse_actions()
425 if (is_dev_otx2(nic->pdev)) { in otx2_tc_parse_actions()
465 return otx2_tc_act_set_police(nic, node, f, rate, burst, in otx2_tc_parse_actions()
471 static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node, in otx2_tc_prepare_flow() argument
494 netdev_info(nic->netdev, "unsupported flow used key 0x%x", in otx2_tc_prepare_flow()
515 netdev_info(nic->netdev, in otx2_tc_prepare_flow()
602 netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n", in otx2_tc_prepare_flow()
699 return otx2_tc_parse_actions(nic, &rule->action, req, f, node); in otx2_tc_prepare_flow()
702 static int otx2_del_mcam_flow_entry(struct otx2_nic *nic, u16 entry) in otx2_del_mcam_flow_entry() argument
707 mutex_lock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
708 req = otx2_mbox_alloc_msg_npc_delete_flow(&nic->mbox); in otx2_del_mcam_flow_entry()
710 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
717 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_del_mcam_flow_entry()
719 netdev_err(nic->netdev, "Failed to delete MCAM flow entry %d\n", in otx2_del_mcam_flow_entry()
721 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
724 mutex_unlock(&nic->mbox.lock); in otx2_del_mcam_flow_entry()
729 static int otx2_tc_del_flow(struct otx2_nic *nic, in otx2_tc_del_flow() argument
732 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_del_flow()
733 struct otx2_tc_info *tc_info = &nic->tc_info; in otx2_tc_del_flow()
741 netdev_err(nic->netdev, "tc flow not found for cookie 0x%lx\n", in otx2_tc_del_flow()
747 mutex_lock(&nic->mbox.lock); in otx2_tc_del_flow()
749 err = cn10k_map_unmap_rq_policer(nic, flow_node->rq, in otx2_tc_del_flow()
752 netdev_err(nic->netdev, in otx2_tc_del_flow()
756 err = cn10k_free_leaf_profile(nic, flow_node->leaf_profile); in otx2_tc_del_flow()
758 netdev_err(nic->netdev, in otx2_tc_del_flow()
762 __clear_bit(flow_node->rq, &nic->rq_bmap); in otx2_tc_del_flow()
764 mutex_unlock(&nic->mbox.lock); in otx2_tc_del_flow()
767 otx2_del_mcam_flow_entry(nic, flow_node->entry); in otx2_tc_del_flow()
769 WARN_ON(rhashtable_remove_fast(&nic->tc_info.flow_table, in otx2_tc_del_flow()
771 nic->tc_info.flow_ht_params)); in otx2_tc_del_flow()
780 static int otx2_tc_add_flow(struct otx2_nic *nic, in otx2_tc_add_flow() argument
784 struct otx2_flow_config *flow_cfg = nic->flow_cfg; in otx2_tc_add_flow()
785 struct otx2_tc_info *tc_info = &nic->tc_info; in otx2_tc_add_flow()
790 if (!(nic->flags & OTX2_FLAG_TC_FLOWER_SUPPORT)) in otx2_tc_add_flow()
808 rc = otx2_tc_prepare_flow(nic, new_node, tc_flow_cmd, &dummy); in otx2_tc_add_flow()
819 otx2_tc_del_flow(nic, tc_flow_cmd); in otx2_tc_add_flow()
821 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
822 req = otx2_mbox_alloc_msg_npc_install_flow(&nic->mbox); in otx2_tc_add_flow()
824 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
834 req->channel = nic->hw.rx_chan_base; in otx2_tc_add_flow()
841 rc = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_add_flow()
844 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
848 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
851 rc = rhashtable_insert_fast(&nic->tc_info.flow_table, &new_node->node, in otx2_tc_add_flow()
852 nic->tc_info.flow_ht_params); in otx2_tc_add_flow()
854 otx2_del_mcam_flow_entry(nic, req->entry); in otx2_tc_add_flow()
866 mutex_lock(&nic->mbox.lock); in otx2_tc_add_flow()
868 err = cn10k_map_unmap_rq_policer(nic, new_node->rq, in otx2_tc_add_flow()
871 netdev_err(nic->netdev, in otx2_tc_add_flow()
874 err = cn10k_free_leaf_profile(nic, new_node->leaf_profile); in otx2_tc_add_flow()
876 netdev_err(nic->netdev, in otx2_tc_add_flow()
880 __clear_bit(new_node->rq, &nic->rq_bmap); in otx2_tc_add_flow()
882 mutex_unlock(&nic->mbox.lock); in otx2_tc_add_flow()
888 static int otx2_tc_get_flow_stats(struct otx2_nic *nic, in otx2_tc_get_flow_stats() argument
891 struct otx2_tc_info *tc_info = &nic->tc_info; in otx2_tc_get_flow_stats()
902 netdev_info(nic->netdev, "tc flow not found for cookie %lx", in otx2_tc_get_flow_stats()
907 mutex_lock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
909 req = otx2_mbox_alloc_msg_npc_mcam_entry_stats(&nic->mbox); in otx2_tc_get_flow_stats()
911 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
917 err = otx2_sync_mbox_msg(&nic->mbox); in otx2_tc_get_flow_stats()
919 netdev_err(nic->netdev, "Failed to get stats for MCAM flow entry %d\n", in otx2_tc_get_flow_stats()
921 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
926 (&nic->mbox.mbox, 0, &req->hdr); in otx2_tc_get_flow_stats()
928 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
932 mutex_unlock(&nic->mbox.lock); in otx2_tc_get_flow_stats()
948 static int otx2_setup_tc_cls_flower(struct otx2_nic *nic, in otx2_setup_tc_cls_flower() argument
953 return otx2_tc_add_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
955 return otx2_tc_del_flow(nic, cls_flower); in otx2_setup_tc_cls_flower()
957 return otx2_tc_get_flow_stats(nic, cls_flower); in otx2_setup_tc_cls_flower()
963 static int otx2_tc_ingress_matchall_install(struct otx2_nic *nic, in otx2_tc_ingress_matchall_install() argument
972 err = otx2_tc_validate_flow(nic, actions, extack); in otx2_tc_ingress_matchall_install()
976 if (nic->flags & OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED) { in otx2_tc_ingress_matchall_install()
986 if (is_dev_otx2(nic->pdev)) { in otx2_tc_ingress_matchall_install()
992 err = cn10k_alloc_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_install()
998 err = cn10k_set_matchall_ipolicer_rate(nic, entry->police.burst, rate); in otx2_tc_ingress_matchall_install()
1001 nic->flags |= OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_install()
1012 static int otx2_tc_ingress_matchall_delete(struct otx2_nic *nic, in otx2_tc_ingress_matchall_delete() argument
1018 if (nic->flags & OTX2_FLAG_INTF_DOWN) { in otx2_tc_ingress_matchall_delete()
1023 err = cn10k_free_matchall_ipolicer(nic); in otx2_tc_ingress_matchall_delete()
1024 nic->flags &= ~OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED; in otx2_tc_ingress_matchall_delete()
1028 static int otx2_setup_tc_ingress_matchall(struct otx2_nic *nic, in otx2_setup_tc_ingress_matchall() argument
1033 return otx2_tc_ingress_matchall_install(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1035 return otx2_tc_ingress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_ingress_matchall()
1047 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_ingress_cb() local
1049 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_ingress_cb()
1054 return otx2_setup_tc_cls_flower(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1056 return otx2_setup_tc_ingress_matchall(nic, type_data); in otx2_setup_tc_block_ingress_cb()
1064 static int otx2_setup_tc_egress_matchall(struct otx2_nic *nic, in otx2_setup_tc_egress_matchall() argument
1069 return otx2_tc_egress_matchall_install(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1071 return otx2_tc_egress_matchall_delete(nic, cls_matchall); in otx2_setup_tc_egress_matchall()
1083 struct otx2_nic *nic = cb_priv; in otx2_setup_tc_block_egress_cb() local
1085 if (!tc_cls_can_offload_and_chain0(nic->netdev, type_data)) in otx2_setup_tc_block_egress_cb()
1090 return otx2_setup_tc_egress_matchall(nic, type_data); in otx2_setup_tc_block_egress_cb()
1103 struct otx2_nic *nic = netdev_priv(netdev); in otx2_setup_tc_block() local
1121 nic, nic, ingress); in otx2_setup_tc_block()
1143 int otx2_init_tc(struct otx2_nic *nic) in otx2_init_tc() argument
1145 struct otx2_tc_info *tc = &nic->tc_info; in otx2_init_tc()
1149 set_bit(0, &nic->rq_bmap); in otx2_init_tc()
1151 if (!nic->flow_cfg) { in otx2_init_tc()
1152 netdev_err(nic->netdev, in otx2_init_tc()
1157 err = otx2_tc_alloc_ent_bitmap(nic); in otx2_init_tc()
1171 void otx2_shutdown_tc(struct otx2_nic *nic) in otx2_shutdown_tc() argument
1173 struct otx2_tc_info *tc = &nic->tc_info; in otx2_shutdown_tc()