Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(C) 2020 Marvell. 3 : : */ 4 : : #include <cnxk_flow.h> 5 : : #include "cn9k_ethdev.h" 6 : : #include "cn9k_flow.h" 7 : : #include "cn9k_rx.h" 8 : : 9 : : struct rte_flow * 10 : 0 : cn9k_flow_create(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr, 11 : : const struct rte_flow_item pattern[], 12 : : const struct rte_flow_action actions[], 13 : : struct rte_flow_error *error) 14 : : { 15 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 16 : 0 : struct roc_npc *npc = &dev->npc; 17 : : struct roc_npc_flow *flow; 18 : : int vtag_actions = 0; 19 : : int mark_actions; 20 : : 21 : 0 : flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error); 22 [ # # ]: 0 : if (!flow) 23 : : return NULL; 24 : : 25 : 0 : mark_actions = roc_npc_mark_actions_get(npc); 26 : : 27 [ # # ]: 0 : if (mark_actions) { 28 : 0 : dev->rx_offload_flags |= NIX_RX_OFFLOAD_MARK_UPDATE_F; 29 : 0 : cn9k_eth_set_rx_function(eth_dev); 30 : : } 31 : : 32 : 0 : vtag_actions = roc_npc_vtag_actions_get(npc); 33 : : 34 [ # # ]: 0 : if (vtag_actions) { 35 : 0 : dev->rx_offload_flags |= NIX_RX_OFFLOAD_VLAN_STRIP_F; 36 : 0 : cn9k_eth_set_rx_function(eth_dev); 37 : : } 38 : : 39 : : return (struct rte_flow *)flow; 40 : : } 41 : : 42 : : int 43 [ # # ]: 0 : cn9k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow, 44 : : struct rte_flow_error *error) 45 : : { 46 : : struct roc_npc_flow *flow = (struct roc_npc_flow *)rte_flow; 47 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 48 : 0 : struct roc_npc *npc = &dev->npc; 49 : : int vtag_actions = 0; 50 : : uint16_t match_id; 51 : : int mark_actions; 52 : : 53 : 0 : match_id = (flow->npc_action >> NPC_RX_ACT_MATCH_OFFSET) & 54 : : NPC_RX_ACT_MATCH_MASK; 55 [ # # ]: 0 : if (match_id) { 56 : 0 : mark_actions = roc_npc_mark_actions_sub_return(npc, 1); 57 [ # # ]: 0 : if (mark_actions == 0) { 58 : 0 : dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_MARK_UPDATE_F; 59 : 0 : cn9k_eth_set_rx_function(eth_dev); 60 : : } 61 : : } 62 : : 63 : 0 : vtag_actions = roc_npc_vtag_actions_get(npc); 64 [ # # ]: 0 : if (vtag_actions) { 65 [ # # ]: 0 : if (flow->nix_intf == ROC_NPC_INTF_RX) { 66 : 0 : vtag_actions = roc_npc_vtag_actions_sub_return(npc, 1); 67 [ # # ]: 0 : if (vtag_actions == 0) { 68 : 0 : dev->rx_offload_flags &= 69 : : ~NIX_RX_OFFLOAD_VLAN_STRIP_F; 70 : 0 : cn9k_eth_set_rx_function(eth_dev); 71 : : } 72 : : } 73 : : } 74 : : 75 : 0 : return cnxk_flow_destroy(eth_dev, flow, error); 76 : : } 77 : : 78 : : int 79 : 0 : cn9k_flow_info_get(struct rte_eth_dev *dev, struct rte_flow_port_info *port_info, 80 : : struct rte_flow_queue_info *queue_info, struct rte_flow_error *err) 81 : : { 82 : : RTE_SET_USED(dev); 83 : : RTE_SET_USED(err); 84 : : 85 : : memset(port_info, 0, sizeof(*port_info)); 86 : : memset(queue_info, 0, sizeof(*queue_info)); 87 : : 88 : 0 : port_info->max_nb_counters = CN9K_NPC_COUNTERS_MAX; 89 : : 90 : 0 : return 0; 91 : : }