1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2020 Marvell.
4 #include <cnxk_rte_flow.h>
5 #include "cn10k_rte_flow.h"
6 #include "cn10k_ethdev.h"
10 cn10k_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)
15 struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
16 int mark_actions = 0, vtag_actions = 0;
17 struct roc_npc *npc = &dev->npc;
18 struct roc_npc_flow *flow;
20 flow = cnxk_flow_create(eth_dev, attr, pattern, actions, error);
24 mark_actions = roc_npc_mark_actions_get(npc);
27 dev->rx_offload_flags |= NIX_RX_OFFLOAD_MARK_UPDATE_F;
28 cn10k_eth_set_rx_function(eth_dev);
31 vtag_actions = roc_npc_vtag_actions_get(npc);
34 dev->rx_offload_flags |= NIX_RX_OFFLOAD_VLAN_STRIP_F;
35 cn10k_eth_set_rx_function(eth_dev);
38 return (struct rte_flow *)flow;
42 cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
43 struct rte_flow_error *error)
45 struct roc_npc_flow *flow = (struct roc_npc_flow *)rte_flow;
46 struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
47 int mark_actions = 0, vtag_actions = 0;
48 struct roc_npc *npc = &dev->npc;
50 mark_actions = roc_npc_mark_actions_get(npc);
52 mark_actions = roc_npc_mark_actions_sub_return(npc, 1);
53 if (mark_actions == 0) {
54 dev->rx_offload_flags &= ~NIX_RX_OFFLOAD_MARK_UPDATE_F;
55 cn10k_eth_set_rx_function(eth_dev);
59 vtag_actions = roc_npc_vtag_actions_get(npc);
61 if (flow->nix_intf == ROC_NPC_INTF_RX) {
62 vtag_actions = roc_npc_vtag_actions_sub_return(npc, 1);
63 if (vtag_actions == 0) {
64 dev->rx_offload_flags &=
65 ~NIX_RX_OFFLOAD_VLAN_STRIP_F;
66 cn10k_eth_set_rx_function(eth_dev);
71 return cnxk_flow_destroy(eth_dev, flow, error);