Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(C) 2024 Marvell. 3 : : */ 4 : : 5 : : #include "cn20k_ethdev.h" 6 : : #include "cn20k_rx.h" 7 : : #include "cnxk_ethdev_mcs.h" 8 : : #include "cnxk_flow_common.h" 9 : : #include <cn20k_flow.h> 10 : : #include <cnxk_flow.h> 11 : : 12 : : struct rte_flow * 13 : 0 : cn20k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, 14 : : const struct rte_flow_item pattern[], const struct rte_flow_action actions[], 15 : : struct rte_flow_error *error) 16 : : { 17 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 18 : 0 : struct roc_npc *npc = &dev->npc; 19 : : struct roc_npc_flow *flow; 20 : : int vtag_actions = 0; 21 : : int mark_actions; 22 : : 23 : 0 : flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error); 24 : : 25 [ # # ]: 0 : if (!flow) 26 : : return NULL; 27 : : 28 : 0 : mark_actions = roc_npc_mark_actions_get(npc); 29 [ # # ]: 0 : if (mark_actions) { 30 : 0 : dev->rx_offload_flags |= NIX_RX_OFFLOAD_MARK_UPDATE_F; 31 : 0 : cn20k_eth_set_rx_function(eth_dev); 32 : : } 33 : : 34 : 0 : vtag_actions = roc_npc_vtag_actions_get(npc); 35 : : 36 [ # # ]: 0 : if (vtag_actions) { 37 : 0 : dev->rx_offload_flags |= NIX_RX_OFFLOAD_VLAN_STRIP_F; 38 : 0 : cn20k_eth_set_rx_function(eth_dev); 39 : : } 40 : : 41 : : return (struct rte_flow *)flow; 42 : : } 43 : : 44 : : int 45 : 0 : cn20k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info, 46 : : struct rte_flow_queue_info *queue_info, struct rte_flow_error *err) 47 : : { 48 : 0 : return cnxk_flow_info_get_common(dev, port_info, queue_info, err); 49 : : } 50 : : 51 : : int 52 [ # # ]: 0 : cn20k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow, 53 : : struct rte_flow_error *error) 54 : : { 55 : : struct roc_npc_flow *flow = (struct roc_npc_flow *)rte_flow; 56 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 57 : 0 : struct roc_npc *npc = &dev->npc; 58 : : int vtag_actions = 0, rc = 0; 59 : : int mark_actions; 60 : : uint16_t match_id; 61 : : uint32_t mtr_id; 62 : : 63 : 0 : match_id = (flow->npc_action >> NPC_RX_ACT_MATCH_OFFSET) & NPC_RX_ACT_MATCH_MASK; 64 [ # # ]: 0 : if (match_id) { 65 : 0 : mark_actions = roc_npc_mark_actions_sub_return(npc, 1); 66 [ # # ]: 0 : if (mark_actions == 0) { 67 : 0 : dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_MARK_UPDATE_F; 68 : 0 : cn20k_eth_set_rx_function(eth_dev); 69 : : } 70 : : } 71 : : 72 : 0 : vtag_actions = roc_npc_vtag_actions_get(npc); 73 [ # # ]: 0 : if (vtag_actions) { 74 [ # # ]: 0 : if (flow->nix_intf == ROC_NPC_INTF_RX) { 75 : 0 : vtag_actions = roc_npc_vtag_actions_sub_return(npc, 1); 76 [ # # ]: 0 : if (vtag_actions == 0) { 77 : 0 : dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_VLAN_STRIP_F; 78 : 0 : cn20k_eth_set_rx_function(eth_dev); 79 : : } 80 : : } 81 : : } 82 : : 83 [ # # ]: 0 : if (cnxk_eth_macsec_sess_get_by_sess(dev, (void *)flow) != NULL) { 84 : 0 : rc = cnxk_mcs_flow_destroy(dev, (void *)flow); 85 [ # # ]: 0 : if (rc < 0) 86 : 0 : rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, 87 : : "Failed to free mcs flow"); 88 : 0 : return rc; 89 : : } 90 : : 91 : 0 : mtr_id = flow->mtr_id; 92 : 0 : rc = cnxk_flow_destroy(eth_dev, flow, error); 93 [ # # ]: 0 : if (!rc && mtr_id != ROC_NIX_MTR_ID_INVALID) { 94 : 0 : rc = cnxk_mtr_destroy(eth_dev, mtr_id); 95 [ # # ]: 0 : if (rc) { 96 : 0 : rte_flow_error_set(error, ENXIO, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, 97 : : "Meter attached to this flow does not exist"); 98 : : } 99 : : } 100 : : return rc; 101 : : }