net/softnic: map flow attribute to pipeline table
[dpdk.git] / drivers / net / softnic / rte_eth_softnic_flow.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #include "rte_eth_softnic_internals.h"
6 #include "rte_eth_softnic.h"
7
8 int
9 flow_attr_map_set(struct pmd_internals *softnic,
10                 uint32_t group_id,
11                 int ingress,
12                 const char *pipeline_name,
13                 uint32_t table_id)
14 {
15         struct pipeline *pipeline;
16         struct flow_attr_map *map;
17
18         if (group_id >= SOFTNIC_FLOW_MAX_GROUPS ||
19                         pipeline_name == NULL)
20                 return -1;
21
22         pipeline = softnic_pipeline_find(softnic, pipeline_name);
23         if (pipeline == NULL ||
24                         table_id >= pipeline->n_tables)
25                 return -1;
26
27         map = (ingress) ? &softnic->flow.ingress_map[group_id] :
28                 &softnic->flow.egress_map[group_id];
29         strcpy(map->pipeline_name, pipeline_name);
30         map->table_id = table_id;
31         map->valid = 1;
32
33         return 0;
34 }
35
36 struct flow_attr_map *
37 flow_attr_map_get(struct pmd_internals *softnic,
38                 uint32_t group_id,
39                 int ingress)
40 {
41         if (group_id >= SOFTNIC_FLOW_MAX_GROUPS)
42                 return NULL;
43
44         return (ingress) ? &softnic->flow.ingress_map[group_id] :
45                 &softnic->flow.egress_map[group_id];
46 }