8c504fc69c6fcd9e8960d98edc2953545dac7ae0
[dpdk.git] / drivers / net / mlx5 / windows / mlx5_flow_os.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4
5 #include "mlx5_flow_os.h"
6 #include "mlx5_win_ext.h"
7
8 /**
9  * Verify the @p attributes will be correctly understood by the NIC and store
10  * them in the @p flow if everything is correct.
11  *
12  * @param[in] dev
13  *   Pointer to dev struct.
14  * @param[in] attributes
15  *   Pointer to flow attributes
16  * @param[in] external
17  *   This flow rule is created by request external to PMD.
18  * @param[out] error
19  *   Pointer to error structure.
20  *
21  * @return
22  *   - 0 on success and non root table (not a valid option for Windows yet).
23  *   - 1 on success and root table.
24  *   - a negative errno value otherwise and rte_errno is set.
25  */
26 int
27 mlx5_flow_os_validate_flow_attributes(struct rte_eth_dev *dev,
28                                       const struct rte_flow_attr *attributes,
29                                       bool external,
30                                       struct rte_flow_error *error)
31 {
32         int ret = 1;
33
34         RTE_SET_USED(dev);
35         RTE_SET_USED(external);
36         if (attributes->group)
37                 return rte_flow_error_set(error, ENOTSUP,
38                                           RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
39                                           NULL,
40                                           "groups are not supported");
41         if (attributes->priority)
42                 return rte_flow_error_set(error, ENOTSUP,
43                                           RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
44                                           NULL,
45                                           "priorities are not supported");
46         if (attributes->transfer)
47                 return rte_flow_error_set(error, ENOTSUP,
48                                           RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
49                                           NULL,
50                                           "transfer not supported");
51         if (!(attributes->ingress))
52                 return rte_flow_error_set(error, ENOTSUP,
53                                           RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
54                                           NULL, "must specify ingress only");
55         return ret;
56 }
57
58 /**
59  * Create flow matcher in a flow table.
60  *
61  * @param[in] ctx
62  *   Pointer to relevant device context.
63  * @param[in] attr
64  *   Pointer to relevant attributes.
65  * @param[in] table
66  *   Pointer to table object.
67  * @param[out] matcher
68  *   Pointer to a valid flow matcher object on success, NULL otherwise.
69  *
70  * @return
71  *   0 on success, or errno on failure.
72  */
73 int
74 mlx5_flow_os_create_flow_matcher(void *ctx,
75                                  void *attr,
76                                  void *table,
77                                  void **matcher)
78 {
79         RTE_SET_USED(ctx);
80         RTE_SET_USED(attr);
81         RTE_SET_USED(table);
82         *matcher = NULL;
83         rte_errno = ENOTSUP;
84         return -rte_errno;
85 }
86
87 /**
88  * Destroy flow matcher.
89  *
90  * @param[in] matcher
91  *   Pointer to matcher object to destroy.
92  *
93  * @return
94  *   0 on success, or the value of errno on failure.
95  */
96 int
97 mlx5_flow_os_destroy_flow_matcher(void *matcher)
98 {
99         RTE_SET_USED(matcher);
100         rte_errno = ENOTSUP;
101         return -rte_errno;
102 }
103
104 /**
105  * Create flow action: dest_devx_tir
106  *
107  * @param[in] tir
108  *   Pointer to DevX tir object
109  * @param[out] action
110  *   Pointer to a valid action on success, NULL otherwise.
111  *
112  * @return
113  *   0 on success, or errno on failure.
114  */
115 int
116 mlx5_flow_os_create_flow_action_dest_devx_tir(struct mlx5_devx_obj *tir,
117                                               void **action)
118 {
119         RTE_SET_USED(tir);
120         *action = NULL;
121         rte_errno = ENOTSUP;
122         return -rte_errno;
123 }
124
125 /**
126  * Destroy flow action.
127  *
128  * @param[in] action
129  *   Pointer to action object to destroy.
130  *
131  * @return
132  *   0 on success, or the value of errno on failure.
133  */
134 int
135 mlx5_flow_os_destroy_flow_action(void *action)
136 {
137         RTE_SET_USED(action);
138         rte_errno = ENOTSUP;
139         return -rte_errno;
140 }
141
142 /**
143  * Create flow rule.
144  *
145  * @param[in] matcher
146  *   Pointer to match mask structure.
147  * @param[in] match_value
148  *   Pointer to match value structure.
149  * @param[in] num_actions
150  *   Number of actions in flow rule.
151  * @param[in] actions
152  *   Pointer to array of flow rule actions.
153  * @param[out] flow
154  *   Pointer to a valid flow rule object on success, NULL otherwise.
155  *
156  * @return
157  *   0 on success, or errno on failure.
158  */
159 int
160 mlx5_flow_os_create_flow(void *matcher, void *match_value,
161                          size_t num_actions,
162                          void *actions[], void **flow)
163 {
164         RTE_SET_USED(matcher);
165         RTE_SET_USED(match_value);
166         RTE_SET_USED(num_actions);
167         RTE_SET_USED(actions);
168         *flow = NULL;
169         rte_errno = ENOTSUP;
170         return -rte_errno;
171 }
172
173 /**
174  * Destroy flow rule.
175  *
176  * @param[in] drv_flow_ptr
177  *   Pointer to flow rule object.
178  *
179  * @return
180  *   0 on success, errno on failure.
181  */
182 int
183 mlx5_flow_os_destroy_flow(void *drv_flow_ptr)
184 {
185         RTE_SET_USED(dev_flow_ptr);
186         rte_errno = ENOTSUP;
187         return -rte_errno;
188 }