net/enic: flow API skeleton
[dpdk.git] / drivers / net / enic / enic_flow.c
1 /*
2  * Copyright (c) 2017, Cisco Systems, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  */
31
32 #include <errno.h>
33 #include <rte_log.h>
34 #include <rte_ethdev.h>
35 #include <rte_flow_driver.h>
36 #include <rte_ether.h>
37 #include <rte_ip.h>
38 #include <rte_udp.h>
39
40 #include "enic_compat.h"
41 #include "enic.h"
42 #include "vnic_dev.h"
43 #include "vnic_nic.h"
44
45 #ifdef RTE_LIBRTE_ENIC_DEBUG_FLOW
46 #define FLOW_TRACE() \
47         RTE_LOG(DEBUG, PMD, "%s()\n", __func__)
48 #define FLOW_LOG(level, fmt, args...) \
49         RTE_LOG(level, PMD, fmt, ## args)
50 #else
51 #define FLOW_TRACE() do { } while (0)
52 #define FLOW_LOG(level, fmt, args...) do { } while (0)
53 #endif
54
55 /*
56  * The following functions are callbacks for Generic flow API.
57  */
58
59 /**
60  * Validate a flow supported by the NIC.
61  *
62  * @see rte_flow_validate()
63  * @see rte_flow_ops
64  */
65 static int
66 enic_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attrs,
67                    const struct rte_flow_item pattern[],
68                    const struct rte_flow_action actions[],
69                    struct rte_flow_error *error)
70 {
71         (void)dev;
72         (void)attrs;
73         (void)pattern;
74         (void)actions;
75         (void)error;
76
77         FLOW_TRACE();
78
79         return 0;
80 }
81
82 /**
83  * Create a flow supported by the NIC.
84  *
85  * @see rte_flow_create()
86  * @see rte_flow_ops
87  */
88 static struct rte_flow *
89 enic_flow_create(struct rte_eth_dev *dev,
90                  const struct rte_flow_attr *attrs,
91                  const struct rte_flow_item pattern[],
92                  const struct rte_flow_action actions[],
93                  struct rte_flow_error *error)
94 {
95         (void)dev;
96         (void)attrs;
97         (void)pattern;
98         (void)actions;
99         (void)error;
100
101         FLOW_TRACE();
102
103         return NULL;
104 }
105
106 /**
107  * Destroy a flow supported by the NIC.
108  *
109  * @see rte_flow_destroy()
110  * @see rte_flow_ops
111  */
112 static int
113 enic_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
114                   __rte_unused struct rte_flow_error *error)
115 {
116         (void)dev;
117         (void)flow;
118
119         FLOW_TRACE();
120
121         return 0;
122 }
123
124 /**
125  * Flush all flows on the device.
126  *
127  * @see rte_flow_flush()
128  * @see rte_flow_ops
129  */
130 static int
131 enic_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
132 {
133         (void)dev;
134         (void)error;
135
136         FLOW_TRACE();
137
138         return 0;
139 }
140
141 /**
142  * Flow callback registration.
143  *
144  * @see rte_flow_ops
145  */
146 const struct rte_flow_ops enic_flow_ops = {
147         .validate = enic_flow_validate,
148         .create = enic_flow_create,
149         .destroy = enic_flow_destroy,
150         .flush = enic_flow_flush,
151 };